Exemplo n.º 1
0
        public static void SendLectureAttendanceToRTA()
        {
            string                MODULE_NAME  = "MarkHolidays";
            string                MethodName   = "SendLectureAttendanceToRTA";
            Notification          notification = new Notification();
            DASystemConfiguration sysConfig    = new DASystemConfiguration();
            DataTable             dt;

            try
            {
                notification.AdapterChannelId = DALConstants.AdapterChannels.SMTP_CHANNEL1;
                notification.RetryCount       = Constants.RETRY_COUNT;
                dt = sysConfig.GetSystemConfigurationByKey("COMPANY_NAME");
                notification.NsFrom = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                dt = sysConfig.GetSystemConfigurationByKey("COMPANY_EMAIL");
                notification.NsFromAdd = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                notification.IS_HTML   = false;
                notification.Priority  = (int)Enumaration.NotificationPriority.High;
                dt = sysConfig.GetSystemConfigurationByKey("NOTIFICATION_EMAIL_RECIPIENTS_TO");
                notification.RecipientTo = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                dt = sysConfig.GetSystemConfigurationByKey("NOTIFICATION_EMAIL_RECIPIENTS_CC");
                notification.RecipientCC = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                dt = sysConfig.GetSystemConfigurationByKey("LECTURE_ATTENDANCE_RPT_UPLOAD_PATH");
                notification.DocumentList = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString() + "Attendance-" + DateTime.Now.ToString("dd-MM-yyyy") + "\\";
                notification.Body         = notification.GetMessageBodyFromMessageKey("LectureAttendanceNotification");
                notification.Subject      = notification.GetMessageSubjectFromMessageKey("LectureAttendanceNotification");
                notification.CreatedBy    = ConfigurationManager.AppSettings["CREATED_BY"];
                notification.InsertNotification(notification);
                Logger.getInstance().Debug(MODULE_NAME, MethodName, "Lectures Sent Successfully");
                Console.WriteLine("Lectures Sent Successfully");
                //Wait for 3 seconds
                Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                Logger.getInstance().Error(MODULE_NAME, MethodName, ex);
                Console.WriteLine("Lecture Notification Failed");
                // Wait For 5 seconds
                Thread.Sleep(5000);
            }
        }
