Exemplo n.º 1
0
        /// <summary>
        /// Finds a valid IP address by scanning the network devices
        /// </summary>
        /// <returns></returns>
        public static string GetIp(IPType type)
        {
            var localIp = NoIP;

            var host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (var ip in host.AddressList)
            {
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    if (type == IPType.Local)
                    {
                        if (IsLocalIpAddress(ip.ToString()))
                        {
                            localIp = ip.ToString();
                            return localIp;
                        }
                    }
                    else
                        localIp = ip.ToString();
                }
            }

            if (localIp == NoIP)
                throw new InvalidOperationException("The client was unable to detect an IP address or there is no active connection.");

            return localIp;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Метод определения типа хоста по имени
 /// </summary>
 private void DetectTypeByName()
 {
     if (this.NetbiosName.Length >= 10)
     {
         char c = this.NetbiosName.ToLower()[9];
         if ((char.IsDigit(c) || (c == 'f')) && (this.Type != IPType.АРМ))
         {
             this.Description = "АРМ (авто)";
             this.Type        = IPType.АРМ;
         }
         else if ((c == 'r') && (this.Type != IPType.Маршрутизатор))
         {
             this.Description = "Маршрутизатор (авто)";
             this.Type        = IPType.Маршрутизатор;
         }
         else if ((c == 'p') && (this.Type != IPType.Принтер))
         {
             this.Description = "Принтер (авто)";
             this.Type        = IPType.Принтер;
         }
         else if ((c == 's') && (this.Type != IPType.Видеорегистратор))
         {
             this.Description = "Видеорегистратор";
             this.Type        = IPType.Видеорегистратор;
         }
     }
 }
Exemplo n.º 3
0
            /// <summary>
            /// 启动一个Tcp服务器
            /// </summary>
            /// <returns><c>true</c>, 启动成功, <c>false</c> 没启动成功.</returns>
            /// <param name="OnConnectCallBack">有客户端连接时触发的回掉函数 传入的值是服务器生成的唯一的客户端的Token.</param>
            /// <param name="OnReceivedCallBack">有客户端收到信息时触发的回掉函数 传入的值是客户端Token 和客户端接收到的字符串消息 返回的字符串消息直接回复给客户端 如果为null则不回复.</param>
            /// <param name="ip">服务端绑定的ip.</param>
            /// <param name="port">监听的端口.</param>
            /// <param name="iPType">ip类型 v4 还是 v6.</param>
            /// <param name="listen">监听并发数.</param>
            public static bool ServerTcpStart(
                Action <string> OnConnectCallBack,
                Action <string, byte[]> OnReceivedCallBack,
                int port      = 8084,
                IPType iPType = IPType.IPv4,
                string ip     = "0.0.0.0",
                int listen    = 100)
            {
                try
                {
                    TcpServer = new TcpServer(ip, port, iPType, OnConnectCallBack, OnReceivedCallBack, listen);

                    TcpServer.runServer();

                    Logger.Log("TCP 服务端 已成功启动!端口:" + port + "");
                    //Logger.Log("欢迎来到微服务器,本SDK的使用详情请登录http://src.pub/查看");

                    return(true);
                }
                catch (Exception e)
                {
                    Logger.LogError(e.Message);

                    return(false);
                }
            }
Exemplo n.º 4
0
        /// <summary>
        /// 获取IP地址,本机IP地址hostname=dns.gethostname(),返回一个IP list
        /// </summary>
        /// <param name="hostname">hostname</param>
        /// <param name="iptype">ip地址的类型,IPV4,IPV6</param>
        /// <returns>返回一个字符串类型的ip list</returns>
        public static List <string> getIP(string hostname, IPType iptype, out string exmsg)
        {
            exmsg = string.Empty;
            List <string> iplist = new List <string>();

            try
            {
                IPAddress[] addressList = Dns.GetHostAddresses(hostname);
                foreach (IPAddress ip in addressList)
                {
                    if (iptype == IPType.IPV4)
                    {
                        if (ip.ToString().Contains("."))
                        {
                            iplist.Add(ip.ToString());
                        }
                    }
                    if (iptype == IPType.IPV6)
                    {
                        if (!ip.ToString().Contains("."))
                        {
                            iplist.Add(ip.ToString());
                        }
                    }
                }
                exmsg = "OK";
            }
            catch (Exception ex)
            {
                exmsg = ex.Message;
            }


            return(iplist);
        }
Exemplo n.º 5
0
        public string GetParticipantIP(int ID, IPType ipType)
        {
            string IP = string.Empty;

            IP = ipType == IPType.Sharer ? connectionManager.GetConnection(ID).SharerIP : connectionManager.GetConnection(ID).ViewerIP;
            return(IP);
        }
