예제 #1
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <SmsFromMobile> TableToList(DataTable table)
        {
            List <SmsFromMobile> retVal = new List <SmsFromMobile>();
            SmsFromMobile        smsFromMobile;

            foreach (DataRow row in table.Rows)
            {
                smsFromMobile = new SmsFromMobile();
                smsFromMobile.SmsFromMobileNum  = PIn.Long(row["SmsFromMobileNum"].ToString());
                smsFromMobile.PatNum            = PIn.Long(row["PatNum"].ToString());
                smsFromMobile.ClinicNum         = PIn.Long(row["ClinicNum"].ToString());
                smsFromMobile.CommlogNum        = PIn.Long(row["CommlogNum"].ToString());
                smsFromMobile.MsgText           = PIn.String(row["MsgText"].ToString());
                smsFromMobile.DateTimeReceived  = PIn.DateT(row["DateTimeReceived"].ToString());
                smsFromMobile.SmsPhoneNumber    = PIn.String(row["SmsPhoneNumber"].ToString());
                smsFromMobile.MobilePhoneNumber = PIn.String(row["MobilePhoneNumber"].ToString());
                smsFromMobile.MsgPart           = PIn.Int(row["MsgPart"].ToString());
                smsFromMobile.MsgTotal          = PIn.Int(row["MsgTotal"].ToString());
                smsFromMobile.MsgRefID          = PIn.String(row["MsgRefID"].ToString());
                smsFromMobile.SmsStatus         = (OpenDentBusiness.SmsFromStatus)PIn.Int(row["SmsStatus"].ToString());
                smsFromMobile.Flags             = PIn.String(row["Flags"].ToString());
                smsFromMobile.IsHidden          = PIn.Bool(row["IsHidden"].ToString());
                smsFromMobile.MatchCount        = PIn.Int(row["MatchCount"].ToString());
                smsFromMobile.GuidMessage       = PIn.String(row["GuidMessage"].ToString());
                retVal.Add(smsFromMobile);
            }
            return(retVal);
        }
예제 #2
0
 ///<summary>Inserts one SmsFromMobile into the database.  Returns the new priKey.</summary>
 public static long Insert(SmsFromMobile smsFromMobile)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         smsFromMobile.SmsFromMobileNum = DbHelper.GetNextOracleKey("smsfrommobile", "SmsFromMobileNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(smsFromMobile, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     smsFromMobile.SmsFromMobileNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(smsFromMobile, false));
     }
 }
예제 #3
0
        ///<summary>Updates one SmsFromMobile in the database.</summary>
        public static void Update(SmsFromMobile smsFromMobile)
        {
            string command = "UPDATE smsfrommobile SET "
                             + "PatNum           =  " + POut.Long(smsFromMobile.PatNum) + ", "
                             + "ClinicNum        =  " + POut.Long(smsFromMobile.ClinicNum) + ", "
                             + "CommlogNum       =  " + POut.Long(smsFromMobile.CommlogNum) + ", "
                             + "MsgText          =  " + DbHelper.ParamChar + "paramMsgText, "
                             + "DateTimeReceived =  " + POut.DateT(smsFromMobile.DateTimeReceived) + ", "
                             + "SmsPhoneNumber   = '" + POut.String(smsFromMobile.SmsPhoneNumber) + "', "
                             + "MobilePhoneNumber= '" + POut.String(smsFromMobile.MobilePhoneNumber) + "', "
                             + "MsgPart          =  " + POut.Int(smsFromMobile.MsgPart) + ", "
                             + "MsgTotal         =  " + POut.Int(smsFromMobile.MsgTotal) + ", "
                             + "MsgRefID         = '" + POut.String(smsFromMobile.MsgRefID) + "', "
                             + "SmsStatus        =  " + POut.Int((int)smsFromMobile.SmsStatus) + ", "
                             + "Flags            = '" + POut.String(smsFromMobile.Flags) + "', "
                             + "IsHidden         =  " + POut.Bool(smsFromMobile.IsHidden) + ", "
                             + "MatchCount       =  " + POut.Int(smsFromMobile.MatchCount) + ", "
                             + "GuidMessage      = '" + POut.String(smsFromMobile.GuidMessage) + "' "
                             + "WHERE SmsFromMobileNum = " + POut.Long(smsFromMobile.SmsFromMobileNum);

            if (smsFromMobile.MsgText == null)
            {
                smsFromMobile.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, POut.StringNote(smsFromMobile.MsgText));

            Db.NonQ(command, paramMsgText);
        }
