Exemplo n.º 1
0
    private static ResultInfo defaultEventHandle(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
    {
        SqlPipe pipe = SqlContext.Pipe;

        try
        {
            pipe.Send("defaultEventHandle");
            string strRlt = string.Empty;
            SqlCLRTest.X9WebService.WebService svValidateBM = new SqlCLRTest.X9WebService.WebService();
            svValidateBM.Url = string.Format("http://{0}", busiConfig.ServiceAddress);
            string strDocInfo = XmlSerialize <K3DataParaInfo>(docInfo, Encoding.Unicode);
            pipe.Send(strDocInfo);
            //string strHttpEncoding = HttpUtility.HtmlEncode(strDocInfo);
            strRlt = svValidateBM.SynchBillFromK3ToX9(strDocInfo);

            if (!string.IsNullOrEmpty(strRlt))
            {
                pipe.Send(strRlt);
                //strRlt = strRlt.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
                //string strHttpDecoding = HttpUtility.HtmlDecode(strRlt);
                ResultInfo rltInfo = XmlDeserialize <ResultInfo>(strRlt, Encoding.Unicode);
                return(rltInfo);
            }
            return(null);
        }
        catch (Exception ex)
        {
            //LogInfoHelp.infoLog(eventName, docInfo, string.Format("调用X9系统服务时,异常:{0}", ex.Message));
            pipe.Send(string.Format("Exception cacheDocInfo:{0}", ex.Message));
            return(null);
        }
    }
Exemplo n.º 2
0
        private static ResultInfo defaultEventHandle(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
        {
            SqlPipe pipe = SqlContext.Pipe;

            try
            {
                pipe.Send("defaultEventHandle");
                string strRlt = string.Empty;

                //WindowsIdentity windowsIdentity = null;
                //WindowsImpersonationContext userImpersonated = null;
                //windowsIdentity = SqlContext.WindowsIdentity;

                //// Switch the context to local service account user (a domain user)
                //// by getting its identity in order to call the web service
                //userImpersonated = windowsIdentity.Impersonate();

                //if (userImpersonated != null)
                //{
                //    // Create the instance of a web service to be called. // Remember this is not actual // CAAT search web service but a similar fake web service just for testing.
                //    pipe.Send("create service");
                //    X9WebService.WebService svValidateBM = new X9WebService.WebService();
                //    pipe.Send("end service");
                //    svValidateBM.Url = string.Format("http://{0}", busiConfig.ServiceAddress);
                //    string strDocInfo = SimpleConfig.XmlSerialize<K3DataParaInfo>(docInfo, Encoding.Unicode);
                //    pipe.Send(strDocInfo);

                //    // Execute the web service and get the IEnumerable type results
                //    strRlt = svValidateBM.SynchBillFromK3ToX9(strDocInfo);
                //    // Switch the context back to the SQL Server
                //    userImpersonated.Undo();
                //}
                //else
                //{
                //    pipe.Send("userImpersonated is null");
                //}

                X9WebService.WebService svValidateBM = new X9WebService.WebService();
                svValidateBM.Url = string.Format("http://{0}", busiConfig.ServiceAddress);
                string strDocInfo = SimpleConfig.XmlSerialize <K3DataParaInfo>(docInfo, Encoding.Unicode);
                pipe.Send(strDocInfo);
                //string strHttpEncoding = HttpUtility.HtmlEncode(strDocInfo);
                strRlt = svValidateBM.SynchBillFromK3ToX9(strDocInfo);

                if (!string.IsNullOrEmpty(strRlt))
                {
                    pipe.Send(strRlt);
                    //strRlt = strRlt.Replace(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
                    //string strHttpDecoding = HttpUtility.HtmlDecode(strRlt);
                    ResultInfo rltInfo = SimpleConfig.XmlDeserialize <ResultInfo>(strRlt, Encoding.Unicode);
                    return(rltInfo);
                }
                return(null);
            }
            catch (Exception ex)
            {
                //LogInfoHelp.infoLog(eventName, docInfo, string.Format("调用X9系统服务时,异常:{0}", ex.Message));
                pipe.Send(string.Format("Exception cacheDocInfo:{0}", ex.Message));
                cacheDocInfo(docInfo, busiConfig);
                return(null);
            }
        }