Пример #1
0
        public int AddToSMSQueue(SMSVo smsVo)
        {
            EmailSMSDao emailSMSDao = new EmailSMSDao();
            int         smsId       = 0;

            try
            {
                smsId = emailSMSDao.AddToSMSQueue(smsVo);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "EmailSMSBo.cs:AddToSMSQueue(SMSVo smsVo)");
                object[] objects = new object[1];
                objects[0] = smsVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(smsId);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="smsVo"></param>
        /// <param name="adviserId"></param>
        /// <param name="smsType"></param>
        /// <returns>bool Result</returns>
        public bool AddToAdviserSMSLog(SMSVo smsVo, int adviserId, string smsType)
        {
            bool       bResult    = false;
            AdvisorDao adviserDao = new AdvisorDao();

            try
            {
                bResult = adviserDao.AddToAdviserSMSLog(smsVo, adviserId, smsType);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AdvisorBo.cs:UpdateAdviserSMSLicence(int adviserId, int smsLincence)");


                object[] objects = new object[2];
                objects[0] = adviserId;
                objects[1] = smsVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(bResult);
        }
Пример #3
0
        public int AddToSMSQueue(SMSVo smsVo)
        {
            int       smsId = 0;
            Database  db;
            DbCommand addToSMSQueueCmd;

            try
            {
                db = DatabaseFactory.CreateDatabase("wealtherp");
                addToSMSQueueCmd = db.GetStoredProcCommand("AddOutgoingSmsToQueue");
                db.AddInParameter(addToSMSQueueCmd, "@number", DbType.String, smsVo.Mobile.ToString());
                db.AddInParameter(addToSMSQueueCmd, "@message", DbType.String, smsVo.Message);
                db.AddInParameter(addToSMSQueueCmd, "@sent", DbType.Int16, smsVo.IsSent);
                db.AddInParameter(addToSMSQueueCmd, "@AdviserId", DbType.Int16, smsVo.AdviserId);
                db.AddOutParameter(addToSMSQueueCmd, "@Id", DbType.Int32, 10000);
                if (db.ExecuteNonQuery(addToSMSQueueCmd) != 0)
                {
                    smsId = int.Parse(db.GetParameterValue(addToSMSQueueCmd, "Id").ToString());
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorDao.cs:AddToSMSQueue(SMSVo smsVo)");
                object[] objects = new object[1];
                objects[0] = smsVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(smsId);
        }
Пример #4
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            //System.Threading.Thread.Sleep(2000);
            int          smsCount    = 0;
            int          smsLicence  = 0;
            SMSVo        smsVo       = new SMSVo();
            List <int>   alertIdList = new List <int>();
            EmailSMSBo   emailSMSBo  = new EmailSMSBo();
            List <SMSVo> smsVoList   = new List <SMSVo>();
            AdvisorBo    advisorBo   = new AdvisorBo();
            AlertsBo     alertsBo    = new AlertsBo();
            string       mobileNo;
            int          adviserId = 0;

            dsAdviserCustomerAlerts = (DataSet)ViewState["vsDsAdviserCustomerAlert"];
            if (Session["advisorVo"] != null)
            {
                adviserId = ((AdvisorVo)Session["advisorVo"]).advisorId;
            }
            if (lblLincenceValue.Text != "No SMS Licence Left!!")
            {
                smsLicence = int.Parse(lblLincenceValue.Text.ToString());
            }
            int i = 0;

            if (dsAdviserCustomerAlerts != null)
            {
                foreach (GridViewRow gvRow in gvCustomerSMSAlerts.Rows)
                {
                    if (gvRow.RowType == DataControlRowType.DataRow)
                    {
                        if (((CheckBox)gvRow.FindControl("chkCustomerSMSAlert")).Checked)
                        {
                            smsVo = new SMSVo();
                            if (dsAdviserCustomerAlerts != null)
                            {
                                mobileNo = dsAdviserCustomerAlerts.Tables[0].Rows[i]["Mobile"].ToString();
                                if (mobileNo != "0")
                                {
                                    if (mobileNo.Length <= 10)
                                    {
                                        smsVo.Mobile = Int64.Parse("91" + dsAdviserCustomerAlerts.Tables[0].Rows[i]["Mobile"].ToString());
                                    }
                                    else
                                    {
                                        smsVo.Mobile = Int64.Parse(mobileNo);
                                    }
                                }
                            }

                            smsVo.Message = CreateSMSMessage(dsAdviserCustomerAlerts.Tables[0].Rows[i]["CustomerName"].ToString(), dsAdviserCustomerAlerts.Tables[0].Rows[i]["Name"].ToString(),
                                                             dsAdviserCustomerAlerts.Tables[0].Rows[i]["AEL_EventCode"].ToString(), dsAdviserCustomerAlerts.Tables[0].Rows[i]["AEN_EventMessage"].ToString(),
                                                             advisorVo.OrganizationName);
                            smsVo.CustomerId = int.Parse(gvCustomerSMSAlerts.DataKeys[gvRow.RowIndex].Values["CustomerId"].ToString());
                            smsVo.IsSent     = 0;
                            if (dsAdviserCustomerAlerts.Tables[0].Rows[i]["AlertId"].ToString() != null)
                            {
                                smsVo.AlertId = int.Parse(dsAdviserCustomerAlerts.Tables[0].Rows[i]["AlertId"].ToString());
                            }
                            else
                            {
                                smsVo.AlertId = 0;
                            }
                            smsVoList.Add(smsVo);
                            alertIdList.Add(int.Parse(gvCustomerSMSAlerts.DataKeys[gvRow.RowIndex].Values["AlertId"].ToString()));
                            smsCount++;
                        }
                    }
                    i++;
                }
                if (smsCount <= smsLicence && smsCount != 0)
                {
                    smsVoList = emailSMSBo.AddToSMSQueue(smsVoList);

                    smsLicence = smsLicence - smsCount;
                    advisorBo.UpdateAdviserSMSLicence(adviserId, smsLicence);
                    advisorBo.AddToAdviserSMSLog(smsVoList, adviserId, "Alert");
                    alertsBo.UpdateAlertStatus(alertIdList, 1);
                    if (smsLicence == 0)
                    {
                        lblLincenceValue.Text = "No SMS Licence Left!!";
                    }
                    else
                    {
                        lblLincenceValue.Text = smsLicence.ToString();
                        GetAdviserCustomerAlerts(out dsAdviserCustomerAlerts);
                        SuccessMessage.Visible = true;
                    }
                }
                else if (smsCount == 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Please select an Alert!!');", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('You dont have enough SMS Credits to process this request');", true);
                }
            }
        }
Пример #5
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            int   smsCount   = 0;
            int   smsLicence = 0;
            SMSVo smsVo      = new SMSVo();

            EmailSMSBo   emailSMSBo = new EmailSMSBo();
            List <SMSVo> smsVoList  = new List <SMSVo>();
            AdvisorBo    advisorBo  = new AdvisorBo();

            int adviserId = 0;

            if (Session["advisorVo"] != null)
            {
                adviserId = ((AdvisorVo)Session["advisorVo"]).advisorId;
            }
            if (lblLincenceValue.Text != "No SMS Credit Left!!")
            {
                smsLicence = int.Parse(lblLincenceValue.Text.ToString());
            }

            foreach (GridViewRow gvRow in gvCustomerSMSAlerts.Rows)
            {
                if (gvRow.RowType == DataControlRowType.DataRow)
                {
                    if (((CheckBox)gvRow.FindControl("chkCustomerSMSAlert")).Checked)
                    {
                        smsVo = new SMSVo();
                        if (gvRow.Cells[2].Text.Trim().Length <= 10)
                        {
                            smsVo.Mobile = Int64.Parse("91" + gvRow.Cells[2].Text.Trim());
                        }
                        else
                        {
                            smsVo.Mobile = int.Parse(gvRow.Cells[2].Text.Trim());
                        }
                        smsVo.Message    = txtMessage.Text.ToString();
                        smsVo.CustomerId = int.Parse(gvCustomerSMSAlerts.DataKeys[gvRow.RowIndex].Values["CustomerId"].ToString());
                        smsVo.IsSent     = 0;
                        smsVo.AdviserId  = adviserId;
                        smsVoList.Add(smsVo);

                        smsCount++;
                    }
                }
            }
            if (smsCount <= smsLicence && smsCount != 0)
            {
                smsVoList = emailSMSBo.AddToSMSQueue(smsVoList);

                //smsLicence = smsLicence - smsCount;
                //advisorBo.UpdateAdviserSMSLicence(adviserId, smsCount);
                advisorBo.AddToAdviserSMSLog(smsVoList, adviserId, "Manual Message");

                if (smsLicence == 0)
                {
                    lblLincenceValue.Text = "No SMS Licence Left!!";
                }
                else
                {
                    lblLincenceValue.Text = smsLicence.ToString();
                }
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('SMS has been Sent to the Selected Customers!!');", true);
            }
            else if (smsCount == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Please select a Customer!!');", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('You dont have enough SMS Credits to process this request');", true);
            }
        }