Ejemplo n.º 1
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <TaskHist> TableToList(DataTable table)
        {
            List <TaskHist> retVal = new List <TaskHist>();
            TaskHist        taskHist;

            foreach (DataRow row in table.Rows)
            {
                taskHist                   = new TaskHist();
                taskHist.TaskHistNum       = PIn.Long(row["TaskHistNum"].ToString());
                taskHist.UserNumHist       = PIn.Long(row["UserNumHist"].ToString());
                taskHist.DateTStamp        = PIn.DateT(row["DateTStamp"].ToString());
                taskHist.IsNoteChange      = PIn.Bool(row["IsNoteChange"].ToString());
                taskHist.TaskNum           = PIn.Long(row["TaskNum"].ToString());
                taskHist.TaskListNum       = PIn.Long(row["TaskListNum"].ToString());
                taskHist.DateTask          = PIn.Date(row["DateTask"].ToString());
                taskHist.KeyNum            = PIn.Long(row["KeyNum"].ToString());
                taskHist.Descript          = PIn.String(row["Descript"].ToString());
                taskHist.TaskStatus        = (OpenDentBusiness.TaskStatusEnum)PIn.Int(row["TaskStatus"].ToString());
                taskHist.IsRepeating       = PIn.Bool(row["IsRepeating"].ToString());
                taskHist.DateType          = (OpenDentBusiness.TaskDateType)PIn.Int(row["DateType"].ToString());
                taskHist.FromNum           = PIn.Long(row["FromNum"].ToString());
                taskHist.ObjectType        = (OpenDentBusiness.TaskObjectType)PIn.Int(row["ObjectType"].ToString());
                taskHist.DateTimeEntry     = PIn.DateT(row["DateTimeEntry"].ToString());
                taskHist.UserNum           = PIn.Long(row["UserNum"].ToString());
                taskHist.DateTimeFinished  = PIn.DateT(row["DateTimeFinished"].ToString());
                taskHist.PriorityDefNum    = PIn.Long(row["PriorityDefNum"].ToString());
                taskHist.ReminderGroupId   = PIn.String(row["ReminderGroupId"].ToString());
                taskHist.ReminderType      = (OpenDentBusiness.TaskReminderType)PIn.Int(row["ReminderType"].ToString());
                taskHist.ReminderFrequency = PIn.Int(row["ReminderFrequency"].ToString());
                taskHist.DateTimeOriginal  = PIn.DateT(row["DateTimeOriginal"].ToString());
                retVal.Add(taskHist);
            }
            return(retVal);
        }
Ejemplo n.º 2
0
        ///<summary>Updates one TaskHist in the database.</summary>
        public static void Update(TaskHist taskHist)
        {
            string command = "UPDATE taskhist SET "
                             + "UserNumHist      =  " + POut.Long(taskHist.UserNumHist) + ", "
                             //DateTStamp not allowed to change
                             + "IsNoteChange     =  " + POut.Bool(taskHist.IsNoteChange) + ", "
                             + "TaskNum          =  " + POut.Long(taskHist.TaskNum) + ", "
                             + "TaskListNum      =  " + POut.Long(taskHist.TaskListNum) + ", "
                             + "DateTask         =  " + POut.Date(taskHist.DateTask) + ", "
                             + "KeyNum           =  " + POut.Long(taskHist.KeyNum) + ", "
                             + "Descript         =  " + DbHelper.ParamChar + "paramDescript, "
                             + "TaskStatus       =  " + POut.Int((int)taskHist.TaskStatus) + ", "
                             + "IsRepeating      =  " + POut.Bool(taskHist.IsRepeating) + ", "
                             + "DateType         =  " + POut.Int((int)taskHist.DateType) + ", "
                             + "FromNum          =  " + POut.Long(taskHist.FromNum) + ", "
                             + "ObjectType       =  " + POut.Int((int)taskHist.ObjectType) + ", "
                             + "DateTimeEntry    =  " + POut.DateT(taskHist.DateTimeEntry) + ", "
                             + "UserNum          =  " + POut.Long(taskHist.UserNum) + ", "
                             + "DateTimeFinished =  " + POut.DateT(taskHist.DateTimeFinished) + ", "
                             + "PriorityDefNum   =  " + POut.Long(taskHist.PriorityDefNum) + ", "
                             + "ReminderGroupId  = '" + POut.String(taskHist.ReminderGroupId) + "', "
                             + "ReminderType     =  " + POut.Int((int)taskHist.ReminderType) + ", "
                             + "ReminderFrequency=  " + POut.Int(taskHist.ReminderFrequency) + " "
                             //DateTimeOriginal not allowed to change
                             + "WHERE TaskHistNum = " + POut.Long(taskHist.TaskHistNum);

            if (taskHist.Descript == null)
            {
                taskHist.Descript = "";
            }
            OdSqlParameter paramDescript = new OdSqlParameter("paramDescript", OdDbType.Text, POut.StringParam(taskHist.Descript));

            Db.NonQ(command, paramDescript);
        }
