Beispiel #1
0
        private void cacheDocInfo(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
        {
            try
            {
                LogInfoHelp.debugLog(string.Empty, docInfo, "进入缓存服务中断数据。");
                using (SqlConnection sqlconn = new SqlConnection(ServiceConfig.Instance.K3ConnectString))
                {
                    sqlconn.Open();
                    using (SqlCommand sqlcommCache = new SqlCommand("zz_pr_X9WebSrvBackup_Save", sqlconn))
                    {
                        sqlcommCache.CommandType = CommandType.StoredProcedure;
                        string       strDocInfo      = XmlSerializerHelper.XmlSerialize <K3DataParaInfo>(docInfo, Encoding.Unicode);
                        SqlParameter sqlparamDocInfo = new SqlParameter("@DocInfo", SqlDbType.Xml, 5000);
                        sqlparamDocInfo.Value = strDocInfo;
                        SqlParameter sqlparamUrl = new SqlParameter("@Url", SqlDbType.NVarChar, 100);
                        sqlparamUrl.Value = string.Format("http://{0}", busiConfig.ServiceAddress);
                        sqlcommCache.Parameters.Add(sqlparamDocInfo);
                        sqlcommCache.Parameters.Add(sqlparamUrl);

                        sqlcommCache.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                LogInfoHelp.debugLog(string.Empty, docInfo, string.Format("进入缓存服务中断数据,发生异常:{0}", ex.Message));
                //throw new RankException(string.Format("暂存DocInfo存储异常:{0}", string.Empty), ex);
                //MessageBox.Show(string.Format("{0}\t暂存DocInfo存储异常:{1}", Environment.NewLine, ex.Message));
                throw new Exception(string.Format("{0}\t暂存DocInfo存储异常:{1}", Environment.NewLine, ex.Message), ex);
            }
            throw new Exception(string.Format("调用X9系统服务时,{0}", docInfo.Data));
        }
Beispiel #2
0
        /// <summary>
        /// 所单据表头增加了“是否进X9”字段,并在zz_t_K3InterceptConfig配置表设置好对应字段则会进行过滤调用。
        /// 对过滤字段的设定,可能是以枚举方式,这样造成保存到数据库后台的值是不可预定。所以后续可考虑加入ExcludedValue字段
        /// 保存“排除调用服务”的字段值,如N、false或其他值。
        /// </summary>
        /// <param name="itemConfig"></param>
        /// <param name="docInfo"></param>
        /// <returns></returns>
        internal bool isCalledFilter(K3InterceptConfig itemConfig, K3DataParaInfo docInfo)
        {
            bool bRlt = true;

            if (itemConfig == null || string.IsNullOrEmpty(itemConfig.ConditionTable) || string.IsNullOrEmpty(itemConfig.ConditionField) || string.IsNullOrEmpty(itemConfig.KeyField))
            {
                return(bRlt);
            }
            using (SqlConnection sqlconn = new SqlConnection(ServiceConfig.Instance.K3ConnectString))
            {
                sqlconn.Open();
                using (SqlCommand sqlcommExists = new SqlCommand(string.Format("select 1 from sys.columns where [object_id] = object_id('{0}') and name = '{1}'", itemConfig.ConditionTable, itemConfig.ConditionField), sqlconn))
                {
                    Object objIsExists = sqlcommExists.ExecuteScalar();
                    if (objIsExists == null || Convert.ToInt32(objIsExists.ToString()) != 1)
                    {
                        return(bRlt);
                    }
                }

                using (SqlCommand sqlcommKeyExists = new SqlCommand(string.Format("select 1 from sys.columns where [object_id] = object_id('{0}') and name = '{1}'", itemConfig.ConditionTable, itemConfig.KeyField), sqlconn))
                {
                    Object objIsExists = sqlcommKeyExists.ExecuteScalar();
                    if (objIsExists == null || Convert.ToInt32(objIsExists.ToString()) != 1)
                    {
                        return(bRlt);
                    }
                }

                string strExcludedValue = "N";
                if (!string.IsNullOrEmpty(itemConfig.ExcludedValue))
                {
                    strExcludedValue = itemConfig.ExcludedValue;
                }

                using (SqlCommand sqlcommCondition = new SqlCommand(string.Format("select isnull({1},'Y') from {0} where {2} = {3}", itemConfig.ConditionTable, itemConfig.ConditionField, itemConfig.KeyField, docInfo.InterID.ToString()), sqlconn))
                {
                    Object objValue = sqlcommCondition.ExecuteScalar();
                    if (objValue == null)
                    {
                        return(bRlt);
                    }
                    else
                    {
                        if (string.Equals(strExcludedValue, objValue.ToString(), StringComparison.OrdinalIgnoreCase))
                        {
                            bRlt = false;
                        }
                    }
                }
            }

            return(bRlt);
        }
Beispiel #3
0
 public override ResultInfo entryClosedAfterExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
 {
     return(defaultEventHandle(InterceptEvent.EntryClosedAfter, docInfo, busiConfig));
 }
Beispiel #4
0
 public override ResultInfo unClosedBeforeExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
 {
     return(defaultEventHandle(InterceptEvent.UnClosedBefore, docInfo, busiConfig));
 }
Beispiel #5
0
 public override ResultInfo unFirstApprovedAfterExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
 {
     return(defaultEventHandle(InterceptEvent.UnApprovedAfter, docInfo, busiConfig));
 }
Beispiel #6
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);
 }
Beispiel #7
0
 public override ResultInfo unKnownExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig)
 {
     return(defaultEventHandle(InterceptEvent.UnKnownEvent, docInfo, busiConfig));
 }
