コード例 #1
0
 /// <summary>
 /// Opens the specified store name.
 /// </summary>
 /// <param name="storeName">Name of the store.</param>
 /// <returns></returns>
 public IAzManStore GetStore(string storeName)
 {
     StoresResult sr;
     if ((sr = (from t in this.db.Stores() where t.Name == storeName select t).FirstOrDefault()) != null)
     {
         int storeId = sr.StoreId.Value;
         string name = sr.Name;
         string description = sr.Description;
         byte netsqlazmanFixedServerRole = 0;
         if (this.IAmAdmin)
         {
             netsqlazmanFixedServerRole = 3;
         }
         else
         {
             var res1 = this.db.CheckStorePermissions(storeId, 2);
             var res2 = this.db.CheckStorePermissions(storeId, 1);
             if (res1.HasValue && res1.Value)
                 netsqlazmanFixedServerRole = 2;
             else if (res2.HasValue && res2.Value)
                 netsqlazmanFixedServerRole = 1;
         }
         IAzManStore result = new SqlAzManStore(this.db, this, storeId, name, description, netsqlazmanFixedServerRole, this.ens);
         this.raiseStoreOpened(result);
         if (this.ens != null)
             this.ens.AddPublisher(result);
         return result;
     }
     else
     {
         throw SqlAzManException.StoreNotFoundException(storeName, null);
     }
 }
コード例 #2
0
 /// <summary>
 /// Gets the stores.
 /// </summary>
 /// <returns></returns>
 public IAzManStore[] GetStores()
 {
     IAzManStore[] stores;
     var s = (from tf in this.db.Stores()
              orderby tf.Name
              select tf).ToList();
     stores = new SqlAzManStore[s.Count];
     int index = 0;
     foreach (var row in s)
     {
         byte netsqlazmanFixedServerRole = 0;
         if (this.IAmAdmin)
         {
             netsqlazmanFixedServerRole = 3;
         }
         else
         {
             var res1 = this.db.CheckStorePermissions(row.StoreId, 2);
             var res2 = this.db.CheckStorePermissions(row.StoreId, 1);
             if (res1.HasValue && res1.Value)
                 netsqlazmanFixedServerRole = 2;
             else if (res2.HasValue && res2.Value)
                 netsqlazmanFixedServerRole = 1;
         }
         stores[index] = new SqlAzManStore(this.db, this, row.StoreId.Value, row.Name, row.Description, netsqlazmanFixedServerRole, this.ens);
         this.raiseStoreOpened(stores[index]);
         if (this.ens != null)
             this.ens.AddPublisher(stores[index]);
         index++;
     }
     return stores;
 }