Ejemplo n.º 1
0
        public void FuelSurChargeSendEmail(string toEmail, string ccEmail, string ContactName, string Attachment, int OperationZoneId)
        {
            string logoImage  = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            string trackImage = AppSettings.EmailServicePath + "/Images/FuelSurCharge.png";

            List <string> ImagePath = new List <string>();

            ImagePath.Add(logoImage);
            ImagePath.Add(trackImage);

            DynamicViewBag viewBag = new DynamicViewBag();

            viewBag.AddValue("Staff", ContactName);
            viewBag.AddValue("StaffEmail", "*****@*****.**");
            viewBag.AddValue("ImageHeader", "FrayteLogo");
            viewBag.AddValue("TrackButton", "FuelSurCharge");
            if (OperationZoneId == 1)
            {
                viewBag.AddValue("FuelPath", AppSettings.TrackingUrl + "/fuel-surcharge");
            }
            else
            {
                viewBag.AddValue("FuelPath", AppSettings.TrackingUrl + "/fuel-surcharge");
            }

            string template = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/FuelSurCharge.cshtml");

            var templateService = new TemplateService();

            var EmailBody    = templateService.Parse(template, "", viewBag, null);
            var EmailSubject = "Update Fuel Sur Charge - FRAYTE Logistics Ltd";

            FrayteEmail.SendMail(toEmail, ccEmail, EmailSubject, EmailBody, Attachment, ImagePath, "FuelCharge", OperationZoneId);
        }
Ejemplo n.º 2
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
        {
            Security frayteSecurity = new Security();
            string   accountNumber  = string.Empty;
            var      content        = await httpRequestMessage.Content.ReadAsStringAsync();

            try
            {
                if (httpRequestMessage.RequestUri.ToString().Contains("AftershipTracking/ProcessWebHook"))
                {
                    if (!string.IsNullOrEmpty(content))
                    {
                        // send mail to developer
                        Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("AftershipTracking's ProcessWebHook hit."));
                        Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(content));
                        try
                        {
                            AftershipWebhookObject webHookObj = JsonConvert.DeserializeObject <AftershipWebhookObject>(content);
                            if (webHookObj == null)
                            {
                                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Aftership's obj  not parsed."));

                                DynamicViewBag viewBag = new DynamicViewBag();
                                viewBag.AddValue("Value", content);
                                string template        = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/" + "aftershipError.cshtml");
                                var    templateService = new TemplateService();
                                var    EmailBody       = templateService.Parse(template, "", viewBag, null);
                                FrayteEmail.SendMail("*****@*****.**", "", "Aftership's obj  not parsed.", "", "", "");
                            }
                        }
                        catch (Exception ex)
                        {
                            Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Aftership's obj  not parsed."));
                        }
                    }
                    else
                    {
                        Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Aftership's obj  is empty."));
                    }
                }
                return(await base.SendAsync(httpRequestMessage, cancellationToken));
            }
            catch (Exception ex)
            {
                return(httpRequestMessage.CreateResponse(HttpStatusCode.Forbidden, "Json is not valid"));
            }
        }
        public FrayteResult MailSendToControlDept(string FileName, string FilePath, List <FrayteUploadshipment> UnpaidShipments)
        {
            FrayteResult fr = new FrayteResult();

            var            operationzone = UtilityRepository.GetOperationZone();
            string         logoImage     = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            DynamicViewBag viewBag       = new DynamicViewBag();

            viewBag.AddValue("TrackingDescription", "Please find the attachment.");
            viewBag.AddValue("Name", AppSettings.ControllerDeptName);
            viewBag.AddValue("ImageHeader", "FrayteLogo");

            if (operationzone.OperationZoneId == 1)
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }
            else
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }
            var res = UnpaidShipments[0];
            //string template = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/eCommerceControlDept.cshtml");
            string template = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/dhl.cshtml");

            TemplateService templateService    = new TemplateService();
            var             EmailBody          = templateService.Parse(template, res, viewBag, null);
            string          EmailSubject       = "Manifest Tracking";
            string          Attachmentfilepath = FilePath;
            var             To = AppSettings.ControllerDeptEmail;
            //_log.Error(MTM.ReceiverMail);
            //var To = "*****@*****.**";
            //var CC = customerDetail.UserEmail;
            string Status = "Confirmation";

            //Send mail to Customer
            //SendMail_New(To, CC, "FRAYTE (" + UtilityRepository.OperationZoneName(operationzone.OperationZoneId) + ")", EmailSubject, EmailBody, Attachment, Status);
            FrayteEmail.SendMail(To, "", EmailSubject, EmailBody, Attachmentfilepath, logoImage);
            return(fr);
        }
