示例#1
0
 private void AddDomain(DomainInfo domainInfo)
 {
     dgvResultView.Rows.Add(new string[] { domainInfo.URL, domainInfo.Price.ToString() });
 }
示例#2
0
        void ThreadProc(Object stateInfo)
        {
            try
            {
                QueryButtonEnabled = false;
                QueryProgress      = 0;

                //get keywords
                List <string> arKeywords = new List <string>();

                for (int i = 0; i < rtbKeywords.Lines.Count(); i++)
                {
                    arKeywords.AddRange(rtbKeywords.Lines[i].Split(' '));
                }

                //get paddingwords
                List <string> arPadding = new List <string>();

                for (int i = 0; i < rtbPaddingwords.Lines.Count(); i++)
                {
                    arPadding.AddRange(rtbPaddingwords.Lines[i].Split(' '));
                }

                //process padding words
                arPadding = analyzePadding(arPadding);

                List <string> arDomains = new List <string>();
                if (arKeywords.Count == 0)
                {
                    //If no keywords
                    arDomains = arPadding;
                }
                else
                {
                    foreach (string strKeyword in arKeywords)
                    {
                        foreach (string strPadding in arPadding)
                        {
                            arDomains.Add(strPadding.Replace("$", strKeyword));
                        }
                    }
                }

                //get all extension
                List <string> arExtension = new List <string>();
                for (int i = 0; i < clbDomainExtension.Items.Count; i++)
                {
                    if (clbDomainExtension.GetItemChecked(i))
                    {
                        arExtension.Add(clbDomainExtension.GetItemText(clbDomainExtension.Items[i]));
                    }
                }

                //get all full domain name
                List <string> arDomainName = new List <string>();
                foreach (string strExtension in arExtension)
                {
                    foreach (string strDomain in arDomains)
                    {
                        arDomainName.Add(strDomain + strExtension);
                    }
                }

                //Query to Godaddy
                List <DomainInfo> arDomainInfo = new List <DomainInfo>();
                int iCount = 0, iAvailable = 0;
                foreach (string strURL in arDomainName)
                {
                    DomainInfo domainInfo = GodaddyDelegation.CheckDomain(strURL);

                    //update to progress
                    iCount++;
                    QueryProgress = iCount * 100 / arDomainName.Count;

                    if (domainInfo != null)
                    {
                        arDomainInfo.Add(domainInfo);
                        iAvailable++;

                        //Render to ListView
                        AddDomainCallback addDomainCallback = AddDomain;
                        dgvResultView.Invoke(addDomainCallback, new Object[] { domainInfo });
                    }

                    //update status
                    SetStatusStripCallback setStatusStripCallback = new SetStatusStripCallback(SetStatusStrip);
                    statusBar.Invoke(setStatusStripCallback, new Object[] { arDomainName.Count, iCount, iAvailable });
                }

                QueryButtonEnabled = true;
            }
            catch (AnalyseException analyseException)
            {
                ShowAnalyseExceptionCallback showAnalyseExceptionCallback = new ShowAnalyseExceptionCallback(ShowAnalyseException);
                this.Invoke(showAnalyseExceptionCallback, new Object[] { analyseException });
                QueryButtonEnabled = true;
                QueryProgress      = 0;
            }
        }