Esempio n. 1
0
        //конструктор
        public ProtocolList(ProtocolTypes protocolType)
        {
            this.CenterToParent();
            this.MdiParent     = MainClass.mainform;
            this._protocolType = protocolType;

            this.sQuery = @"SELECT DISTINCT ed.extAbit.Id as Id, ed.extAbit.RegNum,
                ed.extAbit.BAckDoc, ed.extAbit.RegNum as Рег_Номер,
                ed.extAbit.FIO as ФИО, 
                ed.extPerson.AttestatSeries as AttSer, ed.extPerson.AttestatNum as AttNum, 
                (case when ed.extPerson.SchoolTypeId = 1 then ed.extPerson.AttestatRegion + ' ' + ed.extPerson.AttestatSeries + '  №' + ed.extPerson.AttestatNum else ed.extPerson.DiplomSeries + '  №' + ed.extPerson.DiplomNum end) as Документ_об_образовании, 
                ed.extAbit.ObrazProgramNameEx + ' ' +(Case when ed.extAbit.ProfileId IS NULL then '' else ed.extAbit.ProfileName end) as Направление,
                ed.Competition.Name as Конкурс, 
                0 as Black,
                (CASE WHEN ed.extAbit.BackDoc>0 THEN 'Забрал док.'ELSE (CASE WHEN ed.extAbit.NotEnabled>0 THEN 'Не допущен'ELSE (CASE WHEN ed.qProtocolHistory.Excluded>0 THEN 'Исключен из протокола' ELSE '' END) END)END) as Примечания, 
                (ed.extAbit.BAckDoc | ed.extAbit.NotEnabled | ed.qProtocolHistory.Excluded) as Red, 
                ed.extAbit.Sum as Сумма_баллов, 
                (Case WHEN ed.extPerson.HostelAbit>0 then 'да' else 'нет' END) as Общежитие 
                FROM ed.extAbit 
                INNER JOIN ed.extPerson ON ed.extPerson.Id=ed.extAbit.PersonId 
                LEFT JOIN ed.Competition ON ed.Competition.Id = ed.extAbit.CompetitionId
                LEFT JOIN ed.qProtocolHistory ON ed.qProtocolHistory.AbiturientId = ed.extAbit.Id
                LEFT JOIN ed.qProtocol ON ed.qProtocol.Id =  ed.qProtocolHistory.ProtocolId ";

            this.sWhere   = string.Format(" WHERE 1=1 AND ed.qProtocol.ProtocolTypeId = {0}", TypeToInt(_protocolType));
            this.sOrderby = " ORDER BY ed.extAbit.RegNum, ed.extAbit.BAckDoc ";

            InitializeComponent();

            InitControls();
        }
Esempio n. 2
0
        /// <summary>
        /// Perform the actual score lookup of the server list and return the candidate
        /// </summary>
        /// <returns>IPEndPoint candidate</returns>
        private ServerRecord GetNextServerCandidateInternal(ProtocolTypes supportedProtocolTypes)
        {
            lock ( listLock )
            {
                // ResetOldScores takes a lock internally, however
                // locks are re-entrant on the same thread, so this
                // isn't a problem.
                ResetOldScores();

                var query =
                    from o in servers.Select((server, index) => new { server, index })
                    let server                         = o.server
                                             let index = o.index
                                                         where server.Protocol.HasFlagsFast(supportedProtocolTypes)
                                                         let lastBadConnectionTime = server.LastBadConnectionTimeUtc
                                                                                     orderby lastBadConnectionTime.HasValue, index
                    select new { EndPoint = server.Record.EndPoint, Protocol = server.Protocol };
                var result = query.FirstOrDefault();

                if (result == null)
                {
                    return(null);
                }

                DebugWrite($"Next server candidiate: {result.EndPoint} ({result.Protocol})");
                return(new ServerRecord(result.EndPoint, result.Protocol));
            }
        }
        public override void SetAttributes(string uri, NodeType nodeType, IEnumerable <Pair <string, object> > attributes)
        {
            using (this.AcquireCommandContext())
            {
                var attributesList = attributes.Where(x => !x.Left.EqualsIgnoreCase("length") && !x.Left.EqualsIgnoreCase("exists")).ToList();

                SendCommandWithoutResponse(@"setattributes -t={0} ""{1}""", TextNetworkProtocol.GetNodeTypeName(nodeType), uri);

                ReadResponse().ProcessError();

                try
                {
                    foreach (var attribute in attributesList)
                    {
                        WriteTextBlock(@"{0}=""{1}:{2}""", attribute.Name, ProtocolTypes.GetTypeName(attribute.Value.GetType()), ProtocolTypes.ToEscapedString(attribute.Value));
                    }
                }
                finally
                {
                    WriteTextBlock(ResponseCodes.READY);
                }

                ReadResponse().ProcessError();
            }
        }