Exemplo n.º 6
0
 public IPAddressRange(string ipStart, string ipEnd, bool active, IPType ipType)
 {
     IpStart  = ipStart;
     IpEnd    = ipEnd;
     Active   = active;
     TypeOfIp = ipType;
 }
Exemplo n.º 7
0
        public static IPType GetIPType(string packID, SqlConnection scoConnection)
        {
            // The first part queries the CONFIGURATION table to see if anything exists for this IP. This query only
            // works for IPs that use am ActivityConfiguration type (the options menu). If not found, the second part
            // does a double-check to see if an objects XML file exists for the IP. Since it's possible for an IP to
            // use an Objects XML file that is not named <GUID>Objects.Xml (but is the default behavior for IPs created
            // using the wizard), the query is used first.
            IPType ipType = IPType.Unknown;

            SqlDataReader myReader  = null;
            SqlCommand    myCommand = new SqlCommand(string.Format("select * from [Orchestrator].[dbo].[CONFIGURATION] Where TypeGUID = '{0}'", packID), scoConnection);

            myReader = myCommand.ExecuteReader();

            //read the list
            while (myReader.Read())
            {
                ipType = IPType.Toolkit;
                continue;
            }
            myReader.Close();

            if (ipType == IPType.Unknown)
            {
                string objectsFile = GetObjectsXmlFilePath(packID);
                if (!string.IsNullOrEmpty(objectsFile))
                {
                    ipType = (Utilities.FindStringInFile(objectsFile, "QIKObjects")) ? IPType.Toolkit : IPType.Native;
                }
            }
            return(ipType);
        }
Exemplo n.º 8
0
            /// <summary>
            /// 发送一条Udp消息
            /// </summary>
            /// <param name="target">Target.</param>
            /// <param name="msg">Message.</param>
            public static void UdpSend(System.Net.EndPoint target, byte[] msg, IPType ipType = IPType.IPv4)
            {
                if (udpHandler != null)
                {
                    udpHandler = new Udp(7575, ipType);
                }

                udpHandler.SendTo(target, msg);
            }
Exemplo n.º 9
0
            /// <summary>
            /// 发送一条Udp消息
            /// </summary>
            /// <param name="ip">Ip.</param>
            /// <param name="port">Port.</param>
            /// <param name="msg">Message.</param>
            public static void UdpSend(string ip, int port, byte[] msg, IPType ipType = IPType.IPv4)
            {
                if (udpHandler == null)
                {
                    udpHandler = new Udp(7575, ipType);
                }

                udpHandler.SendTo(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(ip), port), msg);
            }
Exemplo n.º 10
0
        public Udp(int Port = 8085, IPType IpType = IPType.IPv4, Func <EndPoint, byte[], byte[]> ResponseCallBack = null, int bufferSize = 1024)
        {
            ResponseCallback = ResponseCallBack;

            IPType = IpType;

            port = Port;

            this.bufferSize = bufferSize;

            init();
        }
Exemplo n.º 11
0
 /// <summary>
 /// Метод, формирующий массив паролей в массиве string на основе логина и типа хоста
 /// </summary>
 /// <param name="login">Логин в string формате</param>
 /// <param name="iptype">Тип хоста IPType</param>
 /// <returns></returns>
 public static string[] GetPasswords(string login, IPType iptype /*, RegionEnum regiontype*/)
 {
     try
     {
         return((from s in Credentials
                 where (s.Login.Equals(login, StringComparison.OrdinalIgnoreCase) && ((s.HostType == IPType.Общий) || (s.HostType == iptype)) /*&& ((s.Region == RegionEnum.Общий)|| (s.Region == regiontype)*/)
                 select s.Password).Distinct <string>().ToArray <string>());
     }
     catch
     {
         return(new string[] { string.Empty });
     }
 }
 public IPConversions(ref string[] IPAdressArray, IPType type)
 {
     DecimalIPAddress = new byte[octet];
     BinaryIPAddress  = new string[octet];
     if (type == IPType.Decimal)
     {
         DecimalIPAddress = (from ip in IPAdressArray
                             select Convert.ToByte(ip)).ToArray();
     }
     else
     {
         BinaryIPAddress = IPAdressArray;
     }
     IPaddress = IPAdressArray;
     this.type = type;
     converted = false;
 }
