예제 #1
0
        // change the dates document
        public static void AlterUpdateDates()
        {
            UpdateDates update = new UpdateDates();

            update.lastUpdate = dateTimeLastUpdated;
            update.updatedTo  = dateTimeUpdatedTo;
            update.id         = "update_dates";
            if (update.updatedTo.Month == 12 && update.updatedTo.Day == 31) // if 31st december push to 1st january
            {
                update.updatedTo = update.updatedTo.AddDays(1);
            }
            DatabaseDates.ModifyDatesDocument(update);
        }
예제 #2
0
        private void RunAsync()
        {
            // check if new documents need to be created
            // documents created on first of every month for dublin and 1st of january and july for rest of country
            if (DateTime.Now.Day == 1)
            {
                Trace.TraceInformation("Worker role running on first of month, creating new documents");
                string year = DateTime.Now.Year.ToString() + "_";
                List <AlteredRecord> list = new List <AlteredRecord>();
                if (DateTime.Now.Month == 1)
                {
                    for (County co = County.Kerry; co <= County.Clare; co++)
                    {
                        if (co == County.Dublin)
                        {
                            DatabaseConnect db = new DatabaseConnect(co.ToString(), list);
                            db.CreateDocument(year + "1");
                        }
                        else
                        {
                            DatabaseConnect db = new DatabaseConnect(co.ToString(), list);
                            db.CreateDocument(year + "A");
                        }
                    }
                }
                else if (DateTime.Now.Month == 2)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "2");
                }
                else if (DateTime.Now.Month == 3)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "3");
                }
                else if (DateTime.Now.Month == 4)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "4");
                }
                else if (DateTime.Now.Month == 5)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "5");
                }
                else if (DateTime.Now.Month == 6)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "6");
                }
                else if (DateTime.Now.Month == 7)
                {
                    for (County co = County.Kerry; co <= County.Clare; co++)
                    {
                        if (co == County.Dublin)
                        {
                            DatabaseConnect db = new DatabaseConnect(co.ToString(), list);
                            db.CreateDocument(year + "7");
                        }
                        else
                        {
                            DatabaseConnect db = new DatabaseConnect(co.ToString(), list);
                            db.CreateDocument(year + "B");
                        }
                    }
                }
                else if (DateTime.Now.Month == 8)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "8");
                }
                else if (DateTime.Now.Month == 9)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "9");
                }
                else if (DateTime.Now.Month == 10)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "10");
                }
                else if (DateTime.Now.Month == 11)
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "11");
                }
                else
                {
                    DatabaseConnect db = new DatabaseConnect("Dublin", list);
                    db.CreateDocument(year + "12");
                }
            }
            // get dates from database document and check them against the websites dates to see if update available
            UpdateDates update = DatabaseDates.ReadDatesDocument().Result;

            dateTimeLastUpdated = update.lastUpdate;
            dateTimeUpdatedTo   = update.updatedTo;
            if (UpdateAvailable(update.lastUpdate))
            {
                // the main tasks of an update
                MainTasks(dateTimeUpdatedTo.Year.ToString());
            }
        }