Esempio n. 1
0
        /// <summary>
        /// Raises the <see cref="E:Activated"/> event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="IActivatedEventArgs"/> instance containing the event data.
        /// </param>
        protected override void OnActivated(IActivatedEventArgs e)
        {
            // Handle Protocol Activation
            //
            // Handles URIs of the format used by Gramps internally gramps://person/handle/12345
            if (e.Kind == ActivationKind.Protocol)
            {
                if (e is ProtocolActivatedEventArgs uriArgs)
                {
                    string[] uriSegments = uriArgs.Uri.Segments;

                    if (uriSegments[1] != "handle/")
                    {
                        ErrorInfo badUriAdditionalInfo = new ErrorInfo("Bad Protocol Activation Argument")
                        {
                            { "URI", uriArgs.Uri.ToString() },
                            { "Data", uriArgs.Data.ToString() }
                        };

                        ((GrampsView.App)Xamarin.Forms.Application.Current).Services.GetService <IErrorNotifications>().NotifyError(badUriAdditionalInfo);
                    }

                    // TODO Handle if GrampsView not running

                    switch (uriArgs.Uri.Host)
                    {
                    case Constants.ModelNameFamily:
                    {
                        HLinkFamilyModel targetFamily = new HLinkFamilyModel
                        {
                            HLinkKey = new HLinkKey(uriSegments[2])
                        };

                        targetFamily.UCNavigate();

                        break;
                    }

                    case Constants.ModelNamePerson:
                    {
                        HLinkPersonModel targetPerson = new HLinkPersonModel
                        {
                            HLinkKey = new HLinkKey(uriSegments[2])
                        };

                        targetPerson.UCNavigate();

                        break;
                    }

                    default:
                    {
                        // TODO Handle bad arg better

                        break;
                    }
                    }
                }
            }
        }
        /// <summary>
        /// Populates the view ViewModel.
        /// </summary>
        /// <returns>
        /// Task.
        /// </returns>
        public override void HandleViewDataLoadEvent()
        {
            HLinkFamilyModel HLinkFamily = CommonRoutines.GetHLinkParameter <HLinkFamilyModel>(BaseParamsHLink);

            FamilyObject = HLinkFamily.DeRef;

            if (!(FamilyObject is null))
            {
                BaseModelBase = FamilyObject;
                BaseTitleIcon = Constants.IconFamilies;

                // Get basic details
                BaseDetail.Add(new CardListLineCollection("Family Detail")
                {
                    new CardListLine("Family Display Name:", FamilyObject.ToString()),
                    new CardListLine("Family Relationship:", FamilyObject.GFamilyRelationship),
                    new CardListLine("Father Name:", FamilyObject.GFather.DeRef.GPersonNamesCollection.GetPrimaryName.DeRef.FullName),
                    new CardListLine("Mother Name:", FamilyObject.GMother.DeRef.GPersonNamesCollection.GetPrimaryName.DeRef.FullName),
                    new CardListLine("Date:", FamilyObject.GDate.LongDate),
                });

                // Add Model details
                BaseDetail.Add(DV.FamilyDV.GetModelInfoFormatted(FamilyObject));

                // Add parent link
                BaseDetail.Add(new HLinkParentLinkModel
                {
                    DeRef = localFamilyModel,
                });
            }
        }
        /// <summary>
        /// Organises the family repository.
        /// </summary>
        private static async Task <bool> OrganiseFamilyRepository()
        {
            await DataStore.CN.MajorStatusAdd("Organising Family data ").ConfigureAwait(false);

            foreach (FamilyModel theFamilyModel in DV.FamilyDV.DataViewData)
            {
                HLinkFamilyModel t = theFamilyModel.HLink;

                // -- Organse Back Links ---------------------

                // Child Collection
                foreach (HLinkPersonModel personRef in theFamilyModel.GChildRefCollection)
                {
                    DataStore.DS.PersonData[personRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }

                // Citation Collection
                foreach (HLinkCitationModel citationRef in theFamilyModel.GCitationRefCollection)
                {
                    DataStore.DS.CitationData[citationRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }

                // Back Reference Event HLinks
                foreach (HLinkEventModel eventRef in theFamilyModel.GEventRefCollection)
                {
                    DataStore.DS.EventData[eventRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }

                // Media Collection
                foreach (HLinkMediaModel mediaRef in theFamilyModel.GMediaRefCollection)
                {
                    DataStore.DS.MediaData[mediaRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }

                // Note Collection
                foreach (HLinkNoteModel noteRef in theFamilyModel.GNoteRefCollection)
                {
                    DataStore.DS.NoteData[noteRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }

                // Tag Collection
                foreach (HLinkTagModel tagRef in theFamilyModel.GTagRefCollection)
                {
                    DataStore.DS.TagData[tagRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t));
                }
            }

            return(true);
        }
Esempio n. 4
0
        public HLinkBackLink SetBookMarkTarget(string argGTarget, string argGHlink)
        {
            switch (argGTarget)
            {
            case "person":
            {
                HLinkPersonModel p1 = new HLinkPersonModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "family":
            {
                HLinkFamilyModel p1 = new HLinkFamilyModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "event":
            {
                HLinkEventModel p1 = new HLinkEventModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "source":
            {
                HLinkSourceModel p1 = new HLinkSourceModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "citation":
            {
                HLinkCitationModel p1 = new HLinkCitationModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "place":
            {
                HLinkPlaceModel p1 = new HLinkPlaceModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "media":
            {
                HLinkMediaModel p1 = new HLinkMediaModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "repository":
            {
                HLinkRepositoryModel p1 = new HLinkRepositoryModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }

            case "note":
            {
                HLinkNoteModel p1 = new HLinkNoteModel
                {
                    HLinkKey = argGHlink
                };

                return(new HLinkBackLink(p1));
            }
            }

            return(new HLinkBackLink());
        }
Esempio n. 5
0
        /// <summary>
        /// Load the person data from the external storage XML file.
        /// </summary>
        /// <returns>
        /// Flag indicating if people data loaded successfully.
        /// </returns>
        public async Task LoadPeopleDataAsync()
        {
            _iocCommonLogging.RoutineEntry("LoadPeopleDataAsync");

            App.Current.Services.GetService <IErrorNotifications>().DataLogEntryAdd("Loading People data");
            {
                string defaultImage = string.Empty;

                // Run query
                var de =
                    from el in localGrampsXMLdoc.Descendants(ns + "person")
                    select el;

                try
                {
                    foreach (XElement pname in de)
                    {
                        PersonModel loadPerson = new PersonModel();

                        // Person attributes
                        loadPerson.LoadBasics(GetBasics(pname));

                        if (loadPerson.Id == "I1138")
                        {
                        }

                        // Address
                        loadPerson.GAddressCollection = GetAddressCollection(pname);

                        // Get attribute collection
                        loadPerson.GAttributeCollection = GetAttributeCollection(pname);

                        // Childof
                        XElement tempChildOf = pname.Element(ns + "childof");
                        if (tempChildOf != null)
                        {
                            // Force glyph valid while loading
                            loadPerson.GChildOf.HLinkGlyphItem.ImageType = CommonEnums.HLinkGlyphType.TempLoading;
                            loadPerson.GChildOf.HLinkKey = GetHLinkKey(tempChildOf);
                        }

                        // CitationRef collection
                        loadPerson.GCitationRefCollection = GetCitationCollection(pname);

                        // EventRef
                        loadPerson.GEventRefCollection = GetEventCollection(pname);

                        // gender
                        switch (GetElement(pname, "gender"))
                        {
                        case "F":
                        {
                            loadPerson.GGender = CommonEnums.Gender.Female;
                            break;
                        }

                        case "M":
                        {
                            loadPerson.GGender = CommonEnums.Gender.Male;
                            break;
                        }

                        default:
                        {
                            loadPerson.GGender = CommonEnums.Gender.Unknown;
                            break;
                        }
                        }

                        // TODO load LDS collection

                        // media object collection loading
                        loadPerson.GMediaRefCollection = await GetObjectCollection(pname).ConfigureAwait(false);

                        // Name
                        loadPerson.GPersonNamesCollection = GetPersonNameCollection(pname);

                        // NoteRefs Collection
                        loadPerson.GNoteRefCollection = GetNoteCollection(pname);

                        // Parentin
                        IEnumerable <XElement> localPIElement =
                            from pIElementEl in pname.Descendants(ns + "parentin")
                            select pIElementEl;

                        if (localPIElement.Any())
                        {
                            // load parentIn references
                            foreach (XElement loadPIElement in localPIElement)
                            {
                                HLinkFamilyModel t = new HLinkFamilyModel
                                {
                                    HLinkKey = GetHLinkKey(loadPIElement),
                                };

                                loadPerson.GParentInRefCollection.Add(t);
                            }

                            loadPerson.GParentInRefCollection.SetFirstImage();
                        }

                        // PersonRef
                        loadPerson.GPersonRefCollection = GetPersonRefCollection(pname);

                        // TagRef
                        loadPerson.GTagRefCollection = GetTagCollection(pname);

                        // URL
                        loadPerson.GURLCollection = GetURLCollection(pname);

                        // load the person
                        DV.PersonDV.PersonData.Add(loadPerson);
                    }

                    // let everybody know
                    _iocCommonLogging.RoutineExit("loadPeopleData");
                }
                catch (Exception ex)
                {
                    if (DV.PersonDV.PersonData.Count > 0)
                    {
                        // TODO Add this back + DV.PersonDV.PersonData[DV.PersonDV.PersonData.Count].GPersonNamesCollection.GetPrimaryName.FullName
                        App.Current.Services.GetService <IErrorNotifications>().NotifyException("Loading person from GRAMPSXML storage.  The last person successfully loaded was ", ex);
                        throw;
                    }
                    else
                    {
                        App.Current.Services.GetService <IErrorNotifications>().NotifyException("Loading people from GRAMPSXML storage.  No people have been loaded", ex);
                        throw;
                    }
                }
            }

            //var tt = (DataStore.Instance.DS.PersonNameData.Where(x => x.Value.GSurName.GetPrimarySurname == "Ainger"));
            //if (tt.Count() > 0)
            //{
            //}

            App.Current.Services.GetService <IErrorNotifications>().DataLogEntryReplace("People load complete");

            return;
        }
        /// <summary>
        /// load the person data from the external storage XML file.
        /// </summary>
        /// <param name="personRepository">
        /// The person repository.
        /// </param>
        /// <returns>
        /// Flag indicating if people data loaded successfully.
        /// </returns>
        public async Task LoadPeopleDataAsync()
        {
            localGrampsCommonLogging.LogRoutineEntry("loadPeopleData");

            await DataStore.CN.MajorStatusAdd("Loading People data").ConfigureAwait(false);

            {
                string defaultImage = string.Empty;

                // Run query
                var de =
                    from el in localGrampsXMLdoc.Descendants(ns + "person")
                    select el;

                try
                {
                    foreach (XElement pname in de)
                    {
                        PersonModel loadPerson = DV.PersonDV.NewModel();

                        // Person attributes
                        loadPerson.LoadBasics(GetBasics(pname));
                        //loadPerson.Id = GetAttribute(pname.Attribute("id"));

                        if (loadPerson.Id == "I0571")
                        {
                        }

                        //loadPerson.Change = GetDateTime(pname, "change");
                        //loadPerson.Priv = SetPrivateObject(GetAttribute(pname.Attribute("priv")));
                        //loadPerson.Handle = GetAttribute(pname, "handle");

                        // if (loadPerson.Id == "I0922") { // Why parent hugh cameron display bad? } Address
                        loadPerson.GAddress = GetAddressCollection(pname);

                        // Get attribute collection
                        loadPerson.GAttributeCollection = GetAttributeCollection(pname);

                        // Childof
                        XElement tempChildOf = pname.Element(ns + "childof");
                        if (tempChildOf != null)
                        {
                            loadPerson.GChildOf.HLinkKey = (string)tempChildOf.Attribute("hlink");
                        }

                        // CitationRef collection
                        loadPerson.GCitationRefCollection = GetCitationCollection(pname);

                        // EventRef
                        loadPerson.GEventRefCollection = GetEventCollection(pname);

                        // gender
                        loadPerson.GGender = GetElement(pname, "gender");

                        // TODO load LDS collection

                        // media object collection loading
                        loadPerson.GMediaRefCollection = await GetObjectCollection(pname).ConfigureAwait(false);

                        // Name
                        loadPerson.GPersonNamesCollection = GetPersonNameCollection(pname);

                        // NoteRefs Collection
                        loadPerson.GNoteRefCollection = GetNoteCollection(pname);

                        // Parentin
                        var localPIElement =
                            from pIElementEl in pname.Descendants(ns + "parentin")
                            select pIElementEl;

                        if (localPIElement.Any())
                        {
                            // load parentIn references
                            foreach (XElement loadPIElement in localPIElement)
                            {
                                HLinkFamilyModel t = new HLinkFamilyModel
                                {
                                    HLinkKey = (string)loadPIElement.Attribute("hlink"),
                                };
                                loadPerson.GParentInRefCollection.Add(t);
                            }

                            loadPerson.GParentInRefCollection.SortAndSetFirst();
                        }

                        // PersonRef
                        loadPerson.GPersonRefCollection = GetPersonRefCollection(pname);

                        // TagRef
                        loadPerson.GTagRefCollection = GetTagCollection(pname);

                        // URL
                        loadPerson.GURLCollection = GetURLCollection(pname);

                        // HomeImageLink
                        loadPerson = SetHomeImage(loadPerson);

                        // load the person
                        DV.PersonDV.PersonData.Add(loadPerson);
                    }

                    // let everybody know
                    localGrampsCommonLogging.LogRoutineExit("loadPeopleData");
                }
                catch (Exception ex)
                {
                    if (DV.PersonDV.PersonData.Count > 0)
                    {
                        // TODO Add this back + DV.PersonDV.PersonData[DV.PersonDV.PersonData.Count].GPersonNamesCollection.GetPrimaryName.FullName
                        DataStore.CN.NotifyException("Loading person from GRAMPSXML storage.  The last person successfully loaded was ", ex);
                        throw;
                    }
                    else
                    {
                        DataStore.CN.NotifyException("Loading person from GRAMPSXML storage.  No people have been loaded", ex);
                        throw;
                    }
                }
            }

            await DataStore.CN.MajorStatusDelete().ConfigureAwait(false);

            return;
        }
Esempio n. 7
0
        public static HLinkBackLink SetBookMarkTarget(string argGTarget, HLinkKey argHLinkKey)
        {
            switch (argGTarget)
            {
            case "person":
            {
                HLinkPersonModel p1 = DV.PersonDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "family":
            {
                HLinkFamilyModel p1 = DV.FamilyDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "event":
            {
                HLinkEventModel p1 = DV.EventDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "source":
            {
                HLinkSourceModel p1 = DV.SourceDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "citation":
            {
                HLinkCitationModel p1 = DV.CitationDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "place":
            {
                HLinkPlaceModel p1 = DV.PlaceDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "media":
            {
                HLinkMediaModel p1 = DV.MediaDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "repository":
            {
                HLinkRepositoryModel p1 = DV.RepositoryDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }

            case "note":
            {
                HLinkNoteModel p1 = DV.NoteDV.GetModelFromHLinkKey(argHLinkKey).HLink;

                return(new HLinkBackLink(p1));
            }
            }

            return(new HLinkBackLink());
        }