Exemplo n.º 13
0
        public TcpServer(
            string _IPAddress,
            int _port,
            IPType _transProtocol,
            Action <string> OnClientConnected,
            Func <string, byte[], byte[]> OnClientReceived,
            int _ConcurrencyVolumn)
        {
            ipAddr = _IPAddress;

            port = _port;

            ConcurrencyVolumn = _ConcurrencyVolumn;

            transProtocol = _transProtocol;

            this.OnClientConnected = OnClientConnected;

            this.OnClientReceived = OnClientReceived;
        }
Exemplo n.º 14
0
        public UdpPeer(Socket _serverSocket, int bufferSize, IPType iPType)
        {
            serverSocket = _serverSocket;

            this.iPType = iPType;

            if (this.iPType == IPType.IPv4)
            {
                remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
            }
            else
            {
                remoteEndPoint = new IPEndPoint(IPAddress.IPv6Any, 0);
            }

            buffer = new byte[bufferSize];

            this.bufferSize = bufferSize;

            this.iPType = iPType;
        }
Exemplo n.º 15
0
        public bool DeepCopyFrom(SASProfile src)
        {
            if (src == null)
            {
                return(false);
            }
            this.identifier             = src.identifier;
            this.name                   = src.name;
            this.authCode               = src.authCode;
            this.kindCode               = src.kindCode;
            this.ipType                 = src.ipType;
            this.ipAddress              = src.ipAddress;
            this.latitude               = src.latitude;
            this.longitude              = src.longitude;
            this.assignedIAGWRegionCode = src.assignedIAGWRegionCode;
            this.address                = src.address;
            this.managerName            = src.managerName;
            this.managerDepartment      = src.managerDepartment;
            this.managerPhone           = src.managerPhone;

            return(true);
        }
Exemplo n.º 16
0
        void SetMulticastSettings(Profile profile, bool toVideo, bool toAudio, IPType addressType)
        {
            Action <MulticastConfiguration, int> setMulticast = (MulticastConfiguration multicast, int port) =>
            {
                multicast.TTL          = 1;
                multicast.Address.Type = addressType;
                if (addressType == IPType.IPv4)
                {
                    multicast.Address.IPv6Address = null;
                    multicast.Address.IPv4Address = "239.0.0.0";
                }
                else // IPType.IPv6
                {
                    multicast.Address.IPv4Address = null;
                    multicast.Address.IPv6Address = "FFFF:0000:0000:0000:0000:0000:0000:0000";
                }
                multicast.Port = port;
            };

            if (toVideo)
            {
                if (profile.VideoEncoderConfiguration.Multicast == null)
                {
                    profile.VideoEncoderConfiguration.Multicast = new MulticastConfiguration();
                }
                setMulticast(profile.VideoEncoderConfiguration.Multicast, 1234);
                //profile.VideoEncoderConfiguration.SessionTimeout = "PT60S";
            }
            if (toAudio)
            {
                if (profile.AudioEncoderConfiguration.Multicast == null)
                {
                    profile.AudioEncoderConfiguration.Multicast = new MulticastConfiguration();
                }
                setMulticast(profile.AudioEncoderConfiguration.Multicast, 1236);
                //profile.AudioEncoderConfiguration.SessionTimeout = "PT60S";
            }
        }
Exemplo n.º 17
0
Arquivo: p.cs Projeto: Edward125/HA_OA
        /// <summary>
        /// 获取IP地址,本机IP地址hostname=dns.gethostname(),返回一个IP list
        /// </summary>
        /// <param name="hostname">hostname</param>
        /// <param name="iptype">ip地址的类型,IPV4,IPV6</param>
        /// <returns>返回一个字符串类型的ip list</returns>
        public static List <string> getIP(string hostname, IPType iptype)
        {
            List <string> iplist = new List <string>();

            IPAddress[] addressList = Dns.GetHostAddresses(hostname);
            foreach (IPAddress ip in addressList)
            {
                if (iptype == IPType.IPV4)
                {
                    if (ip.ToString().Contains("."))
                    {
                        iplist.Add(ip.ToString());
                    }
                }
                if (iptype == IPType.IPV6)
                {
                    if (!ip.ToString().Contains("."))
                    {
                        iplist.Add(ip.ToString());
                    }
                }
            }
            return(iplist);
        }
Exemplo n.º 18
0
 protected MediaUri GetH264MediaUri(StreamType streamType, TransportProtocol protocol, IPType addressType)
 {
     return(GetVideoMediaUri(
                (options) => { return (options.H264 != null); },
                (profile, options) =>
     {
         AdjustH264VideoEncoderConfiguration(profile, options);
     },
                "H.264",
                VideoEncoding.H264,
                protocol,
                streamType,
                addressType));
 }