Esempio n. 4
0
        public RoamingNetworkInfo(Tracker_Id TrackerId,
                                  String IncomingURI,
                                  DateTime ExpiredAfter,

                                  RoamingNetwork RoamingNetwork,
                                  Byte priority,
                                  Byte weight,
                                  String hostname,
                                  IPPort port,
                                  TransportTypes transport,
                                  String uriPrefix,
                                  HTTPContentType contentType,
                                  ProtocolTypes protocolType,
                                  IEnumerable <String> PublicKeys)

            : this(TrackerId,
                   IncomingURI,
                   ExpiredAfter,

                   RoamingNetwork.Id,
                   priority,
                   weight,
                   hostname,
                   port,
                   transport,
                   uriPrefix,
                   contentType,
                   protocolType,
                   PublicKeys)

        {
            this.RoamingNetwork = RoamingNetwork;
        }
Esempio n. 5
0
        /// <summary>
        /// Get the next server in the list.
        /// </summary>
        /// <param name="supportedProtocolTypes">The minimum supported <see cref="ProtocolTypes"/> of the server to return.</param>
        /// <returns>An <see cref="System.Net.IPEndPoint"/>, or null if the list is empty.</returns>
        public async Task <ServerRecord> GetNextServerCandidateAsync(ProtocolTypes supportedProtocolTypes)
        {
            StartFetchingServers();
            await listTask.ConfigureAwait(false);

            return(GetNextServerCandidateInternal(supportedProtocolTypes));
        }
Esempio n. 6
0
        public RoamingNetworkInfo(Tracker_Id TrackerId,
                                  String IncomingURI,
                                  DateTime ExpiredAfter,

                                  RoamingNetwork_Id RoamingNetworkId,
                                  Byte priority,
                                  Byte weight,
                                  String hostname,
                                  IPPort port,
                                  TransportTypes transport,
                                  String uriPrefix,
                                  HTTPContentType contentType,
                                  ProtocolTypes protocolType,
                                  IEnumerable <String> PublicKeys)
        {
            this.TrackerId    = TrackerId;
            this.IncomingURI  = IncomingURI;
            this.ExpiredAfter = ExpiredAfter;

            this.RoamingNetworkId = RoamingNetworkId;

            this.priority     = priority;
            this.weight       = weight;
            this.hostname     = hostname;
            this.port         = port;
            this.transport    = transport;
            this.uriPrefix    = uriPrefix;
            this.contentType  = contentType;
            this.protocolType = protocolType;
            this.publicKeys   = PublicKeys;

            this.AnnouncedURI = String.Concat(transport, "://", hostname, ":", port, uriPrefix, "_", contentType);
        }
Esempio n. 7
0
        public static RoamingNetworkInfo Create(this RoamingNetwork RoamingNetwork,
                                                Tracker_Id TrackerId,
                                                DateTime ExpiredAfter,

                                                Byte priority,
                                                Byte weight,
                                                String hostname,
                                                IPPort port,
                                                TransportTypes transport,
                                                String uriPrefix,
                                                HTTPContentType contentType,
                                                ProtocolTypes protocolType,
                                                IEnumerable <String> PublicKeys)
        {
            return(new RoamingNetworkInfo(TrackerId,
                                          "",
                                          ExpiredAfter,
                                          RoamingNetwork.Id,
                                          priority,
                                          weight,
                                          hostname,
                                          port,
                                          transport,
                                          uriPrefix,
                                          contentType,
                                          protocolType,
                                          PublicKeys));
        }