Exemplo n.º 2
0
        // Added by AVANZA\muhammad.uzair on 25/09/2017 11:27:10
        public void SendHolidayNotification(string date)
        {
            string                MODULE_NAME = "Holiday";
            string                MethodName  = "SendHolidayNotification";
            DataTable             ds          = this.DA.CheckClassesOnDate(date);
            DASystemConfiguration sysConfig   = new DASystemConfiguration();

            foreach (DataRow row in ds.Rows)
            {
                Notification notification = new Notification();
                DataTable    dt;
                try
                {
                    notification.AdapterChannelId = DALConstants.AdapterChannels.SMS_CHANNEL1;
                    notification.RetryCount       = Constants.RETRY_COUNT;
                    dt = sysConfig.GetSystemConfigurationByKey("COMPANY_NAME");
                    notification.NsFrom = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                    dt = sysConfig.GetSystemConfigurationByKey("COMPANY_EMAIL");
                    notification.NsFromAdd   = dt.Rows[0][Entities.SystemConfiguration.VALUE].ToString();
                    notification.IS_HTML     = false;
                    notification.Priority    = (int)Enumaration.NotificationPriority.High;
                    notification.RecipientTo = row["MOBILE"].ToString();
                    StringBuilder sb      = new StringBuilder(notification.GetMessageBodyFromMessageKey("HolidayCancellationNotification"));
                    string        message = sb.Replace("#{Customer.FirstName}", row["NAME_EN"].ToString()).Replace("#{Customer.Date}", date).ToString();
                    notification.Body      = message;
                    notification.Subject   = notification.GetMessageSubjectFromMessageKey("HolidayCancellationNotification");
                    notification.CreatedBy = ConfigurationManager.AppSettings["CREATED_BY"];
                    notification.InsertNotification(notification);
                    Logger.getInstance().Debug(MODULE_NAME, MethodName, "Holiday Notification Sent Successfully");
                }
                catch (Exception ex)
                {
                    Logger.getInstance().Error(MODULE_NAME, MethodName, ex);
                }
            }
        }
        public override BaseState GotoNextState()
        {
            //Added by Fahim Nasir on 26-9-2017
            DAWorkflowCallLog daWCL = new DAWorkflowCallLog();

            daWCL.CURRENT_STATE = "InternalAssessmentState";
            daWCL.ContractId    = this.DataAccess.ContractId;

            try
            {
                DASystemConfiguration sysConfig     = new DASystemConfiguration();
                var hasInternalAssessmentTestResult = this.DataAccess.HasInternalAssessmentTestResult();
                var IsPaymentF_Cleared = this.DataAccess.IsPaymentF_Cleared();

                daWCL.PROCESS += "hasInternalAssessmentTestResult: " + hasInternalAssessmentTestResult + ", ";
                daWCL.PROCESS += "IsPaymentF_Cleared: " + IsPaymentF_Cleared + ", ";

                // Commented by AVANZA\muhammad.uzair on 25/09/2017 14:46:26
                //Payment F not needed to be checked here
                //if (hasInternalAssessmentTestResult == true && IsPaymentF_Cleared == true)
                if (hasInternalAssessmentTestResult == true)
                {
                    var hasPassedInternalAssessmentTest = this.DataAccess.HasPassedInternalAssessmentTest();
                    daWCL.PROCESS += "hasPassedInternalAssessmentTest: " + hasPassedInternalAssessmentTest + ", ";

                    if (hasPassedInternalAssessmentTest == 1) // 1 means pass
                    {
                        var hasRTAScheduledRoadTest      = this.DataAccess.HasRTAScheduledRoadTest();
                        var IsCurrentStagePaymentCleared = this.DataAccess.IsCurrentStagePaymentCleared();

                        daWCL.PROCESS += "hasRTAScheduledRoadTest: " + hasRTAScheduledRoadTest + ", ";
                        daWCL.PROCESS += "IsCurrentStagePaymentCleared: " + IsCurrentStagePaymentCleared + ", ";

                        // Added by MUHAMMADUZAIR\avanza on 22/09/2017 11:06:42
                        // Modified by AVANZA\muhammad.uzair on 25/09/2017 15:26:25
                        //Added check for payment
                        DataTable ds = sysConfig.GetSystemConfigurationByKey("IS_MANDATORY_ADDITIONAL_CLASSES_BEFORE_ROAD_TEST");

                        string isMandatoryAdditionalClasses = string.Empty;
                        if (ds != null && ds.Rows.Count > 0 && ds.Columns.Contains("VALUE"))
                        {
                            isMandatoryAdditionalClasses = ds.Rows[0]["VALUE"].ToString();
                        }
                        else
                        {
                            daWCL.PROCESS += "SYSTEM CONFIGURATION TABLE HAS NO VALUE FOR IS_MANDATORY_ADDITIONAL_CLASSES_BEFORE_ROAD_TEST";
                        }

                        daWCL.PROCESS += "isMandatoryAdditionalClasses: " + isMandatoryAdditionalClasses + ", ";

                        if (IsPaymentF_Cleared == true)
                        {
                            if (hasRTAScheduledRoadTest == true && IsCurrentStagePaymentCleared == true)
                            {
                                if (isMandatoryAdditionalClasses != "true")
                                {
                                    //if highway or night or additional classes count =0 means all classes are scheduled
                                    // in case we might be required to check attendance of these classes in future as well
                                    daWCL.RETURNED_STATE = "RoadTestScheduledState";
                                    daWCL.Log();
                                    return(new RoadTestScheduledState(this.Manager));
                                }
                                else
                                {
                                    var hasTakenAllOtherClasses = this.DataAccess.HasTakenAllOtherClasses();
                                    daWCL.PROCESS += "hasTakenAllOtherClasses: " + hasTakenAllOtherClasses + ", ";

                                    if (hasTakenAllOtherClasses == true)
                                    {
                                        daWCL.RETURNED_STATE = "RoadTestScheduledState";
                                        daWCL.Log();
                                        return(new RoadTestScheduledState(this.Manager));
                                    }
                                    else
                                    {
                                        daWCL.RETURNED_STATE = daWCL.CURRENT_STATE;
                                        daWCL.PROCESS       += "ALL OTHER CLASSES ARE NOT SCHEDULED";
                                        daWCL.Log();
                                        LogMessages("ALL OTHER CLASSES ARE NOT SCHEDULED");
                                        return(this);
                                    }
                                }
                            }
                            else
                            {
                                daWCL.RETURNED_STATE = daWCL.CURRENT_STATE;
                                daWCL.PROCESS       += "RTA SCHEDULED ROAD TEST WAS NOT PASSED OR CURRENT STAGE PAYMENT NOT CLEARED";
                                daWCL.Log();
                                LogMessages("RTA SCHEDULED ROAD TEST WAS NOT PASSED OR CURRENT STAGE PAYMENT NOT CLEARED");
                                return(this);
                            }
                        }
                        else
                        {
                            daWCL.RETURNED_STATE = daWCL.CURRENT_STATE;
                            daWCL.PROCESS       += "FINAL ROAD TEST PAYMENT NOT CLEARED";
                            daWCL.Log();
                            LogMessages("FINAL ROAD TEST PAYMENT NOT CLEARED");
                            return(this);
                        }
                    }
                    else if (hasPassedInternalAssessmentTest == 0) // 0 means fail
                    {
                        //AVANZA\muhammad.uzair 8/9/17
                        this.DataAccess.GeneratePaymentForInternalAssessmentTestFailure();
                        daWCL.RETURNED_STATE = "AdditionalClassesPendingState";
                        daWCL.Log();

                        // Added by AVANZA\muhammad.uzair on 28/09/2017 10:32:51
                        //updating the is_updated bit of exam
                        this.DataAccess.UpdateResultBitForCustomerExam((int)Enumaration.ExamIdMap.InternalAssessment);


                        // added by MUHAMMAD.AWAIS 8/8/2017
                        return(new AdditionalClassesPendingState(this.Manager));
                    }
                    else // for absent and other cases value would be 2
                    {
                        // Added by MUHAMMADUZAIR\Administrator as Onsite Support on 03/12/2017 18:07:29
                        this.DataAccess.GeneratePaymentForInternalAssessmentTestFailure();

                        daWCL.RETURNED_STATE = "PracticalScheduledBState";
                        daWCL.PROCESS       += "CUSTOMER IS ABSENT IN INTERNAL ASSESSMENT";
                        daWCL.Log();
                        LogMessages("CUSTOMER IS ABSENT IN INTERNAL ASSESSMENT");
                        // internal test if absent then should be scheduled form here

                        // Added by AVANZA\muhammad.uzair on 28/09/2017 10:32:51
                        //updating the is_updated bit of exam
                        this.DataAccess.UpdateResultBitForCustomerExam((int)Enumaration.ExamIdMap.InternalAssessment);

                        return(this);
                    }
                }
                else
                {
                    daWCL.RETURNED_STATE = daWCL.CURRENT_STATE;
                    daWCL.PROCESS       += "INTERNAL ASSESSMENT TEST RESULT DOES NOT EXIST OR PAYMENT F NOT CLEARED";
                    daWCL.Log();
                    LogMessages("INTERNAL ASSESSMENT TEST RESULT DOES NOT EXIST OR PAYMENT F NOT CLEARED");
                    return(this);
                }
            }
            catch (Exception ex)
            {
                daWCL.RETURNED_STATE = daWCL.CURRENT_STATE;
                daWCL.PROCESS        = ex.Message;
                daWCL.Log();
                Logger.getInstance().Error("WorkflowManager", "InternalAssessmentState::GotoNextState()", ex);
                LogMessages("ERROR: " + ex.Message);
                return(this);
            }
        }