示例#1
0
        public MESSAGEDC LoadByPrimaryKey(DBConnection Connection, int MESSAGE_ID)
        {
            MESSAGEDC     objMESSAGE = new MESSAGEDC();
            StringBuilder sql        = new StringBuilder();

            sql.Append("proc_MESSAGESLoadByPrimaryKey");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_MESSAGE_ID", DbType.Int32, MESSAGE_ID);


            IDataReader reader = null;

            if (Connection.Transaction != null)
            {
                reader = Connection.dataBase.ExecuteReader(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                reader = Connection.dataBase.ExecuteReader(dbCommandWrapper.DBCommand);
            }

            objMESSAGE = FillObject(reader);
            return(objMESSAGE);
        }
示例#2
0
        public IHttpActionResult ScheduleMeeting(MESSAGEDC objMessage)
        {
            /* -- CALL_ON does't need to covnert to event tz bz it's already mentioned on the popup.
             * if (!String.IsNullOrEmpty(objMessage.TIME_ZONE_CALL_ON)) {
             *  String strTimeZone = objMessage.TIME_ZONE_CALL_ON.Substring(objMessage.TIME_ZONE_CALL_ON.Length - 3, 3);
             *  String dtDate = objMessage.TIME_ZONE_CALL_ON.Substring(0,objMessage.TIME_ZONE_CALL_ON.Length - 4);
             *  objMessage.CALL_ON = Convert.ToDateTime(dtDate);
             *  bool iseffective = Utility.IsDayTimeSavingEffective((DateTime)objMessage.CALL_ON, strTimeZone);
             *  if(iseffective)
             *  {
             *      objMessage.TIME_ZONE_CALL_ON = Convert.ToDateTime(objMessage.CALL_ON).AddHours(1).ToString("MM/dd/yyyy HH:mm:ss.sss") + " " + strTimeZone;
             *  }
             *
             * }*/
            MESSAGEBL objMessageBL = new MESSAGEBL();

            try
            {
                int IsUpdated = objMessageBL.ScheduleMeeting(objMessage);
                return(Ok(new { IsUpdated }));
            }
            catch (Exception ex)
            {
                return(new TextResult(ex.Message, Request, ex.StackTrace));
            }
        }
示例#3
0
        private MESSAGEDC FillObject(IDataReader reader)
        {
            MESSAGEDC objMESSAGE = null;

            if (reader != null && reader.Read())
            {
                objMESSAGE                    = new MESSAGEDC();
                objMESSAGE.MESSAGE_ID         = (int)reader["MESSAGE_ID"];
                objMESSAGE.EVENT_ID           = (int)reader["EVENT_ID"];
                objMESSAGE.PURPOSE_ID         = (int)reader["PURPOSE_ID"];
                objMESSAGE.DELIVERY_METHOD_ID = (int)reader["DELIVERY_METHOD_ID"];
                objMESSAGE.CALL_ON            = reader["CALL_ON"] == DBNull.Value ? null : (DateTime?)reader["CALL_ON"];
                objMESSAGE.ACCESS_CODE        = reader["ACCESS_CODE"] == DBNull.Value ? null : (String)reader["ACCESS_CODE"];
                objMESSAGE.SUBJECT            = reader["SUBJECT"] == DBNull.Value ? null : (String)reader["SUBJECT"];
                objMESSAGE.CONTENTS           = reader["CONTENTS"] == DBNull.Value ? null : (String)reader["CONTENTS"];
                objMESSAGE.RECIPIENTS         = reader["RECIPIENTS"] == DBNull.Value ? null : (String)reader["RECIPIENTS"];
                objMESSAGE.CREATED_ON         = (DateTime)reader["CREATED_ON"];
                objMESSAGE.CREATED_BY         = (int)reader["CREATED_BY"];
                objMESSAGE.LOCK_COUNTER       = reader["LOCK_COUNTER"] == DBNull.Value ? null : (int?)reader["LOCK_COUNTER"];

                reader.Close();
                reader.Dispose();
            }
            return(objMESSAGE);
        }
示例#4
0
        public void SendDailyEmail(HttpRequestMessage request, DAILYDC dailyDC, bool isNewDaily)
        {
            int       sentStatus   = 0;
            MESSAGEBL objMessageBL = new MESSAGEBL();

            try
            {
                MESSAGEDC objMessage = new MESSAGEDC();
                objMessage.FROM       = ConfigurationManager.AppSettings["AdminEmail"];
                objMessage.RECIPIENTS = new EMAIL_GROUPSBL().GetEmailsAgainstClient(dailyDC.CLIENT_PM);
                if (String.IsNullOrEmpty(objMessage.FROM))
                {
                    throw new Exception("Daily email cann't be sent.</br>Daily's Admin email address is not configured. Please contact your administrator.");
                }
                if (String.IsNullOrEmpty(objMessage.RECIPIENTS))
                {
                    throw new Exception("Daily email cann't be sent.</br>Daily's To email address is not configured. Please contact your administrator.");
                }

                if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["SMTPAddress"]))
                {
                    throw new Exception("Your password cannot be reset.</br>SMTP address is not configured.");
                }
                string subjectPrefix = isNewDaily ? "New" : "Update";
                dailyDC.HYLAN_PROJECT_ID = dailyDC.HYLAN_PROJECT_ID == null ? "Unknown" : dailyDC.HYLAN_PROJECT_ID;
                dailyDC.JOB_FILE_NUMBER  = dailyDC.JOB_FILE_NUMBER == null ? "Unknown" : dailyDC.JOB_FILE_NUMBER;
                objMessage.SUBJECT       = subjectPrefix + " Daily Submitted " + dailyDC.HYLAN_PROJECT_ID + "_" + dailyDC.JOB_FILE_NUMBER;


                string msgBody   = "<!DOCTYPE HTML><html><body><table cellspacing='0' cellpadding='0'>";
                string col1Style = " style='font-weight: bold;background-color: #f2f2f2;padding-left:10px;padding-right:10px;' ";
                string col2Style = " style='padding-left: 10px;' ";
                string rowStyle  = " style='height:25px;' ";
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + " >Submitted by: </td><td " + col2Style + " > " + dailyDC.MODIFIED_BY_NAME + "<td></tr>";  //new to change need to display the name
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + ">Date/Time: </td><td " + col2Style + " > " + dailyDC.MODIFIED_ON.ToString("MM/dd/yyyy HH:mm") + "<td></tr>";
                //msgBody += "<tr><td colspan = 2 >" + dailyDC.DAILY_TYPE_NAME + "<td></tr>";
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + ">Daily Type: </td><td " + col2Style + " > " + dailyDC.DAILY_TYPE_NAME + "<td></tr>";
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + ">Day: </td><td " + col2Style + " > " + dailyDC.DAILY_DAYS + "<td></tr>";
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + ">Status: </td><td " + col2Style + " > " + dailyDC.DAILY_STATUS_NAME + "<td></tr>";
                msgBody += "<tr " + rowStyle + " ><td " + col1Style + ">Work Date: </td><td " + col2Style + " > " + dailyDC.DAILY_DATE.ToString("MM/dd/yyyy") + "<td></tr>";

                msgBody            += "</table></body></html>";
                objMessage.CONTENTS = msgBody;
                sentStatus          = objMessageBL.SendSMTPEmail(objMessage);
                if (sentStatus != 1)
                {
                    throw new Exception("Daily email cann't be sent.due to some error. Please contact your administrator.");
                }
            }
            catch (Exception exp)
            {
                int userID = Common.Utility.GetUserID(request);
                Util.Utility.InsertIntoErrorLog(exp.Message, exp.StackTrace, userID);
            }
        }
