private void UpdatateInterface(bool isSupported, InterfaceType type)
 {
     if (isSupported)
     {
         if (SupportedInterfacesTb.Text.Length != 0)
         {
             SupportedInterfacesTb.AppendText(Environment.NewLine);
         }
         SupportedInterfacesTb.AppendText(type.ToString());
     }
 }
Exemplo n.º 2
0
 public IEnumerable <IDataObject> GetList(IZetboxContext ctx, InterfaceType ifType, int maxListCount, bool eagerLoadLists, IEnumerable <Expression> filter, IEnumerable <OrderBy> orderBy, out List <IStreamable> auxObjects)
 {
     using (Logging.Facade.InfoTraceMethodCallFormat("GetList", "Type=[{0}]", ifType.ToString()))
     {
         try
         {
             return(_implementor.GetList(ctx, ifType, maxListCount, eagerLoadLists, filter, orderBy, out auxObjects));
         }
         catch (Exception ex)
         {
             Logging.Facade.Error("GetList", ex);
             throw;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 调用服务端接口并返回Content
        /// </summary>
        /// <param name="strRequest">请求Json字符串</param>
        /// <param name="InterfaceType">接口枚举</param>
        /// <param name="result">是否成功</param>
        /// <returns>Content值</returns>
        public static string GetResponse(string strRequest, InterfaceType InterfaceType, ref bool result, out string errorMsg, int timeOut = 60000)
        {
            string strContent = string.Empty;

            errorMsg = string.Empty;
            try
            {
                Logging.Log4NetHelper.Debug(typeof(WSInterface), strRequest);

                string requestDownLoadXML = GlobalBW(strRequest);
                if (!string.IsNullOrEmpty(requestDownLoadXML))
                {
                    requestDownLoadXML = System.Web.HttpUtility.UrlEncode(requestDownLoadXML, System.Text.Encoding.UTF8);
                    string fpqzResponse = CommonHelper.HttpPost(ConfigHelper.GetAppSettingValue(InterfaceType.ToString()), requestDownLoadXML, timeOut);

                    JavaScriptSerializer jserial        = new JavaScriptSerializer();
                    GeneralInfo          dyfpqzResponse = jserial.Deserialize <GeneralInfo>(fpqzResponse);

                    if (dyfpqzResponse.state.returnCode.ToString() != "0000")
                    {
                        result = false;

                        //errorMsg = string.Format("{0}({1})", dyfpqzResponse.state.returnMessage, dyfpqzResponse.state.returnCode);
                        errorMsg = string.Format("{0}", dyfpqzResponse.state.returnMessage);
                        Logging.Log4NetHelper.Debug(typeof(WSInterface), string.Format(Message.GetResponseFailed, InterfaceType.GetDescription(), dyfpqzResponse.state.returnCode, dyfpqzResponse.state.returnMessage));
                    }
                    else
                    {
                        result = true;
                    }

                    if (!string.IsNullOrEmpty(dyfpqzResponse.content))
                    {
                        strContent = GetRetContent(dyfpqzResponse, InterfaceType);
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
                Logging.Log4NetHelper.Error(typeof(WSInterface), string.Format(Message.GetResponseException, InterfaceType.GetDescription()) + ex.Message + System.Environment.NewLine + ex.StackTrace);
                strContent = ex.Message;

                if (ex.Message.Contains("timeout") ||
                    ex.Message.Contains("timed out"))
                {
                    strContent = PRO_ReceiptsInvMgr.Resources.Message.TimeOutError;
                }
                else if (ex.Message.Contains("No connection could be made") ||
                         ex.Message.Contains("Unable to connect") || ex.Message.Contains("Not Found"))
                {
                    strContent = PRO_ReceiptsInvMgr.Resources.Message.ConnectError;
                }
                else if (ex.Message.Contains("Internal Server Error"))
                {
                    strContent = PRO_ReceiptsInvMgr.Resources.Message.InternalError;
                }
                errorMsg = strContent;
            }

            return(strContent);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 调用服务端接口并获取返回报文对象
        /// </summary>
        /// <param name="InterfaceType">接口枚举</param>
        /// <param name="result">是否上传或下载成功</param>
        /// <returns></returns>
        public static GeneralInfo GetResponseObject(string strRequest, InterfaceType InterfaceType)
        {
            GeneralInfo dyfpqzResponse = null;

            try
            {
                string requestDownLoadXML = GlobalBW(strRequest);
                if (!string.IsNullOrEmpty(requestDownLoadXML))
                {
                    requestDownLoadXML = System.Web.HttpUtility.UrlEncode(requestDownLoadXML, System.Text.Encoding.UTF8);

                    string fpqzResponse          = CommonHelper.HttpPost(ConfigHelper.GetAppSettingValue(InterfaceType.ToString()).ToString(), requestDownLoadXML);
                    JavaScriptSerializer jserial = new JavaScriptSerializer();
                    dyfpqzResponse = jserial.Deserialize <GeneralInfo>(fpqzResponse);

                    if (dyfpqzResponse.state.returnCode.ToString() != "0000")
                    {
                        Logging.Log4NetHelper.Error(typeof(WSInterface), string.Format(Message.GetResponseFailed, InterfaceType.GetDescription(), dyfpqzResponse.state.returnCode, dyfpqzResponse.state.returnMessage));
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.Log4NetHelper.Error(typeof(WSInterface), string.Format(Message.GetResponseException, InterfaceType.GetDescription()) + ex.Message + System.Environment.NewLine + ex.StackTrace);
                throw;
            }
            return(dyfpqzResponse);
        }
        public EthernetInterfaceControlDefinition(WinPcapInterface wpcInt)
        {
            this.wpcInt = wpcInt;

            if (InterfaceType != System.Net.NetworkInformation.NetworkInterfaceType.Ethernet &&
                InterfaceType != System.Net.NetworkInformation.NetworkInterfaceType.Wireless80211)
            {
                throw new ArgumentException("Cannot create an interface with type " + InterfaceType.ToString() + ", since the EthernetInterface only supports ethernet.");
            }

            try
            {
                Name = InterfaceConfiguration.GetFriendlyName(wpcInt.Name);
            }
            catch (Exception ex)
            {
                Name = "[Could not load description: " + ex.Message + "]";
            }

            Description = "This traffic handler represents a WinPcap capable ethernet interface.\n" + this.Name;
            Author      = "Emanuel Jöbstl";
            WebLink     = "http://www.eex-dev.net";
            PluginType  = PluginTypes.Interface;
            PluginKey   = "eex_winpcap_ethernet";
        }
Exemplo n.º 6
0
 public override string ToString()
 {
     return(InterfaceType.ToString() + InterfaceNumber.ToString());
 }
Exemplo n.º 7
0
        public string GetCommandLineParameters()
        {
            StringBuilder sb = new StringBuilder();

            if (communicator.media is GXNet n)
            {
                if (n.HostName == null)
                {
                    n.Settings = MediaSettings;
                }
                sb.Append("-h " + n.HostName);
                sb.Append(" -p " + n.Port);
            }
            if (communicator.media is GXSerial s)
            {
                if (s.PortName == null)
                {
                    s.Settings = MediaSettings;
                }
                sb.Append("-S " + s.PortName);
                sb.Append(":" + s.BaudRate);
                sb.Append(":" + s.DataBits);
                sb.Append(s.Parity);
                sb.Append(s.StopBits);
            }
            if (!UseLogicalNameReferencing)
            {
                sb.Append(" -r sn");
            }
            if (InterfaceType != InterfaceType.HDLC)
            {
                sb.Append(" -i" + InterfaceType.ToString());
            }
            if (ClientAddress != 16)
            {
                sb.Append(" -c " + ClientAddress);
            }
            if (HDLCAddressing == HDLCAddressType.Default)
            {
                if (PhysicalAddress != 1 && LogicalAddress != 0)
                {
                    if (InterfaceType == InterfaceType.HDLC || InterfaceType == InterfaceType.HdlcWithModeE || InterfaceType == InterfaceType.PlcHdlc)
                    {
                        sb.Append(" -s " + GXDLMSClient.GetServerAddress(LogicalAddress, Convert.ToInt32(PhysicalAddress)));
                    }
                    else
                    {
                        sb.Append(" -s " + communicator.client.ServerAddress);
                    }
                }
            }
            else if (HDLCAddressing == HDLCAddressType.SerialNumber)
            {
                if (PhysicalAddress != 1)
                {
                    sb.Append(" -n " + PhysicalAddress);
                }
            }
            if (Authentication != Authentication.None)
            {
                sb.Append(" -a " + Authentication);
                if (!string.IsNullOrEmpty(Password))
                {
                    string pw = ASCIIEncoding.ASCII.GetString(CryptHelper.Decrypt(Password, GXDLMSDirector.Password.Key));
                    if (!string.IsNullOrEmpty(pw))
                    {
                        sb.Append(" -P " + pw);
                    }
                }
                if (HexPassword != null && HexPassword.Length != 0)
                {
                    sb.Append(" -P 0x" + ASCIIEncoding.ASCII.GetString(CryptHelper.Decrypt(HexPassword, GXDLMSDirector.Password.Key)));
                }
            }
            if (Security != Security.None)
            {
                sb.Append(" -C " + Security);
            }
            if (SecuritySuite != SecuritySuite.Suite0)
            {
                sb.Append(" -V " + SecuritySuite);
            }
            if (Signing != Signing.None)
            {
                sb.Append(" -K " + Signing);
            }
            if (Authentication == Authentication.HighSHA256 ||
                Authentication == Authentication.HighECDSA || Security != Security.None)
            {
                if (!string.IsNullOrEmpty(SystemTitle))
                {
                    sb.Append(" -T " + SystemTitle);
                }
                if (!string.IsNullOrEmpty(ServerSystemTitle))
                {
                    sb.Append(" -M " + ServerSystemTitle);
                }
                if (Security != Security.None)
                {
                    if (!string.IsNullOrEmpty(AuthenticationKey))
                    {
                        sb.Append(" -A " + AuthenticationKey);
                    }
                    if (!string.IsNullOrEmpty(BlockCipherKey))
                    {
                        sb.Append(" -B " + BlockCipherKey);
                    }
                    if (!string.IsNullOrEmpty(DedicatedKey))
                    {
                        sb.Append(" -D " + DedicatedKey);
                    }
                }
                if (!string.IsNullOrEmpty(FrameCounter))
                {
                    sb.Append(" -v " + FrameCounter);
                }
            }
            if (Standard != Standard.DLMS)
            {
                sb.Append(" -d " + Standard);
            }
            if (InterfaceType == InterfaceType.HDLC || InterfaceType == InterfaceType.HdlcWithModeE)
            {
                if (GbtWindowSize != 1)
                {
                    sb.Append(" -W " + GbtWindowSize);
                }
                if (WindowSizeRX != 128)
                {
                    sb.Append(" -w " + WindowSizeRX);
                }
                if (MaxInfoTX != 1)
                {
                    sb.Append(" -f " + MaxInfoRX);
                }
            }
            sb.Append(" -t Verbose");
            return(sb.ToString());
        }