Exemplo n.º 1
0
 public static void SaveTask(TaskDto task)
 {
     using (SqlConnection conn = new SqlConnection(TasksDB))
     {
         conn.Open();
         SqlCommand comm = new SqlCommand("INSERT INTO [dbo].[Tasks]([ProcInstID],[Folio],[Originator],[SharedUser],[ActivityName],[ProcessName],[Destination],[SN],[BusinessData],[Data],[ParamsTable],[Actions],[Status],[State],[CreationTime],[SendTime]) values(@ProcInstID,@Folio,@Originator,@SharedUser,@ActivityName,@ProcessName,@Destination,@SN,@BusinessData,@Data,@ParamsTable,@Actions,@Status,@State,@CreationTime,@SendTime)", conn);
         //@ProcInstID,@Folio,@ActivityName,@ProcessName,@Destination,@SN,@BusinessData,@Data,@Status,@State,@CreationTime,@SendTime
         comm.Parameters.Add(new SqlParameter("@ProcInstID", SqlNull(task.ProcInstID)));
         comm.Parameters.Add(new SqlParameter("@Folio", SqlNull(task.Folio)));
         comm.Parameters.Add(new SqlParameter("@Originator", SqlNull(task.Originator)));
         comm.Parameters.Add(new SqlParameter("@SharedUser", SqlNull(task.SharedUser)));
         comm.Parameters.Add(new SqlParameter("@ActivityName", SqlNull(task.ActivityName)));
         comm.Parameters.Add(new SqlParameter("@ProcessName", SqlNull(task.ProcessName)));
         comm.Parameters.Add(new SqlParameter("@Destination", SqlNull(task.Destination)));
         comm.Parameters.Add(new SqlParameter("@SN", SqlNull(task.SN)));
         comm.Parameters.Add(new SqlParameter("@BusinessData", task.BusinessData));
         comm.Parameters.Add(new SqlParameter("@Data", SqlNull(task.Data)));
         comm.Parameters.Add(new SqlParameter("@ParamsTable", SqlNull(task.ParamsTable)));
         comm.Parameters.Add(new SqlParameter("@Actions", SqlNull(task.Actions)));
         comm.Parameters.Add(new SqlParameter("@Status", SqlNull(task.Status)));
         comm.Parameters.Add(new SqlParameter("@State", SqlNull(task.State)));
         comm.Parameters.Add(new SqlParameter("@CreationTime", SqlNull(task.CreationTime)));
         comm.Parameters.Add(new SqlParameter("@SendTime", SqlNull(task.SendTime)));
         int i = comm.ExecuteNonQuery();
         conn.Close();
     }
 }
Exemplo n.º 2
0
        public void QuanShiPush()
        {
            TaskDto task = new TaskDto()
            {
                ID = 12,
                ActivityName = "主管领导审批",
                Data = @"/ExpenseClaim/Expense/Index?_FormId=568&SN=568_17",
                Destination = @"DENALLIX\jackf",
                Folio = "EC-201601280030",
                Originator = @"DENALLIX\Anthony",
                ParamsTable = "{'IsUsingCar':false,'FormId':568}",
                ProcessName = "ExpenseClaim",
                ProcInstID = 519,
                State = "K2",
                SN = "568_17",
                SendTime = DateTime.Now
            };
            try
            {
                TaskPush.QuanShiPush(task, new string[] { "同意", "拒绝" }, null);
            }
            catch (Exception ex)
            {

                throw ex;
            }

        }
