コード例 #1
0
        public override Model.DealResult BrokerInvoker(U8ApiBroker broker)
        {
            Model.DealResult dr = new Model.DealResult();
            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();
                return(dr);
            }
            System.Boolean result    = Convert.ToBoolean(broker.GetReturnValue());
            System.String  errMsgRet = broker.GetResult("errMsg") as System.String;
            if (!result)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = "API错误:" + errMsgRet;
                if (errMsgRet == "" || errMsgRet == null) //如果是空是可用量检查不过
                {
                    throw new Exception("API错误:可用量检查不通过");
                }
                else
                {
                    throw new Exception("API错误:" + errMsgRet);
                }
            }

            try
            {
                System.String VouchIdRet = broker.GetResult("VouchId") as System.String;
                dr.VouchIdRet = VouchIdRet;
            }
            catch { }
            MSXML2.IXMLDOMDocument2 domMsgRet = broker.GetResult("domMsg") as MSXML2.IXMLDOMDocument2;
            broker.Release();

            return(dr);
        }
コード例 #2
0
ファイル: PurchaseOp.cs プロジェクト: fightx/U8
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override Model.DealResult CancelAudit(Model.APIData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            BusinessObject   domHead = null;
            BusinessObject   domBody = null;

            if (CheckAuditStatus(dt.Cvoucherno, apidata.ConnectInfo.Constring) == false)
            {
                return(dr);
            }

            LoadVouch(apidata, dt, out domHead, out domBody);
            string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            dr = GetU8Login(apidata, u8Login);
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "cancelaudit");
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            broker.SetBoParam("domHead", domHead);

            if (!broker.Invoke())
            {
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;

                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;


                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result = broker.GetReturnValue() as System.String;
            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = "API错误:" + result;
                throw new Exception("API错误" + result);
            }
            broker.Release();

            return(dr);
        }
コード例 #3
0
ファイル: PurchaseOp.cs プロジェクト: fightx/U8
        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <param name="domHead"></param>
        /// <param name="domBody"></param>
        /// <returns></returns>
        public override Model.DealResult LoadVouch(Model.APIData bd, Model.Synergismlogdt dt, out BusinessObject domHead, out BusinessObject domBody)
        {
            domHead = null;
            domBody = null;
            Model.DealResult dr           = new Model.DealResult();
            Model.APIData    apidata      = bd as Model.APIData;
            string           vouchid      = GetCodeorID(dt.Cvoucherno, apidata, "id");
            string           auditaddress = SetApiAddressDelete();

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            GetU8Login(apidata, u8Login);
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "load");
            broker.AssignNormalValue("strWhere", "");
            broker.AssignNormalValue("varVoucherID", vouchid);
            broker.AssignNormalValue("strLocateWhere", "");
            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;


                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }

            System.String result = broker.GetReturnValue() as System.String;
            if (result != string.Empty)
            {
                domHead = broker.GetBoParam("domHead");
                domBody = broker.GetBoParam("domBody");
                domHead.NeedFieldsCheck = false;
                domBody.NeedFieldsCheck = false;
            }
            else
            {
                dr.ResultMsg = "API错误:" + result;
                dr.ResultNum = -1;
                broker.Release();

                BLL.Common.ErrorMsg("", result);
            }
            broker.Release();

            return(dr);
        }
コード例 #4
0
ファイル: PurchaseOp.cs プロジェクト: fightx/U8
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="vouchid"></param>
        /// <returns></returns>
        public override Model.DealResult MakeAudit(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr;
            Model.APIData    apidata = bd as Model.APIData;
            BusinessObject   domHead = null;
            BusinessObject   domBody = null;

            LoadVouch(apidata, dt, out domHead, out domBody);
            domHead.NeedFieldsCheck = false;
            domBody.NeedFieldsCheck = false;
            string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            dr = GetU8Login(apidata, u8Login);
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "audit");
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            broker.SetBoParam("domHead", domHead);

            if (!broker.Invoke())
            {
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;

                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;


                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result = broker.GetReturnValue() as System.String;
            broker.Release();
            if (!string.IsNullOrEmpty(result))
            {
                dr.ResultNum = -1;
                dr.ResultMsg = "API错误:" + result;
                throw new Exception(dr.ResultMsg);
            }
            else
            {
                if (!DAL.Common.SetVerifyDate(bd.ConnectInfo, dt))
                {
                    Log.WriteWinLog("设置单据审核日期失败,Cvouchertype:" + dt.Cvouchertype + ";Cvoucherno:" + dt.Cvoucherno + ".");
                }
            }

            return(dr);
        }
