Пример #1
0
        public void addMissingItems()
        {
            try
            {
                string sql = "SELECT DISTINCT slot, item, short_event_name FROM loot AS l WHERE NOT EXISTS(SELECT 1 FROM items WHERE item = l.item AND short_event_name = l.short_event_name AND slot = l.slot) AND NOT EXISTS(SELECT 1 FROM items WHERE is_global = 'Yes' AND item = l.item AND slot = l.slot)";

                DbDataReader rs = DBManager.getManager().executeQuery(sql);

                while (rs.Read())
                {
                    string slot      = rs[0].ToString().Trim();
                    string item      = rs[1].ToString().Trim();
                    string eventName = rs[2].ToString().Trim();

                    logger.Info(String.Format("Inserting loot entry. [{0}, {1}, {2}]", slot, item, eventName));

                    // Send the new row to the API for insertion.
                    IList <Object> values = new List <Object> {
                        slot, item, eventName
                    };
                    GDriveManager.appendSpreadsheet(Constants.ITEMS_ID, "ROFItems", values);
                    DBManager.getManager().insertItemEntry(slot, item, eventName, "", "", "");
                }
            }
            catch (Exception e)
            {
                logger.Error("Failed to insert loot entry", e);
                throw e;
            }
        }
Пример #2
0
        public void loadItems()
        {
            // Clear the current items
            itemArr.Clear();

            ValueRange response = GDriveManager.readSpreadsheet(Constants.ITEMS_ID, "ROFItems");
            IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(response.Values);
            List <BulkLoader>         rows      = new List <BulkLoader>();

            // Iterate through each row
            foreach (IList <Object> row in response.Values.Skip(1))
            {
                ItemEntry item = new ItemEntry();
                item.itemName   = GDriveManager.readCell(row, headerMap[ITEM_NAME_COL]);
                item.eventName  = GDriveManager.readCell(row, headerMap[EVENT_COL]);
                item.slot       = GDriveManager.readCell(row, headerMap[SLOT_COL]);
                item.is_special = GDriveManager.readCell(row, headerMap[SPECIAL_COL]);

                rows.Add(item);
                itemArr.Add(item);
            }

            DBManager.getManager().bulkInsert(rows, "items");
            logger.Info("Items loaded successfully. " + itemArr.Count + " entries.");
        }
Пример #3
0
        public void loadLootInfo()
        {
            if (!isLoading)
            {
                isLoading = true;
                loadLogFeed();

                IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(logFeed.Values);
                List <BulkLoader>         rows      = new List <BulkLoader>();

                // Iterate through each row
                foreach (IList <Object> row in logFeed.Values.Skip(1))
                {
                    LootEntry loot = new LootEntry();
                    loot.date      = GDriveManager.readCell(row, headerMap["date"]);
                    loot.name      = GDriveManager.readCell(row, headerMap["name"]);
                    loot.eventName = GDriveManager.readCell(row, headerMap["event"]);
                    loot.item      = GDriveManager.readCell(row, headerMap["item"]);
                    loot.slot      = GDriveManager.readCell(row, headerMap["slot"]);
                    loot.rot       = GDriveManager.readCell(row, headerMap["rot"]);
                    loot.altLoot   = GDriveManager.readCell(row, headerMap["alt loot"]);

                    rows.Add(loot);
                }

                DBManager.getManager().emptyTable("loot");
                DBManager.getManager().bulkInsert(rows, "loot");
                isLoading = false;
            }
        }
Пример #4
0
        public void loadEvents()
        {
            events.Clear();

            ValueRange response = GDriveManager.readSpreadsheet(logURI, "RainOfFearRaids");
            IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(response.Values);

            // order by 2nd column (Short Name)
            IEnumerable <IList <Object> > sorted = response.Values.Skip(1).OrderBy(f => f.ElementAt(headerMap[EVENT_SHORT_COL]).ToString());
            List <BulkLoader>             rows   = new List <BulkLoader>();

            // Iterate through each row
            foreach (IList <Object> row in sorted)
            {
                string display = row[headerMap[EVENT_DISPLAY_COL]].ToString().ToLower();
                if (display.Equals("yes"))
                {
                    EventEntry evt = new EventEntry();
                    evt.eventName = row[headerMap[EVENT_EVENT_COL]].ToString();
                    evt.shortName = row[headerMap[EVENT_SHORT_COL]].ToString();
                    evt.tier      = row[headerMap[EVENT_TIER_COL]].ToString();

                    events.Add(evt);
                    rows.Add(evt);
                }
            }

            DBManager.getManager().bulkInsert(rows, "events");

            logger.Info("Events loaded successfully. " + events.Count + " entries.");
        }