Esempio n. 8
0
 public SlimNotificationOptions(ProtocolTypes enabledProtocols, bool isMandatory, ReceiverTypes enabledReceivers, string emailTemplateId)
 {
     EnabledProtocols = enabledProtocols;
     IsMandatory      = isMandatory;
     EnabledReceivers = enabledReceivers;
     EmailTemplateId  = emailTemplateId;
 }
Esempio n. 9
0
        // 接收到客户端消息
        private static void Events_MessageReceived(object sender, ClientStateEventArgs e)
        {
            ServerManager.HandleReceivedPackages(e, (context, protocol) =>
            {
                ProtocolTypes type = ProtocolTypes.FromValue(protocol.cmd);

                // 收到学生连接请求
                if (type == ProtocolTypes.S2T_Connect)
                {
                    // 验证是否当前课堂的学生
                    var valid = DoFirstValidation(context, protocol);



                    // 保持连接, 发送锁屏命令
                    if (valid)
                    {
                        T2S_LockScreenInfo proc = new T2S_LockScreenInfo();
                        proc.msg.state          = 1;
                        ServerManager.Send(proc);
                    }
                }

                // debug
                //var package = ServerManager.DefaultPackageDealer.Seal(protocol);
                //logger.Debug("收到消息 :" + protocol.ToString());
                //logger.Debug(package.ToString());
            });
        }
Esempio n. 10
0
        internal bool TryMark(EndPoint endPoint, ProtocolTypes protocolTypes, ServerQuality quality)
        {
            lock ( listLock )
            {
                ServerInfo[] serverInfos;

                if (quality == ServerQuality.Good)
                {
                    serverInfos = servers.Where(x => x.Record.EndPoint.Equals(endPoint) && x.Protocol.HasFlagsFast(protocolTypes)).ToArray();
                }
                else
                {
                    // If we're marking this server for any failure, mark all endpoints for the host at the same time
                    var host = NetHelpers.ExtractEndpointHost(endPoint).host;
                    serverInfos = servers.Where(x => x.Record.GetHost().Equals(host)).ToArray();
                }

                if (serverInfos.Length == 0)
                {
                    return(false);
                }

                foreach (var serverInfo in serverInfos)
                {
                    MarkServerCore(serverInfo, quality);
                }

                return(true);
            }
        }
Esempio n. 11
0
 /// <summary>
 ///     远程目标可访问资源
 /// </summary>
 /// <param name="client">ZooKeeper客户端实例</param>
 /// <param name="path">所需要关注的远程ZooKeeper路径</param>
 /// <param name="level">应用等级</param>
 /// <param name="protocol">通信协议</param>
 /// <param name="protocolTypes">协议类型</param>
 public ProtocolResource(ZooKeeper client, string path, Protocols protocol, ProtocolTypes protocolTypes, ApplicationLevel level)
 {
     _client        = client;
     _path          = path;
     _protocol      = protocol;
     _protocolTypes = protocolTypes;
     _level         = level;
 }
