Пример #1
0
		public void Init(MediaDataType dataType)
		{
			DataType = dataType;

			SettingsManager = new MediaSettingsManager();

			switch (dataType)
			{
				case MediaDataType.TVSchedule:
					ListManager = new TVListManager();
					break;
				case MediaDataType.RadioSchedule:
					ListManager = new RadioListManager();
					break;
			}
		}
Пример #2
0
        public void Init(MediaDataType dataType)
        {
            DataType = dataType;

            SettingsManager = new MediaSettingsManager();

            switch (dataType)
            {
            case MediaDataType.TVSchedule:
                ListManager = new TVListManager();
                break;

            case MediaDataType.RadioSchedule:
                ListManager = new RadioListManager();
                break;
            }
        }
Пример #3
0
        public async Task <bool> SendMetaDataUpdateAsync(string data, MediaDataType dataType)
        {
            if (this.AppServiceConnection == null)
            {
                await this.InitializeAsync();
            }

            var message = new ValueSet
            {
                { "uuid", GetCharacteristicUuidByMediaDataType(dataType) },
                { "data", data }
            };

            var errorMessage = await this.AppServiceConnection.SendMessageWithResponseAsync(message);

            return(string.IsNullOrWhiteSpace(errorMessage));
        }
Пример #4
0
        static Guid GetCharacteristicUuidByMediaDataType(MediaDataType mediaDataType)
        {
            switch (mediaDataType)
            {
            case MediaDataType.Title:
                return(Asteroid.MediaTitleCharacteristicUuid);

            case MediaDataType.Album:
                return(Asteroid.MediaAlbumCharacteristicUuid);

            case MediaDataType.Artist:
                return(Asteroid.MediaArtistCharacteristicUuid);

            case MediaDataType.PlayerStatus:
                return(Asteroid.MediaPlayingCharacteristicUuid);

            default:
                throw new NotSupportedException($"Unsupported {nameof(MediaDataType)}: {mediaDataType}");
            }
        }
Пример #5
0
		public static void AssignMediaDataType(MediaDataType type)
		{
			switch (type)
			{
				case MediaDataType.Cable:
					_sourceFileName = CableSourceFileName;
					_destinationFileName = CableDestinationFileName;
					_sheetName = CableSheetName;
					_slideHeader = CableSlideHeader;
					_strengths = CableStrengths;
					_challenges = CableChallenges;
					ButtonText = "Cable\nStrengths &&\nChallenges";
					break;
				case MediaDataType.DirectMail:
					_sourceFileName = DirectMailSourceFileName;
					_destinationFileName = DirectMailDestinationFileName;
					_sheetName = DirectMailSheetName;
					_slideHeader = DirectMailSlideHeader;
					_strengths = DirectMailStrengths;
					_challenges = DirectMailChallenges;
					ButtonText = "Direct Mail\nStrengths &&\nChallenges";
					break;
				case MediaDataType.Internet:
					_sourceFileName = InternetSourceFileName;
					_destinationFileName = InternetDestinationFileName;
					_sheetName = InternetSheetName;
					_slideHeader = InternetSlideHeader;
					_strengths = InternetStrengths;
					_challenges = InternetChallenges;
					ButtonText = "Internet\nStrengths &&\nChallenges";
					break;
				case MediaDataType.Mobile:
					_sourceFileName = MobileSourceFileName;
					_destinationFileName = MobileDestinationFileName;
					_sheetName = MobileSheetName;
					_slideHeader = MobileSlideHeader;
					_strengths = MobileStrengths;
					_challenges = MobileChallenges;
					ButtonText = "Mobile\nStrengths &&\nChallenges";
					break;
				case MediaDataType.Outdoor:
					_sourceFileName = OutdoorSourceFileName;
					_destinationFileName = OutdoorDestinationFileName;
					_sheetName = OutdoorSheetName;
					_slideHeader = OutdoorSlideHeader;
					_strengths = OutdoorStrengths;
					_challenges = OutdoorChallenges;
					ButtonText = "Outdoor\nStrengths &&\nChallenges";
					break;
				case MediaDataType.Print:
					_sourceFileName = PrintSourceFileName;
					_destinationFileName = PrintDestinationFileName;
					_sheetName = PrintSheetName;
					_slideHeader = PrintSlideHeader;
					_strengths = PrintStrengths;
					_challenges = PrintChallenges;
					ButtonText = "Print\nStrengths &&\nChallenges";
					break;
				case MediaDataType.Radio:
					_sourceFileName = RadioSourceFileName;
					_destinationFileName = RadioDestinationFileName;
					_sheetName = RadioSheetName;
					_slideHeader = RadioSlideHeader;
					_strengths = RadioStrengths;
					_challenges = RadioChallenges;
					ButtonText = "Radio\nStrengths &&\nChallenges";
					break;
				case MediaDataType.TV:
					_sourceFileName = TVSourceFileName;
					_destinationFileName = TVDestinationFileName;
					_sheetName = TVSheetName;
					_slideHeader = TVSlideHeader;
					_strengths = TVStrengths;
					_challenges = TVChallenges;
					ButtonText = "TV\nStrengths &&\nChallenges";
					break;
				case MediaDataType.YellowPages:
					_sourceFileName = YellowPagesSourceFileName;
					_destinationFileName = YellowPagesDestinationFileName;
					_sheetName = YellowPagesSheetName;
					_slideHeader = YellowPagesSlideHeader;
					_strengths = YellowPagesStrengths;
					_challenges = YellowPagesChallenges;
					ButtonText = "Yellow Pages\nStrengths &&\nChallenges";
					break;
				case MediaDataType.MediaStrategy:
					_sourceFileName = MediaStrategySourceFileName;
					_destinationFileName = MediaStrategyDestinationFileName;
					_sheetName = MediaStrategySheetName;
					_slideHeader = MediaStrategySlideHeader;
					_strengths = "*";
					_challenges = "*";
					ButtonText = "Media\nStrategy";
					break;
			}
		}
Пример #6
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();

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

			if (PowerPointManager.IsPowerPointMultipleInstances(RegularMediaSchedulePowerPointHelper.Instance))
			{
				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("Checking credentials...");
				e.LightCheck = true;
				authManager.Auth(e);
			};

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

			if (stopRun) return;

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

			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(() => Controls.Controller.Instance.InitBusinessObjects());
					AsyncHelper.RunSync(FileStorageManager.Instance.FixDataState);
				});
				thread.Start();
				while (thread.IsAlive)
					Application.DoEvents();

				FormStart.SetTitle("Launching SellerPoint...");
				Application.DoEvents();

				FormMain.Instance.Init();
			}

			FileStorageManager.Instance.Downloading -= OnFileDownloading;
			FileStorageManager.Instance.Extracting -= OnFileExtracting;
			FormStart.CloseProgress();
			FormStart.Destroy();

			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
					{
						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])");
		}
Пример #7
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])");
            }
        }