示例#1
0
        public JsonResult SendContactUs(string fullname, string email, string subject, string content)
        {
            //TODO: Issue Respone all error 403
            Response.Status     = "200 OK";
            Response.StatusCode = 200;
            //TODO: Issue Respone all error 403
            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            //send email
            var fromEmail      = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
            var displayName    = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
            var emailContactUs = AppSettingsReader.GetValue("EmailContactUs", typeof(String)) as string;
            var weblink        = AppSettingsReader.GetValue("Url", typeof(String)) as string;

            var emailContent = TemplateHelpper.FormatTemplateWithContentTemplate(
                TemplateHelpper.ReadContentFromFile(TemplateConfigFile.ContactUsTemplate, true),
                new
            {
                fullname_t = fullname,
                email_t    = email,
                subject_t  = subject,
                content_t  = content,
                web_link   = weblink
            });
            var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];

            _emailHandler.SendEmailSsl(fromEmail, new[] { emailContactUs }, "Email from Contact Us",
                                       emailContent, logo, true, displayName);
            var clientsJson = Json(true, JsonRequestBehavior.AllowGet);

            return(clientsJson);
        }
示例#2
0
        public IHttpActionResult SendEmailForgotPassword(ForgotPasswordDto dtoForgotPassword)
        {
            var          dtoBase        = new DtoBase();
            const string randomPassword = "******";
            var          user           = _userService.FirstOrDefault(o => o.Email == dtoForgotPassword.Email);

            if (user != null)
            {
                var courier = _courierService.GetById(user.Id);
                if (courier != null)
                {
                    var webLink   = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                    var urlSignIn = webLink + "/Authentication/SignIn";
                    var imgSrc    = webLink + "/Content/quickspatch/img/logo-o.svg";

                    var urlChangePass           = webLink + "/Authentication/ChangeRestorePassword?code=" + PasswordHelper.HashString(user.Id.ToString(), user.UserName);
                    var fromEmail               = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                    var displayName             = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                    var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                    var franchiseeName          = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                    var emailContent            = TemplateHelpper.FormatTemplateWithContentTemplate(
                        TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePassword, true),
                        new
                    {
                        img_src         = imgSrc,
                        full_name       = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName),
                        web_link        = webLink,
                        user_name       = user.UserName,
                        url_change_pass = urlChangePass,
                        franchisee_Name = franchiseeName,
                        url_sign_in     = urlSignIn
                    });
                    // send email
                    _emailHandler.SendEmail(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                            emailContent, true, displayName);
                    dtoBase.Id = 1;
                }
            }
            else
            {
                dtoBase.Id = 2;
            }
            return(Ok(dtoBase));
            //return Json(new { }, JsonRequestBehavior.AllowGet);
        }
示例#3
0
        private string _getHtmlDeliveryAgreementReport(RequestQueryInfo queryInfo)
        {
            var data = _requestRepository.GetListDeliveryAgreementVo(queryInfo);

            var fileByte = Convert.FromBase64String(data.Signature);

            var pathDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileUpload");

            if (!Directory.Exists(pathDir))
            {
                Directory.CreateDirectory(pathDir);
            }
            pathDir = Path.Combine(pathDir, "Temps");
            if (!Directory.Exists(pathDir))
            {
                Directory.CreateDirectory(pathDir);
            }

            var fileName = Guid.NewGuid().ToString("N") + ".jpg";

            _pathTempFile = Path.Combine(pathDir, fileName);
            File.WriteAllBytes(_pathTempFile, fileByte);
            var imageName = data.IsAgreed.GetValueOrDefault() ? "accepted" : "rejected";

            var html = TemplateHelpper.FormatTemplateWithContentTemplate(TemplateHelpper.ReadContentFromFile(TemplateConfigFile.DeliveryAgreementReportTemplate, true), new
            {
                data.RequestNo,
                fileName,
                imageName,
                data.RequestAgreed,
                data.RequestFrom,
                data.RequestTo,
                data.RequestTimes,
                data.RequestDistance,
                data.RequestFromName,
                data.RequestToName
            });

            return(string.Format(htmlFormat, html));
        }