Ejemplo n.º 3
0
 ///<summary>Inserts one TaskHist into the database.  Returns the new priKey.</summary>
 public static long Insert(TaskHist taskHist)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         taskHist.TaskHistNum = DbHelper.GetNextOracleKey("taskhist", "TaskHistNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(taskHist, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     taskHist.TaskHistNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(taskHist, false));
     }
 }
Ejemplo n.º 4
0
        ///<summary>Inserts one TaskHist into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(TaskHist taskHist, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO taskhist (";

            if (!useExistingPK && isRandomKeys)
            {
                taskHist.TaskHistNum = ReplicationServers.GetKeyNoCache("taskhist", "TaskHistNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "TaskHistNum,";
            }
            command += "UserNumHist,DateTStamp,IsNoteChange,TaskNum,TaskListNum,DateTask,KeyNum,Descript,TaskStatus,IsRepeating,DateType,FromNum,ObjectType,DateTimeEntry,UserNum,DateTimeFinished,PriorityDefNum,ReminderGroupId,ReminderType,ReminderFrequency,DateTimeOriginal,SecDateTEdit) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(taskHist.TaskHistNum) + ",";
            }
            command +=
                POut.Long(taskHist.UserNumHist) + ","
                + DbHelper.Now() + ","
                + POut.Bool(taskHist.IsNoteChange) + ","
                + POut.Long(taskHist.TaskNum) + ","
                + POut.Long(taskHist.TaskListNum) + ","
                + POut.Date(taskHist.DateTask) + ","
                + POut.Long(taskHist.KeyNum) + ","
                + DbHelper.ParamChar + "paramDescript,"
                + POut.Int((int)taskHist.TaskStatus) + ","
                + POut.Bool(taskHist.IsRepeating) + ","
                + POut.Int((int)taskHist.DateType) + ","
                + POut.Long(taskHist.FromNum) + ","
                + POut.Int((int)taskHist.ObjectType) + ","
                + POut.DateT(taskHist.DateTimeEntry) + ","
                + POut.Long(taskHist.UserNum) + ","
                + POut.DateT(taskHist.DateTimeFinished) + ","
                + POut.Long(taskHist.PriorityDefNum) + ","
                + "'" + POut.String(taskHist.ReminderGroupId) + "',"
                + POut.Int((int)taskHist.ReminderType) + ","
                + POut.Int(taskHist.ReminderFrequency) + ","
                + POut.DateT(taskHist.DateTimeOriginal) + ","
                + POut.DateT(taskHist.SecDateTEdit) + ")";
            if (taskHist.Descript == null)
            {
                taskHist.Descript = "";
            }
            OdSqlParameter paramDescript = new OdSqlParameter("paramDescript", OdDbType.Text, POut.StringParam(taskHist.Descript));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramDescript);
            }
            else
            {
                taskHist.TaskHistNum = Db.NonQ(command, true, "TaskHistNum", "taskHist", paramDescript);
            }
            return(taskHist.TaskHistNum);
        }
Ejemplo n.º 5
0
 ///<summary>Inserts one TaskHist into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TaskHist taskHist)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(taskHist, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             taskHist.TaskHistNum = DbHelper.GetNextOracleKey("taskhist", "TaskHistNum");                  //Cacheless method
         }
         return(InsertNoCache(taskHist, true));
     }
 }
