/// <summary> /// Handles the Click event of the toolStripButton1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void toolStripButton1_Click(object sender, EventArgs e) { List <string> ignoredAttributes = new List <string>(); //for (int j = 0; j < checkedListBoxAttributes.CheckedItems.Count; j++) //{ // ignoredAttributes.Add(checkedListBoxAttributes.CheckedItems[j].ToString()); //} for (int j = 0; j < checkedListBoxAttributes.Items.Count; j++) { if (!checkedListBoxAttributes.CheckedItems.Contains(checkedListBoxAttributes.Items[j])) { ignoredAttributes.Add(checkedListBoxAttributes.Items[j].ToString()); } } if (ignoredAttributes.Count < 1) { ignoredAttributes = null; } SelectedEntity se = new SelectedEntity { EntityName = this.entity, IgnoredAttributes = ignoredAttributes, Filter = xmlEditor1.Text }; int index = rdt.TemporarySelectedEntityListForIgnoredAttributes.FindIndex(match => match.EntityName == this.entity); if (index > -1) { rdt.TemporarySelectedEntityListForIgnoredAttributes[index] = se; } else { rdt.TemporarySelectedEntityListForIgnoredAttributes.Add(se); } this.Dispose(); }
/// <summary> /// Updates the transport report. /// </summary> /// <param name="report">The report.</param> /// <param name="ee">The ee.</param> /// <param name="importedRecordsForEntity">The imported records for entity.</param> /// <param name="importFailuresForEntity">The import failures for entity.</param> /// <param name="entityImportStartDT">The entity import start dt.</param> public void updateTransportReport(TransportReport report, SelectedEntity ee, int importedRecordsForEntity, int importFailuresForEntity, DateTime entityImportStartDT) { bool addNewLine = true; foreach (TransportReportLine reportLine in report.ReportLines) { if (reportLine.Entity == ee.EntityName) { reportLine.ImportedRecords = importedRecordsForEntity; report.TotalImportedRecords += importedRecordsForEntity; DateTime entityImportEndDT = DateTime.Now; TimeSpan ts = entityImportEndDT - entityImportStartDT; reportLine.ImportStartedAt = entityImportStartDT.ToString(); reportLine.ImportFinishedAt = entityImportEndDT.ToString(); reportLine.ImportedIn = ts.ToString().Substring(0, 10); reportLine.ImportFailures = importFailuresForEntity; addNewLine = false; break; } } if (addNewLine) { TransportReportLine currentLine = new TransportReportLine(); currentLine.Entity = ee.EntityName; currentLine.ImportedRecords = importedRecordsForEntity; report.TotalImportedRecords += importedRecordsForEntity; DateTime entityImportEndDT = DateTime.Now; TimeSpan ts = entityImportEndDT - entityImportStartDT; currentLine.ImportStartedAt = entityImportStartDT.ToString(); currentLine.ImportFinishedAt = entityImportEndDT.ToString(); currentLine.ImportedIn = ts.ToString().Substring(0, 10); currentLine.ImportFailures = importFailuresForEntity; report.ReportLines.Add(currentLine); } WriteTransportReport(report, ReportFileName); }
private bool SaveProfile() { bool result = true; //Check that all fields are provided if (string.IsNullOrEmpty(textBoxTransportationProfileName.Text)) { MessageBox.Show("Transportation Profile Name is mandatory!"); return false; } //Check that the name of te connection is valid if (textBoxTransportationProfileName.Text.Contains(" ") || textBoxTransportationProfileName.Text.Contains("\\") || textBoxTransportationProfileName.Text.Contains("/") || textBoxTransportationProfileName.Text.Contains(">") || textBoxTransportationProfileName.Text.Contains("<") || textBoxTransportationProfileName.Text.Contains("?") || textBoxTransportationProfileName.Text.Contains("*") || textBoxTransportationProfileName.Text.Contains(":") || textBoxTransportationProfileName.Text.Contains("|") || textBoxTransportationProfileName.Text.Contains("\"") || textBoxTransportationProfileName.Text.Contains("'") ) { MessageBox.Show("You shouldn't use spaces nor the following characters (\\/<>?*:|\"') in the Transportation Profile Name as it will be used to create folders and files."); return false; } if (comboBoxConnectionSource.SelectedItem == null) { MessageBox.Show("You must select a Source for the Profile"); return false; } if (comboBoxConnectionTarget.SelectedItem == null && comboBoxOperation.SelectedItem.ToString() != "Export Data") { MessageBox.Show("You must select a Target for the Profile"); return false; } //Check for Transport Order Conflicts foreach (ComboBox cb in panelTransportOrder.Controls.OfType<ComboBox>()) { int numberOfOccurencies = 0; int currentComboSelectedIndex = cb.SelectedIndex; foreach (ComboBox cb1 in panelTransportOrder.Controls.OfType<ComboBox>()) { if (currentComboSelectedIndex == cb1.SelectedIndex) { numberOfOccurencies++; } if (numberOfOccurencies > 1) { MessageBox.Show("The entity \"" + cb.SelectedItem + "\" is declared more than once int the Transport Order. Fix this before saving."); return false; } } } //Check if this is a creation if (currentProfile == null) { //Check if a Connection having the same name exist already foreach (TransportationProfile tp in man.Profiles) { if (tp.ProfileName.ToLower() == textBoxTransportationProfileName.Text.ToLower()) { MessageBox.Show("Transportation Profile with the name " + textBoxTransportationProfileName.Text + " exist already. Please select another name"); return false; } } TransportationProfile newProfile = new TransportationProfile(); newProfile.ProfileName = textBoxTransportationProfileName.Text; newProfile.ImportMode = comboBoxImportMode.SelectedIndex; newProfile.SourceConnectionName = comboBoxConnectionSource.SelectedItem.ToString(); newProfile.setSourceConneciton(); if (comboBoxOperation.SelectedItem.ToString() != "Export Data") { newProfile.TargetConnectionName = comboBoxConnectionTarget.SelectedItem.ToString(); newProfile.setTargetConneciton(); } newProfile.SelectedEntities = new List<SelectedEntity>(); foreach (string checkedEntity in checkedListBoxEntities.CheckedItems) { SelectedEntity ee = new SelectedEntity(); ee.EntityName = checkedEntity; ee.ExportedRecords = 0; foreach (ComboBox cb in panelTransportOrder.Controls.OfType<ComboBox>()) { if (cb.SelectedItem.ToString() == ee.EntityName) { ee.TransportOrder = (int)cb.Tag; break; } } SelectedEntity seForIgnoredAttributes = TemporarySelectedEntityListForIgnoredAttributes.Find(match => match.EntityName == checkedEntity); if (seForIgnoredAttributes != null) { ee.IgnoredAttributes = seForIgnoredAttributes.IgnoredAttributes; ee.Filter = seForIgnoredAttributes.Filter; } newProfile.SelectedEntities.Add(ee); } newProfile.Operation = comboBoxOperation.SelectedIndex; man.CreateProfile(newProfile); comboBoxTransportationProfiles.Items.AddRange(new object[] { newProfile.ProfileName }); comboBoxTransportationProfiles.SelectedItem = newProfile.ProfileName; } else { currentProfile.ProfileName = textBoxTransportationProfileName.Text; currentProfile.ImportMode = comboBoxImportMode.SelectedIndex; currentProfile.SourceConnectionName = comboBoxConnectionSource.SelectedItem.ToString(); currentProfile.setSourceConneciton(); if (comboBoxOperation.SelectedItem.ToString() != "Export Data") { currentProfile.TargetConnectionName = comboBoxConnectionTarget.SelectedItem.ToString(); currentProfile.setTargetConneciton(); } //Backup Export Records numbers if existing List<SelectedEntity> backupSelectedEntites = currentProfile.SelectedEntities; currentProfile.SelectedEntities = new List<SelectedEntity>(); TransportationProfile oldProfile = man.GetProfile(currentProfile.ProfileName); foreach (string checkedEntity in checkedListBoxEntities.CheckedItems) { SelectedEntity ee = currentProfile.getSelectedEntity(checkedEntity); if (ee == null) { ee = new SelectedEntity(); ee.EntityName = checkedEntity; //Restore Export Records numbers if existing SelectedEntity tse = backupSelectedEntites.Find(b => b.EntityName == checkedEntity); if (tse != null && tse.ExportedRecords > 0) { ee.ExportedRecords = tse.ExportedRecords; } else { ee.ExportedRecords = 0; } foreach (ComboBox cb in panelTransportOrder.Controls.OfType<ComboBox>()) { if (cb.SelectedItem.ToString() == ee.EntityName) { ee.TransportOrder = (int)cb.Tag; break; } } SelectedEntity seForIgnoredAttributes = TemporarySelectedEntityListForIgnoredAttributes.Find(match => match.EntityName == checkedEntity); if (seForIgnoredAttributes != null) { ee.IgnoredAttributes = seForIgnoredAttributes.IgnoredAttributes; ee.Filter = seForIgnoredAttributes.Filter; } currentProfile.SelectedEntities.Add(ee); } else { foreach (ComboBox cb in panelTransportOrder.Controls.OfType<ComboBox>()) { if (cb.SelectedItem.ToString() == ee.EntityName) { ee.TransportOrder = (int)cb.Tag; break; } } } } //Records mapping cleanup if (currentProfile.RecordMappings != null) { List<int> RecordMappingsForRemovalIndexes = new List<int>(); for (int i = 0; i < currentProfile.RecordMappings.Count; i++) { if (currentProfile.RecordMappings[i].SourceRecordId == Guid.Empty && currentProfile.RecordMappings[i].TargetRecordId == Guid.Empty) RecordMappingsForRemovalIndexes.Add(i); } for (int removeIndex = RecordMappingsForRemovalIndexes.Count - 1; removeIndex >= 0; removeIndex--) currentProfile.RecordMappings.RemoveAt(removeIndex); if (currentProfile.RecordMappings.Count == 0) currentProfile.RecordMappings = null; } currentProfile.Operation = comboBoxOperation.SelectedIndex; man.UpdateProfile(currentProfile); } runProfileToolStripMenuItem.Enabled = true; toolStripStatusLabel.Text = "Transportation Profile " + currentProfile.ProfileName + " saved."; LogManager.WriteLog("Transportation Profile " + currentProfile.ProfileName + " saved."); return result; }
/// <summary> /// Handles the Click event of the toolStripButton1 control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void toolStripButton1_Click(object sender, EventArgs e) { List<string> ignoredAttributes = new List<string>(); //for (int j = 0; j < checkedListBoxAttributes.CheckedItems.Count; j++) //{ // ignoredAttributes.Add(checkedListBoxAttributes.CheckedItems[j].ToString()); //} for (int j = 0; j < checkedListBoxAttributes.Items.Count; j++) { if (!checkedListBoxAttributes.CheckedItems.Contains(checkedListBoxAttributes.Items[j])) ignoredAttributes.Add(checkedListBoxAttributes.Items[j].ToString()); } if (ignoredAttributes.Count < 1) ignoredAttributes = null; SelectedEntity se = new SelectedEntity { EntityName = this.entity, IgnoredAttributes = ignoredAttributes, Filter = xmlEditor1.Text }; int index = rdt.TemporarySelectedEntityListForIgnoredAttributes.FindIndex(match => match.EntityName == this.entity); if (index > -1) rdt.TemporarySelectedEntityListForIgnoredAttributes[index] = se; else rdt.TemporarySelectedEntityListForIgnoredAttributes.Add(se); this.Dispose(); }