static void clean(aboContext db, string identity, businessType bbtype, DateTime dsubmit) { var busi = db.Business.FirstOrDefault(b => b.Identity == identity && b.Businesstype == (short)bbtype && b.Integrated == true && b.Exporttime == dsubmit); if (busi != null) { db.Businesshis.Add(new Businesshis { Identity = busi.Identity, Businesstype = busi.Businesstype, Time = DateTime.Now, }); db.Business.Remove(busi); var pics = db.Businesspic.Where(a => a.Identity == identity && a.Businesstype == (int)bbtype); foreach (var pic in pics) { db.Businesspichis.Add(new Businesspichis { Identity = pic.Identity, Time = DateTime.Now, Businesstype = (short)pic.Businesstype, Pictype = pic.Pictype }); db.Businesspic.Remove(pic); } } db.SaveChanges(); }
/// <summary> /// 获取某业务类型下所有的下拉框 /// </summary> /// <param name="type"></param> /// <returns></returns> public static DataView getEnumDisplayNameList(businessType type) { object businessType = WebCache.Get("FileCache-businessType"); if (businessType == null) { #region 初始化枚举数据 DataTable dtData = new DataTable(); dtData.Columns.Add("type", typeof(string)); dtData.Columns.Add("name", typeof(string)); dtData.Columns.Add("value", typeof(int)); dtData.Rows.Add(new object[] { "productType", 0, "实体商品" }); dtData.Rows.Add(new object[] { "productType", 1, "卡密商品" }); dtData.Rows.Add(new object[] { "productType", 2, "游戏商品" }); dtData.Rows.Add(new object[] { "productStatus", 0, "正常" }); dtData.Rows.Add(new object[] { "productStatus", 1, "下架" }); WebCache.Max("FileCache-businessType", dtData, new CacheDependency("businessType")); #endregion } DataTable dataTable = businessType as DataTable; DataView dvResult = new DataView(dataTable, string.Format("type='{0}' "), type.ToString() , DataViewRowState.CurrentRows); return(dvResult); }
private static bool checkSignpic(businessType bt, string id, string home) { var picp = string.Format("{2}/server/pictures/{0}/{1}", id, bt.ToString(), home); if (!Directory.Exists(picp)) { return(false); } var pp = new DirectoryInfo(picp).GetFiles(); foreach (var ff in pp) { if (ff.Name.Contains(picType.declaration_sign.ToString())) { return(true); } } return(false); }
private bool savePic(string picstr, picType picType, string identity, businessType btype) { try { var fpath = Path.Combine(_picpath, identity); if (!Directory.Exists(fpath)) { Directory.CreateDirectory(fpath); } var fname = Path.Combine(fpath, identity, btype.ToString(), picType + ".jpg"); var index = picstr.IndexOf("base64,"); System.IO.File.WriteAllBytes(fname, Convert.FromBase64String(picstr.Substring(index + 7))); } catch (Exception ex) { _log.LogInformation("savePic error: {0}", ex); return(false); } return(true); }
public async Task <StatisticsResponse> NewSum(businessType bt, string start, string end) { try { var startd = DateTime.Now; if (string.IsNullOrEmpty(start) || !DateTime.TryParse(start, out startd)) { return(new StatisticsResponse { status = (int)sixerrors.invalidstarttime }); } var endd = DateTime.Now; if (string.IsNullOrEmpty(end) || !DateTime.TryParse(end, out endd)) { return(new StatisticsResponse { status = (int)sixerrors.invalidendtime }); } if (bt == businessType.unknown) { return(new StatisticsResponse { status = (int)sixerrors.businesstypeerror }); } var today = DateTime.Now; var yesterday = today.AddDays(-1); var todaydb = _db1.COUNT.FirstOrDefault(c => c.TIME.CompareTo(today) <= 0 && c.TIME.CompareTo(yesterday) > 0); Log.InfoFormat("today={0},yesteday={1}", 11, 22); if (todaydb == null) { todaydb = new COUNT { PAGEVIEW = 0, APPLICATION = 0, PAGEVIEWDAY = 0, APPLICATIONDAY = 0, STARTLEARNINGVOLUME = 0, STARTLEARNINGVOLUMETODAY = 0, KAIFAQU = 0, ZHIFUQU = 0, FUSHANQU = 0, MUPINGQU = 0, LAISHANQU = 0, LONGKOU = 0, ZHAOYUAN = 0, QIXIA = 0, LAIZHOU = 0, CHANGDAO = 0, HAIYANG = 0, LAIYANG = 0, PENGLAI = 0, OTHER = 0, GAOXINQU = 0, }; } var startoftoday = DateTime.Parse(string.Format("{0}-{1}-{2}", today.Year, today.Month, today.Day)); var todaynum = new statistics { PAGEVIEW = todaydb.PAGEVIEWDAY, APPLICATION = todaydb.APPLICATIONDAY, KAIFAQU = todaydb.KAIFAQU, ZHIFUQU = todaydb.ZHIFUQU, FUSHANQU = todaydb.FUSHANQU, MUPINGQU = todaydb.MUPINGQU, LAISHANQU = todaydb.LAISHANQU, LONGKOU = todaydb.LONGKOU, ZHAOYUAN = todaydb.ZHAOYUAN, QIXIA = todaydb.QIXIA, LAIZHOU = todaydb.LAIZHOU, CHANGDAO = todaydb.CHANGDAO, HAIYANG = todaydb.HAIYANG, LAIYANG = todaydb.LAIYANG, PENGLAI = todaydb.PENGLAI, InspectedVolume = _db1.HISTORY.Where(c => c.PROCESSED == "1" && c.OVERTIME.CompareTo(startoftoday) >= 0).Count(), LearningVolume = todaydb.STARTLEARNINGVOLUMETODAY, OTHER = todaydb.OTHER, GAOXINQU = todaydb.GAOXINQU, }; // var totaldb = _db1.COUNT.Sum(c => c.KAIFAQU); var totalnum = new statistics { PAGEVIEW = todaydb.PAGEVIEW, APPLICATION = todaydb.APPLICATION, KAIFAQU = _db1.COUNT.Sum(c => c.KAIFAQU), ZHIFUQU = _db1.COUNT.Sum(c => c.ZHIFUQU), FUSHANQU = _db1.COUNT.Sum(c => c.FUSHANQU), MUPINGQU = _db1.COUNT.Sum(c => c.MUPINGQU), LAISHANQU = _db1.COUNT.Sum(c => c.LAISHANQU), LONGKOU = _db1.COUNT.Sum(c => c.LONGKOU), ZHAOYUAN = _db1.COUNT.Sum(c => c.ZHAOYUAN), QIXIA = _db1.COUNT.Sum(c => c.QIXIA), LAIZHOU = _db1.COUNT.Sum(c => c.LAIZHOU), CHANGDAO = _db1.COUNT.Sum(c => c.CHANGDAO), HAIYANG = _db1.COUNT.Sum(c => c.HAIYANG), LAIYANG = _db1.COUNT.Sum(c => c.LAIYANG), PENGLAI = _db1.COUNT.Sum(c => c.PENGLAI), InspectedVolume = _db1.HISTORY.Where(c => c.PROCESSED == "1").Count(), LearningVolume = todaydb.STARTLEARNINGVOLUME, OTHER = _db1.COUNT.Sum(c => c.OTHER), GAOXINQU = _db1.COUNT.Sum(c => c.GAOXINQU), }; return(new StatisticsResponse { status = 0, today = todaynum, total = totalnum }); } catch (Exception ex) { Log.Error("Statistics,", ex); return(new StatisticsResponse { status = (int)sixerrors.processerror }); } }
public loginresponse login(string name, string identify, string phone, businessType businessType) { if (string.IsNullOrEmpty(identify) || identify == "undefined") { return(new loginresponse { status = responseStatus.iderror }); } if (string.IsNullOrEmpty(name) || name == "undefined") { return(new loginresponse { status = responseStatus.nameerror }); } if (string.IsNullOrEmpty(phone) || phone == "undefined") { return(new loginresponse { status = responseStatus.phoneerror }); } if (businessType == businessType.unknown) { return(new loginresponse { status = responseStatus.businesstypeerror }); } //if (!checkbusi(identify, businessType)) //{ // highlevel.LogRequest(name + phone + identify + responseStatus.forbidden, "login", Request.HttpContext.Connection.RemoteIpAddress.ToString(), (short)businessType); // return new loginresponse { status = responseStatus.forbidden }; //} // _log.LogInformation("{3}-{0} from {1}, input is {2}", DateTime.Now, "login", // Request.HttpContext.Connection.RemoteIpAddress.ToString() + HttpContext.Connection.RemoteIpAddress, // identify + name + phone + businessType); var btype = (short)businessType; var picsl = new List <short>(); var token = GetToken(); var response = new loginresponse { status = responseStatus.ok, blacklist = false, businessstatus = businessstatus.unknown, submitted = false, content = "unknown", token = token, okpic = picsl.ToArray() }; try { if (businessType == businessType.overage) { var idl = identify.Length; if (idl == 18)// { var year = int.Parse(identify.Substring(6, 4)); var month = int.Parse(identify.Substring(10, 2)); var day = int.Parse(identify.Substring(12, 2)); var birth = new DateTime(year, month, day); if (birth.AddYears(60) > DateTime.Now) { return new loginresponse { status = responseStatus.forbidden } } ; } else if (idl == 15) { var year = int.Parse(identify.Substring(6, 2)) + 1900; var month = int.Parse(identify.Substring(8, 2)); var day = int.Parse(identify.Substring(10, 2)); var birth = new DateTime(year, month, day); if (birth.AddYears(60) > DateTime.Now) { return new loginresponse { status = responseStatus.forbidden } } ; } } var theuser = _db1.Aouser.FirstOrDefault(i => i.Identity == identify); if (theuser == null) { _db1.Aouser.Add(new Aouser { Identity = identify, Blacklist = false, Phone = phone, Name = name }); _db1.SaveChanges(); } var business = _db1.Business.FirstOrDefault(i => i.Identity == identify && i.Businesstype == (short)businessType); if (business == null) { _db1.Business.Add(new Business { Identity = identify, Businesstype = (short)businessType, Completed = false, Time = DateTime.Now, }); _db1.SaveChanges(); } else { var pics = _db1.Businesspic.Where(c => c.Businesstype == btype && c.Identity == identify && c.Uploaded == true); response.businessstatus = (businessstatus)business.Status; response.finish_time = business.Finishtime; response.wait_time = business.Waittime; response.process_time = business.Processtime; if (!string.IsNullOrEmpty(business.Reason)) { response.content = business.Reason; } if (pics.Count() < global.businesscount[businessType] || response.businessstatus == businessstatus.failure) { foreach (var a in pics) { picsl.Add(a.Pictype); } response.okpic = picsl.ToArray(); if (response.businessstatus == businessstatus.failure) { response.submitted = true; } } else { response.submitted = true; // response.businessstatus = (businessstatus)business.Status; // response.finish_time = business.Finishtime; // response.wait_time = business.Waittime; // response.process_time = business.Processtime; } } if (theuser != null && theuser.Blacklist == true) { response.blacklist = true; } } catch (Exception ex) { _log.LogError("login -- process error:{0}", ex.Message); } try { var redisdb = highlevel.redis.GetDatabase(); redisdb.StringSet(token, JsonConvert.SerializeObject(new idinfo { Identity = identify, businessType = businessType })); redisdb.KeyExpire(token, TimeSpan.FromDays(30)); } catch (Exception ex) { _log.LogError("redis key process error:{0}", ex.Message); } var found = false; foreach (var a in global.tokens) { if (a.idinfo.Identity == identify && a.idinfo.businessType == businessType) { a.Token = token; found = true; break; } } if (!found) { global.tokens.Add(new Ptoken { idinfo = new idinfo { Identity = identify, businessType = businessType }, Token = token }); } try { var he = Request.Host.ToString(); foreach (var a in Request.Headers) { he += "--" + a.Key + "=" + a.Value; } Task.Run(() => highlevel.LogRequest(he + name + phone + identify + JsonConvert.SerializeObject(response), "login", Request.HttpContext.Connection.RemoteIpAddress.ToString(), (short)businessType)); } catch (Exception ex) { _log.LogError("dblog error:", ex); } return(response); }
private bool checkbusi(string identify, businessType businessType) { if (businessType == businessType.changeContact || businessType == businessType.first) { return(true); } try { if (businessType == businessType.overage) { var idl = identify.Length; if (idl == 18)// { var year = int.Parse(identify.Substring(6, 4)); var month = int.Parse(identify.Substring(10, 2)); var day = int.Parse(identify.Substring(12, 2)); var birth = new DateTime(year, month, day); if (birth.AddYears(60) > DateTime.Now) { return(false); } } else if (idl == 15) { var year = int.Parse(identify.Substring(6, 2)) + 1900; var month = int.Parse(identify.Substring(8, 2)); var day = int.Parse(identify.Substring(10, 2)); var birth = new DateTime(year, month, day); if (birth.AddYears(60) > DateTime.Now) { return(false); } } } _log.LogInformation("sendautomsgone,begin" + identify + DateTime.Now); sendautomsgone(identify); _log.LogInformation("sendautomsgone,end" + identify + DateTime.Now); var rpath = "/home/driverbusiness/detachment"; var rfile = Path.Combine(rpath, identify); var source = System.IO.File.ReadAllText(rfile); var ff = new System.IO.FileInfo(rfile).Length; string pattern = @"{""code"":.*}"; var result = string.Empty; Match theMatch = Regex.Match(source, pattern, RegexOptions.Multiline); if (theMatch.Success) { int endindex = theMatch.Length; result = source.Substring(theMatch.Index, endindex); _log.LogInformation("match detach ok" + result); if (result.Length < 60) { return(false); //此人无驾驶证 } var ret = JsonConvert.DeserializeObject <getDrivingLicenseBySfzmhm>(result); if (ret.code == "200" && ret.status == "1" && ret.result[0].ZT == "A") { _log.LogInformation("normal detach ok" + identify); return(true); } } else { //支队同步库出错情况下,暂时丢弃业务逻辑限制 _log.LogInformation(source.Length + "no match" + identify + source + ff); return(true); } } catch (Exception ex) { _log.LogError("checkbusi process error:{0}", ex.Message); return(true); } return(false); }
public loginresponse login(string name, string identify, string phone, businessType businessType) { if (string.IsNullOrEmpty(identify)) { return(new loginresponse { status = responseStatus.iderror }); } if (string.IsNullOrEmpty(name)) { return(new loginresponse { status = responseStatus.nameerror }); } if (string.IsNullOrEmpty(phone)) { return(new loginresponse { status = responseStatus.phoneerror }); } _log.LogInformation("{3}-{0} from {1}, input is {2}", DateTime.Now, "login", Request.HttpContext.Connection.RemoteIpAddress.ToString() + HttpContext.Connection.RemoteIpAddress, identify + name + phone); var theuser = _db1.User.FirstOrDefault(i => i.Identity == identify); if (theuser == null) { return(new loginresponse { status = responseStatus.iderror }); } theuser.Name = name; theuser.Phone = phone; _db1.SaveChanges(); var btype = (short)businessType; var picsl = new List <short>(); // var unbusiness = _db1.Business.FirstOrDefault(c => c.Completed == false && c.Businesstype == btype); // if(_db1.Businesspic.Count(c=>c.Businesstype==(short)businessType&&c.Identity==identify&&c.Uploaded)<global.businesscount[businessType]) // if (unbusiness != null) // { var pics = _db1.Businesspic.Where(c => c.Businesstype == btype && c.Identity == identify && c.Uploaded == true); if (pics.Count() < global.businesscount[businessType]) { foreach (var a in pics) { picsl.Add(a.Pictype); } } // } var token = GetToken(); try { var redisdb = highlevel.redis.GetDatabase(); redisdb.StringSet(token, JsonConvert.SerializeObject(new idinfo { Identity = identify, businessType = businessType })); redisdb.KeyExpire(token, TimeSpan.FromDays(30)); } catch (Exception ex) { _log.LogError("redis key process error:{0}", ex.Message); } var found = false; foreach (var a in tokens) { if (a.idinfo.Identity == identify && a.idinfo.businessType == businessType) { a.Token = token; found = true; break; } } if (!found) { tokens.Add(new Ptoken { idinfo = new idinfo { Identity = identify, businessType = businessType }, Token = token }); } LogRequest(name + phone + identify, "login", Request.HttpContext.Connection.RemoteIpAddress.ToString(), (short)businessType); return(new loginresponse { status = responseStatus.ok, token = token, okpic = picsl.ToArray() }); }
public loginresponse login(string name, string identify, string phone, businessType businessType) { if (string.IsNullOrEmpty(identify) || identify == "undefined") { return(new loginresponse { status = responseStatus.iderror }); } if (string.IsNullOrEmpty(name) || name == "undefined") { return(new loginresponse { status = responseStatus.nameerror }); } if (string.IsNullOrEmpty(phone) || phone == "undefined") { return(new loginresponse { status = responseStatus.phoneerror }); } if (businessType == businessType.unknown) { return(new loginresponse { status = responseStatus.businesstypeerror }); } var btype = (short)businessType; // var picsl = new List<short>(); var token = GetToken(); var photofile = string.Empty; var response = new loginresponse { status = responseStatus.ok, blacklist = false, businessstatus = businessstatus.unknown, submitted = false, content = "unknown", token = token, // okpic = picsl.ToArray() }; var encryptedIdentity = CryptographyHelpers.StudyEncrypt(identify); try { _log.LogWarning("businessType={0},Scrapplace={1}", businessType, 111); var theuser = _db1.Caruser.FirstOrDefault(i => i.Identity == encryptedIdentity); if (theuser == null) { photofile = token; _db1.Caruser.Add(new Caruser { Identity = encryptedIdentity, Blacklist = false, Photofile = token, Phone = phone, Name = name }); _db1.SaveChanges(); } else { photofile = theuser.Photofile; } _log.LogWarning("businessType={0},Scrapplace={1}", businessType, 222); var business = _db1.Carbusiness.FirstOrDefault(i => i.Identity == encryptedIdentity && i.Businesstype == (short)businessType); if (business == null) { _db1.Carbusiness.Add(new Carbusiness { Identity = encryptedIdentity, Businesstype = (short)businessType, Completed = false, Time = DateTime.Now, }); _db1.SaveChanges(); } else { _log.LogWarning("businessType={0},Scrapplace={1}", businessType, business.Scrapplace); var pics = _db1.Carbusinesspic.Where(c => c.Businesstype == btype && c.Identity == encryptedIdentity && c.Uploaded == true); response.businessstatus = (businessstatus)business.Status; response.finish_time = business.Finishtime; response.wait_time = business.Waittime; response.process_time = business.Processtime; if (!string.IsNullOrEmpty(business.Reason)) { response.content = business.Reason; } if (response.businessstatus == businessstatus.failure) { response.submitted = true; } else { if (businessType != businessType.scrap && pics.Count() >= global.businesscount[businessType]) { response.submitted = true; } if (businessType == businessType.scrap && business.Scrapplace != 0) { response.submitted = true; } } } if (theuser != null && theuser.Blacklist == true) { response.blacklist = true; } } catch (Exception ex) { _log.LogError("login -- process error:{0}", ex.Message); } try { var redisdb = highlevel.redis.GetDatabase(); redisdb.StringSet(token, JsonConvert.SerializeObject(new idinfo { Identity = encryptedIdentity, photofile = photofile, businessType = businessType })); redisdb.KeyExpire(token, TimeSpan.FromDays(30)); } catch (Exception ex) { _log.LogError("redis key process error:{0}", ex.Message); } var found = false; foreach (var a in global.tokens) { if (a.idinfo.Identity == encryptedIdentity && a.idinfo.businessType == businessType) { a.Token = token; found = true; break; } } if (!found) { global.tokens.Add(new Ptoken { idinfo = new idinfo { Identity = encryptedIdentity, photofile = photofile, businessType = businessType }, Token = token }); } try { var he = Request.Host.ToString(); foreach (var a in Request.Headers) { he += "--" + a.Key + "=" + a.Value; } Task.Run(() => highlevel.LogRequest(he + name + phone + encryptedIdentity + JsonConvert.SerializeObject(response), "login", Request.HttpContext.Connection.RemoteIpAddress.ToString(), (short)businessType)); } catch (Exception ex) { _log.LogError("dblog error:", ex); } return(response); }
/// <summary> /// 获取某业务类型下id对应的意义(例如,product表下的商品状态status,0返回'正常',1返回'下架') /// </summary> /// <param name="type"></param> /// <param name="typevalue"></param> /// <returns></returns> public static string getEnumDisplayName(businessType type, int typevalue) { string resultStr = ""; switch (type) { #region 商品相关属性 //商品类型 case businessType.productType: switch (typevalue) { case 0: resultStr = "实体商品"; break; case 1: resultStr = "话费商品"; break; case 2: resultStr = "游戏商品"; break; case 3: resultStr = "Q币商品"; break; case 4: resultStr = "账号商品"; break; } break; //商品状态 case businessType.productStatus: switch (typevalue) { case 0: resultStr = "正常"; break; case 1: resultStr = "下架"; break; } break; #endregion #region 微信相关 case businessType.replyType: //匹配回复类型 switch (typevalue) { case 1: resultStr = "关键字回复"; break; case 2: resultStr = "关注时回复"; break; case 3: resultStr = "无匹配回复"; break; } break; case businessType.messageType: //回复内容类型 switch (typevalue) { case 1: resultStr = "文本"; break; case 2: resultStr = "单图文"; break; case 3: resultStr = "多图文"; break; } break; case businessType.yollystatus: switch (typevalue) { case 0: resultStr = "<span style='color:red'>待充值</span>"; break; case 1: resultStr = "已完成"; break; case 2: resultStr = "<span style='color:red'>失 败</span>"; break; } break; //1、话费 2、支付宝 4、Q币 11、城市服务商佣金 12、网吧活动结算 case businessType.yollytype: switch (typevalue) { case 1: resultStr = "话费充值"; break; case 2: resultStr = "支付宝充值"; break; case 3: resultStr = "充值爽乐币"; break; case 4: resultStr = "QQ币充值"; break; case 11: resultStr = "城市服务商佣金"; break; case 12: resultStr = "网吧活动结算"; break; } break; #endregion #region 支付相关 case businessType.pay_type: //匹配回复类型 switch (typevalue) { case 1: resultStr = "微信支付"; break; case 2: resultStr = "app微信支付"; break; } break; #endregion #region 用户相关 case businessType.user_type: //用户来源 switch (typevalue) { case 0: resultStr = "微信关注"; break; case 1: resultStr = "app登录"; break; case 9: resultStr = "百度推广"; break; } break; #endregion } return(resultStr); }