Esempio n. 1
0
 private void ParseRegCounts(string str)
 {
     RegCounts = new List <RegCount>();
     if (str != null)
     {
         var list = str.Split(';');
         foreach (string s in list)
         {
             var prox = s.Split('|');
             if (prox.Length == 3)
             {
                 var rc = new RegCount()
                 {
                     CountRegistrations = int.Parse(prox[0]),
                     RegDate            = DateTime.ParseExact(prox[1], Const.DateFormat, CultureInfo.InvariantCulture),
                     Address            = prox[2]
                 };
                 if (rc.RegDate.ToString(Const.DateFormat, CultureInfo.InvariantCulture) ==
                     DateTime.Now.ToString(Const.DateFormat, CultureInfo.InvariantCulture))
                 {
                     RegCounts.Add(rc);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void ParseProxies(string str)
        {
            ProxyUsers = new Dictionary <WebProxy, NetworkCredential>();
            WebProxies = new Queue <WebProxy>();
            var list = str.Split(';');

            foreach (string s in list)
            {
                var prox = s.Split(':');
                if (prox.Length == 4)
                {
                    try
                    {
                        WebProxy proxy = new WebProxy(prox[0], int.Parse(prox[1]));
                        //Set credentials
                        var credentials = new NetworkCredential(prox[2], prox[3]);
                        proxy.Credentials = credentials;
                        ProxyUsers.Add(proxy, credentials);
                        //Set proxy
                        //WebProxy proxy = new WebProxy(proxyURI, true, null, credentials );
                        // WebProxy proxy = new WebProxy(prox[0], int.Parse(prox[1]));
                        WebProxies.Enqueue(proxy);
                        RegCount rcTofind = null;
                        foreach (var rc in RegCounts)
                        {
                            if (rc.Address == proxy.Address.ToString())
                            {
                                rcTofind = rc;
                                break;
                            }
                        }
                        ProxyRegCounts.Add(proxy, rcTofind);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex);
                    }
                }
            }
            if (WebProxies.Count > 0)
            {
                CurrentWebProxy = WebProxies.Peek();
            }
        }