Ejemplo n.º 4
0
        public void ExchangeRateSendEmail(string toEmail, string ccEmail, string ContactName, string Attachment, int OperationZoneId)
        {
            //Update Mail Status
            new ExchangeRateRepository().UpdateSendMailStatus(OperationZoneId);

            string logoImage  = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            string trackImage = AppSettings.EmailServicePath + "/Images/ExchangeRate.png";

            List <string> ImagePath = new List <string>();

            ImagePath.Add(logoImage);
            ImagePath.Add(trackImage);

            DynamicViewBag viewBag = new DynamicViewBag();

            viewBag.AddValue("Staff", ContactName);
            viewBag.AddValue("StaffEmail", "*****@*****.**");
            viewBag.AddValue("ImageHeader", "FrayteLogo");
            viewBag.AddValue("TrackButton", "ExchangeRate");
            if (OperationZoneId == 1)
            {
                viewBag.AddValue("ExchangeRatePath", "http://app.frayte.com/");
            }
            else
            {
                viewBag.AddValue("ExchangeRatePath", "http://app.frayte.co.uk/");
            }

            string template        = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/ExchangeRate.cshtml");
            var    templateService = new TemplateService();

            var EmailBody    = templateService.Parse(template, "", viewBag, null);
            var EmailSubject = "Update Exchange Rate - FRAYTE Logistics Ltd";

            FrayteEmail.SendMail(toEmail, ccEmail, EmailSubject, EmailBody, Attachment, ImagePath, "ExchangeRate", OperationZoneId);
        }
