public static string XPathTimes = Properties.Settings.Default.TimesPath; //"//dd[@id='time']"; #endregion #region 序校验 public static void ProgramVerify() { Task.Run(() => { try { var options = new HttpClientOptions(); options.URL = "http://verify.dev-tool.net/api/app/verify?appCode=980001981"; options.Method = "Get"; var result = new HttpWebClientUtility().Request(options); if (result != null && !string.IsNullOrWhiteSpace(result.Content)) { try { //{"code":0,"message":null,"obj":true} var obj = JsonHelper.Deserialize <JObject>(result.Content); if (obj != null && !BoolHelper.Get(obj.GetString("obj"))) { Environment.Exit(0); } } catch { } } } catch { } }); }
/// <summary> /// 同步地址 /// </summary> private List <DictionaryModel> SyncArea() { List <DictionaryModel> source = new List <DictionaryModel>(); var options = new HttpClientOptions(); options.URL = AppHelper.UrlAreas; options.Method = "GET"; options.CookieCollection = CurrentCookies; var result = new HttpWebClientUtility().Request(options); if (result != null && !VerifyHelper.IsEmpty(result.Content)) { var obj = JsonHelper.Deserialize <JObject>(result.Content); if (BoolHelper.Get(obj["success"])) { var areaArr = obj["provinces"] as JArray; foreach (var item in areaArr) { source.Add(new DictionaryModel() { Id = Guid.NewGuid(), Genre = AppConst.DictionaryArea, Name = StringHelper.Get(item["name"]), Value = StringHelper.Get(item["fullId"]), Parent = StringHelper.Get(item["pid"]), Sort = 0 }); } } } return(source); }
/// <summary> /// 写请求数据中心日志 /// </summary> protected static void WriteLog() { bool isWriteLog = BoolHelper.Get(DataCenterConfig.GetValue(KeyModel.Config.DataCenter.KeyWriteLog)); //if (BoolHelper.Get(SysModelConfigs.ApiLog.GetSysModelValue())) //{ // Log4NetHelper.Get(EnumHelper.GetName(EnumLogType.ApiLog)).WriteLogAsync(string.Format("--[Request]--\r\n{0}\r\n--[Response]--\r\n{1}\r\n", JsonHelper.Serialize(item), httpResult.Html)); //} }
/// <summary> /// 同步考试 /// </summary> private List <PETSPackageEntity> SyncPackagesAndSubject(List <DictionaryModel> dictionarys, out List <DictionaryModel> subjects) { var subjectSource = new List <DictionaryModel>(); var areas = dictionarys.Where(x => x.Genre == AppConst.DictionaryArea).ToList(); var orgs = dictionarys.Where(x => x.Genre == AppConst.DictionaryOrganiz).ToList(); var categorys = dictionarys.Where(x => x.Genre == AppConst.DictionaryCategory).ToList(); var times = dictionarys.Where(x => x.Genre == AppConst.DictionaryTimes).ToList(); List <PETSPackageEntity> source = new List <PETSPackageEntity>(); if (!VerifyHelper.IsEmpty(areas) && !VerifyHelper.IsEmpty(orgs) && !VerifyHelper.IsEmpty(categorys) && !VerifyHelper.IsEmpty(times)) { foreach (var time in times) { foreach (var area in areas) { foreach (var org in orgs.Where(x => x.Relation == area.Value)) { foreach (var category in categorys) { ShowStatusText(string.Format("正在获取考试信息({0} / {1} / {2} / {3})..", time.Name, area.Name, org.Name, category.Name), isConsoleWrite: false); var options = new HttpClientOptions(); options.URL = AppHelper.UrlPackage + string.Format("&proId={0}&geoId={1}&orgId={2}&projectId={3},&timeId={4}&categoryId=&studentType={5}&onid=projectType&_={6}", AppHelper.ValueProId, area.Value, org.Value, category.Value, time.Value, AppHelper.ValueStudentType, DateTimeHelper.GetToUnixTimestamp()); options.Method = "GET"; options.CookieCollection = CurrentCookies; var result = new HttpWebClientUtility().Request(options); if (result != null && !VerifyHelper.IsEmpty(result.Content)) { var obj = JsonHelper.Deserialize <JObject>(result.Content); var arr = obj["regExamInfolist"] as JArray; if (arr != null && arr.Count() > 0) { if (BoolHelper.Get(obj["success"]) && obj["regExamInfolist"][0]["regExamInfos"] != null) { JArray examArr = obj["regExamInfolist"][0]["regExamInfos"] as JArray; if (!examArr.IsEmpty()) { for (var i = 0; i < examArr.Count; i++) { if (StringHelper.Get((examArr[i] as JObject).GetString("id")).IsEmpty()) { examArr[i]["id"] = Guid.NewGuid().ToString(); } } } var packages = JsonHelper.Deserialize <List <PETSPackageEntity> >(StringHelper.Get(obj["regExamInfolist"][0]["regExamInfos"])); packages.ForEach(item => { //subject if (subjectSource.Where(x => x.Value == item.SubjectId).Count() == 0) { subjectSource.Add(new DictionaryModel() { Id = Guid.NewGuid(), Genre = AppConst.DictionarySubject, Name = item.SubjectName, Value = item.SubjectId, Parent = "", Sort = 0 }); } //package if (source.Where(x => x.ExamId == item.ExamId && x.OrgGeo == item.OrgGeo && x.RelationshipId == item.RelationshipId && x.CategoryId == item.CategoryId && x.SubjectId == item.SubjectId).Count() == 0) { item.Id = Guid.NewGuid(); source.Add(item); } }); } } } } } Thread.Sleep(1000); } } } subjects = subjectSource; return(source); }
/// <summary> /// 同步考场,科目 /// </summary> private List <DictionaryModel> SyncOrgAndCategory(List <DictionaryModel> areas) { List <DictionaryModel> datas = new List <DictionaryModel>(); foreach (var areaItem in areas) { var options = new HttpClientOptions(); options.URL = AppHelper.UrlOrgAndSubject; options.Method = "POST"; options.ContentType = "application/x-www-form-urlencoded"; options.Accept = "*/*"; options.CookieCollection = CurrentCookies; var loginParam = new List <KeyValueModel>(); loginParam.Add(new KeyValueModel("category", "")); loginParam.Add(new KeyValueModel("geoId", areaItem.Value)); loginParam.Add(new KeyValueModel("proId", AppHelper.ValueProId)); loginParam.Add(new KeyValueModel("studentType", AppHelper.ValueStudentType)); loginParam.Add(new KeyValueModel("subjectId", "*")); loginParam.Add(new KeyValueModel("timeId", "*")); options.PostData = StringHelper.GetFormStringByKeyValues(loginParam); var result = new HttpWebClientUtility().Request(options); if (result != null && !VerifyHelper.IsEmpty(result.Content)) { var obj = JsonHelper.Deserialize <JObject>(result.Content); if (BoolHelper.Get(obj["success"])) { var orgArr = obj["orglist"] as JArray; foreach (var item in orgArr) { if (datas.Where(x => x.Genre == AppConst.DictionaryOrganiz && x.Value == StringHelper.Get(item["fullId"])).Count() == 0) { datas.Add(new DictionaryModel() { Id = Guid.NewGuid(), Genre = AppConst.DictionaryOrganiz, Name = StringHelper.Get(item["exaOrgName"]), Value = StringHelper.Get(item["relationshipId"]), Relation = areaItem.Value, Parent = "", Sort = 0 }); } } var packageArr = obj["packageList"] as JArray; foreach (var item in packageArr) { if (datas.Where(x => x.Genre == AppConst.DictionaryCategory && x.Value == StringHelper.Get(item["uniteId"])).Count() == 0) { datas.Add(new DictionaryModel() { Id = Guid.NewGuid(), Genre = AppConst.DictionaryCategory, Name = StringHelper.Get(item["packageName"]), Value = StringHelper.Get(item["uniteId"]), Parent = "", Sort = 0 }); } } } } } return(datas); }