示例#1
0
        public string UpdateMsgReadStatus(string isRead, string msgDetails)
        {
            string result = string.Empty;
            List <MVCModels.MessagingModel> lstMsg = new List <MVCModels.MessagingModel>();

            DataControl.CurrentInfo objCurInfo = new DataControl.CurrentInfo();
            DataControl.BLMessaging objMsg     = new DataControl.BLMessaging();
            try
            {
                if (!string.IsNullOrEmpty(msgDetails))
                {
                    string[] ar = msgDetails.Split('^');
                    if (ar.Length > 0)
                    {
                        for (int i = 0; i < ar.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(Convert.ToString(ar[i]).Split('~')[0]))
                            {
                                string targetAddress = Convert.ToString(ar[i]).Split('~')[1];
                                MVCModels.MessagingModel objMsgModel = new MVCModels.MessagingModel();
                                objMsgModel.Company_Code   = objCurInfo.GetCompanyCode();
                                objMsgModel.Msg_Code       = Convert.ToString(ar[i]).Split('~')[0];
                                objMsgModel.Target_Address = targetAddress;
                                lstMsg.Add(objMsgModel);
                            }
                        }
                        int rowsAffected = 0;
                        rowsAffected = objMsg.UpdateMsgReadStatus(objCurInfo.GetCompanyCode(), lstMsg, isRead);
                        if (rowsAffected > 0)
                        {
                            if (isRead == "1")
                            {
                                result = "The conversation has been marked as read.";
                            }
                            else
                            {
                                result = "The conversation has been marked as unread.";
                            }
                        }
                        else
                        {
                            if (isRead == "1")
                            {
                                result = "Error while change the conversation as read.";
                            }
                            else
                            {
                                result = "Error while change the conversation as unread.";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicObj = new Dictionary <string, string>();
                DataControl.Impl.ExceptionHandler.WriteLog(ex: ex, dic: dicObj);
            }
            return(result);
        }//The conversation has been moved to the Trash.
示例#2
0
        public string InsertMessage(string subject, string msgContent, string sentStatus, string sentType, string toUsers, string ccUsers, string msgCode)
        {
            string result = string.Empty;
            List <MVCModels.MessagingModel> lstMsgContent = new List <MVCModels.MessagingModel>();
            List <MVCModels.MessagingModel> lstMsgUsers   = new List <MVCModels.MessagingModel>();

            DataControl.CurrentInfo  objCurInfo         = new DataControl.CurrentInfo();
            DataControl.BLMessaging  objMsg             = new DataControl.BLMessaging();
            MVCModels.MessagingModel objMsgContentModel = new MVCModels.MessagingModel();
            try
            {
                #region message content details
                if (sentStatus.ToUpper().Trim() == "SEND")
                {
                    if (!string.IsNullOrEmpty(msgCode))
                    {
                        objMsgContentModel.Msg_Code = msgCode;
                    }
                    else
                    {
                        sentType = "STRAIGHT";
                        msgCode  = Convert.ToString(objMsg.GetSeqNumber("SEQ_tbl_SFA_Noticeboard_Content_MSG"));
                        objMsgContentModel.Msg_Code = msgCode;
                    }


                    objMsgContentModel.Sent_Status = "SENT";
                }
                else if (sentStatus.ToUpper().Trim() == "DRAFT")
                {
                    sentType = "STRAIGHT";
                    if (!string.IsNullOrEmpty(msgCode))
                    {
                        objMsgContentModel.Msg_Code = msgCode;
                    }
                    else
                    {
                        msgCode = Convert.ToString(objMsg.GetSeqNumber("SEQ_tbl_SFA_Noticeboard_Content_MSG"));
                        objMsgContentModel.Msg_Code = msgCode;
                    }

                    objMsgContentModel.Sent_Status = "DRAFTED";
                }
                objMsgContentModel.Company_Code    = objCurInfo.GetCompanyCode();
                objMsgContentModel.Subject         = subject.Replace("á", "<").Replace("í", ">");
                objMsgContentModel.Message_Content = msgContent.Replace("á", "<").Replace("í", ">"); //ALT+160 = á , ALT+161 = í
                objMsgContentModel.Is_Richtext     = "1";
                objMsgContentModel.Priority        = "1";
                // objMsgContentModel.Date_From = "GETDATE()";
                objMsgContentModel.Sender     = objCurInfo.GetUserCode();
                objMsgContentModel.Sent_Type  = sentType;
                objMsgContentModel.Row_Status = "1";
                lstMsgContent.Add(objMsgContentModel);
                #endregion message content details
                #region message user details
                //TO USERS
                string[] ar = toUsers.Split(',');
                for (int i = 0; i < ar.Length; i++)
                {
                    if (!string.IsNullOrEmpty(ar[i]))
                    {
                        MVCModels.MessagingModel objMsgUserModel = new MVCModels.MessagingModel();
                        objMsgUserModel.Company_Code   = objCurInfo.GetCompanyCode();
                        objMsgUserModel.Msg_Code       = msgCode;
                        objMsgUserModel.Target_Address = ar[i];
                        objMsgUserModel.Address_Type   = "TO";
                        objMsgUserModel.Row_Status     = "1";
                        objMsgUserModel.Project_Code   = "MSGSYSTEM";
                        objMsgUserModel.Ack_Reqd       = "N";
                        objMsgUserModel.IsRead         = "0";
                        lstMsgUsers.Add(objMsgUserModel);
                    }
                }
                string[] arcc = ccUsers.Split(',');
                for (int i = 0; i < arcc.Length; i++)
                {
                    if (!string.IsNullOrEmpty(arcc[i]))
                    {
                        MVCModels.MessagingModel objMsgUserModel = new MVCModels.MessagingModel();
                        objMsgUserModel.Company_Code   = objCurInfo.GetCompanyCode();
                        objMsgUserModel.Msg_Code       = msgCode;
                        objMsgUserModel.Target_Address = arcc[i];
                        objMsgUserModel.Address_Type   = "CC";
                        objMsgUserModel.Row_Status     = "1";
                        objMsgUserModel.Project_Code   = "MSGSYSTEM";
                        objMsgUserModel.Ack_Reqd       = "N";
                        objMsgUserModel.IsRead         = "0";
                        lstMsgUsers.Add(objMsgUserModel);
                    }
                }
                #endregion message user details

                int rowsAffected = 0;
                if ("DRAFTED" == sentType.ToUpper())
                {
                    //DRAFTED THEN SEND THE MSG
                    rowsAffected = objMsg.UpdateDraftedMail(objCurInfo.GetCompanyCode(), lstMsgContent, lstMsgUsers, msgCode);
                }
                else
                {
                    rowsAffected = objMsg.InsertSendOrDraftMail(objCurInfo.GetCompanyCode(), lstMsgContent, lstMsgUsers, sentStatus);
                    //REPLY, FORWARD, FORWARDALL MSG
                    //  rowsAffected = objMsg.InsertReplyOrForwardMail(objCurInfo.GetCompanyCode(), lstMsgContent, lstMsgUsers);
                }
                if (rowsAffected > 0)
                {
                    if (sentStatus.ToUpper().Trim() == "DRAFT")
                    {
                        result = "SUCCESS:" + msgCode + "~Your message has been drafted";
                    }
                    else
                    {
                        result = "SUCCESS:" + msgCode + "~Your message has been sent";
                    }
                }
                else
                {
                    result = "ERROR:" + msgCode + "~Sorry. Error while sennding the message ...";
                }
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicObj = new Dictionary <string, string>();
                DataControl.Impl.ExceptionHandler.WriteLog(ex: ex, dic: dicObj);
                result = "Sorry. Error while sennding the message ...";
            }
            return(result);
        }
示例#3
0
        }//The conversation has been moved to the Trash.

        public string UpdateMsgStatus(string rowStatus, string msgCode, string mailMode)
        {
            string result = string.Empty;
            List <MVCModels.MessagingModel> lstMsg = new List <MVCModels.MessagingModel>();

            DataControl.CurrentInfo objCurInfo = new DataControl.CurrentInfo();
            DataControl.BLMessaging objMsg     = new DataControl.BLMessaging();
            try
            {
                if (!string.IsNullOrEmpty(msgCode))
                {
                    string[] ar = msgCode.Split('^');
                    if (ar.Length > 0)
                    {
                        for (int i = 0; i < ar.Length; i++)
                        {
                            if (!string.IsNullOrEmpty(Convert.ToString(ar[i])))
                            {
                                MVCModels.MessagingModel objMsgModel = new MVCModels.MessagingModel();
                                objMsgModel.Company_Code   = objCurInfo.GetCompanyCode();
                                objMsgModel.Msg_Code       = Convert.ToString(ar[i]).Split('~')[0];
                                objMsgModel.Target_Address = Convert.ToString(ar[i]).Split('~')[1];
                                objMsgModel.Sender         = Convert.ToString(ar[i]).Split('~')[1];
                                lstMsg.Add(objMsgModel);
                            }
                        }
                        int rowsAffected = 0;
                        if ("INBOX" == mailMode || "TRASH" == mailMode || "UNREAD" == mailMode)
                        {
                            rowsAffected = objMsg.UpdateMsgStatus(objCurInfo.GetCompanyCode(), lstMsg, rowStatus);
                        }
                        else if ("SENT" == mailMode)
                        {
                            rowsAffected = objMsg.UpdateSentMsgStatus(objCurInfo.GetCompanyCode(), lstMsg, rowStatus);
                        }
                        else
                        {
                            rowsAffected = objMsg.UpdateMsgStatusOtherthanInbox(objCurInfo.GetCompanyCode(), lstMsg, "3");
                        }
                        if (rowsAffected > 0)
                        {
                            if ("TRASH" == mailMode)
                            {
                                result = "The conversation has been deleted";
                            }
                            else if ("INBOX" == mailMode)
                            {
                                result = "The conversation has been moved to the Trash.";
                            }
                            else
                            {
                                result = "The conversation has been deleted";
                            }
                        }
                        else
                        {
                            if ("TRASH" == mailMode)
                            {
                                result = "Error while delete the conversation.";
                            }
                            else
                            {
                                result = "Error while move the conversation to trash";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dicObj = new Dictionary <string, string>();
                DataControl.Impl.ExceptionHandler.WriteLog(ex: ex, dic: dicObj);
            }
            return(result);
        }