Beispiel #1
0
        void EmailReciveChecker(object State)
        {
            try
            {
                Console.WriteLine("emailCheckOn : " + EmailBankCore.ClockServer());
                TestForm.messageBody[] eBankMessage = new TestForm.messageBody[TestForm.messageBodyList.Count];
                TestForm.messageBodyList.CopyTo(eBankMessage);
                if (!TestForm.EmailReciveCheckerISbusy && !TestForm.EmailAddCheckerISbusy)
                {
                    TestForm.EmailReciveCheckerISbusy = true;
                    foreach (TestForm.messageBody MessageRecived in eBankMessage)
                    {
                        Console.WriteLine("New Message Recived From : " + MessageRecived.MailSender);
                        EmailsenderClass mail = new EmailsenderClass();
                        mail.UserName = "******"[email protected]\"<" + ConfigurationManager.AppSettings["EmailAddress"].ToString() + ">";
                        mail.Password = ConfigurationManager.AppSettings["EmailPassword"].ToString();
                        //______________________________________________________________________________
                        long CustomerID = CustomerIDMining(MessageRecived.DepositeNubmer);
                        if (CustomerID == 0)
                        {
                            PageCreator     PC       = new PageCreator(); //"*****@*****.**"
                            string          Page     = PC.PageBuilder();
                            MailInformation Mailinfo = new MailInformation
                            {
                                CustomerEmailAddress = MessageRecived.MailSender,
                                CustomerID           = CustomerID,
                                EmailText            = Page,
                                MailProperties       = mail,
                                Subject        = "Error",
                                EmailType      = "2",
                                DepositeNumber = MessageRecived.DepositeNubmer
                            };
                            CreateEmailThread(Mailinfo);
                        }
                        else
                        {
                            SBS.DataModel.CustomerModel CustomerInfo;
                            int ii = 0;
                            while (true)
                            {
                                try
                                {
                                    CustomerInfo = iCustomer.SelectOneWithOutDeepLoad(CustomerID);
                                    break;
                                }
                                catch (Exception ex)
                                {
                                    ii++;
                                    if (ii > 10)
                                    {
                                        return;
                                    }
                                    if (Login(UserName, PassWord))
                                    {
                                        iCustomer    = SBS.CommonUtils.FacadeFactory.CustomerManager("", LoggedInUserInfo.UserIdentity.ToString(), (short)SBS.CommonUtils.ConstantData.AppUC.Email_SubSystem, LoggedInUserInfo.TicketStr);
                                        iWithdrawals = SBS.CommonUtils.FacadeFactory.WithdrawalsSettlementManager("", LoggedInUserInfo.UserIdentity.ToString(), (short)SBS.CommonUtils.ConstantData.AppUC.Email_SubSystem, LoggedInUserInfo.TicketStr);
                                    }
                                }
                            }
                            //CustomerInfo.Email = "*****@*****.**";
                            //CustomerInfo.Email = "*****@*****.**";
                            //CustomerInfo.Email = "*****@*****.**";
                            //______________________________________________________________________________
                            if (!string.IsNullOrEmpty(CustomerInfo.Email))
                            {
                                PageCreator     PC      = new PageCreator(); //"*****@*****.**"
                                UserInformation UserInf = new UserInformation
                                {
                                    PreName       = "",
                                    Name          = CustomerInfo.DisplayName,
                                    ActionType    = "گردش سپرده",
                                    DepositNubmer = MessageRecived.DepositeNubmer,
                                    Amount        = CustomerInfo.Amount.ToString(),
                                    Comment       = CustomerInfo.Comment,
                                    Date          = FarsiDateServer(),
                                    RemainAmount  = CustomerInfo.RemainAmount.ToString(),
                                    Time          = ClockServer(),
                                    IsTransaction = false,
                                };
                                if (MessageRecived.TransactionCountRequested <= 200)
                                {
                                    UserInf.TransactionCountRequested = MessageRecived.TransactionCountRequested;
                                }
                                else
                                {
                                    UserInf.TransactionCountRequested = 200;
                                }
                                if (MessageRecived.Blocked)
                                {
                                    string          Page     = PC.PageBuilder(UserInf);
                                    MailInformation Mailinfo = new MailInformation
                                    {
                                        CustomerEmailAddress = CustomerInfo.Email,
                                        CustomerID           = CustomerID,
                                        EmailText            = Page,
                                        MailProperties       = mail,
                                        Subject        = "بیش از حد مجاز",
                                        EmailType      = "2",
                                        DepositeNumber = MessageRecived.DepositeNubmer
                                    };
                                    CreateEmailThread(Mailinfo);
                                }
                                else
                                {
                                    List <ReportDetails> LRep = ReportDetailsBuilder(MessageRecived.DepositeNubmer, MessageRecived.TransactionCountRequested);
                                    UserInf.RealTransactionCount = short.Parse(LRep.Count.ToString());
                                    string          Page     = PC.PageBuilder(UserInf, LRep);
                                    MailInformation Mailinfo = new MailInformation
                                    {
                                        CustomerEmailAddress = CustomerInfo.Email,
                                        CustomerID           = CustomerID,
                                        EmailText            = Page,
                                        MailProperties       = mail,
                                        Subject        = "گردش سپرده",
                                        EmailType      = "2",
                                        DepositeNumber = MessageRecived.DepositeNubmer
                                    };
                                    CreateEmailThread(Mailinfo);
                                }
                            }
                        }
                        while (true)
                        {
                            if (!TestForm.EmailAddCheckerISbusy)
                            {
                                TestForm.EmailAddCheckerISbusy = true;
                                TestForm.messageBodyList.Remove(MessageRecived);
                                TestForm.EmailAddCheckerISbusy = false;
                                break;
                            }
                        }
                    }
                    TestForm.EmailReciveCheckerISbusy = false;
                }
            }

            catch (Exception ex)
            {
                LogRegister("EmailReciveChecker", ex.Message);
            }
        }
