Ejemplo n.º 1
0
 /// <summary>
 /// Gets the items.
 /// </summary>
 /// <param name="itemType">Type of the itemName.</param>
 /// <returns></returns>
 public IAzManItem[] GetItems(ItemType itemType)
 {
     IAzManItem[] items;
     var ds = (from tf in this.db.Items()
               where tf.ApplicationId == this.applicationId && tf.ItemType.Value == (byte)itemType
               orderby tf.Name
               select tf).ToList();
     items = new SqlAzManItem[ds.Count];
     int index = 0;
     foreach (var row in ds)
     {
         string bizRule = String.Empty;
         NetSqlAzMan.BizRuleSourceLanguage? bizRuleScriptLanguage = null;
         if (row.BizRuleId.HasValue)
         {
             var bizrule = (from tf in this.db.BizRules()
                            where tf.BizRuleId == row.BizRuleId.Value
                            select tf).First();
             bizRule = bizrule.BizRuleSource;
             bizRuleScriptLanguage = (NetSqlAzMan.BizRuleSourceLanguage)bizrule.BizRuleLanguage.Value;
         }
         items[index] = new SqlAzManItem(this.db, this, row.ItemId.Value, row.Name, row.Description, (ItemType)row.ItemType, bizRule, bizRuleScriptLanguage, this.ens);
         if (this.ens != null)
             this.ens.AddPublisher(items[index]);
         index++;
     }
     return items;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the <see cref="T:IAzManItem"/> with the specified itemName name.
 /// </summary>
 /// <value></value>
 public IAzManItem GetItem(string itemName)
 {
     ItemsResult items;
     if ((items = (from t in this.db.Items() where t.Name == itemName && t.ApplicationId == this.applicationId select t).FirstOrDefault()) != null)
     {
         int itemId = items.ItemId.Value;
         string name = items.Name;
         string description = items.Description;
         ItemType itemType = (ItemType)items.ItemType.Value;
         string bizRule = String.Empty;
         NetSqlAzMan.BizRuleSourceLanguage? bizRuleScriptLanguage = null;
         if (items.BizRuleId.HasValue)
         {
             var bizrule = (from br in this.db.BizRules()
                            where br.BizRuleId == items.BizRuleId.Value
                            select br).First();
             bizRule = bizrule.BizRuleSource;
             bizRuleScriptLanguage = (NetSqlAzMan.BizRuleSourceLanguage)bizrule.BizRuleLanguage.Value;
         }
         IAzManItem result = new SqlAzManItem(this.db, this, itemId, name, description, itemType, bizRule, bizRuleScriptLanguage, this.ens);
         if (this.ens != null)
             this.ens.AddPublisher(result);
         return result;
     }
     else
     {
         throw SqlAzManException.ItemNotFoundException(itemName, this, null);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the items.
 /// </summary>
 /// <returns></returns>
 public IAzManItem[] GetItems()
 {
     IAzManItem[] items;
     var ds = (from tf in this.db.Items()
               where tf.ApplicationId == this.applicationId
               orderby tf.Name
               select tf).ToList();
     items = new SqlAzManItem[ds.Count];
     int index = 0;
     this.items = new Dictionary<string, IAzManItem>();
     foreach (var row in ds)
     {
         string bizRule = String.Empty;
         NetSqlAzMan.BizRuleSourceLanguage? bizRuleScriptLanguage = null;
         if (row.BizRuleId.HasValue)
         {
             var bizrule = (from tf in this.db.BizRules()
                            where tf.BizRuleId == row.BizRuleId
                            select tf).First();
             bizRule = bizrule.BizRuleSource;
             bizRuleScriptLanguage = (NetSqlAzMan.BizRuleSourceLanguage)bizrule.BizRuleLanguage.Value;
         }
         items[index] = new SqlAzManItem(this.db, this, row.ItemId.Value, row.Name, row.Description, (ItemType)row.ItemType.Value, bizRule, bizRuleScriptLanguage, this.ens);
         this.items.Add(items[index].Name, items[index]);
         if (this.ens != null)
             this.ens.AddPublisher(items[index]);
         index++;
     }
     //Members
     var dt = (from v in this.db.ItemsHierarchyView
               where v.ApplicationId == this.applicationId
               select v).ToList();
     foreach (IAzManItem item in this.items.Values)
     {
         ((SqlAzManItem)item).members = new Dictionary<string, IAzManItem>();
         foreach (var row in dt.Where<ItemsHierarchyView>(p => p.Name == item.Name))
         {
             IAzManItem member = this.items[row.MemberName];
             ((SqlAzManItem)item).members.Add(member.Name, member);
             //Items Where Im a member
             if (((SqlAzManItem)member).itemsWhereIAmAMember == null)
             {
                 ((SqlAzManItem)member).itemsWhereIAmAMember = new Dictionary<string, IAzManItem>();
             }
             if (!(((SqlAzManItem)member).itemsWhereIAmAMember.ContainsKey(item.Name)))
             {
                 ((SqlAzManItem)member).itemsWhereIAmAMember.Add(item.Name, item);
             }
         }
     }
     return items;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the itemName.
        /// </summary>
        /// <param name="itemName">Name of the itemName.</param>
        /// <param name="itemDescription">The itemName description.</param>
        /// <param name="itemType">Type of the itemName.</param>
        /// <returns></returns>
        public IAzManItem CreateItem(string itemName, string itemDescription, ItemType itemType)
        {
            try
            {
                int id = this.db.ItemInsert(itemName, itemDescription, (byte)itemType, null, this.applicationId);
                IAzManItem itemCreated = new SqlAzManItem(this.db, this, id, itemName, itemDescription, itemType, String.Empty, null, this.ens);
                this.raiseItemCreated(this, itemCreated);
                if (this.ens != null)
                    this.ens.AddPublisher(itemCreated);
                //Update cached items
                if (this.items != null && !this.items.ContainsKey(itemCreated.Name))
                    this.items.Add(itemCreated.Name, itemCreated);
                ((SqlAzManItem)itemCreated).members = new Dictionary<string, IAzManItem>();
                return itemCreated;
            }
            catch (System.Data.SqlClient.SqlException sqlex)
            {
                if (sqlex.Number == 2601) //Index Duplicate Error
                    throw SqlAzManException.ItemDuplicateException(itemName, this, sqlex);
                else
                    throw SqlAzManException.GenericException(sqlex);

            }
        }