Exemplo n.º 19
0
 protected MediaUri GetJpegMediaUri(StreamType streamType, TransportProtocol protocol, IPType addressType)
 {
     return(GetVideoMediaUri(
                (options) => { return (options.JPEG != null); },
                (profile, options) => { },
                "JPEG",
                VideoEncoding.JPEG,
                protocol,
                streamType,
                addressType));
 }
Exemplo n.º 20
0
        public TcpClient(string _ServerIpAddr, int _ServerPort, Action <byte[]> OnReceived, IPType ipType = IPType.IPv4)
        {
            if (ipType == IPType.IPv6)
            {
                dasSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
            }
            else
            {
                dasSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            }

            IPAddress ipa = IPAddress.Parse(_ServerIpAddr);

            IPEndPoint ipe = new IPEndPoint(ipa, _ServerPort);

            this.OnReceived = OnReceived;

            dasSocket.BeginConnect(ipe, new AsyncCallback(ConnectAsynCallBack), dasSocket);
        }
Exemplo n.º 21
0
        public void SetDnsConfigurationDnsManualIpv6Test()
        {
            NetworkInterface ni = null;

            RunTest <DNSInformation>(

                new Backup <DNSInformation>(() =>
            {
                DNSInformation originalInformation = GetDnsConfiguration();
                Assert(originalInformation != null, "Failed to get original DNS configuration", "Check that original DNS configuration returned from the DUT");

                ni = TurnOffDhcpIpv6();

                return(originalInformation);
            }),

                () =>
            {
                DNSInformation testInformation = new DNSInformation();
                testInformation.FromDHCP       = false;
                testInformation.DNSManual      =
                    new IPAddress[]
                {
                    new IPAddress()
                    {
                        IPv6Address = _environmentSettings.DnsIpv6, Type = IPType.IPv6
                    }
                };

                SetDnsConfiguration(testInformation);

                double timeout = ((double)_operationDelay) / 1000;

                BeginStep(string.Format("Wait {0} seconds to allow the DUT to apply settings", timeout.ToString("0.000")));
                Sleep(_operationDelay);
                StepPassed();

                DNSInformation actualInformation = GetDnsConfiguration();

                Assert(actualInformation != null, "Failed to get current DNS configuration", "Check that current DNS configuration returned from the DUT");

                BeginStep("Check current DNS configuration");

                bool bAllEquals;

                bool bEquals = (actualInformation.FromDHCP == testInformation.FromDHCP);

                LogStepEvent(string.Format("FromDHCP: expected - {0}, actual - {1}", testInformation.FromDHCP,
                                           actualInformation.FromDHCP));

                bAllEquals = bEquals;

                string actualIpDescription;
                actualIpDescription = DeviceManagementNetworkTestSuite.DumpIPArray(actualInformation.DNSManual);

                string expectedAddress = testInformation.DNSManual[0].IPv6Address;
                IPType expectedType    = testInformation.DNSManual[0].Type;

                if (actualInformation.DNSManual.Where(
                        A => A.Type == expectedType && A.IPv6Address == expectedAddress).Count() > 0)
                {
                    bEquals = true;
                }
                else
                {
                    bEquals = false;
                }

                LogStepEvent(string.Format("DNSManual: expected - {0} should be presented, actual - {1}",
                                           expectedAddress, actualIpDescription));

                bAllEquals = bAllEquals && bEquals;

                /*************************************************/

                actualIpDescription = DeviceManagementNetworkTestSuite.DumpIPArray(actualInformation.DNSFromDHCP);

                if (actualInformation.DNSFromDHCP == null)
                {
                    bEquals = true;
                }
                else
                {
                    bEquals = (actualInformation.DNSFromDHCP.Length == 0);
                }

                string expectedDescription = "No DNSFromDHCP";

                LogStepEvent(string.Format("DNSFromDHCP: expected - {0}, actual - {1}",
                                           expectedDescription, actualIpDescription));

                bAllEquals = bAllEquals && bEquals;

                /*********************************************************/

                if (!bAllEquals)
                {
                    throw new AssertException("Current DNS configuration differs from configuration was set");
                }

                StepPassed();
            },

                (originalInformation) =>
            {
                SetDnsConfiguration(originalInformation, "Restore DNS configuration");
                if (ni.IPv6.Config.DHCP != IPv6DHCPConfiguration.Off)
                {
                    // restore network interface configuration
                    RestoreNetworkInterface(ni.token, ni);
                }
            }
                );
        }
