예제 #1
0
        public ActionResult Index(string keyCode)
        {
            if (string.IsNullOrEmpty(keyCode))
            {
                return(Redirect("/"));
            }
            var password = string.Empty;
            var userName = GetKeyAuthenticationDecrypt(keyCode, ref password);
            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
            {
                FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
            };
            var franchiseeTenantPackageInfo = _webApiUserService.GetPackageCurrentId(objFranchiseeAndLicense);

            //TODO: franchiseeTenantPackageInfo.Active == false update franchiseeTenantPackageInfo.Active == true when deploy
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password) || franchiseeTenantPackageInfo == null || franchiseeTenantPackageInfo.Active)
            {
                return(Redirect("/"));
            }
            return(View(new LicenceExtensionData {
                KeyCode = keyCode, UserName = userName
            }));
        }
예제 #2
0
        public JsonResult QuickspatchSignIn(string userName, string password, bool rememberMe, string returnUrl)
        {
            var isCamino = true;

            // Check if system is the franchisse, login to the web api to verify the license

            if (ConstantValue.DeploymentMode == DeploymentMode.Franchisee)
            {
                isCamino = false;
                var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
                {
                    //FranchiseeName = ConstantValue.FranchiseeName,
                    //LicenseKey = ConstantValue.LicenseKey
                    FranchiseeName = franchiseeConfiguration != null?franchiseeConfiguration.Name:"",
                    LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "",
                };
                //Get Key Authentication for exeption Licence Invalid.
                var keyAuthentication = GetKeyAuthentication(userName, password);
                SignInToWebApi(objFranchiseeAndLicense, keyAuthentication);
                // Get list module for franchisee
                var franchiseeData = _webApiUserService.GetModuleForFranchisee(objFranchiseeAndLicense);
                MenuExtractData.Instance.ModuleForFranchisee = franchiseeData;
                MenuExtractData.Instance.NumberOfCourier     = franchiseeData.NumberOfCourier;
            }

            password = PasswordHelper.HashString(password, userName);
            _authenticationService.SignIn(userName, password, rememberMe, ConstantValue.DeploymentMode.ToString());

            return(Json(new { isCamino }, JsonRequestBehavior.AllowGet));
        }
예제 #3
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);
        }
예제 #4
0
        public ActionResult Index()
        {
            var isQuickTour = false;

            if (ConstantValue.DeploymentMode != DeploymentMode.Camino)
            {
                var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();

                if (franchiseeConfiguration != null)
                {
                    isQuickTour = franchiseeConfiguration.IsQuickTour != null && (bool)franchiseeConfiguration.IsQuickTour;
                }
            }

            var model = new DashboardHomeIndexViewModel
            {
                IsQuickTour = false
            };

            return(View(model));
        }
예제 #5
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);
        }
예제 #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);
        }