示例#5
0
 public IHttpActionResult GetEmptyModel()
 {
     try
     {
         MESSAGEDC resultObject = new MESSAGEDC();
         return(Ok(new { resultObject }));
     }
     catch (Exception ex)
     {
         return(new TextResult(ex.Message, Request, ex.StackTrace));
     }
 }
示例#6
0
        public IHttpActionResult SendEmail(MESSAGEDC objMessage)
        {
            MESSAGEBL objMessageBL = new MESSAGEBL();

            try
            {
                int IsUpdated = objMessageBL.SendSMTPEmail(objMessage);
                return(Ok(new { IsUpdated }));
            }
            catch (Exception ex) {
                return(new TextResult(ex.Message, Request, ex.StackTrace));
            }
        }
示例#7
0
        private int Update(DBConnection Connection, MESSAGEDC objMESSAGE)
        {
            int updateCount = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_MESSAGESUpdate");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);


            dbCommandWrapper.AddInParameter("p_MESSAGE_ID", DbType.Int32, objMESSAGE.MESSAGE_ID);
            dbCommandWrapper.AddInParameter("p_EVENT_ID", DbType.Int32, objMESSAGE.EVENT_ID);
            dbCommandWrapper.AddInParameter("p_PURPOSE_ID", DbType.Int32, objMESSAGE.PURPOSE_ID);
            dbCommandWrapper.AddInParameter("p_DELIVERY_METHOD_ID", DbType.Int32, objMESSAGE.DELIVERY_METHOD_ID);
            dbCommandWrapper.AddInParameter("p_CALL_ON", DbType.DateTime, objMESSAGE.CALL_ON);
            dbCommandWrapper.AddInParameter("p_ACCESS_CODE", DbType.String, objMESSAGE.ACCESS_CODE);
            dbCommandWrapper.AddInParameter("p_SUBJECT", DbType.String, objMESSAGE.SUBJECT);
            dbCommandWrapper.AddInParameter("p_CONTENTS", DbType.String, objMESSAGE.CONTENTS);
            dbCommandWrapper.AddInParameter("p_RECIPIENTS", DbType.String, objMESSAGE.RECIPIENTS);
            dbCommandWrapper.AddInParameter("p_CREATED_ON", DbType.DateTime, objMESSAGE.CREATED_ON);
            dbCommandWrapper.AddInParameter("p_CREATED_BY", DbType.Int32, objMESSAGE.CREATED_BY);
            dbCommandWrapper.AddInParameter("p_LOCK_COUNTER", DbType.Int32, objMESSAGE.LOCK_COUNTER);

            try
            {
                if (Connection.Transaction != null)
                {
                    updateCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
                }
                else
                {
                    updateCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
                }

                if (updateCount == 0)
                {
                    objMESSAGE.IsDirty = IsDirty = true;
                }
            }
            catch (Exception exp)
            {
                //Utilities.InsertIntoErrorLog("Error: MESSAGE UPDATE ", exp.Message + "\r\n" + exp.StackTrace, objMESSAGE.CREATED_BY);
                objMESSAGE.SetError(exp);
                throw exp;
            }

            return(updateCount);
        }
