Пример #1
0
        public HttpResponseMessage GetCheckShipmentsByMembership(int customerId)
        {
            try {
                BOShipments shipment = new BOShipments();

                string result = shipment.checkShipmentsByMembership(customerId);


                Result json = JsonConvert.DeserializeObject <Result>(result);
                if (json.sendMail == "Yes")
                {
                    BOContacts contact      = new BOContacts();
                    var        listContacts = new List <customer_contacts>();
                    listContacts = contact.GetContact(customerId);
                    //List<Order> SortedList = objListOrder.OrderBy(o=>o.OrderDate).ToList();
                    var emailhandler = new TransShip.EMailHandler.EMailHandler();

                    emailhandler.SendMembershipEmail(json.message, listContacts[0].email);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            } catch (Exception e) {
                ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to get shipments - " + e.GetBaseException().Message, e.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje));
            }
        }
Пример #2
0
        public string RecoverPassword(string email, string baseURI)
        {
            var returnValue = string.Empty;
            var passwd      = TransShip.Security.Security.Encrypt(DateTime.Now.ToString(), new RijndaelManaged(), TransShip.Security.Security.GenerateKey(new RijndaelManaged(), 256));
            var stopwatch   = new Stopwatch();

            stopwatch.Start();
            try
            {
                var userToConfirm = _transshipEntities.users.First(x => x.email.Equals(email,
                                                                                       StringComparison.Ordinal));
                //userToConfirm.status = "R"; //Recover Password
                userToConfirm.confirmationKey = passwd;
                _transshipEntities.SaveChanges();
                returnValue = "done";
            }
            catch (Exception e)
            {
                LogBook.TextLog.Info(string.Format("{0} {3}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
            finally
            {
                if (string.IsNullOrEmpty(returnValue) == false)
                {
                    var emailhandler = new TransShip.EMailHandler.EMailHandler();
                    emailhandler.SendConfirmationEmail(string.Format("your password has been recovered, please enter the following link"), string.Format("{0}/Home/RecoverPassword?apiInformation={1}", baseURI,
                                                                                                                                                         HttpUtility.UrlEncode(passwd)), email);
                }
                stopwatch.Stop();
            }
            return(returnValue);
        }
Пример #3
0
        public decimal UpdateUserState(decimal?customerId, decimal?userId, string newState, string baseURI)
        {
            var    returnValue = (long)0;
            var    stopwatch   = new Stopwatch();
            string email       = "";
            string passwd      = "";

            stopwatch.Start();
            try
            {
                var userEntity = _transshipEntities.users.First(x => x.userId == userId);
                userEntity.status = newState;
                email             = userEntity.email;
                passwd            = userEntity.password;
                _transshipEntities.SaveChanges();

                var customerEntity = _transshipEntities.customers.First(x => x.customerId == customerId);
                if (newState == "A")
                {
                    customerEntity.status = "A";
                    _transshipEntities.SaveChanges();
                }
                else
                {
                    customerEntity.status = "R";
                    _transshipEntities.SaveChanges();
                }

                returnValue = 1000;
            }
            catch (Exception e)
            {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
            finally
            {
                var emailhandler = new TransShip.EMailHandler.EMailHandler();
                try {
                    if (newState == "A")
                    {
                        emailhandler.SendConfirmationEmail(string.Format("Your request has been approved, please enter the following link"),
                                                           string.Format(baseURI + "/home"), email);
                    }
                    else
                    {
                        emailhandler.SendConfirmationEmail(string.Format("Your request has been rejected, please contact TransShip"),
                                                           string.Format(""), email);
                    }
                    stopwatch.Stop();
                } catch (Exception e) {
                    throw e;
                }
            }
            return(returnValue);
        }
Пример #4
0
        public decimal CreateUser(CreateUserObject createUserObject, string baseURI)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var returnValue = (decimal)0;
            var passwd      = string.Empty;

            using (var dbTran = _transshipEntities.Database.BeginTransaction())
            {
                try
                {
                    var newCustomer = new customers {
                        company_name         = createUserObject.companyname,
                        countryId            = createUserObject.idCountry,
                        city                 = createUserObject.city,
                        estimated_membership = createUserObject.membership,
                        address1             = createUserObject.addr1,
                        address2             = createUserObject.addr2,
                        zipcode              = createUserObject.zipcode,
                        status               = "P",
                        register_date        = DateTime.Today,
                        state                = createUserObject.usstate
                    };

                    _transshipEntities.customers.Add(newCustomer);

                    passwd = TransShip.Security.Security.Encrypt(DateTime.Now.ToString(), new RijndaelManaged(), TransShip.Security.Security.GenerateKey(new RijndaelManaged(), 256));
                    var newUser = new users
                    {
                        customerId      = newCustomer.customerId,
                        full_name       = createUserObject.fullname,
                        email           = createUserObject.email,
                        password        = TransShip.Security.Security.Encrypt(createUserObject.keyinformation, new RijndaelManaged(), KEY),
                        user_type       = "C",
                        status          = "I",
                        role            = "A",
                        confirmationKey = passwd
                    };
                    _transshipEntities.users.Add(newUser);

                    var newContact = new customer_contacts {
                        customerId   = newCustomer.customerId,
                        full_name    = createUserObject.fullname,
                        title        = createUserObject.title,
                        phone_number = createUserObject.phonenumber,
                        email        = createUserObject.email
                    };

                    _transshipEntities.customer_contacts.Add(newContact);
                    _transshipEntities.SaveChanges();
                    returnValue = newUser.userId;
                    dbTran.Commit();
                }
                catch (Exception e)
                {
                    LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                }
                finally
                {
                    stopwatch.Stop();
                    LogBook.TextLog.Info(string.Format("Ellapsed time {0} milli seconds", stopwatch.ElapsedMilliseconds));
                    var emailhandler = new TransShip.EMailHandler.EMailHandler();

                    emailhandler.SendConfirmationEmail(string.Format("your registration has been successful, TranShip will contact you "),
                                                       string.Format("{0}?apiInformation={1}", baseURI, HttpUtility.UrlEncode(passwd)), createUserObject.email);
                }
            }
            return(returnValue);
        }