Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="i_nResponseCode"></param>
        /// <param name="i_sResponseMessage"></param>
        /// <returns></returns>
        public bool UpdateResponseCode(string i_sConnectionString, int i_nCompanyId, DataTable m_tblNotificationResponse)
        {
            bool bReturn = false;

            try
            {
                WindowServiceCommon.WriteErrorLog("INFO: Enter Update Response Code function.........");

                EmailNotificationSL objEmailNotificationSL = new EmailNotificationSL();

                bReturn = objEmailNotificationSL.UpdateNotificationResponse(i_sConnectionString, i_nCompanyId, m_tblNotificationResponse);

                WindowServiceCommon.WriteErrorLog("INFO: Exit Update Response Code function.........");
            }
            catch (Exception exp)
            {
                WindowServiceCommon.WriteErrorLog("ERROR: " + MethodBase.GetCurrentMethod() + " " + exp.Message);

                bReturn = false;
                throw exp;
            }
            return(bReturn);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool broadCast()
        {
            bool   bReturn = false;
            string sEmailServiceForCompanies = "";

            try
            {
                WindowServiceCommon.WriteErrorLog("INFO : Enter broadCast fuction..........");

                sEmailServiceForCompanies = ConfigurationManager.AppSettings.Get(InsiderTrading_NotificationService.WindowServiceConstEnum.AppSettingsKey.EmailServiceForCompanies);

                string [] splitCompanyName = sEmailServiceForCompanies.Split(',');

                EmailNotificationSL objEmailNotificationSL = new EmailNotificationSL();
                string dbConnectionString = InsiderTrading_NotificationService.WindowServiceCommon.getSystemConnectionString();

                WindowServiceCommon.WriteErrorLog("INFO: Connection string : -" + dbConnectionString);

                IEnumerable <InsiderTradingDAL.CompanyIDListDTO> lstCompanyIDListDTO = objEmailNotificationSL.GetCompanyIds(dbConnectionString);

                foreach (var item in lstCompanyIDListDTO)
                {
                    WindowServiceCommon.WriteErrorLog("INFO: Company ID is : - " + item.CompanyId + " Company Name:- " + item.CompanyName);

                    if (ContainsString(splitCompanyName, item.ConnectionDatabaseName))
                    {
                        WindowServiceCommon.WriteErrorLog("INFO: If Company Exists in Config Company ID is : - " + item.CompanyId + " Company Name:- " + item.CompanyName);

                        DataTable tblNotificationQueueResponse = new DataTable("NotificationQueueResponse");
                        tblNotificationQueueResponse.Columns.Add(new DataColumn("RowId", typeof(int)));
                        tblNotificationQueueResponse.Columns.Add(new DataColumn("NotificationQueueId", typeof(int)));
                        tblNotificationQueueResponse.Columns.Add(new DataColumn("CompanyIdentifierCodeId", typeof(int)));
                        tblNotificationQueueResponse.Columns.Add(new DataColumn("ResponseStatusCodeId", typeof(int)));
                        tblNotificationQueueResponse.Columns.Add(new DataColumn("ResponseMessage", typeof(string)));

                        IEnumerable <InsiderTradingDAL.CompanyDetailsForNotificationDTO> lstCompanyDetailsForNotificationDTO = objEmailNotificationSL.GetCompanyDetailsForNotification(dbConnectionString, item.CompanyId);



                        if (lstCompanyDetailsForNotificationDTO != null)
                        {
                            CompanyDetailsForNotificationDTO objCompanyDetailsForNotificationDTO = lstCompanyDetailsForNotificationDTO.FirstOrDefault();
                            if (objCompanyDetailsForNotificationDTO != null)
                            {
                                WindowServiceCommon.WriteErrorLog("INFO: Fetching Company Details SMTP :- " + objCompanyDetailsForNotificationDTO.SmtpServer);
                                WindowServiceCommon.WriteErrorLog("INFO: Fetching Company Details User :- " + objCompanyDetailsForNotificationDTO.SmtpUserName);

                                ConfigurationModel objConfigurationModel = new ConfigurationModel();
                                objConfigurationModel.SmtpServer     = objCompanyDetailsForNotificationDTO.SmtpServer;
                                objConfigurationModel.SmtpUserName   = objCompanyDetailsForNotificationDTO.SmtpUserName;
                                objConfigurationModel.SmtpPortNumber = objCompanyDetailsForNotificationDTO.SmtpPortNumber;
                                //objConfigurationModel.SmtpPassword = objCompanyDetailsForNotificationDTO.SmtpPassword;

                                using (DataSecurity ds = new DataSecurity())
                                {
                                    objConfigurationModel.SmtpPassword = ds.DecryptData(objCompanyDetailsForNotificationDTO.SmtpPassword);;
                                }

                                IEnumerable <InsiderTradingDAL.NotificationSendListDTO> lstNotificationSendListDTO = objEmailNotificationSL.GetNotificationSendList(dbConnectionString, item.CompanyId);

                                WindowServiceCommon.WriteErrorLog("INFO: Fetch Notification Send List");

                                if (lstNotificationSendListDTO != null)
                                {
                                    WindowServiceCommon.WriteErrorLog("INFO: Record found in Notification Send List");

                                    int nRowIDCount = 1;
                                    foreach (var mailPart in lstNotificationSendListDTO)
                                    {
                                        if (Convert.ToInt32(mailPart.ModeCodeId) == Convert.ToInt32(WindowServiceConstEnum.NotificationType.EmailNotificationType))
                                        {
                                            WindowServiceCommon.WriteErrorLog("INFO: Only Email Type Record Select");

                                            DataRow row = tblNotificationQueueResponse.NewRow();

                                            Recipient objRecipient = new Recipient();
                                            objRecipient.EmailAddress      = mailPart.UserContactInfo;
                                            objRecipient.EmailSubject      = mailPart.Subject;
                                            objRecipient.EmailBody         = mailPart.Contents;
                                            objRecipient.Signature         = mailPart.Signature;
                                            objRecipient.DocumentName      = mailPart.DocumentName;
                                            objRecipient.DocumentPath      = mailPart.DocumentPath;
                                            objRecipient.CommunicationFrom = mailPart.CommunicationFrom;

                                            WindowServiceCommon.WriteErrorLog("INFO: Mail Sending Details:- " + item.CompanyId + " NotificationQueueId :- " + mailPart.NotificationQueueId);


                                            WindowServiceCommon.WriteErrorLog("INFO: Email Address :-" + mailPart.UserContactInfo);
                                            WindowServiceCommon.WriteErrorLog("INFO: Subject :- " + mailPart.Subject);
                                            WindowServiceCommon.WriteErrorLog("INFO: Email Body:- " + mailPart.Contents);
                                            WindowServiceCommon.WriteErrorLog("INFO: Signature: -" + mailPart.Signature);

                                            //objRecipient.NotificationQueueID
                                            //Add in Datatable
                                            row["RowId"] = nRowIDCount;
                                            row["NotificationQueueId"] = mailPart.NotificationQueueId;
                                            if (mailPart.CompanyIdentifierCodeId != null && mailPart.CompanyIdentifierCodeId > 0)
                                            {
                                                row["CompanyIdentifierCodeId"] = mailPart.CompanyIdentifierCodeId;
                                            }
                                            else
                                            {
                                                row["CompanyIdentifierCodeId"] = DBNull.Value;
                                            }

                                            int o_nResponseCode = 0;

                                            string o_sResponseMessage = "";

                                            WindowServiceCommon.WriteErrorLog("INFO: Call Send Mail Function............");

                                            bool bResult = SendMail(objRecipient, objConfigurationModel, out o_nResponseCode, out o_sResponseMessage);
                                            if (o_nResponseCode != null && o_nResponseCode > 0)
                                            {
                                                row["ResponseStatusCodeId"] = o_nResponseCode;
                                            }
                                            else
                                            {
                                                row["ResponseStatusCodeId"] = DBNull.Value;
                                            }
                                            row["ResponseMessage"] = o_sResponseMessage;
                                            tblNotificationQueueResponse.Rows.Add(row);

                                            WindowServiceCommon.WriteErrorLog("INFO: Response Code :-" + o_nResponseCode + " Response Message:- " + o_sResponseMessage);
                                        }
                                        else if (Convert.ToInt32(mailPart.ModeCodeId) == Convert.ToInt32(WindowServiceConstEnum.NotificationType.SMSNotifactionType))
                                        {
                                            DataRow row = tblNotificationQueueResponse.NewRow();

                                            WindowServiceCommon.WriteErrorLog("INFO: Only SMS Type Record Select");

                                            row["RowId"] = nRowIDCount;
                                            row["NotificationQueueId"] = mailPart.NotificationQueueId;
                                            if (mailPart.CompanyIdentifierCodeId != null && mailPart.CompanyIdentifierCodeId > 0)
                                            {
                                                row["CompanyIdentifierCodeId"] = mailPart.CompanyIdentifierCodeId;
                                            }
                                            else
                                            {
                                                row["CompanyIdentifierCodeId"] = DBNull.Value;
                                            }

                                            int    o_nResponseCode    = Convert.ToInt32(WindowServiceConstEnum.Code.BroadcastResponseSuccess);
                                            string o_sResponseMessage = "SMS Part is remaining....";
                                            //Send Message part is remaining
                                            //  bool bResult = SendMessage();
                                            if (o_nResponseCode != null && o_nResponseCode > 0)
                                            {
                                                row["ResponseStatusCodeId"] = o_nResponseCode;
                                            }
                                            else
                                            {
                                                row["ResponseStatusCodeId"] = DBNull.Value;
                                            }
                                            row["ResponseMessage"] = o_sResponseMessage;
                                            tblNotificationQueueResponse.Rows.Add(row);
                                        }
                                        nRowIDCount++;
                                    }
                                }
                            }

                            WindowServiceCommon.WriteErrorLog("INFO: Update Response Started for Company ID............" + item.CompanyId);


                            bool bUpdateResponseCode = UpdateResponseCode(dbConnectionString, item.CompanyId, tblNotificationQueueResponse);

                            WindowServiceCommon.WriteErrorLog("INFO: Update Response End for Company ID............" + item.CompanyId);
                        }
                    }
                }

                bReturn = true;
            }
            catch (Exception exp)
            {
                //  WindowServiceCommon.WriteErrorLog("Eroor Occured in Send Mail Function " + exp.Message);

                WindowServiceCommon.WriteErrorLog("ERROR: " + MethodBase.GetCurrentMethod() + " " + exp.Message);

                bReturn = false;
                throw exp;
            }
            return(bReturn);
        }