private static void Main(string[] args) { //Set the application directory as the current directory string appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); appPath = appPath.Replace("file:\\", ""); Directory.SetCurrentDirectory(appPath); MSCRMWorkflowExecutionManager man = new MSCRMWorkflowExecutionManager(); string selectedProfileName = ""; if (args.Length == 0) { if (man.Profiles.Count == 0) { Console.WriteLine("\nNo profiles found."); return; } //Display all profiles for selection Console.WriteLine("\nSpecify the Profile to run (1-{0}) [1] : ", man.Profiles.Count); int tpCpt = 1; foreach (MSCRMWorkflowExecutionProfile profile in man.Profiles) { Console.WriteLine(tpCpt + ". " + profile.ProfileName); tpCpt++; } String input = Console.ReadLine(); if (input == String.Empty) { input = "1"; } int depNumber; Int32.TryParse(input, out depNumber); if (depNumber > 0 && depNumber <= man.Profiles.Count) { selectedProfileName = man.Profiles[depNumber - 1].ProfileName; } else { Console.WriteLine("The specified Profile does not exist."); return; } } else { //Check that the Profile name is provided if (string.IsNullOrEmpty(args[0])) return; selectedProfileName = args[0]; } MSCRMWorkflowExecutionProfile p = man.GetProfile(selectedProfileName); if (p == null) { Console.WriteLine("The specified Profile does not exist."); return; } man.RunProfile(p); }
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); }
private static void Main(string[] args) { //Set the application directory as the current directory string appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); appPath = appPath.Replace("file:\\", ""); Directory.SetCurrentDirectory(appPath); MSCRMWorkflowExecutionManager man = new MSCRMWorkflowExecutionManager(); string selectedProfileName = ""; if (args.Length == 0) { if (man.Profiles.Count == 0) { Console.WriteLine("\nNo profiles found."); return; } //Display all profiles for selection Console.WriteLine("\nSpecify the Profile to run (1-{0}) [1] : ", man.Profiles.Count); int tpCpt = 1; foreach (MSCRMWorkflowExecutionProfile profile in man.Profiles) { Console.WriteLine(tpCpt + ". " + profile.ProfileName); tpCpt++; } String input = Console.ReadLine(); if (input == String.Empty) { input = "1"; } int depNumber; Int32.TryParse(input, out depNumber); if (depNumber > 0 && depNumber <= man.Profiles.Count) { selectedProfileName = man.Profiles[depNumber - 1].ProfileName; } else { Console.WriteLine("The specified Profile does not exist."); return; } } else { //Check that the Profile name is provided if (string.IsNullOrEmpty(args[0])) { return; } selectedProfileName = args[0]; } MSCRMWorkflowExecutionProfile p = man.GetProfile(selectedProfileName); if (p == null) { Console.WriteLine("The specified Profile does not exist."); return; } man.RunProfile(p); }