Пример #1
0
        public string[] Send_Message_TradeConfirmation()
        {
            string[] result  = new string[2];
            int      success = 0;
            int      fail    = 0;

            foreach (MessaGenerateAndSendAAA item in messagesObjs_tradeConfirm)
            {
                CCSBAL    bal    = new CCSBAL();
                CommonBAL comBal = new CommonBAL();
                Thread.Sleep(5000);
                try
                {
                    client.Timeout = 25000;
                    client.Send(item.Mail);

                    // bal.CCS_Email_NotificationSent(item.MessageInfoBo.Cust_Code, Indication_EmailNotification.Email_NotificationType_TradeConfirmation, "HTML Formatted Email", comBal.GetCurrentServerDate().ToShortDateString());
                    //success = success + 1;
                }
                catch (Exception ex)
                {
                    //bal.CCS_Email_NotificationFailure(item.MessageInfoBo.Cust_Code, Indication_EmailNotification.Email_NotificationType_TradeConfirmation, "HTML Formatted Email", comBal.GetCurrentServerDate().ToShortDateString(), ex.Message);
                    //fail = fail + 1;
                }
            }
            //result[0] = Convert.ToString(success);
            //result[1] = Convert.ToString(fail);

            return(result);
        }
        public void SetMessages_MoneyTrans()
        {
            DataTable dt  = new DataTable();
            CCSBAL    bal = new CCSBAL();

            messagesObjs_moneyTrans = new List <MessageObject_MoneyTran>();
            dt = bal.CCS_GetTemp_MoneyTransactionForEmail_ForSending();

            foreach (DataRow dr in dt.Rows)
            {
                double      doubleTryParse;
                int         intTryParse;
                MailAddress to                     = new MailAddress(dr["Email"].ToString());
                MailMessage message_dep            = new MailMessage(from, to);
                EmailMonetyTrans_NotificationBO bo = new EmailMonetyTrans_NotificationBO();
                bo.Cust_Code         = dr["Cust_Code"].ToString();
                bo.Entry_Branch_Name = (dr["Branch_Name"].ToString() == Indication_BrokerBranch.HeadOffice) ? (dr["Branch_Name"].ToString()) : (dr["Branch_Name"].ToString() + " Branch");
                bo.VoucherNo         = dr["VoucherNo"].ToString();
                bo.ChequekBank       = dr["ChequekBank"].ToString();
                bo.ChequeBranch      = dr["ChequeBranch"].ToString();
                bo.Payment_Media_No  = dr["Payment_Media_No"].ToString();
                bo.Payment_Media     = dr["Payment_Media"].ToString();
                bo.Deposit_Withdraw  = dr["Deposit_Withdraw"].ToString();
                bo.TransReason       = dr["TransReason"].ToString();
                bo.CollectionBranch  = (dr["CollectionBranch"].ToString() == Indication_BrokerBranch.HeadOffice)?(dr["CollectionBranch"].ToString()):(dr["CollectionBranch"].ToString() + " Branch");
                bo.ReferenceNo       = Convert.ToInt32(dr["ReferenceNo"].ToString());
                double TransactionAmount = 0.00;
                if (double.TryParse(dr["Amount"].ToString(), out doubleTryParse))
                {
                    bo.Amount = doubleTryParse;
                }
                double CurrentBalance = 0.00;
                if (double.TryParse(dr["Money_Balance"].ToString(), out doubleTryParse))
                {
                    bo.Money_Balance = doubleTryParse;
                }

                if (bo.Deposit_Withdraw == "Deposit")
                {
                    message_dep = SetMoneyDepositInfoBody(message_dep, bo);
                    messagesObjs_moneyTrans.Add(new MessageObject_MoneyTran()
                    {
                        MessageInfoBo = bo, Mail = message_dep
                    });
                }
                else if (bo.Deposit_Withdraw == "Withdraw")
                {
                    message_dep = SetMoneyWithdrawInfoBody(message_dep, bo);
                    messagesObjs_moneyTrans.Add(new MessageObject_MoneyTran()
                    {
                        MessageInfoBo = bo, Mail = message_dep
                    });
                }
            }
        }
        public string[] Send_Message_MoneyTrans()
        {
            string[] result  = new string[2];
            int      success = 0;
            int      fail    = 0;

            foreach (MessageObject_MoneyTran item in messagesObjs_moneyTrans)
            {
                CCSBAL    bal    = new CCSBAL();
                CommonBAL comBal = new CommonBAL();

                Thread.Sleep(5000);
                try
                {
                    client.Timeout = 15000;
                    //string userState = "Test Message";
                    client.Send(item.Mail);
                    if (item.MessageInfoBo.Payment_Media == "EFT" && item.MessageInfoBo.Deposit_Withdraw == "Withdraw")
                    {
                        bal.CCS_Email_NotificationSent(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_EftWithdraw, string.Empty, comBal.GetCurrentServerDate().ToShortDateString());
                    }
                    else if (item.MessageInfoBo.Payment_Media != "EFT" && item.MessageInfoBo.Deposit_Withdraw == "Withdraw")
                    {
                        bal.CCS_Email_NotificationSent(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_MoneyWithdraw, string.Empty, comBal.GetCurrentServerDate().ToShortDateString());
                    }
                    else if (item.MessageInfoBo.Deposit_Withdraw == "Deposit")
                    {
                        bal.CCS_Email_NotificationSent(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_MoneyDeposit, string.Empty, comBal.GetCurrentServerDate().ToShortDateString());
                    }
                    success = success + 1;
                }
                catch (Exception ex)
                {
                    if (item.MessageInfoBo.Payment_Media == "EFT" && item.MessageInfoBo.Deposit_Withdraw == "Withdraw")
                    {
                        bal.CCS_Email_NotificationFailure(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_EftWithdraw, string.Empty, comBal.GetCurrentServerDate().ToShortDateString(), ex.Message);
                    }
                    else if (item.MessageInfoBo.Payment_Media != "EFT" && item.MessageInfoBo.Deposit_Withdraw == "Withdraw")
                    {
                        bal.CCS_Email_NotificationFailure(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_MoneyWithdraw, string.Empty, comBal.GetCurrentServerDate().ToShortDateString(), ex.Message);
                    }
                    else if (item.MessageInfoBo.Deposit_Withdraw == "Deposit")
                    {
                        bal.CCS_Email_NotificationFailure(item.MessageInfoBo.Cust_Code, item.MessageInfoBo.ReferenceNo, Indication_EmailNotification.Email_NotificationType_MoneyDeposit, string.Empty, comBal.GetCurrentServerDate().ToShortDateString(), ex.Message);
                    }
                    fail = fail + 1;
                }
                item.Mail.Dispose();
            }
            result[0] = Convert.ToString(success);
            result[1] = Convert.ToString(fail);

            return(result);
        }
        public void SetMessages_TradeConfirmation()
        {
            DataTable dt_Master  = new DataTable();
            DataTable dt_Details = new DataTable();

            CCSBAL      bal = new CCSBAL();
            MailMessage message;

            messagesObjs_tradeConfirm = new List <MessageObject_TradeConfirm>();
            dt_Master = bal.CCS_GetTemp_EmailTradeConfirmation_Master();

            if (dt_Master.Rows.Count > 0)
            {
                foreach (DataRow drM in dt_Master.Rows)
                {
                    MailAddress to = new MailAddress(drM["Email"].ToString());
                    message = new MailMessage(from, to);

                    message.Subject         = "Trade Confirmation";
                    message.SubjectEncoding = System.Text.Encoding.UTF8;
                    message.IsBodyHtml      = true;

                    EmailTradeConfirmation_NotificationBO bo = new EmailTradeConfirmation_NotificationBO();
                    bo.Cust_Code         = drM["Cust_Code"].ToString();
                    bo.Cust_Name         = drM["Cust_Name"].ToString();
                    bo.Trade_Date        = Convert.ToDateTime(drM["Trade_Date"].ToString());
                    bo.Interest          = Convert.ToDouble(drM["Interest"].ToString());
                    bo.Pre_Balance       = Convert.ToDouble(drM["Pre_Balance"].ToString());
                    bo.TotalOnBuyTotal   = Convert.ToDouble(drM["TotalOnBuyTotal"].ToString());
                    bo.TotalOnSellToal   = Convert.ToDouble(drM["TotalOnSellTotal"].ToString());
                    bo.TotalOnBalance    = Convert.ToDouble(drM["TotalOnBalance"].ToString());
                    bo.TotalOnAmount     = Convert.ToDouble(drM["TotalOnAmount"].ToString());
                    bo.TotalOnCommission = Convert.ToDouble(drM["TotalOnCommission"].ToString());
                    bo.TotalOnPayable    = Convert.ToDouble(drM["TotalPayable"].ToString());
                    bo.CurrentBalance    = Convert.ToDouble(drM["CurrentBalance"].ToString());

                    SetTradeConfirmationInfoBody_Master(message, bo);

                    //Details Executed As Nested
                    dt_Details = bal.CCS_GetTemp_EmailTradeConfirmation_Detials(bo.Cust_Code);
                    if (dt_Details.Rows.Count > 0)
                    {
                        List <EmailTradeConfirmation_NotificationBO> bo_details_List = new List <EmailTradeConfirmation_NotificationBO>();

                        foreach (DataRow dr in dt_Details.Rows)
                        {
                            EmailTradeConfirmation_NotificationBO bo_detais = new EmailTradeConfirmation_NotificationBO();

                            bo_detais.Comp_Short_Code = dr["Comp_Short_Code"].ToString();
                            bo_detais.Buy_Qty         = Convert.ToInt32(dr["Buy_Qty"].ToString());
                            bo_detais.Buy_Avg         = Convert.ToDouble(dr["Buy_Avg"].ToString());
                            bo_detais.Buy_Total       = Convert.ToDouble(dr["Buy_Total"].ToString());
                            bo_detais.Sell_Qty        = Convert.ToInt32(dr["Sell_Qty"].ToString());
                            bo_detais.Sell_Avg        = Convert.ToDouble(dr["Sell_Avg"].ToString());
                            bo_detais.Sell_Total      = Convert.ToDouble(dr["Sell_Total"].ToString());
                            bo_detais.Balance         = Convert.ToDouble(dr["Balance"].ToString());
                            bo_detais.Amount          = Convert.ToDouble(dr["Amount"].ToString());
                            bo_detais.Commission      = Convert.ToDouble(dr["Commission"].ToString());

                            bo_details_List.Add(bo_detais);
                        }
                        SetTradeConfirmationInfoBody_Details(message, bo_details_List);
                    }

                    //Footer Executed
                    SetTradeConfirmationInfoBody_Footer(message, bo);

                    messagesObjs_tradeConfirm.Add(new MessageObject_TradeConfirm()
                    {
                        Mail = message, MessageInfoBo = bo
                    });
                }
            }
        }