Beispiel #1
0
        /// <summary>
        /// To send route approval notification
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ApproverButton_Click(object sender, EventArgs e)
        {
            string ResultValue  = string.Empty;
            string message      = string.Empty;
            string WorkFlowCode = UtilBO.WorkflowRouteApproval;
            string emailSubject = string.Empty;
            string emailBody    = string.Empty;

            ProjectRouteBO   objProjectRoute     = new ProjectRouteBO();
            ProjectRouteBLL  objProjectRouteBLL  = new ProjectRouteBLL();
            ProjectRouteList objProjectRouteList = new ProjectRouteList();

            objProjectRoute.WorkFlowApprover = UtilBO.WorkflowRouteApproval;
            objProjectRoute.Project_Id       = Convert.ToInt32(Session["PROJECT_ID"]);

            objProjectRoute = objProjectRouteBLL.getWOrkFlowApprovalID(objProjectRoute);

            if ((objProjectRoute) != null)
            {
                (new NotificationBLL()).SendEmail(Convert.ToInt32(Session["PROJECT_ID"]), UtilBO.WorkflowRouteApproval);
                #region for sending SMS
                WIS_ConfigBO  WIS_ConfigBO  = new WIS_ConfigBO();
                WIS_ConfigBLL WIS_ConfigBLL = new WIS_ConfigBLL();
                WIS_ConfigBO = WIS_ConfigBLL.GetConfigSMSsending();
                if (WIS_ConfigBO != null)
                {
                    if (WIS_ConfigBO.MobileStatus == "Y")
                    {
                        string          Result             = string.Empty;
                        string          SendsmsTest        = objProjectRoute.SmsText + objProjectRoute.ProjectCode + objProjectRoute.ProjectName;
                        NotificationBO  SMSNotificationBO  = new NotificationBO();
                        NotificationBLL SMSNotificationBLL = new NotificationBLL();
                        SMSNotificationBO.ProviderMobileNo = WIS_ConfigBO.MobileNumber;
                        SMSNotificationBO.ProviderPasword  = WIS_ConfigBO.MobilePassword;
                        SMSNotificationBO.ProviderURL      = WIS_ConfigBO.SiteUrl;

                        SMSNotificationBO.CellNumber = objProjectRoute.CellNumber;
                        SMSNotificationBO.SmsText    = SendsmsTest;

                        Result = SMSNotificationBLL.SENDSMS(SMSNotificationBO);
                    }
                }
                #endregion

                //NotificationObj.SendEmail(objProjectRoute.EmailID, objProjectRoute.EmailSubject, objProjectRoute.EmailBody, objProjectRoute.ProjectCode, objProjectRoute.ProjectName);
                //ResultValue = NotificationObj.SendSMS(objProjectRoute.CellNumber, objProjectRoute.SmsText, objProjectRoute.ProjectCode, objProjectRoute.ProjectName);

                ProjectRouteBO objApprovalHeaderSave = new ProjectRouteBO();
                objApprovalHeaderSave.WorkFlowApproverID   = objProjectRoute.WorkFlowApproverID;
                objApprovalHeaderSave.StatusID             = objProjectRoute.StatusID;
                objApprovalHeaderSave.CreatedBy            = Convert.ToInt32(Session["USER_ID"]);
                objApprovalHeaderSave.PageCode             = "RTA";
                objApprovalHeaderSave.ApproverUserID       = objProjectRoute.ApproverUserID;
                objApprovalHeaderSave.WorkFlowDefinitionID = objProjectRoute.WorkFlowDefinitionID;

                #region email formate
                switch (WorkFlowCode)
                {
                case "RTA":
                    emailSubject = string.Format("{0} {1}", objProjectRoute.EmailSubject, objProjectRoute.ProjectName);
                    //emailBody = emailBody.Replace("@@PROJECTNAME", objProjectRoute.EmailBody);
                    emailBody = objProjectRoute.EmailBody.Replace("@@PROJECTNAME", objProjectRoute.ProjectName);
                    break;

                default:
                    emailSubject = objProjectRoute.EmailSubject;
                    break;
                }
                string        approverName = objProjectRoute.ApproverUserName;
                StringBuilder sb           = new StringBuilder();
                sb.Append("Dear " + approverName + ",");
                sb.Append("<br/><br/>");
                sb.Append(emailBody);
                sb.Append("<br/><br/>");
                sb.Append("Thanks and Regards,");
                sb.Append("<br/>");
                sb.Append("WIS - UETCL Team");
                #endregion

                objApprovalHeaderSave.EmailSubject = emailSubject;
                objApprovalHeaderSave.EmailBody    = sb.ToString();

                message = objProjectRouteBLL.AddApprovalTrackheader(objApprovalHeaderSave);

                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Route Approval Notification has been sent";
                }
                if (message != "")
                {
                    int ProjectId = Convert.ToInt32(Session["PROJECT_ID"]);
                    findRouteStatusafterSave(ProjectId);
                    getFinalRouteApprovalDetial(ProjectId);
                    GetApproavlComments();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                    ApproverButton.Visible = false;
                }
            }
            else
            {
                message = "Route Approver is not defined";
                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
            }

            findRouteStatusafterSave(Convert.ToInt32(Session["PROJECT_ID"]));
        }