Exemplo n.º 1
0
        public void NotificationMessagingService()
        {
            try
            {
                var recordNum = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "EmailBatchNumber").Paramvalue;
                var con = new SqlConnection(constring);
                string query = "SELECT TOP " + recordNum + " * FROM NOTIFICATONS_TOSEND ";
                DataTable dt = new DataTable();
                con.Open();
                var da = new SqlDataAdapter(query, con);
                da.Fill(dt);
                con.Close();
                if (dt.Rows.Count > 0)
                {

                    foreach (DataRow n in dt.Rows)
                    {
                        var m = _repository.Find<Notification>(Guid.Parse(n[0].ToString()));
                        var refNo = m.REFERENCE_NO;
                        var paymentDetails = m.PAYMENT_DETAILS1 + " " + m.PAYMENT_DETAILS2 + " " + m.PAYMENT_DETAILS3 + " " +
                                             m.PAYMENT_DETAILS4;
                        var byOrderOf = m.BY_ORDER_OF1 + " " + m.BY_ORDER_OF2 + " " + m.BY_ORDER_OF3 + " " + m.BY_ORDER_OF4 + " " + m.BY_ORDER_OF5;
                        var currency = m.OFFSET_CCY;
                        var amount = m.TXN_AMOUNT;
                        var account = m.OFFSET_ACCOUNT;
                        var txt = m.TEXT;
                        var transDate = m.TXN_DATE;
                        var valueDate = m.VALUE_DT;
                        var transType = m.TRN_DESC;
                        var msg = "Reference Number:  " + refNo + Environment.NewLine +
                                  "Account:  " + account + Environment.NewLine +
                                  "Currency: " + currency + Environment.NewLine +
                                  "Amount:  " + amount + Environment.NewLine +
                                  "Transaction Date: " + transDate + Environment.NewLine +
                                  "Value Date: " + valueDate + Environment.NewLine +
                                  "Transaction Type: " + transType + Environment.NewLine +
                                  "Text: " + txt + Environment.NewLine +
                                  "Details Of Payment: " + paymentDetails + Environment.NewLine +
                                  "By Order Of: " + byOrderOf;
                        var product =
                                       _repository.Fetch<Subject>().FirstOrDefault(p => (p.ProductDesc == "Notification") && (p.TransactionDescription == transType) && (p.Status == MyEnums.StatusOptions.Approved));
                        if (product != null)
                        {
                            var context = new DbManager();
                            if (transType == "FCY LOCAL CHECK (S) DEPOSIT")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameFCYLOCALCHECKDEPOSIT").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "INCOMING CLEARING TRANSFER")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameINCOMINGCLEARINGTRANSFER").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "BOOK TFR MAN")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameBOOKTFRMAN").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "INHSE CHEQUE DEPOSITED IN C/A")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameINHSECHEQUEDEPOSITEDINCA").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "CHQ DEP WITH SLIP SRTD")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameCHQDEPWITHSLIPSRTD").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "BOOK TFR REC INTRA BR")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameBOOKTFRRECINTRABR").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "CASH DEPOSIT")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameCASHDEPOSIT").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }
                            if (transType == "WIRE PYMT XB W COV AUTO")
                            {
                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameWIREPYMTXBWCOVAUTO").Paramvalue;
                                var model =
                                    context.Database.SqlQuery<String>(
                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
                                var subject = product.Description + ": " + model;
                                var intro = product.Intro;
                                var salutation = product.Salutation;
                                var footer = product.Footer;
                                var productName = "Notification";
                                var refrenceNo = n[2].ToString();
                                var acc = n[1].ToString();
                                var mail = n[3].ToString().Remove(n[3].ToString().Length - 1);
                                Email send = new Email();
                                send.FnSendMail(mail, subject, salutation, intro, msg, footer, productName,
                                    refrenceNo, acc);
                            }

                        }
                        else
                        {
                            var newReport = new MessagingReport
                            {
                                Id = Guid.NewGuid(),
                                SentTo = "",
                                RefNo = m.REFERENCE_NO,
                                Message = msg,
                                Product = "Notification",
                                Account = n[1].ToString(),
                                Osysdate = DateTime.Now,
                                EmailSent = false,
                                Report = "Transaction Type '" + transType + "' has no approved email structure"

                            };
                            _repository.SaveNew(newReport);
                        }
                        m.Flag = true;
                        _repository.SaveUpdate(m);
                    }
                }

            }
            catch (Exception )
            {

            }
        }
