public static void UpdateData() { List<SlideHeader> headers = new List<SlideHeader>(); List<string> strengths = new List<string>(); List<string> challenges = new List<string>(); bool readHeaders = false; bool readStrengths = false; bool readChallenges = false; string connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";", Path.Combine(Application.StartupPath, _sourceFileName)); OleDbConnection connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + _sheetName + "$]", connection); ; DataTable dataTable = new DataTable(); ; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string rowValue1 = row[0].ToString().Trim(); string rowValue2 = string.Empty; if (dataTable.Columns.Count > 1) { if (row[1] != null) rowValue2 = row[1].ToString(); } if (rowValue1.Equals(_slideHeader)) { readHeaders = true; readStrengths = false; readChallenges = false; continue; } else if (rowValue1.Equals(_strengths)) { readHeaders = false; readStrengths = true; readChallenges = false; continue; } else if (rowValue1.Equals(_challenges)) { readHeaders = false; readStrengths = false; readChallenges = true; continue; } if (!string.IsNullOrEmpty(rowValue1)) { if (readHeaders) { SlideHeader header = new SlideHeader(); header.Value = rowValue1; header.IsDefault = rowValue2.ToString().Trim().ToLower().Equals("d"); headers.Add(header); } else if (readStrengths) strengths.Add(rowValue1); else if (readChallenges) challenges.Add(rowValue1); } } headers.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = InteropClasses.WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); strengths.Sort((x, y) => InteropClasses.WinAPIHelper.StrCmpLogicalW(x, y)); challenges.Sort((x, y) => InteropClasses.WinAPIHelper.StrCmpLogicalW(x, y)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); //Save XML StringBuilder xml = new StringBuilder(); xml.AppendLine("<" + _sheetName + ">"); foreach (SlideHeader header in headers) { xml.Append(@"<SlideHeader "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("IsDefault = \"" + header.IsDefault + "\" "); xml.AppendLine(@"/>"); } foreach (string strength in strengths) { xml.Append(@"<Strength "); xml.Append("Value = \"" + strength.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (string challenge in challenges) { xml.Append(@"<Challenge "); xml.Append("Value = \"" + challenge.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</" + _sheetName + ">"); var xmlPath = Path.Combine(Application.StartupPath, _destinationFileName); using (StreamWriter sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); } }
public static void UpdateData() { var headers = new List<SlideHeader>(); var demos = new List<string>(); var hhis = new List<string>(); var geographies = new List<string>(); string connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";", Path.Combine(Application.StartupPath, TargetCustomerSourceFileName)); var connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { OleDbDataAdapter dataAdapter; DataTable dataTable; //Load Headers dataAdapter = new OleDbDataAdapter("SELECT * FROM [Headers$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) headers.Add(title); } headers.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Demos dataAdapter = new OleDbDataAdapter("SELECT * FROM [Demos$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string demo = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(demo)) demos.Add(demo); } demos.Sort((x, y) => WinAPIHelper.StrCmpLogicalW(x, y)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load HHI dataAdapter = new OleDbDataAdapter("SELECT * FROM [HHI$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string hhi = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(hhi)) hhis.Add(hhi); } hhis.Sort((x, y) => WinAPIHelper.StrCmpLogicalW(x, y)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Geography dataAdapter = new OleDbDataAdapter("SELECT * FROM [Geography$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string geography = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(geography)) geographies.Add(geography); } geographies.Sort((x, y) => WinAPIHelper.StrCmpLogicalW(x, y)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); //Save XML var xml = new StringBuilder(); xml.AppendLine("<TargetCustomers>"); foreach (SlideHeader header in headers) { xml.Append(@"<SlideHeader "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("IsDefault = \"" + header.IsDefault + "\" "); xml.AppendLine(@"/>"); } foreach (string demo in demos) { xml.Append(@"<Demo "); xml.Append("Value = \"" + demo.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (string hhi in hhis) { xml.Append(@"<HHI "); xml.Append("Value = \"" + hhi.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (string geography in geographies) { xml.Append(@"<Geography "); xml.Append("Value = \"" + geography.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</TargetCustomers>"); var xmlPath = Path.Combine(Application.StartupPath, TargetCustomerDestinationFileName); using (var sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); } }
public static void UpdateData() { List<SlideHeader> headers = new List<SlideHeader>(); List<string> benefits = new List<string>(); string connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";", Path.Combine(Application.StartupPath, ClientBenefitsSourceFileName)); OleDbConnection connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { OleDbDataAdapter dataAdapter; DataTable dataTable; //Load Headers dataAdapter = new OleDbDataAdapter("SELECT * FROM [Slide Headers$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { SlideHeader title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) headers.Add(title); } headers.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = InteropClasses.WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Benefits dataAdapter = new OleDbDataAdapter("SELECT * FROM [Benefits$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string benefit = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(benefit)) benefits.Add(benefit); } benefits.Sort((x, y) => InteropClasses.WinAPIHelper.StrCmpLogicalW(x, y)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); //Save XML StringBuilder xml = new StringBuilder(); xml.AppendLine("<ClientBenefits>"); foreach (SlideHeader header in headers) { xml.Append(@"<SlideHeader "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("IsDefault = \"" + header.IsDefault + "\" "); xml.AppendLine(@"/>"); } foreach (string benefit in benefits) { xml.Append(@"<Benefit "); xml.Append("Value = \"" + benefit.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</ClientBenefits>"); var xmlPath = Path.Combine(Application.StartupPath, ClientBenefitsDestinationFileName); using (StreamWriter sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); } }
public static void UpdateData() { var slideHeaders = new List<SlideHeader>(); var positioningPoints = new List<string>(); var lenghts = new List<string>(); var clientTypes = new List<string>(); var flexFlightDatesAllowed = false; var customDemos = new List<string>(); var statuses = new List<SlideHeader>(); var stations = new List<Station>(); var broadcastTemplates = new List<BroadcastMonthTemplate>(); var defaultWeeklyScheduleSettings = new ScheduleSectionSettings(); var defaultMonthlyScheduleSettings = new ScheduleSectionSettings(); var defaultSnapshotSettings = new SnapshotSettings(); var defaultSnapshotSummarySettings = new SnapshotSummarySettings(); var defaultOptionsSettings = new OptionsSettings(); var defaultOptionsSummarySettings = new OptionsSummarySettings(); var defaultBroadcastCalendarSettings = new CalendarToggleSettings(); var defaultCustomCalendarSettings = new CalendarToggleSettings(); var connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";", Path.Combine(Application.StartupPath, SourceFileName)); var connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State != ConnectionState.Open) return; OleDbDataAdapter dataAdapter; DataTable dataTable; //Load Headers And Positioning Points dataAdapter = new OleDbDataAdapter("SELECT * FROM [Headers-Positioning Point$]", connection); dataTable = new DataTable(); bool loadHeaders = true; bool loadPositioningPoint = false; slideHeaders.Clear(); positioningPoints.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Positioning Point")) { loadHeaders = false; loadPositioningPoint = true; continue; } if (loadHeaders) { var title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) slideHeaders.Add(title); } if (loadPositioningPoint) { var positioningPoint = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(positioningPoint)) positioningPoints.Add(positioningPoint); } } slideHeaders.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = 1; return result; }); positioningPoints.Sort(WinAPIHelper.StrCmpLogicalW); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Statuses dataAdapter = new OleDbDataAdapter("SELECT * FROM [File-Status$]", connection); dataTable = new DataTable(); statuses.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var status = new SlideHeader(); status.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) status.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(status.Value)) statuses.Add(status); } statuses.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Lenghts lenghts.Clear(); dataAdapter = new OleDbDataAdapter("SELECT * FROM [Length$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string lenght = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(lenght)) lenghts.Add(lenght); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Client Types dataAdapter = new OleDbDataAdapter("SELECT * FROM [Client Type$]", connection); dataTable = new DataTable(); clientTypes.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var clientType = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(clientType)) clientTypes.Add(clientType); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Date Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Date$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString().Trim(), out temp)) flexFlightDatesAllowed = temp; break; } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Dayparts GetDayparts(connection); dataAdapter = new OleDbDataAdapter("SELECT * FROM [Dayparts$]", connection); dataTable = new DataTable(); try { var rowIndex = 0; dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 1) foreach (DataRow row in dataTable.Rows) { string code = row[1].ToString().Trim(); var daypart = _dayparts.FirstOrDefault(x => x.Name.Equals(code)); if (daypart != null) { daypart.Code = row[0].ToString().Trim(); daypart.Index = rowIndex; } rowIndex++; } _dayparts.Sort((x, y) => x.Index.CompareTo(y.Index)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Custom Demos dataAdapter = new OleDbDataAdapter("SELECT * FROM [Custom Demos$]", connection); dataTable = new DataTable(); customDemos.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var customDemo = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(customDemo)) customDemos.Add(customDemo); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Stations dataAdapter = new OleDbDataAdapter("SELECT * FROM [Stations$]", connection); dataTable = new DataTable(); stations.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 1) foreach (DataRow row in dataTable.Rows) { var station = new Station(); station.Name = row[0].ToString().Trim(); string filePath = Path.Combine(Application.StartupPath, ImageSourceFolder, row[1].ToString().Trim()); if (File.Exists(filePath)) station.Logo = new Bitmap(filePath); if (!string.IsNullOrEmpty(station.Name)) stations.Add(station); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load View Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Toggle Defaults$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 1) { var header = "Weekly Schedule"; foreach (DataRow row in dataTable.Rows) { var rowTag = row[0].ToString().Trim(); var rowValue = row[1].ToString().Trim(); if (rowTag.StartsWith("*")) header = rowTag.Replace("*", String.Empty); else if(!String.IsNullOrEmpty(rowTag)) { switch (header) { case "Weekly Schedule": defaultWeeklyScheduleSettings.ApplyValue(rowTag, rowValue); break; case "Monthly Schedule": defaultMonthlyScheduleSettings.ApplyValue(rowTag, rowValue); break; case "Snapshot-Tab": defaultSnapshotSettings.ApplyValue(rowTag, rowValue); break; case "Snapshot-Summary Slide": defaultSnapshotSummarySettings.ApplyValue(rowTag, rowValue); break; case "Options-Tab": defaultOptionsSettings.ApplyValue(rowTag, rowValue); break; case "Options-Summary Slide": defaultOptionsSummarySettings.ApplyValue(rowTag, rowValue); break; case "Calendar1": defaultBroadcastCalendarSettings.ApplyValue(rowTag, rowValue); break; case "Calendar2": defaultCustomCalendarSettings.ApplyValue(rowTag, rowValue); break; } } else break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); //Load TV Programs _programs.Clear(); connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";", Path.Combine(Application.StartupPath, SourceFileName)); connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State != ConnectionState.Open) return; foreach (var daypart in _dayparts) { dataAdapter = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}$]", daypart.Name), connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 4) foreach (var row in dataTable.Rows.OfType<DataRow>().Skip(3)) { var program = new TVProgram(); program.Station = row[0].ToString().Trim(); program.Name = row[1].ToString().Trim(); program.Day = row[2].ToString().Trim(); program.Time = row[3].ToString().Trim(); program.Daypart = daypart.Code; for (int i = 4; i < 44; i++) { if (dataTable.Columns.Count <= i) continue; if (row[i] == null) continue; var demo = new Demo(); demo.Source = dataTable.Rows[0][i].ToString().Trim(); demo.DemoType = dataTable.Rows[1][i].ToString().Trim().ToUpper().Equals("IMP") ? DemoType.Imp : DemoType.Rtg; demo.Name = dataTable.Rows[2][i].ToString().Trim(); demo.Value = row[i].ToString().Trim(); if (!string.IsNullOrEmpty(demo.Name) && !string.IsNullOrEmpty(demo.Value)) program.Demos.Add(demo); } if (!string.IsNullOrEmpty(program.Name)) _programs.Add(program); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } } connection.Close(); broadcastTemplates.AddRange(BroadcastMonthTemplate.Load(Path.Combine(Application.StartupPath, TemplatesFilePath))); //Save XML var xml = new StringBuilder(); xml.AppendLine("<TVStrategy>"); foreach (var header in slideHeaders) { xml.Append(@"<SlideHeader "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("IsDefault = \"" + header.IsDefault + "\" "); xml.AppendLine(@"/>"); } foreach (var status in statuses) { xml.Append(@"<Status "); xml.Append("Value = \"" + status.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var positionPoint in positioningPoints) { xml.Append(@"<Statement "); xml.Append("Value = \"" + positionPoint.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var lenght in lenghts) { xml.Append(@"<Lenght "); xml.Append("Value = \"" + lenght.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var daypart in _dayparts) { xml.Append(@"<Daypart "); xml.Append("Name = \"" + daypart.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Code = \"" + daypart.Code.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } var converter = TypeDescriptor.GetConverter(typeof(Bitmap)); foreach (var station in stations) { xml.Append(@"<Station "); xml.Append("Name = \"" + station.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Logo = \"" + Convert.ToBase64String((byte[])converter.ConvertTo(station.Logo, typeof(byte[]))).Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var clientType in clientTypes) { xml.Append(@"<ClientType "); xml.Append("Value = \"" + clientType.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(String.Format(@"<FlexFlightDatesAllowed>{0}</FlexFlightDatesAllowed> ", flexFlightDatesAllowed)); foreach (var customDemo in customDemos) { xml.Append(@"<CustomDemo "); xml.Append("Value = \"" + customDemo.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var program in _programs) { xml.Append(@"<Program "); xml.Append("Name = \"" + program.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Station = \"" + program.Station.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Daypart = \"" + program.Daypart.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Day = \"" + program.Day.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Time = \"" + program.Time.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@">"); foreach (var demo in program.Demos) { xml.Append(@"<Demo "); xml.Append("Source = \"" + demo.Source.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("DemoType = \"" + (int)demo.DemoType + "\" "); xml.Append("Name = \"" + demo.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Value = \"" + demo.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</Program>"); } broadcastTemplates.ForEach(bt => xml.AppendLine(bt.Serialize())); xml.AppendLine(@"<DefaultWeeklyScheduleSettings>" + defaultWeeklyScheduleSettings.Serialize() + @"</DefaultWeeklyScheduleSettings>"); xml.AppendLine(@"<DefaultMonthlyScheduleSettings>" + defaultMonthlyScheduleSettings.Serialize() + @"</DefaultMonthlyScheduleSettings>"); xml.AppendLine(@"<DefaultSnapshotSettings>" + defaultSnapshotSettings.Serialize() + @"</DefaultSnapshotSettings>"); xml.AppendLine(@"<DefaultSnapshotSummarySettings>" + defaultSnapshotSummarySettings.Serialize() + @"</DefaultSnapshotSummarySettings>"); xml.AppendLine(@"<DefaultOptionsSettings>" + defaultOptionsSettings.Serialize() + @"</DefaultOptionsSettings>"); xml.AppendLine(@"<DefaultOptionsSummarySettings>" + defaultOptionsSummarySettings.Serialize() + @"</DefaultOptionsSummarySettings>"); xml.AppendLine(@"<DefaultBroadcastCalendarSettings>" + defaultBroadcastCalendarSettings.Serialize() + @"</DefaultBroadcastCalendarSettings>"); xml.AppendLine(@"<DefaultCustomCalendarSettings>" + defaultCustomCalendarSettings.Serialize() + @"</DefaultCustomCalendarSettings>"); xml.AppendLine(@"</TVStrategy>"); var xmlPath = Path.Combine(Application.StartupPath, DestinationFileName); using (var sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); }
public static void UpdateData() { var slideHeaders = new List<SlideHeader>(); var sites = new List<SlideHeader>(); var strengths = new List<SlideHeader>(); var products = new List<Product>(); var statuses = new List<SlideHeader>(); var defaultFormula = String.Empty; var lockedMode = false; var pricingStrategies = new List<string>(); var columnPositions = new List<string>(); var specialLinksEnable = false; var specialLinksGroupName = String.Empty; Image specialLinksGroupLogo = null; var specialLinksBrowsers = new List<string>(); var specialLinkButtons = new List<SpecialLinkButton>(); var targetingRecords = new List<DigitalProductInfo>(); var richMediaRecords = new List<DigitalProductInfo>(); var defaultHomeViewSettings = new HomeViewSettings(); var defaultDigitalProductSettings = new DigitalProductSettings(); var defaultDigitalProductPackageSettings = new DigitalPackageSettings(); var defaultDigitalStandalonePackageSettings = new DigitalPackageSettings(); var controlsConfiguration = new DigitalControlsConfiguration(); var connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";", Path.Combine(Application.StartupPath, SourceFileName)); var connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { //Load Headers var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Headers$]", connection); var dataTable = new DataTable(); slideHeaders.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) slideHeaders.Add(title); } slideHeaders.Sort((x, y) => { var result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = 1; return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Statuses dataAdapter = new OleDbDataAdapter("SELECT * FROM [File-Status$]", connection); dataTable = new DataTable(); statuses.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var status = new SlideHeader(); status.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) status.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(status.Value)) statuses.Add(status); } statuses.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Sites dataAdapter = new OleDbDataAdapter("SELECT * FROM [Sites$]", connection); dataTable = new DataTable(); sites.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var site = new SlideHeader(); site.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) site.IsDefault = row[1].ToString().Trim().Equals("d", StringComparison.OrdinalIgnoreCase); if (!string.IsNullOrEmpty(site.Value)) sites.Add(site); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Strengths dataAdapter = new OleDbDataAdapter("SELECT * FROM [Strengths$]", connection); dataTable = new DataTable(); strengths.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var strength = new SlideHeader(); strength.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) strength.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(strength.Value)) strengths.Add(strength); } strengths.Sort((x, y) => { var result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Default Formula dataAdapter = new OleDbDataAdapter("SELECT * FROM [WebFormula$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 2) foreach (DataRow row in dataTable.Rows) { if (row[0] != null && row[1] != null && row[1].ToString().Trim().ToLower().Equals("d")) { defaultFormula = row[0].ToString(); break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Locked Mode dataAdapter = new OleDbDataAdapter("SELECT * FROM [LockedMode$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { bool temp; if (row[0] == null) continue; var rowValue = row[0].ToString(); if (!String.IsNullOrEmpty(rowValue) && !rowValue.StartsWith("*") && Boolean.TryParse(rowValue, out temp)) { lockedMode = temp; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Pricing Strategy dataAdapter = new OleDbDataAdapter("SELECT * FROM [PricingStrategy$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0] == null) continue; var rowValue = row[0].ToString(); if (!String.IsNullOrEmpty(rowValue) && !pricingStrategies.Contains(rowValue)) pricingStrategies.Add(rowValue); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Position Column dataAdapter = new OleDbDataAdapter("SELECT * FROM [PositionColumn$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0] == null) continue; var rowValue = row[0].ToString(); if (!String.IsNullOrEmpty(rowValue) && !columnPositions.Contains(rowValue)) columnPositions.Add(rowValue); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Special Links Group dataAdapter = new OleDbDataAdapter("SELECT * FROM [SpecialRBNLinks$A1:A2]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0] == null) continue; var rowValue = row[0].ToString(); bool temp; if (!String.IsNullOrEmpty(rowValue) && Boolean.TryParse(rowValue, out temp)) { specialLinksEnable = temp; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } dataAdapter = new OleDbDataAdapter("SELECT * FROM [SpecialRBNLinks$A4:A5]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var rowValue = row[0]?.ToString(); if (String.IsNullOrEmpty(rowValue)) continue; specialLinksGroupName = rowValue; var imageFilePath = Path.Combine(Application.StartupPath, SpecialButtonsImageSourceFolder, "!RibbonGroup.png"); if (File.Exists(imageFilePath)) specialLinksGroupLogo = new Bitmap(imageFilePath); break; } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } dataAdapter = new OleDbDataAdapter("SELECT * FROM [SpecialRBNLinks$A7:E8]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var colCount = dataTable.Columns.Count; for (var i = 0; i < colCount; i++) { if (row[i] == null) continue; var rowValue = row[i].ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; specialLinksBrowsers.Add(rowValue); } break; } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Special Link Buttons dataAdapter = new OleDbDataAdapter("SELECT * FROM [SpecialRBNLinks$A10:J30]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); foreach (DataRow row in dataTable.Rows) { var specialButton = new SpecialLinkButton(); var colCount = dataTable.Columns.Count; for (var i = 0; i < colCount; i++) { if (row[i] == null) continue; var rowValue = row[i].ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; switch (i) { case 0: specialButton.Name = rowValue; break; case 1: specialButton.Type = rowValue; break; case 2: specialButton.Tooltip = rowValue; break; case 3: var imageFilePath = Path.Combine(Application.StartupPath, SpecialButtonsImageSourceFolder, rowValue); if (File.Exists(imageFilePath)) specialButton.Image = new Bitmap(imageFilePath); break; default: specialButton.Paths.Add(rowValue); break; } } if (!String.IsNullOrEmpty(specialButton.Name) && !String.IsNullOrEmpty(specialButton.Type) && specialButton.Paths.Any()) specialLinkButtons.Add(specialButton); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Targeting dataAdapter = new OleDbDataAdapter("SELECT * FROM [TGT_Popup$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); foreach (DataRow row in dataTable.Rows) { var digitalProductInfo = new DigitalProductInfo(); var colCount = dataTable.Columns.Count; for (var i = 0; i < colCount; i++) { if (row[i] == null) continue; var rowValue = row[i].ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; switch (i) { case 0: digitalProductInfo.Group = rowValue; break; case 1: { bool temp; if (Boolean.TryParse(rowValue, out temp)) digitalProductInfo.Selected = temp; } break; default: digitalProductInfo.Phrases.Add(rowValue); break; } } if (!String.IsNullOrEmpty(digitalProductInfo.Group) && digitalProductInfo.Phrases.Any()) targetingRecords.Add(digitalProductInfo); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Rich Media dataAdapter = new OleDbDataAdapter("SELECT * FROM [RM_Popup$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); foreach (DataRow row in dataTable.Rows) { var digitalProductInfo = new DigitalProductInfo(); var colCount = dataTable.Columns.Count; for (var i = 0; i < colCount; i++) { if (row[i] == null) continue; var rowValue = row[i].ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; switch (i) { case 0: digitalProductInfo.Group = rowValue; break; case 1: { bool temp; if (Boolean.TryParse(rowValue, out temp)) digitalProductInfo.Selected = temp; } break; default: digitalProductInfo.Phrases.Add(rowValue); break; } } if (!String.IsNullOrEmpty(digitalProductInfo.Group) && digitalProductInfo.Phrases.Any()) richMediaRecords.Add(digitalProductInfo); } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Categories GetCategories(connection); dataAdapter = new OleDbDataAdapter("SELECT * FROM [Categories$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); int i = 0; if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 4) foreach (DataRow row in dataTable.Rows) { var originalName = row[0].ToString().Trim(); var schemaName = originalName .Replace(".", "#") .Replace("!", "_") .Replace("`", "_") .Replace("[", "(") .Replace("]", ")"); var category = _categories.FirstOrDefault(x => x.Name.Equals(schemaName)); if (category != null) { category.Name = originalName; category.Order = i; category.TooltipTitle = row[1].ToString().Trim(); category.TooltipValue = row[2].ToString().Trim(); var filePath = Path.Combine(Application.StartupPath, CategoryImageSourceFolder, row[3].ToString().Trim()); if (File.Exists(filePath)) category.Logo = new Bitmap(filePath); } i++; } _categories.Sort((x, y) => x.Order.CompareTo(y.Order)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Products products.Clear(); foreach (var category in _categories) { dataAdapter = new OleDbDataAdapter( String.Format("SELECT * FROM [{0}$]", category.Name .Replace("!", "") ) , connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 12) foreach (DataRow row in dataTable.Rows) { var product = new Product(); product.SubCategory = row[0].ToString().Trim(); product.Name = row[1].ToString().Trim(); product.RateType = row[2].ToString().Trim(); product.Rate = row[3].ToString().Trim(); product.Width = row[4].ToString().Trim(); product.Height = row[5].ToString().Trim(); product.EnableTarget = row[6].ToString().Trim().ToLower() == "e"; product.EnableLocation = row[7].ToString().Trim().ToLower() == "e"; product.EnableRichMedia = row[8].ToString().Trim().ToLower() == "e"; product.Overview = row[9].ToString().Trim(); product.DefaultWebsite = row[10] != null ? row[10].ToString().Trim() : null; product.EnableRate = row[11].ToString().Trim().ToLower() == "e"; product.Category = category; if (!string.IsNullOrEmpty(product.Name)) products.Add(product); } } catch(Exception ex) { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } } //Load Home Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Home$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count >= 3) foreach (DataRow row in dataTable.Rows) { var optionName = row[0] != null ? row[0].ToString().Trim() : null; if (String.IsNullOrEmpty(optionName)) continue; switch (optionName) { case "Ad Dimensions": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultHomeViewSettings.EnableDigitalDimensions = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultHomeViewSettings.ShowDigitalDimensions = temp; } break; case "Location": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultHomeViewSettings.EnableDigitalLocation = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultHomeViewSettings.ShowDigitalLocation = temp; } break; case "Pricing Strategy": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultHomeViewSettings.EnableDigitalStrategy = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultHomeViewSettings.ShowDigitalStrategy = temp; } break; case "Rich Media": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultHomeViewSettings.EnableDigitalRichMedia = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultHomeViewSettings.ShowDigitalRichMedia = temp; } break; case "Targeting": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultHomeViewSettings.EnableDigitalTargeting = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultHomeViewSettings.ShowDigitalTargeting = temp; } break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Digital Product Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [WebSlide$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count >= 3) foreach (DataRow row in dataTable.Rows) { var optionName = row[0] != null ? row[0].ToString().Trim() : null; if (String.IsNullOrEmpty(optionName)) continue; switch (optionName) { case "Strategy": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductSettings.EnableCategory = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductSettings.ShowCategory = temp; } break; case "Campaign Dates": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductSettings.EnableFlightDates = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductSettings.ShowFlightDates = temp; } break; case "Duration": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductSettings.EnableDuration = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductSettings.ShowDuration = temp; } break; case "Pricing Default": { int temp; if (row[2] != null && Int32.TryParse(row[2].ToString(), out temp)) defaultDigitalProductSettings.DefaultPricing = temp; } break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Digital Package Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [DigPkgA$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count >= 3) foreach (DataRow row in dataTable.Rows) { var optionName = row[0]?.ToString().Trim(); if (String.IsNullOrEmpty(optionName)) continue; switch (optionName) { case "Category": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableCategory = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowCategory = temp; } break; case "Group": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableGroup = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowGroup = temp; } break; case "Product": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableProduct = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowProduct = temp; } break; case "Impressions": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableImpressions = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowImpressions = temp; } break; case "CPM": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableCPM = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowCPM = temp; } break; case "Rate": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableRate = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowRate = temp; } break; case "Investment": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableInvestment = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowInvestment = temp; } break; case "Schedule Info": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableInfo = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowInfo = temp; } break; case "Campaign": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableLocation = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowLocation = temp; } break; case "Screenshot": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalProductPackageSettings.EnableScreenshot = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalProductPackageSettings.ShowScreenshot = temp; } break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Digital Standalone Package Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [DigPkgB$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Columns.Count >= 3) foreach (DataRow row in dataTable.Rows) { var optionName = row[0]?.ToString().Trim(); if (String.IsNullOrEmpty(optionName)) continue; switch (optionName) { case "Category": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableCategory = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowCategory = temp; } break; case "Group": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableGroup = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowGroup = temp; } break; case "Product": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableProduct = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowProduct = temp; } break; case "Impressions": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableImpressions = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowImpressions = temp; } break; case "CPM": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableCPM = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowCPM = temp; } break; case "Rate": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableRate = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowRate = temp; } break; case "Investment": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableInvestment = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowInvestment = temp; } break; case "Schedule Info": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableInfo = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowInfo = temp; } break; case "Campaign": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableLocation = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowLocation = temp; } break; case "Screenshot": { bool temp; if (row[1] != null && Boolean.TryParse(row[1].ToString(), out temp)) defaultDigitalStandalonePackageSettings.EnableScreenshot = temp; if (row[2] != null && Boolean.TryParse(row[2].ToString(), out temp)) defaultDigitalStandalonePackageSettings.ShowScreenshot = temp; } break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";", Path.Combine(Application.StartupPath, SourceFileName)); connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State != ConnectionState.Open) return; //Load Digital Tab Controls Configuration dataAdapter = new OleDbDataAdapter("SELECT * FROM [DigitalRBNLabels$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); var groupName = String.Empty; var groupValues = new List<string>(); foreach (DataRow row in dataTable.Rows) { var rowValue = row[0]?.ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; if (rowValue.Contains("*")) { if (!String.IsNullOrEmpty(groupName) && groupValues.Any()) controlsConfiguration.ApplyValues(groupName, groupValues); groupName = rowValue.Replace("*", ""); groupValues.Clear(); } else groupValues.Add(rowValue); } if (!String.IsNullOrEmpty(groupName) && groupValues.Any()) controlsConfiguration.ApplyValues(groupName, groupValues); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Digital Section Controls Configuration dataAdapter = new OleDbDataAdapter("SELECT * FROM [DigitalSubScheduleLabels$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); var groupName = String.Empty; var groupValues = new List<string>(); foreach (DataRow row in dataTable.Rows) { var rowValue = row[0]?.ToString().Trim(); if (String.IsNullOrEmpty(rowValue)) continue; if (rowValue.Contains("*")) { if (!String.IsNullOrEmpty(groupName) && groupValues.Any()) controlsConfiguration.ApplyValues(groupName, groupValues); groupName = rowValue.Replace("*", ""); groupValues.Clear(); } else groupValues.Add(rowValue); } if (!String.IsNullOrEmpty(groupName) && groupValues.Any()) controlsConfiguration.ApplyValues(groupName, groupValues); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); } //Save XML var converter = TypeDescriptor.GetConverter(typeof(Bitmap)); var xml = new StringBuilder(); xml.AppendLine("<OnlineStrategy>"); foreach (var header in slideHeaders) { xml.Append(@"<Header "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var status in statuses) { xml.Append(@"<Status "); xml.Append("Value = \"" + status.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var site in sites) { xml.Append(@"<Site "); xml.Append("Value = \"" + site.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var strength in strengths) { xml.Append(@"<Strength "); xml.Append("Value = \"" + strength.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine("<DefaultFormula>" + defaultFormula.Replace(@"&", "&").Replace("\"", """) + "</DefaultFormula>"); xml.AppendLine("<LockedMode>" + lockedMode + "</LockedMode>"); foreach (var pricingStrategy in pricingStrategies) { xml.Append(@"<PricingStrategy "); xml.Append("Value = \"" + pricingStrategy.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var columnPosition in columnPositions) { xml.Append(@"<PositionColumn "); xml.Append("Value = \"" + columnPosition.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine("<SpecialLinksEnable>" + specialLinksEnable + "</SpecialLinksEnable>"); xml.AppendLine("<SpecialButtonsGroupName>" + specialLinksGroupName.Replace(@"&", "&").Replace("\"", """) + "</SpecialButtonsGroupName>"); if (specialLinksGroupLogo != null) xml.AppendLine("<SpecialButtonsGroupLogo>" + Convert.ToBase64String((byte[])converter.ConvertTo(specialLinksGroupLogo, typeof(byte[]))).Replace(@"&", "&").Replace("\"", """) + "</SpecialButtonsGroupLogo>"); foreach (var browser in specialLinksBrowsers) xml.AppendLine("<Browser>" + browser + "</Browser>"); foreach (var specialLinkButton in specialLinkButtons) { xml.Append(@"<SpecialButton "); xml.Append("Name = \"" + specialLinkButton.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Type = \"" + specialLinkButton.Type.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Tooltip = \"" + specialLinkButton.Tooltip.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Image = \"" + Convert.ToBase64String((byte[])converter.ConvertTo(specialLinkButton.Image, typeof(byte[]))).Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@">"); foreach (var path in specialLinkButton.Paths) xml.AppendLine(String.Format(@"<Path>{0}</Path>", path.Replace(@"&", "&").Replace("\"", """))); xml.AppendLine(@"</SpecialButton>"); } foreach (var productInfo in targetingRecords) xml.AppendLine(String.Format(@"<Targeting>{0}</Targeting>", productInfo.Serialize())); foreach (var productInfo in richMediaRecords) xml.AppendLine(String.Format(@"<RichMedia>{0}</RichMedia>", productInfo.Serialize())); foreach (var category in _categories.Where(c => !String.IsNullOrEmpty(c.Name) && !String.IsNullOrEmpty(c.TooltipTitle) && !String.IsNullOrEmpty(c.TooltipValue) && c.Logo != null)) { xml.Append(@"<Category "); xml.Append("Name = \"" + category.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("TooltipTitle = \"" + category.TooltipTitle.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("TooltipValue = \"" + category.TooltipValue.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Logo = \"" + Convert.ToBase64String((byte[])converter.ConvertTo(category.Logo, typeof(byte[]))).Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (var product in products) { xml.Append(@"<Product "); xml.Append("Category = \"" + product.Category.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("SubCategory = \"" + product.SubCategory.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Name = \"" + product.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("RateType = \"" + product.RateType.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Rate = \"" + product.Rate.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Width = \"" + product.Width.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Height = \"" + product.Height.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("EnableTarget = \"" + product.EnableTarget + "\" "); xml.Append("EnableLocation = \"" + product.EnableLocation + "\" "); xml.Append("EnableRichMedia = \"" + product.EnableRichMedia + "\" "); xml.Append("EnableRate = \"" + product.EnableRate + "\" "); xml.Append("Overview = \"" + product.Overview.Replace(@"&", "&").Replace("\"", """) + "\" "); if (!String.IsNullOrEmpty(product.DefaultWebsite)) xml.Append("DefaultWebsite = \"" + product.DefaultWebsite.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(String.Format(@"<DefaultHomeViewSettings>{0}</DefaultHomeViewSettings>", defaultHomeViewSettings.Serialize())); xml.AppendLine(String.Format(@"<DefaultDigitalProductSettings>{0}</DefaultDigitalProductSettings>", defaultDigitalProductSettings.Serialize())); xml.AppendLine(String.Format(@"<DefaultDigitalProductPackageSettings>{0}</DefaultDigitalProductPackageSettings>", defaultDigitalProductPackageSettings.Serialize())); xml.AppendLine(String.Format(@"<DefaultDigitalStandalonePackageSettings>{0}</DefaultDigitalStandalonePackageSettings>", defaultDigitalStandalonePackageSettings.Serialize())); xml.AppendLine(String.Format(@"<DigitalControlsConfiguration>{0}</DigitalControlsConfiguration>", Convert.ToBase64String(Encoding.Unicode.GetBytes(JsonConvert.SerializeObject(controlsConfiguration, Formatting.None, new JsonImageConverter()))))); xml.AppendLine(@"</OnlineStrategy>"); var xmlPath = Path.Combine(Application.StartupPath, DestinationFileName); using (var sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); }
public static void UpdateData() { var titles = new List<SlideHeader>(); var quotes = new List<Quote>(); string connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";", Path.Combine(Application.StartupPath, CoverSourceFileName)); var connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { OleDbDataAdapter dataAdapter; DataTable dataTable; //Load Titles dataAdapter = new OleDbDataAdapter("SELECT * FROM [Titles$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { var title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) titles.Add(title); } titles.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } //Load Quotes dataAdapter = new OleDbDataAdapter("SELECT * FROM [Quotes$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string value = row[0].ToString().Trim(); string author = row[1].ToString().Trim(); if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(author)) quotes.Add(new Quote(value, author)); } quotes.Sort((x, y) => WinAPIHelper.StrCmpLogicalW(x.Value, y.Value)); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } connection.Close(); //Save XML var xml = new StringBuilder(); xml.AppendLine("<CoverSlide>"); foreach (SlideHeader title in titles) { xml.Append(@"<SlideHeader "); xml.Append("Value = \"" + title.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("IsDefault = \"" + title.IsDefault + "\" "); xml.AppendLine(@"/>"); } foreach (Quote quote in quotes) { xml.Append(@"<Quote "); xml.Append("Value = \"" + quote.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Author = \"" + quote.Author.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</CoverSlide>"); var xmlPath = Path.Combine(Application.StartupPath, CoverDestinationFileName); using (var sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); AppManager.Instance.ShowInformation("Data was updated."); } }
public static void UpdateData() { bool tempBool; int tempInt; bool allowToLoad; var slideHeaders = new List<SlideHeader>(); var publications = new List<Publication>(); var adSizes = new List<AdSize>(); var notes = new List<NameCodePair>(); var clientTypes = new List<string>(); var sections = new List<Section>(); var mechanicals = new List<MechanicalType>(); var deadlines = new List<string>(); var statuses = new List<SlideHeader>(); var shareUnits = new List<ShareUnit>(); string selectedNotesBorderValue = string.Empty; string selectedSectionsBorderValue = string.Empty; var defaultHomeViewSettings = new HomeViewSettings(); var defaultPrintScheduleViewSettings = new PrintScheduleViewSettings(); var defaultPublicationBasicOverviewSettings = new PublicationBasicOverviewSettings(); var defaultPublicationMultiSummarySettings = new PublicationMultiSummarySettings(); var defaultSnapshotViewSettings = new SnapshotViewSettings(); var defaultDetailedGridColumnState = new GridColumnsState(); var defaultDetailedGridAdNotesState = new AdNotesState(); var defaultDetailedGridSlideBulletsState = new SlideBulletsState(); var defaultDetailedGridSlideHeaderState = new SlideHeaderState(); var defaultMultiGridColumnState = new GridColumnsState(); var defaultMultiGridAdNotesState = new AdNotesState(); var defaultMultiGridSlideBulletsState = new SlideBulletsState(); var defaultMultiGridSlideHeaderState = new SlideHeaderState(); var defaultCalendarViewSettings = new CalendarViewSettings(); string connnectionString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";", Path.Combine(Application.StartupPath, SourceFileName)); var connection = new OleDbConnection(connnectionString); try { connection.Open(); } catch { AppManager.Instance.ShowWarning("Couldn't open source file"); return; } if (connection.State == ConnectionState.Open) { DataTable dataTable; #region Load Headers OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM [Headers$]", connection); dataTable = new DataTable(); bool loadHeaders = false; slideHeaders.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Ad Schedule Slide Headers")) { loadHeaders = true; continue; } if (loadHeaders) { var title = new SlideHeader(); title.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) title.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(title.Value)) slideHeaders.Add(title); } } slideHeaders.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = WinAPIHelper.StrCmpLogicalW(x.Value, y.Value); return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Statuses dataAdapter = new OleDbDataAdapter("SELECT * FROM [File-Status$]", connection); dataTable = new DataTable(); loadHeaders = false; statuses.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*File-Status")) { loadHeaders = true; continue; } if (loadHeaders) { var status = new SlideHeader(); status.Value = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) status.IsDefault = row[1].ToString().Trim().ToLower().Equals("d"); if (!string.IsNullOrEmpty(status.Value)) statuses.Add(status); } } statuses.Sort((x, y) => { int result = y.IsDefault.CompareTo(x.IsDefault); if (result == 0) result = 1; return result; }); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Publications dataAdapter = new OleDbDataAdapter("SELECT * FROM [Publications$]", connection); dataTable = new DataTable(); bool loadPublications = false; publications.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 16) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("User-Entry")) { loadPublications = true; continue; } if (loadPublications) { var publication = new Publication(); publication.Name = row[0].ToString().Trim(); if (row[1] != null) publication.SortOrder = row[1].ToString().Trim(); if (row[2] != null) publication.Abbreviation = row[2].ToString().Trim(); if (row[3] != null) publication.BigLogo = row[3].ToString().Trim(); if (row[4] != null) publication.LittleLogo = row[4].ToString().Trim(); if (row[5] != null) publication.TinyLogo = row[5].ToString().Trim(); if (row[6] != null) publication.DailyCirculation = row[6].ToString().Trim(); if (row[7] != null) publication.DailyReadership = row[7].ToString().Trim(); if (row[8] != null) publication.SundayCirculation = row[8].ToString().Trim(); if (row[9] != null) publication.SundayReadership = row[9].ToString().Trim(); if (row[10] != null) publication.AllowSundaySelect = row[10].ToString().Trim().ToLower().Equals("y"); if (row[11] != null) publication.AllowMondaySelect = row[11].ToString().Trim().ToLower().Equals("y"); if (row[12] != null) publication.AllowTuesdaySelect = row[12].ToString().Trim().ToLower().Equals("y"); if (row[13] != null) publication.AllowWednesdaySelect = row[13].ToString().Trim().ToLower().Equals("y"); if (row[14] != null) publication.AllowThursdaySelect = row[14].ToString().Trim().ToLower().Equals("y"); if (row[15] != null) publication.AllowFridaySelect = row[15].ToString().Trim().ToLower().Equals("y"); if (row[16] != null) publication.AllowSaturdaySelect = row[16].ToString().Trim().ToLower().Equals("y"); if (!string.IsNullOrEmpty(publication.Name)) publications.Add(publication); } } publications.Sort((x, y) => x.SortOrder.CompareTo(y.SortOrder) == 0 ? WinAPIHelper.StrCmpLogicalW(x.Name, y.Name) : (string.IsNullOrEmpty(x.SortOrder) ? "z" : x.SortOrder).CompareTo((string.IsNullOrEmpty(y.SortOrder) ? "z" : y.SortOrder))); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load AdSizes dataAdapter = new OleDbDataAdapter("SELECT * FROM [Ad-Sizes$]", connection); dataTable = new DataTable(); adSizes.Clear(); try { dataAdapter.Fill(dataTable); foreach (DataColumn column in dataTable.Columns) { var groupName = String.Empty; foreach (DataRow row in dataTable.Rows) { var rowValue = row[column] as String; if (String.IsNullOrEmpty(rowValue)) break; if (rowValue.StartsWith("*")) { groupName = rowValue.Replace("*", String.Empty); continue; } if (String.IsNullOrEmpty(groupName)) continue; adSizes.Add(new AdSize { Group = groupName, Name = rowValue }); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load ShareUnits dataAdapter = new OleDbDataAdapter("SELECT * FROM [Share-Units$]", connection); dataTable = new DataTable(); bool loadShareUnits = false; shareUnits.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count >= 6) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Rate Card")) { loadShareUnits = true; continue; } if (loadShareUnits) { var shareUnit = new ShareUnit(); if (row[0] != null) shareUnit.RateCard = row[0].ToString().Trim(); if (row[1] != null) shareUnit.PercentOfPage = row[1].ToString().Trim(); if (row[2] != null) shareUnit.Width = row[2].ToString().Trim(); if (row[3] != null) shareUnit.WidthMeasureUnit = row[3].ToString().Trim(); if (row[4] != null) shareUnit.Height = row[4].ToString().Trim(); if (row[5] != null) shareUnit.HeightMeasureUnit = row[5].ToString().Trim(); if (!string.IsNullOrEmpty(shareUnit.RateCard)) shareUnits.Add(shareUnit); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Notes dataAdapter = new OleDbDataAdapter("SELECT * FROM [Notes$]", connection); dataTable = new DataTable(); bool loadNotes = false; notes.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Notes Library")) { loadNotes = true; if (dataTable.Columns.Count >= 2) selectedNotesBorderValue = row[1].ToString().Trim(); continue; } if (loadNotes) { var note = new NameCodePair(); note.Name = row[0].ToString().Trim(); if (dataTable.Columns.Count >= 2) note.Code = row[1].ToString().Trim(); if (!string.IsNullOrEmpty(note.Name)) notes.Add(note); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Client Types dataAdapter = new OleDbDataAdapter("SELECT * FROM [Client Type$]", connection); dataTable = new DataTable(); bool loadClientTypes = false; clientTypes.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Client Type")) { loadClientTypes = true; continue; } if (loadClientTypes) { string clientType = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(clientType)) clientTypes.Add(clientType); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Sections dataAdapter = new OleDbDataAdapter("SELECT * FROM [Sections$]", connection); dataTable = new DataTable(); bool loadSections = false; sections.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Sections")) { loadSections = true; if (dataTable.Columns.Count >= 2) selectedSectionsBorderValue = row[1].ToString().Trim(); continue; } if (loadSections) { var section = new Section(); section.Name = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) section.Abbreviation = row[1].ToString().Trim(); if (!string.IsNullOrEmpty(section.Name)) sections.Add(section); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Mechanicals dataAdapter = new OleDbDataAdapter("SELECT * FROM [Mechanicals$]", connection); dataTable = new DataTable(); mechanicals.Clear(); MechanicalType mechanicalType = null; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Contains("*") && !row[0].ToString().Trim().Contains("*Comment:")) { if (mechanicalType != null) mechanicals.Add(mechanicalType); mechanicalType = new MechanicalType(); mechanicalType.Name = row[0].ToString().Replace("*", ""); continue; } if (mechanicalType != null) { var mechanicalItem = new MechanicalItem(); mechanicalItem.Name = row[0].ToString().Trim(); if (dataTable.Columns.Count > 1) if (row[1] != null) mechanicalItem.Value = row[1].ToString().Trim(); if (!string.IsNullOrEmpty(mechanicalItem.Name)) mechanicalType.Items.Add(mechanicalItem); } } if (mechanicalType != null) mechanicals.Add(mechanicalType); } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Deadlines dataAdapter = new OleDbDataAdapter("SELECT * FROM [Deadlines$]", connection); dataTable = new DataTable(); bool loadDeadlines = false; deadlines.Clear(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { if (row[0].ToString().Trim().Equals("*Deadlines")) { loadDeadlines = true; continue; } if (loadDeadlines) { string deadline = row[0].ToString().Trim(); if (!string.IsNullOrEmpty(deadline)) deadlines.Add(deadline); } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Home Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [HOME$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Acct #": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultHomeViewSettings.EnableAccountNumber = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultHomeViewSettings.ShowAccountNumber = tempBool; break; case "Logo": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultHomeViewSettings.EnableLogo = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultHomeViewSettings.ShowLogo = tempBool; break; case "Code": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultHomeViewSettings.EnableCode = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultHomeViewSettings.ShowCode = tempBool; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultHomeViewSettings.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultHomeViewSettings.ShowDelivery = tempBool; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultHomeViewSettings.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultHomeViewSettings.ShowReadership = tempBool; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Print Schedule Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Print Schedule$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Column Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnablePCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultPCI = tempBool; break; case "Flat": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableFlat = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultFlat = tempBool; break; case "Share": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableShare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultShare = tempBool; break; case "BW": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableBlackWhite = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultBlackWhite = tempBool; break; case "Spot Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableSpotColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultSpotColor = tempBool; break; case "Full Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableFullColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultFullColor = tempBool; break; case "Per Ad": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableCostPerAd = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultCostPerAd = tempBool; break; case "% of Ad": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnablePercentOfAd = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultPercentOfAd = tempBool; break; case "Included": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableColorIncluded = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultColorIncluded = tempBool; break; case "PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableCostPerInch = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultCostPerInch = tempBool; break; case "Textbox": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.EnableMechanicals = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.DefaultMechanicals = tempBool; break; case "Before Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPrintScheduleViewSettings.CalcDiscountBeforeColor = tempBool; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Publication BasicOverview Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Overview$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Column Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowSquare = tempBool; break; case "Columns X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowDimensions = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowPercentOfPage = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowPageSize = tempBool; break; case "Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowColor = tempBool; break; case "Total Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableTotalInserts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowTotalInserts = tempBool; break; case "Total Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableTotalSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowTotalSquare = tempBool; break; case "Avg Ad Rate": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableAvgAdCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowAvgAdCost = tempBool; break; case "Avg PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableAvgPCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowAvgPCI = tempBool; break; case "Total Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableDiscounts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowDiscounts = tempBool; break; case "Total Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableInvestment = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowInvestment = tempBool; break; case "Flight Dates": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableFlightDates2 = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowFlightDates2 = tempBool; break; case "Specific Days": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableDates = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowDates = tempBool; break; case "Custom Field": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.EnableComments = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationBasicOverviewSettings.ShowComments = tempBool; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Publication Multi Summary Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Analysis$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Total Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableTotalInserts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowTotalInserts = tempBool; break; case "Dimensions": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowDimensions = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowPageSize = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowPercentOfPage = tempBool; break; case "Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableTotalColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowTotalColor = tempBool; break; case "BW Avg Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableAvgAdCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowAvgAdCost = tempBool; break; case "FINAL Avg Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableAvgFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowAvgFinalCost = tempBool; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableDiscounts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowDiscounts = tempBool; break; case "Sections": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowSection = tempBool; break; case "Flight Dates": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableFlightDates = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowFlightDates = tempBool; break; case "Specific Days": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableDates = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowDates = tempBool; break; case "Custom Field": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.EnableComments = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultPublicationMultiSummarySettings.ShowComments = tempBool; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Snapshot Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Snapshot$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Logo": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableLogo = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowLogo = tempBool; break; case "Total Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableTotalInserts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowTotalInserts = tempBool; break; case "Investment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableTotalFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowTotalFinalCost = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowPageSize = tempBool; break; case "Columns X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowDimensions = tempBool; break; case "Total Column Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowSquare = tempBool; break; case "Total Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableTotalSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowTotalSquare = tempBool; break; case "Final Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableAvgFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowAvgFinalCost = tempBool; break; case "Total Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableTotalColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowTotalColor = tempBool; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableTotalDiscounts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowTotalDiscounts = tempBool; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowReadership = tempBool; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowDelivery = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultSnapshotViewSettings.ShowPercentOfPage = tempBool; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Detailed Grid Column State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Detailed Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Print Grid Columns")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "ID": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableID = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowID = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.IDPosition = tempInt; break; case "INS#": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableIndex = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowIndex = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.IndexPosition = tempInt; break; case "Date": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableDate = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowDate = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.DatePosition = tempInt; break; case "Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowColor = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.ColorPosition = tempInt; break; case "Section": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowSection = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.SectionPosition = tempInt; break; case "PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnablePCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowPCI = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.PCIPosition = tempInt; break; case "Total Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowFinalCost = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.FinalCostPosition = tempInt; break; case "Publication": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnablePublication = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowPublication = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.PublicationPosition = tempInt; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowPercentOfPage = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.PercentOfPagePosition = tempInt; break; case "BW Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowCost = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.CostPosition = tempInt; break; case "Col x In": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowDimensions = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.DimensionsPosition = tempInt; break; case "Mechanicals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableMechanicals = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowMechanicals = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.MechanicalsPosition = tempInt; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowDelivery = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.DeliveryPosition = tempInt; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableDiscount = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowDiscount = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.DiscountPosition = tempInt; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowPageSize = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.PageSizePosition = tempInt; break; case "Total Col. In.": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowSquare = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.SquarePosition = tempInt; break; case "Deadline": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableDeadline = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowDeadline = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.DeadlinePosition = tempInt; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowReadership = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridColumnState.ReadershipPosition = tempInt; break; case "Select up to 4 Ad-Notes": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.EnableAdNotes = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridColumnState.ShowAdNotes = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Detailed Grid Ad Notes State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Detailed Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*AdNotes")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Comment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableComments = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowComments = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionComments = tempInt; break; case "Section": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowSection = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionSection = tempInt; break; case "Mechanicals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableMechanicals = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowMechanicals = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionMechanicals = tempInt; break; case "Col. X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowDimensions = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionDimensions = tempInt; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowDelivery = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionDelivery = tempInt; break; case "Publication": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnablePublication = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowPublication = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionPublication = tempInt; break; case "Total Col In": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowSquare = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionSquare = tempInt; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowPageSize = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionPageSize = tempInt; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowPercentOfPage = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionPercentOfPage = tempInt; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowReadership = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionReadership = tempInt; break; case "Deadline": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.EnableDeadline = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridAdNotesState.ShowDeadline = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultDetailedGridAdNotesState.PositionDeadline = tempInt; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Detailed Grid Slide Bullets State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Detailed Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Info Totals")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Show Slide Totals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableSlideBullets = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowSlideBullets = tempBool; break; case "Last Slide": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableOnlyOnLastSlide = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowOnlyOnLastSlide = tempBool; break; case "Total Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableTotalInserts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowTotalInserts = tempBool; break; case "Investment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableTotalFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowTotalFinalCost = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowPageSize = tempBool; break; case "Col. X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowDimensions = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowPercentOfPage = tempBool; break; case "Total Col. In.": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableColumnInches = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowColumnInches = tempBool; break; case "Total Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableTotalSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowTotalSquare = tempBool; break; case "BW Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableAvgAdCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowAvgAdCost = tempBool; break; case "Final Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableAvgFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowAvgFinalCost = tempBool; break; case "Avg PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableAvgPCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowAvgPCI = tempBool; break; case "Total Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableTotalColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowTotalColor = tempBool; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableDiscounts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowDiscounts = tempBool; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowDelivery = tempBool; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowReadership = tempBool; break; case "Show Signature": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.EnableSignature = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideBulletsState.ShowSignature = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Detailed Grid Slide Header State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Detailed Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Info Headers")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Slide Header Options": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableSlideInfo = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowSlideInfo = tempBool; break; case "Slide Title": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableSlideHeader = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowSlideHeader = tempBool; break; case "Advertiser": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableAdvertiser = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowAdvertiser = tempBool; break; case "Decision Maker": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableDecisionMaker = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowDecisionMaker = tempBool; break; case "Presentation Date": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnablePresentationDate = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowPresentationDate = tempBool; break; case "Schedule Window": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableFlightDates = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowFlightDates = tempBool; break; case "Publication Name": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableName = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowName = tempBool; break; case "Publication Logo": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.EnableLogo1 = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultDetailedGridSlideHeaderState.ShowLogo1 = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Multi Grid Column State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Logo Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Print Grid Columns")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "ID": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableID = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowID = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.IDPosition = tempInt; break; case "INS#": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableIndex = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowIndex = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.IndexPosition = tempInt; break; case "Date": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableDate = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowDate = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.DatePosition = tempInt; break; case "Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowColor = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.ColorPosition = tempInt; break; case "Section": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowSection = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.SectionPosition = tempInt; break; case "PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnablePCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowPCI = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.PCIPosition = tempInt; break; case "Total Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowFinalCost = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.FinalCostPosition = tempInt; break; case "Publication": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnablePublication = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowPublication = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.PublicationPosition = tempInt; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowPercentOfPage = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.PercentOfPagePosition = tempInt; break; case "BW Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowCost = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.CostPosition = tempInt; break; case "Col x In": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowDimensions = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.DimensionsPosition = tempInt; break; case "Mechanicals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableMechanicals = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowMechanicals = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.MechanicalsPosition = tempInt; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowDelivery = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.DeliveryPosition = tempInt; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableDiscount = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowDiscount = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.DiscountPosition = tempInt; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowPageSize = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.PageSizePosition = tempInt; break; case "Total Col. In.": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowSquare = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.SquarePosition = tempInt; break; case "Deadline": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableDeadline = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowDeadline = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.DeadlinePosition = tempInt; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowReadership = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridColumnState.ReadershipPosition = tempInt; break; case "Select up to 4 Ad-Notes": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.EnableAdNotes = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridColumnState.ShowAdNotes = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Multi Grid Ad Notes State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Logo Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*AdNotes")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Comment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableComments = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowComments = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionComments = tempInt; break; case "Section": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowSection = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionSection = tempInt; break; case "Mechanicals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableMechanicals = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowMechanicals = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionMechanicals = tempInt; break; case "Col. X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowDimensions = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionDimensions = tempInt; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowDelivery = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionDelivery = tempInt; break; case "Publication": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnablePublication = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowPublication = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionPublication = tempInt; break; case "Total Col In": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowSquare = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionSquare = tempInt; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowPageSize = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionPageSize = tempInt; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowPercentOfPage = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionPercentOfPage = tempInt; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowReadership = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionReadership = tempInt; break; case "Deadline": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.EnableDeadline = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridAdNotesState.ShowDeadline = tempBool; if (row[3] != null) if (int.TryParse(row[3].ToString().Trim(), out tempInt)) defaultMultiGridAdNotesState.PositionDeadline = tempInt; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Multi Grid Slide Bullets State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Logo Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Info Totals")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Show Slide Totals": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableSlideBullets = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowSlideBullets = tempBool; break; case "Last Slide": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableOnlyOnLastSlide = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowOnlyOnLastSlide = tempBool; break; case "Total Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableTotalInserts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowTotalInserts = tempBool; break; case "Investment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableTotalFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowTotalFinalCost = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowPageSize = tempBool; break; case "Col. X Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableDimensions = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowDimensions = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowPercentOfPage = tempBool; break; case "Total Col. In.": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableColumnInches = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowColumnInches = tempBool; break; case "Total Inches": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableTotalSquare = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowTotalSquare = tempBool; break; case "BW Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableAvgAdCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowAvgAdCost = tempBool; break; case "Final Ad Cost": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableAvgFinalCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowAvgFinalCost = tempBool; break; case "Avg PCI": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableAvgPCI = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowAvgPCI = tempBool; break; case "Total Color": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableTotalColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowTotalColor = tempBool; break; case "Discounts": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableDiscounts = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowDiscounts = tempBool; break; case "Delivery": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableDelivery = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowDelivery = tempBool; break; case "Readership": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableReadership = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowReadership = tempBool; break; case "Show Signature": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.EnableSignature = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideBulletsState.ShowSignature = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Multi Grid Slide Header State dataAdapter = new OleDbDataAdapter("SELECT * FROM [Logo Grid$]", connection); dataTable = new DataTable(); allowToLoad = false; try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); if (header.Contains("*")) { if (header.Equals("*Info Headers")) allowToLoad = true; else allowToLoad = false; continue; } if (allowToLoad) { switch (header) { case "Slide Header Options": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableSlideInfo = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowSlideInfo = tempBool; break; case "Slide Title": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableSlideHeader = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowSlideHeader = tempBool; break; case "Advertiser": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableAdvertiser = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowAdvertiser = tempBool; break; case "Decision Maker": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableDecisionMaker = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowDecisionMaker = tempBool; break; case "Presentation Date": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnablePresentationDate = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowPresentationDate = tempBool; break; case "Schedule Window": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableFlightDates = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowFlightDates = tempBool; break; case "Publication Name": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableName = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowName = tempBool; break; case "Publication Logo": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.EnableLogo1 = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultMultiGridSlideHeaderState.ShowLogo1 = tempBool; break; } } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion #region Load Default Calendar Settings dataAdapter = new OleDbDataAdapter("SELECT * FROM [Calendar$]", connection); dataTable = new DataTable(); try { dataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0 && dataTable.Columns.Count > 0) foreach (DataRow row in dataTable.Rows) { string header = string.Empty; if (row[0] != null) header = row[0].ToString().Trim(); switch (header) { case "Ad Section": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableSection = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowSection = tempBool; break; case "Color-BW": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableColor = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowColor = tempBool; break; case "Codes Only": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableAbbreviationOnly = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowAbbreviationOnly = tempBool; break; case "Col x In": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableAdSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowAdSize = tempBool; break; case "Page Size": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnablePageSize = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowPageSize = tempBool; break; case "% of Page": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnablePercentOfPage = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowPercentOfPage = tempBool; break; case "Big Dates": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableBigDate = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowBigDate = tempBool; break; case "Logo": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableLogo = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowLogo = tempBool; break; case "Monthly $": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableCost = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowCost = tempBool; break; case "Comment": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableComments = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowComments = tempBool; break; case "# Ads": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableTotalAds = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowTotalAds = tempBool; break; case "# Days": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableActiveDays = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.ShowActiveDays = tempBool; break; case "Gray": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableGray = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "gray"; break; case "Black": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableBlack = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "black"; break; case "Blue": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableBlue = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "blue"; break; case "Teal": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableTeal = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "teal"; break; case "Orange": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableOrange = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "orange"; break; case "Green": if (row[1] != null) if (bool.TryParse(row[1].ToString().Trim(), out tempBool)) defaultCalendarViewSettings.EnableGreen = tempBool; if (row[2] != null) if (bool.TryParse(row[2].ToString().Trim(), out tempBool)) if (tempBool) defaultCalendarViewSettings.SlideColor = "green"; break; } } } catch { } finally { dataAdapter.Dispose(); dataTable.Dispose(); } #endregion connection.Close(); #region Save XML var xml = new StringBuilder(); xml.AppendLine("<PrintStrategy>"); foreach (SlideHeader header in slideHeaders) { xml.Append(@"<Header "); xml.Append("Value = \"" + header.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (SlideHeader status in statuses) { xml.Append(@"<Status "); xml.Append("Value = \"" + status.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (Publication publication in publications) { xml.Append(@"<Publication "); xml.Append("Name = \"" + publication.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Abbreviation = \"" + publication.Abbreviation.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("BigLogo = \"" + publication.BigLogo.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("LittleLogo = \"" + publication.LittleLogo.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("TinyLogo = \"" + publication.TinyLogo.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("DailyCirculation = \"" + publication.DailyCirculation.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("DailyReadership = \"" + publication.DailyReadership.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("SundayCirculation = \"" + publication.SundayCirculation.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("SundayReadership = \"" + publication.SundayReadership.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("AllowSundaySelect = \"" + publication.AllowSundaySelect + "\" "); xml.Append("AllowMondaySelect = \"" + publication.AllowMondaySelect + "\" "); xml.Append("AllowTuesdaySelect = \"" + publication.AllowTuesdaySelect + "\" "); xml.Append("AllowWednesdaySelect = \"" + publication.AllowWednesdaySelect + "\" "); xml.Append("AllowThursdaySelect = \"" + publication.AllowThursdaySelect + "\" "); xml.Append("AllowFridaySelect = \"" + publication.AllowFridaySelect + "\" "); xml.Append("AllowSaturdaySelect = \"" + publication.AllowSaturdaySelect + "\" "); xml.AppendLine(@"/>"); } foreach (AdSize adSize in adSizes) { xml.Append(@"<AdSize "); xml.Append("Group = \"" + adSize.Group.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Name = \"" + adSize.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (ShareUnit shareUnit in shareUnits) { xml.Append(@"<ShareUnit "); xml.Append("RateCard = \"" + shareUnit.RateCard.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("PercentOfPage = \"" + shareUnit.PercentOfPage.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Width = \"" + shareUnit.Width.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("WidthMeasureUnit = \"" + shareUnit.WidthMeasureUnit.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Height = \"" + shareUnit.Height.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("HeightMeasureUnit = \"" + shareUnit.HeightMeasureUnit.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (NameCodePair note in notes) { xml.Append(@"<Note "); xml.Append("Value = \"" + note.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Code = \"" + note.Code.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"<SelectedNotesBorderValue>" + selectedNotesBorderValue.Replace(@"&", "&").Replace("\"", """) + @"</SelectedNotesBorderValue>"); foreach (string clientType in clientTypes) { xml.Append(@"<ClientType "); xml.Append("Value = \"" + clientType.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } foreach (Section section in sections) { xml.Append(@"<Section "); xml.Append("Name = \"" + section.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Abbreviation = \"" + section.Abbreviation.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"<SelectedSectionsBorderValue>" + selectedSectionsBorderValue.Replace(@"&", "&").Replace("\"", """) + @"</SelectedSectionsBorderValue>"); foreach (MechanicalType mechanical in mechanicals) { xml.Append(@"<Mechanicals "); xml.Append("Name = \"" + mechanical.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@">"); foreach (MechanicalItem mechanicalItem in mechanical.Items) { xml.Append(@"<Mechanical "); xml.Append("Name = \"" + mechanicalItem.Name.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.Append("Value = \"" + mechanicalItem.Value.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"</Mechanicals>"); } foreach (string deadline in deadlines) { xml.Append(@"<Deadline "); xml.Append("Value = \"" + deadline.Replace(@"&", "&").Replace("\"", """) + "\" "); xml.AppendLine(@"/>"); } xml.AppendLine(@"<DefaultHomeViewSettings>" + defaultHomeViewSettings.Serialize() + @"</DefaultHomeViewSettings>"); xml.AppendLine(@"<DefaultPrintScheduleViewSettings>" + defaultPrintScheduleViewSettings.Serialize() + @"</DefaultPrintScheduleViewSettings>"); xml.AppendLine(@"<DefaultPublicationBasicOverviewSettings>" + defaultPublicationBasicOverviewSettings.Serialize() + @"</DefaultPublicationBasicOverviewSettings>"); xml.AppendLine(@"<DefaultPublicationMultiSummarySettings>" + defaultPublicationMultiSummarySettings.Serialize() + @"</DefaultPublicationMultiSummarySettings>"); xml.AppendLine(@"<DefaultSnapshotViewSettings>" + defaultSnapshotViewSettings.Serialize() + @"</DefaultSnapshotViewSettings>"); xml.AppendLine(@"<DefaultDetailedGridColumnState>" + defaultDetailedGridColumnState.Serialize() + @"</DefaultDetailedGridColumnState>"); xml.AppendLine(@"<DefaultDetailedGridAdNotesState>" + defaultDetailedGridAdNotesState.Serialize() + @"</DefaultDetailedGridAdNotesState>"); xml.AppendLine(@"<DefaultDetailedGridSlideBulletsState>" + defaultDetailedGridSlideBulletsState.Serialize() + @"</DefaultDetailedGridSlideBulletsState>"); xml.AppendLine(@"<DefaultDetailedGridSlideHeaderState>" + defaultDetailedGridSlideHeaderState.Serialize() + @"</DefaultDetailedGridSlideHeaderState>"); xml.AppendLine(@"<DefaultMultiGridColumnState>" + defaultMultiGridColumnState.Serialize() + @"</DefaultMultiGridColumnState>"); xml.AppendLine(@"<DefaultMultiGridAdNotesState>" + defaultMultiGridAdNotesState.Serialize() + @"</DefaultMultiGridAdNotesState>"); xml.AppendLine(@"<DefaultMultiGridSlideBulletsState>" + defaultMultiGridSlideBulletsState.Serialize() + @"</DefaultMultiGridSlideBulletsState>"); xml.AppendLine(@"<DefaultMultiGridSlideHeaderState>" + defaultMultiGridSlideHeaderState.Serialize() + @"</DefaultMultiGridSlideHeaderState>"); xml.AppendLine(@"<DefaultCalendarViewSettings>" + defaultCalendarViewSettings.Serialize() + @"</DefaultCalendarViewSettings>"); xml.AppendLine(@"</PrintStrategy>"); string xmlPath = Path.Combine(Application.StartupPath, DestinationFileName); using (var sw = new StreamWriter(xmlPath, false)) { sw.Write(xml.ToString()); sw.Flush(); } ProductionFilesUpdateHelper.UpdateProductionFies(xmlPath); #endregion AppManager.Instance.ShowInformation("Data was updated."); } }