Beispiel #2
0
        public void EmailBiulder()
        {
            long CustomerID = 0;

            try
            {
                string           text = "";
                EmailsenderClass mail = new EmailsenderClass();
                mail.UserName = "******"[email protected]\"<" + ConfigurationManager.AppSettings["EmailAddress"].ToString() + ">";
                mail.Password = ConfigurationManager.AppSettings["EmailPassword"].ToString();
                List <SBS.DataModel.CustomerModel> SDCustomermodel = new List <CustomerModel>();
                // setLastID(0);
                try
                {
                    SDCustomermodel = iWithdrawals.SelectForNotifyEmail(getLastID(), getDate());
                }
                catch (Exception)
                {
                    Thread.Sleep(10000);
                    EmailBankCoreMethod(UserName, PassWord);
                    EmailBiulder();
                    return;
                }
                foreach (SBS.DataModel.CustomerModel CustomerModelRow in SDCustomermodel)
                {
                    UserInformation UserInf;
                    try
                    {
                        CustomerID = CustomerModelRow.ID.Value;
                        UserInf    = new UserInformation
                        {
                            PreName       = "",
                            Name          = CustomerModelRow.DisplayName,
                            ActionType    = CustomerModelRow.Moaref + " سپرده ",
                            DepositNubmer = CustomerModelRow.DepositName,
                            Amount        = CustomerModelRow.Amount.ToString(),
                            Comment       = CustomerModelRow.Comment,
                            Date          = CustomerModelRow.Date,
                            RemainAmount  = CustomerModelRow.RemainAmount.ToString(),
                            Time          = CustomerModelRow.Clock, IsTransaction = true
                        };
                        UserInf.PreName = "";
                        PageCreator Page = new PageCreator();
                        text = Page.PageBuilder(UserInf, ReportDetailsBuilder(UserInf.DepositNubmer, 5));
                    }
                    catch (Exception ex)
                    {
                        UserInf = new UserInformation();
                        //iWithdrawals.UpdateForNotifyErrorSent(CustomerID);
                    }
                    MailInformation Mailinfo = new MailInformation {
                        CustomerEmailAddress = CustomerModelRow.Email, CustomerID = CustomerID, EmailText = text, MailProperties = mail, Subject = UserInf.ActionType, EmailType = "1", DepositeNumber = UserInf.DepositNubmer
                    };
                    if (CustomerID != 0)
                    {
                        setLastID(CustomerID);
                    }
                    CreateEmailThread(Mailinfo);
                }

                CurrentlyInUse = false;
            }
            catch (Exception ex)
            {
                CurrentlyInUse = false;
                LogRegister("EmailBiulder", ex.Message);
            }
        }