private bool SaveProfile() { bool result = true; //Check that all fields are provided if (string.IsNullOrEmpty(textBoxProfileName.Text)) { MessageBox.Show("Profile Name is mandatory!"); return(false); } //Check that the name of the connection is valid if (textBoxProfileName.Text.Contains(" ") || textBoxProfileName.Text.Contains("\\") || textBoxProfileName.Text.Contains("/") || textBoxProfileName.Text.Contains(">") || textBoxProfileName.Text.Contains("<") || textBoxProfileName.Text.Contains("?") || textBoxProfileName.Text.Contains("*") || textBoxProfileName.Text.Contains(":") || textBoxProfileName.Text.Contains("|") || textBoxProfileName.Text.Contains("\"") || textBoxProfileName.Text.Contains("'") ) { MessageBox.Show("You shouldn't use spaces nor the following characters (\\/<>?*:|\"') in the 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 (comboBoxWorkflows.SelectedItem == null) { MessageBox.Show("You must select a Workflow for the Profile"); return(false); } //Vérify that the query was provided if (xmlEditor1.Text == "") { MessageBox.Show("You must provide a Query for the records!"); return(false); } //Check if this is a creation if (currentProfile == null) { //Check if a Data Export Profile having the same name exist already MSCRMWorkflowExecutionProfile existingProfile = man.Profiles.Find(d => d.ProfileName.ToLower() == textBoxProfileName.Text.ToLower()); if (existingProfile != null) { MessageBox.Show("Profile with the name " + textBoxProfileName.Text + " exist already. Please select another name"); return(false); } MSCRMWorkflowExecutionProfile newProfile = new MSCRMWorkflowExecutionProfile(); newProfile.ProfileName = textBoxProfileName.Text; newProfile.SourceConnectionName = comboBoxConnectionSource.SelectedItem.ToString(); newProfile.setSourceConneciton(); newProfile.WorkflowId = this.Workflows.Find(w => w.Name == comboBoxWorkflows.SelectedItem.ToString()).Id; newProfile.WorkflowName = comboBoxWorkflows.SelectedItem.ToString(); newProfile.FetchXMLQuery = xmlEditor1.Text; man.CreateProfile(newProfile); comboBoxProfiles.Items.AddRange(new object[] { newProfile.ProfileName }); comboBoxProfiles.SelectedItem = newProfile.ProfileName; currentProfile = newProfile; } else { currentProfile.ProfileName = textBoxProfileName.Text; currentProfile.SourceConnectionName = comboBoxConnectionSource.SelectedItem.ToString(); currentProfile.WorkflowId = this.Workflows.Find(w => w.Name == comboBoxWorkflows.SelectedItem.ToString()).Id; currentProfile.WorkflowName = comboBoxWorkflows.SelectedItem.ToString(); currentProfile.FetchXMLQuery = xmlEditor1.Text; currentProfile.setSourceConneciton(); MSCRMWorkflowExecutionProfile oldDEP = man.GetProfile(currentProfile.ProfileName); man.UpdateProfile(currentProfile); } runProfileToolStripMenuItem.Enabled = true; toolStripStatusLabel1.Text = "Profile " + currentProfile.ProfileName + " saved."; LogManager.WriteLog("Profile " + currentProfile.ProfileName + " saved."); return(result); }