private void SerializeStatsAndIntermediateOutputs(EventStore es, iCalendar ical, NonIcalStats stats, SourceType type)
 {
     SerializeStatsAndIntermediateOutputs(new FeedRegistry(this.id), es, ical, stats, type);
 }
        // public methods used by worker to collect events from all source types
        public Collector(Calinfo calinfo, Dictionary<string, string> settings)
        {
            this.calinfo = calinfo;
            this.settings = settings;

            this.mock_eventful = false;
            this.mock_upcoming = false;
            this.mock_eventbrite = false;

            this.id = calinfo.id;
            this.bs = BlobStorage.MakeDefaultBlobStorage();

            // an instance of a DDay.iCal for each source type, used to collect intermediate ICS
            // results which are saved, then combined to produce a merged ICS, e.g.:
            // http://elmcity.blob.core.windows.net/a2cal/a2cal.ics
            this.ical_ical = NewCalendarWithTimezone();
            this.eventful_ical = NewCalendarWithTimezone();
            this.upcoming_ical = NewCalendarWithTimezone();
            this.eventbrite_ical = NewCalendarWithTimezone();
            this.facebook_ical = NewCalendarWithTimezone();

            this.estats = new NonIcalStats();
            this.estats.blobname = "eventful_stats";
            this.ustats = new NonIcalStats();
            this.ustats.blobname = "upcoming_stats";
            this.ebstats = new NonIcalStats();
            this.ebstats.blobname = "eventbrite_stats";
            this.fbstats = new NonIcalStats();
            this.fbstats.blobname = "facebook_stats";
            this.mustats = new NonIcalStats();
            this.mustats.blobname = "meetup_stats";
        }
        private void SerializeStatsAndIntermediateOutputs(FeedRegistry fr, EventStore es, iCalendar ical, NonIcalStats stats, SourceType type)
        {
            BlobStorageResponse bsr;
            HttpResponse tsr;

            if (BlobStorage.ExistsContainer(this.id) == false)
                bs.CreateContainer(this.id, is_public: true, headers: new Hashtable());

            if (type == SourceType.ical) // NonIcalStats is null in this case, and not used
            {
                bsr = fr.SerializeIcalStatsToJson();
                GenUtils.LogMsg("info", this.id + ": SerializeIcalStatsToJson",  bsr.HttpResponse.status.ToString());
                tsr = fr.SaveStatsToAzure();
                GenUtils.LogMsg("info", this.id + ": FeedRegistry.SaveStatsToAzure", tsr.status.ToString());
            }
            else
            {

                bsr = Utils.SerializeObjectToJson(stats, this.id, stats.blobname + ".json");
                GenUtils.LogMsg("info", this.id + ": Collector: SerializeObjectToJson: " + stats.blobname + ".json", bsr.HttpResponse.status.ToString());
                tsr = this.SaveStatsToAzure(type);
                GenUtils.LogMsg("info", this.id + ": Collector: SaveStatsToAzure", tsr.status.ToString());

            }

            bsr = this.SerializeIcalEventsToIcs(ical, type);
            GenUtils.LogMsg("info", this.id + ": SerializeIcalStatsToIcs: " + id + "_" + type.ToString() + ".ics", bsr.HttpResponse.status.ToString());

            bsr = es.Serialize();
            GenUtils.LogMsg("info", this.id + ": EventStore.Serialize: " + es.objfile, bsr.HttpResponse.status.ToString());
        }