Ejemplo n.º 6
0
        private void FillGrid()
        {
            gridTaskHist.BeginUpdate();
            gridTaskHist.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableTaskAudit", "Create Date"), 140);

            gridTaskHist.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableTaskAudit", "Edit Date"), 140);
            gridTaskHist.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableTaskAudit", "Editing User"), 80);
            gridTaskHist.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableTaskAudit", "Changes"), 100);
            gridTaskHist.Columns.Add(col);
            gridTaskHist.Rows.Clear();
            ODGridRow row;            //Row describes difference between current row and the Next row. Last row will be the last TaskHist compared to the current Task.

            for (int i = 1; i < _listTaskAudit.Count; i++)
            {
                TaskHist taskHistCur  = _listTaskAudit[i - 1];
                TaskHist taskHistNext = _listTaskAudit[i];
                row = new ODGridRow();
                if (taskHistCur.DateTimeEntry == DateTime.MinValue)
                {
                    row.Cells.Add(_listTaskAudit[i].DateTimeEntry.ToString());
                }
                else
                {
                    row.Cells.Add(taskHistCur.DateTimeEntry.ToString());
                }
                row.Cells.Add(taskHistCur.DateTStamp.ToString());
                long usernum = taskHistCur.UserNumHist;
                if (usernum == 0)
                {
                    usernum = taskHistCur.UserNum;
                }
                row.Cells.Add(Userods.GetUser(usernum).UserName);
                row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext));
                gridTaskHist.Rows.Add(row);
            }
            //Compare the current task with the last hist entry (Add the "current revision" of the task if necessary.)
            if (_listTaskAudit.Count > 0)
            {
                TaskHist taskHistCur = _listTaskAudit[_listTaskAudit.Count - 1];
                Task     task        = Tasks.GetOne(TaskNumCur);
                if (task != null)
                {
                    TaskHist taskHistNext = new TaskHist(task);
                    row = new ODGridRow();
                    if (taskHistCur.DateTimeEntry == DateTime.MinValue)
                    {
                        row.Cells.Add(taskHistNext.DateTimeEntry.ToString());
                    }
                    else
                    {
                        row.Cells.Add(taskHistCur.DateTimeEntry.ToString());
                    }
                    row.Cells.Add(taskHistCur.DateTStamp.ToString());
                    long usernum = taskHistCur.UserNumHist;
                    if (usernum == 0)
                    {
                        usernum = taskHistCur.UserNum;
                    }
                    row.Cells.Add(Userods.GetUser(usernum).UserName);
                    row.Cells.Add(TaskHists.GetChangesDescription(taskHistCur, taskHistNext));
                    gridTaskHist.Rows.Add(row);
                }
            }
            gridTaskHist.EndUpdate();
        }
Ejemplo n.º 7
0
 ///<summary>Returns true if Update(TaskHist,TaskHist) 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(TaskHist taskHist, TaskHist oldTaskHist)
 {
     if (taskHist.UserNumHist != oldTaskHist.UserNumHist)
     {
         return(true);
     }
     //DateTStamp not allowed to change
     if (taskHist.IsNoteChange != oldTaskHist.IsNoteChange)
     {
         return(true);
     }
     if (taskHist.TaskNum != oldTaskHist.TaskNum)
     {
         return(true);
     }
     if (taskHist.TaskListNum != oldTaskHist.TaskListNum)
     {
         return(true);
     }
     if (taskHist.DateTask.Date != oldTaskHist.DateTask.Date)
     {
         return(true);
     }
     if (taskHist.KeyNum != oldTaskHist.KeyNum)
     {
         return(true);
     }
     if (taskHist.Descript != oldTaskHist.Descript)
     {
         return(true);
     }
     if (taskHist.TaskStatus != oldTaskHist.TaskStatus)
     {
         return(true);
     }
     if (taskHist.IsRepeating != oldTaskHist.IsRepeating)
     {
         return(true);
     }
     if (taskHist.DateType != oldTaskHist.DateType)
     {
         return(true);
     }
     if (taskHist.FromNum != oldTaskHist.FromNum)
     {
         return(true);
     }
     if (taskHist.ObjectType != oldTaskHist.ObjectType)
     {
         return(true);
     }
     if (taskHist.DateTimeEntry != oldTaskHist.DateTimeEntry)
     {
         return(true);
     }
     if (taskHist.UserNum != oldTaskHist.UserNum)
     {
         return(true);
     }
     if (taskHist.DateTimeFinished != oldTaskHist.DateTimeFinished)
     {
         return(true);
     }
     if (taskHist.PriorityDefNum != oldTaskHist.PriorityDefNum)
     {
         return(true);
     }
     if (taskHist.ReminderGroupId != oldTaskHist.ReminderGroupId)
     {
         return(true);
     }
     if (taskHist.ReminderType != oldTaskHist.ReminderType)
     {
         return(true);
     }
     if (taskHist.ReminderFrequency != oldTaskHist.ReminderFrequency)
     {
         return(true);
     }
     //DateTimeOriginal not allowed to change
     return(false);
 }
