Beispiel #1
0
        public ResponseModel ReportSearch([FromBody] StoreReportModel SearchParams)
        {
            ResponseModel           objResponseModel = new ResponseModel();
            int                     StatusCode       = 0;
            string                  statusMessage    = "";
            int                     resultCount      = 0;
            StoreReportCaller       dbsearchMaster   = new StoreReportCaller();
            List <StoreUserListing> StoreUserList    = new List <StoreUserListing>();

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();

                authenticate          = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                SearchParams.TenantID = authenticate.TenantId; // add tenantID to request
                                                               // searchparams.curentUserId = authenticate.UserMasterID; // add currentUserID to request

                StoreUserList = new StoreUserService(_connectioSting).GetStoreUserList(authenticate.TenantId);

                resultCount = dbsearchMaster.StoreReportSearch(new StoreReportService(_connectioSting), SearchParams, StoreUserList);

                StatusCode                    = resultCount > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound;
                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)StatusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = StatusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = resultCount;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
Beispiel #2
0
        public ResponseModel CheckIfReportNameExists(int ReportID, string ReportName)
        {
            ResponseModel           objResponseModel = new ResponseModel();
            int                     StatusCode       = 0;
            string                  statusMessage    = "";
            bool                    IsExists         = false;
            StoreReportCaller       dbsearchMaster   = new StoreReportCaller();
            List <StoreUserListing> StoreUserList    = new List <StoreUserListing>();

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();

                authenticate  = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                StoreUserList = new StoreUserService(_connectioSting).GetStoreUserList(authenticate.TenantId);
                IsExists      = dbsearchMaster.CheckIfReportNameExists(new StoreReportService(_connectioSting), ReportID, ReportName, authenticate.TenantId);

                StatusCode                    = IsExists ? (int)EnumMaster.StatusCode.RecordAlreadyExists : (int)EnumMaster.StatusCode.RecordNotFound;
                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)StatusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = StatusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = IsExists;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
        public void TestLoginAndLogout()
        {
            StoreUserService storeUserService = new StoreUserService();
            var data = storeUserService.Login("1008", "123456", true);

            storeUserService.Logout();
        }
Beispiel #4
0
        public ResponseModel DownloadStoreReportSearch(int ReportID)
        {
            ResponseModel           objResponseModel = new ResponseModel();
            int                     StatusCode       = 0;
            string                  statusMessage    = "";
            string                  CSVReport        = string.Empty;
            string                  appRoot          = string.Empty;
            string                  Folderpath       = string.Empty;
            string                  URLPath          = string.Empty;
            StoreReportCaller       dbsearchMaster   = new StoreReportCaller();
            List <StoreUserListing> StoreUserList    = new List <StoreUserListing>();

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();

                authenticate  = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                StoreUserList = new StoreUserService(_connectioSting).GetStoreUserList(authenticate.TenantId);
                CSVReport     = dbsearchMaster.DownloadStoreReportSearch(new StoreReportService(_connectioSting), ReportID, authenticate.UserMasterID, authenticate.TenantId, StoreUserList);

                appRoot = Directory.GetCurrentDirectory();

                string CSVFileName = "StoreReport_" + ReportID + "_" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".csv";

                Folderpath = Path.Combine(appRoot, "ReportDownload");
                if (!Directory.Exists(Folderpath))
                {
                    Directory.CreateDirectory(Folderpath);
                }


                if (!string.IsNullOrEmpty(CSVReport))
                {
                    URLPath    = rootPath + "ReportDownload" + "/" + CSVFileName;
                    Folderpath = Path.Combine(Folderpath, CSVFileName);
                    CommonService.SaveFile(Folderpath, CSVReport);
                }


                StatusCode                    = !string.IsNullOrEmpty(CSVReport) ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound;
                statusMessage                 = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)StatusCode);
                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = StatusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = !string.IsNullOrEmpty(CSVReport) ? URLPath : string.Empty;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
Beispiel #5
0
        public IActionResult Index()
        {
            string from = Request.Query["from"];

            if (!string.IsNullOrEmpty(from))
            {
                from = HttpUtility.UrlDecode(from);
                Response.Cookies.Append("refer", from);
            }
            if (HttpContext.Session.Get <AdminDto>(SessionKey.AdminInfo) != null)
            {
                if (string.IsNullOrEmpty(from))
                {
                    from = QuickKeys.AdminHome;
                }
                return(Redirect(from));
            }
            if (Request.Cookies.Count > 2)
            {
                string name     = Request.Cookies["admin_username"];
                string pwd      = Request.Cookies["admin_password"]?.DesDecrypt(AppConfig.BaiduAK);
                var    adminDto = StoreUserService.Login(name, pwd).Mapper <AdminDto>();
                if (adminDto != null)
                {
                    Response.Cookies.Append("admin_username", name, new CookieOptions()
                    {
                        Expires = DateTime.Now.AddDays(7)
                    });
                    Response.Cookies.Append("admin_password", Request.Cookies["admin_password"], new CookieOptions()
                    {
                        Expires = DateTime.Now.AddDays(7)
                    });
                    HttpContext.Session.Set(SessionKey.AdminInfo, adminDto);
                    //HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.LoginRecord), "default", adminDto, HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), LoginType.Default);
                    //初始化系统设置参数
                    CommonHelper.SystemSettings = SettingService.LoadEntities(l => l.wxapp_id == adminDto.wxapp_id).ToList().ToDictionary(s => s.key, s => JObject.Parse(s.values));
                    if (string.IsNullOrEmpty(from))
                    {
                        from = QuickKeys.AdminHome;
                    }
                    return(Redirect(from));
                }
            }
            return(View(new AdminLoginRequest()));
        }
Beispiel #6
0
        public IActionResult Login(AdminLoginRequest request)
        {
            //string validSession = HttpContext.Session.Get<string>("valid") ?? string.Empty; //将验证码从Session中取出来,用于登录验证比较
            //if (string.IsNullOrEmpty(validSession) || !valid.Trim().Equals(validSession, StringComparison.InvariantCultureIgnoreCase))
            //{
            //    return No("验证码错误");
            //}
            //HttpContext.Session.Remove("valid"); //验证成功就销毁验证码Session,非常重要

            if (string.IsNullOrEmpty(request.user_name.Trim()) || string.IsNullOrEmpty(request.password.Trim()))
            {
                return(No("用户名或密码不能为空"));
            }
            var adminDto = StoreUserService.Login(request.user_name, request.password).Mapper <AdminDto>();

            if (adminDto != null)
            {
                HttpContext.Session.Set(SessionKey.AdminInfo, adminDto);
                if (request.remember.Trim().Contains(new[] { "on", "true" })) //是否记住登录
                {
                    Response.Cookies.Append("admin_username", HttpUtility.UrlEncode(request.user_name.Trim()), new CookieOptions()
                    {
                        Expires = DateTime.Now.AddDays(7)
                    });
                    Response.Cookies.Append("admin_password", request.password.Trim().DesEncrypt(AppConfig.BaiduAK), new CookieOptions()
                    {
                        Expires = DateTime.Now.AddDays(7)
                    });
                }
                //HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.LoginRecord), "default", adminDto, HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), LoginType.Default);
                string refer = Request.Cookies["refer"];
                //初始化系统设置参数
                CommonHelper.SystemSettings = SettingService.LoadEntities(l => l.wxapp_id == adminDto.wxapp_id).ToList().ToDictionary(s => s.key, s => JObject.Parse(s.values));
                return(YesRedirect("登陆成功!", string.IsNullOrEmpty(refer) ? "/" : refer));
            }
            return(No("用户名或密码错误"));
        }