Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public void ProcessEntries()
        {
            if (cDataBatch != null && cDataBatch.Count > 0)
            {
                List <Account> lNewRecords = new List <Account>();
                List <String>  lNewData;
                int            lDstPortInt;
                String[]       lSplitter;
                String         lProto;
                String         lSMAC;
                String         lSIP;
                String         lSPort;
                String         lDIP;
                String         lDPort;
                String         lData;

                lock (this)
                {
                    lNewData = new List <String>(cDataBatch);
                    cDataBatch.Clear();
                } // lock (this)...


                foreach (String lEntry in lNewData)
                {
                    try
                    {
                        if (!String.IsNullOrEmpty(lEntry))
                        {
                            if ((lSplitter = Regex.Split(lEntry, @"\|\|")).Length == 7)
                            {
                                lProto = lSplitter[0];
                                lSMAC  = lSplitter[1];
                                lSIP   = lSplitter[2];
                                lSPort = lSplitter[3];
                                lDIP   = lSplitter[4];
                                lDPort = lSplitter[5];
                                lData  = lSplitter[6];


                                /*
                                 * HTML GET authentication strings
                                 */
                                sHTTPAccount lAuthData = new sHTTPAccount();

                                try
                                {
                                    lAuthData = FindAuthString(lData);
                                }
                                catch (Exception lEx)
                                {
                                    PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message));
                                    return;
                                }

                                if (lAuthData.CompanyURL.Length > 0 && lAuthData.Username.Length > 0 && lAuthData.Password.Length > 0)
                                {
                                    if (!Int32.TryParse(lDPort, out lDstPortInt))
                                    {
                                        throw new Exception("Something is wrong with the remote port.");
                                    }
                                    else if (!Regex.Match(lDIP, @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$").Success&& !Regex.Match(lDIP, @"\.[\d\w]+").Success)
                                    {
                                        throw new Exception("Something is wrong with the remote system.");
                                    }

                                    lNewRecords.Add(new Account(lSMAC, lSIP, lAuthData.CompanyURL, lDPort, lAuthData.Username, lAuthData.Password));
                                } // if (lAuthData.Co...
                            }     // if (lSplitter...
                        }         // if (pData.Lengt ...
                    }
                    catch (Exception lEx)
                    {
                        PluginParameters.HostApplication.LogMessage(String.Format("{0} : {1}", Config.PluginName, lEx.Message));
                    }
                } // foreach ...

                if (lNewRecords.Count > 0)
                {
                    cTask.addRecord(lNewRecords);
                }
            } // if (cDataBat...
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        public void ProcessEntries()
        {
            if (cDataBatch != null && cDataBatch.Count > 0)
              {
            List<Account> lNewRecords = new List<Account>();
            List<String> lNewData;
            int lDstPortInt;
            String[] lSplitter;
            String lProto;
            String lSMAC;
            String lSIP;
            String lSPort;
            String lDIP;
            String lDPort;
            String lData;

            lock (this)
            {
              lNewData = new List<String>(cDataBatch);
              cDataBatch.Clear();
            } // lock (this)...

            foreach (String lEntry in lNewData)
            {
              try
              {
            if (!String.IsNullOrEmpty(lEntry))
            {
              if ((lSplitter = Regex.Split(lEntry, @"\|\|")).Length == 7)
              {
                lProto = lSplitter[0];
                lSMAC = lSplitter[1];
                lSIP = lSplitter[2];
                lSPort = lSplitter[3];
                lDIP = lSplitter[4];
                lDPort = lSplitter[5];
                lData = lSplitter[6];

                /*
                 * HTML GET authentication strings
                 */
                sHTTPAccount lAuthData = new sHTTPAccount();

                try
                {
                  lAuthData = FindAuthString(lData);
                }
                catch (Exception lEx)
                {
                  PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message));
                  return;
                }

                if (lAuthData.CompanyURL.Length > 0 && lAuthData.Username.Length > 0 && lAuthData.Password.Length > 0)
                {
                  if (!Int32.TryParse(lDPort, out lDstPortInt))
                    throw new Exception("Something is wrong with the remote port.");
                  else if (!Regex.Match(lDIP, @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$").Success && !Regex.Match(lDIP, @"\.[\d\w]+").Success)
                    throw new Exception("Something is wrong with the remote system.");

                  lNewRecords.Add(new Account(lSMAC, lSIP, lAuthData.CompanyURL, lDPort, lAuthData.Username, lAuthData.Password));
                } // if (lAuthData.Co...
              } // if (lSplitter...
            } // if (pData.Lengt ...
              }
              catch (Exception lEx)
              {
            PluginParameters.HostApplication.LogMessage(String.Format("{0} : {1}", Config.PluginName, lEx.Message));
              }
            } // foreach ...

            if (lNewRecords.Count > 0)
              cTask.addRecord(lNewRecords);

              } // if (cDataBat...
        }