예제 #4
0
        ///<summary>Notifies all registered devices that a new SMS has been received. Pass in the patient for this SmsFromMobile if one exists. This will
        ///only be sent to registered devices attached to the ClinicNum</summary>
        public static void ODM_NewTextMessage(SmsFromMobile sms, long patNum = 0)
        {
            if (sms == null)
            {
                return;
            }
            //No need to bother mobile users with alert for eConfirmation responses.
            if (sms.IsConfirmationResponse)
            {
                return;
            }
            Patient pat        = Patients.GetLim(patNum);
            string  senderName = pat?.GetNameFirstOrPreferred();

            if (string.IsNullOrEmpty(senderName))
            {
                if (sms.MobilePhoneNumber.Length == 11 && sms.MobilePhoneNumber[0] == '1')
                {
                    senderName = $"({sms.MobilePhoneNumber[1]}{sms.MobilePhoneNumber[2]}{sms.MobilePhoneNumber[3]})" +
                                 $"{sms.MobilePhoneNumber[4]}{sms.MobilePhoneNumber[5]}{sms.MobilePhoneNumber[6]}-" +
                                 $"{sms.MobilePhoneNumber[7]}{sms.MobilePhoneNumber[8]}{sms.MobilePhoneNumber[9]}{sms.MobilePhoneNumber[10]}";
                }
                else
                {
                    senderName = sms.MobilePhoneNumber;
                }
            }
            //See ODM_NewTextMessage for input details.
            SendPushAlert(PushType.ODM_NewTextMessage, $@"New Message", $@"Received a new message from {senderName}", clinicNum: sms.ClinicNum,
                          listTags: new List <string>()
            {
                sms.MobilePhoneNumber
            });
        }
예제 #5
0

        
예제 #6
0
 ///<summary>Inserts one SmsFromMobile into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(SmsFromMobile smsFromMobile)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(smsFromMobile, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             smsFromMobile.SmsFromMobileNum = DbHelper.GetNextOracleKey("smsfrommobile", "SmsFromMobileNum");                  //Cacheless method
         }
         return(InsertNoCache(smsFromMobile, true));
     }
 }
예제 #7
0
        public static SmsFromMobile CreateSmsFromMobile(long patNum, long clinicNum, string patPhone, string provPhone, DateTime dateTimeReceived,
                                                        string msgText = "", string guidMessage = "")
        {
            if (string.IsNullOrEmpty(guidMessage))
            {
                guidMessage = Guid.NewGuid().ToString();
            }
            SmsFromMobile smsFromMobile = new SmsFromMobile()
            {
                GuidMessage       = guidMessage,
                PatNum            = patNum,
                MobilePhoneNumber = patPhone,
                SmsPhoneNumber    = provPhone,
                ClinicNum         = clinicNum,
                DateTimeReceived  = dateTimeReceived,
                MsgText           = string.IsNullOrEmpty(msgText) ? MiscUtils.CreateRandomAlphaNumericString(10) : msgText,
            };

            smsFromMobile.SmsFromMobileNum = SmsFromMobiles.Insert(smsFromMobile);
            return(smsFromMobile);
        }
예제 #8
0
 ///<summary>Returns true if Update(SmsFromMobile,SmsFromMobile) 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(SmsFromMobile smsFromMobile, SmsFromMobile oldSmsFromMobile)
 {
     if (smsFromMobile.PatNum != oldSmsFromMobile.PatNum)
     {
         return(true);
     }
     if (smsFromMobile.ClinicNum != oldSmsFromMobile.ClinicNum)
     {
         return(true);
     }
     if (smsFromMobile.CommlogNum != oldSmsFromMobile.CommlogNum)
     {
         return(true);
     }
     if (smsFromMobile.MsgText != oldSmsFromMobile.MsgText)
     {
         return(true);
     }
     if (smsFromMobile.DateTimeReceived != oldSmsFromMobile.DateTimeReceived)
     {
         return(true);
     }
     if (smsFromMobile.SmsPhoneNumber != oldSmsFromMobile.SmsPhoneNumber)
     {
         return(true);
     }
     if (smsFromMobile.MobilePhoneNumber != oldSmsFromMobile.MobilePhoneNumber)
     {
         return(true);
     }
     if (smsFromMobile.MsgPart != oldSmsFromMobile.MsgPart)
     {
         return(true);
     }
     if (smsFromMobile.MsgTotal != oldSmsFromMobile.MsgTotal)
     {
         return(true);
     }
     if (smsFromMobile.MsgRefID != oldSmsFromMobile.MsgRefID)
     {
         return(true);
     }
     if (smsFromMobile.SmsStatus != oldSmsFromMobile.SmsStatus)
     {
         return(true);
     }
     if (smsFromMobile.Flags != oldSmsFromMobile.Flags)
     {
         return(true);
     }
     if (smsFromMobile.IsHidden != oldSmsFromMobile.IsHidden)
     {
         return(true);
     }
     if (smsFromMobile.MatchCount != oldSmsFromMobile.MatchCount)
     {
         return(true);
     }
     if (smsFromMobile.GuidMessage != oldSmsFromMobile.GuidMessage)
     {
         return(true);
     }
     return(false);
 }
