public void GetDateStatistics(HttpContext context) { JObject returnobj = new JObject(); JArray jarray = new JArray(); try { int ClassType = Convert.ToInt32(context.Request["classtype"]); int TableColumnID = Convert.ToInt32(context.Request["tablecolumn"]); int TableTypeID = Convert.ToInt32(context.Request["tabletype"]); DateTime BeginDate = new BaseUtils().GetSelectDate(string.IsNullOrEmpty(context.Request["begin"].ToString()) ? DateTime.MinValue : Convert.ToDateTime(context.Request["begin"]), true); DateTime EndDate = new BaseUtils().GetSelectDate(string.IsNullOrEmpty(context.Request["end"].ToString()) ? DateTime.MaxValue : Convert.ToDateTime(context.Request["end"]), false); if (BeginDate > EndDate) { DateTime Temp = BeginDate; BeginDate = EndDate; EndDate = Temp; } if ((EndDate - BeginDate).TotalDays < 15) { using (IFMPDBContext db = new IFMPDBContext()) { List <TableData> TableDataList = db.TableData.Where(t => t.CreateDate >= BeginDate && t.CreateDate <= EndDate && t.TableColumnID == TableColumnID && db.Table.Where(m => m.TableTypeID == TableTypeID && (ClassType == 0 || db.Task.FirstOrDefault(k => k.ID == m.TaskID).ClassType == (ClassTypeEnums)ClassType)).Select(m => m.ID).Contains(t.TableID) ).ToList(); List <User> UserList = db.User.ToList(); List <TaskFlow> TaskFlowList = db.TaskFlow.Where(t => t.ApplyDate >= BeginDate && t.ApplyDate <= EndDate && db.Flow.Where(m => m.IsAudit != true).Select(m => m.ID).Contains(t.ID) ).ToList(); //这个以天为单位统计 while (BeginDate <= EndDate) { JArray SelDataArray = new JArray(); List <TableData> SelTableDataList = TableDataList.Where(t => t.CreateDate >= BeginDate && t.CreateDate <= BeginDate.AddDays(1)).ToList(); if (SelTableDataList.Count > 0) { foreach (TableData SelTableData in SelTableDataList) { JObject SelJObject = new JObject(); SelJObject.Add("Name", UserList.FirstOrDefault(t => t.ID == SelTableData.CreateUserID).RealName); SelJObject.Add("Count", SelTableData.Data); SelDataArray.Add(SelJObject); } JObject DayJObject = new JObject(); DayJObject.Add("Date", BeginDate.ToString("yyyy-MM-dd")); DayJObject.Add("List", SelDataArray); jarray.Add(DayJObject); } BeginDate = BeginDate.AddDays(1); } returnobj.Add("result", "success"); returnobj.Add("List", jarray); } } else { returnobj.Add("result", "failed"); returnobj.Add("message", "请选择最多相差14天的数据"); } } catch { returnobj.Add("result", "failed"); } context.Response.Clear(); context.Response.Write(returnobj); HttpContext.Current.ApplicationInstance.CompleteRequest(); }
/// <summary> /// 数据绑定 /// </summary> private void DataBindList() { //分情况计算 using (IFMPDBContext db = new IFMPDBContext()) { int group = Convert.ToInt32(ViewState["group"]); List <User> UserList = db.User.Where(t => (group == -1 || db.DepartmentUser.Where(m => m.DepartmentID == group).Select(m => m.UserID).Contains(t.ID)) && t.IsDel != true && !db.NoScoreUser.Select(m => m.UserID).Contains(t.ID)).ToList(); List <ScoreUser> ScoreUserList = db.ScoreUser.Where(t => t.IsDel != true).ToList(); List <Score> ScoreList = db.Score.Where(t => t.IsDel != true && t.AuditState == AuditState.通过).ToList(); DateTime begindate = new BaseUtils().GetSelectDate(Convert.ToDateTime(ViewState["beign"])); DateTime enddate = new BaseUtils().GetSelectDate(Convert.ToDateTime(ViewState["end"]), false); foreach (User User in UserList) { User.Total = ScoreUserList.Where(t => t.UserID == User.ID && ScoreList.Where(m => m.IsDel != true && m.CreateDate.Value > begindate && m.CreateDate.Value < enddate).Select(m => m.ID).Contains(t.ScoreID)).Sum(t => t.BScore); } List <object> returnlist = new List <object>(); UserList = UserList.OrderByDescending(t => t.Total).ThenBy(t => t.CreateDate).ToList(); int k = 0; int lastcount = 0; int samecount = 0; foreach (User User in UserList) { if (lastcount == User.Total) { samecount++; } else { k = k + samecount + 1; samecount = 0; } returnlist.Add(new { Number = k, User.RealName, User.Total, isbr = User.ID == UserID ? "1" : "0" }); lastcount = User.Total; } if (returnlist.Count > 0) { this.tr_null.Visible = false; } else { this.tr_null.Visible = true; } this.rp_List.DataSource = returnlist; rp_List.DataBind(); this.hf_CheckIDS.Value = ""; LinkButton lbtn = lbtn_Saturday; if (title == "月度") { lbtn = lbtn_Staff; } this.lbtn_Staff.BackColor = lbtn_Saturday.BackColor = System.Drawing.Color.FromName("#67b7ef"); this.lbtn_Staff.ForeColor = lbtn_Saturday.ForeColor = System.Drawing.Color.FromName("#e6e8c9"); lbtn.BackColor = System.Drawing.Color.FromName("#4F7ECF"); lbtn.ForeColor = System.Drawing.Color.FromName("#f0f5ff"); } }
private async Task <bool> Begin() { if (string.IsNullOrEmpty(GlobalData.VM_MA.Cookies)) { await GetCheck(GlobalLanguage.Msg_CheckCk); ShowLoading(false); return(false); } if (string.IsNullOrEmpty(GlobalData.VM_MA.SavePath)) { await GetCheck(GlobalLanguage.Msg_CheckSP); ShowLoading(false); return(false); } Directory.CreateDirectory(GlobalData.VM_MA.SavePath); if (!Directory.Exists(GlobalData.VM_MA.SavePath)) { await GetCheck(GlobalLanguage.Msg_CreateSP); ShowLoading(false); return(false); } if (null != GlobalData.DownLP) { GlobalData.VM_DL.DownLoadItemList.Clear(); GlobalData.DownLP.Close(); } GlobalData.VM_MA.PostCount = 0; GlobalData.VM_MA.PostTitle = string.Empty; ResultMessage _ret = null; _utils = GlobalData.CaptureUtil; if (_utils is PatreonUtils) { _ret = await(_utils as PatreonUtils).InitBrowser(); if (_ret.Error != ErrorType.NoError) { await GetCheck(_ret.Msgs); ShowLoading(false); return(false); } else if ((bool)_ret.Result) { while (GlobalData.VM_MA.ShowLogin) { await Task.Delay(1000); } if (!GlobalData.VM_MA.IsInitialized) { ShowLoading(false); return(false); } } } _selectF = GlobalData.VM_MA.HasSelected; if (!_selectF) { ArtistInfo ai = null; _ret = await _utils.GetArtistInfo(GlobalData.VM_MA.Artist.PostUrl); if (_ret.Error != ErrorType.NoError) { await GetCheck(_ret.Msgs); ShowLoading(false); return(false); } ai = (ArtistInfo)_ret.Result; GlobalData.VM_MA.Artist = ai; if (!GlobalData.VM_MA.ArtistList.Contains(GlobalData.VM_MA.Artist)) { if (GlobalData.VM_MA.ArtistList.Count > 0) { GlobalData.VM_MA.ArtistList[GlobalData.VM_MA.ArtistList.Count - 1] = GlobalData.VM_MA.Artist; } else { GlobalData.VM_MA.ArtistList.Add(GlobalData.VM_MA.Artist); } } } Task.Run(() => SaveSetting()); await Task.Run(() => GlobalData.DLLogs.LoadData(GlobalData.VM_MA.Artist.Id, GlobalData.VM_MA.Site)); if (GlobalData.VM_MA.Site == SiteType.Fantia) { GlobalData.DownLP = new Downloader(null, true); GlobalData.DownLP.Show(); GlobalData.DownLP.LoadData(); _ret = await _utils.GetPostIDs(GlobalData.VM_MA.Artist.Cid); if (_ret.Error != ErrorType.NoError) { await GetCheck(_ret.Msgs); ShowLoading(false); return(false); } _tempBis = (List <BaseItem>)_ret.Result; if (_tempBis.Count == 0) { await GetCheck(GlobalLanguage.Msg_NoPosts); ShowLoading(false); return(false); } GlobalData.VM_MA.ItemList = _tempBis.Where(x => !x.Skip).ToList(); GlobalCommand.BackCommand.Execute(BackType.Pop); GlobalData.VM_MA.Date = GlobalData.StartTime.ToString("yyyy/MM/dd HH:mm:ss"); GlobalData.LastDateDic.Update(GlobalData.VM_MA.LastDate); } else { _ret = await _utils.GetPostIDs(GlobalData.VM_MA.Artist.Cid); if (_ret.Error != ErrorType.NoError) { await GetCheck(_ret.Msgs); ShowLoading(false); return(false); } _tempBis = (List <BaseItem>)_ret.Result; if (_tempBis.Count == 0) { await GetCheck(GlobalLanguage.Msg_NoPosts); ShowLoading(false); return(false); } GlobalData.VM_MA.ItemList = _tempBis.Where(x => !x.Skip).ToList(); GlobalData.DownLP = new Downloader(_tempBis); GlobalData.DownLP.Show(); GlobalData.DownLP.LoadData(); GlobalCommand.BackCommand.Execute(BackType.Pop); } return(true); }
static void InitSoundManager() { BaseUtils.CreateGlobalObj <SoundManager>("SoundManager"); //temp.crossDuration }
private Task <IRestResponse> ExecuteRequest(Method requestMethod, ResourceType resource, RootObject json = null, params object[] requestParams) { int buildId; int testRunId; int testResultId; int testSnapshotId; string endPoint = string.Empty; string content = string.Empty; string statusCode = string.Empty; BaseUtils baseUtils = new BaseUtils(); try { switch (resource) { case ResourceType.TestRuns: if (requestMethod == Method.GET) { TestRunType testRunType = (TestRunType)requestParams[0]; testRunId = baseUtils.ConvertToType <int>(requestParams[1]); if (testRunType == TestRunType.GetTest) { testSnapshotId = baseUtils.ConvertToType <int>(requestParams[3]); bool allTests = baseUtils.ConvertToType <bool>(requestParams[2]); endPoint = allTests ? $"/test_runs/{testRunId}/test_snapshots" : $"/test_runs/{testRunId}"; } else if (testRunType == TestRunType.Sync) { endPoint = $"/test_runs/{testRunId}?show_synchronization_information=true"; } } else { endPoint = "/test_runs"; } break; case ResourceType.TestResults: if (requestMethod == Method.POST) { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); buildId = baseUtils.ConvertToType <int>(requestParams[1]); endPoint = $"/test_runs/{testRunId}/builds/{buildId}/test_results"; } else if (requestMethod == Method.PATCH) { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); testSnapshotId = baseUtils.ConvertToType <int>(requestParams[1]); testResultId = baseUtils.ConvertToType <int>(requestParams[2]); endPoint = $"/test_runs/{testRunId}/test_snapshots/{testSnapshotId}/test_results/{testResultId}"; } else { testRunId = baseUtils.ConvertToType <int>(requestParams[0]); testSnapshotId = baseUtils.ConvertToType <int>(requestParams[1]); endPoint = $"/test_runs/{testRunId}/test_snapshots/{testSnapshotId}?include=last-result"; } break; case ResourceType.TestSnapshots: testRunId = baseUtils.ConvertToType <int>(requestParams[0]); endPoint = $"/test_runs/{testRunId}/test_snapshots?include=scenario"; break; } IRestRequest request = CreateRequest(requestMethod, endPoint); if (json != null) { request.AddJsonBody(json); } log.Info($"API Endpoint: {endPoint}"); IRestClient client = new RestClient(ApiBase); var responseTask = Task.Factory.StartNew(() => client.Execute(request)); Task.WaitAny(responseTask); var response = responseTask.Result; statusCode = response.StatusCode.ToString(); content = response.Content; return(responseTask); } catch (Exception e) { log.Debug($"ExecuteRequest StatusCode: {statusCode}\n{e.Message}"); log.Debug(content); throw; } }
private void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) { outputWindowLog.WriteLine("Exception in Plugster"); outputWindowLog.WriteLine(BaseUtils.GetExceptionInfo(e.Exception)); MessageBox.Show(e.Exception.Message, "An exception occurred(See logs for more details):", MessageBoxButtons.OK, MessageBoxIcon.Error); }
public ApiResult Login(SysUser user) { ApiResult result = new ApiResult(); string message = string.Empty; try { using (FLDbContext db = new FLDbContext()) { if (!string.IsNullOrEmpty(user.UserName) && !string.IsNullOrEmpty(user.Password)) { string md5pw = new BaseUtils().BuildPW(user.UserName, user.Password); SysUser loginuser = db.SysUser.FirstOrDefault(t => t.UserName == user.UserName && t.Password == md5pw); if (loginuser != null) { if (loginuser.IsAccountDisabled == true) { message = "用户被限制登录,请联系管理员"; } else { DateTime now = DateTime.Now; DateTime?expires = null; //重新生成token expires = DateTime.Now.AddMinutes(60 * 24 * 7); //一周后过期 //expires = DateTime.Now.AddMinutes(1); //测试 string token = LoginHelper.GenerateToken(loginuser.ID, expires.Value, db); LoginHelper.CurrentUser = loginuser; loginuser.LastLogindate = DateTime.Now; db.SaveChanges(); //new WXDAO().SendMessage("登陆成功"); new SysLogDAO().AddLog(LogType.Success, message: "登录"); result.Data = new { RealName = loginuser.RealName, Token = token, Expires = expires, HeaderUrl = loginuser.HeaderUrl,//需要默认的头像 }; result.Status = ApiResultCodeType.Success; } } else { message = "登录失败,请检查用户名和密码"; } } else { message = "请输入用户名和密码"; } } } catch (Exception ex) { message = ex.Message.ToString(); } if (!string.IsNullOrEmpty(message)) { result = ApiResult.NewErrorJson(message); } return(result); }