Ejemplo n.º 5
0
        public void SendMissingAWBsMail(List <ExpressMissingShipmentModel> Awbs, int UserId)
        {
            ExpressEmailModel Res = new ExpressEmailModel();

            Res.ImageHeader = "FrayteLogo";
            Res.TotalMawb   = Awbs.Count;
            //foreach (var mawb in Mawbs)
            //{
            //    MawbCount = MawbCount + mawb.GrossWeight
            //}
            Res.MissingAwbs = Awbs;

            Res.TotalWeight = Awbs.Sum(a => a.TotalWeight);
            Res.ShipInfo    = new List <ExpressMissingShipmentsInfo>();
            Res.TotalAwbs   = Awbs.Count;
            Res.CreatedOn   = DateTime.UtcNow.Date.AddDays(-1).ToString("dd-MMM-yyyy");
            string        logoImage = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            List <string> ImagePath = new List <string>();

            ImagePath.Add(logoImage);
            var    OperationName = UtilityRepository.GetOperationZone();
            string Site          = string.Empty;

            if (OperationName.OperationZoneId == 1)
            {
                //Res.SiteAddress = AppSettings.TrackingUrl;
            }
            else if (OperationName.OperationZoneId == 2)
            {
                //Res.SiteAddress = AppSettings.TrackingUrl;
            }
            Res.ImageHeader = "FrayteLogo";
            string OperationUserEmail = "";
            int    RoleId             = 0;
            var    Email = "";

            var result = (from Usr in dbContext.Users
                          join Rl in dbContext.UserRoles on Usr.UserId equals Rl.UserId
                          join UA in dbContext.UserAdditionals on Usr.UserId equals UA.UserId
                          where Usr.UserId == UserId
                          select new
            {
                Usr.UserEmail,
                Rl.RoleId,
                Usr.ContactName,
                Usr.CompanyName,
                UA.OperationUserId
            }).FirstOrDefault();

            if (result != null)
            {
                RoleId = result.RoleId;
                Email  = result.UserEmail;
                Res.CustomerCompanyName = result.CompanyName;
            }

            var result1 = (from Usr in dbContext.Users
                           join Rl in dbContext.UserRoles on Usr.UserId equals Rl.UserId
                           join UA in dbContext.UserAdditionals on Usr.UserId equals UA.UserId
                           where Usr.UserId == result.OperationUserId
                           select new
            {
                Usr.Email,
                Rl.RoleId,
                Usr.ContactName,
                Usr.CompanyName,
                UA.OperationUserId,
                Usr.Position
            }).FirstOrDefault();

            if (result1 != null)
            {
                RoleId             = result1.RoleId;
                OperationUserEmail = result1.Email;
            }
            if (OperationName.OperationZoneId == 1)
            {
                Res.UserEmail     = result1.Email;
                Res.UserName      = result1.ContactName;
                Res.UserPosition  = result1.Position;
                Res.CustomerName  = result.ContactName;
                Res.CustomerEmail = result.UserEmail;
                Res.SystemEmail   = "*****@*****.**";
                Res.UserPhone     = "(+852) 2148 4880";
                //Res.SiteAddress = AppSettings.TrackingUrl;
                Res.Site = "www.FRAYTE.com";
            }
            if (OperationName.OperationZoneId == 2)
            {
                Res.UserEmail     = result1.Email;
                Res.UserPosition  = result1.Position;
                Res.UserName      = result1.ContactName;
                Res.CustomerName  = result.ContactName;
                Res.CustomerEmail = result.UserEmail;
                Res.SystemEmail   = "*****@*****.**";
                Res.UserPhone     = "(+44) 01792 277295";
                // Res.SiteAddress = AppSettings.TrackingUrl;
                Res.Site = "www.FRAYTE.co.uk";
            }

            string template     = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/Express/EXS_E4.cshtml");
            var    EmailBody    = Engine.Razor.RunCompile(template, "Usr4", null, Res, null);
            var    EmailSubject = "";
            var    Mawbvar      = "";
            var    Status       = "";

            if (!string.IsNullOrEmpty(Res.CustomerCompanyName))
            {
                EmailSubject = Res.CustomerCompanyName + " - EXS Discrepancies Shipment Summary – " + DateTime.UtcNow.Date.AddDays(-1).ToString("dd-MMM-yyyy");
            }

            FrayteEmail.SendMail(Email, "", EmailSubject, EmailBody, "", logoImage);

            ExpressSchedulerEmail ExpSchEm1 = new ExpressSchedulerEmail();

            ExpSchEm1.CustomerId   = UserId;
            ExpSchEm1.EmailSentOn  = DateTime.UtcNow.Date;
            ExpSchEm1.EmailContent = EmailBody;
            dbContext.ExpressSchedulerEmails.Add(ExpSchEm1);
            dbContext.SaveChanges();
        }
