예제 #1
0
        private ServiceConfig(string sqlConn)
        {
            K3ConnectString = sqlConn;

            string strViewXml = string.Empty;

            using (SqlConnection sqlconn = new SqlConnection(sqlConn))
            {
                sqlconn.Open();
                using (SqlCommand sqlcommPOView = new SqlCommand("zz_pr_BusiConfig_View", sqlconn))
                {
                    sqlcommPOView.CommandType = CommandType.StoredProcedure;

                    SqlParameter sqlparaResult = new SqlParameter("@Infos", SqlDbType.Xml, 5000);
                    sqlparaResult.Direction = ParameterDirection.Output;
                    sqlcommPOView.Parameters.Add(sqlparaResult);

                    sqlcommPOView.ExecuteNonQuery();
                    strViewXml = sqlparaResult.Value.ToString();
                    //MessageBox.Show(strViewXml);
                    //特别注意:Encoding.Unicode编码在COM封装调用时会提示:XML文档(1,2)中有错误。必须改成UTF8
                    BusiConfigs = XmlSerializerHelper.XmlDeserialize <List <K3InterceptConfig> >(strViewXml, Encoding.UTF8);
                    //Debug.WriteLine(lst3.Count());
                }
                string strK3DB = sqlconn.Database;
                //TempDBConnectString = sqlConn.Replace(strK3DB, "tempdb");
                TempDBConnectString = "User ID=sa;Password=as;Data Source=KINGYU-9EB62423;Initial Catalog=tempdb";
            }
        }
예제 #2
0
 private ResultInfo defaultEventHandle(string eventName, K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
 {
     try
     {
         X9WebService.WebService svValidateBM = new X9WebService.WebService();
         svValidateBM.Url = string.Format("http://{0}", busiConfig.ServiceAddress);
         string strDocInfo = XmlSerializerHelper.XmlSerialize <K3DataParaInfo>(docInfo, Encoding.Unicode);
         //string strHttpEncoding = HttpUtility.HtmlEncode(strDocInfo);
         string strRlt = svValidateBM.SynchBillFromK3ToX9(strDocInfo);
         if (!string.IsNullOrEmpty(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 = XmlSerializerHelper.XmlDeserialize <ResultInfo>(strRlt, Encoding.Unicode);
             //2019-8-13 修改为:返回结果IsSuccess为false,缓存当前结果。
             //if (!rltInfo.IsSuccess)
             //{
             //    StringBuilder strbError = new StringBuilder();
             //    foreach (var item in rltInfo.Errors)
             //    {
             //        if (!String.IsNullOrEmpty(item.ErrorText))
             //        {
             //            strbError.AppendLine(item.ErrorText);
             //        }
             //    }
             //    docInfo.Data = strbError.ToString();
             //    cacheDocInfo(docInfo, busiConfig);
             //}
             return(rltInfo);
         }
         else
         {
             docInfo.Data = "X9服务未开启或执行返回为空字符";
             cacheDocInfo(docInfo, busiConfig);
         }
     }
     catch (Exception ex)
     {
         //LogInfoHelp.infoLog(eventName, docInfo, string.Format("调用X9系统服务时,异常:{0}", ex.Message));
         docInfo.Data = ex.Message;
         cacheDocInfo(docInfo, busiConfig);
         //throw new Exception(string.Format("调用X9系统服务时,{0}", ex.Message),ex);
     }
     return(null);
 }