Exemplo n.º 22
0
 /// <summary>
 /// 启动一个Tcp客户端
 /// </summary>
 /// <returns><c>true</c>, i启动成功, <c>false</c> 没启动成功.</returns>
 /// <param name="ip">要连接的IP.</param>
 /// <param name="port">端口.</param>
 /// <param name="OnReceived">接收到消息时的回掉函数 传入的值是接收到的消息 返回字符串直接发送给服务端 如果返回null则不发送.</param>
 public static bool ClientTcpStart(string ip, int port, Action <byte[]> OnReceived, IPType ipType = IPType.IPv4)
 {
     TcpClient = new TcpClient(ip, port, OnReceived, ipType);
     return(true);
 }
Exemplo n.º 23
0
        private void LoadGridView()
        {
            //format grid header
            dataGridView1.Columns[1].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[2].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[3].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[4].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[5].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Columns[6].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.Rows.Clear();

            try
            {
                _ipList = IPUtilities.GetAllIpInfo(_myConnection);

                foreach (string key in _ipList.Keys)
                {
                    //create new instances of the objects to create the row
                    DataGridViewRow          row                 = new DataGridViewRow();
                    DataGridViewTextBoxCell  ipNameCell          = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  ipTypeCell          = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  activitiesCell      = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  runbookInstanceCell = new DataGridViewTextBoxCell();
                    DataGridViewTextBoxCell  dataInstanceCell    = new DataGridViewTextBoxCell();
                    DataGridViewCheckBoxCell isRegistered        = new DataGridViewCheckBoxCell();
                    DataGridViewCheckBoxCell isDeployed          = new DataGridViewCheckBoxCell();

                    string value = string.Empty;
                    ipNameCell.Value = key;
                    _ipList.TryGetValue(key, out value);
                    ipNameCell.Tag = value;

                    //add formatting
                    ipTypeCell.Style.Alignment          = DataGridViewContentAlignment.MiddleCenter;
                    activitiesCell.Style.Alignment      = DataGridViewContentAlignment.MiddleCenter;
                    runbookInstanceCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    dataInstanceCell.Style.Alignment    = DataGridViewContentAlignment.MiddleCenter;

                    //add the cells to the row
                    row.Cells.Add(ipNameCell);
                    row.Cells.Add(ipTypeCell);
                    row.Cells.Add(activitiesCell);
                    row.Cells.Add(runbookInstanceCell);
                    row.Cells.Add(dataInstanceCell);
                    row.Cells.Add(isRegistered);
                    row.Cells.Add(isDeployed);

                    //add the row to the gridview
                    dataGridView1.Rows.Add(row);
                }


                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    try
                    {
                        string packId = row.Cells[0].Tag.ToString();
                        IPType ipType = IPUtilities.GetIPType(packId, _myConnection);

                        row.Cells[1].Value = ipType.ToString();
                        row.Cells[2].Value = IPUtilities.GetNumberOfActivitiesInIP(packId, _myConnection, ipType).ToString();
                        row.Cells[3].Value = IPUtilities.GetActivityInstancesCountForIP(packId, _myConnection, ipType).ToString();
                        row.Cells[4].Value = IPUtilities.GetActivityInstanceDataCountForIP(packId, _myConnection, ipType).ToString();

                        if (ipType == IPType.Toolkit)
                        {
                        }
                        else if (ipType == IPType.Native)
                        {
                            row.DefaultCellStyle.BackColor = Color.LightGray;
                        }
                        else  //unknown type
                        {
                            row.DefaultCellStyle.BackColor = Color.Cornsilk;
                        }
                        string productCode  = IPUtilities.GetProductCodeForIP(packId, _myConnection);
                        bool   isDeployed   = IPUtilities.IpIsDeployed(productCode, _computerName);
                        bool   isRegistered = IPUtilities.IpIsRegistered(packId);

                        row.Cells[5].Value = isRegistered;
                        row.Cells[6].Value = isDeployed;

                        if ((isRegistered == false) && (isDeployed == false))
                        {
                            row.DefaultCellStyle.BackColor = Color.LightSalmon;
                        }
                    }
                    catch { }
                }
                //re-sort columns to prioritize non-deployed, non-registered IPs
                dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Descending);
                dataGridView1.Sort(dataGridView1.Columns[6], ListSortDirection.Ascending);
                dataGridView1.Sort(dataGridView1.Columns[5], ListSortDirection.Ascending);

                //prevent the first row from being selected by default
                dataGridView1.SelectedRows[0].Selected = false;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemplo n.º 24
