Exemple #1
0
 public void AddTest()
 {
     SessionList.Add(new Session()
     {
         BeginLine = 4, EndLine = 5, Message = Test
     });
 }
        private void FinishNewSessionFunc(object o, EventArgs e)
        {
            EventArgsNewSession eventArgs = (EventArgsNewSession)e;
            Session             session   = eventArgs.Session;

            App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
            {
                SessionList.Add(session);
            }));

            if (session.Direction == Direct.input)
            {
                InputSession++;
            }
            else if (session.Direction == Direct.output)
            {
                OutputSession++;
            }
            if (session.Status == "successful")
            {
                SuccessSession++;
            }
            else if (session.Status == "terminated")
            {
                TerminatedSession++;
            }
            AllSession++;
        }
Exemple #3
0
        private StudioEntityRegistry(IStorage storage)
            : base(storage)
        {
            Prepare();

            var delayAction = new DelayAction(storage, exception => exception.LogError());

            Sessions = new SessionList(Storage)
            {
                DelayAction = delayAction
            };

            _boards = new ExchangeBoardListEx(Storage);

            _securities = new StudioSecurityList(this)
            {
                DelayAction = delayAction
            };
            _portfolios = new PortfolioList(Storage)
            {
                BulkLoad = true, DelayAction = delayAction
            };

            //FavoriteSecurities = new FavoriteSecurityList(this) { BulkLoad = true, DelayAction = delayAction };
            IndexSecurities = new IndexSecurityList(storage)
            {
                BulkLoad = true, DelayAction = delayAction
            };
            ContinuousSecurities = new ContinuousSecurityList(this)
            {
                DelayAction = delayAction
            };

            var session = Sessions.Battle;

            if (session == null)
            {
                session = new Session
                {
                    Type      = SessionType.Battle,
                    StartTime = DateTime.Today,
                    EndTime   = DateTime.MaxValue,
                    Settings  = new SettingsStorage(),
                };

                Sessions.Add(session);
                Sessions.DelayAction.WaitFlush();
            }

            DelayAction = delayAction;

            CreateCommonData();

            Strategies = new StrategyInfoList(this, session);
        }
        public static int ProcessList(List <CensusIndividual> individuals, IProgress <string> outputText)
        {
            if (individuals is null)
            {
                return(0);
            }
            int recordsAdded = 0;

            try
            {
                ToProcess    = individuals;
                _previousRef = string.Empty;
                int recordsFailed     = 0;
                int recordsPresent    = 0;
                int sessionDuplicates = 0;
                int count             = 0;
                if (Website is null)
                {
                    Website = LoadWebsiteAncestors(outputText);
                }
                if (SessionList is null)
                {
                    SessionList = new List <LostCousin>();
                }
                bool alias = GeneralSettings.Default.ShowAliasInName;
                GeneralSettings.Default.ShowAliasInName = false; // turn off adding alias in name when exporting
                foreach (CensusIndividual ind in ToProcess)
                {
                    if (ind.LCAge.Equals("Unknown"))
                    {
                        outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Cannot determine age at census {ind.CensusString}.\n");
                        recordsFailed++;
                    }
                    else if (ind.LCSurnameAtDate(ind.CensusDate).Length == 0 || ind.LCForename.Length == 0)
                    {
                        outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Cannot process person with unknown forename or surname {ind.CensusString}.\n");
                        recordsFailed++;
                    }
                    else if (ind.CensusReference != null && ind.CensusReference.IsValidLostCousinsReference())
                    {
                        LostCousin lc = new LostCousin($"{ind.SurnameAtDate(ind.CensusDate)}, {ind.Forenames}", ind.BirthDate.BestYear, GetCensusSpecificFields(ind), ind.CensusDate.BestYear, ind.CensusCountry, true);
                        if (Website.Contains(lc))
                        {
                            outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Already Present {ind.CensusString}, {ind.CensusReference}.\n");
                            if (!DatabaseHelper.LostCousinsExists(ind))
                            {
                                DatabaseHelper.StoreLostCousinsFact(ind, outputText);
                            }
                            AddLostCousinsFact(ind);
                            recordsPresent++;
                        }
                        else
                        {
                            if (SessionList.Contains(lc))
                            {
                                outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Already submitted this session {ind.CensusString}, {ind.CensusReference}. Possible duplicate Individual\n");
                                sessionDuplicates++;
                            }
                            else
                            {
                                if (AddIndividualToWebsite(ind, outputText))
                                {
                                    outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - {ind.CensusString}, {ind.CensusReference} added.\n");
                                    recordsAdded++;
                                    SessionList.Add(lc);
                                    if (!DatabaseHelper.LostCousinsExists(ind))
                                    {
                                        DatabaseHelper.StoreLostCousinsFact(ind, outputText);
                                    }
                                    AddLostCousinsFact(ind);
                                }
                                else
                                {
                                    outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Failed to add {ind.CensusString}, {ind.CensusReference}.\n");
                                    recordsFailed++;
                                }
                            }
                        }
                    }
                    else
                    {
                        outputText.Report($"Record {++count} of {ToProcess.Count}: {ind.CensusDate} - Failed to add {ind.CensusString}, {ind.CensusReference}. Census Reference problem.\n");
                        recordsFailed++;
                    }
                }
                GeneralSettings.Default.ShowAliasInName = alias;
                outputText.Report($"\nFinished writing Entries to Lost Cousins website. {recordsAdded} successfully added, {recordsPresent} already present, {sessionDuplicates} possible duplicates and {recordsFailed} failed.\nView Lost Cousins Report tab to see current status.\n");
                outputText.Report("\nPlease note you MUST check the entries by clicking the arrow next to the census reference on the list on my ancestors page.\n");
                outputText.Report("This only needs done once per household and will link to the census on Find My Past.\n");
                outputText.Report("If you have any errors you can correct them on your my ancestors page. The most common will be Age and different spelling of names.\n");
                outputText.Report("Occasionally you may have got a census reference wrong in which case the page either wont exist or will show the wrong family.");
                outputText.Report("\n\nNote if you fail to check your entries you will fail to match with your Lost Cousins.");
                int ftanalyzerfacts = Website.FindAll(lc => lc.FTAnalyzerFact).Count;
                int manualfacts     = Website.FindAll(lc => !lc.FTAnalyzerFact).Count;
                Task.Run(() => Analytics.TrackActionAsync(Analytics.LostCousinsAction, Analytics.ReadLostCousins, $"{DateTime.Now.ToUniversalTime():yyyy-MM-dd HH:mm}: {manualfacts} manual & {ftanalyzerfacts} -> {ftanalyzerfacts + recordsAdded} FTAnalyzer entries"));
            }
            catch (Exception e)
            {
                UIHelpers.ShowMessage($"Problem uploading to Lost Cousins error was : {e.Message}");
            }
            return(recordsAdded);
        }