Exemplo n.º 1
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.º 2
0
        public static void QuanShiPushChange(string sysId, int newStatus, log4net.ILog logger)
        {
            string msgId = GetMsgId(sysId);
            try
            {
                string data = TaskPush.CreateQuanShiToKen();
                LoginRequestModel re = new LoginRequestModel();
                re = JsonConvert.DeserializeObject<LoginRequestModel>(data);
                if (re.crrorCode == 0)
                {
                    OANewsChangeModel ch = new OANewsChangeModel()
                    {
                        username = re.data.username,
                        token = re.data.token
                    };
                    OANewsChangeDataModel item = new OANewsChangeDataModel();
                    item.msgId = msgId;
                    item.newStatus = newStatus;
                    ch.data = item;
                    string psp = JsonConvert.SerializeObject(ch);
                    string dataCheck = TaskPush.PostWebRequest(QuanShiOASendChangeAPIUrl, psp, Encoding.UTF8);
                    JObject obj = JObject.Parse(dataCheck);
                    if (obj["errorCode"].ToString() == "0")
                    {
                        logger.Info("QuanShiPushChange_OA消息状态更新成功,请求数据:" + sysId + ",返回数据:" + dataCheck);
                    }
                    else
                    {
                        logger.Warn("QuanShiPushChange_OA消息状态更新失败,请求数据:" + sysId + ",返回数据:" + dataCheck);
                    }
                }
                else
                {
                    logger.Warn("QuanShiPushChange_管理员登录失败,请求数据:" + sysId + ",返回数据:" + data);
                }

            }
            catch (Exception ex)
            {
                logger.Error("QuanShiPushChange_Login请求失败,在执行过程中出现异常", ex);
            }
        }
Exemplo n.º 3
0
        public JsonResult Login(CheckModel checkModel)
        {
            DataModel dataModel = new DataModel();
            try
            {
                string data = TaskPush.CreateQuanShiToKen();
                LoginRequestModel re = new LoginRequestModel();
                re = JsonConvert.DeserializeObject<LoginRequestModel>(data);
                if (re.crrorCode == 0)
                {
                    //checkModel.token = re.data.token;
                    string username = checkModel.username;
                    string token = checkModel.token;
                    checkModel.username = re.data.username;
                    checkModel.token = re.data.token;
                    List<CheckDataModel> list = new List<CheckDataModel>();
                    CheckDataModel item = new CheckDataModel();
                    item.account = username;
                    item.sessionId = token;
                    list.Add(item);
                    checkModel.data = list;
                    string dataCheck = TaskPush.PostWebRequest(QuanShiCheckAPIUrl, JsonConvert.SerializeObject(checkModel), Encoding.UTF8);
                    JObject obj = JObject.Parse(dataCheck);
                    if (obj["data"][0]["errorCode"].ToString() == "0")
                    {
                        string user = obj["data"][0]["account"].ToString();
                        dataModel.status = RequestStatus.Success;
                        dataModel.message = "";
                        dataModel.data = user; ;//_tasks.Where(t => t.Folio == id).FirstOrDefault();
                        logger.Info("Login请求成功,Lgoin User:" + user);
                        return Json(dataModel, JsonRequestBehavior.AllowGet);
                    }
                    dataModel.status = RequestStatus.Error;
                    dataModel.message = "全时token检查失败,errorCode:" + obj["data"][0]["errorCode"].ToString();
                    dataModel.data = new List<string>();//_tasks.Where(t => t.Folio == id).FirstOrDefault();
                    logger.Error("Login请求失败,在检查session 状态失败,请求account:" + username + ",返回值:" + dataCheck);
                    return Json(dataModel, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    dataModel.status = RequestStatus.Error;
                    dataModel.message = "蜜蜂OpenAPI登录失败,errorCode:" + re.crrorCode.ToString();
                    dataModel.data = new List<string>();
                    logger.Error("Login请求失败,在使用管理员登录蜜蜂Open API失败,错误:" + data +
                        System.Environment.NewLine + "错误信息:" + re.errorMessage);
                    return Json(dataModel, JsonRequestBehavior.AllowGet);
                }

            }
            catch (Exception ex)
            {
                dataModel.status = RequestStatus.Error;
                dataModel.message = "在验证身份时程序出现异常,错误的信息:" + ex.Message +
                  System.Environment.NewLine + "错误详细信息:" + ex.StackTrace;
                dataModel.data = new List<string>();
                logger.Error("Login请求失败,在执行过程中出现异常", ex);
                return Json(dataModel, JsonRequestBehavior.AllowGet);
            }
        }