コード例 #5
0
ファイル: PurchaseOp.cs プロジェクト: fightx/U8
        public override Model.DealResult UndoMake(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            try
            {
                CancelAudit(apidata, dt);
            }
            catch (Exception ex)
            {
                Log.WriteWinLog("purchaseop_cancelaudit:" + ex.ToString());
                dr.ResultNum = -1;
                dr.ResultMsg = ex.Message;
                return(dr);
            }
            BusinessObject domHead = null;
            BusinessObject domBody = null;

            LoadVouch(apidata, dt, out domHead, out domBody);
            string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            dr = GetU8Login(apidata, u8Login);
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "delete");
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            broker.SetBoParam("domHead", domHead);
            try
            {
                broker.SetBoParam("domBody", domBody);
            }
            catch { }

            MSXML2.IXMLDOMDocument2 CurDom = new MSXML2.DOMDocument();
            broker.AssignNormalValue("CurDom", CurDom);
            if (!broker.Invoke())
            {
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;

                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;


                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result = broker.GetReturnValue() as System.String;
            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = "API错误:" + result;
                throw new Exception("API错误:" + result);
            }
            broker.Release();

            DAL.Regist   registdal = new DAL.Regist();
            Model.Regist regist    = registdal.GetModel(dt.Accid); //acccode 转 accid
            return(dr);
        }
コード例 #6
0
ファイル: SaleOp.cs プロジェクト: sky-tc/U8
        /// <summary>
        /// 删除单据
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override Model.DealResult UndoMake(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            BusinessObject   domHead = null;
            BusinessObject   domBody = null;

            string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");

            if (string.IsNullOrEmpty(vouchid))
            {
                return(dr);
            }

            try
            {
                CancelAudit(apidata, dt);
            }
            catch (Exception ex)
            {
                Log.WriteWinLog("saleop_cancelaudit:" + ex.ToString());
                dr.ResultNum = -1;
                dr.ResultMsg = ex.Message;
                return(dr);
            }
            LoadVouch(apidata, dt, out domHead, out domBody);
            domHead.NeedFieldsCheck = false;
            domBody.NeedFieldsCheck = false;

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            dr = GetU8Login(apidata, u8Login);
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "delete");
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            broker.SetBoParam("domHead", domHead);
            try
            {
                broker.SetBoParam("dombodyforlog", domBody);
            }
            catch { }
            if (!broker.Invoke())
            {
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }
                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }
                broker.Release();

                return(dr);
            }
            System.String result = broker.GetReturnValue() as System.String;
            broker.Release();
            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = result;
                throw new Exception(result);
            }

            return(dr);
        }