Exemplo n.º 2
0
        //public void TMessagingService()
        //{
        //    try
        //    {
        //        var newTt = _repository.Fetch<FLEX_DATA_TTS>().Where(p => p.Flag == false);
        //        foreach (var m in newTt.ToList())
        //        {
        //            var message = _repository.Find<FLEX_DATA_TTS>(m.Id);
        //            var account = message.BY_ORDER_OF1;
        //            var msg = message.MESSAGE;
        //            var customer = _repository.Fetch<MessagingCustomers>().Where(p => "/" + p.ACCOUNT_NUMBER == account);
        //            if (customer.Count() != 0)
        //            {
        //                foreach (var c in customer.ToList())
        //                {
        //                    var cust =
        //                        _repository.Fetch<MessagingContacts>()
        //                            .FirstOrDefault(p => p.MessagingCustomersId == c.Id && p.ProductType == "TT");
        //                        if (cust != null)
        //                        {
        //                            var a = _repository.Find<MessagingContacts>(cust.Id);
        //                            var mail1 = string.Join(",", _repository.Fetch<MessagingContacts>().Where(p => p.MessagingCustomersId == c.Id && p.ProductType=="TT").Select(z => z.EmailAddress1));
        //                            var productType = a.ProductType;
        //                            var product =
        //                                _repository.Fetch<Subject>().FirstOrDefault(p => p.ProductTypeId == a.ProductId);
        //                            if (product != null)
        //                            {
        //                                var subject = product.Description +":" +message.BENEFICIARY;
        //                                var intro = product.Intro;
        //                                var salutation = product.Salutation;
        //                                var footer = product.Footer;
        //                                var productName = "TT";
        //                                var refrenceNo = m.DCN;
        //                                Email send = new Email();
        //                                send.FnSendMail(mail1, subject, salutation, intro, msg, footer, productName,
        //                                    refrenceNo);
        //                            }
        //                        }
        //                    else
        //                    {
        //                        var newReport = new MessagingReport
        //                        {
        //                            Id = Guid.NewGuid(),
        //                            SentTo = "",
        //                            RefNo = m.DCN,
        //                            Message = msg,
        //                            Product = "TT",
        //                            Osysdate = DateTime.Now,
        //                            EmailSent = false,
        //                            Report = "Account '" + account + "' message DCN '" + m.DCN + "' for '" + c.CUST_NAME_1 + "'has no address Assigned to it"
        //                        };
        //                        _repository.SaveNew(newReport);
        //                    }
        //                }
        //            }
        //            else
        //            {
        //                var newReport = new MessagingReport
        //                {
        //                    Id = Guid.NewGuid(),
        //                    SentTo = "",
        //                    RefNo = m.DCN,
        //                    Message = msg,
        //                    Product = "TT",
        //                    Osysdate = DateTime.Now,
        //                    EmailSent = false,
        //                    Report = "Account '" + account + "' message DCN '"+m.DCN+"' has no customer detailed Assigned to it"
        //                };
        //                _repository.SaveNew(newReport);
        //            }
        //                message.Flag = true;
        //            _repository.SaveUpdate(message);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/errorLOG.txt"), System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
        //        System.IO.StreamWriter s = new System.IO.StreamWriter(fs);
        //        s.BaseStream.Seek(0, System.IO.SeekOrigin.End);
        //        s.WriteLine("ERROR DATE: " + System.DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture) + " \nERROR MESSAGE: " + ex.Message + "\nSOURCE: " + ex.Source + "\nFORM NAME: " + System.Web.HttpContext.Current.Request.Url.ToString() + "\nQUERYSTRING: " + Request.QueryString.ToString() + "\nTARGETSITE: " + ex.TargetSite.ToString() + "\nSTACKTRACE: " + ex.StackTrace + System.Diagnostics.EventLogEntryType.Error);
        //        s.WriteLine("-------------------------------------------------------------------------------------------------------------");
        //        s.Close();
        //    }
        //}
        //public void NotificationMessagingService1()
        //{
        //    try
        //    {
        //        var newNotification = _repository.Fetch<Notification>().Where(p => p.Flag == false);
        //        foreach (var m in newNotification.ToList())
        //        {
        //            var notification = _repository.Find<Notification>(m.Id);
        //            var refNo = m.REFERENCE_NO;
        //            var paymentDetails = m.PAYMENT_DETAILS1 + m.PAYMENT_DETAILS2 + m.PAYMENT_DETAILS3 +
        //                                 m.PAYMENT_DETAILS4;
        //            var byOrderOf = m.BY_ORDER_OF1 + m.BY_ORDER_OF2 + m.BY_ORDER_OF3 + m.BY_ORDER_OF4 + m.BY_ORDER_OF5;
        //            var currency = m.OFFSET_CCY;
        //            var amount = m.TXN_AMOUNT;
        //            var account = m.OFFSET_ACCOUNT;
        //            var transDate = m.TXN_DATE;
        //            var valueDate = m.VALUE_DT;
        //            var transType = m.TRN_DESC;
        //            var message = "Reference Number:  " + refNo + Environment.NewLine + "Details Of Payment: " + paymentDetails + Environment.NewLine + "By Order Of: " + byOrderOf + Environment.NewLine + "Currency: " + currency + Environment.NewLine + "Amount:  " + amount + Environment.NewLine + "Transaction Date: " + transDate + Environment.NewLine + "Value Date: " + valueDate + Environment.NewLine + "Transaction Type: "+transType;
        //            var customer = _repository.Fetch<MessagingCustomers>().Where(p => p.ACCOUNT_NUMBER == account);
        //            if (customer.Count() != 0)
        //            {
        //                foreach (var c in customer.ToList())
        //                {
        //                    var cust =
        //                        _repository.Fetch<MessagingContacts>()
        //                            .FirstOrDefault(p => p.MessagingCustomersId == c.Id && p.ProductType == "Notification");
        //                    if (cust != null)
        //                        {
        //                            var a = _repository.Find<MessagingContacts>(cust.Id);
        //                            var mail1 = string.Join(",", _repository.Fetch<MessagingContacts>().Where(p => p.MessagingCustomersId == c.Id && p.ProductType=="Notification").Select(z => z.EmailAddress1));
        //                            var productType = a.ProductType;
        //                            var product =
        //                                _repository.Fetch<Subject>().FirstOrDefault(p => (p.ProductTypeId == a.ProductId) && (p.TransactionDescription==transType));
        //                            if (product != null)
        //                            {
        //                                var context = new DbManager();
        //                                var columnName = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "ColumnNameNotification").Paramvalue;
        //                                var model =
        //                                    context.Database.SqlQuery<String>(
        //                                        "SELECT Distinct " + columnName + " FROM Notification WHERE Id = '" + m.Id + "'").FirstOrDefault();
        //                                var subject =product.Description+model;
        //                                var intro = product.Intro;
        //                                var salutation = product.Salutation;
        //                                var footer = product.Footer;
        //                                var productName = "Notification";
        //                                var refrenceNo = m.REFERENCE_NO;
        //                                Email send = new Email();
        //                                send.FnSendMail(mail1, subject, salutation, intro, message, footer, productName, refrenceNo);
        //                            }
        //                    }
        //                    else
        //                    {
        //                        var newReport = new MessagingReport
        //                        {
        //                            Id = Guid.NewGuid(),
        //                            SentTo = "",
        //                            RefNo = m.REFERENCE_NO,
        //                            Message = message,
        //                            Product = "Notification",
        //                            Osysdate = DateTime.Now,
        //                            EmailSent = false,
        //                            Report = "Account '" + account + "' message Reference Number '" + m.REFERENCE_NO + "' for '" + c.CUST_NAME_1 + "'has no address Assigned to it"
        //                        };
        //                        _repository.SaveNew(newReport);
        //                    }
        //                }
        //            }
        //            else
        //            {
        //                var newReport = new MessagingReport
        //                {
        //                    Id = Guid.NewGuid(),
        //                    SentTo = "",
        //                    RefNo = m.REFERENCE_NO,
        //                    Message = message,
        //                    Product = "Notification",
        //                    Osysdate = DateTime.Now,
        //                    EmailSent = false,
        //                    Report = "Account '" + account + "' message Reference Number '" + m.REFERENCE_NO + "' has no customer detailed Assigned to it"
        //                };
        //                _repository.SaveNew(newReport);
        //            }
        //            m.Flag = true;
        //            _repository.SaveUpdate(notification);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/errorLOG.txt"), System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
        //        System.IO.StreamWriter s = new System.IO.StreamWriter(fs);
        //        s.BaseStream.Seek(0, System.IO.SeekOrigin.End);
        //        s.WriteLine("ERROR DATE: " + System.DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture) + " \nERROR MESSAGE: " + ex.Message + "\nSOURCE: " + ex.Source + "\nFORM NAME: " + System.Web.HttpContext.Current.Request.Url.ToString() + "\nQUERYSTRING: " + Request.QueryString.ToString() + "\nTARGETSITE: " + ex.TargetSite.ToString() + "\nSTACKTRACE: " + ex.StackTrace + System.Diagnostics.EventLogEntryType.Error);
        //        s.WriteLine("-------------------------------------------------------------------------------------------------------------");
        //        s.Close();
        //    }
        //}
        public void TtMessagingService()
        {
            try
            {
                var recordNum = _repository.Fetch<Parameter>().FirstOrDefault(p => p.Paramname == "EmailBatchNumber").Paramvalue;
                var con = new SqlConnection(constring);
                string query = "SELECT TOP " + recordNum + " * FROM TTS_TOSEND";
                DataTable dt = new DataTable();
                con.Open();
                var da = new SqlDataAdapter(query, con);
                da.Fill(dt);
                con.Close();
                if (dt.Rows.Count > 0)
                {

                    foreach (DataRow n in dt.Rows)
                    {
                        var product =
                                       _repository.Fetch<Subject>().FirstOrDefault(p => (p.ProductDesc == "TT")&&(p.Status == MyEnums.StatusOptions.Approved));
                        if (product != null)
                        {
                            var subject = product.Description + ": " + n[3];
                            var intro = product.Intro;
                            var salutation = product.Salutation;
                            var footer = product.Footer;
                            var productName = "TT";
                            var refrenceNo = n[2].ToString();
                            var acc = n[1].ToString();
                            var mail = n[5].ToString().Remove(n[5].ToString().Length -1);
                            Email send = new Email();
                            send.FnSendMail(mail, subject, salutation, intro, n[4].ToString(), footer, productName,
                                refrenceNo,acc);

                        }
                        else
                        {
                            var newReport = new MessagingReport
                            {
                                Id = Guid.NewGuid(),
                                SentTo = "",
                                RefNo = n[2].ToString(),
                                Message = n[4].ToString(),
                                Product = "TT",
                                Account = n[1].ToString(),
                                Osysdate = DateTime.Now,
                                EmailSent = false,
                                Report = "TT has no approved email structure"

                            };
                            _repository.SaveNew(newReport);
                        }
                        var message = _repository.Find<FLEX_DATA_TTS>(Guid.Parse(n[0].ToString()));
                        message.Flag = true;
                        _repository.SaveUpdate(message);
                    }
                }

            }
            catch (Exception )
            {
            }
        }