Пример #5
0
        public void loadArmorTypes()
        {
            armorTypes.Clear();

            ValueRange response = GDriveManager.readSpreadsheet(logURI, "Constants");
            IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(response.Values);

            IEnumerable <IList <Object> > sorted = response.Values.Skip(1).OrderBy(f => f.ElementAt(headerMap[CONSTANTS_ARMOR_TYPES_NAME_COL]).ToString());
            List <BulkLoader>             rows   = new List <BulkLoader>();

            // Iterate through each row
            foreach (IList <Object> row in sorted)
            {
                ArmorTypeEntry at = new ArmorTypeEntry();
                at.armorType = GDriveManager.readCell(row, headerMap[CONSTANTS_ARMOR_TYPES_NAME_COL]);

                // for some reason if data isn't present in the 2nd column the row array is set to 1
                // not sure what happens if the first column was missing data
                if (row.Count > headerMap[CONSTANTS_TIER_COL])
                {
                    string tier = row[headerMap[CONSTANTS_TIER_COL]].ToString();
                    if (!tier.Equals(""))
                    {
                        tiers.Add(tier);
                    }
                }

                armorTypes.Add(at);
            }

            tiers.Reverse();
            logger.Info("Events loaded successfully. " + events.Count + " entries.");
        }
Пример #6
0
        public Roster()
        {
            // Clear the current roster
            rosterArr.Clear();

            ValueRange response = GDriveManager.readSpreadsheet(Constants.ROSTER_ID, "Sheet1");
            IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(response.Values);

            IEnumerable <IList <Object> > sorted = response.Values.Skip(1).OrderBy(f => f.ElementAt(headerMap[NAME_COL]).ToString());
            List <BulkLoader>             rows   = new List <BulkLoader>();

            // Iterate through each row
            foreach (IList <Object> row in sorted)
            {
                RosterEntry r = new RosterEntry();
                r.name      = GDriveManager.readCell(row, headerMap[NAME_COL]);
                r.classType = GDriveManager.readCell(row, headerMap[CLASS_COL]);
                r.rank      = GDriveManager.readCell(row, headerMap[RANK_COL]);
                r.active    = GDriveManager.readCell(row, headerMap[ACTIVE_COL]);

                rows.Add(r);
                rosterArr.Add(r);
            }

            DBManager.getManager().bulkInsert(rows, "roster");

            logger.Info("Roster loaded successfully. " + rosterArr.Count + " entries.");
        }
Пример #7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            GDriveManager.initialize();

            Application.Run(new frmMain());

            PropertyManager.getManager().close();

            logger.Info("Closing...");
        }
Пример #8
0
        public void insertNewLootEntry(string date, string name, string eventName, string item, string slot, string rot, string altLoot)
        {
            try
            {
                // Create a local representation of the new row.
                IList <Object> values = new List <Object> {
                    date, name, eventName, item, slot, rot, altLoot
                };
                GDriveManager.appendSpreadsheet(logURI, "RainOfFearLoot", values);

                logger.Info(String.Format("Inserted loot entry. [{0}, {1}, {2}, {3}, {4}, {5}, {6}]", date, name, eventName, item, slot, rot, altLoot));
            }
            catch (Exception e)
            {
                logger.Error(String.Format("Failed to insert loot entry [{0}, {1}, {2}, {3}, {4}, {5}, {6}]", date, name, eventName, item, slot, rot, altLoot), e);
                throw e;
            }
        }
Пример #9
0
 public void loadLogFeed()
 {
     logFeed = GDriveManager.readSpreadsheet(logURI, "RainOfFearLoot");
 }