Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CubeProperty" /> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="cube">The cube.</param>
        /// <param name="de">The de.</param>
        /// <exception cref="Exception"></exception>
        public CubeProperty(object property, CubeBase cube, Entity de)
        {
            _Property = property;
            if (property != null)
            {
                IsSet = true;
            }

            KeyValuePair <string, object> p = (KeyValuePair <string, object>)property;

            if (p.Value is EntityReference)
            {
                EntityReference er = (EntityReference)p.Value;
                Name        = er.Name;
                LogicalName = er.LogicalName;
                ValueString = er.Id.ToString();
                ValueObject = er.Id;
            }
            else if (p.Value is OptionSetValue)
            {
                OptionSetValue osv      = (OptionSetValue)p.Value;
                Result         mdResult = cube.MetadataRetrieveActions.GetOptionSetText(de.LogicalName, p.Key, osv.Value);
                if (mdResult.isError)
                {
                    throw new Exception(mdResult.Message);
                }

                Name        = mdResult.BusinessObject.ToString();
                LogicalName = p.Key;
                ValueString = osv.Value.ToString();
                ValueObject = osv.Value;
            }
            else if (p.Value is Money)
            {
                Money money = (Money)p.Value;
                Name        = money.Value.ToString();
                LogicalName = p.Key;
                ValueString = money.Value.ToString();
                ValueObject = money.Value;
            }
            else
            {
                Name        = p.Value.ToString();
                LogicalName = p.Key;
                ValueString = p.Value.ToString();
                ValueObject = p.Value;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parses the entities.
        /// </summary>
        /// <param name="de">The de.</param>
        /// <param name="Schema">The schema.</param>
        /// <param name="cube">The cube.</param>
        /// <returns>Result.</returns>
        public static Result ParseEntities(Entity de, string[] Schema, CubeBase cube)
        {
            try
            {
                Hashtable parsedEntities = new Hashtable();
                if (Schema != null && Schema.Length > 0)
                {
                    ArrayList listSchema = new ArrayList(Schema);
                    foreach (KeyValuePair <string, object> p in de.Attributes)
                    {
                        for (int i = 0; i < listSchema.Count; i++)
                        {
                            if (p.Key == (string)listSchema[i])
                            {
                                parsedEntities.Add(p.Key, new CubeProperty(p, cube, de));
                                listSchema.RemoveAt(i);
                                break;
                            }
                        }
                    }

                    if (listSchema.Count > 0)
                    {
                        foreach (string s in listSchema)
                        {
                            parsedEntities.Add(s, new CubeProperty(null));
                        }
                    }
                }
                else
                {
                    foreach (KeyValuePair <string, object> p in de.Attributes)
                    {
                        parsedEntities.Add(p.Key, new CubeProperty(p, cube, de));
                    }
                }

                CubeEntity cubeE = new CubeEntity();
                cubeE.TableCubeEntity = parsedEntities;
                return(new Result(false, string.Empty, cubeE, cube.LogSystem));
            }
            catch (Exception ex)
            {
                return(new Result(true, ex.Message, null, cube.LogSystem));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Clones the specified cube.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="cube">The cube.</param>
 /// <returns>Result.</returns>
 public static Result Clone(this Entity entity, CubeBase cube)
 {
     try
     {
         var result = new Entity(entity.LogicalName, entity.Id)
         {
             EntityState = entity.EntityState,
             RowVersion  = entity.RowVersion
         };
         result.KeyAttributes.AddRange(entity.KeyAttributes.Select(k => new KeyValuePair <string, object>(k.Key, k.Value)));
         result.Attributes.AddRange(entity.Attributes.Select(a => new KeyValuePair <string, object>(a.Key, a.Value)));
         return(new Result(false, null, entity, null));
     }
     catch (Exception ex)
     {
         return(new Result(true, ex.Message, null, cube.LogSystem));
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Merges the specified entity.
 /// </summary>
 /// <param name="baseEntity">The base entity.</param>
 /// <param name="entity">The entity.</param>
 /// <param name="cube">The cube.</param>
 /// <returns>Result.</returns>
 public static Result Merge(this Entity baseEntity, Entity entity, CubeBase cube)
 {
     try
     {
         if (baseEntity == null)
         {
             return(new Result(false, null, entity, null));
         }
         if (entity != null)
         {
             baseEntity.Attributes.AddRange(entity.Attributes.Where(a => !baseEntity.Contains(a.Key)).Select(b => new KeyValuePair <string, object>(b.Key, b.Value)));
         }
         return(new Result(false, null, baseEntity, null));
     }
     catch (Exception ex)
     {
         return(new Result(true, ex.Message, null, cube.LogSystem));
     }
 }
Esempio n. 5
0
 public CubeEntity()
 {
     cube = ObjectCarrier.GetValue <CubeBase>("cube");
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CubeEntity" /> class.
 /// </summary>
 /// <param name="Cube">The cube.</param>
 public CubeEntity(CubeBase Cube)
 {
     cube = Cube;
 }