コード例 #7
0
        public static string InsertProduct(DataTable dthead, DataTable dtbody)
        {
            U8EnvContext envContext = new U8EnvContext();

            envContext.U8Login = canshu.u8Login;
            //envContext.U8Login = u8Login;
            //第三步:设置API地址标识(Url)
            //当前API:添加新单据的地址标识为:U8API/MaterialOut/Add
            U8ApiAddress myApiAddress = new U8ApiAddress("U8API/ARClose/SaveVouch");

            //第四步:构造APIBroker
            U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);

            //第五步:API参数赋值

            ////给普通参数sVouchType赋值。此参数的数据类型为System.String,此参数按值传递,表示单据类型:11
            //broker.AssignNormalValue("sVouchType", "11");
            ////该参数VouchId为INOUT型普通参数。此参数的数据类型为System.String,此参数按值传递。在API调用返回时,可以通过GetResult("VouchId")获取其值
            //string vouid = "";
            //broker.AssignNormalValue("VouchId", vouid);

            ////该参数domMsg为OUT型参数,由于其数据类型为MSXML2.IXMLDOMDocument2,非一般值类型,因此必须传入一个参数变量。在API调用返回时,可以直接使用该参数


            MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocumentClass();
            broker.AssignNormalValue("domMsg", domMsg);

            ////给普通参数bCheck赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示是否控制可用量。
            //broker.AssignNormalValue("bCheck", true);

            ////给普通参数bBeforCheckStock赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示检查可用量
            //broker.AssignNormalValue("bBeforCheckStock", true);


            ////给普通参数bIsRedVouch赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示是否红字单据
            //broker.AssignNormalValue("bIsRedVouch", false);

            ////给普通参数sAddedState赋值。此参数的数据类型为System.String,此参数按值传递,表示传空字符串
            //string sadd = "";
            //broker.AssignNormalValue("sAddedState", sadd);

            ////给普通参数bReMote赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示是否远程:转入false
            //broker.AssignNormalValue("bReMote", false);

            //打开adodb连接
            Connection oCon = new ConnectionClass();

            oCon.Open(envContext.U8Login.UfDbName);
            MSXML2.IXMLDOMDocument2 domhead = new DOMDocument();
            MSXML2.IXMLDOMDocument2 dombody = new DOMDocument();
            //表头赋值


            //表头DOM赋值
            string    sqlt = "select cast(null as nvarchar(2)) as editprop,* from AR_CloseR where 1=2 ";
            Recordset rs   = new Recordset();

            rs.Open(sqlt, oCon, CursorTypeEnum.adOpenForwardOnly, LockTypeEnum.adLockReadOnly);
            rs.Save(domhead, PersistFormatEnum.adPersistXML);
            //插入表头信息
            IXMLDOMElement eleHead = (IXMLDOMElement)domhead.selectSingleNode("//rs:data");
            IXMLDOMElement ele     = (IXMLDOMElement)domhead.createElement("z:row");

            eleHead.appendChild(ele);

            try
            {
                ele.setAttribute("editprop", "A");//A代表增加,M代表修改

                ele.setAttribute("dVouchDate", DateTime.Now.ToShortDateString());
                ele.setAttribute("cdwcode", "0999");
                //ele.setAttribute("id", rdid);
                ele.setAttribute("ccode", "100");
                ele.setAttribute("VT_ID", "65");
                ele.setAttribute("ddate", DateTime.Now.ToShortDateString());    //出库日期


                ele.setAttribute("dnmaketime", DateTime.Now.ToString()); //制单日期
                ele.setAttribute("cmemo", "下料生成");                       //备注
                ele.setAttribute("cmaker", canshu.u8Login.cUserName);    //制单人


                broker.AssignNormalValue("DomHead", domhead);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误发生", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return("0");
            }



            //表体赋值
            string sqlw = "select cast(null as nvarchar(2)) as editprop,* from recordoutsq where 1=2 ";

            //Recordset rs = new Recordset();
            rs.Close();
            rs.Open(sqlw, oCon, CursorTypeEnum.adOpenForwardOnly, LockTypeEnum.adLockReadOnly);
            rs.Save(dombody, PersistFormatEnum.adPersistXML);
            //插入表体尾信息
            //dombody.rowcount =
            IXMLDOMElement eleBody = (IXMLDOMElement)dombody.selectSingleNode("//rs:data");

            for (int i = 0; i < dtbody.Rows.Count; i++)
            {
                ele = (IXMLDOMElement)dombody.createElement("z:row");
                eleBody.appendChild(ele);

                // 表尾赋值

                //string cinvcode = "01019002063";
                //int autoid = 1000;
                //decimal sl = 4m;
                try
                {
                    ele.setAttribute("editprop", "A");
                    //ele.setAttribute("autoid", autoid);
                    ele.setAttribute("cinvcode", DbHelper.GetDbString(dtbody.Rows[i]["存货编码"]));
                    if (string.IsNullOrEmpty(DbHelper.GetDbString(dtbody.Rows[i]["lotno"])) != true)
                    {
                        ele.setAttribute("cBatch", DbHelper.GetDbString(dtbody.Rows[i]["lotno"]));
                    }

                    ele.setAttribute("iquantity", DbHelper.GetDbString(dtbody.Rows[i]["本次下料"]));
                    //MessageBox.Show(dtbody.Rows[i]["本次下料"].ToString());
                    ele.setAttribute("iMPoIds", DbHelper.GetDbInt(dtbody.Rows[i]["allocateid"]));
                    ele.setAttribute("cmocode", DbHelper.GetDbString(dthead.Rows[0]["染料单号"]));
                    ele.setAttribute("inquantity", DbHelper.GetDbdecimal(dtbody.Rows[i]["未下数量"])); //未下应下数量
                    //生产订单信息
                    ele.setAttribute("invcode", DbHelper.GetDbString(dthead.Rows[0]["色号"]));
                    ele.setAttribute("imoseq", DbHelper.GetDbString(dthead.Rows[0]["sortseq"]));
                    ele.setAttribute("iopseq", DbHelper.GetDbString(dtbody.Rows[i]["opseq"]));
                    ele.setAttribute("copdesc", DbHelper.GetDbString(dtbody.Rows[i]["工序"]));
                    ele.setAttribute("iExpiratDateCalcu", 0);
                    ele.setAttribute("irowno", i + 1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误发生", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return("0");
                }
            }

            broker.AssignNormalValue("DomBody", dombody);

            //测试结果
            //domhead.save(@"d:\2xml");
            //dombody.save(@"d:\3.xm.l");

            //第六步:调用API
            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        MessageBox.Show("系统异常:" + sysEx.Message);
                        //todo:异常处理
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        MessageBox.Show("API异常:" + bizEx.Message);
                        //todo:异常处理
                    }
                    //异常原因
                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        MessageBox.Show("异常原因:" + exReason);
                    }
                }
                //结束本次调用,释放API资源
                broker.Release();
                return("0");
            }

            //第七步:获取返回结果

            //获取返回值
            //获取普通返回值。此返回值数据类型为System.Boolean,此参数按值传递,表示返回值:true:成功,false:失败
            System.Boolean result = Convert.ToBoolean(broker.GetReturnValue());

            if (result == false)
            {
                //获取普通OUT参数errMsg。此返回值数据类型为System.String,在使用该参数之前,请判断是否为空
                System.String errMsgRet = broker.GetResult("errMsg") as System.String;
                if (errMsgRet != null)
                {
                    MessageBox.Show(errMsgRet.ToString(), "错误提示1!");
                }
                return("2");
                //MessageBox.Show(result.ToString(), "导入成功提示");
            }
            ////获取out/inout参数值

            ////获取普通OUT参数errMsg。此返回值数据类型为System.String,在使用该参数之前,请判断是否为空
            //System.String errMsgRet = broker.GetResult("errMsg") as System.String;
            //if (errMsgRet != null)
            //    MessageBox.Show(errMsgRet.ToString(), "错误提示1!");

            ////获取普通INOUT参数VouchId。此返回值数据类型为System.String,在使用该参数之前,请判断是否为空
            System.String VouchIdRet = broker.GetResult("VouchId") as System.String;

            ////获取普通OUT参数domMsg。此返回值数据类型为MSXML2.IXMLDOMDocument2,在使用该参数之前,请判断是否为空
            //MSXML2.IXMLDOMDocument2 domMsgRet = (broker.GetResult("domMsg")) as MSXML2.IXMLDOMDocument2;
            //if (domMsgRet != null)
            //    MessageBox.Show(domMsgRet.ToString(), "错误提示2!");
            //结束本次调用,释放API资源
            broker.Release();
            return(VouchIdRet);
        }