Esempio n. 12
0
        /// <summary>
        ///    根据一组参数获取相应的远程目标资源
        /// </summary>
        /// <param name="level">应用等级</param>
        /// <param name="protocol">通信协议</param>
        /// <param name="protocolTypes">协议类型</param>
        /// <returns>返回远程目标可访问资源</returns>
        public IProtocolResource GetProtocolResource(Protocols protocol, ProtocolTypes protocolTypes, ApplicationLevel level)
        {
            string            path     = string.Format("{0}/{1}-{2}-{3}-{4}-{5}", _protocolPath, protocol.ProtocolId, protocol.ServiceId, protocol.DetailsId, protocolTypes, level);
            IProtocolResource resource = new ProtocolResource(_client, path, protocol, protocolTypes, level);

            resource.ChildrenChanged += delegate(object sender, System.EventArgs args) { OnChildrenChanged(new LightSingleArgEventArgs <IProtocolResource>((IProtocolResource)sender)); };
            return(resource);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a server record for a given endpoint.
        /// </summary>
        /// <param name="host">The host to connect to. This can be an IP address or a DNS name.</param>
        /// <param name="port">The port to connect to.</param>
        /// <param name="protocolTypes">The protocol types that this server supports.</param>
        /// <returns></returns>
        public static ServerRecord CreateServer(string host, int port, ProtocolTypes protocolTypes)
        {
            if (IPAddress.TryParse(host, out var address))
            {
                return(new ServerRecord(new IPEndPoint(address, port), protocolTypes));
            }

            return(new ServerRecord(new DnsEndPoint(host, port), protocolTypes));
        }
Esempio n. 14
0
        /// <summary>
        /// Get the next server in the list.
        /// </summary>
        /// <param name="supportedProtocolTypes">The minimum supported <see cref="ProtocolTypes"/> of the server to return.</param>
        /// <returns>An <see cref="System.Net.IPEndPoint"/>, or null if the list is empty.</returns>
        public ServerRecord GetNextServerCandidate(ProtocolTypes supportedProtocolTypes)
        {
            if (!WaitForServersFetched())
            {
                return(null);
            }

            return(GetNextServerCandidateInternal(supportedProtocolTypes));
        }
Esempio n. 15
0
        public static void PrintAttribute(FileSystemCommandConnection connection, string name, object value)
        {
            var typeName = ProtocolTypes.GetTypeName(value.GetType());

            if (typeName != null)
            {
                connection.WriteTextBlock(" {0}=\"{1}:{2}\"", name,
                                          typeName, ProtocolTypes.ToEscapedString(value));
            }
        }
Esempio n. 16
0
        internal ServerRecordEndPoint([NotNull] string host, ushort port, ProtocolTypes protocolTypes)
        {
            if (string.IsNullOrEmpty(host) || (port == 0) || (protocolTypes == 0))
            {
                throw new ArgumentNullException(nameof(host) + " || " + nameof(port) + " || " + nameof(protocolTypes));
            }

            Host          = host;
            Port          = port;
            ProtocolTypes = protocolTypes;
        }
Esempio n. 17
0
 /// <summary>
 ///    更新网络缓存信息
 /// </summary>
 /// <param name="level">应用等级</param>
 /// <param name="cache">远程目标终结点信息列表</param>
 /// <param name="protocol">通信协议</param>
 /// <param name="protocolTypes">协议类型</param>
 public static void UpdateCache(Protocols protocol, ProtocolTypes protocolTypes, ApplicationLevel level, List <string> cache)
 {
     if (protocolTypes == ProtocolTypes.Metadata)
     {
         _metadataCluster.UpdateCache(protocol, level, cache);
     }
     else if (protocolTypes == ProtocolTypes.Intellegence)
     {
         _clsuter.UpdateCache(protocol, level, cache);
     }
 }
Esempio n. 18
0
    public void onDispatch(ProtocolTypes type, byte[] json)
    {
        string    jsonStr = Encoding.UTF8.GetString(json);
        Hashtable res     = (Hashtable)MiniJSON.jsonDecode(jsonStr);

        if (res == null || res.Count <= 0)
        {
            return;
        }
        onRecv.Invoke(type, res);
    }
        internal static string ToSerializedValue(this ProtocolTypes value)
        {
            switch (value)
            {
            case ProtocolTypes.Http:
                return("Http");

            case ProtocolTypes.Https:
                return("Https");
            }
            return(null);
        }
 /// <summary>
 ///    获取默认支持的协议栈
 /// </summary>
 /// <param name="protocolType">
 ///     协议类型
 ///     <para>* 默认只会支持Metadata和Intellect这两种协议栈</para>
 /// </param>
 /// <returns>返回默认的协议栈</returns>
 /// <exception cref="NotSupportedException">当前传入的协议不被支持</exception>
 public IProtocolStack GetDefaultProtocolStack(ProtocolTypes protocolType)
 {
     if (protocolType == ProtocolTypes.Metadata)
     {
         return(_metadataProtocolStack);
     }
     if (protocolType == ProtocolTypes.Intellegence)
     {
         return(_intellectProtocolStack);
     }
     throw new NotSupportedException("#Current type of protocol you passed had not supported yet.");
 }
Esempio n. 21
0
        /// <summary>
        ///     将一个业务的通信协议与远程可访问地址注册到服务器上
        /// </summary>
        /// <param name="identity">业务协议编号</param>
        /// <param name="protocolTypes">通信协议类型</param>
        /// <param name="level">KAE应用等级</param>
        /// <param name="resourceUri">远程可访问的资源地址</param>
        /// <param name="kppUniqueId">KPP全局唯一编号</param>
        public void Register(MessageIdentity identity, ProtocolTypes protocolTypes, ApplicationLevel level, Uri resourceUri, Guid kppUniqueId)
        {
            if (resourceUri == null)
            {
                throw new ArgumentNullException(nameof(resourceUri));
            }
            string path = string.Format("{0}/{1}-{2}-{3}-{4}", _protocolPath, identity.ProtocolId, identity.ServiceId, identity.DetailsId, level);

            AddPath(path, CreateMode.PERSISTENT);
            path += string.Format("/{0};{1}", resourceUri.Address, kppUniqueId);
            AddPath(path, CreateMode.PERSISTENT);
        }
Esempio n. 22
0
 /// <summary>
 /// 处理铱星模块发送回来的MO信息
 /// </summary>
 /// <param name="data"></param>
 private void HandleIridiumModelMOPayload(IridiumData data)
 {
     // 如果是正式的协议则以正常的方式处理
     if (data.Length >= TX300Items.header_length)
     {
         // TX300通讯协议首字节必定大于等于17
         // 卫星通讯协议首字节必定等于01
         if (data.Payload[0] >= 17 &&
             ProtocolTypes.IsTX300(data.Payload[2]) &&
             TerminalTypes.IsTX300(data.Payload[3]))
         {
             // 根据卫星号码查询终端的Sim卡号码并将其填入包头结构里
             using (var bll = new TerminalBLL())
             {
                 var terminal = bll.Find(f => f.TB_Satellite.CardNo.Equals(data.IMEI) && f.Delete == false);
                 if (null != terminal)
                 {
                     var sim = terminal.Sim;
                     sim += sim.Length < 11 ? "000" : "";
                     sim  = "0" + sim;
                     var s = CustomConvert.GetBytes(sim);
                     Buffer.BlockCopy(s, 0, data.Payload, 9, s.Length);
                     s = null;
                     // 更新命令的MTMSN状态为返回状态
                     HandleData(new Sockets.AsyncUserDataBuffer()
                     {
                         Buffer       = data.Payload,
                         DataType     = Sockets.AsyncUserDataType.ReceivedData,
                         IP           = "",
                         PackageType  = Sockets.AsyncDataPackageType.SAT,
                         Port         = 0,
                         ReceiveTime  = DateTime.Now,
                         SocketHandle = 0
                     });
                 }
                 else
                 {
                     ShowUnhandledMessage("Unbind satellite report data: " + CustomConvert.GetHex(data.Payload));
                 }
             }
         }
         else
         {
             HandleIridiumNewProtocolPackage(data);
         }
         // 统计铱星的接收数据次数和数据长度
         HandleIridiumMOFlow(data);
     }
     data.Dispose();
 }
Esempio n. 23
0
        /// <summary>
        ///     获取不同协议类型的网络协议栈
        /// </summary>
        /// <param name="protocol">协议类型</param>
        /// <returns>返回相应的协议栈</returns>
        /// <exception cref="NotSupportedException">不支持的协议类型</exception>
        public static object GetTransactionManager(ProtocolTypes protocol)
        {
            switch (protocol)
            {
            case ProtocolTypes.Metadata:
                return(_metadataTm);

            case ProtocolTypes.Intellegence:
                return(_intellegenceTm);

            default:
                throw new NotSupportedException(string.Format("#We've not supported current protocol: {0}!", protocol));
            }
        }
Esempio n. 24
0
        internal static IEnumerable <ProtocolTypes> GetFlags(this ProtocolTypes self)
        {
            if (self.HasFlagsFast(ProtocolTypes.Tcp))
            {
                yield return(ProtocolTypes.Tcp);
            }

            if (self.HasFlagsFast(ProtocolTypes.Udp))
            {
                yield return(ProtocolTypes.Udp);
            }

            if (self.HasFlagsFast(ProtocolTypes.WebSocket))
            {
                yield return(ProtocolTypes.WebSocket);
            }
        }
Esempio n. 25
0
        internal bool TryMark(EndPoint endPoint, ProtocolTypes protocolTypes, ServerQuality quality)
        {
            lock ( listLock )
            {
                var serverInfos = servers.Where(x => x.Record.EndPoint.Equals(endPoint) && x.Protocol.HasFlagsFast(protocolTypes)).ToArray();
                if (serverInfos.Length == 0)
                {
                    return(false);
                }

                foreach (var serverInfo in serverInfos)
                {
                    MarkServerCore(serverInfo, quality);
                }
                return(true);
            }
        }
Esempio n. 26
0
        IConnection CreateConnection(ProtocolTypes protocol)
        {
            if (protocol.HasFlagsFast(ProtocolTypes.WebSocket))
            {
                return(new WebSocketConnection());
            }
            else if (protocol.HasFlagsFast(ProtocolTypes.Tcp))
            {
                return(new EnvelopeEncryptedConnection(new TcpConnection(), Universe));
            }
            else if (protocol.HasFlagsFast(ProtocolTypes.Udp))
            {
                return(new EnvelopeEncryptedConnection(new UdpConnection(), Universe));
            }

            throw new ArgumentOutOfRangeException(nameof(protocol), protocol, "Protocol bitmask has no supported protocols set.");
        }
Esempio n. 27
0
        public void Reset()
        {
            m_Protocol     = "";
            m_ProtocolType = 0;
            m_Server       = "";
            m_Port         = "";
            m_Path         = "";
            m_Document     = "";
            m_DocumentType = 0;
            m_Anchor       = "";
            m_Params       = "";
            m_Extension    = "";
            m_EMail        = "";
            m_Domain       = "";
            m_TLD          = "";

            DomainFlag = false;
        }
Esempio n. 28
0
        public override void Process(Command command)
        {
            var options  = (CommandOptions)this.LoadOptions((TextCommand)command);
            var nodeType = NodeType.FromName(options.NodeType);
            var node     = this.Connection.FileSystemManager.Resolve(options.Uri, nodeType);

            node.Refresh();

            this.Connection.WriteOk();

            foreach (Pair <string, object> attribute in node.Attributes)
            {
                if (attribute.Value != null)
                {
                    Connection.WriteTextBlock(@"{0}=""{1}:{2}""", attribute.Name, ProtocolTypes.GetTypeName(attribute.Value.GetType()), ProtocolTypes.ToEscapedString(attribute.Value));
                }
            }
        }
Esempio n. 29
0
        public static int TypeToInt(ProtocolTypes type)
        {
            switch (type)
            {
            case ProtocolTypes.EnableProtocol: return(1);

            case ProtocolTypes.DisEnableProtocol: return(2);

            case ProtocolTypes.ChangeCompCelProtocol: return(3);

            case ProtocolTypes.EntryView: return(4);

            case ProtocolTypes.DisEntryView: return(5);

            case ProtocolTypes.ChangeCompBEProtocol: return(6);
            }
            return(0);
        }
Esempio n. 30
0
        public static IProtocolOption GetObject(ProtocolTypes type)
        {
            switch (type)
            {
            case ProtocolTypes.Version:
                return(new ProtocolVersion());

            case ProtocolTypes.MinimumVersion:
                return(new MinimumVersion());

            case ProtocolTypes.SwarmIdentifier:
                return(new SwarmIdentifier());

            case ProtocolTypes.CipMethod:
                return(new CipMethod());

            case ProtocolTypes.MhtFunction:
                return(new MhtFunction());

            case ProtocolTypes.LiveSignatureAlgorithm:
                return(new LiveSignatureAlgorithm());

            case ProtocolTypes.ChunkAdressingMethod:
                return(new ChunkAdressingMethod());

            case ProtocolTypes.LiveDiscardWindow:
                return(new LiveDiscardWindow());

            case ProtocolTypes.SupportedMessages:
                return(new SupportedMessages());

            case ProtocolTypes.ChunkSize:
                return(new ChunkSize());

            case ProtocolTypes.EndOption:
                return(new EndOption());

            default:
                return(null);
            }
        }