Ejemplo n.º 6
0
        public void SendPODAWBsMail(List <ExpressDispatchedMawbModel> Mawbs, List <ExpressShipmentBookedConsolidateModel> Shipments, int UserId)
        {
            ExpressEmailModel Res = new ExpressEmailModel();

            Res.TotalMawb       = Mawbs.Count;
            Res.DispatchedMawbs = Mawbs;
            Res.AWbShipmentList = Shipments;
            var Hubs = Shipments.Select(a => a.HubCode).Distinct();

            Res.ShipList = new List <ExpressHubShipmentCountModel>();

            foreach (var h in Hubs)
            {
                var ShipmentCount = 0;

                foreach (var Sh in Shipments)
                {
                    if (h == Sh.HubCode)
                    {
                        ShipmentCount = ShipmentCount + Sh.Shipments.Count;
                    }
                }
                Res.ShipList.Add(new ExpressHubShipmentCountModel {
                    HubCode = h, ShipmentCount = ShipmentCount
                });
            }

            Res.TotalWeight = Mawbs.Sum(a => a.GrossWeight);
            Res.ShipInfo    = new List <ExpressMissingShipmentsInfo>();

            Res.TotalAwbs = 0;
            for (int i = 0; i < Shipments.Count; i++)
            {
                Res.TotalAwbs = Res.TotalAwbs + Shipments[i].Shipments.Count;
            }

            Res.CreatedOn = DateTime.UtcNow.Date.AddDays(-1).ToString("dd-MMM-yyyy");
            string        logoImage = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            List <string> ImagePath = new List <string>();

            ImagePath.Add(logoImage);
            var OperationName = UtilityRepository.GetOperationZone();

            Res.ImageHeader = "FrayteLogo";
            string OperationUserEmail = "";
            int    RoleId             = 0;
            var    Email = "";

            var result = (from Usr in dbContext.Users
                          join Rl in dbContext.UserRoles on Usr.UserId equals Rl.UserId
                          join UA in dbContext.UserAdditionals on Usr.UserId equals UA.UserId
                          where Usr.UserId == UserId
                          select new
            {
                Usr.UserEmail,
                Rl.RoleId,
                Usr.ContactName,
                Usr.CompanyName,
                UA.OperationUserId
            }).FirstOrDefault();

            if (result != null)
            {
                RoleId = result.RoleId;
                Email  = result.UserEmail;
                Res.CustomerCompanyName = result.CompanyName;
            }

            var result1 = (from Usr in dbContext.Users
                           join Rl in dbContext.UserRoles on Usr.UserId equals Rl.UserId
                           join UA in dbContext.UserAdditionals on Usr.UserId equals UA.UserId
                           where Usr.UserId == result.OperationUserId
                           select new
            {
                Usr.Email,
                Rl.RoleId,
                Usr.ContactName,
                Usr.CompanyName,
                UA.OperationUserId,
                Usr.Position
            }).FirstOrDefault();

            if (result1 != null)
            {
                RoleId             = result1.RoleId;
                OperationUserEmail = result1.Email;
            }

            if (OperationName.OperationZoneId == 1)
            {
                Res.UserEmail     = result1.Email;
                Res.UserName      = result1.ContactName;
                Res.UserPosition  = result1.Position;
                Res.CustomerName  = result.ContactName;
                Res.CustomerEmail = result.UserEmail;
                Res.SystemEmail   = "*****@*****.**";
                Res.UserPhone     = "(+852) 2148 4880";
                //Res.SiteAddress = AppSettings.TrackingUrl;
                Res.Site = "www.FRAYTE.com";
            }

            if (OperationName.OperationZoneId == 2)
            {
                Res.UserEmail     = result1.Email;
                Res.UserPosition  = result1.Position;
                Res.UserName      = result1.ContactName;
                Res.CustomerName  = result.ContactName;
                Res.CustomerEmail = result.UserEmail;
                Res.SystemEmail   = "*****@*****.**";
                Res.UserPhone     = "(+44) 01792 277295";
                // Res.SiteAddress = AppSettings.TrackingUrl;
                Res.Site = "www.FRAYTE.co.uk";
            }

            string template     = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/Express/EXS_E2_POD.cshtml");
            var    EmailBody    = Engine.Razor.RunCompile(template, "Usr3", null, Res, null);
            var    EmailSubject = "";
            var    Mawbvar      = "";
            var    Status       = "";

            if (!string.IsNullOrEmpty(Res.CustomerCompanyName))
            {
                EmailSubject = Res.CustomerCompanyName + " - EXS POD Summary   – " + DateTime.UtcNow.Date.AddDays(-1).ToString("dd-MMM-yyyy");
            }

            FrayteEmail.SendMail(Email, "", EmailSubject, EmailBody, "", logoImage);

            ExpressSchedulerEmail ExpSchEm1 = new ExpressSchedulerEmail();

            ExpSchEm1.CustomerId   = UserId;
            ExpSchEm1.EmailSentOn  = DateTime.UtcNow.Date;
            ExpSchEm1.EmailContent = EmailBody;
            dbContext.ExpressSchedulerEmails.Add(ExpSchEm1);
            dbContext.SaveChanges();
        }
