示例#1
0
 internal static bool MatchesType(CompoundIdentity entityId, BundleDataType type)
 {
     if (type == BundleDataType.Site)
     {
         return(entityId.DataStoreIdentity.Equals(siteDomainId));
     }
     else if (type == BundleDataType.TaxaUnit)
     {
         return(entityId.DataStoreIdentity.Equals(taxaDomainId));
     }
     else if (type == BundleDataType.Instrument)
     {
         return(entityId.DataStoreIdentity.Equals(instrumentDomainId));
     }
     return(entityId.DataStoreIdentity.Equals(plotTypeDomainId));
 }
示例#2
0
        public EntityBundle Create(string name, CompoundIdentity principalOrgId, BundleDataType dataType)
        {
            if (!string.IsNullOrEmpty(name) && !principalOrgId.IsNullOrEmpty() && this.CanCreate())
            {
                try
                {
                    NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
                    cmd.CommandText = Db.InsertBundle;
                    Guid id = Guid.NewGuid();
                    cmd.Parameters.AddWithValue("id", id);
                    cmd.Parameters.AddWithValue("name", name);
                    cmd.Parameters.AddWithValue("osid", principalOrgId.DataStoreIdentity);
                    cmd.Parameters.AddWithValue("oid", principalOrgId.Identity);
                    cmd.Parameters.AddWithValue("dt", (int)dataType);

                    Db.ExecuteNonQuery(cmd);

                    return(new EntityBundle(id, name, principalOrgId, dataType));
                }
                catch
                { }
            }
            return(null);
        }
示例#3
0
文件: Items.cs 项目: OSRS/Oncor_Base
 internal static bool Verify(IEnumerable <Tuple <CompoundIdentity, string, string> > items, BundleDataType type, UserSecurityContext ctx)
 {
     if (type == BundleDataType.TaxaUnit)
     {
         ITaxaUnitProvider tprov = TaxonomyManager.Instance.GetTaxaUnitProvider(ctx);
         if (tprov != null)
         {
             foreach (Tuple <CompoundIdentity, string, string> cur in items)
             {
                 if (!tprov.Exists(cur.Item1))
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     else if (type == BundleDataType.Site)
     {
         ISiteProvider sprov = SiteManager.Instance.GetSiteProvider(ctx);
         if (sprov != null)
         {
             foreach (Tuple <CompoundIdentity, string, string> cur in items)
             {
                 if (!sprov.Exists(cur.Item1))
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     else if (type == BundleDataType.Instrument)
     {
         IInstrumentProvider iprov = InstrumentManager.Instance.GetInstrumentProvider(ctx);
         if (iprov != null)
         {
             foreach (Tuple <CompoundIdentity, string, string> cur in items)
             {
                 if (!iprov.Exists(cur.Item1))
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
示例#4
0
文件: Items.cs 项目: OSRS/Oncor_Base
 internal static bool VandV(IEnumerable <Tuple <CompoundIdentity, string, string> > items, BundleDataType type, UserSecurityContext ctx)
 {
     if (Validate(items))
     {
         return(Verify(items, type, ctx));
     }
     return(false);
 }
示例#5
0
 internal EntityBundle(Guid bundleId, string name, CompoundIdentity principalOrgId, BundleDataType dataType)
 {
     this.Id             = bundleId;
     this.name           = name;
     this.PrincipalOrgId = principalOrgId;
     this.DataType       = dataType;
 }