示例#8
0
        private MESSAGEDC FillObject(DataRow row)
        {
            MESSAGEDC objMESSAGE = null;

            objMESSAGE                    = new MESSAGEDC();
            objMESSAGE.MESSAGE_ID         = (int)row["MESSAGE_ID"];
            objMESSAGE.EVENT_ID           = (int)row["EVENT_ID"];
            objMESSAGE.PURPOSE_ID         = (int)row["PURPOSE_ID"];
            objMESSAGE.DELIVERY_METHOD_ID = (int)row["DELIVERY_METHOD_ID"];
            objMESSAGE.CALL_ON            = row["CALL_ON"] == DBNull.Value ? null : (DateTime?)row["CALL_ON"];
            objMESSAGE.ACCESS_CODE        = row["ACCESS_CODE"] == DBNull.Value ? null : (String)row["ACCESS_CODE"];
            objMESSAGE.SUBJECT            = row["SUBJECT"] == DBNull.Value ? null : (String)row["SUBJECT"];
            objMESSAGE.CONTENTS           = row["CONTENTS"] == DBNull.Value ? null : (String)row["CONTENTS"];
            objMESSAGE.RECIPIENTS         = row["RECIPIENTS"] == DBNull.Value ? null : (String)row["RECIPIENTS"];
            objMESSAGE.CREATED_ON         = (DateTime)row["CREATED_ON"];
            objMESSAGE.CREATED_BY         = (int)row["CREATED_BY"];
            objMESSAGE.LOCK_COUNTER       = row["LOCK_COUNTER"] == DBNull.Value ? null : (int?)row["LOCK_COUNTER"];

            return(objMESSAGE);
        }
