SetMessage() public method

Sets the dialog's message content.
public SetMessage ( string message ) : void
message string The message to be set.
return void
Ejemplo n.º 1
0
        public string CreateXmlDb(List<MagicCard> listOfCards, ProgressDialogController dialogController)
        {
            var curCard = 0;
            var totalCards = listOfCards.Count;

            foreach (var distinctSet in listOfCards.DistinctBy(o => o.Set))
            {
                var enumerable = listOfCards.Where(op => op.Set == distinctSet.Set && op.PathOfCardImage.Contains("original")).DistinctBy(o => o.Name);
                foreach (var distinctCard in enumerable)
                {
                    var cardElement = _xmlfile.CreateElement("card");
                    AddChildElementAndValue(cardElement, _util.GetVariableName(() => distinctCard.Name), distinctCard.Name);
                    AddChildElementAndValue(cardElement, _util.GetVariableName(() => distinctCard.Set), distinctCard.Set);
                    AddChildElementAndValue(cardElement, _util.GetVariableName(() => distinctCard.PathOfCardImage), distinctCard.PathOfCardImage);

                    var phashesElement = _xmlfile.CreateElement("phashes");
                    foreach (var magicCard in listOfCards.Where(o => o.Name == distinctCard.Name && o.Set == distinctSet.Set))
                    {
                        foreach (var phash in magicCard.PHashes)
                        {
                            AddChildElementAndValue(phashesElement, "phash", phash.ToString());
                        }
                    }
                    cardElement.AppendChild(phashesElement);
                    _rootNode.AppendChild(cardElement);
                    curCard++;
                    dialogController.SetProgress((double)curCard / totalCards);
                    dialogController.SetMessage("Creating a Simple Database of all those pHashes: " + curCard + "/" + totalCards);
                }
            }

            SaveXmlFile();
            return Path.GetFullPath(XmlDbPath);
        }
Ejemplo n.º 2
0
        public void Parse(string flexXML, ProgressDialogController progress)
        {
            progress.SetMessage("Parsing Flex File");
            var context = new DBContext();
            context.Configuration.AutoDetectChangesEnabled = false;

            bool skipLastDateCheck = !Properties.Settings.Default.preventDuplicateImports;

            XDocument xml = XDocument.Parse(flexXML);

            ParseAccounts(xml, context);

            IEnumerable<XElement> flexStatements = xml.Descendants("FlexStatement");

            foreach(XElement flexStatement in flexStatements)
            {
                ParseStatement(flexStatement, progress, context, skipLastDateCheck);
            }

            context.Configuration.AutoDetectChangesEnabled = true;
            context.Dispose();
        }
Ejemplo n.º 3
0
        public async Task<bool> LoadLastUpdateAndFill(ProgressDialogController controller)
        {
            DateTime start = DateTime.Now;
            InitializationController init = new InitializationController();
            
            await Task.Delay(2000);
            init.OnLoadingUpdate += delegate(object sender, string mess) { controller.SetMessage(mess); };
            if ( init.LoadData())
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.Title += " | Game version = " + init.Version;
                });

                List<BuildingViewModel> usmodels = new List<BuildingViewModel>();
                List<BuildingViewModel> carmodels = new List<BuildingViewModel>();
                List<BuildingViewModel> chimmodels = new List<BuildingViewModel>();
                //Fill the forms
                //US
                foreach (AoABuilding b in init.UsBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    usmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView Usview = new FactionBuildingListView(new FactionViewModel(usmodels));
                    UsGrid.Children.Clear();
                    UsGrid.Children.Add(Usview);
                });
                init.UsBuildings.Clear();
            
                

                //Cartel
                foreach (AoABuilding b in init.CartelBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    carmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView cartelview = new FactionBuildingListView(new FactionViewModel(carmodels));
                    CartelGrid.Children.Clear();
                    CartelGrid.Children.Add(cartelview);
                });
                init.CartelBuildings.Clear();
                    
                

                //Chimera
                foreach (AoABuilding b in init.ChimeraBuildings)
                {
                    BuildingViewModel buioding = new BuildingViewModel(b);
                    chimmodels.Add(buioding);
                }
                
                this.Dispatcher.Invoke(() =>
                {
                    FactionBuildingListView chimview = new FactionBuildingListView(new FactionViewModel(chimmodels));
                    ChimeraGrid.Children.Clear();
                    ChimeraGrid.Children.Add(chimview);
                });

                init.ChimeraBuildings.Clear();
                controller.SetMessage("finished, time taken : " + (DateTime.Now - start).TotalSeconds);
                await Task.Delay(2000);
                
                return true;
            }
            else
            {
                init.Clear(); Console.Out.WriteLine(DateTime.Now.ToShortDateString() + " : loading last update failed."); 
                controller.SetMessage("loading failed...");
                await Task.Delay(2000); 
                return false;
            }
        }
