Beispiel #1
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            //UFIDA.U9.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            UFIDA.U9.MO.Complete.CompleteRpt entity = (UFIDA.U9.MO.Complete.CompleteRpt)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                if (entity.Org.Code == "300")
                {
                    try
                    {
                        string        DocNo       = entity.DocNo;
                        string        result      = "";
                        string        content     = HttpMethod.PostMethod("http://192.168.30.8:9090/MXQHService/common.asmx/DoBefore", GenPara("ExecPlan", "CompleteRpt", "GetQty", "{WorkOrder:'" + entity.MO.DocNo + "'}"));
                        MesReturnData r           = Newtonsoft.Json.JsonConvert.DeserializeObject <MesReturnData>(content);
                        int           CompleteQty = 0;
                        if (r.data.Count == 0)
                        {
                            CompleteQty = 0;
                        }
                        else
                        {
                            CompleteQty = r.data[0].CompleteQty;
                        }
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", entity.MO.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("CompleteQty", CompleteQty, ParameterDirection.Input, DbType.Int32, 64));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MOCompleteQtyAI", dp);
                        result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Beispiel #2
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            //UFIDA.U9.InvDoc.TransferIn.TransferIn transferIn = (UFIDA.U9.InvDoc.TransferIn.TransferIn)key.GetEntity();
            UFIDA.U9.MO.Complete.CompleteRpt entity = (UFIDA.U9.MO.Complete.CompleteRpt)key.GetEntity();
            if (entity == null)
            {
                return;
            }
            else
            {
                if (entity.Org.Code == "300")
                {
                    try
                    {
                        //校验mes是否完工足够的数量
                        string        DocNo       = entity.DocNo;
                        string        result      = "";
                        string        content     = HttpMethod.PostMethod("http://192.168.30.8:9090/MXQHService/common.asmx/DoBefore", GenPara("ExecPlan", "CompleteRpt", "GetQty", "{WorkOrder:'" + entity.MO.DocNo + "'}"));
                        MesReturnData r           = Newtonsoft.Json.JsonConvert.DeserializeObject <MesReturnData>(content);
                        int           CompleteQty = 0;
                        if (r.data.Count == 0)
                        {
                            CompleteQty = 0;
                        }
                        else
                        {
                            CompleteQty = r.data[0].CompleteQty;
                        }
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", entity.MO.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("CompleteQty", CompleteQty, ParameterDirection.Input, DbType.Int32, 64));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MOCompleteQtyAU", dp);
                        result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }

                        //流程触发到OA
                        if (entity.DocState == UFIDA.U9.MO.Enums.CompleteRptStateEnum.Approving && entity.OriginalData.DocState == UFIDA.U9.MO.Enums.CompleteRptStateEnum.Opened && entity.DocType.DescFlexField.PrivateDescSeg1 == "1")
                        {
                            Dictionary <string, object> dicResult = new Dictionary <string, object>();
                            Dictionary <string, object> dicMain   = new Dictionary <string, object>();
                            User user = User.Finder.FindByID(Context.LoginUserID);//U9用户信息
                            #region OA信息
                            BaseInfo baseInfo;
                            if (entity.DescFlexField.PrivateDescSeg3 == "是")//驳回后提交
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("10"), entity.ID.ToString(), 1, entity.DescFlexField.PrivateDescSeg2, 1, "完工报告:" + entity.DocNo);
                            }
                            else//非驳回提交
                            {
                                baseInfo = Auctus.Common.Utils.GenerateOABaseInfo(user.Code, PubFunction.GetOAInfoByCode("10"), entity.ID.ToString(), 1, "", 1, "完工报告:" + entity.DocNo);
                            }
                            #endregion
                            dicMain = GenerateMainInfo(entity, user.Code);
                            dicResult.Add("base", baseInfo);
                            dicResult.Add("main", dicMain);
                            List <Dictionary <string, object> > li = new List <Dictionary <string, object> >();
                            li.Add(dicResult);
                            string json = JsonHelper.GetJsonJS(li);
                            Utils.LogError("完工报告JSON");
                            Utils.LogError(json);
                            PubFunction pubFun   = new PubFunction();
                            string      OAFlowID = pubFun.OAService(json);
                            //更新扩展字段:OA流程ID和是否驳回
                            string sql = string.Format("update MO_CompleteRpt set DescFlexField_PrivateDescSeg3='否',DescFlexField_PrivateDescSeg2='{0}' where ID={1}", OAFlowID, entity.ID);
                            DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sql, null);//更新sql
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }