コード例 #1
0
 public static int       Length => 9; //TODO Fix
 public AosHeader(ProtocolTypeEnum protocolType, int bodySize, byte channelVer = 4, byte clientType = 4, byte protocolVersion = 0, byte isZipped = 0)
 {
     ChannelVer      = channelVer;
     ClientType      = clientType;
     ProtocolType    = protocolType;
     ProtocolVersion = protocolVersion;
     IsZipped        = isZipped;
     BodySize        = bodySize;
 }
コード例 #2
0
 public void Start(ProtocolTypeEnum type)
 {
     foreach (var server in servers)
     {
         if (server.Type == type)
         {
             server.Start();
         }
     }
 }
 public void SendBatched(IEnumerable <FileMessage> fileMessages, ProtocolTypeEnum protocolType)
 {
     foreach (var sender in senders)
     {
         if (sender.Type == protocolType)
         {
             this.fileMessageSenderWatcher.MeasureElapsedTime(() => { sender.SendBatched(fileMessages); });
         }
     }
 }
 public void Send(FileMessage fileMessage, ProtocolTypeEnum protocolType)
 {
     foreach (var sender in senders)
     {
         if (sender.Type == protocolType)
         {
             this.fileMessageSenderWatcher.MeasureElapsedTime(() => { sender.Send(fileMessage); });
         }
     }
 }
コード例 #5
0
ファイル: IPLCConnector.cs プロジェクト: doronweiss/MBLoop
        public static IPLCConnector GetConnector(ProtocolTypeEnum protocolType)
        {
            switch (protocolType)
            {
            case ProtocolTypeEnum.TCP:
            case ProtocolTypeEnum.UDP:
                return(new PLCConnector());

            default:
                return(null);
            }
        }
コード例 #6
0
        static public ProtocolObject ConvertTo(JObject jso)
        {
            ProtocolObject   p    = null;
            ProtocolTypeEnum type = GetProtocolType(jso["ProtocolType"]);

            if (type == ProtocolTypeEnum.Thread)
            {
                p = new ThreadProtocol();
                ((ThreadProtocol)p).MockUserId = jso["MockUserId"].ToString();
                //if (jso["PublishUrl"] != null)
                //{
                //    ((ThreadProtocol)p).PublishUrl = jso["PublishUrl"].ToString();
                //}
            }
            else if (type == ProtocolTypeEnum.Register)
            {
                p = new RegisterProtocol();
                ((RegisterProtocol)p).MockUserId = jso["MockUserId"].ToString();
            }
            else if (type == ProtocolTypeEnum.Recorder)
            {
                p = new RecorderProtocol();
                ((RecorderProtocol)p).ScriptId  = jso["ScriptId"].ToString();
                ((RecorderProtocol)p).WebsiteId = jso["WebsiteId"].ToString();
            }
            else if (type == ProtocolTypeEnum.KeywordPlan)
            {
                p = new KeywordPlanProtocol();
            }
            else if (type == ProtocolTypeEnum.RunnerScript)
            {
                p = new ScriptRunnerProtocol();
                ((ScriptRunnerProtocol)p).ScriptId = jso["ScriptId"].ToString();
            }
            else
            {
                p = new ProtocolObject();
            }
            p.CurrentUserId    = jso["CurrentUserId"].ToString();
            p.IsAuthentication = Convert.ToBoolean(jso["IsAuthentication"]);
            // if (jso.ContainsKey("Target"))
            {
                p.Target = jso["Target"] == null ? "_blank" : jso["Target"].ToString();
            }
            p.ProtocolType = type;
            // if (jso.ContainsKey("InputParameters"))
            //{
            //    p.InputParameters = jso["InputParameters"].ToString();
            //}
            return(p);
        }
コード例 #7
0
ファイル: PLCConnector.cs プロジェクト: doronweiss/MBLoop
        public bool Connect(ProtocolTypeEnum protocolType, BaseCommConfig commCfg, out string errorStr)
        {
            errorStr = "";
            TCPCommConfig ipCfg = commCfg as TCPCommConfig;

            if (protocol != null)
            {
                if (slaveIP == ipCfg.addressMajor)
                {
                    return(true);
                }
                else
                {
                    errorStr = "Connected to a different device";
                    return(false);
                }
            }
            try {
                if (protocolType == ProtocolTypeEnum.TCP)
                {
                    protocol = new MbusTcpMasterProtocol();
                }
                else
                {
                    protocol = new MbusUdpMasterProtocol();
                }
            } catch (OutOfMemoryException ex) {
                return(false);
            }
            slaveAddr          = ipCfg.devId;
            protocol.timeout   = ipCfg.timeout;
            protocol.retryCnt  = ipCfg.retryCnt;
            protocol.pollDelay = ipCfg.pollDelay;
            protocol.setPort((short)ipCfg.addressMinor);
            int res = protocol.openProtocol(ipCfg.addressMajor);

            if ((res == BusProtocolErrors.FTALK_SUCCESS))
            {
                slaveIP  = ipCfg.addressMajor;
                errorStr = string.Format("Modbus/TCP Device: {0} Port: {1} opened successfully", ipCfg.addressMajor, ipCfg.addressMinor);
                return(true);
            }
            else
            {
                errorStr = ("Could not open protocol, error was: " + BusProtocolErrors.getBusProtocolErrorText(res));
                protocol = null;
                return(false);
            }
        }
コード例 #8
0
        public IFetchMailService Resolve(ProtocolTypeEnum protocolType)
        {
            Type t = null;
            switch (protocolType)
            {
                case ProtocolTypeEnum.Imap:
                    t = typeof(ImapService);
                    break;
                case ProtocolTypeEnum.Pop3:
                    t = typeof(Pop3Service);
                    break;
            }

            return t != null
                ? _injector.Get(t) as IFetchMailService
                : null;
        }
コード例 #9
0
        public IFetchMailService Resolve(ProtocolTypeEnum protocolType)
        {
            Type t = null;

            switch (protocolType)
            {
            case ProtocolTypeEnum.Imap:
                t = typeof(ImapService);
                break;

            case ProtocolTypeEnum.Pop3:
                t = typeof(Pop3Service);
                break;
            }

            return(t != null
                ? _injector.Get(t) as IFetchMailService
                : null);
        }
コード例 #10
0
 public OtherPingRequestFactory(ProtocolTypeEnum protocolType)
 {
     _protocolType = protocolType;
 }
コード例 #11
0
 /// <summary>
 /// 连接协议:Protocol, ConnectionProtocol, Connection Protocol 默认:Socket
 /// </summary>
 public XConnectionBuilder SetProtocol(ProtocolTypeEnum protocolType)
 {
     DbPairs.AddOrReplace("Protocol", protocolType.ToString());
     return(this);
 }
コード例 #12
0
        //http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework/2007-06/msg00458.html - Discusses grouping on the firewall rules.
        /// <summary>
        /// 
        /// </summary>
        /// <param name="RuleName">
        /// Note: Must not contain the '|' character.</param>
        /// <param name="actionType"></param>
        /// <param name="profileType"></param>
        /// <param name="protocol">Export rules.  Only doing UDP and TCP show in the referenced enum.  Additional protocols that are possibly supported:
        /// http://go.microsoft.com/fwlink/p/?linkid=89889 </param>
        /// <param name="localAddresses">
        /// "*" indicates any local address. If present, this must be the only token included.
        /// "Defaultgateway"
        /// "DHCP"
        /// "WINS"
        /// "LocalSubnet" indicates any local address on the local subnet. This token is not case-sensitive.
        /// A subnet can be specified using either the subnet mask or network prefix notation. If neither a subnet mask not a network prefix is specified, the subnet mask defaults to 255.255.255.255.
        /// A valid IPv6 address.
        /// An IPv4 address range in the format of "start address - end address" with no spaces included.
        /// An IPv6 address range in the format of "start address - end address" with no spaces included.
        /// </param>
        /// <param name="remoteAddresses">
        /// "*" indicates any remote address. If present, this must be the only token included.
        /// "Defaultgateway"
        /// "DHCP"
        /// "DNS"
        /// "WINS"
        /// "LocalSubnet" indicates any local address on the local subnet. This token is not case-sensitive.
        /// A subnet can be specified using either the subnet mask or network prefix notation. If neither a subnet mask not a network prefix is specified, the subnet mask defaults to 255.255.255.255.
        /// A valid IPv6 address.
        /// An IPv4 address range in the format of "start address - end address" with no spaces included.
        /// An IPv6 address range in the format of "start address - end address" with no spaces included.
        /// </param>
        /// <param name="localPorts"></param>
        /// <param name="remotePorts">
        /// </param>
        /// <param name="Program">The path to the program for which an exception is being added.
        /// Note: If there are environment variables, they will be expanded when the rule is saved.</param>
        /// <param name="AllowedUsers"></param>
        /// <param name="AllowedComputers"></param>
        /// <param name="Group">
        /// Using the Grouping property is highly recommended, as it groups multiple rules into a single line in the
        /// Windows Firewall control panel. This allows the user to enable or disable multiple rules with a single click.
        /// The Grouping property can also be specified using indirect strings. In this case, a group description can
        /// also be specified that will appear in the rule group properties in the Windows Firewall control panel. For
        /// example, if the group string is specified by an indirect string at index 1005 ("@yourresources.dll,-1005"),
        /// the group description can be specified at a resource string higher by 10000 "@youresources.dll,-11005."
        /// 
        /// When indirect strings in the form of "h" are passed as parameters to the Windows Firewall with Advanced
        /// Security APIs, they should either be placed under the System32 Windows directory or specified by a full
        /// path. Further, the file should have a secure access that permits the Local Service account read acces
        /// to allow the Windows Firewall Service to read the strings. To avoid non-privileged security principals
        /// from modifying the strings, the DLLs should only allow write access to the Administrator account.</param>
        /// <param name="Enabled"></param>
        /// <param name="Override"></param>
        /// <param name="TrafficDirection"></param>
        /// //Description: Describes the rule.  Must not contiain the '|' character.
        /// //Interfaces: Represented by their friendly names.  http://msdn.microsoft.com/en-us/library/windows/desktop/dd339603(v=vs.85).aspx
        /// //InterfaceTypes: Acceptable values for this property are "RemoteAccess", "Wireless", "Lan", and "All". If more than one interface type is specified, the strings must be separated by a comma.
        /// //ServiceName property: A serviceName value of "*" indicates that a service, not an application, must be sending or receiving traffic.
        /// <returns></returns>
        internal static INetFwRule NewFirewallRule(string RuleName, FirewallActionTypeEnum actionType, ProfileTypeEnum profileType, ProtocolTypeEnum protocol,
			string localAddresses, string remoteAddresses, string localPorts, string remotePorts,
			string Program,
			string AllowedUsers, string AllowedComputers,//Not yet supported.
			string Group,
			bool Enabled,
			bool Override,
			TrafficDirectionTypeEnum TrafficDirection = TrafficDirectionTypeEnum.Incoming)
        {
            INetFwRule firewallRule = Extensions.InstantiateTypeFromProgID("HNetCfg.FWRule");
            //Don't count on the property list at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365344(v=vs.85).aspx being in the correct order...
            firewallRule.Name = RuleName;
            //Description
            firewallRule.Enabled = Enabled;

            if (!string.IsNullOrWhiteSpace(Program) && !Program.Matches("Any"))
                firewallRule.ApplicationName = Program;
            //ServiceName
            firewallRule.Protocol = (int)protocol;
            #region Addresses and ports
            if (string.IsNullOrWhiteSpace(Program) ||  Program.Matches("Any"))
            {
                if (localPorts.Matches("Any"))
                    firewallRule.LocalPorts = "*";
                else
                    firewallRule.LocalPorts = localPorts.Replace(" ", "");
                if (remotePorts.Matches("Any"))
                    firewallRule.RemotePorts = "*";
                else
                    firewallRule.RemotePorts = remotePorts.Replace(" ", "");
                if (localAddresses.Matches("Any"))
                    firewallRule.LocalAddresses = "*";
                else
                    firewallRule.LocalAddresses = localAddresses.Replace(" ", "");
                if (remoteAddresses.Matches("Any"))
                    firewallRule.RemoteAddresses = "*";
                else
                    firewallRule.RemoteAddresses = remoteAddresses.Replace(" ", "");
            }
            #endregion
            firewallRule.Profiles = (int)profileType;
            //Interfaces
            //InterfaceTypes
            firewallRule.Direction = TrafficDirection.GetCOMEnum();
            firewallRule.Action = actionType.GetCOMEnum();
            //Edge Traversal
            //Set either scope or remote addresses, but not both.  - http://msdn.microsoft.com/en-us/library/aa366436(v=vs.85).aspx
            #region AllowedSettings
            //TODO: Find settings for Allowed Users and Allowed Computers
            #endregion
            firewallRule.Grouping = Group;
            //firewallRule.InterfaceTypes = "All";
            return firewallRule;
            //Additional data: http://msdn.microsoft.com/en-us/library/aa366447(v=vs.85).aspx
            //Interfaces: http://msdn.microsoft.com/en-us/library/aa366449(v=vs.85).aspx
        }
コード例 #13
0
 //Requires a single Port.
 internal static INetFwOpenPort NewOpenPortObject(string ExceptionName, bool Enabled, string PortDetails, string remoteAddresses, ProtocolTypeEnum protocol)
 {
     INetFwOpenPort portException = Extensions.InstantiateTypeFromGUID("{0CA545C6-37AD-4A6C-BF92-9F7610067EF5}");//HNetCfg.FwOpenPort ?
     portException.Name = ExceptionName;
     portException.Port = int.Parse(PortDetails);
     portException.Protocol = protocol.GetCOMEnum();
     portException.RemoteAddresses = remoteAddresses;
     portException.Enabled = Enabled;
     return portException;
 }