Пример #1
0
        //refresh selected items in listview
        public static void Refreshselected(ListView serverView, Protocol.Protocol protocolInstance,
                                           Servers serversInstance)
        {
            Server serv = serversInstance.masterServers[serverView.SelectedItems[0].Name];

            protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic);

            UpdateServerInServerView(serv, serverView);
        }
Пример #2
0
        private void updateListBackThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel,
                                          StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance,
                                          String ipport)
        {
            if (baseView.serversInstance.masterServers.ContainsKey(ipport) == false)
            {
                baseView.serversInstance.masterServers.Add(ipport, new Server());
            }

            Server serv = baseView.serversInstance.masterServers[ipport];

            protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic);
            changeCurrThread(-1, true);
        }
Пример #3
0
        public void updateAllServersThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel,
                                           StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance,
                                           bool selectedOnly, bool serverViewOnly)
        {
            killThreads = false;

            int maxthreads = 90;

            changeCurrThread(0, false);
            int count = 0;

            var updateList = new List <string>();
            int max        = 0;

            //refresh selected in server view
            if (selectedOnly && serverViewOnly)
            {
                ListView.SelectedListViewItemCollection SLVIC = serverView.SelectedItems;
                max = SLVIC.Count;
                foreach (ListViewItem LVI in SLVIC)
                {
                    updateList.Add(LVI.Name);
                }
            }
            //refresh all in server view
            else if (selectedOnly == false && serverViewOnly)
            {
                max = serverView.Items.Count;
                foreach (ListViewItem LVI in serverView.Items)
                {
                    updateList.Add(LVI.Name);
                }
            }
            //otherwise refresh all in database
            else
            {
                max = serversInstance.masterServers.Keys.Count;
                foreach (String s in serversInstance.masterServers.Keys)
                {
                    updateList.Add(s);
                }
            }

            foreach (String s in updateList)
            {
                if (selectedOnly && serverViewOnly == false && serverView.Items.ContainsKey(s) == false)
                {
                    continue;
                }

retry:
                if (killThreads)
                {
                    break;
                }

                if (currthreads > maxthreads)
                {
                    Thread.Sleep(100);
                    goto retry;
                }

                changeCurrThread(1, true);
                Thread t;

                if (serverViewOnly)
                {
                    t =
                        new Thread(
                            () =>
                            updateListServerViewThread(baseView, serverView, toolStripLabel, SS, serversInstance,
                                                       protocolInstance, s));
                }
                else
                {
                    t =
                        new Thread(
                            () =>
                            updateListBackThread(baseView, serverView, toolStripLabel, SS, serversInstance,
                                                 protocolInstance, s));
                }
                t.Start();

                Controller.ToolStripText(toolStripLabel, ref SS, "Updating " + count.ToString() + "/" + max.ToString());
                count++;
            }

            while (currthreads > 0)
            {
                Thread.Sleep(100);
            }

            Controller.ToolStripText(toolStripLabel, ref SS, "Ready");
            killThreads = false;
        }
Пример #4
0
        /// <summary>
        /// Converts AccessCondition into a <see cref="ConditionHeaderKind"/> type for use as a source conditional to Copy.
        /// </summary>
        /// <param name="condition">The original condition.</param>
        /// <param name="header">The resulting header for the condition.</param>
        /// <param name="value">The value for the condition.</param>
        internal static void GetSourceConditions(
            AccessCondition condition,
            out Protocol.ConditionHeaderKind header,
            out string value)
        {
            header = Protocol.ConditionHeaderKind.None;
            value = null;

            if (condition.AccessConditionHeader != null)
            {
                switch (condition.AccessConditionHeader.GetValueOrDefault())
                {
                    case HttpRequestHeader.IfMatch:
                        header = Protocol.ConditionHeaderKind.IfMatch;
                        break;
                    case HttpRequestHeader.IfNoneMatch:
                        header = Protocol.ConditionHeaderKind.IfNoneMatch;
                        break;
                    case HttpRequestHeader.IfModifiedSince:
                        header = Protocol.ConditionHeaderKind.IfModifiedSince;
                        break;
                    case HttpRequestHeader.IfUnmodifiedSince:
                        header = Protocol.ConditionHeaderKind.IfUnmodifiedSince;
                        break;
                    default:
                        CommonUtils.ArgumentOutOfRange("condition", condition);
                        break;
                }

                value = condition.AccessConditionValue;
            }
        }
Пример #5
0
        //refresh selected items in listview
        public static void Refreshselected(ListView serverView, Protocol.Protocol protocolInstance,
                                           Servers serversInstance)
        {
            Server serv = serversInstance.masterServers[serverView.SelectedItems[0].Name];

            protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic);

            UpdateServerInServerView(serv, serverView);
        }
Пример #6
0
        private void updateListServerViewThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel,
                                                StatusStrip SS, Servers serversInstance,
                                                Protocol.Protocol protocolInstance,
                                                String ipport)
        {
            if (baseView.serversInstance.masterServers.ContainsKey(ipport) == false)
                baseView.serversInstance.masterServers.Add(ipport, new Server());

            Server serv = baseView.serversInstance.masterServers[ipport];
            protocolInstance.updateServerInfo(serv, Protocol.Protocol.basic);
            Controller.UpdateServerInServerView(serv, serverView);
            changeCurrThread(-1, true);
        }
Пример #7
0
        public void updateAllServersThread(view baseView, ListView serverView, ToolStripLabel toolStripLabel,
                                           StatusStrip SS, Servers serversInstance, Protocol.Protocol protocolInstance,
                                           bool selectedOnly, bool serverViewOnly)
        {
            killThreads = false;

            int maxthreads = 90;

            changeCurrThread(0, false);
            int count = 0;

            var updateList = new List<string>();
            int max = 0;
            //refresh selected in server view
            if (selectedOnly && serverViewOnly)
            {
                ListView.SelectedListViewItemCollection SLVIC = serverView.SelectedItems;
                max = SLVIC.Count;
                foreach (ListViewItem LVI in SLVIC)
                {
                    updateList.Add(LVI.Name);
                }
            }
            //refresh all in server view
            else if (selectedOnly == false && serverViewOnly)
            {
                max = serverView.Items.Count;
                foreach (ListViewItem LVI in serverView.Items)
                {
                    updateList.Add(LVI.Name);
                }
            }
            //otherwise refresh all in database
            else
            {
                max = serversInstance.masterServers.Keys.Count;
                foreach (String s in serversInstance.masterServers.Keys)
                {
                    updateList.Add(s);
                }
            }

            foreach (String s in updateList)
            {
                if (selectedOnly && serverViewOnly == false && serverView.Items.ContainsKey(s) == false)
                    continue;

            retry:
                if (killThreads)
                    break;

                if (currthreads > maxthreads)
                {
                    Thread.Sleep(100);
                    goto retry;
                }

                changeCurrThread(1, true);
                Thread t;

                if (serverViewOnly)
                    t =
                        new Thread(
                            () =>
                            updateListServerViewThread(baseView, serverView, toolStripLabel, SS, serversInstance,
                                                       protocolInstance, s));
                else
                    t =
                        new Thread(
                            () =>
                            updateListBackThread(baseView, serverView, toolStripLabel, SS, serversInstance,
                                                 protocolInstance, s));
                t.Start();

                Controller.ToolStripText(toolStripLabel, ref SS, "Updating " + count.ToString() + "/" + max.ToString());
                count++;
            }

            while (currthreads > 0)
            {
                Thread.Sleep(100);
            }

            Controller.ToolStripText(toolStripLabel, ref SS, "Ready");
            killThreads = false;
        }