Example #1
0
        /// <summary>
        /// Saves a profile for the specified workflow type
        /// </summary>
        /// <param name="workflowType"></param>
        /// <param name="profile"></param>
        public void SaveProfile(Type workflowType, TrackingProfile profile)
        {
            TrackingProfile currentProfile = GetWorkflowProfile(workflowType, false);

            if (currentProfile != null && currentProfile.Version >= profile.Version)
            {
                //If there already exists a profile (with a later version)
                //for this workflow, prompt the user to rev the version.
                UpdateProfileVersion updateVersionForm = new UpdateProfileVersion();
                updateVersionForm.CurrentTrackingProfile = currentProfile;
                updateVersionForm.NewTrackingProfile     = profile;
                updateVersionForm.WorkflowType           = workflowType;
                DialogResult result = updateVersionForm.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return;
                }
            }
            try
            {
                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.CommandText = "[dbo].[UpdateTrackingProfile]";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Connection  = connection;

                        SqlParameter typeFullName     = new SqlParameter("@TypeFullName", workflowType.FullName);
                        SqlParameter assemblyFullName = new SqlParameter("@AssemblyFullName", workflowType.Assembly.FullName);

                        command.Parameters.Add(typeFullName);
                        command.Parameters.Add(assemblyFullName);

                        SqlParameter version           = new SqlParameter("@Version", profile.Version.ToString());
                        SqlParameter serializedProfile = new SqlParameter("@TrackingProfileXml", new TrackingProfileManager(profile).SerializeProfile());

                        command.Parameters.Add(version);
                        command.Parameters.Add(serializedProfile);

                        connection.Open();
                        command.ExecuteNonQuery();
                        MessageBox.Show("Save successful!", "Success");
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(string.Format("Error saving profile: {0}", ex.Message), "Error");
            }
        }
Example #2
0
        /// <summary>
        /// Saves a profile for the specified workflow type
        /// </summary>
        /// <param name="workflowType"></param>
        /// <param name="profile"></param>
        public void SaveProfile(Type workflowType, TrackingProfile profile)
        {
            TrackingProfile currentProfile = GetWorkflowProfile(workflowType, false);

            if (currentProfile != null && currentProfile.Version >= profile.Version)
            {
                //If there already exists a profile (with a later version)
                //for this workflow, prompt the user to rev the version.    
                UpdateProfileVersion updateVersionForm = new UpdateProfileVersion();
                updateVersionForm.CurrentTrackingProfile = currentProfile;
                updateVersionForm.NewTrackingProfile = profile;
                updateVersionForm.WorkflowType = workflowType;
                DialogResult result = updateVersionForm.ShowDialog();
                if (result != DialogResult.OK) return;
            }
            try
            {
                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {

                        command.CommandText = "[dbo].[UpdateTrackingProfile]";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Connection = connection;

                        SqlParameter typeFullName = new SqlParameter("@TypeFullName", workflowType.FullName);
                        SqlParameter assemblyFullName = new SqlParameter("@AssemblyFullName", workflowType.Assembly.FullName);

                        command.Parameters.Add(typeFullName);
                        command.Parameters.Add(assemblyFullName);

                        SqlParameter version = new SqlParameter("@Version", profile.Version.ToString());
                        SqlParameter serializedProfile = new SqlParameter("@TrackingProfileXml", new TrackingProfileManager(profile).SerializeProfile());

                        command.Parameters.Add(version);
                        command.Parameters.Add(serializedProfile);

                        connection.Open();
                        command.ExecuteNonQuery();
                        MessageBox.Show("Save successful!", "Success");
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(string.Format("Error saving profile: {0}", ex.Message), "Error");
            }
        }