示例#4
0
        public ActionResult ResetPassword(int id, string password, string username)
        {
            var user = _userService.GetById(id);

            if (user != null)
            {
                string randomPassword = password;
                user.Password = PasswordHelper.HashString(randomPassword, user.UserName);
                _userService.Update(user);

                var webLink                 = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                var imgSrc                  = webLink + "/Content/quickspatch/img/logo-o.svg";
                var urlChangePass           = webLink + "/Authentication/ChangePasswordCourier?code=" + PasswordHelper.HashString(id.ToString(), user.UserName);
                var fromEmail               = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                var webapi                  = AppSettingsReader.GetValue("WebApiUrlFranchisee", typeof(String)) as string;
                var displayName             = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var franchiseeName          = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                var emailContent            = TemplateHelpper.FormatTemplateWithContentTemplate(
                    TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePasswordCourierTemplate, true),
                    new
                {
                    img_src         = imgSrc,
                    full_name       = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName),
                    web_link        = webLink,
                    user_name       = user.UserName,
                    password        = randomPassword,
                    url_change_pass = urlChangePass,
                    franchisee_Name = franchiseeName,
                    web_api         = webapi
                });
                // send email
                var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];
                _emailHandler.SendEmailSsl(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                           emailContent, logo, true, displayName);
            }


            return(Json(true, JsonRequestBehavior.AllowGet));
        }
