public ActionResult Dafen([Bind(Include = "groupId,taskId,submitTime,submitterId,submitTimes,taskGrade,taskComment,courseId,taskUrl")] TaskSubmit tsb) { if (ModelState.IsValid) { TaskSubmitDBContext cdb = new TaskSubmitDBContext(); cdb.Entry(tsb).State = EntityState.Modified; cdb.SaveChanges(); return(RedirectToAction("TaskSubmitInfo")); } return(View(tsb)); }
public ActionResult Dafen(string gid, string tid, DateTime st, string cid) { if (tid == null || gid == null || cid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DBHelper dbHelper = DBHelper.getMyHelper(); List <TaskSubmit> ts = dbHelper.getTaskSubmits(); TaskSubmitDBContext cdb = new TaskSubmitDBContext(); TaskSubmit ts1 = new TaskSubmit(); foreach (TaskSubmit ts2 in ts) { if (ts2.groupId == gid && ts2.taskId == tid && ts2.submitTime.CompareTo(st) == 0 && ts2.courseId == cid) { ts1 = ts2; } } if (ts1 == null) { return(HttpNotFound()); } return(View(ts1)); }
private void HandleApprovalStatus(string sfWorkOrderID, int jobId, int estRevID, int woId, int userEmployeeID, string remarks, DateTime?dueDate, string rush, string woType, enterprise.QueryResult result, double?version, DateTime?issueDateTime) { try { if (version == null) { return; } short ver = Convert.ToInt16(version); var sales_Dispatching = _db.Sales_Dispatching.Where(x => x.JobID == jobId && x.TaskType == 720 && x.WoID == woId && x.Importance == ver).FirstOrDefault(); if (sales_Dispatching == null) { //create service client to call API endpoint using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr)) { if (result == null || (result != null && result.size == 0)) { return; } //cast query results IEnumerable <enterprise.ProcessInstance> processInstanceList = result.records.Cast <enterprise.ProcessInstance>(); //show results foreach (var el in processInstanceList) { if (el.Status == "Pending") { int taskCategory = 720; //-- [Work order Approval] is defined in Sales_Dispatching_Task_Category int submitBy = userEmployeeID; string taskFromWhere = "wip"; // coresponding to stage of 2 TaskSubmitFactory foTaskSubmit = new TaskSubmitFactory(taskCategory, submitBy, taskFromWhere); TaskSubmit dp = foTaskSubmit.ObjTaskSubmit; dp.ParameterDispatchingTask.Responsible = 8; // Mr. Fan is approved it dp.ParameterDispatchingTask.JobId = jobId; dp.ParameterDispatchingTask.EstRevId = estRevID; dp.ParameterDispatchingTask.WoId = woId; dp.ParameterDispatchingTask.Subject = "Workorder approval"; //DispatchingTaskEN.NDispatchingTaskPurpose.WorkorderApproval if (!string.IsNullOrEmpty(remarks)) { dp.ParameterDispatchingTask.Description = remarks.Trim(); } if (dueDate != null) { dp.ParameterDispatchingTask.RequiredTime = (DateTime)dueDate; } else { dp.ParameterDispatchingTask.RequiredTime = DateTime.Now.AddDays(1); } if (issueDateTime != null) { dp.ParameterDispatchingTask.SubmitTime = issueDateTime.Value.ToLocalTime(); } else { dp.ParameterDispatchingTask.SubmitTime = DateTime.Now; } switch (rush) { case "Yes": dp.ParameterDispatchingTask.Rush = true; break; default: dp.ParameterDispatchingTask.Rush = false; break; } switch (woType) { case "Production": dp.ParameterDispatchingTask.WorkorderType = 10; break; case "Service": dp.ParameterDispatchingTask.WorkorderType = 20; break; case "Site Check": dp.ParameterDispatchingTask.WorkorderType = 30; break; default: break; } dp.EnableDuplicateSubmit = true; dp.Insert(ver); } } LogMethods.Log.Debug("HandleApprovalStatus:Debug:" + "Done"); } } else { // this work order has been submitted using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr)) { if (result == null || (result != null && result.size == 0)) { return; } //cast query results IEnumerable <enterprise.ProcessInstance> processInstanceList = result.records.Cast <enterprise.ProcessInstance>(); //show results foreach (var el in processInstanceList) { if (el.Status == "Removed") { var workOrder = _db.Sales_JobMasterList_WO.Where(x => x.woID == sales_Dispatching.WoID).FirstOrDefault(); if (workOrder != null) { workOrder.woStatus = (short)NJobStatus.woNew; } _db.Entry(workOrder).State = EntityState.Modified; _db.SaveChanges(); /* delete a row in Sales_Dispatching */ _db.Sales_Dispatching.Remove(sales_Dispatching); _db.SaveChanges(); } } } } } catch (Exception e) { LogMethods.Log.Error("HandleApprovalStatus:Error:" + e.Message); } }