Beispiel #1
0
        public ActionResult Create(SuppliersModel model)
        {
            ViewBag.thArea   = _thAreaService.GetTHAreaByParentID(ACultureHelper.GetLanguageID, 0).Data;
            ViewBag.xianArea = SelectCommon.GetTHArea_lang(null);

            if (ModelState.IsValid)
            {
                ResultModel resultModel = new ResultModel();

                if (model.SupplierId > 0)
                {
                    model.UpdateBy = UserInfo.CurrentUserName;
                    model.UpdateDT = DateTime.Now;
                    var result = _suppliersService.UpdateSuppliers(model).IsValid;

                    resultModel.Messages = new List <string> {
                        result == true ? " success!" : " failed!"
                    };
                    var opera = string.Empty;
                    opera = string.Format("修改供应商管理:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "修改供应商管理");
                }
                else
                {
                    SalesSuppliersModel smodel = new SalesSuppliersModel();
                    smodel.Mobile     = model.Mobile;
                    smodel.PagedIndex = 0;
                    smodel.PagedSize  = 2;
                    var bl = Mobile(smodel);
                    if (bl)
                    {
                        model.PassWord   = FormsAuthentication.HashPasswordForStoringInConfigFile(model.PassWord.Trim(), "MD5");
                        model.SupplierId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                        model.CreateBy   = UserInfo.CurrentUserName;
                        model.CreateDT   = DateTime.Now;
                        model.UpdateBy   = UserInfo.CurrentUserName;
                        model.UpdateDT   = DateTime.Now;
                        var result = _suppliersService.AddSuppliers(model).IsValid;
                        resultModel.Messages = new List <string> {
                            result == true ? " success!" : " failed!"
                        };
                        var opera = string.Empty;
                        opera = string.Format("添加供应商管理:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                        LogPackage.InserAC_OperateLog(opera, "添加供应商管理");
                    }
                    else
                    {
                        resultModel.IsValid  = false;
                        resultModel.Messages = new List <string> {
                            " Mobile phone number already exists!"
                        };
                    }
                }


                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }

            return(PartialView(model));
        }
Beispiel #2
0
        public async Task DataInMemoryCacheButNotFresh_BackendGetErrors()
        {
            CachedItemWrapper <string> memoryCacheItem = new CachedItemWrapper <string>("fromMemCache", new DateTimeOffset(2020, 05, 17, 19, 59, 59, 00, new TimeSpan(0, 0, 0)));

            _pollySyncCacheProvider.Setup(x => x.TryGet(It.IsAny <string>())).Returns((true, memoryCacheItem));

            _mockableDateTime.Setup(x => x.UtcNow).Returns(new DateTimeOffset(2020, 05, 17, 20, 00, 00, 00, new TimeSpan(0, 0, 0)));

            Func <CancellationToken, Task <string> > _dataGetterDelegate1 = (token) =>
            {
                _numberOfTimesDataGetterDelegate1Called++;
                throw new Exception("An error");
            };

            MemCacheFactory <string> memCacheFactory = new MemCacheFactory <string>(_pollySyncCacheProvider.Object, _mockableDateTime.Object, _logger.Object);
            IMemDistCache <string>   memCache        = memCacheFactory.GetCache(_defaultCacheDuration, ResetTimeFactory.OnHour);

            string result = await memCache.GetCachedDataAsync(_dataGetterDelegate1, _key, RefreshBehaviour.DontWaitForFreshData, CancellationToken.None);

            Assert.AreEqual("fromMemCache", result);

            _pollySyncCacheProvider.Verify(x => x.TryGet(It.Is <string>(y => y == _key)), Times.Once);


            await Task.Delay(_waitForBackgroundThreadToCompleteMs); // wait for background thread

            _logger.Verify(x => x.LogError(It.Is <string>(y => y == $"Error executing data getter for key: {_key}"), It.IsAny <Exception>()));

            Assert.AreEqual(1, _numberOfTimesDataGetterDelegate1Called);

            DateTimeOffset whenDataWillNotBeFresh = new DateTimeOffset(2020, 05, 17, 21, 00, 00, 00, new TimeSpan(0, 0, 0));

            _pollySyncCacheProvider.Verify(x => x.Put(It.IsAny <string>(), It.Is <CachedItemWrapper <string> >(y => y.Content == "dataFromBackendGet" && y.IsFreshUntil == whenDataWillNotBeFresh), It.Is <Ttl>(y => y.Timespan == _defaultCacheDuration)), Times.Never);
        }
        //
        // GET: /Home/
        public ActionResult Index()
        {
            //string bb = DateTime.Now.ToString("YYMMDDhhmm");
            _logger.Error("ssssssss");
            //Session["a"] = "oererr";
            //long id = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
            //string ip = ToolUtil.GetRealIP();
            // ViewBag.UserName = "******";

            for (int a = 0; a < 10; a++)
            {
                long id = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
            }
            if (UserInfo.CurrentUserRoleID == 0)
            {
                //Response.Redirect("/AC_User/login");
            }
            ViewBag.UserName = UserInfo.CurrentUserName;
            ViewBag.UserID   = UserInfo.CurrentUserID;
            int roleId = UserInfo.CurrentUserRoleID;
            List <AC_ModuleModel> menuList = new List <AC_ModuleModel>();

            if (roleId > 0)
            {
                menuList = (_roleService.GetModuleMenuList(roleId)).Data;
            }
            return(View(menuList));
        }
        public ActionResult Create(ParameterSetModel model)
        {
            var admin = UserInfo.CurrentUserName;

            if (ModelState.IsValid)
            {
                var resultModel = new ResultModel();
                if (model.ParamenterID != 0)
                {
                    model.UpdateBy = admin;
                    model.UpdateDT = DateTime.Now;
                    var result = _parameterSetService.Update(model);
                    resultModel.Messages = new List <string>
                    {
                        result.Data > 0 ? "Modify system parameter success" : "Modify system parameter failed"
                    };
                    var opera = string.Format("修改系统参数:{0},操作结果:{1}", JsonConverts.ToJson(model), result.Data > 0 ? "成功" : "失败");
                    LogPackage.InserAC_OperateLog(opera, "系统管理--系统参数");
                }
                else
                {
                    model.ParamenterID   = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.CreateBy       = admin;
                    model.CreateDT       = DateTime.Now;
                    model.UpdateBy       = admin;
                    model.UpdateDT       = DateTime.Now;
                    resultModel.Messages = new List <string>
                    {
                        _parameterSetService.Add(model).Messages.Count == 0 ? "Add system parameter success" : "Add system parameter failed"
                    };
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            return(PartialView(model));
        }
        public ActionResult Create(SalesRuleModel model)
        {
            var admin = UserInfo.CurrentUserName;

            if (ModelState.IsValid)
            {
                var resultModel = new ResultModel();
                if (model.SalesRuleId != 0)
                {
                    resultModel.Messages = new List <string>
                    {
                        _salesRuleService.Update(model).Data > 0 ? "修改促销规则成功" : "修改促销规则失败"
                    };
                }
                else
                {
                    model.SalesRuleId    = (int)MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    resultModel.Messages = new List <string>
                    {
                        _salesRuleService.Add(model).Messages.Count == 0 ? "添加促销规则成功" : "添加促销规则失败"
                    };
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            return(PartialView(model));
        }
        public void Return_GoodsService_AddReturn_Goods_Test()
        {
            for (int i = 0; i < 10; i++)
            {
                var resultModel = this._return_GoodsService.AddReturnProductInfo(new ReturnProductInfoModel()
                {
                    ReturnOrderID     = MemCacheFactory.GetCurrentMemCache().Increment("logId").ToString(),
                    OrderID           = "100",
                    UserID            = 1,
                    ProductId         = 1,
                    ProductSnapshotID = 1,
                    ReturnType        = 1,
                    ReturnStatus      = 1, //ToolUtil.GetRealIP(),
                    TradeAmount       = 10,
                    RefundAmount      = 1,
                    ReturntNumber     = 1,
                    ReasonType        = 1,
                    Discription       = "sdfa",
                    //ReturnType=2,
                    ReturnAddress  = "asdfasdf",
                    ReceiverName   = "阿道夫",
                    ReceiverMobile = "135552554",
                    ReceiverTel    = "2025555",
                    //ReturnStatus=1,
                    MerchantReturnAddress = "asdfas阿斯蒂芬",
                    ReturnText            = "阿斯蒂芬",
                    CreateTime            = DateTime.Now,
                    UpdateTime            = DateTime.Now
                }, 1);

                Assert.IsTrue(resultModel.IsValid);
            }
        }
Beispiel #7
0
        public ActionResult BannerCreate(bannerModel model)
        {
            ViewBag.RootImage = ImagePath;
            ViewData["BannerPlaceCodeModel1"] = null;
            ViewBag.ImagePath = ImagePath;//图片前半段地址
            var opera = string.Empty;

            if (ModelState.IsValid)
            {
                ResultModel resultModel = new ResultModel();
                if (model.ProductId > 0)
                {
                    ProductModel modelp = GetBannerProductByProductId(model.ProductId);
                    if (modelp == null)
                    {
                        resultModel.Messages = new List <string>()
                        {
                            "Invalid product ID"
                        };
                        return(Json(resultModel, JsonRequestBehavior.AllowGet));
                    }
                }


                if (model.bannerId != 0)
                {
                    model.UpdateBy = UserInfo.CurrentUserName;
                    model.UpdateDT = DateTime.Now;

                    resultModel          = this._bannerService.UpdateBanner(model);
                    resultModel.Messages = new List <string>()
                    {
                        resultModel.Data > 0 ? "Modify success" : "Modify failed"
                    };

                    opera = string.Format("修改首页轮播banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "广告管理--首页轮播banner-修改");
                }
                else
                {
                    model.bannerId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.CreateBy = UserInfo.CurrentUserName;
                    model.CreateDT = DateTime.Now;
                    model.UpdateBy = UserInfo.CurrentUserName;
                    model.UpdateDT = DateTime.Now;
                    model.Sorts    = MemCacheFactory.GetCurrentMemCache().Increment("commonId");

                    resultModel          = this._bannerService.AddBanner(model);
                    resultModel.Messages = new List <string>()
                    {
                        resultModel.Data != 0 ? "Add success" : "Add failed"
                    };
                    opera = string.Format("添加首页轮播banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "广告管理--首页轮播banner-添加");
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            ViewBag.Ts = "有未填项";
            return(PartialView(model));
        }
        public ActionResult Create(AC_UserModel model)
        {
            ResultModel resultModel = resultModel = new ResultModel();
            string      opera       = "";

            if (model.UserID == 0)
            {
                model.UserID     = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                model.LoginTimes = 0;
                model.CreateUser = UserInfo.CurrentUserName;
                model.CreateDT   = DateTime.Now;
                model.Password   = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "MD5");
                resultModel      = _acUserService.AddAC_User(model);
                opera            = string.Format("系统用户添加:{0},操作结果:{1}", JsonConverts.ToJson(model), "操作成功");
                LogPackage.InserAC_OperateLog(opera, "System--User-Add");
            }
            else
            {
                model.UpdateUser     = UserInfo.CurrentUserName;
                model.UpdateDt       = DateTime.Now;
                resultModel          = _acUserService.UpdateAC_User(model);
                resultModel.Messages = new List <string> {
                    "Edit user success"
                };
                opera = string.Format("系统用户修改:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                LogPackage.InserAC_OperateLog(opera, "System--User-Edit");
            }
            return(Json(resultModel, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        /// <summary>
        /// 获取区域数据
        /// zhoub 20150709
        /// </summary>
        /// <returns></returns>
        public ResultModel GetTHAreaByLanguageIdToTreeApi(int languageId)
        {
            var     result = new ResultModel();
            dynamic cl;
            var     key       = "GetTHAreaByLanguageIdToTreeApi" + languageId;
            var     dataCache = MemCacheFactory.GetCurrentMemCache().GetCache <dynamic>(key);

            if (dataCache != null && dataCache.Count > 0)
            {
                result.Data = dataCache;
            }
            else
            {
                var data = _database.Db.THArea
                           .Query()
                           .LeftJoin(_database.Db.THArea_lang, out cl)
                           .On(cl.THAreaID == _database.Db.THArea.THAreaID)
                           .Select(
                    _database.Db.THArea.THAreaID.As("areaId")
                    , cl.AreaName.As("text")
                    , cl.languageId
                    , _database.Db.THArea.parentId
                    ).OrderBy(_database.Db.THArea.THAreaID, cl.languageId)
                           .Where(cl.languageId == languageId)
                           .ToList();
                result.Data = CreateTreeApi(data, 0);
                MemCacheFactory.GetCurrentMemCache().AddCache(key, result.Data, 60);
            }
            return(result);
        }
Beispiel #10
0
        public void BrndService_Add_Test()
        {
            var resultModel = this._baseService.Add(new BrandModel
            {
                BrandID    = (int)MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                BrandState = 0,
                BrandUrl   = "www.baidu.com",
                FirstPY    = "1",
                Remark     = "非常棒的商品品牌",
                UpdateBy   = "admin",
                UpdateDT   = DateTime.Now,
                AddTime    = DateTime.Now,
                AddUsers   = "admin",
                Brand_Lang = new List <Brand_Lang>()
                {
                    new Brand_Lang()
                    {
                        LanguageID = 1, BrandName = "aaa"
                    },
                    new Brand_Lang()
                    {
                        LanguageID = 2, BrandName = "ccc"
                    },
                    new Brand_Lang()
                    {
                        LanguageID = 3, BrandName = "sssss"
                    }
                }
            });

            Assert.IsTrue(resultModel.IsValid);
        }
        /// <summary>
        /// 生成返现实体
        /// </summary>
        /// <param name="totalMoney"></param>
        /// <param name="model"></param>
        /// <param name="dmodel"></param>
        /// <returns></returns>
        private ZJ_RebateInfo FormartZJ_RebateInfo(decimal totalMoney, OderModel model, OrderDetails dmodel)
        {
            ZJ_RebateInfo zrModel = new ZJ_RebateInfo();

            zrModel.ID             = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
            zrModel.CreateBY       = "系统服务";
            zrModel.CreateTime     = DateTime.Now;
            zrModel.OrderDetailsID = dmodel.OrderDetailsID;
            zrModel.OrderID        = dmodel.OrderID;
            zrModel.ProductID      = dmodel.ProductId;
            zrModel.SKUID          = dmodel.SKU_ProducId;
            zrModel.StartTime      = DateTime.Now;
            zrModel.Status         = 1;
            if (isFixedDays == 1)
            {
                zrModel.TotalDay   = backDays;
                zrModel.TotalMoney = totalMoney * backPoint;
            }
            else
            {
                zrModel.TotalDay   = dmodel.RetateDays != null ? (int)dmodel.RetateDays : backDays;
                zrModel.TotalMoney = totalMoney * (decimal)(dmodel.ReateRedio != null ? dmodel.ReateRedio : backPoint);
            }
            zrModel.UserID = model.UserID;
            return(zrModel);
        }
        public void CategoryService_UpdateCategory_Test()
        {
            var resultModel = this._categoryService.AddCategory(new AddCategoryModel
            {
                AddDate    = DateTime.Now,
                parentId   = 0,
                AuditState = true,
                AddUser    = "******",
                Grade      = 1,
                CategoryId = (int)MemCacheFactory.GetCurrentMemCache().Increment("commonId")
            });

            var result = this._categoryService.UpdateCategory(new UpdateCategoryModel()
            {
                UpdateBy   = "test1",
                CategoryId = resultModel.Data,
                parentId   = 1,
                AuditState = true,
                Grade      = 1,
                UpdateDT   = DateTime.Now
            });

            Assert.IsTrue(result.IsValid);

            var category = this._categoryService.GetCategoryById(resultModel.Data);

            Assert.AreEqual(category.Data.AddUser, "test1");
            Assert.AreEqual(category.Data.parentId, 1);
            Assert.AreEqual(category.Data.AuditState, 1);
            Assert.AreEqual(category.Data.Grade, 1);
        }
Beispiel #13
0
        public async Task DataInMemoryCacheButNotFresh_DontRefreshData()
        {
            CachedItemWrapper <string> memoryCacheItem = new CachedItemWrapper <string>("fromMemCache", new DateTimeOffset(2020, 05, 17, 19, 59, 59, 00, new TimeSpan(0, 0, 0)));

            _pollySyncCacheProvider.Setup(x => x.TryGet(It.IsAny <string>())).Returns((true, memoryCacheItem));

            _mockableDateTime.Setup(x => x.UtcNow).Returns(new DateTimeOffset(2020, 05, 17, 20, 00, 00, 00, new TimeSpan(0, 0, 0)));

            MemCacheFactory <string> memCacheFactory = new MemCacheFactory <string>(_pollySyncCacheProvider.Object, _mockableDateTime.Object, _logger.Object);
            IMemDistCache <string>   memCache        = memCacheFactory.GetCache(_defaultCacheDuration, ResetTimeFactory.OnHour);

            string result = await memCache.GetCachedDataAsync(_dataGetterDelegate1, _key, RefreshBehaviour.DontRefreshData, CancellationToken.None);

            Assert.AreEqual("fromMemCache", result);

            _pollySyncCacheProvider.Verify(x => x.TryGet(It.Is <string>(y => y == _key)), Times.Once);


            await Task.Delay(_waitForBackgroundThreadToCompleteMs); // wait for background thread

            Assert.AreEqual(0, _numberOfTimesDataGetterDelegate1Called);


            _pollySyncCacheProvider.Verify(x => x.Put(It.IsAny <string>(), It.IsAny <CachedItemWrapper <string> >(), It.Is <Ttl>(y => y.Timespan == _defaultCacheDuration)), Times.Never);
        }
        public ActionResult BannerCreate(bannerModel model)
        {
            ViewData["BannerPlaceCodeModel1"] = null;
            ViewBag.ImagePath = ImagePath;
            var opera = string.Empty;

            if (model.IdentityStatus == (int)EIdentityStatus.AppFloor)
            {
                ViewData["BannerPlaceCodeModel1"] = con.GetBannerProducPlaceCodeNameList(ACultureHelper.GetLanguageID, 0, model.IdentityStatus);
            }
            if (ModelState.IsValid)
            {
                ResultModel resultModel = new ResultModel();

                if (model.ProductId > 0)
                {
                    ProductModel modelp = GetBannerProductByProductId(model.ProductId);
                    if (modelp == null)
                    {
                        resultModel.Messages = new List <string>()
                        {
                            "Invalid product ID"
                        };
                        return(Json(resultModel, JsonRequestBehavior.AllowGet));
                    }
                }

                if (model.bannerId != 0)
                {
                    model.UpdateBy       = UserInfo.CurrentUserName;
                    model.UpdateDT       = DateTime.Now;
                    resultModel.Messages = new List <string>()
                    {
                        this._bannerService.UpdateBanner(model).Data > 0 ? "Modify success" : "Modify failed"
                    };
                    opera = string.Format("修改APP首页楼层banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "广告管理--APP 首页楼层banner-修改");
                }
                else
                {
                    model.bannerId       = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.CreateBy       = UserInfo.CurrentUserName;
                    model.CreateDT       = DateTime.Now;
                    model.UpdateBy       = UserInfo.CurrentUserName;
                    model.UpdateDT       = DateTime.Now;
                    model.Sorts          = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    resultModel.Messages = new List <string>()
                    {
                        this._bannerService.AddBanner(model).Data != 0 ? "Add success" : "Add failed"
                    };
                    opera = string.Format("添加APP 首页楼层banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "APP--APP首页楼层banner-添加");
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            return(PartialView(model));
        }
 public ActionResult Create(SalesProductModel model)
 {
     if (ModelState.IsValid)
     {
         var userName    = UserInfo.CurrentUserName;
         var resultModel = new ResultModel();
         if (model.SalesProductId != 0)
         {
             model.UpdateBy = userName;
             model.UpdateDT = DateTime.Now;
             var resultUp = _salesProductService.Update(model);
             if (resultUp.IsValid)
             {
                 resultModel.IsValid  = true;
                 resultModel.Messages = new List <string> {
                     "Change promotion item success"
                 };
             }
             else
             {
                 resultModel.IsValid  = false;
                 resultModel.Messages = new List <string> {
                     resultUp.Messages[0]
                 };
             }
             var opera = string.Format("修改广告促销商品参数:SalesProductId={0},操作结果:{1}", model.SalesProductId, resultModel.IsValid ? "成功" : "失败");
             LogPackage.InserAC_OperateLog(opera, "广告管理--首页促销商品");
         }
         else
         {
             model.SalesProductId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
             model.CreateBy       = userName;
             model.CreateDT       = DateTime.Now;
             model.UpdateBy       = userName;
             model.UpdateDT       = DateTime.Now;
             model.Sorts          = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
             var result = _salesProductService.Add(model);
             if (result.IsValid)
             {
                 resultModel.IsValid  = true;
                 resultModel.Messages = new List <string> {
                     "Add promotion item success"
                 };
             }
             else
             {
                 resultModel.IsValid  = false;
                 resultModel.Messages = new List <string> {
                     result.Messages[0]
                 };
             }
         }
         return(Json(resultModel, JsonRequestBehavior.AllowGet));
     }
     return(PartialView(model));
 }
Beispiel #16
0
        /// <summary>
        /// 通过语言Id查询新闻类型
        /// </summary>
        /// <param name="languageID">语言ID</param>
        /// <returns></returns>
        /// <remarks>added by jimmmy,2015-8-27</remarks>
        public ResultModel GetBD_NewsTypelang(int languageID)
        {
            var result = new ResultModel()
            {
                Data = base._database.Db.BD_NewsTypelang.FindAll(base._database.Db.BD_NewsTypelang.LanguageID == languageID)
            };

            MemCacheFactory.GetCurrentMemCache().AddCache("GetBD_NewsTypelang" + languageID, result.Data, 60);
            return(result);
        }
        /// <summary>
        /// 生成验证码(依赖Couchbase 缓存中间键,和ValidCode 配套使用)
        /// </summary>
        /// <param name="cacheKey">缓存依赖键</param>
        /// <param name="length">验证码长度,默认为4</param>
        public static void GenerateVerifyCode(string cacheKey, int length = 4)
        {
            string code = VerifyCodeUtil.CreateValidateCode(length);

            MemCacheFactory.GetCurrentMemCache().AddCache(cacheKey, code);
            byte[] bytes = CreateValidateGraphic(code);
            System.Drawing.Image image = System.Drawing.Image.FromStream(new MemoryStream(bytes));
            image.Save(HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            HttpContext.Current.Response.End();
        }
Beispiel #18
0
        public ActionResult Add(NewInfoModel model)
        {
            var opera = string.Empty;

            if (ModelState.IsValid)
            {
                ResultModel resultModel = new ResultModel();
                if (model.NewInfoId != 0)
                {
                    model.UpdateBy       = UserInfo.CurrentUserName;//asuser.UserName;
                    model.UpdateDT       = DateTime.Now;
                    resultModel          = this._newInfoService.UpdateNewInfos(model);
                    resultModel.Messages = new List <string>()
                    {
                        resultModel.Data > 0 ? "Modify success" : "Modify failed"
                    };
                    opera = string.Format("修改新闻:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "企业信息--新闻信息-修改");
                }
                else
                {
                    model.NewInfoId   = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.CreateBy    = UserInfo.CurrentUserName;
                    model.CreateDT    = DateTime.Now;
                    model.UpdateBy    = UserInfo.CurrentUserName;
                    model.UpdateDT    = DateTime.Now;
                    model.IsRecommend = 0;


                    if (model.NewImage != null && model.NewImage.Trim() == ImagePath.Trim())
                    {
                        model.NewImage = null;//前台会根据空值,加载默认图片
                    }
                    resultModel          = this._newInfoService.AddNewInfo(model);
                    resultModel.Messages = new List <string>()
                    {
                        resultModel.Data != 0 ? "Add success" : "Add failed"
                    };

                    opera = string.Format("添加新闻:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages);
                    LogPackage.InserAC_OperateLog(opera, "企业信息--新闻信息-添加");
                }
                if (resultModel.IsValid)
                {
                    Response.Redirect("/NewInfo/Index");
                }
                else
                {
                    ViewBag.Messages = resultModel.Messages;
                    return(View(model));
                }
                //return Json(resultModel, JsonRequestBehavior.AllowGet);
            }
            return(View(model));
        }
 public ResultModel Delete(List <long> ids)
 {
     MemCacheFactory.GetCurrentMemCache().ClearCache("languageWeb");//刘宏文加
     return(new ResultModel
     {
         Data = this._database.RunQuery(db =>
                                        db.MultiLanguage.Delete(
                                            ID: ids.ToArray()
                                            )
                                        )
     });
 }
        /// <summary>更新当前用户的数据库购物车.</summary>
        /// <remarks></remarks>
        /// <author>Yun 2015-04-19 10:16:35</author>
        /// <param name="lstGoodsInfoNew">The LST goods information new.</param>
        /// <returns>Boolean.</returns>
        public Boolean updateCartInDb(List <ShoppingCartModel> lstGoodsInfoNew, string userid = null)
        {
            lstGoodsInfoNew = lstGoodsInfoNew.Distinct(new GoodsInfoEqualityComparer()).ToList();
            //YH_User u = _database.Db.YH_User.FindByUserID(userid);
            var Index  = 0;
            var result = new ResultModel();

            foreach (var newGood in lstGoodsInfoNew)
            {
                using (var transaction = _database.Db.BeginTransaction())
                {
                    var resultq = new ResultModel
                    {
                        Data =
                            _database.Db.ShoppingCart.All()
                            .Select(_database.Db.ShoppingCart.ShoppingCartId)
                            .Where(_database.Db.ShoppingCart.ProductID == newGood.ProductID && _database.Db.ShoppingCart.SKU_ProducId == newGood.SKU_ProducId && _database.Db.ShoppingCart.UserID == userid)
                            .ToList <ShoppingCartModel>()
                    };

                    var id = resultq.Data.Count > 0 ? resultq.Data[0].ShoppingCartId : null;

                    if (id != null)
                    {
                        // 更新
                        dynamic updateRecord = new SimpleRecord();
                        updateRecord.ShoppingCartId = id;
                        updateRecord.ProductID      = newGood.ProductID;
                        updateRecord.SKU_ProducId   = newGood.SKU_ProducId;
                        updateRecord.UserID         = userid;
                        updateRecord.Quantity       = newGood.Quantity;
                        updateRecord.IsCheck        = newGood.IsCheck;
                        transaction.ShoppingCart.UpdateByShoppingCartId(updateRecord);
                    }
                    else
                    {
                        //添加
                        dynamic insertRecord = new SimpleRecord();
                        insertRecord.ShoppingCartId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                        insertRecord.ProductID      = newGood.ProductID;
                        insertRecord.SKU_ProducId   = newGood.SKU_ProducId;
                        insertRecord.UserID         = userid;
                        insertRecord.Quantity       = newGood.Quantity;
                        insertRecord.CartDate       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        insertRecord.IsCheck        = newGood.IsCheck;
                        transaction.ShoppingCart.Insert(insertRecord);
                    }
                    transaction.Commit();
                }
            }
            return(result.IsValid);
        }
Beispiel #21
0
        /// <summary>
        /// 订单处理
        /// </summary>
        /// <param name="paymentOrderId">支付单号</param>
        private static void OrderHandler(long paymentOrderId)
        {
            ResultModel result = null;

            try
            {
                AddOrderInfoView addOrderInfoView =
                    MemCacheFactory.GetCurrentMemCache().GetCache <AddOrderInfoView>("ZF" + paymentOrderId);
                if (addOrderInfoView == null)
                {
                    _logger.Error(typeof(OrderMQ), string.Format("未找到支付编号【{0}】的订单信息", paymentOrderId));
                    return;
                }

                switch ((OrderEnums.PurchaseType)addOrderInfoView.PurchaseType)
                {
                case OrderEnums.PurchaseType.Normal:
                default:
                    result = _orderService.GenerateNormalOrder(addOrderInfoView);
                    break;

                case OrderEnums.PurchaseType.Outright:
                    result = _orderService.GenerateOutrightOrder(addOrderInfoView);
                    break;
                }

                //订单处理成功
                if (result.IsValid && result.Status == (int)OrderEnums.GenerateOrderFailType.Success)
                {
                    _logger.Error(typeof(OrderMQ), string.Format("支付编号【{0}】的订单已经成功处理", paymentOrderId));
                }
                else
                {
                    _logger.Error(typeof(OrderMQ),
                                  string.Format("支付编号【{0}】的订单失败:{1}", paymentOrderId,
                                                EnumDescription.GetFieldText((OrderEnums.GenerateOrderFailType)result.Status)));
                }
            }
            catch (Exception ex)
            {
                result = new ResultModel()
                {
                    Status = (int)OrderEnums.GenerateOrderFailType.Fail,
                };
                _logger.Error(typeof(OrderMQ), string.Format("支付编号【{0}】的订单处理异常:{1}", paymentOrderId, ex.Message));
            }
            finally
            {
                bool flag = MemCacheFactory.GetCurrentMemCache().AddCache("DDJG" + paymentOrderId, result, 24 * 60);
                MemCacheFactory.GetCurrentMemCache().ClearCache("ZF" + paymentOrderId);
            }
        }
Beispiel #22
0
        /// <summary>
        /// 更新角色
        /// </summary>
        /// <param name="model">角色模型</param>
        /// <returns>是否修改成功</returns>
        public ResultModel Update(AC_RoleModel model)
        {
            var result = new ResultModel
            {
                //base._database.Db.AC_Role.UpdateByRoleID(model);
                Data = base._database.Db.AC_Role.UpdateByRoleID(RoleID: model.RoleID, RoleName: model.RoleName, RoleModuleValue: model.RoleModuleValue, RoleFuctionValue: model.RoleFuctionValue, UpdateUser: model.UpdateUser, UpdateDt: model.UpdateDt, RoleDescription: model.RoleDescription)
            };

            //_db.Users.UpdateById(Id: 1, Name: "Steve", Age: 50);
            MemCacheFactory.GetCurrentMemCache().ClearCache("ModuleMenuList" + model.RoleID.ToString());
            MemCacheFactory.GetCurrentMemCache().ClearCache("FunctionList" + model.RoleID.ToString());
            return(result);
        }
Beispiel #23
0
        /// <summary>
        /// 添加收藏
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="productId">商品ID</param>
        /// <returns></returns>
        /// <remarks>added by jimmy,2015-8-7</remarks>
        public ResultModel AddFavorites(long userId, long productId, out long favoritesID)
        {
            FavoritesModel model = new FavoritesModel();

            model.UserID        = userId;
            model.ProductId     = productId;
            model.FavoritesDate = DateTime.Now;
            model.FavoritesID   = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
            var result = Add(model);

            favoritesID = !result.IsValid ? result.Data : model.FavoritesID;
            return(result);
        }
Beispiel #24
0
        public void FloorCategory_Add_Test()
        {
            var resultModel = this._floorCategoryService.Add(new FloorCategoryModel()
            {
                Place           = MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                DCategoryId     = 973840518,
                CategoryId      = 973840522,
                FloorCategoryId = MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                AddUsers        = "admin",
                AddTime         = DateTime.Now
            });

            Assert.IsTrue(resultModel.IsValid);
        }
        public void ProductImage_Add_Test()
        {
            var resultModel = this._productImageService.Add(new ProductImageModel()
            {
                ProductImageId = MemCacheFactory.GetCurrentMemCache().Increment("commonId"),
                ProductName    = "小人妖",
                ImageUrl       = "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=763725892,311696505&fm=58",
                CreateBy       = "admin",
                CreateDT       = DateTime.Now,
                UpdateDT       = DateTime.Now,
                UpdateBy       = "admin"
            });

            Assert.IsTrue(resultModel.IsValid);
        }
Beispiel #26
0
        /// <summary>
        /// 添加系统操作日记
        /// </summary>
        /// <param name="OperateContent">操作内容</param>
        /// <param name="Remark">操作说明</param>
        /// <returns></returns>
        public static ResultModel InserAC_OperateLog(string OperateContent, string Remark)
        {
            var resultModel = _ac_OperateLogService.AddAC_OperateLog(new AC_OperateLogModel()
            {
                OperateID      = MemCacheFactory.GetCurrentMemCache().Increment("logId"),
                UserID         = UserInfo.CurrentUserID,
                OperateName    = UserInfo.CurrentUserName,
                IP             = ToolUtil.GetRealIP(),
                OperateContent = OperateContent,
                Remark         = Remark,
                OperateTime    = DateTime.Now
            });

            return(resultModel);
        }
        public ActionResult Create(FloorCategoryModel model)
        {
            var admin = UserInfo.CurrentUserName;

            if (ModelState.IsValid)
            {
                var resultModel = new ResultModel();
                if (model.FloorCategoryId != 0)
                {
                    var result = _floorCategoryService.Update(model);
                    resultModel.Messages = new List <string>
                    {
                        result.Data > 0 ? "Modified floor display classification success" : "Modified floor display classification failure"
                    };
                    string opera = string.Format("修改楼层显示分类:{0},操作结果:{1}", JsonConverts.ToJson(model), result.IsValid ? "成功" : "失败");
                    LogPackage.InserAC_OperateLog(opera, "广告管理--楼层显示分类");
                }
                else
                {
                    model.FloorCategoryId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.AddUsers        = admin;
                    model.AddTime         = DateTime.Now;
                    model.Place           = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    var result = _floorCategoryService.Add(model);
                    if (result.IsValid)
                    {
                        resultModel.IsValid  = true;
                        resultModel.Messages = new List <string> {
                            "Add category display success"
                        };
                    }
                    else
                    {
                        resultModel.IsValid  = false;
                        resultModel.Messages = new List <string> {
                            result.Messages[0]
                        };
                    }
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            else
            {
                DrowFirstList(null);
                GetCategory(model.DCategoryId);
            }
            return(PartialView(model));
        }
        /// <summary>
        /// 取多语言库(刘宏文)
        /// </summary>
        /// <returns></returns>
        public static List <MultiLanguageModel> GetLanguageWebCacheAll()
        {
            var tb = _database.Db.MultiLanguage;
            List <MultiLanguageModel> languageList = new List <MultiLanguageModel>();
            string key = "languageWeb";

            languageList = MemCacheFactory.GetCurrentMemCache().GetCache <List <MultiLanguageModel> >(key);
            if (languageList == null || languageList.Count == 0)
            {
                languageList = tb.FindAll(tb.DataType == 1).select(tb.LangKey, tb.NameTH, tb.NameEng, tb.NameChs, tb.NameHK).ToList <MultiLanguageModel>();
                MemCacheFactory.GetCurrentMemCache().AddCache(key, languageList, 60 * 24);
                // MemCacheFactory.GetCurrentMemCache().ClearCache("languageWeb");
            }

            return(languageList);
        }
        /// <summary>
        ///     根据父ID获取商品分类
        ///     zhoub 20150708
        /// </summary>
        /// <param name="languageId">语言ID</param>
        /// <param name="parentId">父ID</param>
        /// <returns></returns>
        /// <remarks>modified by jimmy,2015-8-13</remarks>
        public List <CategoryModel> GetCategoriesByParentId(int languageId, int parentId)
        {
            string key = "GetCategoriesByParentId" + parentId;
            List <CategoryModel> list = this._database.Db.Category.All()
                                        .LeftJoin(this._database.Db.Category_Lang)
                                        .On(this._database.Db.Category.CategoryId == this._database.Db.Category_Lang.CategoryId)
                                        .Where(this._database.Db.Category.parentId == parentId &&
                                               this._database.Db.Category_Lang.LanguageID == languageId &&
                                               this._database.Db.Category.AuditState == 1)
                                        .Select(this._database.Db.Category.CategoryId, this._database.Db.Category_Lang.CategoryName)
                                        .OrderByPlace()
                                        .ToList <CategoryModel>();

            MemCacheFactory.GetCurrentMemCache().AddCache(key, list, 2);
            return(list);
        }
Beispiel #30
0
        public async Task RefreshData()
        {
            _mockableDateTime.Setup(x => x.UtcNow).Returns(new DateTimeOffset(2020, 05, 17, 20, 00, 00, 00, new TimeSpan(0, 0, 0)));

            MemCacheFactory <string> memCacheFactory = new MemCacheFactory <string>(_pollySyncCacheProvider.Object, _mockableDateTime.Object, _logger.Object);
            IMemDistCache <string>   memCache        = memCacheFactory.GetCache(_defaultCacheDuration, ResetTimeFactory.OnHour);

            string result = await memCache.RefreshDataAsync(_dataGetterDelegate1, _key, CancellationToken.None);

            Assert.AreEqual("dataFromBackendGet", result);

            Assert.AreEqual(1, _numberOfTimesDataGetterDelegate1Called);

            DateTimeOffset whenDataWillNotBeFresh = new DateTimeOffset(2020, 05, 17, 21, 00, 00, 00, new TimeSpan(0, 0, 0));

            _pollySyncCacheProvider.Verify(x => x.Put(It.Is <string>(y => y == _key), It.Is <CachedItemWrapper <string> >(y => y.Content == "dataFromBackendGet" && y.IsFreshUntil == whenDataWillNotBeFresh), It.Is <Ttl>(y => y.Timespan == _defaultCacheDuration)), Times.Once);
        }