private int LoadInfoDB(TokenGitHubInfo inf, bool truncate)
        {
            DbOper dbo = new DbOper();

            if (truncate)
            {
                dbo.TruncateTables();
            }

            dbo.LoadRoot(inf.CoinID, inf.Symbol, inf.GitHubRoot, inf.GitHubLeadPrj, inf.ReposNumber, inf.Followers, inf.CreatedAt,
                         inf.UpdatedAt, inf.ErrNum.ToString(), inf.ErrMes, inf.Url);
            if (dbo.ErrNum > 0)
            {
                intErr = dbo.ErrNum;
                strErr = dbo.ErrMes;
                dbo.CloseConn();
                return(intErr);
            }

            if (inf.ErrNum > 0)
            {
                return(intErr);
            }

            dbo.LoadHithubInfoTable("RepoInfo", "repoinfo.txt");
            if (dbo.ErrNum > 0)
            {
                intErr = dbo.ErrNum;
                strErr = dbo.ErrMes;
                dbo.CloseConn();
                return(intErr);
            }

            dbo.LoadHithubInfoTable("ContribInfo", "contribinfo.txt");
            if (dbo.ErrNum > 0)
            {
                intErr = dbo.ErrNum;
                strErr = dbo.ErrMes;
                dbo.CloseConn();
                return(intErr);
            }

            //dbo.CloseConn();
            return(intErr);
        }
        private void cmdRepeatCommit_Click(object sender, EventArgs e)
        {
            DbOper    dbOper       = new DbOper();
            DataTable dtRepCommits = dbOper.GetCommitsForRepeat();
            string    coinid       = "";
            string    symbol       = "";
            string    githubroot   = "";
            string    reponame     = "";
            string    repoid       = "";

            //** Secret Key
            string strGAuth = ConfigurationManager.AppSettings["gthauth"];
            ContribInfoCompiler ctrbListComp     = null;
            ContribCommit       cbcCommits       = null;
            StringBuilder       sbContribCommits = null;
            string DL = "|";

            foreach (DataRow dr in dtRepCommits.Rows)
            {
                coinid     = dr[0].ToString();
                symbol     = dr[1].ToString();
                githubroot = dr[2].ToString();
                repoid     = dr[3].ToString();
                reponame   = dr[4].ToString();

                Repo rpRepo = new Repo();
                rpRepo.RepoID   = repoid;
                rpRepo.RepoName = reponame;

                sbContribCommits = new StringBuilder();

                ctrbListComp = new ContribInfoCompiler(strGAuth);
                ctrbListComp.GetContribCommits(rpRepo, githubroot);

                for (int k = 0; k < rpRepo.Contribs.Count; k++)
                {
                    cbcCommits = rpRepo.Contribs[k];
                    if (cbcCommits == null)
                    {
                        continue;
                    }
                    sbContribCommits.Append(coinid + DL + symbol + DL + rpRepo.RepoID + DL + rpRepo.RepoName + DL + cbcCommits.LoginName + DL +
                                            cbcCommits.Additions + DL + cbcCommits.Deletions + DL + cbcCommits.Commits + DL + cbcCommits.CommTime + DL +
                                            cbcCommits.ErrNum.ToString() + DL + cbcCommits.ErrMes + DL + cbcCommits.Cnt.ToString() + DL + cbcCommits.Url + "\n");
                }

                if (sbContribCommits.Length > 0)
                {
                    dbOper.DeleteRepeatCommits(coinid, symbol, reponame);
                    if (dbOper.ErrNum > 0)
                    {
                        intErr = dbOper.ErrNum;
                        strErr = dbOper.ErrMes;
                    }

                    File.WriteAllText("contribinfo.txt", sbContribCommits.ToString());

                    dbOper.LoadHithubInfoTable("ContribInfo", "contribinfo.txt");
                    if (dbOper.ErrNum > 0)
                    {
                        intErr = dbOper.ErrNum;
                        strErr = dbOper.ErrMes;
                    }
                }

                Thread.Sleep(3000);
            }

            MessageBox.Show("Success!");
        }
        private void cmdRunAll_Click(object sender, EventArgs e)
        {
            int    smallset = 0;
            DbOper dbo      = new DbOper();

            if (chkClean.Checked)
            {
                dbo.TruncateTables();
            }
            if (chkSmall.Checked)
            {
                smallset = 1;
            }

            DataTable dtCoins = dbo.GetCoinsForGitHub(smallset);

            //** Secret Key
            string strGAuth = ConfigurationManager.AppSettings["gthauth"];

            TokenGitHubInfo     inf          = null;
            ProjectInfoBuilder  infoBuild    = new ProjectInfoBuilder(strGAuth);
            RepoListCompiler    repListComp  = new RepoListCompiler(strGAuth);
            ContribInfoCompiler ctrbListComp = new ContribInfoCompiler(strGAuth);
            ProjectsLoader      ldPrj        = new ProjectsLoader();
            Repo        rpRep    = null;
            List <Repo> lstRepos = null;;
            string      lprj     = "";

            foreach (DataRow dr in dtCoins.Rows)
            {
                lprj = dr[3].ToString().Replace("/", "");
                if (lprj.Length > 20)
                {
                    lprj = "-";
                }
                if (lprj.Equals(""))
                {
                    lprj = "-";
                }
                inf = infoBuild.GetProjectInfo(dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), lprj);

                //** Get Repo List
                repListComp.GetRepoList(inf);

                lstRepos = inf.RepoList;

                for (int i = 0; i < lstRepos.Count; i++)
                {
                    rpRep = lstRepos[i];
                    ctrbListComp.GetContribCommits(rpRep, inf.GitHubRoot);
                    Thread.Sleep(3000);
                }

                ldPrj.LoadGitHubInfo(inf, false);

                //if (ldPrj.LoadGitHubInfo(inf, false) > 0)
                //{
                //    //MessageBox.Show(ldPrj.ErrMes);
                //    //continue;
                //}

                Thread.Sleep(2000);
            }

            MessageBox.Show("Success!");
        }