public Boolean SendWorkItem(int workItemId, int receiveUserId, int preActivityInstId, int nextActivityId)
        {
            //老工作项更新
            Model.WorkItem preWorkItem = (Model.WorkItem)service.GetDataList("t.*", "", "and t.id=" + workItemId)[0];
            preWorkItem.State = 1;
            preWorkItem.Update();
            //老环节实例更新
            Model.Activity_Inst preActivityInst = (Model.Activity_Inst) new DataService("Activity_Inst", "OA_Activity_Inst").GetDataList("t.*", "", "and t.id=" + preActivityInstId)[0];
            preActivityInst.EndTime = DateTime.Now;
            preActivityInst.Update();
            //表单实例更新
            Model.FormInst formInst = (Model.FormInst) new DataService("FormInst", "OA_FORMINST").GetDataList("t.*", "", "and t.projectid=" + preWorkItem.ProjectId)[0];
            formInst.Content = System.IO.File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + "\\temp.html");
            formInst.Update();
            //获取项目
            Model.Project project = (Model.Project) new DataService("Project", "OA_PROJECT").GetDataList("t.*", "", "and t.id=" + preWorkItem.ProjectId)[0];
            if (nextActivityId == 0)
            {
                //项目标记结束
                project.State   = 1;
                project.EndTime = DateTime.Now;
                project.Update();
            }
            else
            {
                //新建环节实例
                Model.Activity_Inst nextActivityInst = new Model.Activity_Inst();
                nextActivityInst.ActivityId    = nextActivityId;
                nextActivityInst.ProcessInstId = preActivityInst.ProcessInstId;
                nextActivityInst.ProjectId     = preActivityInst.ProjectId;
                int nextActivityInstId = (int)nextActivityInst.Create();
                //新建工作项
                Model.WorkItem nextWorkItem = new Model.WorkItem();
                nextWorkItem.ProjectId      = preWorkItem.ProjectId;
                nextWorkItem.ReceiveUserId  = receiveUserId;
                nextWorkItem.State          = 0;
                nextWorkItem.ActivityInstId = nextActivityInstId;
                int nextWorkItemId = (int)nextWorkItem.Create();
                //新建环节实例关系
                Model.Activity_Inst_Relation activity_Inst_Relation = new Model.Activity_Inst_Relation();
                activity_Inst_Relation.ActivityInstId    = nextActivityInstId;
                activity_Inst_Relation.PreActivityInstId = preActivityInst.Id;
                activity_Inst_Relation.Create();
                //更新项目信息
                project.CurrentUserId = receiveUserId;
                project.WorkItemId    = nextWorkItemId;
                project.Update();
            }

            return(true);
        }
        public Object CreateProject(Model.Project project, string userName)
        {
            //获取创建人
            Model.User user = new UserController().GetUserByName(userName);
            project.CreateUserId  = user.Id;
            project.CurrentUserId = user.Id;
            //新建项目
            Dictionary <string, string> backData = (Dictionary <string, string>)project.Create();
            int projectId = Convert.ToInt32(backData["Id"]);

            try
            {
                //新建表单实例
                Model.FormInst formInst = new Model.FormInst();
                formInst.ProjectId = projectId;
                FormTempController formTempController = new FormTempController();
                Model.FormTemp     formTemp           = (Model.FormTemp)formTempController.GetFormTempByBusinessId(project.BusinessId);
                formInst.Name       = formTemp.Name;
                formInst.FormTempId = formTemp.Id;
                formInst.Content    = System.IO.File.ReadAllBytes(path);
                formInst.Create();
                //新建流程实例
                ProcessController  processController = new ProcessController();
                Model.Process      process           = (Model.Process)processController.GetProcessByBusinessId(project.BusinessId);
                Model.Process_Inst process_Inst      = new Model.Process_Inst();
                process_Inst.ProcessId    = process.Id;
                process_Inst.ProjectId    = projectId;
                process_Inst.CreateUserId = user.Id;
                int processInstId = (int)process_Inst.Create();
                //新建环节实例
                ActivityController  activityController = new ActivityController();
                Model.Activity      activity           = (Model.Activity)activityController.GetActivityByProcessId(process.Id);
                Model.Activity_Inst activity_Inst      = new Model.Activity_Inst();
                activity_Inst.ActivityId    = activity.Id;
                activity_Inst.ProcessInstId = processInstId;
                activity_Inst.ProjectId     = project.Id;
                int activityInstId = (int)activity_Inst.Create();
                //新建工作项
                Model.WorkItem workItem = new Model.WorkItem();
                workItem.ProjectId      = projectId;
                workItem.State          = 0;
                workItem.ActivityInstId = activityInstId;
                workItem.ReceiveUserId  = user.Id;
                int workItemId = (int)workItem.Create();
                project.WorkItemId = workItemId;
                project.Update();
                //新建材料清单模板实例
                MaterialTempController  materialTempController = new MaterialTempController();
                Model.MaterialTemp      materialTemp           = (Model.MaterialTemp)materialTempController.GetMaterialTempByBusinessId(project.BusinessId);
                Model.MaterialTemp_Inst materialTemp_Inst      = new Model.MaterialTemp_Inst();
                materialTemp_Inst.MaterialTempId = materialTemp.Id;
                materialTemp_Inst.Name           = materialTemp.Name;
                materialTemp_Inst.ProjectId      = projectId;
                materialTemp_Inst.Create();
            }
            catch (Exception e)
            {
                Util.Log.LogHelper.WriteLog(e.Message);
            }

            //返回项目数据
            return(Newtonsoft.Json.JsonConvert.SerializeObject(backData));
        }