0
        private void DisplayIPDetails()
        {
            textBoxSelectedIPInfo.Enabled = true;
            SelectionWindowText           = "Loading IP Detail Information...";

            StringBuilder sb          = new StringBuilder();
            string        ipName      = dataGridView1.SelectedCells[0].Value.ToString();
            string        packID      = GetSelectedPackID();
            string        productCode = IPUtilities.GetProductCodeForIP(packID, _myConnection);
            IPType        ipType      = (IPType)Enum.Parse(typeof(IPType), dataGridView1.SelectedCells[1].Value.ToString());

            sb.AppendLine("IP Name            : " + ipName);
            sb.AppendLine("Registered Version : " + IPUtilities.GetRegisteredIPVersion(packID, _myConnection));
            sb.AppendLine("IP Type            : " + ipType.ToString());
            if (dataGridView1.SelectedCells[5].Value.ToString() == "True")
            {
                sb.AppendLine("IP Registered?     : Yes");
                checkBoxUnregisterIP.Enabled = true;
            }
            else
            {
                sb.AppendLine("IP Registered?     : No");
            }

            sb.AppendLine("Runbook Designers  :");
            List <string> designers = Infrastructure.GetRunbookDesigners(_myConnection);

            foreach (string designer in designers)
            {
                string ipVersion = IPUtilities.GetDeployedIpVersion(productCode, designer);
                if (!string.IsNullOrEmpty(ipVersion))
                {
                    sb.AppendLine("\t" + designer.PadRight(20) + "\tVersion " + ipVersion + " deployed");
                    checkBoxUndeployIP.Enabled = true;
                }
                else
                {
                    sb.AppendLine("\t" + designer.PadRight(20) + "\tIP not deployed");
                }
            }
            sb.AppendLine("Runbook Servers:");
            List <string> rbServers = Infrastructure.GetRunbookDesigners(_myConnection);

            foreach (string rbServer in rbServers)
            {
                string ipVersion = IPUtilities.GetDeployedIpVersion(productCode, rbServer);
                if (!string.IsNullOrEmpty(ipVersion))
                {
                    sb.AppendLine("\t" + rbServer.PadRight(20) + "\tVersion " + ipVersion + " deployed");
                    checkBoxUndeployIP.Enabled = true;
                }
                else
                {
                    sb.AppendLine("\t" + rbServer.PadRight(20) + "\tIP not deployed");
                }
            }

            sb.AppendLine("");
            int numActivities = IPUtilities.GetNumberOfActivitiesInIP(packID, _myConnection, ipType);

            sb.AppendLine("Number of Activities in the IP                   : " + numActivities);


            int numActivitiesInRunbooks = IPUtilities.GetActivityInstancesCountForIP(packID, _myConnection, ipType);

            sb.AppendLine("# of Times the Activities are Used in Runbooks   : " + numActivitiesInRunbooks);
            radioRemoveAllActivities.Enabled = (numActivitiesInRunbooks > 0);

            int numActivitiesInJobs = IPUtilities.GetActivityInstanceDataCountForIP(packID, _myConnection, ipType);

            sb.AppendLine("# of Times the Activities were Run in Jobs       : " + numActivitiesInJobs);
            radioRemoveAllJobHistory.Enabled = (numActivitiesInJobs > 0);
            sb.AppendLine("");

            int numDeletedActivitiesInRunbooks = IPUtilities.GetActivityInstancesCountForIP(packID, _myConnection, ipType, true);

            sb.AppendLine("# of 'Deleted' Activities in Runbooks            : " + numDeletedActivitiesInRunbooks);
            radioRemoveDeletedActivities.Enabled = (numDeletedActivitiesInRunbooks > 0);

            int numDeletedActivitiesInJobs = IPUtilities.GetActivityInstanceDataCountForIP(packID, _myConnection, ipType, true);

            sb.AppendLine("# of Job Data Items for 'Deleted' Activities     : " + numDeletedActivitiesInJobs);
            radioRemoveDeletedJobHistory.Enabled = (numDeletedActivitiesInJobs > 0);

            //only get list of activities for Toolkit-based IPs.
            sb.AppendLine("");
            sb.AppendLine("");
            sb.AppendLine("List of Activities in the IP and the runbooks where they are used:");
            sb.AppendLine("");
            Dictionary <string, string> activitiesList = IPUtilities.GetActivitesInIP(packID);

            sb.AppendLine("   Activity Name    /   Runbooks Where Used");
            sb.AppendLine("-------------------------------------------------------------------------");
            if (null != activitiesList)
            {
                foreach (string activity in activitiesList.Keys)
                {
                    sb.AppendLine("  " + activity);
                    string activityType = string.Empty;
                    if (activitiesList.TryGetValue(activity, out activityType))
                    {
                        List <string> runbookNames = IPUtilities.GetRunbookNamesWhereActivityTypeIsUsed(activityType, _myConnection);
                        if (runbookNames.Count > 0)
                        {
                            foreach (string name in runbookNames)
                            {
                                sb.AppendLine("                 " + name);
                            }
                            sb.AppendLine("");
                        }
                    }
                }
            }

            sb.AppendLine("");
            SelectionWindowText = sb.ToString();
        }