示例#5
0
        public JsonResult RestorePassword(string email)
        {
            var user = _userService.FirstOrDefault(o => o.Email == email);

            if (user != null)
            {
                var webLink   = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                var urlSignIn = webLink + "/Authentication/SignIn";
                var imgSrc    = webLink + "/Content/quickspatch/img/logo-o.svg";

                var urlChangePass           = webLink + "/Authentication/ChangeRestorePassword?code=" + PasswordHelper.HashString(user.Id.ToString(), user.UserName);
                var fromEmail               = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                var displayName             = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var franchiseeName          = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                var emailContent            = TemplateHelpper.FormatTemplateWithContentTemplate(
                    TemplateHelpper.ReadContentFromFile(TemplateConfigFile.RestorePassword, true),
                    new
                {
                    img_src         = imgSrc,
                    full_name       = Framework.Utility.CaculatorHelper.GetFullName(user.FirstName, user.MiddleName, user.LastName),
                    web_link        = webLink,
                    user_name       = user.UserName,
                    url_change_pass = urlChangePass,
                    franchisee_Name = franchiseeName,
                    url_sign_in     = urlSignIn
                });
                // send email
                var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];
                _emailHandler.SendEmailSsl(fromEmail, new[] { user.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                           emailContent, logo, true, displayName);
            }
            else
            {
                throw new UserVisibleException("EmailInvalidText");
            }
            return(Json(new { }, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public JsonResult Create(CourierParameter parameters)
        {
            //get franchisee configuration
            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
            {
                FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
            };
            var packageInfo    = _webApiConsumeUserService.GetListPackageChange(objFranchiseeAndLicense);
            var currentPackage = packageInfo.OrderByDescending(o => o.Id).Where(o => o.IsApply).FirstOrDefault();

            //Lay so luong courier dc cho phep cua franchisee
            int numberAllow = 2;

            if (currentPackage != null)
            {
                numberAllow = CaculatorHelper.GetNumberUserAllow(currentPackage.PackageId);
            }

            var numberOfUserCurrent = _userService.Count(o => o.UserRoleId == 2);

            if (numberAllow <= numberOfUserCurrent)
            {
                var mess = string.Format(SystemMessageLookup.GetMessage("NumberUserAllow"));
                MasterFileService.ThrowCustomValidation(mess);
            }
            //Bat dau Add
            var viewModel = MapFromClientParameters(parameters);
            var entity    = viewModel.MapTo <Courier>();

            entity.Status = (int)StatusCourier.Offline;
            // Generate password
            const string randomPassword = "******";

            if (entity.User.UserName != null)
            {
                entity.User.Password = PasswordHelper.HashString(randomPassword, entity.User.UserName);
            }

            var sharViewModel = viewModel.SharedViewModel as DashboardCourierShareViewModel;//
            var logoFilePath  = "";

            if (sharViewModel != null)
            {
                if (!String.IsNullOrEmpty(sharViewModel.UserShareViewModel.Avatar))
                {
                    if (!sharViewModel.UserShareViewModel.Avatar.Contains("data:image/jpg;base64"))
                    {
                        logoFilePath       = Server.MapPath(sharViewModel.UserShareViewModel.Avatar);
                        entity.User.Avatar = _resizeImage.ResizeImageByHeightAndWidth(logoFilePath, 450, 450);
                    }
                }
            }



            var savedEntity = MasterFileService.Add(entity);

            if (savedEntity.Id > 0)
            {
                var webLink       = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                var imgSrc        = webLink + "/Content/quickspatch/img/logo-o.svg";
                var urlChangePass = webLink + "/Authentication/ChangePasswordCourier?code=" + PasswordHelper.HashString(savedEntity.Id.ToString(), entity.User.UserName);
                var fromEmail     = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                var webapi        = AppSettingsReader.GetValue("WebApiUrlFranchisee", typeof(String)) as string;
                var displayName   = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                //var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                var emailContent   = Framework.Utility.TemplateHelpper.FormatTemplateWithContentTemplate(
                    TemplateHelpper.ReadContentFromFile(TemplateConfigFile.CreateCourierEmailTemplate, true),
                    new
                {
                    img_src         = imgSrc,
                    full_name       = Framework.Utility.CaculatorHelper.GetFullName(savedEntity.User.FirstName, savedEntity.User.MiddleName, savedEntity.User.LastName),
                    web_link        = webLink,
                    user_name       = entity.User.UserName,
                    password        = randomPassword,
                    url_change_pass = urlChangePass,
                    franchisee_Name = franchiseeName,
                    web_api         = webapi
                });
                // send email
                var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];
                _emailHandler.SendEmailSsl(fromEmail, new[] { savedEntity.User.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                           emailContent, logo, true, displayName);
            }
            return
                (Json(new
            {
                id = savedEntity.Id,
                name =
                    Framework.Utility.CaculatorHelper.GetFullName(savedEntity.User.FirstName,
                                                                  savedEntity.User.MiddleName, savedEntity.User.LastName)
            }, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        public int Create(UserParameter parameters)
        {
            //get franchisee configuration
            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
            {
                FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
            };
            var packageInfo = _webApiConsumeUserService.GetListPackageChange(objFranchiseeAndLicense);

            //Bat dau Add
            var viewModel = MapFromClientParameters(parameters);
            var entity    = viewModel.MapTo <User>();
            // Generate password
            const string randomPassword = "******";

            if (entity.UserName != null)
            {
                entity.Password = PasswordHelper.HashString(randomPassword, entity.UserName);
            }
            //entity.Password = "******";
            var sharViewModel = viewModel.SharedViewModel as DashboardUserShareViewModel;//
            var logoFilePath  = "";

            if (sharViewModel != null)
            {
                if (!String.IsNullOrEmpty(sharViewModel.Avatar))
                {
                    if (!sharViewModel.Avatar.Contains("data:image/jpg;base64"))
                    {
                        logoFilePath  = Server.MapPath(sharViewModel.Avatar);
                        entity.Avatar = _resizeImage.ResizeImageByHeightAndWidth(logoFilePath, 450, 450);
                    }
                }
            }


            var savedEntity = MasterFileService.Add(entity);

            if (savedEntity.Id > 0)
            {
                var webLink       = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                var urlSignIn     = webLink + "/Authentication/SignIn";
                var imgSrc        = webLink + "/Content/quickspatch/img/logo-o.svg";
                var urlChangePass = webLink + "/Authentication/ChangePassword?code=" + PasswordHelper.HashString(savedEntity.Id.ToString(), entity.UserName);
                var fromEmail     = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                var displayName   = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                //var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                var emailContent   = Framework.Utility.TemplateHelpper.FormatTemplateWithContentTemplate(
                    TemplateHelpper.ReadContentFromFile(TemplateConfigFile.CreateUserEmailTemplate, true),
                    new
                {
                    img_src         = imgSrc,
                    full_name       = Framework.Utility.CaculatorHelper.GetFullName(savedEntity.FirstName, savedEntity.MiddleName, savedEntity.LastName),
                    web_link        = webLink,
                    user_name       = entity.UserName,
                    password        = randomPassword,
                    url_change_pass = urlChangePass,
                    franchisee_Name = franchiseeName,
                    url_sign_in     = urlSignIn
                });
                // send email
                var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];
                _emailHandler.SendEmailSsl(fromEmail, new[] { savedEntity.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                           emailContent, logo, true, displayName);
            }
            return(savedEntity.Id);
        }