如何以最少的数据库往返进行 gedcom 导入。这种开发的最佳实践是什么

发布于 2024-08-30 17:29:09 字数 12132 浏览 12 评论 0原文

在我当前的应用程序中, 我需要从 gedcom 文件导入用户。 这些用户可能存在于我的注册用户中,或者我需要为其创建一个注册用户。 现在 gedcom 文件包含许多信息 例如个人详细信息、地址、教育详细信息、专业详细信息 这是我们存储用于存储用户个人资料的 xml 文件示例之一。

<UserProfile xmlns="">
  <BasicInfo>
    <Title value="Basic Details" />
    <Fields>
      <UserId title="UserId" right="Public" value="151" />
      <EmailAddress title="Email Address" right="CUG" value="[email protected]" />
      <FirstName title="First Name" right="Public" value="Anju" />
      <LastName title="Last Name" right="Public" value="Trivedi" />
      <DisplayName title="Display Name" right="Private" value="Anju" />
      <RegistrationStatusId title="RegistrationStatusId" right="Public" value="19" />
      <RegistrationStatus title="Registration Status" right="Private" value="Registered" />
      <CityId title="CityId" right="Private" value="19" />
      <CityName title="City" right="Public" value="Delhi" />
      <StateId title="StateId" right="Private" value="69" />
      <StateName title="State" right="Public" value="Delhi" />
      <CountryId title="CountryId" right="Private" value="109" />
      <CountryName title="Country" right="Public" value="India" />
      <Gender title="Gender" right="Private" value="Male" />
      <CreatedBy title="CreatedBy" right="Public" value="0" />
      <CreatedOn title="CreatedOn" right="Public" value="Nov 27 2009  3:08PM " />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="Mar  3 2010  6:56PM " />
      <LogInStatusId title="LogInStatusId" right="Public" value="1" />
      <LogInStatus title="LogIn Status" right="Private" value="Free" />
      <ProfileImagePath title="Profile Pic" right="Public" value="~/Images/13_HolidayBarbie07CL2010427143129.jpg" />
      <ProfileThumbnailPath title="Profile Thumbnail" right="Public" value="~/Images/Thumb13_HolidayBarbie07CL2010427143129.jpg" />
    </Fields>
  </BasicInfo>
  <PersonalInfo>
    <Title value="Personal Details" />
    <Fields>
      <Nickname title="Nick Name" right="Public" value="Anju" />
      <NativeLocation title="Native" right="Public" value="Mehsana" />
      <DateofAnniversary title="Anniversary Dt." right="Private" value="4/1/2010" />
      <BloodGroupId title="BloodGroupId" right="Public" value="24" />
      <BloodGroupName title="Blood Group" right="Public" value="A+" />
      <MaritalStatusId title="MaritalStatusId" right="Private" value="35" />
      <MaritalStatusName title="Marital status" right="Private" value="UnMarried" />
      <DateofDeath title="Death dt" right="Private" value="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="4/27/2010 2:32:07 PM" />
      <DateOfBirth title="Birth Date" value="" right="Public" />
      <BirthPlace title="Birth Place" value="Jaipur" right="Private" />
    </Fields>
  </PersonalInfo>
  <FamilyInfo>
    <Title value="Family Details" />
    <Fields>
      <GallantryHistory title="Gallantry History" right="Public" value="Anjli History" />
      <Ethinicity title="Ethinicity" right="Public" value="Indian" />
      <KulDev title="KulDev" right="Public" value="Krishna" />
      <KulDevi title="KulDevi" right="Public" value="Lakhsmi" />
      <Caste title="Caste" right="Private" value="Vaishnav" />
      <SunSignId title="SunSignId" right="Public" value="15" />
      <SunSignName title="SunSignName" right="Public" value="Gemini" />
    </Fields>
  </FamilyInfo>
  <HobbyInfo>
    <Title value="Hobbies/Interests" />
    <Fields>
      <AbountMe title="Abount Me" right="Public" value="" />
      <Hobbies title="Hobbies" right="Public" value="" />
      <Food title="Food" right="Public" value="" />
      <Movies title="Movies" right="Public" value="" />
      <Music title="Music" right="Public" value="" />
      <TVShows title="TV Shows" right="Public" value="" />
      <Books title="Books" right="Public" value="" />
      <Sports title="Sports" right="Public" value="" />
      <Will title="Will" right="Public" value="" />
      <FavouriteQuotes title="Favourite Quotes" right="Public" value="" />
      <CremationPrefernces title="Cremation Prefernces" right="Public" value="" />
    </Fields>
  </HobbyInfo>
  <PermenantAddr>
    <Title value="Permenant Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="116" />
      <CityName title="City" right="Public" value="Iran" />
      <StateId title="StateId" right="Public" value="95" />
      <StateName title="State" right="Public" value="Iran" />
      <CountryId title="CountryId" right="Public" value="7" />
      <CountryName title="Country" right="Public" value="Afghanistan" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PermenantAddr>
  <PresentAddr>
    <Title value="Present Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="1" />
      <CityName title="City" right="Public" value="Select" />
      <StateId title="StateId" right="Public" value="1" />
      <StateName title="State" right="Public" value="Select" />
      <CountryId title="CountryId" right="Public" value="1" />
      <CountryName title="Country" right="Public" value="Select" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PresentAddr>
  <ContactInfo>
    <Title value="Contact Details" />
    <Fields>
      <DayPhoneNo title="Day Phone" right="Public" value="" />
      <NightPhoneNo title="Night Phone" right="Public" value="" />
      <MobileNo title="Mobile No" right="Private" value="" />
      <FaxNo title="Fax No" right="CUG" value="" />
    </Fields>
  </ContactInfo>
  <EmailInfo>
    <Title value="Alternate Email Addresses" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="3" />
        <Provider title="Provider" right="Public" value="google" />
        <EmailAddress title="Email Address" right="Public" value="[email protected]" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Mar  3 2010 10:17AM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="                    " />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Provider title="Provider" right="Public" value="Yahoo" />
        <EmailAddress title="Email Address" right="Public" value="[email protected]" />
        <IsActive title="IsActive" right="Public" value="false" />
     </Record>
      <Record right="Private">
        <Provider value="111" right="Private" />
        <EmailAddress value="[email protected]" right="Private" />
        <Id value="5" />
     </Record>
    </Fields>
  </EmailInfo>
  <AcademicInfo>
    <Title value="Education Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Education title="Education" right="Public" value="" />
        <Institute title="Institute" right="Public" value="" />
        <PassingYear title="Passing Year" right="Public" value="" />
       </Record>
    </Fields>
  </AcademicInfo>
  <AchievementInfo>
    <Title value="Achievement Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Awards title="Award" right="Public" value="" />
        <FieldOfAward title="Field Of Award" right="Public" value="" />
        <Tournament title="Tournament" right="Public" value="" />
        <AwardDescription title="Description" right="Public" value="" />
        <AwardYear title="Award Year" right="Public" value="" />
      </Record>
    </Fields>
  </AchievementInfo>
  <ProfessionalInfo>
    <Title value="Professional Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Occupation title="Occupation" right="Public" value="a" />
        <Organization title="Organization" right="Public" value="a" />
        <ProjectsDescription title="Description" right="Public" value="a" />
        <Duration title="Duration" right="Public" value="2" /
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="5" />
        <Occupation title="Occupation" right="Public" value="ab" />
        <Organization title="Organization" right="Public" value="zsd" />
        <ProjectsDescription title="Description" right="Public" value="sd" />
        <Duration title="Duration" right="Public" value="5" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="8" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="9" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="10" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
    </Fields>
  </ProfessionalInfo>