示例#9
0
        public MESSAGEDC LoadByPrimaryKey(int MESSAGE_ID)
        {
            DBConnection objConnection = new DBConnection();
            MESSAGEDA    objMESSAGEDA  = new MESSAGEDA();
            MESSAGEDC    objMESSAGEDC  = null;

            try
            {
                objConnection.Open(false);
                objMESSAGEDC = objMESSAGEDA.LoadByPrimaryKey(objConnection, MESSAGE_ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objConnection.Close();
            }
            return(objMESSAGEDC);
        }
示例#10
0
        public int ScheduleMeeting(MESSAGEDC objMessage)
        {
            int    returnStatus    = 1;
            string orginalContents = objMessage.CONTENTS;
            string msgBody         = "<!DOCTYPE HTML><html><body><table>";

            msgBody += "<tr><td>" + objMessage.CONTENTS + "</td></tr>";
            msgBody += "<tr><td><b>Event:</b> " + ((!String.IsNullOrEmpty(objMessage.EVENT_NAME)) ? objMessage.EVENT_NAME : "") + "</td></tr>";
            msgBody += "<tr><td><b>RMAG:</b> " + ((!String.IsNullOrEmpty(objMessage.RMAG_NAMES))?objMessage.RMAG_NAMES.TrimEnd(',').Replace(",", ", "):"") + "</td></tr>";
            msgBody += "<tr><td><b>Conference Call/Access Code:</b> " + objMessage.ACCESS_CODE + "</td></tr>";
            msgBody += "<tr><td><b>Purpose of Call:</b> " + objMessage.CALL_PURPOSE_TEXT + "</td></tr>";
            msgBody += "<tr><td><b>Date/Time of Call:</b> " + objMessage.TIME_ZONE_CALL_ON + "</td></tr>";
            if (!String.IsNullOrEmpty(objMessage.USER_INFO))
            {
                msgBody += objMessage.USER_INFO;
            }
            msgBody            += "</table></body></html>";
            objMessage.CONTENTS = msgBody;
            returnStatus        = SendSMTPEmail(objMessage);
            objMessage.CONTENTS = orginalContents;
            //returnStatus = UpdateDatabase(objMessage);
            return(1);
        }
示例#11
0
        private int Delete(DBConnection Connection, MESSAGEDC objMESSAGE)
        {
            int deleteCount = 0;

            StringBuilder sql = new StringBuilder();

            sql.Append("proc_MESSAGESDelete");

            DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection);

            dbCommandWrapper.AddInParameter("p_MESSAGE_ID", DbType.Int32, objMESSAGE.MESSAGE_ID);

            if (Connection.Transaction != null)
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction);
            }
            else
            {
                deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand);
            }

            return(deleteCount);
        }
