Beispiel #1
0
        ///<summary>Inserts one ScheduledProcess into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ScheduledProcess scheduledProcess, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO scheduledprocess (";

            if (!useExistingPK && isRandomKeys)
            {
                scheduledProcess.ScheduledProcessNum = ReplicationServers.GetKeyNoCache("scheduledprocess", "ScheduledProcessNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ScheduledProcessNum,";
            }
            command += "ScheduledAction,TimeToRun,FrequencyToRun,LastRanDateTime) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(scheduledProcess.ScheduledProcessNum) + ",";
            }
            command +=
                "'" + POut.String(scheduledProcess.ScheduledAction.ToString()) + "',"
                + POut.DateT(scheduledProcess.TimeToRun) + ","
                + "'" + POut.String(scheduledProcess.FrequencyToRun.ToString()) + "',"
                + POut.DateT(scheduledProcess.LastRanDateTime) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                scheduledProcess.ScheduledProcessNum = Db.NonQ(command, true, "ScheduledProcessNum", "scheduledProcess");
            }
            return(scheduledProcess.ScheduledProcessNum);
        }
 public FormScheduledProcessesEdit(ScheduledProcess schedProc)
 {
     InitializeComponent();
     Lan.F(this);
     _schedProcEdit = schedProc;
     _schedProcOld  = _schedProcEdit.Copy();
 }
Beispiel #3
0
        ///<summary>Updates one ScheduledProcess in the database.</summary>
        public static void Update(ScheduledProcess scheduledProcess)
        {
            string command = "UPDATE scheduledprocess SET "
                             + "ScheduledAction    = '" + POut.String(scheduledProcess.ScheduledAction.ToString()) + "', "
                             + "TimeToRun          =  " + POut.DateT(scheduledProcess.TimeToRun) + ", "
                             + "FrequencyToRun     = '" + POut.String(scheduledProcess.FrequencyToRun.ToString()) + "', "
                             + "LastRanDateTime    =  " + POut.DateT(scheduledProcess.LastRanDateTime) + " "
                             + "WHERE ScheduledProcessNum = " + POut.Long(scheduledProcess.ScheduledProcessNum);

            Db.NonQ(command);
        }
Beispiel #4
0
        private void GridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            ScheduledProcess           selectedSchedProc          = gridMain.SelectedTag <ScheduledProcess>();
            FormScheduledProcessesEdit formScheduledProcessesEdit = new FormScheduledProcessesEdit(selectedSchedProc);

            if (formScheduledProcessesEdit.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            FillGrid();
        }
Beispiel #5
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            ScheduledProcess schedProc = new ScheduledProcess();

            schedProc.IsNew = true;
            FormScheduledProcessesEdit formScheduledProcessesEdit = new FormScheduledProcessesEdit(schedProc);

            if (formScheduledProcessesEdit.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            FillGrid();
        }
Beispiel #6
0
        ///<summary>Updates one ScheduledProcess in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(ScheduledProcess scheduledProcess, ScheduledProcess oldScheduledProcess)
        {
            string command = "";

            if (scheduledProcess.ScheduledAction != oldScheduledProcess.ScheduledAction)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ScheduledAction = '" + POut.String(scheduledProcess.ScheduledAction.ToString()) + "'";
            }
            if (scheduledProcess.TimeToRun != oldScheduledProcess.TimeToRun)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TimeToRun = " + POut.DateT(scheduledProcess.TimeToRun) + "";
            }
            if (scheduledProcess.FrequencyToRun != oldScheduledProcess.FrequencyToRun)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FrequencyToRun = '" + POut.String(scheduledProcess.FrequencyToRun.ToString()) + "'";
            }
            if (scheduledProcess.LastRanDateTime != oldScheduledProcess.LastRanDateTime)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "LastRanDateTime = " + POut.DateT(scheduledProcess.LastRanDateTime) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE scheduledprocess SET " + command
                      + " WHERE ScheduledProcessNum = " + POut.Long(scheduledProcess.ScheduledProcessNum);
            Db.NonQ(command);
            return(true);
        }
Beispiel #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ScheduledProcess> TableToList(DataTable table)
        {
            List <ScheduledProcess> retVal = new List <ScheduledProcess>();
            ScheduledProcess        scheduledProcess;

            foreach (DataRow row in table.Rows)
            {
                scheduledProcess = new ScheduledProcess();
                scheduledProcess.ScheduledProcessNum = PIn.Long(row["ScheduledProcessNum"].ToString());
                string scheduledAction = row["ScheduledAction"].ToString();
                if (scheduledAction == "")
                {
                    scheduledProcess.ScheduledAction = (OpenDentBusiness.ScheduledActionEnum) 0;
                }
                else
                {
                    try{
                        scheduledProcess.ScheduledAction = (OpenDentBusiness.ScheduledActionEnum)Enum.Parse(typeof(OpenDentBusiness.ScheduledActionEnum), scheduledAction);
                    }
                    catch {
                        scheduledProcess.ScheduledAction = (OpenDentBusiness.ScheduledActionEnum) 0;
                    }
                }
                scheduledProcess.TimeToRun = PIn.DateT(row["TimeToRun"].ToString());
                string frequencyToRun = row["FrequencyToRun"].ToString();
                if (frequencyToRun == "")
                {
                    scheduledProcess.FrequencyToRun = (OpenDentBusiness.FrequencyToRunEnum) 0;
                }
                else
                {
                    try{
                        scheduledProcess.FrequencyToRun = (OpenDentBusiness.FrequencyToRunEnum)Enum.Parse(typeof(OpenDentBusiness.FrequencyToRunEnum), frequencyToRun);
                    }
                    catch {
                        scheduledProcess.FrequencyToRun = (OpenDentBusiness.FrequencyToRunEnum) 0;
                    }
                }
                scheduledProcess.LastRanDateTime = PIn.DateT(row["LastRanDateTime"].ToString());
                retVal.Add(scheduledProcess);
            }
            return(retVal);
        }
Beispiel #8
0
 ///<summary>Returns true if Update(ScheduledProcess,ScheduledProcess) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(ScheduledProcess scheduledProcess, ScheduledProcess oldScheduledProcess)
 {
     if (scheduledProcess.ScheduledAction != oldScheduledProcess.ScheduledAction)
     {
         return(true);
     }
     if (scheduledProcess.TimeToRun != oldScheduledProcess.TimeToRun)
     {
         return(true);
     }
     if (scheduledProcess.FrequencyToRun != oldScheduledProcess.FrequencyToRun)
     {
         return(true);
     }
     if (scheduledProcess.LastRanDateTime != oldScheduledProcess.LastRanDateTime)
     {
         return(true);
     }
     return(false);
 }
Beispiel #9
0
 ///<summary>Inserts one ScheduledProcess into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ScheduledProcess scheduledProcess)
 {
     return(InsertNoCache(scheduledProcess, false));
 }