Example #1
0
        /* C R E A T E  M A I L  M E R G E  D O C */
        /*----------------------------------------------------------------------------
            %%Function: CreateMailMergeDoc
            %%Qualified: ArbWeb.OOXML.CreateMailMergeDoc
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public static void CreateMailMergeDoc(string sTemplate, string sDest, string sDataSource, GameData.GameSlots gms, out string sArbiterHelpNeeded)
        {
            System.IO.File.Copy(sTemplate, sDest);
            Package pkg = Package.Open(sDest, FileMode.Open, FileAccess.ReadWrite, FileShare.None);

            CreateDocSettings(pkg, sDataSource);
            CreateMainDoc(pkg, sDataSource, gms, out sArbiterHelpNeeded);
            pkg.Flush();
            pkg.Close();
        }
Example #2
0
        /* L O A D  D A T A */
        /*----------------------------------------------------------------------------
            %%Function: LoadData
            %%Qualified: ArbWeb.CountsData.LoadData
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public void LoadData(string sRoster, string sSource, bool fIncludeCanceled, int iMiscAffiliation)
        {
            //            srpt.UnitTest();
            m_gmd = new GameData(m_srpt);
            m_srpt.AddMessage("Loading roster...", StatusRpt.MSGT.Header, false);

            m_gmd.FLoadRoster(sRoster, iMiscAffiliation);
            // m_srpt.AddMessage(String.Format("Using plsMisc[{0}] ({1}) for team affiliation", iMiscAffiliation, m_gmd.SMiscHeader(iMiscAffiliation)), StatusBox.StatusRpt.MSGT.Body);

            m_srpt.PopLevel();
            m_srpt.AddMessage("Loading games...", StatusRpt.MSGT.Header, false);
            m_gmd.FLoadGames(sSource, fIncludeCanceled);
            m_srpt.PopLevel();
            // read in the roster of umpires...
        }
Example #3
0
        /* C R E A T E  M A I N  D O C */
        /*----------------------------------------------------------------------------
            %%Function: CreateMainDoc
            %%Qualified: ArbWeb.OOXML.CreateMainDoc
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public static bool CreateMainDoc(Package pkg, string sDataSource, GameData.GameSlots gms, out string sArbiterHelpNeeded)
        {
            PackagePart prt;
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id='D9UrgentHelpNeeded'><h1>HELP NEEDED</h1><h4> The following upcoming games URGENTLY need help! <br>Please <a href=\"https://www.arbitersports.com/Official/SelfAssign.aspx\">SELF ASSIGN</a> now!</h4><style>    table.help td {padding-left: 2mm;padding-right: 2mm;}td.bold {font-weight: bold;}</style> <table class='help' border=1 style='border-collapse: collapse'></div>");

            Stream stm = StmCreatePart(pkg, "/word/document.xml", s_sUriContentTypeDoc, out prt);

            XmlTextWriter xw = new XmlTextWriter(stm, System.Text.Encoding.UTF8);

            StartElement(xw, "document");
            StartElement(xw, "body");
            WritePara(xw, "The following upcoming games URGENTLY need help!");
            WritePara(xw, "If you can work ANY of these games, either sign up on Arbiter, or just reply to this mail and let me know which games you can do. Thanks!");

            StartTable(xw, 5);
            Dictionary<string, List<GameData.Game>> mpSlotGames = new Dictionary<string, List<GameData.Game>>();

            foreach (GameData.Game gm in gms.Games.Values)
                {
                if (gm.TotalSlots - gm.OpenSlots > 1)
                    continue;

                string s = String.Format("{0}-{1}-{2}", gm.Slots[0].Dttm.ToString("yyyyMMdd:HHmm"), gm.Slots[0].SiteShort, gm.TotalSlots - gm.OpenSlots);
                if (!mpSlotGames.ContainsKey(s))
                    mpSlotGames.Add(s, new List<GameData.Game>());

                mpSlotGames[s].Add(gm);
                }

            foreach (List<GameData.Game> plgm in mpSlotGames.Values)
                {
                WriteGame(xw, plgm[0], plgm.Count);
                AppendGameToSb(plgm[0], plgm.Count, sb);
                }
            EndTable(xw);
            sb.Append("</table>");
            EndElement(xw); // body
            EndElement(xw); // document

            xw.Flush();
            stm.Flush();

            sArbiterHelpNeeded = sb.ToString();
            return true;
        }
Example #4
0
        static void WriteGame(XmlTextWriter xw, GameData.Game gm, int cGames)
        {
            StartElement(xw, "tr");
            WriteSingleParaCell(xw, "0", "auto", gm.Slots[0].Dttm.ToString("M/dd"));
            WriteSingleParaCell(xw, "0", "auto", gm.Slots[0].Dttm.ToString("ddd h tt"));

            WriteSingleParaCell(xw, "0", "auto", FriendlySport(gm));
            WriteSingleParaCell(xw, "0", "auto", gm.Slots[0].SiteShort);

            WriteSingleParaCell(xw, "0", "auto", DescribeGame(gm, cGames));
            EndElement(xw); // tr
        }
Example #5
0
        static string FriendlySport(GameData.Game gm)
        {
            if (s_mpSportLevelFriendly.ContainsKey(gm.Slots[0].SportLevel))
                return s_mpSportLevelFriendly[gm.Slots[0].SportLevel];

            return gm.Slots[0].SportLevel;
        }
Example #6
0
        static string DescribeGame(GameData.Game gm, int cGames)
        {
            string sDesc;
            string sCount = "";

            if (cGames > 1)
                sCount = String.Format("{0} games, ", cGames);
            else
                sCount = String.Format("{0} game, ", cGames);

            if (gm.TotalSlots - gm.OpenSlots == 0)
                sDesc = "NO UMPIRES";
            else
                sDesc = String.Format("{0} UMPIRE", gm.TotalSlots - gm.OpenSlots);

            return String.Format("{0}{1}", sCount, sDesc);
        }
Example #7
0
 static void AppendGameToSb(GameData.Game gm, int cGames, StringBuilder sb)
 {
     sb.Append(String.Format("<tr><td>{0}<td>{1}", gm.Slots[0].Dttm.ToString("M/dd"), gm.Slots[0].Dttm.ToString("ddd h tt")));
     sb.Append(String.Format("<td>{0}<td>{1}<td class='bold'>{2}", FriendlySport(gm), gm.Slots[0].SiteShort, DescribeGame(gm, cGames)));
 }
Example #8
0
        /* A D D  S L O T */
        /*----------------------------------------------------------------------------
            %%Function: AddSlot
            %%Qualified: ArbWeb.SlotCount.AddSlot
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public void AddSlot(GameData.GameSlot gm)
        {
            if (m_mpSportCount.ContainsKey(gm.Sport))
                m_mpSportCount[gm.Sport]++;
            else
                m_mpSportCount.Add(gm.Sport, 1);

            if (m_mpSportLevelCount.ContainsKey(gm.SportLevel))
                m_mpSportLevelCount[gm.SportLevel]++;
            else
                m_mpSportLevelCount.Add(gm.SportLevel, 1);

            string sSite = gm.SiteShort;

            if (m_mpSiteCount.ContainsKey(sSite))
                m_mpSiteCount[sSite]++;
            else
                m_mpSiteCount.Add(sSite, 1);
        }
Example #9
0
        /* S L O T  C O U N T */
        /*----------------------------------------------------------------------------
            %%Function: SlotCount
            %%Qualified: ArbWeb.SlotCount.SlotCount
            %%Contact: rlittle

        ----------------------------------------------------------------------------*/
        public SlotCount(GameData.GameSlot gm)
        {
            m_dttmSlot = gm.Dttm;
            m_mpSportCount = new Dictionary<string, int>();
            m_mpSportCount.Add(gm.Sport, 1);
            m_mpSportLevelCount = new Dictionary<string, int>();
            m_mpSportLevelCount.Add(gm.SportLevel, 1);
            m_mpSiteCount = new Dictionary<string, int>();
            m_mpSiteCount.Add(gm.SiteShort, 1);
        }