示例#12
0
        public int SendSMTPEmail(MESSAGEDC objMessage, Boolean isSystemGenerated = false)
        {
            int         returnStatus = 1;
            MailMessage msg          = new MailMessage();

            msg.Priority = System.Net.Mail.MailPriority.High;
            if (!String.IsNullOrEmpty(objMessage.FROM))
            {
                msg.From = new MailAddress(objMessage.FROM);
            }
            else
            {
                throw new Exception("Your message could not be sent.</br>Sender's email address is not provided. Please update your profile.");
            }
            msg.Subject = objMessage.SUBJECT;

            string[] strTempAddress = objMessage.RECIPIENTS.Split(new string[] { ",", ";" }, StringSplitOptions.RemoveEmptyEntries);
            for (int intAddressCounter = 0; intAddressCounter < strTempAddress.Length; intAddressCounter++)
            {
                //if(isSystemGenerated)
                //    msg.Bcc.Add(strTempAddress[intAddressCounter]);
                //else
                msg.To.Add(strTempAddress[intAddressCounter]);
            }


            //msg.CC.Add(msg.From);

            AlternateView plainView = AlternateView.CreateAlternateViewFromString(objMessage.CONTENTS.Replace("null", ""), null, MediaTypeNames.Text.Html);

            msg.AlternateViews.Add(plainView);
            string smtpAddress = GetSMTPAddress();

            if (smtpAddress.Trim() != string.Empty)
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtpAddress.Split(':')[0]);
                if (smtpAddress.Split(':').Length > 1 && smtpAddress.Split(':')[1].Trim() != string.Empty)
                {
                    smtp.Port = Convert.ToInt32(smtpAddress.Split(':')[1]);
                }
                else
                {
                    smtp.Port = 25;
                }
                smtp.UseDefaultCredentials = true;
                smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                //if (GetSMTPAdminEmail() != string.Empty && GetSMTPAdminPassword() != string.Empty)
                //    smtp.Credentials = new NetworkCredential(GetSMTPAdminEmail(), GetSMTPAdminPassword());
                try
                {
                    // smtp.EnableSsl = true;
                    smtp.Send(msg);
                }
                catch (SmtpFailedRecipientsException smtpFailRecipientsExp)
                {
                    String errorMessage    = String.Empty;
                    String failedRecipient = String.Empty;
                    for (int i = 0; i < smtpFailRecipientsExp.InnerExceptions.Length; i++)
                    {
                        if (smtpFailRecipientsExp.InnerExceptions[i].StatusCode != SmtpStatusCode.Ok)
                        {
                            //switch (smtpFailRecipientsExp.InnerExceptions[i].StatusCode)
                            //{
                            //    case SmtpStatusCode.TransactionFailed: errorMessage += ""; break;

                            //}
                            failedRecipient += smtpFailRecipientsExp.InnerExceptions[0].FailedRecipient + ",";
                        }
                    }
                    throw new Exception("Your message could not be sent to '" + failedRecipient.TrimEnd(','));
                }
                catch (System.Net.Mail.SmtpException smtpExp)
                {
                    if (smtpExp.StatusCode == SmtpStatusCode.TransactionFailed)
                    {
                        throw new Exception("Your message could not be sent.</br>Sender’s email address '" + objMessage.FROM + "' could not be verified. Please update your profile.");
                    }
                    else
                    {
                        throw new Exception("Your message could not be sent.</br>" + smtpExp.Message);
                    }
                }
                finally
                {
                    msg.Dispose();
                }
            }
            else
            {
                throw new Exception("Your message could not be sent.</br>SMTP address is not configured.");
            }
            return(returnStatus);
        }