Ejemplo n.º 4
0
 public void ComputePHashes(string selectedPath, ProgressDialogController dialogController)
 {
     ListOfMagicCards.Clear();
     //read images in resources
     Util.TraverseTree(@"H:\Compy Sci\MTG-Scanner\MTG-Scanner\Resources\Card Images", ListOfMagicCards);
     //Util.TraverseTree(selectedPath, ListOfMagicCards);
     //Util.TraverseTree(selectedPath, ListOfMagicCards);
     //compute hashes
     var curCard = 0;
     var totalCards = ListOfMagicCards.Count;
     Parallel.ForEach(ListOfMagicCards, card =>
     {
         var hash = Util.ComputePHash(card);
         card.PHashes.Add(hash);
         curCard++;
         dialogController.SetProgress((double)curCard / totalCards);
         dialogController.SetMessage("pHashing real hard! Finished: " + curCard + "/" + totalCards);
     });
 }
Ejemplo n.º 5
0
        private void DoExport(ProgressDialogController dialogController, List<BulkExportModel> timersToExport)
        {
            for (var i = 0; i < timersToExport.Count; i++)
            {
                var exportModel = timersToExport[i];

                if (i == 0)
                {
                    dialogController.SetMessage($"Exporting Timer {exportModel.JiraRef} For {exportModel.ExportDate.Date.ToString("ddd, dd MMM")}");
                }
                else
                {
                    dialogController.SetMessage($"Exporting Timer {exportModel.JiraRef} For {exportModel.ExportDate.Date.ToString("ddd, dd MMM")}\nDone {i} Of {timersToExport.Count}");
                }

                try
                {
                    var jiraRef = exportModel.JiraRef;
                    var date = exportModel.ExportDate;
                    var toExport = exportModel.ToExport;
                    var strategy = exportModel.WorkLogStrategy;
                    var comment = exportModel.Comment;
                    var remaining = exportModel.Remaining;
                    var standardComment = exportModel.StandardComment;
                    modelHelpers.Gallifrey.JiraConnection.LogTime(jiraRef, date, toExport, strategy, standardComment, comment, remaining);
                    modelHelpers.Gallifrey.JiraTimerCollection.AddJiraExportedTime(exportModel.Timer.UniqueId, exportModel.ToExportHours ?? 0, exportModel.ToExportMinutes ?? 0);
                }
                catch (WorkLogException ex)
                {
                    throw new BulkExportException($"Error Logging Work To {exportModel.JiraRef}\n\nError Message From Jira: { ex.InnerException.Message }");
                }
                catch (CommentException)
                {
                    throw new BulkExportException($"The Comment Was Not Added To Jira {exportModel.JiraRef}");
                }
            }
        }
Ejemplo n.º 6
0
        private List<BulkExportModel> GetTimers(ProgressDialogController dialogController, List<JiraTimer> timers)
        {
            var timersToShow = new List<BulkExportModel>();
            var issuesRetrieved = new List<Issue>();
            var timersToGet = timers.Where(x => !x.LocalTimer && !x.IsRunning).ToList();

            for (var i = 0; i < timersToGet.Count; i++)
            {
                var timerToShow = timersToGet[i];

                var requireRefresh = !timerToShow.LastJiraTimeCheck.HasValue || timerToShow.LastJiraTimeCheck < DateTime.UtcNow.AddMinutes(-15);
                var model = new BulkExportModel(timerToShow, modelHelpers.Gallifrey.Settings.ExportSettings);
                var jiraIssue = issuesRetrieved.FirstOrDefault(x => x.key == timerToShow.JiraReference);

                if (i == 0)
                {
                    dialogController.SetMessage($"Downloading Jira Work Logs For {timerToShow.JiraReference} To Ensure Accurate Export");
                }
                else
                {
                    dialogController.SetMessage($"Downloading Jira Work Logs For {timerToShow.JiraReference} To Ensure Accurate Export\nDone {i} Of {timersToGet.Count}");
                }

                if (jiraIssue == null)
                {
                    try
                    {
                        jiraIssue = modelHelpers.Gallifrey.JiraConnection.GetJiraIssue(timerToShow.JiraReference, requireRefresh);
                        issuesRetrieved.Add(jiraIssue);
                    }
                    catch (Exception)
                    {
                        throw new BulkExportException($"Unable To Locate Jira {timerToShow.JiraReference}!\nCannot Export Time\nPlease Verify/Correct Jira Reference");
                    }
                }

                if (requireRefresh)
                {
                    modelHelpers.Gallifrey.JiraTimerCollection.RefreshFromJira(timerToShow.UniqueId, jiraIssue, modelHelpers.Gallifrey.JiraConnection.CurrentUser);
                    timerToShow = modelHelpers.Gallifrey.JiraTimerCollection.GetTimer(timerToShow.UniqueId);
                }

                if (!timerToShow.FullyExported)
                {
                    model.UpdateTimer(timerToShow, jiraIssue);
                    timersToShow.Add(model);
                }
            }

            return timersToShow;
        }
