Exemplo n.º 1
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var task = ProcessTaskManager.GetAll()
                       .Include(o => o.Tenant)
                       .Include(o => o.ProcessType)
                       .Include(o => o.Part).ThenInclude(o => o.Project)
                       .Where(o => o.Id == args.DataId)
                       .SingleOrDefault();

            if (task != null)
            {
                //图片之前已生成,不进行重新生成
                //ProcessTaskManager.SaveTaskSheetToImage2(task).GetAwaiter().GetResult();
                var config  = _hostingEnvironment.GetAppConfiguration();
                var baseurl = config["base:url"];
                var url     = baseurl + "/MES/OuterTaskView?id=" + task.Id;

                var templateId = "wVpgBt0ziOXX3DwWvqosHb7K2G43G61Xj40aS7iY3R4";//模来模往
                //var templateId = "dltvm7BNLgK9d6KxxMn_Sl6uVuaPkV1ywMdZTiudHkk";//云报工
                if (!string.IsNullOrEmpty(config["TemplateId:SendOuterTask"]))
                {
                    templateId = config["TemplateId:SendOuterTask"];
                }
                var message = new
                {
                    first    = new TemplateDataItem("你好,收到" + task.Tenant.TenancyName + "新的加工任务"),
                    keyword1 = new TemplateDataItem(task.Part.Project.ProjectSN),
                    keyword2 = new TemplateDataItem(task.Part.PartName + task.ProcessType.ProcessTypeName),
                    keyword3 = new TemplateDataItem(task.Part.Project.GetPropertyValue <string>("ProjectCharger")),
                    keyword4 = new TemplateDataItem(task.RequireDate?.ToString("yyyy-MM-dd HH:mm:ss")),
                    remark   = new TemplateDataItem("请及时处理")
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                }
            }
        }
Exemplo n.º 2
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var task = ProcessTaskManager.GetAll()
                       .Include(o => o.Supplier)
                       .Include(o => o.Tenant)
                       .Include(o => o.ProcessType)
                       .Include(o => o.Part)
                       .Where(o => o.Id == args.DataId)
                       .SingleOrDefault();

            if (task != null)
            {
                var config  = _hostingEnvironment.GetAppConfiguration();
                var baseurl = config["base:url"];
                var url     = baseurl + "/MES/wechat/Receiptaudit?taskid=" + task.Id;

                var templateId = "wVpgBt0ziOXX3DwWvqosHb7K2G43G61Xj40aS7iY3R4";//master
                //var templateId= "dltvm7BNLgK9d6KxxMn_Sl6uVuaPkV1ywMdZTiudHkk"//demo
                if (!string.IsNullOrEmpty(config["TemplateId:ReportRemind"]))
                {
                    templateId = config["TemplateId:ReportRemind"];
                }
                var message = new
                {
                    first    = new TemplateDataItem("外协回单提醒"),
                    keyword1 = new TemplateDataItem(task.ProcessSN),
                    keyword2 = new TemplateDataItem(task.Part.PartName + task.ProcessType.ProcessTypeName),
                    keyword3 = new TemplateDataItem(task.Supplier.UnitName),
                    keyword4 = new TemplateDataItem(""),
                    remark   = new TemplateDataItem("请及时处理")
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                }
            }
        }
Exemplo n.º 3
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var task = ProcessTaskManager.GetAll().IgnoreQueryFilters()
                       .Include(o => o.CreatorUser)
                       .Where(o => o.Id == args.DataId)
                       .SingleOrDefault();

            if (task != null)
            {
                var config  = _hostingEnvironment.GetAppConfiguration();
                var baseurl = config["base:url"];
                var url     = baseurl + "/mes/JGKD?taskid=" + task.Id;

                var templateId = "u99i9f5VikTcDUJw4OL1neDcI3Lt2oYl7y5wmIqHQjA";//模来模往
                //var templateId = "8j4xzh_ke3-ikaLx3iNnoY4yn8A-yEBLllrNxTiv7bY";//云报工
                if (!string.IsNullOrEmpty(config["TemplateId:TaskConfirm"]))
                {
                    templateId = config["TemplateId:TaskConfirm"];
                }
                var message = new
                {
                    first    = new TemplateDataItem("你好,收到新的加工开单申请"),
                    keyword1 = new TemplateDataItem(task.Poster),
                    keyword2 = new TemplateDataItem(task.ProjectCharger),
                    keyword3 = new TemplateDataItem(task.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    remark   = new TemplateDataItem("请及时处理")
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                }
            }
        }
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var notice = NoticeManager.GetAll()
                         .IgnoreQueryFilters()
                         .Include(o => o.Tenant)
                         .Where(o => o.Id == args.DataId)
                         .SingleOrDefault();

            if (notice != null)
            {
                var baseurl = HostingEnvironment.GetAppConfiguration()["base:url"];
                var url     = baseurl + "/MES/TenantNoticeView?id=" + args.DataId;

                var templateId = "r5azOIRD5TP2heIi-6TTF29h_0TvyM4gruh4wy4YXMQ";//模来模往
                //var templateId = "MPrQIbyjLaa-grTkEihsEPEWtCUvvguDk6mtmMO0hnc";//云报工
                var message = new
                {
                    first    = new TemplateDataItem($"收到{notice.Tenant.TenancyName}公告消息"),
                    keyword1 = new TemplateDataItem(notice.Tenant.TenancyName),
                    keyword2 = new TemplateDataItem(notice.NoticeTitle),
                    //keyword3 = new TemplateDataItem(processQuote.PublishDate?.ToString("yyyy-MM-dd")),
                    remark = new TemplateDataItem("请及时查看")
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                }
            }
        }