Exemplo n.º 3
0
        public static int QuanShiPush(TaskDto task, string[] actions, log4net.ILog logger)
        {
            //_sem.Wait();
            try
            {
                //var CreateQuanShiToKenAsync = TaskPush.CreateQuanShiToKenAsync();
                //_sem.Wait();
                string data = TaskPush.CreateQuanShiToKen();
                LoginRequestModel re = new LoginRequestModel();
                re = JsonConvert.DeserializeObject<LoginRequestModel>(data);

                if (re.crrorCode == 0)
                {
                    OANewsModel oa = new OANewsModel();
                    oa.username = re.data.username;
                    oa.token = re.data.token;
                    OANewsDataModel oaData = new OANewsDataModel();
                    List<string> users = new List<string>();
                    if (string.IsNullOrEmpty(IsEmail))
                    {
                        users.Add(task.Destination.Replace(WindowDomain + @"\", ""));
                    }
                    else
                    {
                        users.Add(task.Destination.Replace(WindowDomain + @"\", "") + IsEmail);
                    }
                    oaData.toUsers = users.ToArray();
                    oaData.toPartyIds = new int[] { };
                    oaData.appId = 136;
                    oaData.title = task.Folio;
                    oaData.color = "red";
                    oaData.status = 11;
                    oaData.elements = new List<object>();
                    string sharedUser = string.IsNullOrEmpty(task.SharedUser) ? "null" : task.SharedUser;
                    oaData.detailURL = string.Format(TaskUrl + "task/{0}/{1}/{2}/{3}", task.SN, task.ProcInstID, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser);
                    oaData.detailAuth = 1;
                    //申请信息
                    OANewsDataTextRichModel text1 = new OANewsDataTextRichModel();
                    text1.type = "text";
                    //text1.status = 11;
                    text1.content = new List<OANewsDataTextContentModel>();
                    OANewsDataTextContentModel content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "申请信息" };
                    text1.content.Add(content);
                    oaData.elements.Add(text1);

                    OANewsDataTextModel text6 = new OANewsDataTextModel() { type = "text", content = " " };
                    oaData.elements.Add(text6);

                    //申请人
                    OANewsDataTextRichModel text2 = new OANewsDataTextRichModel();
                    text2.type = "text";
                    //text2.status = 11;
                    text2.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { bold = 1, text = "申请人:" };
                    text2.content.Add(content);
                    content = new OANewsDataTextContentModel() { bold = 0, text = task.Originator };
                    text2.content.Add(content);
                    oaData.elements.Add(text2);

                    OANewsDataTextRichModel text3 = new OANewsDataTextRichModel();
                    text3.type = "text";
                    //text3.status = 11;
                    text3.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { bold = 1, text = "申请时间:" };
                    text3.content.Add(content);
                    content = new OANewsDataTextContentModel() { bold = 0, text = task.StartDate.ToString("yyyy-MM-dd HH:mm") };
                    text3.content.Add(content);
                    oaData.elements.Add(text3);

                    OANewsDataTextRichModel text4 = new OANewsDataTextRichModel();
                    text4.type = "text";
                    //text4.status = 11;
                    text4.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { bold = 1, text = "当前环节:" };
                    text4.content.Add(content);
                    content = new OANewsDataTextContentModel() { bold = 0, text = task.ActivityName };
                    text4.content.Add(content);
                    oaData.elements.Add(text4);
                    OANewsDataTextModel text7 = new OANewsDataTextModel() { type = "text", content = " " };
                    oaData.elements.Add(text7);
                    //操作
                    OANewsDataTextRichModel text5 = new OANewsDataTextRichModel();
                    text5.type = "text";
                    text5.status = 11;
                    text5.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "操作" };
                    text5.content.Add(content);
                    oaData.elements.Add(text5);

                    //操作
                    OANewsDataTextRichModel text11 = new OANewsDataTextRichModel();
                    text11.type = "text";
                    text11.status = 12;
                    text11.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "操作" };
                    text11.content.Add(content);
                    oaData.elements.Add(text11);

                    OANewsDataTextRichModel text10 = new OANewsDataTextRichModel();
                    text10.type = "text";
                    text10.status = 12;
                    text10.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { color = "#FF0000", bold = 1, text = "审批过程中出现错误,请重试或联系管理员处理!" };
                    text10.content.Add(content);
                    oaData.elements.Add(text10);
                    // status=11
                    OANewsDataActionModel action = new OANewsDataActionModel();
                    action.type = "action";
                    action.status = 11;
                    action.buttons = new List<OANewsDataButtonModel>();

                    Guid sysId = Guid.NewGuid();
                    foreach (var item in actions)
                    {

                        string actionUrl = string.Format(TaskUrl + "quanShiExecuteTask?ActionName={0}&SN={1}&Destination={2}&SharedUser={3}&ProcInstID={4}", System.Web.HttpUtility.UrlEncode(item), task.SN, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser, sysId);
                        OANewsDataButtonModel button = new OANewsDataButtonModel() { title = item, url = actionUrl };
                        action.buttons.Add(button);
                    }
                    oaData.elements.Add(action);

                    // status=11
                    action = new OANewsDataActionModel();
                    action.type = "action";
                    action.status = 12;
                    action.buttons = new List<OANewsDataButtonModel>();
                    foreach (var item in actions)
                    {

                        string actionUrl = string.Format(TaskUrl + "quanShiExecuteTask?ActionName={0}&SN={1}&Destination={2}&SharedUser={3}&ProcInstID={4}", System.Web.HttpUtility.UrlEncode(item), task.SN, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser, sysId);
                        OANewsDataButtonModel button = new OANewsDataButtonModel() { title = item, url = actionUrl };
                        action.buttons.Add(button);
                    }
                    oaData.elements.Add(action);



                    //状态
                    OANewsDataTextRichModel text8 = new OANewsDataTextRichModel();
                    text8.type = "text";
                    text8.status = 1;
                    text8.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { bold = 1, color = "#808080", text = "状态:" };
                    text8.content.Add(content);
                    content = new OANewsDataTextContentModel() { bold = 0, color = "#FF0000", text = "已处理" };
                    text8.content.Add(content);
                    oaData.elements.Add(text8);

                    OANewsDataTextRichModel text9 = new OANewsDataTextRichModel();
                    text9.type = "text";
                    text9.status = 9;
                    text9.content = new List<OANewsDataTextContentModel>();
                    content = new OANewsDataTextContentModel() { bold = 1, color = "#808080", text = "状态:" };
                    text9.content.Add(content);
                    content = new OANewsDataTextContentModel() { bold = 0, color = "#FF0000", text = "任务已经被处理" };
                    text9.content.Add(content);
                    oaData.elements.Add(text9);

                    oa.data = oaData;
                    string psp = JsonConvert.SerializeObject(oa);
                    //var CreateQuanShiOAAsync = TaskPush.CreateQuanShiOAAsync(psp);
                    string dataCheck = TaskPush.PostWebRequest(QuanShiOASendAPIUrl, psp, Encoding.UTF8);
                    JObject obj = JObject.Parse(dataCheck);
                    if (obj["errorCode"].ToString() == "0")
                    {
                        QuanShiMsgModel msg = new QuanShiMsgModel() { sysId = sysId.ToString(), msgId = obj["data"][0]["msgId"].ToString() };
                        SaveMsgId(msg);
                        logger.Info("QuanShiPush_任务推送请求成功,请求消息:" + psp + ";返回消息:" + dataCheck);

                    }
                    else
                    {
                        logger.Error("QuanShiPush_任务推送请求失败,请求消息:" + psp + ";返回消息:" + dataCheck);
                    }
                }
                //_sem.Release();
                return 1;
            }
            catch (Exception ex)
            {
                logger.Error("QuanShiPush_请求失败,在执行过程中出现异常", ex);
                //_sem.Release();
                return 2;
            }
        }
Exemplo n.º 4
0
        public void PostTask([FromBody]WorkItemArgs work)
        {
            logger.Warn("有任务了,内容:" + JsonConvert.SerializeObject(work));
            try
            {
                string[] arrUrl = work.Task.Data.Split('?');
                string sn = null, sharedUser = null, action = null;
                DateTime thisDate = DateTime.Now;
                if (arrUrl.Length > 1)
                {
                    string queryString = arrUrl[1];
                    NameValueCollection col = TaskPush.GetQueryString(queryString);
                    sn = col["SN"];
                    sharedUser = col["SharedUser"];
                }
                else
                {
                    logger.Warn("获取不到SN号,Url:" + work.Task.Data);
                }
                if (work.Actions.Length > 0)
                {
                    for (int i = 0; i < work.Actions.Length; i++)
                    {
                        action += work.Actions[i] + ",";
                    }
                    action = action.Trim(',');
                }
                foreach (var item in work.Users)
                {

                    TaskDto task = new TaskDto()
                    {
                        Actions = action,
                        ActivityName = work.Task.ActivityName,
                        BusinessData = "",
                        CreationTime = thisDate,
                        Data = work.Task.Data,
                        Destination = item.Name,
                        Folio = work.Task.Folio,
                        Originator = work.Task.Originator,
                        ParamsTable = work.Task.ParamsTable,
                        ProcessName = work.Task.ProcessName,
                        ProcInstID = work.Task.ProcInstID,
                        SendTime = DateTime.MaxValue,
                        SharedUser = sharedUser,
                        SN = sn,
                        State = work.Task.State,
                        Status = TaskPushStatus.Create.ToString(),
                        StartDate = work.Task.StartDate
                    };
                    TaskPush.SaveTask(task);
                    var stask = Task.Run(() =>
                    {
                        return TaskPush.QuanShiPush(task, work.Actions, logger);
                    });
                    //TaskPush.QuanShiPush(task, work.Actions, logger);
                }
                logger.Warn("推送,保存推送任务成功!" + JsonConvert.SerializeObject(work));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }