public void RunForm()
        {
            bool stopRun = false;

            var appTitle = "6 Minute Seller";

            if (PowerPointManager.IsPowerPointMultipleInstances())
            {
                using (var form = new FormPowerPointSeveralInstancesWarning())
                {
                    form.Text = appTitle;
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
            }

            PopupMessageHelper.Instance.Title = appTitle;

            AppProfileManager.Instance.InitApplication(AppTypeEnum.Dashboard);

            FileStorageManager.Instance.UsingLocalMode += (o, e) =>
            {
                if (FileStorageManager.Instance.UseLocalMode)
                {
                    return;
                }
                FormStart.CloseProgress();
                if (FileStorageManager.Instance.DataState != DataActualityState.Updated)
                {
                    PopupMessageHelper.Instance.ShowWarning("Server is not available. Application will be closed");
                    stopRun = true;
                }
                else if (PopupMessageHelper.Instance.ShowWarningQuestion("Server is not available. Do you want to continue to work in local mode?") != DialogResult.Yes)
                {
                    stopRun = true;
                }
                if (stopRun)
                {
                    FormStart.Destroy();
                }
            };

            FileStorageManager.Instance.Authorizing += (o, e) =>
            {
                var authManager = new AuthManager();
                FormStart.SetTitle("Checking credentials...");
                e.LightCheck = true;
                authManager.Auth(e);
            };

            FormStart.ShowProgress();
            FormStart.SetTitle("Connecting to adSALEScloud…");
            var thread = new Thread(() => AsyncHelper.RunSync(() => FileStorageManager.Instance.InitStorage()));

            thread.Start();
            while (thread.IsAlive)
            {
                Application.DoEvents();
            }

            if (stopRun)
            {
                return;
            }

            FileStorageManager.Instance.Downloading += (sender, args) =>
                                                       FormStart.SetDetails(args.ProgressPercent < 100 ?
                                                                            String.Format("Loading {0} - {1}%", args.FileName, args.ProgressPercent) :
                                                                            String.Empty);
            FileStorageManager.Instance.Extracting += (sender, args) =>
                                                      FormStart.SetDetails(args.ProgressPercent < 100 ?
                                                                           String.Format("Extracting {0} - {1}%", args.FileName, args.ProgressPercent) :
                                                                           String.Empty);

            if (FileStorageManager.Instance.Activated)
            {
                if (FileStorageManager.Instance.DataState == DataActualityState.NotExisted)
                {
                    FormStart.SetTitle("Syncing adSALEScloud for the 1st time…");
                }
                else if (FileStorageManager.Instance.DataState == DataActualityState.Outdated)
                {
                    FormStart.SetTitle("Refreshing data from adSALEScloud…");
                }
                else
                {
                    FormStart.SetTitle("Loading application data...");
                }

                thread = new Thread(() =>
                {
                    AsyncHelper.RunSync(Init);
                    AsyncHelper.RunSync(FileStorageManager.Instance.FixCommonDataState);
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }

                FormMain.Instance.Init();
            }
            FormStart.CloseProgress();
            FormStart.Destroy();

            if (FileStorageManager.Instance.Activated)
            {
                if (PowerPointManager.SettingsSource == SettingsSourceEnum.PowerPoint &&
                    MasterWizardManager.Instance.SelectedWizard != null &&
                    !MasterWizardManager.Instance.SelectedWizard.HasSlideConfiguration(SlideSettingsManager.Instance.SlideSettings))
                {
                    var availableMasterWizards = MasterWizardManager.Instance.MasterWizards.Values.Where(w => w.HasSlideConfiguration(SlideSettingsManager.Instance.SlideSettings)).ToList();
                    if (availableMasterWizards.Any())
                    {
                        using (var form = new FormSelectMasterWizard())
                        {
                            form.comboBoxEditSlideFormat.Properties.Items.AddRange(availableMasterWizards);
                            form.comboBoxEditSlideFormat.EditValue = availableMasterWizards.FirstOrDefault();
                            if (form.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                            SettingsManager.Instance.SelectedWizard = ((MasterWizard)form.comboBoxEditSlideFormat.EditValue).Name;
                            MasterWizardManager.Instance.SetMasterWizard();
                        }
                    }
                    else
                    {
                        PopupMessageHelper.Instance.ShowWarning("You already have a PowerPoint file opened that is not compatible with this application.\nPlease close that presentation, and open Sales Ninja again.");
                        return;
                    }
                }
                Application.Run(FormMain.Instance);
            }
            else
            {
                PopupMessageHelper.Instance.ShowWarning("This app is not activated. Contact adSALESapps Support ([email protected])");
            }
        }
Esempio n. 2
0
		public void RunApplication()
		{
			bool stopRun = false;

			LicenseHelper.Register();

			AppProfileManager.Instance.InitApplication(AppTypeEnum.PrintSchedule);

			FileStorageManager.Instance.UsingLocalMode += (o, e) =>
			{
				if (FileStorageManager.Instance.UseLocalMode) return;
				FormStart.CloseProgress();
				if (FileStorageManager.Instance.DataState != DataActualityState.Updated)
				{
					Utilities.Instance.ShowWarning("Server is not available. Application will be closed");
					stopRun = true;
					Application.Exit();
					return;
				}
				if (Utilities.Instance.ShowWarningQuestion("Server is not available. Do you want to continue to work in local mode?") != DialogResult.Yes)
				{
					stopRun = true;
					Application.Exit();
				}
			};

			FileStorageManager.Instance.Authorizing += (o, e) =>
			{
				var authManager = new AuthManager();
				authManager.Init();
				FormStart.SetTitle("Checking credentials...", "*This should not take long…");
				authManager.Auth(e);
			};

			FormStart.ShowProgress();
			FormStart.SetTitle("Connecting to adSALEScloud…", "*This should not take long…");
			var thread = new Thread(() => AsyncHelper.RunSync(FileStorageManager.Instance.Init));
			thread.Start();
			while (thread.IsAlive)
				Application.DoEvents();

			if (stopRun) return;

			FileStorageManager.Instance.Downloading += (sender, args) =>
				FormStart.SetDetails(args.ProgressPercent < 100 ?
					String.Format("Loading {0} - {1}%", args.FileName, args.ProgressPercent) :
					String.Empty);
			FileStorageManager.Instance.Extracting += (sender, args) =>
				FormStart.SetDetails(args.ProgressPercent < 100 ?
					String.Format("Extracting {0} - {1}%", args.FileName, args.ProgressPercent) :
					String.Empty);

			if (FileStorageManager.Instance.Activated)
			{
				if (FileStorageManager.Instance.DataState == DataActualityState.NotExisted)
					FormStart.SetTitle("Syncing adSALEScloud for the 1st time…", "*This may take a few minutes…");
				else if (FileStorageManager.Instance.DataState == DataActualityState.Outdated)
					FormStart.SetTitle("Refreshing data from adSALEScloud…", "*This may take a few minutes…");
				else
					FormStart.SetTitle("Loading application data...", "*This should not take long…");

				thread = new Thread(() =>
				{
					AsyncHelper.RunSync(() => Controls.Controller.Instance.InitBusinessObjects());
					FileStorageManager.Instance.DataState = DataActualityState.Updated;
				});
				thread.Start();
				while (thread.IsAlive)
					Application.DoEvents();

				FormMain.Instance.Init();
			}

			FormStart.CloseProgress();
			if (FileStorageManager.Instance.Activated)
			{
				if (PowerPointManager.Instance.SettingsSource == SettingsSourceEnum.PowerPoint &&
				MasterWizardManager.Instance.SelectedWizard != null &&
				!MasterWizardManager.Instance.SelectedWizard.HasSlideConfiguration(PowerPointManager.Instance.SlideSettings))
				{
					var availableMasterWizards = MasterWizardManager.Instance.MasterWizards.Values.Where(w => w.HasSlideConfiguration(PowerPointManager.Instance.SlideSettings)).ToList();
					if (availableMasterWizards.Any())
					{
						using (var form = new FormSelectMasterWizard())
						{
							form.comboBoxEditSlideFormat.Properties.Items.AddRange(availableMasterWizards);
							form.comboBoxEditSlideFormat.EditValue = availableMasterWizards.FirstOrDefault();
							if (form.ShowDialog() != DialogResult.OK)
								return;
							SettingsManager.Instance.SelectedWizard = ((MasterWizard)form.comboBoxEditSlideFormat.EditValue).Name;
							MasterWizardManager.Instance.SetMasterWizard();
						}
					}
					else
					{
						Utilities.Instance.ShowWarning("Slide pack not found for selected size. Contact adSALESapps Support ([email protected])");
						return;
					}
				}
				Application.Run(FormMain.Instance);
			}
			else
				Utilities.Instance.ShowWarning("This app is not activated. Contact adSALESapps Support ([email protected])");
		}
Esempio n. 3
0
        public void RunApplication()
        {
            bool stopRun = false;

            LicenseHelper.Register();

            AppProfileManager.Instance.InitApplication(AppTypeEnum.PrintSchedule);

            FileStorageManager.Instance.UsingLocalMode += (o, e) =>
            {
                if (FileStorageManager.Instance.UseLocalMode)
                {
                    return;
                }
                FormStart.CloseProgress();
                if (FileStorageManager.Instance.DataState != DataActualityState.Updated)
                {
                    Utilities.Instance.ShowWarning("Server is not available. Application will be closed");
                    stopRun = true;
                    Application.Exit();
                    return;
                }
                if (Utilities.Instance.ShowWarningQuestion("Server is not available. Do you want to continue to work in local mode?") != DialogResult.Yes)
                {
                    stopRun = true;
                    Application.Exit();
                }
            };

            FileStorageManager.Instance.Authorizing += (o, e) =>
            {
                var authManager = new AuthManager();
                authManager.Init();
                FormStart.SetTitle("Checking credentials...", "*This should not take long…");
                authManager.Auth(e);
            };

            FormStart.ShowProgress();
            FormStart.SetTitle("Connecting to adSALEScloud…", "*This should not take long…");
            var thread = new Thread(() => AsyncHelper.RunSync(FileStorageManager.Instance.Init));

            thread.Start();
            while (thread.IsAlive)
            {
                Application.DoEvents();
            }

            if (stopRun)
            {
                return;
            }

            FileStorageManager.Instance.Downloading += (sender, args) =>
                                                       FormStart.SetDetails(args.ProgressPercent < 100 ?
                                                                            String.Format("Loading {0} - {1}%", args.FileName, args.ProgressPercent) :
                                                                            String.Empty);
            FileStorageManager.Instance.Extracting += (sender, args) =>
                                                      FormStart.SetDetails(args.ProgressPercent < 100 ?
                                                                           String.Format("Extracting {0} - {1}%", args.FileName, args.ProgressPercent) :
                                                                           String.Empty);

            if (FileStorageManager.Instance.Activated)
            {
                if (FileStorageManager.Instance.DataState == DataActualityState.NotExisted)
                {
                    FormStart.SetTitle("Syncing adSALEScloud for the 1st time…", "*This may take a few minutes…");
                }
                else if (FileStorageManager.Instance.DataState == DataActualityState.Outdated)
                {
                    FormStart.SetTitle("Refreshing data from adSALEScloud…", "*This may take a few minutes…");
                }
                else
                {
                    FormStart.SetTitle("Loading application data...", "*This should not take long…");
                }

                thread = new Thread(() =>
                {
                    AsyncHelper.RunSync(() => Controls.Controller.Instance.InitBusinessObjects());
                    FileStorageManager.Instance.DataState = DataActualityState.Updated;
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }

                FormMain.Instance.Init();
            }

            FormStart.CloseProgress();
            if (FileStorageManager.Instance.Activated)
            {
                if (PowerPointManager.Instance.SettingsSource == SettingsSourceEnum.PowerPoint &&
                    MasterWizardManager.Instance.SelectedWizard != null &&
                    !MasterWizardManager.Instance.SelectedWizard.HasSlideConfiguration(PowerPointManager.Instance.SlideSettings))
                {
                    var availableMasterWizards = MasterWizardManager.Instance.MasterWizards.Values.Where(w => w.HasSlideConfiguration(PowerPointManager.Instance.SlideSettings)).ToList();
                    if (availableMasterWizards.Any())
                    {
                        using (var form = new FormSelectMasterWizard())
                        {
                            form.comboBoxEditSlideFormat.Properties.Items.AddRange(availableMasterWizards);
                            form.comboBoxEditSlideFormat.EditValue = availableMasterWizards.FirstOrDefault();
                            if (form.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                            SettingsManager.Instance.SelectedWizard = ((MasterWizard)form.comboBoxEditSlideFormat.EditValue).Name;
                            MasterWizardManager.Instance.SetMasterWizard();
                        }
                    }
                    else
                    {
                        Utilities.Instance.ShowWarning("Slide pack not found for selected size. Contact adSALESapps Support ([email protected])");
                        return;
                    }
                }
                Application.Run(FormMain.Instance);
            }
            else
            {
                Utilities.Instance.ShowWarning("This app is not activated. Contact adSALESapps Support ([email protected])");
            }
        }
Esempio n. 4
0
        public void RunApplication(MediaDataType mediaType)
        {
            bool stopRun = false;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday;

            LicenseHelper.Register();

            var textSettings = new StartFormTextConfiguration();

            textSettings.Load(Path.Combine(Common.Core.Configuration.ResourceManager.Instance.AppRootFolderPath, "sync_text.xml"));

            MediaMetaData.Instance.Init(mediaType);
            var appTitle = String.Format("SellerPoint for {0}", MediaMetaData.Instance.DataTypeString);

            if (BusinessObjects.Instance.PowerPointManager.IsPowerPointMultipleInstances())
            {
                using (var form = new FormPowerPointSeveralInstancesWarning())
                {
                    form.Text = appTitle;
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
            }

            PopupMessageHelper.Instance.Title = appTitle;
            AppProfileManager.Instance.InitApplication(MediaMetaData.Instance.AppType);

            FileStorageManager.Instance.UsingLocalMode += (o, e) =>
            {
                if (FileStorageManager.Instance.UseLocalMode)
                {
                    return;
                }
                FormStart.CloseProgress();
                if (FileStorageManager.Instance.DataState != DataActualityState.Updated)
                {
                    PopupMessageHelper.Instance.ShowWarning("Server is not available. Application will be closed");
                    stopRun = true;
                    Application.Exit();
                    return;
                }
                if (PopupMessageHelper.Instance.ShowWarningQuestion("Server is not available. Do you want to continue to work in local mode?", "adSALESapps.com ") != DialogResult.Yes)
                {
                    stopRun = true;
                    Application.Exit();
                }
            };

            FileStorageManager.Instance.Authorizing += (o, e) =>
            {
                var authManager = new AuthManager();
                FormStart.SetTitle(textSettings.VersionText ?? "Checking credentials...");
                e.LightCheck = true;
                authManager.Auth(e);
            };

            FormStart.ShowProgress();
            FormStart.SetTitle(textSettings.ConnectText ?? "Connecting to adSALEScloud…");
            var thread = new Thread(() =>
            {
                AsyncHelper.RunSync(() => FileStorageManager.Instance.InitStorage());
                if (FileStorageManager.Instance.Activated)
                {
                    AsyncHelper.RunSync(() => AppProfileManager.Instance.LoadProfile());
                }
            });

            thread.Start();
            while (thread.IsAlive)
            {
                Application.DoEvents();
            }

            if (stopRun)
            {
                return;
            }

            if (FileStorageManager.Instance.Activated)
            {
                if (FileStorageManager.Instance.SubStorages.Any() &&
                    String.IsNullOrEmpty(AppProfileManager.Instance.SubStorageName))
                {
                    if (FileStorageManager.Instance.SubStorages.Count > 1)
                    {
                        FormStart.CloseProgress();

                        using (var form = new FormMediaSettings())
                        {
                            form.comboBoxEditMedia.Properties.Items.AddRange(FileStorageManager.Instance.SubStorages);
                            form.comboBoxEditMedia.EditValue = FileStorageManager.Instance.SubStorages.FirstOrDefault();
                            if (form.ShowDialog() == DialogResult.OK)
                            {
                                AppProfileManager.Instance.SubStorageName = form.comboBoxEditMedia.EditValue as string;
                                AppProfileManager.Instance.SaveProfile();
                                FormStart.ShowProgress();
                            }
                            else
                            {
                                FormStart.Destroy();
                                return;
                            }
                        }
                    }
                    else
                    {
                        AppProfileManager.Instance.SubStorageName = FileStorageManager.Instance.SubStorages.FirstOrDefault();
                        AppProfileManager.Instance.SaveProfile();
                    }
                }

                thread = new Thread(() =>
                {
                    AsyncHelper.RunSync(() => FileStorageManager.Instance.CheckDataSate());
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }

                FileStorageManager.Instance.Downloading += OnFileDownloading;
                FileStorageManager.Instance.Extracting  += OnFileExtracting;

                if (FileStorageManager.Instance.DataState == DataActualityState.NotExisted)
                {
                    FormStart.SetTitle(textSettings.InitialLoadingText ?? "Syncing adSALEScloud for the 1st time…");
                }
                else if (FileStorageManager.Instance.DataState == DataActualityState.Outdated)
                {
                    FormStart.SetTitle(textSettings.RefreshText ?? "Refreshing data from adSALEScloud…");
                }
                else
                {
                    FormStart.SetTitle("Loading application data...");
                }

                thread = new Thread(() =>
                {
                    AsyncHelper.RunSync(() => Business.Media.Configuration.ResourceManager.Instance.LoadSubStorageIndependentResources());

                    Controller.Instance.InitBusinessObjects();
                    AsyncHelper.RunSync(FileStorageManager.Instance.FixCommonDataState);
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }

                FormStart.SetTitle(textSettings.LaunchText ?? "Launching SellerPoint...");
                Application.DoEvents();

                FormMain.Instance.Init();

                Controller.Instance.InitForm();

                FileStorageManager.Instance.Downloading -= OnFileDownloading;
                FileStorageManager.Instance.Extracting  -= OnFileExtracting;
            }

            FormStart.CloseProgress();
            FormStart.Destroy();

            if (FileStorageManager.Instance.Activated)
            {
                if (BusinessObjects.Instance.PowerPointManager.SettingsSource == SettingsSourceEnum.PowerPoint &&
                    MasterWizardManager.Instance.SelectedWizard != null &&
                    !MasterWizardManager.Instance.SelectedWizard.HasSlideConfiguration(SlideSettingsManager.Instance.SlideSettings))
                {
                    var availableMasterWizards = MasterWizardManager.Instance.MasterWizards.Values.Where(w => w.HasSlideConfiguration(SlideSettingsManager.Instance.SlideSettings)).ToList();
                    if (availableMasterWizards.Any())
                    {
                        using (var form = new FormSelectMasterWizard())
                        {
                            form.comboBoxEditSlideFormat.Properties.Items.AddRange(availableMasterWizards);
                            form.comboBoxEditSlideFormat.EditValue = availableMasterWizards.FirstOrDefault();
                            if (form.ShowDialog() != DialogResult.OK)
                            {
                                return;
                            }
                            SettingsManager.Instance.SelectedWizard = ((MasterWizard)form.comboBoxEditSlideFormat.EditValue).Name;
                            MasterWizardManager.Instance.SetMasterWizard();
                        }
                    }
                    else
                    {
                        PopupMessageHelper.Instance.ShowWarning("You already have a PowerPoint file opened that is not compatible with Sales Ninja.\nPlease close that presentation, and open Sales Ninja again.");
                        return;
                    }
                }
                Application.Run(FormMain.Instance);
            }
            else
            {
                PopupMessageHelper.Instance.ShowWarning("This app is not activated. Contact adSALESapps Support ([email protected])");
            }
        }