Exemplo n.º 5
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var report = ProcessTaskReportRepository.GetAll().Include(o => o.ProcessTask)
                         .ThenInclude(o => o.Part)
                         .ThenInclude(o => o.Project)
                         .Where(o => o.Id == args.DataId)
                         .SingleOrDefault();

            if (report != null)
            {
                var config   = _hostingEnvironment.GetAppConfiguration();
                var baseurl  = config["base:url"];
                var url      = baseurl + "/MES/ReportView?id=" + report.Id;
                var reporter = _personRepository.Get(report.ReporterId);

                var templateId = "wVpgBt0ziOXX3DwWvqosHb7K2G43G61Xj40aS7iY3R4";//master
                //var templateId= "dltvm7BNLgK9d6KxxMn_Sl6uVuaPkV1ywMdZTiudHkk"//demo
                if (!string.IsNullOrEmpty(config["TemplateId:ReportRemind"]))
                {
                    templateId = config["TemplateId:ReportRemind"];
                }
                var message = new
                {
                    first    = new TemplateDataItem("加工进度提醒"),
                    keyword1 = new TemplateDataItem(report.ProcessTask.Part.Project.ProjectSN),
                    keyword2 = new TemplateDataItem(report.ProcessTask.Part.PartName + report.ProcessTask.ProcessType.ProcessTypeName + report.ReportType.ToString()),
                    keyword3 = new TemplateDataItem(reporter.Name),
                    keyword4 = new TemplateDataItem(report.ReportTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    remark   = new TemplateDataItem(report.Remarks)
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                    Logger.Error(ex.Message, ex);
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                    CurrentUnitOfWork.SaveChanges();
                }
                //如果是失败状态,抛出异常,使后台作业自动重试
                if (sendResult.ErrorCodeValue != 0)
                {
                    throw new Exception("SendError:" + sendResult.ErrorCodeValue);
                }
            }
        }
Exemplo n.º 6
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            var task = ProcessTaskManager.GetAll()
                       .Include(o => o.Supplier)
                       .Include(o => o.ProcessType)
                       .Include(o => o.Part)
                       .ThenInclude(o => o.Project)
                       .Where(o => o.Id == args.DataId)
                       .SingleOrDefault();

            if (task != null)
            {
                var remark    = "";
                var delayType = Enum.Parse <DelayType>(args.ExtendInfo);
                switch (delayType)
                {
                case DelayType.DelayStart:
                    remark = $"预约日期:{task.AppointDate.Value.ToString("yyyy-MM-dd")},任务已延期{(DateTime.Now-task.AppointDate.Value).Days}天未上机";
                    break;

                case DelayType.DelayEnd:
                    remark = $"要求完成日期:{task.RequireDate.Value.ToString("yyyy-MM-dd")},任务已延期{(DateTime.Now - task.RequireDate.Value).Days}天未下机";
                    break;

                case DelayType.ReceiveNotStart:
                    remark = $"到料日期:{task.ReceiveDate.Value.ToString("yyyy-MM-dd")},任务已到料{(DateTime.Now - task.ReceiveDate.Value).Days}天尚未上机";
                    break;
                }
                var templateId = "wVpgBt0ziOXX3DwWvqosHb7K2G43G61Xj40aS7iY3R4";
                var message    = new
                {
                    first    = new TemplateDataItem("延期提醒"),
                    keyword1 = new TemplateDataItem(task.Part.Project.ProjectSN),
                    keyword2 = new TemplateDataItem(task.Part.PartName + task.ProcessType.ProcessTypeName),
                    keyword3 = new TemplateDataItem(task.Supplier?.UnitName),
                    //keyword4 = new TemplateDataItem(report.ReportTime.ToString("yyyy-MM-dd HH:mm:ss")),
                    remark = remark
                };
                SendTemplateMessageResult sendResult;
                try
                {
                    sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, "", message);
                }
                catch (Exception ex)
                {
                    sendResult = new SendTemplateMessageResult()
                    {
                        errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                        errmsg  = ex.Message
                    };
                }
                //更新提醒记录状态
                var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();
                if (remindLog != null)
                {
                    remindLog.Success = sendResult.ErrorCodeValue == 0;
                    remindLog.SetPropertyValue("errCode", sendResult.errcode);
                    remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                    RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
                }
            }
        }
