Example #1
0
        public Manager(Configuration configuration, Action<string> outputText)
        {
            Log.InitializeOutputSource(outputText, Path.Combine(configuration.StoragePath, "log.txt"));

            m_configuration = configuration;

            m_server = new Server();
            m_info = new AppInfo(m_server, m_configuration);

            m_server.Initialize(m_info);

            m_features = new Dictionary<FeatureType, Feature>();

            // Initialize features; we should have a better factory for this; any new features should be added here.
            m_features.Add(FeatureType.Contact, new Features.ContactFeature(m_info));
            m_features.Add(FeatureType.Company, new Features.CompanyFeature(m_info));
            m_features.Add(FeatureType.List, new Features.ListFeature(m_info));
            m_features.Add(FeatureType.ListMembership, new Features.ListMembershipFeature(m_info));
            m_features.Add(FeatureType.Workflow, new Features.WorkflowFeature(m_info));
            m_features.Add(FeatureType.WorkflowEnrollment, new Features.WorkflowEnrollmentFeature(m_info));
            m_features.Add(FeatureType.ContactProperty, new Features.ContactPropertyFeature(m_info));
            m_features.Add(FeatureType.CompanyProperty, new Features.CompanyPropertyFeature(m_info));
            m_features.Add(FeatureType.ContactPropertyGroup, new Features.SingleCallFeature(m_info, FeatureType.ContactPropertyGroup, "contacts/v2/groups"));
            m_features.Add(FeatureType.CompanyPropertyGroup, new Features.SingleCallFeature(m_info, FeatureType.CompanyPropertyGroup, "companies/v2/groups"));
            m_features.Add(FeatureType.Form, new Features.FormFeature(m_info));
            m_features.Add(FeatureType.CalendarEvent, new Features.CalendarEventFeature(m_info));
        }
Example #2
0
        public void Start(bool interactive)
        {
            var config = new HubSpotManager.Configuration()
            {
                ApiKey = Configuration.HubSpotApiKey,
                MaxDailyRequests = Configuration.MaxDailyRequests,
                StoragePath = GetStoragePath(Configuration.StoragePath),
                MaxRecordCount = Configuration.MaxRecordCount,
                DelayHttpRetry = Configuration.DelayHttpRetry,
                CalendarPreviousDayCount = Configuration.CalendarPreviousDayCount,
                CalendarUpcomingDayCount = Configuration.CalendarUpcomingDayCount
            };

            Console.WriteLine("ApiKey: {0}", config.ApiKey);
            Console.WriteLine("MaxDailyRequests: {0}", config.MaxDailyRequests);
            Console.WriteLine("StoragePath: {0}", config.StoragePath);
            Console.WriteLine("MaxRecordCount: {0}", config.MaxRecordCount);
            Console.WriteLine("DelayHttpRetry: {0}", config.DelayHttpRetry);
            Console.WriteLine("CalendarPreviousDayCount: {0}", config.CalendarPreviousDayCount);
            Console.WriteLine("CalendarUpcomingDayCount: {0}", config.CalendarUpcomingDayCount);

            if (interactive)
            {
                ConsoleWriteLine("Backup will run with the above configuration.  Type \"start\" and press <enter> to continue; anything else to quit.  Run the program with \"/start\" to suppress this.", ConsoleColor.Cyan);
                Console.Write("> ");
                string result = Console.ReadLine();
                if (!result.Equals("start", StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }
            }

            // Assert there is no downloaded information currently in the file system before downloading it
            if (Directory.Exists(config.StoragePath) && Directory.GetDirectories(config.StoragePath).Length > 0)
            {
                Console.WriteLine("The storage folder you specified contains files.  Ensure the folder is empty before continuing");
                return;
            }

            ConsoleWriteLine("Starting backup...", ConsoleColor.Cyan);

            m_manager = new HubSpotManager.Manager(config, this.OutputText);

            m_manager.ProgressUpdated += OnProgressUpdated;

            Task t = m_manager.BackupRemoteHubSpot();

            try
            {
                t.Wait();
            }
            catch(Exception ex)
            {
                ConsoleWriteLine(ex.ToString(), ConsoleColor.Red);
            }

            ConsoleWriteLine("Backup complete", ConsoleColor.Green);
        }
Example #3
0
        private void InitializeModel()
        {
            if (m_manager != null)
            {
                return;
            }

            this.groupBoxConfiguration.Enabled = false;

            var config = new HubSpotManager.Configuration()
            {
                ApiKey = this.textBoxApiKey.Text,
                MaxDailyRequests = Convert.ToInt32(this.textBoxTotalDailyRequests.Text),
                StoragePath = GetStoragePath(),
                MaxRecordCount = Convert.ToInt32(this.textBoxMaxRecordCount.Text),
                DelayHttpRetry = this.checkBoxDelayRetry.Checked,
                CalendarPreviousDayCount = Convert.ToInt32(this.numericUpDownCalendarPreviousDays.Value),
                CalendarUpcomingDayCount = Convert.ToInt32(this.numericUpDownCalendarUpcomingDays.Value)
            };

            m_manager = new HubSpotManager.Manager(config, this.OutputText);

            m_manager.ProgressUpdated += OnProgressUpdated;
        }