예제 #9
0
        ///<summary>Updates one SmsFromMobile 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(SmsFromMobile smsFromMobile, SmsFromMobile oldSmsFromMobile)
        {
            string command = "";

            if (smsFromMobile.PatNum != oldSmsFromMobile.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(smsFromMobile.PatNum) + "";
            }
            if (smsFromMobile.ClinicNum != oldSmsFromMobile.ClinicNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ClinicNum = " + POut.Long(smsFromMobile.ClinicNum) + "";
            }
            if (smsFromMobile.CommlogNum != oldSmsFromMobile.CommlogNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CommlogNum = " + POut.Long(smsFromMobile.CommlogNum) + "";
            }
            if (smsFromMobile.MsgText != oldSmsFromMobile.MsgText)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MsgText = " + DbHelper.ParamChar + "paramMsgText";
            }
            if (smsFromMobile.DateTimeReceived != oldSmsFromMobile.DateTimeReceived)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeReceived = " + POut.DateT(smsFromMobile.DateTimeReceived) + "";
            }
            if (smsFromMobile.SmsPhoneNumber != oldSmsFromMobile.SmsPhoneNumber)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SmsPhoneNumber = '" + POut.String(smsFromMobile.SmsPhoneNumber) + "'";
            }
            if (smsFromMobile.MobilePhoneNumber != oldSmsFromMobile.MobilePhoneNumber)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MobilePhoneNumber = '" + POut.String(smsFromMobile.MobilePhoneNumber) + "'";
            }
            if (smsFromMobile.MsgPart != oldSmsFromMobile.MsgPart)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MsgPart = " + POut.Int(smsFromMobile.MsgPart) + "";
            }
            if (smsFromMobile.MsgTotal != oldSmsFromMobile.MsgTotal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MsgTotal = " + POut.Int(smsFromMobile.MsgTotal) + "";
            }
            if (smsFromMobile.MsgRefID != oldSmsFromMobile.MsgRefID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MsgRefID = '" + POut.String(smsFromMobile.MsgRefID) + "'";
            }
            if (smsFromMobile.SmsStatus != oldSmsFromMobile.SmsStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SmsStatus = " + POut.Int((int)smsFromMobile.SmsStatus) + "";
            }
            if (smsFromMobile.Flags != oldSmsFromMobile.Flags)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Flags = '" + POut.String(smsFromMobile.Flags) + "'";
            }
            if (smsFromMobile.IsHidden != oldSmsFromMobile.IsHidden)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsHidden = " + POut.Bool(smsFromMobile.IsHidden) + "";
            }
            if (smsFromMobile.MatchCount != oldSmsFromMobile.MatchCount)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MatchCount = " + POut.Int(smsFromMobile.MatchCount) + "";
            }
            if (smsFromMobile.GuidMessage != oldSmsFromMobile.GuidMessage)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "GuidMessage = '" + POut.String(smsFromMobile.GuidMessage) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            if (smsFromMobile.MsgText == null)
            {
                smsFromMobile.MsgText = "";
            }
            OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, POut.StringNote(smsFromMobile.MsgText));

            command = "UPDATE smsfrommobile SET " + command
                      + " WHERE SmsFromMobileNum = " + POut.Long(smsFromMobile.SmsFromMobileNum);
            Db.NonQ(command, paramMsgText);
            return(true);
        }
예제 #10
0