示例#13
0
        public int EmailResetPassword(string selectedUserIds, int currentUserId, string username, string emailId, bool isFromManageUsers)
        {
            int          updatedCount  = 0;
            DBConnection objConnection = new DBConnection();
            USERDA       objUSERDA     = new USERDA();
            MESSAGEBL    objMessageBL  = new MESSAGEBL();
            string       NewPassword   = Utility.GenerateRandomPassword(8);

            try
            {
                string[] UserID    = selectedUserIds.Split(',');
                string[] UserName  = username.Split(',');
                string[] UserEmail = emailId.Split(',');
                objConnection.Open(true);
                updatedCount = objUSERDA.ResetPassword(objConnection, selectedUserIds, currentUserId, NewPassword);
                IsDirty      = objUSERDA.IsDirty;
                if (!IsDirty)
                {
                    MESSAGEDC objMessage = new MESSAGEDC();
                    objMessage.FROM = ConfigurationManager.AppSettings["AdminEmail"];
                    if (String.IsNullOrEmpty(objMessage.FROM))
                    {
                        throw new Exception("Your password cannot be reset.</br>Administrator's email address is not configured. Please contact your administrator.");
                    }
                    if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["SMTPAddress"]))
                    {
                        throw new Exception("Your password cannot be reset.</br>SMTP address is not configured.");
                    }
                    for (int i = 0; i < UserID.Length; i++)
                    {
                        objMessage.SUBJECT    = "Password Reset";
                        objMessage.RECIPIENTS = UserEmail[i];
                        string orginalContents = objMessage.CONTENTS;
                        string msgBody         = "<!DOCTYPE HTML><html><body><table>";
                        if (!isFromManageUsers)
                        {
                            msgBody += "<tr><td>Your password has been reset upon your request.</td></tr><tr><td></td></tr><tr><td></td></tr>";
                        }
                        else
                        {
                            msgBody += "<tr><td>Your password has been changed as below</td></tr><tr><td></td></tr><tr><td></td></tr>";
                        }
                        msgBody              += "<tr><td><b>Username:</b> " + UserName[i] + "</td></tr>";
                        msgBody              += "<tr><td><b>New Password:</b> " + NewPassword + "</td></tr>";
                        msgBody              += "</table></body></html>";
                        objMessage.CONTENTS   = msgBody;
                        objMessage.CREATED_BY = currentUserId;

                        updatedCount = objMessageBL.SendSMTPEmail(objMessage);

                        objMessage.CONTENTS = "Password has been reset for the user " + username;
                        //if (!isFromManageUsers)
                        //{
                        //    updatedCount = objMessageBL.UpdateDatabase(objMessage, objConnection, false);
                        //}
                    }
                }
                if (IsDirty)
                {
                    objConnection.Rollback();
                }
                else
                {
                    objConnection.Commit();
                }
            }
            catch (Exception ex)
            {
                objConnection.Rollback();
                throw ex;
            }
            finally
            {
                objConnection.Close();
            }
            return(updatedCount);
        }
示例#14
0
        public int Insert(List <USERDC> objUSERs)
        {
            int          insertedCount = 0;
            bool         IsDirty       = false;
            DBConnection objConnection = new DBConnection();
            USERDA       objUSERDA     = new USERDA();

            try
            {
                objConnection.Open(true);
                foreach (USERDC objUSER in objUSERs)
                {
                    objUSER.CREATED_ON = objUSER.MODIFIED_ON = DateTime.Now;
                    objUSER.PASSWORD   = Utility.GenerateRandomPassword(8);
                    insertedCount      = objUSERDA.Insert(objConnection, objUSER);
                    if (objUSER.USER_ID == -111)
                    {
                        throw new Exception("User Name '" + objUSER.USER_NAME + "' already exists. All other changes saved successfully.");
                    }

                    //IsDirty = objUSERDA.IsDirty;
                    //if (IsDirty == false)
                    //{
                    //    objUSERDA.UpdateUserCompanies(objConnection, objUSER);
                    //}
                    //else
                    //{
                    //    break;
                    //}

                    int       EmailSent = 0;
                    MESSAGEDC objMsgDC  = new MESSAGEDC();
                    MESSAGEBL objMsgBL  = new MESSAGEBL();
                    USERDA    objUser   = new USERDA();
                    USERDC    objUserDC = new USERDC();

                    objUserDC = objUser.LoadByPrimaryKey(objConnection, objUSER.USER_ID);
                    Task.Run(() =>
                    {
                        StringBuilder strContents = new StringBuilder();
                        strContents.Append("<!DOCTYPE HTML><html><body><table>");
                        strContents.Append("<tr><td>Your profile for Hylan has been created.</td></tr><tr><td></td></tr>");
                        strContents.Append("<tr><td>Following are your account credentials:</td></tr><tr><td></td></tr>");
                        strContents.Append("<tr><td><b>Username:</b> " + objUSER.USER_NAME + "</td></tr>");
                        strContents.Append("<tr><td><b>Password:</b> " + objUSER.PASSWORD + "</td></tr>");
                        strContents.Append("</table></body></html>");
                        try
                        {
                            objMsgDC.FROM       = objUserDC.EMAIL_ADDRESS;
                            objMsgDC.SUBJECT    = "Your profile is created.";
                            objMsgDC.CONTENTS   = strContents.ToString();
                            objMsgDC.RECIPIENTS = objUSER.EMAIL_ADDRESS;
                            EmailSent           = objMsgBL.SendSMTPEmail(objMsgDC, true);
                        }
                        catch (Exception exp)
                        {
                            EPay.DataAccess.Utilities.InsertIntoErrorLog("Error: USER PROFILE CREATED NOTIFICATION EMAIL ", exp.Message + "\r\n" + exp.StackTrace, objUSER.MODIFIED_BY);
                        }
                    });
                }
                if (IsDirty)
                {
                    objConnection.Rollback();
                }
                else
                {
                    objConnection.Commit();
                }
            }
            catch (Exception ex)
            {
                objConnection.Rollback();
                throw ex;
            }
            finally
            {
                objConnection.Close();
            }
            return(insertedCount);
        }
