private void GetWorkTaskByID() { List <Performance.Error> errors = new List <Performance.Error>(); WorkTaskViewModel pvm = null; try { WorkTask p = BllInstance.WorkTaskBllInstance.GetWorkTask(Convert.ToInt32(_Context.Request.Params["Pkid"])); pvm = new WorkTaskViewModel(p); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"item\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(pvm), JsonConvert.SerializeObject(errors)); }
private void GetWorkTaskHistoryByID() { List <Performance.Error> errors = new List <Performance.Error>(); WorkTaskViewModel pvm = null; try { //WorkTaskHistory p = // InstanceFactory.CreateWorkTaskHistoryFacade().GetWorkTaskHistoryByPKID( // Convert.ToInt32(_Context.Request.Params["HistoryId"])); //pvm = new WorkTaskViewModel(p); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"item\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(pvm), JsonConvert.SerializeObject(errors)); }
private void GetWorkTaskByName() { List <Performance.Error> errors = new List <Performance.Error>(); WorkTaskViewModel pvm = null; try { //WorkTask p = // BllInstance.WelcomeMailBllInstance.GetWorkTaskByName(_Context.Request.Params["Name"], _Operator); //if (p != null) //{ // p = BllInstance.WorkTaskBllInstance.GetWorkTaskById(p.Id, _Operator); //} //pvm = new WorkTaskViewModel(p); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"item\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(pvm), JsonConvert.SerializeObject(errors)); }
private void SearchWorkTask() { List <Performance.Error> errors = new List <Performance.Error>(); List <WorkTaskViewModel> workTaskViewModelUIs = new List <WorkTaskViewModel>(); try { DateTime dt; int x; bool b; DateTime startDate = new DateTime(1900, 1, 1); DateTime endDate = new DateTime(2999, 12, 31); int status = -1; int accountID = 0; bool ifNotStarted = false; bool ifFinish = false; bool ifOngoing = false; bool ifFailure = false; if (_Context.Request.Params["StartDate"] != null && DateTime.TryParse(_Context.Request.Params["StartDate"], out dt)) { startDate = dt; } if (_Context.Request.Params["EndDate"] != null && DateTime.TryParse(_Context.Request.Params["EndDate"], out dt)) { endDate = dt; } if (_Context.Request.Params["Priority"] != null && int.TryParse(_Context.Request.Params["Priority"], out x)) { status = x; } if (_Context.Request.Params["AccountID"] != null && int.TryParse(_Context.Request.Params["AccountID"], out x)) { accountID = x; } if (!string.IsNullOrEmpty(_Context.Request.Params["Status"])) { string[] ischecks = _Context.Request.Params["Status"].Split('|'); if (ischecks.Length == 5) { ifNotStarted = bool.TryParse(ischecks[1], out b) ? b : ifNotStarted; ifOngoing = bool.TryParse(ischecks[2], out b) ? b : ifOngoing; ifFailure = bool.TryParse(ischecks[3], out b) ? b : ifFailure; ifFinish = bool.TryParse(ischecks[4], out b) ? b : ifFinish; } } List <WorkTask> WorkTasks = new List <WorkTask>(); if (_Context.Request.Params["type"] == "SearchOwnerWorkTask") { WorkTasks = BllInstance.WorkTaskBllInstance.GetMyWorkTaskByCondition( _Context.Request.Params["TaskName"] ?? string.Empty, startDate, endDate, status, ifNotStarted, ifOngoing, ifFailure, ifFinish, accountID); _Context.Session["SearchOwnerWorkTaskList"] = WorkTasks; } if (_Context.Request.Params["type"] == "SearchOtherWorkTask") { WorkTasks = BllInstance.WorkTaskBllInstance.GetResponsibleWorkTaskByCondition( _Context.Request.Params["TaskName"] ?? string.Empty, startDate, endDate, status, ifNotStarted, ifOngoing, ifFailure, ifFinish, accountID); _Context.Session["SearchOtherWorkTaskList"] = WorkTasks; } if (_Context.Request.Params["type"] == "SearchTeamWorkTask") { WorkTasks = BllInstance.WorkTaskBllInstance.GetTeamWorkTaskByCondition(_Context.Request.Params["CreatorName"] ?? string.Empty, _Context.Request.Params["DeptName"] ?? string.Empty, _Context.Request.Params["TaskName"] ?? string.Empty, startDate, endDate, status, ifNotStarted, ifOngoing, ifFailure, ifFinish, accountID); _Context.Session["SearchTeamWorkTaskList"] = WorkTasks; } workTaskViewModelUIs = WorkTaskViewModel.Turn(WorkTasks); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"itemList\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(workTaskViewModelUIs), JsonConvert.SerializeObject(errors)); }
private void ExportToExcel(Worksheet excelSheet) { List <WorkTask> worktasks = new List <WorkTask>(); try { if (_Context.Request.Params["ExportSource"] == "OwnerWorkTaskList") { excelSheet.Name = "个人工作计划"; worktasks = _Context.Session["SearchOwnerWorkTaskList"] as List <WorkTask>; } if (_Context.Request.Params["ExportSource"] == "OtherWorkTaskList") { excelSheet.Name = "其他工作计划"; worktasks = _Context.Session["SearchOtherWorkTaskList"] as List <WorkTask>; } if (_Context.Request.Params["ExportSource"] == "TeamWorkTaskList") { excelSheet.Name = "团队工作计划"; worktasks = _Context.Session["SearchTeamWorkTaskList"] as List <WorkTask>; } } catch { } if (worktasks == null) { worktasks = new List <WorkTask>(); } //二维数组定义是多一个标题行。 List <WorkTaskViewModel> workTaskViewModelUIs = WorkTaskViewModel.Turn(worktasks); int rowcount = worktasks.Count; int colcount = 10; object[,] dataArray = new object[rowcount + 1, colcount]; dataArray[0, 0] = "任务名称"; dataArray[0, 1] = "工作内容"; dataArray[0, 2] = "优先级别"; dataArray[0, 3] = "创建人"; dataArray[0, 4] = "负责人"; dataArray[0, 5] = "开始时间"; dataArray[0, 6] = "完成时间"; dataArray[0, 7] = "当前状态"; dataArray[0, 8] = "当前状态工作描述"; dataArray[0, 9] = "备注"; for (int i = 0; i < workTaskViewModelUIs.Count; i++) { dataArray[i + 1, 0] = workTaskViewModelUIs[i].Title; dataArray[i + 1, 1] = workTaskViewModelUIs[i].Content; dataArray[i + 1, 2] = workTaskViewModelUIs[i].PriorityName; dataArray[i + 1, 3] = workTaskViewModelUIs[i].OwerName; dataArray[i + 1, 4] = workTaskViewModelUIs[i].ResponsiblesNameIncludeOwner; dataArray[i + 1, 5] = workTaskViewModelUIs[i].StartDate; dataArray[i + 1, 6] = workTaskViewModelUIs[i].EndDate; dataArray[i + 1, 7] = workTaskViewModelUIs[i].StatusName; dataArray[i + 1, 8] = workTaskViewModelUIs[i].Description; dataArray[i + 1, 9] = workTaskViewModelUIs[i].Remark; } excelSheet.get_Range("A1", excelSheet.Cells[rowcount + 1, colcount]).Value2 = dataArray; Range r = excelSheet.get_Range("A1", excelSheet.Cells[rowcount + 1, colcount]); r.Font.Size = 10; r.WrapText = true; r.Borders.LineStyle = XlLineStyle.xlContinuous; r.Borders.Color = Color.Black.ToArgb(); r.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, Color.Black.ToArgb()); r.RowHeight = 24; ((Range) excelSheet.Columns[ ExcelExportUtility.ExcelColumnNames[0] + ":" + ExcelExportUtility.ExcelColumnNames[0], Type.Missing]).ColumnWidth = 15; ((Range) excelSheet.Columns[ ExcelExportUtility.ExcelColumnNames[1] + ":" + ExcelExportUtility.ExcelColumnNames[1], Type.Missing]).ColumnWidth = 28; ((Range) excelSheet.Columns[ ExcelExportUtility.ExcelColumnNames[4] + ":" + ExcelExportUtility.ExcelColumnNames[4], Type.Missing]).ColumnWidth = 10; ((Range) excelSheet.Columns[ ExcelExportUtility.ExcelColumnNames[8] + ":" + ExcelExportUtility.ExcelColumnNames[8], Type.Missing]).ColumnWidth = 33; if (worktasks.Count > 0) { Range r8 = excelSheet.get_Range("I2", "I" + (worktasks.Count + 1)); r8.Font.Color = ColorTranslator.FromHtml("#FF0000").ToArgb(); } ((Range)excelSheet.Rows["1:1", Type.Missing]).RowHeight = 45; ((Range)excelSheet.Rows["1:1", Type.Missing]).HorizontalAlignment = XlHAlign.xlHAlignCenter; for (int i = 0; i < workTaskViewModelUIs.Count; i++) { Range r7 = excelSheet.get_Range("H" + (i + 2), "H" + (i + 2)); if (workTaskViewModelUIs[i].StatusName == "未开始") { r7.Interior.Color = ColorTranslator.FromHtml("#FF0000").ToArgb(); } if (workTaskViewModelUIs[i].StatusName == "进行中") { r7.Interior.Color = ColorTranslator.FromHtml("#00FFFF").ToArgb(); } if (workTaskViewModelUIs[i].StatusName == "未完成") { r7.Interior.Color = ColorTranslator.FromHtml("#0000FF").ToArgb(); } if (workTaskViewModelUIs[i].StatusName == "已完成") { r7.Interior.Color = ColorTranslator.FromHtml("#00FF00").ToArgb(); } } }