using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.OA.DAL.WorkFlow; using DSWeb.Areas.OA.Models.WorkFlow; using DSWeb.Areas.OA.Models.Comm; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using DSWeb.Areas.CommMng.DAL; //using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using HcUtility.Core; using Microsoft.Practices.EnterpriseLibrary.Data; using System.Text; using System.Data; using DSWeb.Areas.Import.Models.CwVouitems; using DSWeb.Areas.Import.Models.CwDesign; using DSWeb.Areas.Import.DAL.CwVouchersDAL; using DSWeb.Areas.Import.Models.CwVouchers; using DSWeb.EntityDA; namespace DSWeb.Areas.OA.Controllers { [JsonRequestBehavior] public class WorkFlowController : Controller { // // GET: /Import/XXH public ActionResult Index() { return View(); } // // GET: /Import/XXH/Edit public ActionResult Edit() { return View(); } // // 获取工作流Type列表 public ContentResult GetTypeList(int start, int limit, string sort, string condition) { var dataList = OA.DAL.WorkFlow.WorkFlowDAL.GetTypeList(condition); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult Save_Type(string ProjectBody, string ProjectDelBody) { var ProjectBodyList = JsonConvert.Deserialize>(ProjectBody); var ProjectDelBodyList = JsonConvert.Deserialize>(ProjectDelBody); var modb = new ModelObjectRepository(); DBResult result = modb.SaveComm( ModelObjectConvert.ToModelObjectList(ProjectBodyList), ModelObjectConvert.ToModelObjectList(ProjectDelBodyList) ); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult GetWorkFlowList(int start, int limit, string sort, string condition) { var dataList = OA.DAL.WorkFlow.WorkFlowDAL.GetWorkFlowList(condition); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetWorkFlowData(string handle, string condition) { WorkFlowmb head = null; if (handle == "edit") { head = OA.DAL.WorkFlow.WorkFlowDAL.GetWorkFlowData(condition); } if (head == null) { head = new WorkFlowmb(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult GetStepList(string WorkFlowID) { var _condition = " WorkFlowID ='"+WorkFlowID+"'"; var dataList = OA.DAL.WorkFlow.WorkFlowDAL.GetStepList(_condition); var list = dataList; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetUserStateList(string WorkFlowID) { var _condition = WorkFlowID ; var dataList = OA.DAL.WorkFlow.WorkFlowDAL.GetUserStateList(_condition); var list = dataList; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetUserPathList(string WorkFlowID) { var _condition = WorkFlowID; var dataList = OA.DAL.WorkFlow.WorkFlowDAL.GetUserPathList(_condition); var list = dataList; var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public class WorkFlowstepeditmb : WorkFlowStepmb { private string _editstate = string.Empty; public string editstate { get { return _editstate; } set { _editstate = value; } } } public ContentResult SaveStep(string opstatus, string data, string StepBody, string StepDel) { var head = JsonConvert.Deserialize(data); var StepbodyList = JsonConvert.Deserialize>(StepBody); var StepDelbodyList = JsonConvert.Deserialize>(StepDel); if (head.ISDEFAULT == "1") { OA.DAL.WorkFlow.WorkFlowDAL.SetDefaultStep(head.TYPE,head.COMPANYID); } // if (head.GID == "") head.GID = Guid.NewGuid().ToString(); //由于工作流变动会对处于审核流程中的工作流状态产生影响 //故需要首先记录产生变动的workflow_step //在修改完成后 如果增加,则调用insertstep处理workflow_using,删除调用delstep //修改,则先调用del,再调用insert。 var insertlist = new List(); var editlist = new List(); if (StepbodyList != null) { foreach (var Stepbody in StepbodyList) { if (Stepbody.WORKFLOWID == "") { insertlist.Add(Stepbody); } else { editlist.Add(Stepbody); } } } if (StepbodyList != null) { foreach (var stepedit in editlist) { //var _result = DSWeb.Areas.CommMng.DAL.WorkFlowDAL.DelStep(stepedit.GID);//.WORKFLOWID, stepedit.AUDITOR, stepedit.STEPNO, stepedit.GROUPID); //_result = DSWeb.Areas.CommMng.DAL.WorkFlowDAL.InsertStep(stepedit.WORKFLOWID, stepedit.AUDITOR, stepedit.STEPNO, stepedit.GROUPID); } foreach (var stepedit in insertlist) { var _result = DSWeb.Areas.CommMng.DAL.WorkFlowDAL.InsertStep(stepedit.WORKFLOWID, stepedit.AUDITOR, stepedit.STEPNO, stepedit.GROUPID); } } if (StepDelbodyList != null) { foreach (var stepedit in StepDelbodyList) { //var _result = DSWeb.Areas.CommMng.DAL.WorkFlowDAL.DelStep(stepedit.GID);//, stepedit.AUDITOR, stepedit.STEPNO, stepedit.GROUPID); } } if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; //head.GID="newid()"; //自动填写接单审单人id //head.CREATEUSER = CookieConfig.GetCookie_UserName(Request); //head.COMPANY = CookieConfig.GetCookie_OrgName(Request); //head.COMPANY = CookieConfig.GetCookie_OrgName(Request); } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(StepbodyList), ModelObjectConvert.ToModelObjectList(StepDelbodyList) ); //刷新父窗口上的父节点 var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data =OA.DAL.WorkFlow.WorkFlowDAL.GetWorkFlowData("GID='" + head.GID + "'") }; //p_op_gain(head.BXGID); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteWorkFlow(string data, string USERID) { //首先判断 如有审核流程中的业务则返回错误 var head = JsonConvert.Deserialize(data); var GID = head.GID; var _inused = OA.DAL.WorkFlow.WorkFlowDAL.GetWorkFlowInUsingList(GID); if (_inused.Count > 0) { var jsonRespose0 = new JsonResponse { Success = false, Message = "该工作流有未完结的审批,不能删除!" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose0) }; } var modb = new ModelObjectDB(); DBResult result = modb.Delete(head , "delete from WorkFlow_step where workflowid = '" + GID + "'" , "delete from workflow_UserPath where workflowid = '" + GID + "'" ); /* strSql.Append(" delete from WorkFlow where gid = '" + GID + "'"); strSql.Append(" delete from WorkFlow_step where workflowid = '" + GID + "'"); strSql.Append(" delete from workflow_UserPath where workflowid = '" + GID + "'");*/ var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; //var _count = 0; //_count = OA.DAL.WorkFlow.WorkFlowDAL.DeleteWorkFlow(GID); return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult SaveUserPath(string WORKFLOWTYPENO,string WORKFLOWID,string USERIDList) { //HTmb head = null; var _result = OA.DAL.WorkFlow.WorkFlowDAL.SaveUserPath(WORKFLOWTYPENO,WORKFLOWID, USERIDList); var jsonRespose = new JsonResponse { Success = _result.Success, Message = _result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; //return new ContentResult() { Content = JsonConvert.Serialize("") }; } public ContentResult DelUserPath(string WORKFLOWTYPENO, string WORKFLOWID, string USERIDList) { //HTmb head = null; var _result = OA.DAL.WorkFlow.WorkFlowDAL.DelUserPath(WORKFLOWTYPENO, WORKFLOWID, USERIDList); var jsonRespose = new JsonResponse { Success = _result.Success, Message = _result.Message, //Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; //return new ContentResult() { Content = JsonConvert.Serialize("") }; } public ContentResult GetWorkLog ( int start, int limit, string sort, string condition ) { var dataList = OA.DAL.WorkFlow.WorkLogDAL.GetWorkLog(condition,sort); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } public Boolean WriteWorkLog ( WorkLogmb WorkLog ) { WorkLog.DbOperationType = DbOperationType.DbotIns; WorkLog.ModelUIStatus = "I"; WorkLog.GID = System.Guid.NewGuid().ToString(); WorkLog.OP = Convert.ToString(Session["SHOWNAME"]); WorkLog.OPDATE = DateTime.Now.ToLocalTime().ToString(); var modb = new ModelObjectRepository(); DBResult result = modb.Save(WorkLog); return result.Success; } #region 参照部分 #endregion } }