Exemplo n.º 25
0
        public static int GetActivityInstanceDataCountForIP(string packID, SqlConnection scoConnection, IPType ipType, bool deletedOnly)
        {
            int           instanceCount = 0;
            StringBuilder queryString   = new StringBuilder();


            queryString.Append("Select COUNT(*) FROM [Orchestrator].[dbo].[OBJECTINSTANCEDATA] oid ");
            queryString.Append("JOIN [Orchestrator].[dbo].[OBJECTINSTANCES] oi on oid.ObjectInstanceID = oi.InstanceID ");
            queryString.Append("JOIN [Orchestrator].[dbo].[OBJECTS] obj on oi.ObjectID = obj.UniqueID ");
            if (ipType == IPType.Toolkit)
            {
                queryString.Append("JOIN [Orchestrator].[dbo].[CONFIGURATION] cfg on obj.ObjectType = cfg.TypeGUID ");
                queryString.Append("Where cfg.DataName = 'QIKOBJECT' ");
                queryString.Append(string.Format("AND DataValue like '%{0}%' ", packID));
            }
            else if ((ipType == IPType.Native) || (ipType == IPType.Unknown))
            {
                queryString.Append("Where obj.ObjectType ");
                queryString.Append(BuildActivityTypesListForQuery(packID));
            }
            if (deletedOnly)
            {
                queryString.Append(" AND obj.Deleted = 1");
            }

            SqlDataReader myReader  = null;
            SqlCommand    myCommand = new SqlCommand(queryString.ToString(), scoConnection);

            myReader = myCommand.ExecuteReader();

            //read the list
            while (myReader.Read())
            {
                instanceCount = Int32.Parse(myReader[0].ToString());
            }
            myReader.Close();
            return(instanceCount);
        }
Exemplo n.º 26
0
 protected MediaUri GetJpegG726MediaUri(StreamType streamType, TransportProtocol protocol, IPType addressType)
 {
     return(GetAudioVideoMediaUri(
                (options) => { return (options.JPEG != null); },
                "JPEG",
                VideoEncoding.JPEG,
                options => (CheckAudioSupport(options, AudioEncoding.G726)),
                "G726",
                AudioEncoding.G726,
                streamType,
                protocol,
                addressType));
 }
Exemplo n.º 27
0
 public static int GetNumberOfActivitiesInIP(string packID, SqlConnection scoConnection, IPType ipType)
 {
     if (ipType == IPType.Toolkit)
     {
         return(GetNumberOfActivitiesInToolkitIP(packID, scoConnection));
     }
     else if ((ipType == IPType.Native) || (ipType == IPType.Unknown))
     {
         return(GetNumberOfActivitiesInNativeIP(packID));
     }
     return(0);
 }
Exemplo n.º 28
0
            /// <summary>
            /// 启动Udp服务器
            /// </summary>
            /// <returns><c>true</c>, 启动成功, <c>false</c> 没启动成功.</returns>
            /// <param name="port">端口.</param>
            /// <param name="ResponseCallBack">接收到消息的回掉方法 接受传入Endpoint发送源和string消息 返回string消息返回string类型返回值直接回复给客户端 如果为null则不回复.</param>
            /// <param name="iPType">IPv4 或 IPv6.</param>
            /// <param name="bufferSize">缓冲区尺寸.</param>
            public static bool ServerUdpStart(Action <System.Net.EndPoint, byte[]> ResponseCallBack = null, int port = 8085, IPType iPType = IPType.IPv4, int bufferSize = 1024)
            {
                try
                {
                    udpHandler = new Udp(port, iPType, ResponseCallBack, bufferSize);

                    udpHandler.runServer();

                    Logger.Log("UDP 服务端 已成功启动!端口:" + port + "");
                    //Logger.Log("欢迎来到微服务器,本SDK的使用详情请登录http://src.pub/查看");

                    return(true);
                }
                catch (Exception e)
                {
                    Logger.LogError("UDP Start Error" + e.Message);

                    return(false);
                }
            }
