Example #1
0
    public int GetJudgeNameId()
    {
        if (JudgeNameId != -1 && !bIsDataDirty)
        {
            return(JudgeNameId);
        }

        if (CurPool != EPool.None)
        {
            ResultsData Data = TournamentData.FindResultsData(CurDivision, CurRound, CurPool);
            JudgeNameId = Data.GetNameId(JudgerCategory, JudgeCategoryIndex);
        }

        return(JudgeNameId);
    }
    void ExportScheduleToExcel()
    {
        if (CurDivIndex != -1 && CurRoundIndex != -1 && File.Exists(ExcelPath))
        {
            StringWriter OutStr = new StringWriter();

            OutStr.WriteLine((EDivision)(CurDivIndex) + " - " + (ERound)(CurRoundIndex) + "\t\tJudges");
            List <PoolData> Pools     = Global.AllData.AllDivisions[CurDivIndex].Rounds[CurRoundIndex].Pools;
            int             PoolIndex = 0;
            foreach (PoolData pd in Pools)
            {
                OutStr.WriteLine("Pool " + pd.PoolName + "\t\tAI\tEx\tDiff");
                ResultsData JData = TournamentData.FindResultsData((EDivision)CurDivIndex, (ERound)CurRoundIndex, (EPool)PoolIndex);

                int TeamNum = 0;
                foreach (TeamDataDisplay tdd in pd.Teams)
                {
                    ++TeamNum;
                    OutStr.Write(TeamNum + ": " + tdd.Data.PlayerNames + "\t\t");

                    if (JData != null)
                    {
                        int NameId = JData.GetNameId(ECategory.AI, TeamNum - 1);
                        if (NameId != -1)
                        {
                            OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName);
                        }
                        OutStr.Write("\t");

                        NameId = JData.GetNameId(ECategory.Ex, TeamNum - 1);
                        if (NameId != -1)
                        {
                            OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName);
                        }
                        OutStr.Write("\t");

                        NameId = JData.GetNameId(ECategory.Diff, TeamNum - 1);
                        if (NameId != -1)
                        {
                            OutStr.Write(NameDatabase.FindInDatabase(NameId).DisplayName);
                        }
                        OutStr.WriteLine("\t");
                    }
                }

                OutStr.WriteLine();

                ++PoolIndex;
            }

            int    TempNum      = 0;
            string TempFilePath = Application.persistentDataPath + "/TempExcelStr.txt";
            if (File.Exists(TempFilePath))
            {
                bool bDeletedFile = false;
                while (!bDeletedFile)
                {
                    try
                    {
                        File.Delete(TempFilePath);

                        bDeletedFile = true;
                    }
                    catch
                    {
                        TempFilePath = Application.persistentDataPath + "/TempExcelStr-" + TempNum++ + ".txt";
                    }
                }
            }
            StreamWriter TempFile = new StreamWriter(TempFilePath);
            TempFile.Write(OutStr.ToString());
            TempFile.Close();
            OutStr.Close();

            TempFilePath = TempFilePath.Replace('/', '\\');
            Process.Start(ExcelPath, "\"" + TempFilePath + "\"");
        }
    }