示例#15
0
        public int Update(List <USERDC> objUSERs, ref List <EXCEPTIONDC> lstExceptions)
        {
            int          updatedCount  = 0;
            DBConnection objConnection = new DBConnection();
            USERDA       objUSERDA     = new USERDA();

            try
            {
                foreach (USERDC objUSER in objUSERs)
                {
                    objConnection.Open(true);
                    try
                    {
                        objUSER.MODIFIED_ON = DateTime.Now;
                        updatedCount        = objUSERDA.Update(objConnection, objUSER);
                        if (objUSERDA.IsDirty)
                        {
                            break;
                        }

                        ///  Email sent an Match Complete
                        int           EmailSent     = 0;
                        MESSAGEDC     objMsgDC      = new MESSAGEDC();
                        MESSAGEBL     objMsgBL      = new MESSAGEBL();
                        List <string> lstUserEmails = new List <string>();
                        USERDA        objUser       = new USERDA();
                        USERDC        objUserDC     = new USERDC();

                        objUserDC = objUser.LoadByPrimaryKey(objConnection, objUSER.USER_ID);

                        // lstUserEmails = objUser.GetUsersEmailAddressByEventId(objUSER.USER_ID, "", 62, objConnection);

                        //if (lstUserEmails.Count > 0)
                        //{
                        Task.Run(() =>
                        {
                            //if (!lstUserEmails.Contains(objUSER.EMAIL_ADDRESS))
                            //    lstUserEmails.Add(objUSER.EMAIL_ADDRESS);
                            StringBuilder strContents = new StringBuilder();
                            strContents.Append("<!DOCTYPE HTML><html><body><table>");
                            strContents.Append("<tr><td>Profile for user  <b>" + objUSER.USER_NAME + "</b>. has been updated.");
                            strContents.Append("<tr><td>Please log into the system to verify changes.");
                            strContents.Append("</table></body></html>");
                            try
                            {
                                objMsgDC.FROM       = GetSMTPAdminEmail();
                                objMsgDC.SUBJECT    = "Your profile is changed.";
                                objMsgDC.CONTENTS   = strContents.ToString();
                                objMsgDC.RECIPIENTS = String.Join(";", objUserDC.EMAIL_ADDRESS);
                                EmailSent           = objMsgBL.SendSMTPEmail(objMsgDC, true);
                            }
                            catch (Exception exp)
                            {
                                EPay.DataAccess.Utilities.InsertIntoErrorLog("Error: USER PROFILE CHANGED NOTIFICATION EMAIL ", exp.Message + "\r\n" + exp.StackTrace, objUSER.MODIFIED_BY);
                            }
                        });
                        // }
                        objConnection.Commit();
                    }
                    catch (Exception exp)
                    {
                        EXCEPTIONDC objExcption = new EXCEPTIONDC();
                        objExcption.FIELD_ID          = objUSER.USER_ID;
                        objExcption.EXCEPTION_MESSAGE = exp.Message;
                        objExcption.STACK_TRACK       = exp.StackTrace;
                        lstExceptions.Add(objExcption);
                        objConnection.Rollback();
                        // throw exp;
                    }
                }
                if (lstExceptions.Count > 0)
                {
                    throw new Exception(lstExceptions[0].EXCEPTION_MESSAGE);
                }
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                objConnection.Close();
            }

            return(updatedCount);
        }