Beispiel #8
0
        /// <summary>
        /// 基类缺省处理事件方法
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="docInfo"></param>
        /// <param name="rltFlag"></param>
        /// <returns><\returns>
        private ResultInfo defaultEventHandle(string eventName, K3DataParaInfo docInfo)
        {
            ResultInfo rltInfo = null;

            try
            {
                LogInfoHelp.debugLog(eventName, docInfo, string.Format("进入基类{0}事件响应", eventName));

                K3InterceptConfig itemConfig = validateBusinessEnable(docInfo, eventName);

                if (itemConfig != null)
                {
                    LogInfoHelp.debugLog(eventName, docInfo, string.Format("进入X9系统业务校验事件{0}服务中", eventName));
                    if (!isCalledFilter(itemConfig, docInfo))
                    {
                        LogInfoHelp.infoLog(eventName, docInfo, string.Format("X9系统业务校验事件{0}服务,单据【{1}]表头标记为“不进入X9系统”。", eventName, docInfo.InterID.ToString()));
                        return(null);
                    }
                    switch (eventName)
                    {
                    case InterceptEvent.AddBefore:
                        rltInfo = addBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.AddAfter:
                        rltInfo = addAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.DeleteBefore:
                        rltInfo = deleteBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.DeleteAfter:
                        rltInfo = deleteAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.FirstApprovedBefore:
                        rltInfo = firstApprovedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.FirstApprovedAfter:
                        rltInfo = firstApprovedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnFirstApprovedBefore:
                        rltInfo = unFirstApprovedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnFirstApprovedAfter:
                        rltInfo = unFirstApprovedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.ApprovedBefore:
                        rltInfo = approvedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.ApprovedAfter:
                        rltInfo = approvedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnApprovedBefore:
                        rltInfo = unApprovedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnApprovedAfter:
                        rltInfo = unApprovedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.ClosedBefore:
                        rltInfo = closedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.ClosedAfter:
                        rltInfo = closedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnClosedBefore:
                        rltInfo = unClosedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnClosedAfter:
                        rltInfo = unClosedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.EntryClosedBefore:
                        rltInfo = entryClosedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.EntryClosedAfter:
                        rltInfo = entryClosedAfterExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnEntryClosedBefore:
                        rltInfo = unEntryClosedBeforeExtend(docInfo, itemConfig);
                        break;

                    case InterceptEvent.UnEntryClosedAfter:
                        rltInfo = unEntryClosedAfterExtend(docInfo, itemConfig);
                        break;

                    default:
                        rltInfo = unKnownExtend(docInfo, itemConfig);
                        break;
                    }
                }
                else
                {
                    LogInfoHelp.debugLog(eventName, docInfo, string.Format("未启用X9系统对K3事件{0}的拦截", eventName));
                }
            }
            catch (Exception ex)
            {
                LogInfoHelp.infoLog(docInfo.EventName, docInfo,
                                    string.Format("执行基类缺省拦截处理:{0}事件。异常:{1}", eventName, ex.Message));
                //throw new Exception(string.Format("{0}\t{1}", Environment.NewLine,
                //    string.Format("执行基类缺省拦截处理:{0}事件。异常:{1}", eventName, ex.Message)),ex);
                //throw new RankException(string.Format("执行基类缺省拦截处理:{0}事件。异常:{1}", eventName, string.Empty), ex);
            }
            return(rltInfo);
        }
Beispiel #9
0
 public abstract ResultInfo unKnownExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig);
Beispiel #10
0
 public abstract ResultInfo unEntryClosedAfterExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig);
Beispiel #11
0
 public abstract ResultInfo entryClosedBeforeExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig);
Beispiel #12
0
 public abstract ResultInfo unApprovedBeforeExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig);
Beispiel #13
0
 public abstract ResultInfo approvedAfterExtend(K3DataParaInfo docInfo, K3InterceptConfig busiConfig);