in tree/master/cloud/src/solution/Microsoft.Legal.MatterCenter.Web/Startup.cs [405:629]
private void CreateConfig(IHostingEnvironment hostingEnvironment)
{
StringBuilder sb = new StringBuilder();
JsonWriter jw = new JsonTextWriter(new StringWriter(sb));
jw.Formatting = Formatting.Indented;
var configPath = Path.Combine(hostingEnvironment.WebRootPath, "app/config.js");
if (System.IO.File.Exists(configPath))
System.IO.File.Delete(configPath);
var configFile = File.Open(configPath, FileMode.Create);
var configWriter = new StreamWriter(configFile, Encoding.UTF8);
var generalSettingsSection = Configuration.GetSection("General");
var matterSettingsSection = Configuration.GetSection("Matter").GetChildren();
var uploadMessagesSection = Configuration.GetSection("uploadMessages").GetChildren();
var taxonomySettingsSection = Configuration.GetSection("Taxonomy");
var searchSettingsSection = Configuration.GetSection("Search").GetChildren();
var contentTypeSettingsSection = Configuration.GetSection("ContentTypes").GetSection("ManagedColumns").GetChildren();
var contentTypeStampedSettingsSection = Configuration.GetSection("ContentTypes").GetSection("ManagedStampedColumns").GetChildren();
var appInsightsSections = Configuration.GetSection("ApplicationInsights");
var matterSearchColumnPickerSection = Configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForMatter").GetChildren();
var documentSearchColumnPickerSection = Configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetChildren();
configWriter.WriteLine("var configs =");
jw.WriteStartObject();
jw.WritePropertyName("uri");
jw.WriteStartObject();
jw.WritePropertyName("SPOsiteURL");
jw.WriteValue(generalSettingsSection["SiteURL"]);
jw.WritePropertyName("tenant");
jw.WriteValue(generalSettingsSection["Tenant"]);
jw.WritePropertyName("MainURL");
jw.WriteValue(generalSettingsSection["MainURL"]);
jw.WriteEndObject();
jw.WritePropertyName("ADAL");
jw.WriteStartObject();
jw.WritePropertyName("clientId");
jw.WriteValue(generalSettingsSection["ClientId"]);
jw.WritePropertyName("authUserEmail");
jw.WriteValue("");
jw.WriteEndObject();
jw.WritePropertyName("appInsights");
jw.WriteStartObject();
jw.WritePropertyName("instrumentationKey");
jw.WriteValue(appInsightsSections["InstrumentationKey"]);
jw.WritePropertyName("appType");
jw.WriteValue("");
jw.WriteEndObject();
jw.WritePropertyName("global");
jw.WriteStartObject();
jw.WritePropertyName("repositoryUrl");
jw.WriteValue(generalSettingsSection["CentralRepositoryUrl"]);
jw.WritePropertyName("isDevMode");
jw.WriteValue(bool.Parse(generalSettingsSection["IsDevMode"]));
jw.WritePropertyName("isBackwardCompatible");
jw.WriteValue(bool.Parse(generalSettingsSection["IsBackwardCompatible"]));
jw.WritePropertyName("isClientMappedWithHierachy");
jw.WriteValue(bool.Parse(generalSettingsSection["IsClientMappedWithHierachy"]));
jw.WritePropertyName("overwriteDupliacteFileNameWithDateTimeFor");
jw.WriteValue(generalSettingsSection["OverwriteDupliacteFileNameWithDateTimeFor"]);
jw.WriteEndObject();
jw.WritePropertyName("matter");
jw.WriteStartObject();
foreach (var key in matterSettingsSection)
{
//Assuming that all the keys for the matter property bag keys will start with "StampedProperty"
if (key.Key.ToString().ToLower().StartsWith("stampedproperty"))
{
jw.WritePropertyName(key.Key);
jw.WriteValue(key.Value);
}
//Assuming that all the keys for the matter property bag keys will start with "StampedProperty"
if (key.Key.ToString().ToLower().StartsWith("specialcharacterexpression"))
{
jw.WritePropertyName(key.Key);
jw.WriteValue(key.Value);
}
}
jw.WriteEndObject();
jw.WritePropertyName("taxonomy");
jw.WriteStartObject();
jw.WritePropertyName("levels");
jw.WriteValue(taxonomySettingsSection["Levels"]);
jw.WritePropertyName("practiceGroupTermSetName");
jw.WriteValue(taxonomySettingsSection["PracticeGroupTermSetName"]);
jw.WritePropertyName("termGroup");
jw.WriteValue(taxonomySettingsSection["TermGroup"]);
jw.WritePropertyName("clientTermSetName");
jw.WriteValue(taxonomySettingsSection["ClientTermSetName"]);
jw.WritePropertyName("clientCustomPropertiesURL");
jw.WriteValue(taxonomySettingsSection["ClientCustomPropertiesURL"]);
jw.WritePropertyName("clientCustomPropertiesId");
jw.WriteValue(taxonomySettingsSection["ClientCustomPropertiesId"]);
jw.WritePropertyName("subAreaOfLawCustomContentTypeProperty");
jw.WriteValue(taxonomySettingsSection["SubAreaOfLawContentTypeTemplates"]);
jw.WritePropertyName("subAreaOfLawDocumentContentTypeProperty");
jw.WriteValue(taxonomySettingsSection["SubAreaOfLawDocumentTemplates"]);
jw.WritePropertyName("matterProvisionExtraPropertiesContentType");
jw.WriteValue(taxonomySettingsSection["MatterProvisionExtraPropertiesContentType"]);
jw.WriteEndObject();
jw.WritePropertyName("search");
jw.WriteStartObject();
jw.WritePropertyName("Schema");
jw.WriteValue(Configuration.GetSection("Search").GetSection("Schema").Value);
foreach (var key in searchSettingsSection)
{
//Assuming that all the keys for the matter property bag keys will start with "StampedProperty"
if (key.Key.ToString().ToLower().StartsWith("managedproperty"))
{
jw.WritePropertyName(key.Key);
jw.WriteValue(key.Value);
}
}
jw.WritePropertyName("searchColumnsUIPickerForMatter");
jw.WriteStartObject();
foreach (var key in matterSearchColumnPickerSection)
{
jw.WritePropertyName(key.Key);
jw.WriteStartObject();
foreach (var subKey in Configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForMatter").GetSection(key.Key).GetChildren())
{
jw.WritePropertyName(subKey.Key);
var propVal = subKey.Value.Trim();
var propKey = subKey.Key.Trim();
switch (propKey)
{
case "displayInUI":
case "defaultVisibleInGrid":
case "displayInFlyOut":
case "enableHiding":
case "enableColumnMenu":
case "displayInDashboard":
jw.WriteValue(bool.Parse(propVal));
break;
case "position":
jw.WriteValue(int.Parse(propVal));
break;
default:
jw.WriteValue(propVal);
break;
}
}
jw.WriteEndObject();
}
jw.WriteEndObject();
jw.WritePropertyName("searchColumnsUIPickerForDocument");
jw.WriteStartObject();
foreach (var key in documentSearchColumnPickerSection)
{
jw.WritePropertyName(key.Key);
jw.WriteStartObject();
foreach (var subKey in Configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection(key.Key).GetChildren())
{
jw.WritePropertyName(subKey.Key);
var propVal = subKey.Value.Trim();
var propKey = subKey.Key.Trim();
switch (propKey)
{
case "displayInUI":
case "defaultVisibleInGrid":
case "displayInFlyOut":
case "enableHiding":
case "enableColumnMenu":
case "displayInDashboard":
case "suppressRemoveSort":
jw.WriteValue(bool.Parse(propVal));
break;
case "position":
jw.WriteValue(int.Parse(propVal));
break;
default:
jw.WriteValue(propVal);
break;
}
}
jw.WriteEndObject();
}
jw.WriteEndObject();
jw.WriteEndObject();
jw.WritePropertyName("contentTypes");
jw.WriteStartObject();
jw.WritePropertyName("managedColumns");
jw.WriteStartObject();
foreach (var key in contentTypeSettingsSection)
{
jw.WritePropertyName(key.Key);
jw.WriteValue(key.Value);
}
jw.WriteEndObject();
jw.WritePropertyName("managedStampedColumns");
jw.WriteStartObject();
foreach (var key in contentTypeStampedSettingsSection)
{
jw.WritePropertyName(key.Key);
jw.WriteValue(key.Value);
}
jw.WriteEndObject();
jw.WriteEndObject();
jw.WriteEndObject();
configWriter.Write(sb.ToString());
configWriter.Dispose();
}