/// <summary>
        /// This method is called when the user presses the Go button.
        /// </summary>
        public async Task Go()
        {
            var ids = new MobileList <Guid>();

            foreach (var songViewModel in Items)
            {
                if (songViewModel.IsChecked)
                {
                    ids.Add(songViewModel.Model.Id);
                }
            }

            //var targetId = new Guid(@"5D4355FE-C46E-4AA1-9E4A-45288C341C44");
            var targetId = Guid.NewGuid();

            History.Events.ThinkingAboutTargetEvent.Publish(targetId);
            var songs = await MultiLineTextList.NewMultiLineTextListAsync(ids);

            History.Events.ThinkedAboutTargetEvent.Publish(targetId);

            var nativeLanguage = await LanguageEdit.GetLanguageEditAsync(GetNativeLanguageText());

            var noExpirationDate = StudyJobInfo <MultiLineTextList, IViewModelBase> .NoExpirationDate;
            var precision        = double.Parse(AppResources.DefaultExpectedPrecision);

            //CREATE JOB INFO
            var studyJobInfo = new StudyJobInfo <MultiLineTextList, IViewModelBase>(songs,
                                                                                    nativeLanguage,
                                                                                    noExpirationDate,
                                                                                    precision);
            //CREATE OPPORTUNITY
            var opportunity = new Opportunity <MultiLineTextList, IViewModelBase>(Id,
                                                                                  this,
                                                                                  studyJobInfo,
                                                                                  StudyResources.CategoryStudy);

            //ADD OPPORTUNITY TO OUR FUTURE OPPORTUNITIES
            FutureOpportunities.Add(opportunity);

            //LET THE HISTORY SHOW THAT YOU ARE THINKING ABOUT THIS OPPORTUNITY
            var opportunityId = opportunity.Id;

            History.Events.ThinkingAboutTargetEvent.Publish(opportunityId);

            //PUBLISH THE OPPORTUNITY
            Exchange.Ton.Publish(opportunity);

            //NOW, WE WAIT UNTIL WE HEAR A HANDLE(OFFER) MESSAGE.
            //TODO: TIMEOUT FOR OPPORTUNITY, BOTH EXPIRATION DATE AND WAITING FOR OFFER TIMEOUT
        }
Esempio n. 2
0
        /// <summary>
        /// This method is called when the user presses the Go button.
        /// </summary>
        public async Task Go()
        {
            if (!CanGo)
            {
                return;
            }

            DisableNavigationRequestedEventMessage.Publish();
            GoInProgress = true;
            try
            {
                var ids = new MobileList <Guid>();
                foreach (var songViewModel in Items)
                {
                    if (songViewModel.IsChecked)
                    {
                        Guid id      = default(Guid);
                        var  results = from entry in _MultiLineTextIdsAndTitles
                                       where entry.Value == songViewModel.SongTitle
                                       select entry;
                        id = results.First().Key;
                        ids.Add(id);
                    }
                }
                MultiLineTextList songs = null;
                #region Try ...(thinking)
                //var targetId = new Guid(@"5D4355FE-C46E-4AA1-9E4A-45288C341C44");
                var targetId = Guid.NewGuid();
                History.Events.ThinkingAboutTargetEvent.Publish(targetId);
                try
                {
                    #endregion
                    songs = await MultiLineTextList.NewMultiLineTextListAsync(ids);

                    #region ...Finally (thinked)
                }

                finally
                {
                    History.Events.ThinkedAboutTargetEvent.Publish(targetId);
                }
                #endregion

                var nativeLanguage = await LanguageEdit.GetLanguageEditAsync(GetNativeLanguageText());

                var noExpirationDate = StudyJobInfo <MultiLineTextList, IViewModelBase> .NoExpirationDate;
                var precision        = double.Parse(StudyResources.DefaultExpectedPrecision);

                //CREATE JOB INFO
                var studyJobInfo = new StudyJobInfo <MultiLineTextList, IViewModelBase>(songs,
                                                                                        nativeLanguage,
                                                                                        noExpirationDate,
                                                                                        precision);
                //CREATE OPPORTUNITY
                var opportunity = new Opportunity <MultiLineTextList, IViewModelBase>(Id,
                                                                                      this,
                                                                                      studyJobInfo,
                                                                                      StudyResources.CategoryStudy);

                //ADD OPPORTUNITY TO OUR FUTURE OPPORTUNITIES
                FutureOpportunities.Add(opportunity);

                //LET THE HISTORY SHOW THAT YOU ARE THINKING ABOUT THIS OPPORTUNITY
                var opportunityId = opportunity.Id;
                History.Events.ThinkingAboutTargetEvent.Publish(System.Guid.Empty);

                //PUBLISH THE OPPORTUNITY
                Exchange.Ton.Publish(opportunity);

                //NOW, WE WAIT UNTIL WE HEAR A HANDLE(OFFER) MESSAGE.
                //TODO: TIMEOUT FOR OPPORTUNITY, BOTH EXPIRATION DATE AND WAITING FOR OFFER TIMEOUT
            }
            finally
            {
                EnableNavigationRequestedEventMessage.Publish();
            }
        }