Ejemplo n.º 8
0
        ///<summary>Updates one TaskHist 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(TaskHist taskHist, TaskHist oldTaskHist)
        {
            string command = "";

            if (taskHist.UserNumHist != oldTaskHist.UserNumHist)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNumHist = " + POut.Long(taskHist.UserNumHist) + "";
            }
            //DateTStamp not allowed to change
            if (taskHist.IsNoteChange != oldTaskHist.IsNoteChange)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsNoteChange = " + POut.Bool(taskHist.IsNoteChange) + "";
            }
            if (taskHist.TaskNum != oldTaskHist.TaskNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TaskNum = " + POut.Long(taskHist.TaskNum) + "";
            }
            if (taskHist.TaskListNum != oldTaskHist.TaskListNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TaskListNum = " + POut.Long(taskHist.TaskListNum) + "";
            }
            if (taskHist.DateTask.Date != oldTaskHist.DateTask.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTask = " + POut.Date(taskHist.DateTask) + "";
            }
            if (taskHist.KeyNum != oldTaskHist.KeyNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "KeyNum = " + POut.Long(taskHist.KeyNum) + "";
            }
            if (taskHist.Descript != oldTaskHist.Descript)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Descript = " + DbHelper.ParamChar + "paramDescript";
            }
            if (taskHist.TaskStatus != oldTaskHist.TaskStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "TaskStatus = " + POut.Int((int)taskHist.TaskStatus) + "";
            }
            if (taskHist.IsRepeating != oldTaskHist.IsRepeating)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsRepeating = " + POut.Bool(taskHist.IsRepeating) + "";
            }
            if (taskHist.DateType != oldTaskHist.DateType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateType = " + POut.Int((int)taskHist.DateType) + "";
            }
            if (taskHist.FromNum != oldTaskHist.FromNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FromNum = " + POut.Long(taskHist.FromNum) + "";
            }
            if (taskHist.ObjectType != oldTaskHist.ObjectType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ObjectType = " + POut.Int((int)taskHist.ObjectType) + "";
            }
            if (taskHist.DateTimeEntry != oldTaskHist.DateTimeEntry)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeEntry = " + POut.DateT(taskHist.DateTimeEntry) + "";
            }
            if (taskHist.UserNum != oldTaskHist.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = " + POut.Long(taskHist.UserNum) + "";
            }
            if (taskHist.DateTimeFinished != oldTaskHist.DateTimeFinished)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeFinished = " + POut.DateT(taskHist.DateTimeFinished) + "";
            }
            if (taskHist.PriorityDefNum != oldTaskHist.PriorityDefNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PriorityDefNum = " + POut.Long(taskHist.PriorityDefNum) + "";
            }
            if (taskHist.ReminderGroupId != oldTaskHist.ReminderGroupId)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReminderGroupId = '" + POut.String(taskHist.ReminderGroupId) + "'";
            }
            if (taskHist.ReminderType != oldTaskHist.ReminderType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReminderType = " + POut.Int((int)taskHist.ReminderType) + "";
            }
            if (taskHist.ReminderFrequency != oldTaskHist.ReminderFrequency)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReminderFrequency = " + POut.Int(taskHist.ReminderFrequency) + "";
            }
            //DateTimeOriginal not allowed to change
            if (command == "")
            {
                return(false);
            }
            if (taskHist.Descript == null)
            {
                taskHist.Descript = "";
            }
            OdSqlParameter paramDescript = new OdSqlParameter("paramDescript", OdDbType.Text, POut.StringParam(taskHist.Descript));

            command = "UPDATE taskhist SET " + command
                      + " WHERE TaskHistNum = " + POut.Long(taskHist.TaskHistNum);
            Db.NonQ(command, paramDescript);
            return(true);
        }
Ejemplo n.º 9
0
 ///<summary>Inserts one TaskHist into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(TaskHist taskHist)
 {
     return(InsertNoCache(taskHist, false));
 }