Exemplo n.º 1
0
        public string PreAlertShipmentDocuments(TradelanePreAlertInitial preAlerDetail)
        {
            string attachments    = string.Empty;
            string documentFolder = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + preAlerDetail.TradelaneShipmentId);

            if (preAlerDetail != null)
            {
                if (preAlerDetail.PreAlertDocumnets.Count > 0)
                {
                    foreach (var item in preAlerDetail.PreAlertDocumnets)
                    {
                        if (item.Documents != null && item.Documents.Count > 0)
                        {
                            foreach (var doc in item.Documents)
                            {
                                if (doc.IsSelected)
                                {
                                    if (doc.TradelaneShipmentDocumentId > 0)
                                    {
                                        if (!string.IsNullOrEmpty(doc.Document) && File.Exists(documentFolder + "\\" + doc.Document))
                                        {
                                            attachments += documentFolder + "\\" + doc.Document;
                                            attachments += ";";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(attachments);
        }
Exemplo n.º 2
0
        public FrayteResult SendPreAlertEmail(TradelanePreAlertInitial preAlerDetail)
        {
            var          emailModel = new TradelaneEmailRepository().TradelaneEmailObj(preAlerDetail.TradelaneShipmentId);
            FrayteResult result     = new TradelaneEmailRepository().SendEmail_E5(emailModel, preAlerDetail);

            return(result);
        }
        public IHttpActionResult SendPreAlertEmail(TradelanePreAlertInitial preAlerDetail)
        {
            FrayteResult result = new TradelaneShipmentRepository().SendPreAlertEmail(preAlerDetail);

            if (result.Status)
            {
                new TradelaneShipmentRepository().SavePreAlertLog(preAlerDetail);
            }

            return(Ok(result));
        }
Exemplo n.º 4
0
        public void SavePreAlertLog(TradelanePreAlertInitial preAlerDetail)
        {
            try
            {
                TradelaneLogging log = new TradelaneLogging();
                log.ShipmentId = preAlerDetail.TradelaneShipmentId;
                log.SentBy     = preAlerDetail.UserId;
                log.SentOnUtc  = DateTime.UtcNow;
                log.Type       = TradelaneLoggingType.PreAlert;

                dbContext.TradelaneLoggings.Add(log);
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
        public string PreAlertEmails(TradelanePreAlertInitial preAlerDetail, string type)
        {
            string emails = string.Empty;

            if (type == "TO")
            {
                if (preAlerDetail.ShipmentEmail != null)
                {
                    if (!string.IsNullOrEmpty(preAlerDetail.ShipmentEmail.CustomerEmail) && preAlerDetail.ShipmentEmail.IsCustomerSentEmail)
                    {
                        emails += preAlerDetail.ShipmentEmail.CustomerEmail + ";";
                    }
                    if (!string.IsNullOrEmpty(preAlerDetail.ShipmentEmail.ShipperEmail) && preAlerDetail.ShipmentEmail.IsShipperSentEmail)
                    {
                        emails += preAlerDetail.ShipmentEmail.ShipperEmail + ";";
                    }
                    if (!string.IsNullOrEmpty(preAlerDetail.ShipmentEmail.ReceiverEmail) && preAlerDetail.ShipmentEmail.IsReceiverSentEmail)
                    {
                        emails += preAlerDetail.ShipmentEmail.ReceiverEmail + ";";
                    }
                    if (!string.IsNullOrEmpty(preAlerDetail.ShipmentEmail.NotifyPartyEmail) && preAlerDetail.ShipmentEmail.IsNotifyPartySentEmail)
                    {
                        emails += preAlerDetail.ShipmentEmail.NotifyPartyEmail + ";";
                    }
                    if (!string.IsNullOrEmpty(preAlerDetail.ShipmentEmail.AgentEmail) && preAlerDetail.ShipmentEmail.IsAgentSentEmail)
                    {
                        emails += preAlerDetail.ShipmentEmail.AgentEmail + ";";
                    }
                }
                if (preAlerDetail.PreAlerEmailTo != null && preAlerDetail.PreAlerEmailTo.Count > 0)
                {
                    foreach (var item in preAlerDetail.PreAlerEmailTo)
                    {
                        if (!string.IsNullOrEmpty(item.Email))
                        {
                            emails += item.Email;
                            emails += ";";
                        }
                    }
                }
            }
            else if (type == "CC")
            {
                if (preAlerDetail.PreAlerEmailCC != null && preAlerDetail.PreAlerEmailCC.Count > 0)
                {
                    foreach (var item in preAlerDetail.PreAlerEmailCC)
                    {
                        if (!string.IsNullOrEmpty(item.Email))
                        {
                            emails += item.Email;
                            emails += ";";
                        }
                    }
                }
            }
            else if (type == "BCC")
            {
                if (preAlerDetail.PreAlerEmailBCC != null && preAlerDetail.PreAlerEmailBCC.Count > 0)
                {
                    foreach (var item in preAlerDetail.PreAlerEmailBCC)
                    {
                        if (!string.IsNullOrEmpty(item.Email))
                        {
                            emails += item.Email;
                            emails += ";";
                        }
                    }
                }
            }
            else
            {
            }

            return(emails);
        }
Exemplo n.º 6
0
        public TradelanePreAlertInitial PreALertInitials(int shipmentId)
        {
            TradelanePreAlertInitial preAlert = new TradelanePreAlertInitial();

            preAlert.PreAlerEmailTo = (from r in dbContext.TradelaneShipments
                                       join utc in dbContext.TradelaneUserTrackingConfigurations on r.CustomerId equals utc.UserId
                                       join utcd in dbContext.TradelaneUserTrackingConfigurationDetails on utc.TradelaneUserTrackingConfigurationId equals utcd.TradelaneUserTrackingConfigurationId
                                       where r.TradelaneShipmentId == shipmentId &&
                                       utc.OtherMethod == "PreAlert"
                                       select new PreAlertEmail
            {
                Email = utcd.Email,
                Name = utcd.Name,
                TradelaneUserTrackingConfigurationDetailId = utcd.TradelaneUserTrackingConfigurationDetailId
            }).ToList();

            preAlert.PreAlertDocumnets = (from r in dbContext.TradelaneShipmentDocuments select r)
                                         .Where(p => p.TradelaneShipmentId == shipmentId)
                                         .GroupBy(x => x.DocumentType)
                                         .Select(group => new TradelanePreAlertDocument
            {
                DocumentType        = group.FirstOrDefault().DocumentType,
                DocumentTypeDisplay = group.FirstOrDefault().DocumentNameDisplay,
                Documents           = group
                                      .Select(subgroup => new TradelanePreAlertDoc
                {
                    Document = subgroup.DocumentName,
                    TradelaneShipmentDocumentId = subgroup.TradelaneShipmentDocumentId,
                    IsSelected = false
                }).ToList()
            }).OrderBy(p => p.DocumentType).ToList();

            preAlert.ShipmentEmail = (from r in dbContext.TradelaneShipments
                                      join oa in dbContext.TradelaneShipmentAddresses on r.FromAddressId equals oa.TradelaneShipmentAddressId
                                      join da in dbContext.TradelaneShipmentAddresses on r.ToAddressId equals da.TradelaneShipmentAddressId
                                      join na in dbContext.TradelaneShipmentAddresses on r.NotifyPartyAddressId equals na.TradelaneShipmentAddressId into leftJoinTemp
                                      from caTemp in leftJoinTemp.DefaultIfEmpty()
                                      join u in dbContext.Users on r.CustomerId equals u.UserId
                                      join ua in dbContext.Users on r.MAWBAgentId equals ua.UserId
                                      where r.TradelaneShipmentId == shipmentId
                                      select new TradelaneShipmentEmailUser
            {
                CustomerEmail = u.UserEmail,
                NotifyPartyEmail = (caTemp == null ? da.Email : caTemp.Email),
                ReceiverEmail = da.Email,
                ShipperEmail = oa.Email,
                AgentEmail = ua.Email
            }).FirstOrDefault();

            // Get Kind Regards Information
            var staffDetail = (from r in dbContext.TradelaneShipments
                               join u in dbContext.Users on r.CustomerId equals u.UserId
                               join ua in dbContext.UserAdditionals on u.UserId equals ua.UserId
                               join uau in dbContext.Users on ua.OperationUserId equals uau.UserId
                               join uaud in dbContext.UserAdditionals on uau.UserId equals uaud.UserId
                               join uaudd in dbContext.UserAddresses on uau.UserId equals uaudd.UserId
                               join c in dbContext.Countries on uaudd.CountryId equals c.CountryId
                               where r.TradelaneShipmentId == shipmentId
                               select new
            {
                UserName = uau.ContactName,
                UserEmail = uau.Email,
                PhoneNumber = uau.TelephoneNo,
                CountryCode = c.CountryPhoneCode,
                Position = uau.Position,
                AdditionalInfo = r.AdditionalInfo
            }).FirstOrDefault();

            if (staffDetail != null)
            {
                preAlert.StaffUserName     = staffDetail.UserName;
                preAlert.StaffUserEmail    = staffDetail.UserEmail;
                preAlert.StaffUserPosition = staffDetail.Position;
                preAlert.StaffUserPhone    = "(+" + staffDetail.CountryCode + ") " + staffDetail.PhoneNumber;
                preAlert.SiteCompany       = "FRAYTE GLOBAL";
                preAlert.AdditionalInfo    = staffDetail.AdditionalInfo;
                preAlert.SiteAddress       = UtilityRepository.GetOperationZone().OperationZoneId == 1 ? "www.FRAYTE.com" : "www.FRAYTE.co.uk";
            }

            return(preAlert);
        }