// GET api/menu public IEnumerable <dynamic> Get() { var UserCode = SysHelper.GetUserCode(); var TenantId = SysHelper.GetTenantId(); dynamic result = ZCache.GetCache("MenuData"); if (result == null && !string.IsNullOrEmpty(UserCode) && !string.IsNullOrEmpty(TenantId)) { var postdata = new { AppCode = "EPS", ApiCode = "GetUserMenuData", TenantId = TenantId, UserCode = UserCode, RequestAppCode = "MiniMES" }; result = HttpHelper.PostWebApi(ZConfig.GetConfigString("APIGatewayUrl"), JsonConvert.SerializeObject(postdata), 18000); ZCache.SetCache("MenuData", result); } return(result); }
public ActionResult Logout() { FormsAuth.SingOut(); var result = Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login"); return(result); }
/// <summary> /// 连接串 /// </summary> /// <returns></returns> public ConfigurationOptions Conn() { var options = ConfigurationOptions.Parse(ZConfig.GetConfigString("redispath")); options.SyncTimeout = int.MaxValue; options.AllowAdmin = true; options.Password = ZConfig.GetConfigString("redispwd"); return(options); }
public ActionResult Index() { ViewBag.CnName = "STD MiniMES系统"; ViewBag.EnName = "STD MiniMES System"; var Token = Request["Token"]; if (!string.IsNullOrEmpty(Token)) { string APIGatewayUrl = ZConfig.GetConfigString("APIGatewayUrl"); var data = new { AppCode = "EPS", ApiCode = "PostValidateToken", Token = Token }; var result = HttpHelper.PostWebApi(APIGatewayUrl, JsonConvert.SerializeObject(data), 18000); if (result != null) { if (result.status == true) { var UserInfo = result.UserInfo; //调用框架中的登录机制 var loginer = new LoginerBase { UserId = UserInfo.UserId, UserType = "2", TenantId = UserInfo.TenantId, UserCode = UserInfo.UserCode, UserName = UserInfo.UserName, ShiftId = UserInfo.ShiftId }; var effectiveHours = ZConfig.GetConfigInt("LoginEffectiveHours"); FormsAuth.SignIn(loginer.UserCode, loginer, 60 * effectiveHours); ZCache.SetCache("MenuData", result.MenuData); return(Redirect("Home")); } } //return View("授权Token验证失败!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。"); return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login")); } else { //return View("授权参数错误!单击<a href='" + ZConfig.GetConfigString("GatewayServer") + "'>这里</a>返回登录页面。"); //return View(); return(Redirect(ZConfig.GetConfigString("GatewayServer") + "/Login")); } }
protected override void Seed(EfDbContext context) { try { //context.Set<CityArea>().AddRange(new List<CityArea> { //new CityArea { Name = "厦门", Pinyin = "xiamen", CityId = 0, IsEdit = false, Sort = 1, State = 1, CreateTime = DateTime.Now }, //new CityArea { Name = "深圳", Pinyin = "shenzhen", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }, //new CityArea { Name = "福州", Pinyin = "fuzhou", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }, //new CityArea { Name = "泉州", Pinyin = "quanzhou", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }, //new CityArea { Name = "龙岩", Pinyin = "longyan", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }, //new CityArea { Name = "武汉", Pinyin = "wuhan", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }, //new CityArea { Name = "重庆", Pinyin = "chongqing", CityId = 0, IsEdit = false, Sort = 1, State = 0, CreateTime = DateTime.Now }}); //context.SaveChanges(); //ProductCategory productCategory = new ProductCategory { Name = "其他", CreateTime = DateTime.Now, State = DelStateEnum.正常 }; //context.Set<ProductCategory>().Add(productCategory); //context.SaveChanges(); //context.Set<Product>().Add(new Product { Name = "其他", ProductCategoryId = productCategory.Id, State = DelStateEnum.正常, CreateTime = DateTime.Now }); //context.SaveChanges(); var filePath = ZConfig.GetConfigString("InitSqlFile"); if (string.IsNullOrEmpty(filePath)) throw new Exception("初始化数据文件不能为空!"); if (filePath.StartsWith("~")) { filePath = filePath.Substring(2); filePath = $"{AppDomain.CurrentDomain.BaseDirectory}{filePath}"; } var sql = File.ReadAllText(filePath); context.Database.ExecuteSqlCommand(sql); base.Seed(context); } catch (Exception ex) { NLogger.Error(ex); } }
/// <summary> /// 主键key查找 /// </summary> /// <param name="key">关键字</param> public static List <string> GetByKey(string key) { List <string> result = new List <string>(); try { using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(GetConn.GetInstance().Conn())) { string host = ZConfig.GetConfigString("redispath"); var server = redis.GetServer(host); foreach (var item in server.Keys(pattern: key)) { result.Add(item); } return(result); } } catch (Exception ex) { NLogger.Error(ex.ToString(), "Cache"); return(new List <string>()); } }
/// <summary> /// 添加溢出值 /// </summary> public void AddInventoryOver() { int Stockdate = ZConvert.StrToInt(ZConfig.GetConfigString("Stockdate")); DateTime Time = DateTime.Now; for (int z = 0; z < Stockdate; z++) { int t = z == 0 ? 0 : 1; Time = Time.AddDays(t); var InventoryHistory = InventoryOverHistoryBLL.GetInstance().TableNoTracking().Where(o => o.CreTime == Time.Date).FirstOrDefault(); if (InventoryHistory == null) { // 添加记录 InventoryOverHistory obj = new InventoryOverHistory(); obj.CreTime = Time.Date; InventoryOverHistoryBLL.GetInstance().Add(obj); var store = StoreBll.GetInstance().TableNoTracking().Where(o => o.State == (int)StoreState.线中).ToList(); var ProductCategory = ProductCategoryBll.GetInstance().TableNoTracking().ToList(); var ProductCategoryidlist = ProductCategory.Select(o => o.Id).ToList(); ProductCategoryidlist.Add(0); var Productlist = ProductBll.GetInstance().TableNoTracking().Where(o => ProductCategoryidlist.Contains(o.ProductCategoryId) && o.State == ProductStateEnum.架).ToList(); var Productidlist = Productlist.Select(o => o.Id).ToList(); Productidlist.Add(0); var StockSettinglist = StockSettingBLL.GetInstance().TableNoTracking().Where(o => Productidlist.Contains(o.ProductId)).ToList(); if (store != null && store.Count > 0) { foreach (var itemstore in store) { if (ProductCategory != null && ProductCategory.Count > 0) { foreach (var itemProductCategory in ProductCategory) { #region MyRegion //// //店铺 分类下 当天的总库存 List <StockOutInView> StockOutInViewlist = InventoryBLL.GetInstance().GetStockTotal(itemstore.Id, itemProductCategory.Id, Time); List <Product> ProductList = Productlist.Where(o => o.ProductCategoryId == itemProductCategory.Id).ToList(); if (ProductList != null) { foreach (var item in ProductList) { string sql = " INSERT INTO [InventoryOver] ([StoreId] ,[ProductId] ,[CreTime] "; sql += " ,[Time1] ,[Time2] ,[Time3] ,[Time4] ,[Time5] ,[Time6] ,[Time7] ,[Time8] ,[Time9] ,[Time10] ,[Time11] ,[Time12] ,[Time13] ,[Time14] ,[Time15] "; sql += " ,[Time16] ,[Time17] ,[Time18] ,[Time19] ,[Time20] ,[Time21] ,[Time22] ,[Time23] "; sql += " ,[Time24] ,[Time25] ,[Time26] ,[Time27] ,[Time28] ,[Time29] ,[Time30] ,[Time31] ,[Time32] ,[Time33] "; sql += " ,[Time34] ,[Time35] ,[Time36] ,[Time37] ,[Time38] ,[Time39] ,[Time40] ,[Time41] ,[Time42] ,[Time43] ,[Time44] ,[Time45] ,[Time46] ,[Time47] ,[Time48] "; sql += " ) "; sql += " VALUES "; sql += " (" + itemstore.Id + "," + item.Id + ",'" + Time.Date + "' "; int i = 1; #region 循环 while (i < 49) { //分类下 var EmployeeProductViewModellistitem = new List <StockOutInView>(); #region MyRegion if (i == 1) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time1 != null).ToList(); } else if (i == 2) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time2 != null).ToList(); } else if (i == 3) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time3 != null).ToList(); } else if (i == 4) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time4 != null).ToList(); } else if (i == 5) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time5 != null).ToList(); } else if (i == 6) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time6 != null).ToList(); } else if (i == 7) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time7 != null).ToList(); } else if (i == 8) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time8 != null).ToList(); } else if (i == 9) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time9 != null).ToList(); } else if (i == 10) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time10 != null).ToList(); } else if (i == 11) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time11 != null).ToList(); } else if (i == 12) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time12 != null).ToList(); } else if (i == 13) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time13 != null).ToList(); } else if (i == 14) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time14 != null).ToList(); } else if (i == 15) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time15 != null).ToList(); } else if (i == 16) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time16 != null).ToList(); } else if (i == 17) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time17 != null).ToList(); } else if (i == 18) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time18 != null).ToList(); } else if (i == 19) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time19 != null).ToList(); } else if (i == 20) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time20 != null).ToList(); } else if (i == 21) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time21 != null).ToList(); } else if (i == 22) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time22 != null).ToList(); } else if (i == 23) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time23 != null).ToList(); } else if (i == 24) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time24 != null).ToList(); } else if (i == 25) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time25 != null).ToList(); } else if (i == 26) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time26 != null).ToList(); } else if (i == 27) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time27 != null).ToList(); } else if (i == 28) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time28 != null).ToList(); } else if (i == 29) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time29 != null).ToList(); } else if (i == 30) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time30 != null).ToList(); } else if (i == 31) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time31 != null).ToList(); } else if (i == 32) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time32 != null).ToList(); } else if (i == 33) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time33 != null).ToList(); } else if (i == 34) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time34 != null).ToList(); } else if (i == 35) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time35 != null).ToList(); } else if (i == 36) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time36 != null).ToList(); } else if (i == 37) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time37 != null).ToList(); } else if (i == 38) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time38 != null).ToList(); } else if (i == 39) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time39 != null).ToList(); } else if (i == 40) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time40 != null).ToList(); } else if (i == 41) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time41 != null).ToList(); } else if (i == 42) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time42 != null).ToList(); } else if (i == 43) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time43 != null).ToList(); } else if (i == 44) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time44 != null).ToList(); } else if (i == 45) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time45 != null).ToList(); } else if (i == 46) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time46 != null).ToList(); } else if (i == 47) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time47 != null).ToList(); } else if (i == 48) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time48 != null).ToList(); } #endregion //产品下的总库存 int TotalInventory = EmployeeProductViewModellistitem.Select(o => o.EmployeeId).Distinct().Count(); //百分比计算 var StockSetting = StockSettinglist.Where(o => o.ProductId == item.Id).FirstOrDefault(); if (StockSetting != null) { TotalInventory = ZConvert.StrToInt(TotalInventory * ((StockSetting.OverflowValue - 100) / 100)); } else { TotalInventory = 0; } sql += " ," + TotalInventory + " "; i++; } #endregion sql += " )"; ExecuteSqlCommand(sql, null); } } #endregion } } } } } } }
public static IDbContext Context(string connName) { var setting = ConfigurationManager.ConnectionStrings[connName]; var db = new DbContext().ConnectionString(setting.ConnectionString, Provider(setting.ProviderName)); if (ZConfig.GetConfigString("SqlLog") == "1") { db.OnExecuting(x => { //if (APP.OnDbExecuting != null) APP.OnDbExecuting(x); var sql = x.Command.CommandText; for (int i = x.Command.Parameters.Count - 1; i >= 0; i--) { var item = x.Command.Parameters[i] as IDataParameter; sql = sql.Replace(item.ParameterName, string.Format("'{0}'", item.Value)); } log.Debug(sql); }); } db.OnError(e => { var log = LogManager.GetLogger(connName); var ex = e.Exception as SqlException; if (ex != null) { var error = ""; switch (ex.Number) { case -2: error = "超时时间已到。在操作完成之前超时时间已过或服务器未响应"; break; case 4060: // Invalid Database error = "数据库不可用,请检查系统设置后重试!"; break; case 18456: // Login Failed error = "登陆数据库失败!"; break; case 547: // ForeignKey Violation error = "数据已经被引用,更新失败,请先删除引用数据并重试!"; break; case 2627: // Unique Index/Constriant Violation error = "主键重复,更新失败!"; break; case 2601: // Unique Index/Constriant Violation break; // throw a general DAL Exception } if (!string.IsNullOrEmpty(error)) { throw new Exception(error); } log.Error(ex.Message); } }); return(db); }