Exemplo n.º 29
0
        void SetDnsConfiguration()
        {
            DNSInformation testInformation = new DNSInformation();

            testInformation.FromDHCP  = false;
            testInformation.DNSManual =
                new IPAddress[]
            {
                new IPAddress()
                {
                    IPv4Address = _environmentSettings.DnsIpv4, Type = IPType.IPv4
                }
            };

            SetDnsConfiguration(testInformation);

            double timeout = ((double)_operationDelay) / 1000;

            BeginStep(string.Format("Wait {0} seconds to allow the DUT to apply settings", timeout.ToString("0.000")));
            Sleep(_operationDelay);
            StepPassed();

            DNSInformation actualInformation = GetDnsConfiguration();

            Assert(actualInformation != null, "Failed to get current DNS configuration", "Check that current DNS configuration returned from the DUT");

            BeginStep("Check current DNS configuration");

            bool bAllEquals;

            bool bEquals = (actualInformation.FromDHCP == testInformation.FromDHCP);

            LogStepEvent(string.Format("FromDHCP: expected - {0}, actual - {1}", testInformation.FromDHCP,
                                       actualInformation.FromDHCP));

            bAllEquals = bEquals;

            string actualIpDescription;

            actualIpDescription = DumpIPArray(actualInformation.DNSManual);

            string expectedAddress = testInformation.DNSManual[0].IPv4Address;
            IPType expectedType    = testInformation.DNSManual[0].Type;

            if (actualInformation.DNSManual.Where(
                    A => A.Type == expectedType && A.IPv4Address == expectedAddress).Count() > 0)
            {
                bEquals = true;
            }
            else
            {
                bEquals = false;
            }

            LogStepEvent(string.Format("DNSManual: expected - {0} should be presented, actual - {1}",
                                       expectedAddress, actualIpDescription));

            bAllEquals = bAllEquals && bEquals;

            // Compare DNSFromDHCP part

            actualIpDescription = DumpIPArray(actualInformation.DNSFromDHCP);

            if (actualInformation.DNSFromDHCP == null)
            {
                bEquals = true;
            }
            else
            {
                bEquals = (actualInformation.DNSFromDHCP.Length == 0);
            }

            string expectedDescription = "No DNSFromDHCP";

            LogStepEvent(string.Format("DNSFromDHCP: expected - {0}, actual - {1}",
                                       expectedDescription, actualIpDescription));

            bAllEquals = bAllEquals && bEquals;

            // Compare Search Domain

            // ToDo : remove search domain validation.
            // The DUT may leave old Search Domain (TT Release Notes)
            //expectedDescription = "no Search Domains";
            //string actualDomainsDescription = DumpStringArray(actualInformation.SearchDomain);
            //if (actualInformation.SearchDomain == null)
            //{
            //    bEquals = true;
            //}
            //else
            //{
            //    bEquals = (actualInformation.SearchDomain.Length == 0);
            //}

            //LogStepEvent(string.Format("SearchDomain: expected - {0}, actual - {1}",
            //expectedDescription, actualDomainsDescription));

            //bAllEquals = bAllEquals && bEquals;

            // Dump total result

            if (!bAllEquals)
            {
                throw new AssertException("Current DNS configuration differs from configuration was set");
            }

            StepPassed();
        }
Exemplo n.º 30
0
 public Record(string name, IPType ip, int index)
 {
     this.name = name;
     this.index = index;
     this.ip = ip;
 }
Exemplo n.º 31
0
        public static int GetActivityInstancesCountForIP(string packID, SqlConnection scoConnection, IPType ipType, bool deletedOnly)
        {
            int           instanceCount = 0;
            StringBuilder queryString   = new StringBuilder();

            queryString.Append("Select COUNT(*) FROM [Orchestrator].[dbo].[OBJECTS] WHERE ObjectType IN ");
            if (ipType == IPType.Toolkit)
            {
                queryString.Append(" (Select TypeGUID from [Orchestrator].[dbo].[CONFIGURATION] ");
                queryString.Append(string.Format("Where DataName = 'QIKOBJECT' AND DataValue like '%{0}%')", packID));
            }
            else if ((ipType == IPType.Native) || (ipType == IPType.Unknown))
            {
                queryString.Append(BuildActivityTypesListForQuery(packID));
            }
            if (deletedOnly)
            {
                queryString.Append(" AND Deleted = 1");
            }

            SqlDataReader myReader  = null;
            SqlCommand    myCommand = new SqlCommand(queryString.ToString(), scoConnection);

            myReader = myCommand.ExecuteReader();

            //read the list
            while (myReader.Read())
            {
                instanceCount = Int32.Parse(myReader[0].ToString());
            }
            myReader.Close();
            return(instanceCount);
        }
Exemplo n.º 32
0
 public static int GetActivityInstanceDataCountForIP(string packID, SqlConnection scoConnection, IPType ipType)
 {
     return(GetActivityInstanceDataCountForIP(packID, scoConnection, ipType, false));
 }