Beispiel #1
0
 private void comboBoxProfiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     comboBoxConnectionSource.SelectedItem = null;
     if (comboBoxProfiles.SelectedItem != null)
     {
         currentProfile          = man.Profiles[comboBoxProfiles.SelectedIndex];
         this.selectedReportId   = currentProfile.SelectedReprortId;
         textBoxProfileName.Text = currentProfile.ProfileName;
         comboBoxConnectionSource.SelectedItem  = currentProfile.SourceConnectionName;
         deleteProfileToolStripMenuItem.Enabled = true;
         newToolStripMenuItem.Enabled           = true;
         saveToolStripMenuItem.Enabled          = true;
         textBoxProfileName.Enabled             = false;
         runProfileToolStripMenuItem.Enabled    = true;
         toolStripStatusLabel1.Text             = "Report Execution Profile " + currentProfile.ProfileName + " loaded.";
         LogManager.WriteLog("Report Execution Profile " + currentProfile.ProfileName + " loaded.");
     }
     else
     {
         currentProfile          = null;
         textBoxProfileName.Text = "";
         deleteProfileToolStripMenuItem.Enabled = false;
         newToolStripMenuItem.Enabled           = false;
         saveToolStripMenuItem.Enabled          = false;
         textBoxProfileName.Enabled             = true;
         runProfileToolStripMenuItem.Enabled    = false;
         this.selectedReportId = Guid.Empty;
     }
 }
Beispiel #2
0
        private void deleteProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string       currentProfileName = currentProfile.ProfileName;
            DialogResult dResTest;

            dResTest = MessageBox.Show("Are you sure you want to delete this Report Execution Profile ?", "Confirm Profile Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dResTest == DialogResult.No)
            {
                return;
            }
            else
            {
                comboBoxProfiles.Items.Remove(currentProfile.ProfileName);
                comboBoxProfiles.SelectedItem = null;
                man.DeleteProfile(currentProfile);
                currentProfile                        = null;
                textBoxProfileName.Text               = "";
                textBoxProfileName.Enabled            = true;
                comboBoxConnectionSource.SelectedItem = null;

                toolStripStatusLabel1.Text = "Report Execution Profile " + currentProfileName + " deleted";
                LogManager.WriteLog("Report Execution Profile " + currentProfileName + " deleted");
            }
        }
Beispiel #3
0
        private bool SaveProfile()
        {
            bool result = true;

            //Check that all fields are provided
            if (string.IsNullOrEmpty(textBoxProfileName.Text))
            {
                MessageBox.Show("Report Execution 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 Report Execution 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 (this.selectedReportId == Guid.Empty)
            {
                MessageBox.Show("You must select a Report for the Profile");
                return(false);
            }

            //Check if this is a creation
            if (currentProfile == null)
            {
                //Check if a Solution Transport Profile having the same name exist already
                MSCRMReportExecutionProfile profile = man.Profiles.Find(p => p.ProfileName.ToLower() == textBoxProfileName.Text.ToLower());
                if (profile != null)
                {
                    MessageBox.Show("Report Execution Profile with the name " + textBoxProfileName.Text + " exist already. Please select another name");
                    return(false);
                }

                MSCRMReportExecutionProfile newProfile = new MSCRMReportExecutionProfile();
                newProfile.ProfileName          = textBoxProfileName.Text;
                newProfile.SourceConnectionName = comboBoxConnectionSource.SelectedItem.ToString();
                newProfile.SelectedReprortId    = this.selectedReportId;
                newProfile.setSourceConneciton();

                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.SelectedReprortId    = this.selectedReportId;
                currentProfile.setSourceConneciton();
                MSCRMReportExecutionProfile oldDEP = man.GetProfile(currentProfile.ProfileName);
                man.UpdateProfile(currentProfile);
            }

            runProfileToolStripMenuItem.Enabled = true;
            toolStripStatusLabel1.Text          = "Report Execution Profile " + currentProfile.ProfileName + " saved.";
            return(result);
        }