Ejemplo n.º 7
0
        private static async Task WaitForCancel(ProgressDialogController dialog, string message)
        {
            dialog.SetMessage("Failed: " + message);
            dialog.SetCancelable(true);

            while (!dialog.IsCanceled)
                await Task.Delay(10);

            await dialog.CloseAsync();
        }
Ejemplo n.º 8
0
        private async void OnFlyoutFirstOpen( )
        {
            if ( MainWindow.Client.IsLoggedIn ) return;

            controller = await window.ShowProgressAsync( "Signing in.", "Signing into opensubtitles.org." );
            controller.SetIndeterminate( );
            LogInOutput output = await SignInClient( );

            if ( output.LogInSuccesful && MainWindow.Client.IsLoggedIn )
            {
                controller.SetTitle( "Downloading subtitle languages." );
                controller.SetMessage( "Downloading the available subtitle languages from opensubtitles.org." );
                this.languages = await GetSubtitleLanguages( );
                this.LanguageList.ItemsSource = this.languages;

                CollectionView languagesView = ( CollectionView )CollectionViewSource.GetDefaultView( LanguageList.ItemsSource );
                languagesView.SortDescriptions.Add( new SortDescription( "LanguageName", ListSortDirection.Ascending ) );
            }
            else
                await window.ShowMessageAsync( "Signing in failed", $"Unable to sign in to opensubtitles.org. Please try again later. (Status: {output.Status}, {output.StatusStringWithoutCode})" );

            await controller.CloseAsync( );

            OnFlyoutOpen( );
        }
Ejemplo n.º 9
0
 private async Task ProgressFailed(ProgressDialogController controller, String reason)
 {
     controller.SetMessage("Failure to login: " + reason);
     await Task.Delay(1500);
     await controller.CloseAsync();
 }
Ejemplo n.º 10
0
 private async Task LoginRTMP(ProgressDialogController controller, HTTPLoginResult res)
 {
     controller.SetMessage("Contacting RTMP Server");
     Supporting.LRtmp rtmpClient = new Supporting.LRtmp();
     await rtmpClient.ConnectAsync();
     com.riotgames.platform.login.AuthenticationCredentials rtmpInfo = new com.riotgames.platform.login.AuthenticationCredentials()
     {
         operatingSystem = "Windows 8",
         username = txtUser.Text,
         domain = "lolclient.lol.riotgames.com",
         clientVersion = "4.17.14_09_22_18_55", //todo: don't hardcode this
         locale = "en_US",
         password = txtPass.Password,
         macAddress = ""
     };
     rtmpInfo.authToken = await Task.Factory.StartNew(() => Newtonsoft.Json.JsonConvert.SerializeObject(new com.riotgames.platform.login.AuthToken
     {
         account_id = res.lqt.account_id,
         account_name = res.lqt.account_name,
         fingerprint = res.lqt.fingerprint,
         other = res.lqt.other,
         resources = res.lqt.resources,
         signature = res.lqt.signature,
         timestamp = res.lqt.timestamp,
         uuid = res.lqt.uuid
     }));
     if (await rtmpClient.LoginAsync(rtmpInfo))
     {
         com.riotgames.platform.clientfacade.domain.LoginDataPacket data = await rtmpClient.GetLoginDataPacketAsync();
         MainWindow mainWindow = new MainWindow(data, rtmpClient);
         mainWindow.Show();
         rtmpClient.PerformHeartBeatLoop();
         this.Close();
         return;
     }
     else
     {
         await ProgressFailed(controller, "Rejected from RTMPS side(?)");
     }
 }
Ejemplo n.º 11
0
 public void SetMessage(string message)
 {
     _controller.SetMessage(message);
 }