Esempio n. 1
0
        private object GetProcess(APIContext context)
        {
            var data      = JsonHelper.DeserializeJsonToObject <GetProcessReq>(context.Data);
            var ddService = SysContext.GetService <IDingDingServices>();

            return(ddService.GetProcess(data.OriUserId, data.OriDeptId, data.taskUserId, data.OpeUserId, data.pageIndex, data.pageSize).Result);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建后续任务
        /// </summary>
        /// <param name="NextTasks"></param>
        /// <param name="sourcetaskid"></param>
        public object CreatTasksAndCreatWorkrecor(work_task[] NextTasks, string sourcetaskid)
        {
            if (NextTasks == null)
            {
                return(null);
            }
            if (NextTasks.Length < 1)
            {
                return(null);
            }
            foreach (var Task in NextTasks)
            {
                //保存任务
                Task.LaskTaskId             = sourcetaskid;               //上一个任务id
                Task.InitiationTime         = DateTime.Now;               //状态
                Task.TaskStatus             = (int)WorkTaskStatus.Normal; //状态
                Task.ExpectedCompletionTime = DateTime.Now.AddDays(1);    //期望完成时间
                var loginClientInfo = SysContext.GetService <ClientInfo>();
                if (loginClientInfo != null)
                {
                    Task.CreateUserID = loginClientInfo.UserId ?? null;  //任务创建人
                }
                string id = SaveWorkTask(Task);
                Task.ID = id;
                //发送待办
                if (!string.IsNullOrEmpty(Task.AppLinks))
                {
                    Task.AppLinks += (Task.AppLinks.Contains("?") ? "&" : "?") + "taskid=" + Task.ID;
                }
                if (!string.IsNullOrEmpty(Task.PCLinks))
                {
                    Task.PCLinks += (Task.PCLinks.Contains("?") ? "&" : "?") + "taskid=" + Task.ID;
                }
                var dic = new Dictionary <string, string>();
                dic.Add("任务说明", Task.TaskContent);
                dic.Add("任务发起时间", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                dic.Add("期望完成时间", Task.ExpectedCompletionTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));

                if (Task.TaskType.ToUpper() == TaskType.Punishment.ToString().ToUpper())
                {
                    string taskTypeStr = QueryDb.ExecuteScalar <string>("select title from res_dictionaryitems where itemcode=@0", Task.TaskType);  //获取任务类型中文描述
                    string caseNumber  = QueryDb.ExecuteScalar <string>("select caseNumber from case_info where id=@0", Task.CaseID);
                    Task.TaskTitle = caseNumber + "-" + taskTypeStr;
                }

                Task.TodotaskID = CreateWorkrecor(Task.AssignUsers, Task.TaskTitle, Task.AppLinks, dic);   //待办id

                //记录待办id
                ServiceHelper.GetService("work_task").Update(Task);  //修改关联的

                //修改关联事件状态已分配任务
                UpdateEventState(Task.EventInfoId, EventStatus.dispose);
            }
            return(true);
        }
Esempio n. 3
0
        public object Handle(APIContext context)
        {
            var data = JsonHelper.DeserializeJsonToObject <case_reportFinishReq>(context.Data);

            if (data.CaseReport == null)
            {
                throw new Exception("没有主体数据");
            }
            data.CaseReport.TaskId      = data.SourceTaskId;
            data.CaseReport.EventInfoId = data.EventInfoId;
            QueryDb.BeginTransaction();
            try
            {
                #region 发起钉钉的审批 并将其返回的ID写入Task内
                if (data.oapiProcessinstanceCreateRequest != null)
                {
                    //填值
                    var UsrService      = SysContext.GetService <IUserServices>();
                    var loginClientInfo = SysContext.GetService <WanJiang.Framework.Infrastructure.Logging.ClientInfo>();

                    //ServiceConfig userServiceConfig = ServiceHelper.GetServiceConfig("user");
                    //var OTDB = SysContext.GetOtherDB(userServiceConfig.model.dbName);
                    //var deptId = OTDB.FirstOrDefault<long>(@"SELECT org.id FROM organization org
                    //                        inner join organizationuser ou on ou.OrganizationId = org.Id
                    //                        inner join user usr on usr.Id = ou.UserId
                    //                        where usr.AccountId = @0", loginClientInfo.AccountId);
                    ////
                    //if (deptId == null)
                    //    throw new Exception("无组织部门");

                    var usrDetail = UsrService.GetUserDetails(loginClientInfo.UserId);
                    var ddService = SysContext.GetService <IDingDingServices>();
                    if (usrDetail.Result.Organizations == null || usrDetail.Result.Organizations.Count <= 0)
                    {
                        throw new Exception("无组织部门");
                    }
                    var deptId = usrDetail.Result.Organizations[0].Id;

                    data.oapiProcessinstanceCreateRequest.DeptId           = deptId;
                    data.oapiProcessinstanceCreateRequest.OriginatorUserId = loginClientInfo.AccountId;

                    var result = ddService.ProcessInstaceCreateAsync(data.oapiProcessinstanceCreateRequest);
                    var test   = result.Result;
                    if (result.Result.Errcode != 0)
                    {
                        throw new Exception("发起审核流失败" + result.Result.ErrMsg);
                    }
                    data.CaseReport.ProcessInstanceId = result.Result.ProcessInstanceId;
                    data.CaseReport.FormState         = "待审核";
                    //更新该Report上的信息
                    //var targetId = result.Result.ProcessInstanceId;
                    //if (data.CaseReport.TaskId == null || data.CaseReport.TaskId == "")
                    //    throw new Exception("Task为空");
                    //var taskObj = QueryDb.FirstOrDefault<work_task>("where TaskID =@0", data.CaseReport.TaskId);
                    //if (taskObj == null)
                    //    throw new Exception("该Task不存在");
                    ////更新值
                    //taskObj.processInstanceId = result.Result.ProcessInstanceId;
                    //data.CaseReport.FormState = "待审批";
                    ////data.CaseReport.
                    //QueryDb.Update(taskObj);
                    //ServiceHelper.GetService("work_task").Update(taskObj);
                }
                #endregion
                CreateInfo(data.CaseReport);
                if (!string.IsNullOrEmpty(data.CaseReport.CaseId))
                {
                    var caseinfo = QueryDb.FirstOrDefault <case_Info>("select * from case_Info where Id=@0", data.CaseReport.CaseId);
                    if (caseinfo == null)
                    {
                        throw new Exception("没有案件信息");
                    }
                    caseinfo.CaseStatus = "完成处罚";
                    QueryDb.Update(caseinfo);
                }
                else
                {
                    throw new Exception("没有案件信息");
                }
                _sHBaseService.CreatTasksAndCreatWorkrecor(data.NextTasks, data.SourceTaskId);
                _sHBaseService.UpdateWorkTaskState(data.SourceTaskId, WorkTaskStatus.Close);//关闭任务

                //打印预生成
                var PDFSerivce = ServiceHelper.GetService("form_printPDFService") as form_printPDFService;
                PDFSerivce.AsposeToPdf(new APIContext()
                {
                    Data = @"{""formId"":""" + data.CaseReport.ID + @""",""formType"":""case_report""}"
                });
            }
            catch (Exception e)
            {
                QueryDb.AbortTransaction();
                throw e;
            }
            QueryDb.CompleteTransaction();
            return(true);
        }
 public form_printPDFService()
 {
     _converter       = SysContext.GetService <IConverter>();
     OnGetAPIHandler += form_printPDFService_OnGetAPIHandler;
 }
Esempio n. 5
0
        /// <summary>
        /// 撤回待办
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="recordId"></param>
        public void WorkrecordUpdate(string userId, string recordId)
        {
            var ddService = SysContext.GetService <IDingDingServices>();

            ddService.WorkrecordUpdate(userId, recordId);
        }
Esempio n. 6
0
        /// <summary>
        /// 发送待办
        /// </summary>
        /// <param name="userId">钉钉用户id</param>
        /// <param name="title">待办标题</param>
        /// <param name="url">跳转地址</param>
        /// <param name="formTitle">待办表单标题</param>
        /// <param name="fromContent">待办表单内容</param>
        public string CreateWorkrecor(string userId, string title, string url, Dictionary <string, string> formInfo)
        {
            var ddService = SysContext.GetService <IDingDingServices>();

            return(ddService.CreateWorkrecor(userId, title, url, formInfo));
        }