public List <Dynamic> GetStar2Profile(string pcc, string level1, string level2, string connectionName)
        {
            Database  db        = DatabaseFactory.CreateDatabase(connectionName);
            DbCommand dbCommand = db.GetStoredProcCommand(Resources.FieldsDynamics.SP_GetStar2);

            db.AddInParameter(dbCommand, Resources.FieldsDynamics.PARAM_Pcc, DbType.String, pcc);
            db.AddInParameter(dbCommand, Resources.FieldsDynamics.PARAM_Level1, DbType.String, level1);
            db.AddInParameter(dbCommand, Resources.FieldsDynamics.PARAM_Level2, DbType.String, level2);

            var     listItem = new List <Dynamic>();
            Dynamic item     = null;

            using (IDataReader dr = db.ExecuteReader(dbCommand))
            {
                if (dr.Read())
                {
                    for (int i = 0; i < dr.FieldCount; i++)
                    {
                        item = new Dynamic();

                        item           = item.Add(dr.GetName(i), dr.GetValue(i));
                        item.FieldName = dr.GetName(i);

                        listItem.Add(item);
                    }
                }
            }

            return(listItem);
        }
Esempio n. 2
0
        private Dynamic Array()
        {
            Dynamic arr = new Dynamic();

            if (_ch == '[')
            {
                Next('[');
                White();

                if (_ch == ']')
                {
                    Next(']');
                    return(arr);
                }

                while (true)
                {
                    arr.Add(Value());
                    White();

                    if (_ch == ']')
                    {
                        Next(']');
                        return(arr);
                    }

                    if (!Next(','))
                    {
                        break;
                    }
                    White();
                }
            }
            return(arr);
        }
Esempio n. 3
0
        protected override Dynamic Process()
        {
            Dynamic data = new Dynamic();

            do
            {
                var table   = new Dynamic();
                var columns = new Dynamic();

                var isFirstRow = true;

                while (ReadLine())
                {
                    var row = new Dynamic();

                    for (int i = 0; i < FieldCount; i++)
                    {
                        var name = GetFieldName(i);
                        var val  = GetDynamicValue(i);

                        row[name] = val;

                        if (isFirstRow)
                        {
                            columns.Add(new Dynamic()
                            {
                                ["Name"] = name,
                                ["Type"] = GetFieldType(i)
                            });
                        }
                    }

                    isFirstRow = false;
                    table.Add(row);
                }

                data["Tables"].Add(new Dynamic()
                {
                    ["Table"]   = table,
                    ["Columns"] = columns
                });
            } while (ReadNextResult());

            data["Code"] = 0;
            return(data);
        }
        public static void AddFields(Dynamic.SerializableDictionary<string, Field> fields, TCM.Fields.ItemFields tcmItemFields, int linkLevels, bool resolveWidthAndHeight, Dynamic.MergeAction mergeAction, BuildManager manager)
        {
            foreach (TCM.Fields.ItemField tcmItemField in tcmItemFields)
             {
            try
            {
               if (fields.ContainsKey(tcmItemField.Name))
               {
                  if (mergeAction.Equals(Dynamic.MergeAction.Skip))
                  {
                     continue;
                  }
                  Dynamic.Field f = manager.BuildField(tcmItemField, linkLevels, resolveWidthAndHeight);
                  if (mergeAction.Equals(Dynamic.MergeAction.Replace))
                  {
                     fields.Remove(f.Name);
                     fields.Add(f.Name, f);
                  }
                  else
                  {
                     Field existingField = fields[f.Name];
                     switch (existingField.FieldType)
                     {

                        case FieldType.ComponentLink:
                        case FieldType.MultiMediaLink:
                           foreach (Component linkedComponent in f.LinkedComponentValues)
                           {
                              bool valueExists = false;
                              foreach (Component existingLinkedComponent in existingField.LinkedComponentValues)
                              {
                                 if (linkedComponent.Id.Equals(existingLinkedComponent.Id))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.LinkedComponentValues.Add(linkedComponent);
                              }
                           }
                           break;
                        case FieldType.Date:
                           foreach (DateTime dateTime in f.DateTimeValues)
                           {
                              bool valueExists = false;
                              foreach (DateTime existingDateTime in existingField.DateTimeValues)
                              {
                                 if (dateTime.Equals(existingDateTime))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.DateTimeValues.Add(dateTime);
                              }
                           }
                           break;
                        case FieldType.Number:
                           foreach (int nr in f.NumericValues)
                           {
                              bool valueExists = false;
                              foreach (int existingNr in existingField.NumericValues)
                              {
                                 if (nr == existingNr)
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.NumericValues.Add(nr);
                              }
                           }
                           break;
                        default:
                           foreach (string val in f.Values)
                           {
                              bool valueExists = false;
                              foreach (string existingVal in existingField.Values)
                              {
                                 if (val.Equals(existingVal))
                                 {
                                    // this value already exists
                                    valueExists = true;
                                    break;
                                 }
                              }
                              if (!valueExists)
                              {
                                 existingField.Values.Add(val);
                              }
                           }
                           break;
                     }
                  }
               }
               else
               {
                   Dynamic.Field f = manager.BuildField(tcmItemField, linkLevels, resolveWidthAndHeight);
                  fields.Add(f.Name, f);
               }
            }
            catch (FieldHasNoValueException)
            {
               // fail silently, field is not added to the list
            }
            catch (FieldTypeNotDefinedException)
            {
               // fail silently, field is not added to the list
            }
             }
        }