コード例 #8
0
ファイル: Form1.cs プロジェクト: anchengw/u8dev
        /// <summary>
        /// 销售订单:装载单据
        /// </summary>
        public void LoadSaleOrder(string vouchID)
        {
            try
            {
                //第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
                U8EnvContext envContext = new U8EnvContext();
                envContext.U8Login = u8Login;

                //销售所有接口均支持内部独立事务和外部事务,默认内部事务
                //如果是外部事务,则需要传递ADO.Connection对象,并将IsIndependenceTransaction属性设置为false
                //envContext.BizDbConnection = new ADO.Connection();
                //envContext.IsIndependenceTransaction = false;

                //设置上下文参数
                envContext.SetApiContext("VoucherType", 12); //上下文数据类型:int,含义:单据类型:12

                //第三步:设置API地址标识(Url)
                //当前API:装载单据的地址标识为:U8API/SaleOrder/Load
                U8ApiAddress myApiAddress = new U8ApiAddress("U8API/SaleOrder/Load");

                //第四步:构造APIBroker
                U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);

                //第五步:API参数赋值

                //给普通参数VouchID赋值。此参数的数据类型为string,此参数按值传递,表示单据号
                broker.AssignNormalValue("VouchID", vouchID);

                //给普通参数blnAuth赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示是否控制权限:true
                broker.AssignNormalValue("blnAuth", true);

                //第六步:调用API
                if (!broker.Invoke())
                {
                    //错误处理
                    Exception apiEx = broker.GetException();
                    if (apiEx != null)
                    {
                        if (apiEx is MomSysException)
                        {
                            MomSysException sysEx = apiEx as MomSysException;
                            Console.WriteLine("系统异常:" + sysEx.Message);
                            //todo:异常处理
                        }
                        else if (apiEx is MomBizException)
                        {
                            MomBizException bizEx = apiEx as MomBizException;
                            Console.WriteLine("API异常:" + bizEx.Message);
                            //todo:异常处理
                        }
                        //异常原因
                        String exReason = broker.GetExceptionString();
                        if (exReason.Length != 0)
                        {
                            Console.WriteLine("异常原因:" + exReason);
                        }
                    }
                    //结束本次调用,释放API资源
                    broker.Release();
                    //return null;
                }

                //第七步:获取返回结果

                //获取返回值
                //获取普通返回值。此返回值数据类型为System.String,此参数按值传递,表示成功为空串
                System.String result = broker.GetReturnValue() as System.String;
                //throw new Exception(result);
                if (!string.IsNullOrEmpty(result))
                {
                    throw new Exception(result);
                }
                //获取out/inout参数值

                //out参数domHead为BO对象(表头),此BO对象的业务类型为销售订单。BO参数均按引用传递,具体请参考服务接口定义
                //如果要取原始的XMLDOM对象结果,请使用GetResult("domHead") as MSXML2.DOMDocument
                BusinessObject domHeadRet = broker.GetBoParam("domHead");
                Console.WriteLine("BO对象(表头)行数为:" + domHeadRet.RowCount); //获取BO对象(表头)的行数
                //获取BO对象(表头)各字段的值。字段定义详见API服务接口定义

                //MSXML2.DOMDocument domHead = broker.GetResult("domHead") as MSXML2.DOMDocument;

                //out参数domBody为BO对象(表体),此BO对象的业务类型为销售订单。BO参数均按引用传递,具体请参考服务接口定义
                //如果要取原始的XMLDOM对象结果,请使用GetResult("domBody") as MSXML2.DOMDocument
                BusinessObject domBodyRet = broker.GetBoParam("domBody");
                Console.WriteLine("BO对象(表体)行数为:" + domBodyRet.RowCount); //获取BO对象(表体)的行数
                //获取BO对象(表体)各字段的值。以下代码示例只取第一行。字段定义详见API服务接口定义

                //MSXML2.DOMDocument domBody = broker.GetResult("domBody") as MSXML2.DOMDocument;


                //结束本次调用,释放API资源
                broker.Release();

                /*
                 * SO_SOMain so_somain = EntityConvert.ToSO_SOMain(domHeadRet[0]);
                 * SO_SODetails so_sodetail;
                 * for (int i = 0; i < domBodyRet.RowCount; i++)
                 * {
                 *  so_sodetail = EntityConvert.ToSO_SODetails(domBodyRet[i]);
                 *  so_sodetail.cSOCode = so_somain.cSOCode;
                 *  so_somain.List.Add(so_sodetail);
                 * }
                 * return so_somain;
                 */
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #9
0
ファイル: SfcOp.cs プロジェクト: sky-tc/U8
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override Model.DealResult MakeAudit(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            //string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");
            string auditaddress = SetApiAddressAudit();

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            GetU8Login(apidata, u8Login);
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "audit");

            broker.AssignNormalValue("mocode", dt.Cvoucherno);

            //第六步:调用API
            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        Console.WriteLine("系统异常:" + sysEx.Message);
                        //todo:异常处理
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        Console.WriteLine("API异常:" + bizEx.Message);
                        //todo:异常处理
                    }
                    //异常原因
                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        Console.WriteLine("异常原因:" + exReason);
                    }
                }
                //结束本次调用,释放API资源
                broker.Release();
                return(dr);
            }

            //第七步:获取返回结果

            //获取返回值
            //获取普通返回值。此返回值数据类型为System.Boolean,此参数按值传递,表示返回值: true:成功, false: 失败
            System.Boolean result = Convert.ToBoolean(broker.GetReturnValue());

            //结束本次调用,释放API资源
            broker.Release();


            //dr = BrokerInvoker(broker);
            if (!DAL.Common.SetVerifyDate(bd.ConnectInfo, dt))
            {
                U8.Interface.Bus.Log.WriteWinLog("设置单据审核日期失败,Cvouchertype:" + dt.Cvouchertype + ";Cvoucherno:" + dt.Cvoucherno + ".");
            }

            return(dr);
        }