Exemplo n.º 7
0
        public override void Execute(SendWeiXinMessageJobArgs args)
        {
            Logger.Error("\r\n\r\nstart");
            //JObject jo = (JObject)JsonConvert.DeserializeObject(args.ExtendInfo);
            var tenantId        = args.DataId; //Supplier. tenantId
            var arr             = args.ExtendInfo.Split(new string[] { "test123" }, StringSplitOptions.None);
            var taskIds         = arr[0];
            var currentTenantId = arr[1];
            var totalFee        = arr[2];
            var processSNs      = arr[3];

            var q           = TenantManager.GetAll().Where(o => o.Id == Convert.ToInt32(currentTenantId)).SingleOrDefault();
            var currentUser = q.TenancyName;
            var partUrl     = ProcessTaskManager.SaveAccountingSheetToImage(taskIds, currentTenantId, tenantId.ToString()).GetAwaiter().GetResult();

            partUrl = $"/sheets/{currentTenantId}/CountingPic/{tenantId}/{partUrl}.png";
            var config  = _hostingEnvironment.GetAppConfiguration();
            var baseurl = $"{config["base:url"]}";
            //var url = $"{_hostingEnvironment.GetAppConfiguration()["base:url"]}/MES/CountingView?ids={taskIds}&tenantId={tenantId}&currentTenantId={currentTenantId}&partUrl={partUrl}";
            var url = $"{_hostingEnvironment.GetAppConfiguration()["base:url"]}/MES/CountingView?ids={taskIds}&partUrl={partUrl}&signUrl=";
            //var openids = await MESUnitManager.FindUnitOpenId(tenantId);
            var templateId = "dE83qStBxfAAAFMAnn_0t6EknJ8B97L_A7A03LdiYkk";           //master: B2CWkuQKyZDqE4EreiQHqitAYbfU_Njxelremw546lk

            if (!string.IsNullOrEmpty(config["TemplateId:SendCounting"]))
            {
                templateId = config["TemplateId:SendCounting"];
            }
            //var tenantId = AbpSession.GetTenantId();                             //demo:dE83qStBxfAAAFMAnn_0t6EknJ8B97L_A7A03LdiYkk
            //currentUser = AbpSession.GetTenantId();
            //var q = await TenantManager.GetByIdAsync(AbpSession.GetTenantId());
            //var currentUser = q.TenancyName;
            //var url = "";
            var message = new
            {
                first    = new TemplateDataItem("您好,收到" + currentUser + "发来的核算信息"),
                keyword1 = new TemplateDataItem("核算单号:" + processSNs),
                keyword2 = new TemplateDataItem(DateTime.Now.ToString()),
                keyword3 = new TemplateDataItem(totalFee.ToString()),
                keyword4 = new TemplateDataItem(currentUser),
                remark   = new TemplateDataItem("总核算金额为:" + totalFee.ToString() + "元")
            };
            SendTemplateMessageResult sendResult;

            try
            {
                sendResult = WeiXin.WeiXinHelper.SendTemplateMessage(args.OpenId, templateId, url, message);
            }
            catch (Exception ex)
            {
                sendResult = new SendTemplateMessageResult()
                {
                    errcode = Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试,
                    errmsg  = ex.Message
                };
            }
            //更新提醒记录状态
            var remindLog = RemindLogManager.GetAll().IgnoreQueryFilters().Where(o => o.Id == args.RemindLogId).SingleOrDefault();

            if (remindLog != null)
            {
                remindLog.Success = sendResult.ErrorCodeValue == 0;
                remindLog.SetPropertyValue("errCode", sendResult.errcode);
                remindLog.SetPropertyValue("errMsg", sendResult.errmsg);
                RemindLogManager.UpdateAsync(remindLog).GetAwaiter().GetResult();
            }
        }