Exemplo n.º 1
0
        private static ISinoBestMTSAdatper GetNewAdapter(string MethodName)
        {
            try
            {
                using (SqlConnection cn = SqlHelper.OpenConnection())
                {
                    SqlCommand _cmd = new SqlCommand(SQL_GetAdapterDLLFile, cn);
                    _cmd.Parameters.Add(":CSNAME", MethodName);
                    string _dllname    = (string)_cmd.ExecuteScalar();
                    string AssmblyName = StrUtils.GetMetaByName2("Assembly", _dllname);
                    string AdapterType = StrUtils.GetMetaByName2("Type", _dllname);


                    String path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "";
                    try
                    {
                        Assembly            assembly = Assembly.LoadFile(path + "\\" + AssmblyName);
                        Type                type     = assembly.GetType(AdapterType);
                        ISinoBestMTSAdatper instance = (ISinoBestMTSAdatper)Activator.CreateInstance(type);
                        return(instance);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format("反射生成处理类时出错!Assmebly={0} Type={1}  {2}", AssmblyName, AdapterType, ex.Message));
                    }
                }
            }
            catch (Exception ex)
            {
                //LogWriter.WriteSystemLog(string.Format("取消息报文接收处理器时出错!MethodName={0} {1}", MethodName, ex.Message), "ERROR");
                return(null);
            }
        }
Exemplo n.º 2
0
 public static ISinoBestMTSAdatper GetAdapter(string MethodName)
 {
     if (Adapters.ContainsKey(MethodName))
     {
         return(Adapters[MethodName]);
     }
     else
     {
         ISinoBestMTSAdatper _da = GetNewAdapter(MethodName);
         return(_da);
     }
 }
Exemplo n.º 3
0
        public string Handle(string MessageData)
        {
            MTSResultMessage _s;
            MTSMessage       _msg = new CS.BizMetaDataManager.MTS.MTSMessage(MessageData);
            //先落地保存
            bool _ret = SinoBestMTSWriter.SaveBufferData(_msg.PKGuid, _msg.DEPLOYID_TX, _msg.DEPLOYID_RX, "RX接收成功", "", 0, _msg.DataPKG, _msg.PROCMETHOD);

            if (!_ret)
            {
                _s              = new MTSResultMessage();
                _s.PKGuid       = _msg.PKGuid;
                _s.ResultType   = "1";
                _s.ResultMethod = "";
                _s.ResultBody   = "数据存入接收缓存区时失败!";
            }
            else
            {
                //反射类处理
                ISinoBestMTSAdatper _adapter = AdapterLib.GetAdapter(_msg.PROCMETHOD);
                string _excuteRet            = _adapter.Excute(_msg.PKGuid);
                if (_excuteRet == null || _excuteRet == "")
                {
                    _s              = new MTSResultMessage();
                    _s.PKGuid       = _msg.PKGuid;
                    _s.ResultType   = "0";
                    _s.ResultMethod = "";
                    _s.ResultBody   = "处理成功!";
                    SinoBestMTSWriter.ChangeStatus("RX处理成功", _msg.PKGuid, "");
                }
                else
                {
                    _s              = new MTSResultMessage();
                    _s.PKGuid       = _msg.PKGuid;
                    _s.ResultType   = "1";
                    _s.ResultMethod = "";
                    _s.ResultBody   = _excuteRet;
                    SinoBestMTSWriter.ChangeStatus("RX处理失败", _msg.PKGuid, _excuteRet);
                }
            }
            return(_s.CreateMsg());
        }