Esempio n. 1
0
        /// <summary>
        /// 调用OA接口服务
        /// </summary>
        /// <returns></returns>
        public ResultInfo OAServiceDelete(string requestid)
        {
            //参数1:准入码,参数2:json
            string  OACode = PubFunction.GetOACode();
            string  result = string.Empty;
            string  IsTest = PubFunction.IsOATest();
            ILogger logger = LoggerManager.GetLogger(typeof(CacheManager));

            if (IsTest == "是")//测试环境
            {
                OAWorkflowService4Test.WorkflowServiceToOtherSystemPortTypeClient service = new OAWorkflowService4Test.WorkflowServiceToOtherSystemPortTypeClient();
                try
                {
                    result = service.deleteWorkflow(OACode, requestid);
                    logger.Error("调用OA审批内网测试接口成功,返回的结果为:" + result);
                }
                catch (Exception ex)
                {
                    logger.Error("调用OA审批内网测试接口出错,错误信息为:" + ex.Message);
                    throw new Exception("调用OA审批内网测试接口出错,错误信息为:" + ex.Message);
                }
            }
            else//生产环境
            {
                OAWorkflowService.WorkflowServiceToOtherSystemPortTypeClient service = new OAWorkflowService.WorkflowServiceToOtherSystemPortTypeClient();
                try
                {
                    result = service.deleteWorkflow(OACode, requestid);
                    logger.Error("调用OA审批接口成功,返回的结果为:" + result);
                }
                catch (Exception ex)
                {
                    logger.Error("调用OA审批接口出错,错误信息为:" + ex.Message);
                    throw new Exception("调用OA审批接口出错,错误信息为:" + ex.Message);
                }
            }


            //将OA接口返回结果转成对象
            ResultInfo OAResult = JsonHelper.JsonDeserialize <ResultInfo>(result);

            logger.Error("删除OA审批流返回结果:" + result);
            if (OAResult.type == "1")
            {
                logger.Error("OA接口返回错误,错误信息为:" + OAResult.backmsg);
                throw new Exception("OA接口返回错误,错误信息为:" + OAResult.backmsg);
            }
            return(OAResult);
        }
Esempio n. 2
0
        /// <summary>
        /// 调用OA接口服务
        /// </summary>
        /// <returns></returns>
        public string OAService(string jsson)
        {
            //参数1:准入码,参数2:json
            string  OACode = PubFunction.GetOACode();
            string  result = string.Empty;
            string  IsTest = PubFunction.IsOATest();
            ILogger logger = LoggerManager.GetLogger(typeof(CacheManager));

            if (IsTest == "是")//测试环境
            {
                OAWorkflowService4Test.WorkflowServiceToOtherSystemPortTypeClient service = new OAWorkflowService4Test.WorkflowServiceToOtherSystemPortTypeClient();
                try
                {
                    result = service.createWorkflow(OACode, jsson);
                    logger.Error("调用OA审批内网测试接口成功,返回的结果为:" + result);
                }
                catch (Exception ex)
                {
                    logger.Error("调用OA审批内网测试接口出错,错误信息为:" + ex.Message);
                    throw new Exception("调用OA审批内网测试接口出错,错误信息为:" + ex.Message);
                }
            }
            else//生产环境
            {
                OAWorkflowService.WorkflowServiceToOtherSystemPortTypeClient service = new OAWorkflowService.WorkflowServiceToOtherSystemPortTypeClient();
                try
                {
                    result = service.createWorkflow(OACode, jsson);
                    logger.Error("调用OA审批接口成功,返回的结果为:" + result);
                }
                catch (Exception ex)
                {
                    logger.Error("调用OA审批接口出错,错误信息为:" + ex.Message);
                    throw new Exception("调用OA审批接口出错,错误信息为:" + ex.Message);
                }
            }


            //将OA接口返回结果转成对象
            string     OAFlowID = "";
            ResultInfo OAResult = JsonHelper.JsonDeserialize <ResultInfo>(result);

            if (OAResult.type == "1")
            {
                logger.Error("OA接口返回错误,错误信息为:" + OAResult.backmsg);
                throw new Exception("OA接口返回错误,错误信息为:" + OAResult.backmsg);
            }
            else
            {
                //检查结果集
                foreach (ResultList rList in OAResult.resultlist)
                {
                    if (rList.status == "1")
                    {
                        throw new Exception("OA接口返回错误,错误信息为:" + rList.msg);
                        throw new Exception("OA接口返回错误,错误信息为:" + OAResult.backmsg);
                    }
                    OAFlowID = rList.requestid;
                }
            }
            return(OAFlowID);
        }