Ejemplo n.º 7
0
        public void SendMail(string toEmail, string ccEmail, string EmailSubject, string EmailBody)
        {
            string logoImage = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";

            FrayteEmail.SendMail(toEmail, ccEmail, EmailSubject, EmailBody, filpath, logoImage);
        }
Ejemplo n.º 8
0
        public void SendMailToReceivers(ManifestTrackingReceiver MTM)
        {
            string xsUserFolder = @"C:\FMS\" + "FrayteSchedularlog.txt";

            BaseLog.Instance.SetLogFile(xsUserFolder);
            Logger _log = Get_Log();
            //Get Customer Name and Customer User Detail
            var customerDetail = (from u in dbContext.Users
                                  join ua in dbContext.UserAdditionals on u.UserId equals ua.UserId
                                  join ua1 in dbContext.UserAdditionals on ua.OperationUserId equals ua1.UserId
                                  join u1 in dbContext.Users on ua1.UserId equals u1.UserId
                                  join tz in dbContext.Timezones on u.TimezoneId equals tz.TimezoneId
                                  where u.UserId == MTM.CustomerId
                                  select new
            {
                CustomerName = u.ContactName,
                CustomerEmail = u.Email,
                CompanyName = u.CompanyName,
                UserName = u1.ContactName,
                UserPosition = u1.Position,
                UserEmail = u1.Email,
                UserPhone = u1.TelephoneNo,
                UserSkype = u1.Skype,
                UserFax = u1.FaxNumber,
                TimeZoneDetail = new TimeZoneModal
                {
                    Name = tz.Name,
                    Offset = tz.Offset,
                    OffsetShort = tz.OffsetShort,
                    TimezoneId = tz.TimezoneId
                }
            }).FirstOrDefault();
            var            operationzone = UtilityRepository.GetOperationZone();
            string         logoImage     = AppSettings.EmailServicePath + "/Images/FrayteLogo.png";
            DynamicViewBag viewBag       = new DynamicViewBag();

            if (customerDetail.TimeZoneDetail != null)
            {
                viewBag.AddValue("CreatedOn", UtilityRepository.GetTimeZoneCurrentDateTime(customerDetail.TimeZoneDetail.Name).ToString("dd-MMM-yyyy hh:mm"));;
                viewBag.AddValue("TimeZone", customerDetail.TimeZoneDetail.OffsetShort);
            }
            else
            {
                viewBag.AddValue("CreatedOn", DateTime.Now.ToString("dd-MMM-yyyy hh:mm"));
            }

            viewBag.AddValue("TrackingDescription", MTM.TrackingDescription);
            viewBag.AddValue("TrackingNo", MTM.ReceiverTrackingNo);
            viewBag.AddValue("CustomerName", MTM.ReceiverName);
            viewBag.AddValue("UserEmail", customerDetail.CustomerEmail);
            viewBag.AddValue("UserPhone", customerDetail.UserPhone);
            viewBag.AddValue("ImageHeader", "FrayteLogo");

            if (operationzone.OperationZoneId == 1)
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }
            else
            {
                viewBag.AddValue("SiteAddress", AppSettings.TrackingUrl);
            }

            string template        = File.ReadAllText(AppSettings.EmailServicePath + "/EmailTeamplate/eCommerceManifestTracking.cshtml");
            var    templateService = new TemplateService();
            var    EmailBody       = templateService.Parse(template, MTM, viewBag, null);
            string EmailSubject    = "Manifest Tracking";

            //var To = MTM.ReceiverMail;
            _log.Error(MTM.ReceiverMail);
            var    To     = "*****@*****.**";
            var    CC     = customerDetail.UserEmail;
            string Status = "Confirmation";

            //Send mail to Customer
            //SendMail_New(To, CC, "FRAYTE (" + UtilityRepository.OperationZoneName(operationzone.OperationZoneId) + ")", EmailSubject, EmailBody, Attachment, Status);
            FrayteEmail.SendMail(To, CC, EmailSubject, EmailBody, logoImage);
        }