</UserProfile>

现在,当我从 gedcom 导入数据时,我正在创建一个包含所有这些信息的人对象。 但在我插入之前,itodatabase 必须检查电子邮件地址的用户 ID 是否存在,不要更新数据 否则创建一个用户并根据从 gedcom 获取的数据更新其 profilexml。

为此,我认为我需要一些解决方案,通过它我只能对数据库进行一次往返,并且可以更新所有用户的 xml。

或者我可以执行一个 sp 来从所有用户获取用户 ID,我将检查用户是否存在然后返回用户 ID,否则插入基本数据并返回插入的用户 ID,

然后为每个用户从数据生成 xml 并更新它。

请提供建议进行此类开发的最佳实践是什么。

如果需要更多详细信息,请写信给我

In My current application,
I need to import users from gedcom file.
these users may exist in my registered users or i need to create one registered user for the same.
now gedcom file contain s many information
e.g. PersonalDetails,Addresses, Education Details, ProfessionalDetails
this is one sample of xml file we are storing to store user's profile.

<UserProfile xmlns="">
  <BasicInfo>
    <Title value="Basic Details" />
    <Fields>
      <UserId title="UserId" right="Public" value="151" />
      <EmailAddress title="Email Address" right="CUG" value="[email protected]" />
      <FirstName title="First Name" right="Public" value="Anju" />
      <LastName title="Last Name" right="Public" value="Trivedi" />
      <DisplayName title="Display Name" right="Private" value="Anju" />
      <RegistrationStatusId title="RegistrationStatusId" right="Public" value="19" />
      <RegistrationStatus title="Registration Status" right="Private" value="Registered" />
      <CityId title="CityId" right="Private" value="19" />
      <CityName title="City" right="Public" value="Delhi" />
      <StateId title="StateId" right="Private" value="69" />
      <StateName title="State" right="Public" value="Delhi" />
      <CountryId title="CountryId" right="Private" value="109" />
      <CountryName title="Country" right="Public" value="India" />
      <Gender title="Gender" right="Private" value="Male" />
      <CreatedBy title="CreatedBy" right="Public" value="0" />
      <CreatedOn title="CreatedOn" right="Public" value="Nov 27 2009  3:08PM " />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="Mar  3 2010  6:56PM " />
      <LogInStatusId title="LogInStatusId" right="Public" value="1" />
      <LogInStatus title="LogIn Status" right="Private" value="Free" />
      <ProfileImagePath title="Profile Pic" right="Public" value="~/Images/13_HolidayBarbie07CL2010427143129.jpg" />
      <ProfileThumbnailPath title="Profile Thumbnail" right="Public" value="~/Images/Thumb13_HolidayBarbie07CL2010427143129.jpg" />
    </Fields>
  </BasicInfo>
  <PersonalInfo>
    <Title value="Personal Details" />
    <Fields>
      <Nickname title="Nick Name" right="Public" value="Anju" />
      <NativeLocation title="Native" right="Public" value="Mehsana" />
      <DateofAnniversary title="Anniversary Dt." right="Private" value="4/1/2010" />
      <BloodGroupId title="BloodGroupId" right="Public" value="24" />
      <BloodGroupName title="Blood Group" right="Public" value="A+" />
      <MaritalStatusId title="MaritalStatusId" right="Private" value="35" />
      <MaritalStatusName title="Marital status" right="Private" value="UnMarried" />
      <DateofDeath title="Death dt" right="Private" value="" />
      <CreatedBy title="CreatedBy" right="Public" value="" />
      <CreatedOn title="CreatedOn" right="Public" value="" />
      <ModifiedBy title="ModifiedBy" right="Public" value="13" />
      <ModifiedOn title="ModifiedOn" right="Public" value="4/27/2010 2:32:07 PM" />
      <DateOfBirth title="Birth Date" value="" right="Public" />
      <BirthPlace title="Birth Place" value="Jaipur" right="Private" />
    </Fields>
  </PersonalInfo>
  <FamilyInfo>
    <Title value="Family Details" />
    <Fields>
      <GallantryHistory title="Gallantry History" right="Public" value="Anjli History" />
      <Ethinicity title="Ethinicity" right="Public" value="Indian" />
      <KulDev title="KulDev" right="Public" value="Krishna" />
      <KulDevi title="KulDevi" right="Public" value="Lakhsmi" />
      <Caste title="Caste" right="Private" value="Vaishnav" />
      <SunSignId title="SunSignId" right="Public" value="15" />
      <SunSignName title="SunSignName" right="Public" value="Gemini" />
    </Fields>
  </FamilyInfo>
  <HobbyInfo>
    <Title value="Hobbies/Interests" />
    <Fields>
      <AbountMe title="Abount Me" right="Public" value="" />
      <Hobbies title="Hobbies" right="Public" value="" />
      <Food title="Food" right="Public" value="" />
      <Movies title="Movies" right="Public" value="" />
      <Music title="Music" right="Public" value="" />
      <TVShows title="TV Shows" right="Public" value="" />
      <Books title="Books" right="Public" value="" />
      <Sports title="Sports" right="Public" value="" />
      <Will title="Will" right="Public" value="" />
      <FavouriteQuotes title="Favourite Quotes" right="Public" value="" />
      <CremationPrefernces title="Cremation Prefernces" right="Public" value="" />
    </Fields>
  </HobbyInfo>
  <PermenantAddr>
    <Title value="Permenant Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="116" />
      <CityName title="City" right="Public" value="Iran" />
      <StateId title="StateId" right="Public" value="95" />
      <StateName title="State" right="Public" value="Iran" />
      <CountryId title="CountryId" right="Public" value="7" />
      <CountryName title="Country" right="Public" value="Afghanistan" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PermenantAddr>
  <PresentAddr>
    <Title value="Present Address" />
    <Fields>
      <Address title="Address" right="Public" value="Select" />
      <CityId title="CityId" right="Public" value="1" />
      <CityName title="City" right="Public" value="Select" />
      <StateId title="StateId" right="Public" value="1" />
      <StateName title="State" right="Public" value="Select" />
      <CountryId title="CountryId" right="Public" value="1" />
      <CountryName title="Country" right="Public" value="Select" />
      <ZipCode title="ZipCode" right="Private" value="" />
    </Fields>
  </PresentAddr>
  <ContactInfo>
    <Title value="Contact Details" />
    <Fields>
      <DayPhoneNo title="Day Phone" right="Public" value="" />
      <NightPhoneNo title="Night Phone" right="Public" value="" />
      <MobileNo title="Mobile No" right="Private" value="" />
      <FaxNo title="Fax No" right="CUG" value="" />
    </Fields>
  </ContactInfo>
  <EmailInfo>
    <Title value="Alternate Email Addresses" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="3" />
        <Provider title="Provider" right="Public" value="google" />
        <EmailAddress title="Email Address" right="Public" value="[email protected]" />
        <IsActive title="IsActive" right="Public" value="false" />
        <CreatedBy title="CreatedBy" right="Public" value="13" />
        <CreatedOn title="CreatedOn" right="Public" value="Mar  3 2010 10:17AM " />
        <ModifiedBy title="ModifiedBy" right="Public" value="0" />
        <ModifiedOn title="ModifiedOn" right="Public" value="                    " />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Provider title="Provider" right="Public" value="Yahoo" />
        <EmailAddress title="Email Address" right="Public" value="[email protected]" />
        <IsActive title="IsActive" right="Public" value="false" />
     </Record>
      <Record right="Private">
        <Provider value="111" right="Private" />
        <EmailAddress value="[email protected]" right="Private" />
        <Id value="5" />
     </Record>
    </Fields>
  </EmailInfo>
  <AcademicInfo>
    <Title value="Education Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Education title="Education" right="Public" value="" />
        <Institute title="Institute" right="Public" value="" />
        <PassingYear title="Passing Year" right="Public" value="" />
       </Record>
    </Fields>
  </AcademicInfo>
  <AchievementInfo>
    <Title value="Achievement Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="0" />
        <Awards title="Award" right="Public" value="" />
        <FieldOfAward title="Field Of Award" right="Public" value="" />
        <Tournament title="Tournament" right="Public" value="" />
        <AwardDescription title="Description" right="Public" value="" />
        <AwardYear title="Award Year" right="Public" value="" />
      </Record>
    </Fields>
  </AchievementInfo>
  <ProfessionalInfo>
    <Title value="Professional Details" />
    <Fields>
      <Record right="Public">
        <Id title="Id" right="Public" value="4" />
        <Occupation title="Occupation" right="Public" value="a" />
        <Organization title="Organization" right="Public" value="a" />
        <ProjectsDescription title="Description" right="Public" value="a" />
        <Duration title="Duration" right="Public" value="2" /
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="5" />
        <Occupation title="Occupation" right="Public" value="ab" />
        <Organization title="Organization" right="Public" value="zsd" />
        <ProjectsDescription title="Description" right="Public" value="sd" />
        <Duration title="Duration" right="Public" value="5" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="8" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="9" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
      <Record right="Public">
        <Id title="Id" right="Public" value="10" />
        <Occupation title="Occupation" right="Public" value="fgdf" />
        <Organization title="Organization" right="Public" value="gdfg" />
        <ProjectsDescription title="Description" right="Public" value="dfgdf" />
        <Duration title="Duration" right="Public" value="12" />
      </Record>
    </Fields>
  </ProfessionalInfo>
</UserProfile>

now when i am importing data from gedcom, i am creating one person object which contains all this info.
but before i insert it itodatabase have to check if userid exist for the emailaddress dont update data
else create a user and update its profilexml from data fecthed from gedcom.

for this i think i need some soln by which i can do only one roundtrip to database and can update all user's xml.

or i can execute one sp to get userid from all users where i'll check if user exist then return userid else insert basic data and return inserted userid

then for every user make xml from data and update it.

please provide be suggestion what is best practice to do this kind of development.

if need any more details please write me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲性难收 2024-09-06 17:29:09

您可以向数据库发送一个查询来获取新文件的用户:

select * from person_table where [email protected]  or  userID = [email protected] or ...

然后,根据返回的结果,您可以检查结果集中是否有每个用户的记录,并进行相应的处理。

You could send one query to the database to get users for your new file:

select * from person_table where [email protected]  or  userID = [email protected] or ...

Then from the results you get back you can check to see if there was a record for each user in the result set and procede accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文