Exemplo n.º 1
0
        public static string ToQueryItem(DataProperty dataProperty, bool includeAlias)
        {
            string columnName = Utilities.ExtractColumnName(dataProperty.columnName);

              if (dataProperty.columnName.EndsWith(Utilities.USER_ATTRIBUTE_TOKEN))
              {
            string item = string.Format("Attributes[\"Global\", \"{0}\"].Value", columnName);

            if (includeAlias)
            {
              item += " " + dataProperty.propertyName;
            }

            return item;
              }
              else if (!dataProperty.columnName.EndsWith(Utilities.RELATED_ATTRIBUTE_TOKEN))
              {
            string item = columnName;

            if (includeAlias)
            {
              item += " " + dataProperty.propertyName;
            }

            return item;
              }

              return string.Empty;
        }
Exemplo n.º 2
0
 public virtual object GetNextTempId(DataProperty property) {
   var nextValue = property.DataType.GetNextTempValue();
   if (nextValue == null) {
     throw new Exception("Unable to generate a temporary id for this property: " + property.Name);
   }
   TempIds.Add(new UniqueId(property, nextValue));
   return nextValue;
 }
Exemplo n.º 3
0
 public Data(bool HasChildren, string App, string Id, string[] Actions, string Name, string IconOpen, string IconClosed, string Description, string Url, DataProperty[] Properties)
 {
     _hasChildren = HasChildren;
     _app = App;
     _id = Id;
     _actions = Actions;
     _name = Name;
     _iconOpen = IconOpen;
     _iconClosed = IconClosed;
     _description = Description;
     _url = Url;
     _properties = Properties;
 }
 /// <summary>
 /// Binds the selector to the given property. Sets the selection mode based on
 /// whether or not the property is multivalued and the default list item template
 /// unless it has already been set in XAML.
 /// </summary>
 /// <param name="property">The data property to bind the framework element to.</param>
 public override void BindTo(DataProperty property)
 {
     // update selection mode before updating the values
     ListBox lb = element as ListBox;
     if (lb != null && property != null)
     {
         if (!property.IsMultiValued)
             lb.SelectionMode = SelectionMode.Single;
         else if (lb.SelectionMode == SelectionMode.Single)
             lb.SelectionMode = SelectionMode.Extended;
     }
     Selector sel = (Selector)element;
     if (property != null && sel.ItemTemplate == null && sel.ItemTemplateSelector == null)
         sel.ItemTemplate = XamlReader.Parse(defaultTemplate) as DataTemplate;
     base.BindTo(property);
     if (sel.DataContext == null) FixPopupRootMemoryLeak();
 }
Exemplo n.º 5
0
        static int GetPropertySize(DataProperty p)
        {
            switch (p)
            {
            case DataProperty.R8: return(1);

            case DataProperty.G8: return(1);

            case DataProperty.B8: return(1);

            case DataProperty.A8: return(1);

            case DataProperty.R16: return(2);

            case DataProperty.G16: return(2);

            case DataProperty.B16: return(2);

            case DataProperty.A16: return(2);

            case DataProperty.SingleX: return(4);

            case DataProperty.SingleY: return(4);

            case DataProperty.SingleZ: return(4);

            case DataProperty.DoubleX: return(8);

            case DataProperty.DoubleY: return(8);

            case DataProperty.DoubleZ: return(8);

            case DataProperty.Data8: return(1);

            case DataProperty.Data16: return(2);

            case DataProperty.Data32: return(4);

            case DataProperty.Data64: return(8);
            }
            return(0);
        }
Exemplo n.º 6
0
        private OpenApiSchema GeneratePropertySchema(DataProperty serializerMember, ParameterInfo parameterInfo, SchemaRepository schemaRepository)
        {
            var schema = GenerateSchemaForType(serializerMember.MemberType, parameterInfo, schemaRepository);

            if (serializerMember.MemberInfo != null)
            {
                ApplyMemberMetadata(schema, serializerMember.MemberType, serializerMember.MemberInfo);
            }

            if (schema.Reference == null)
            {
                schema.Nullable  = serializerMember.IsNullable && schema.Nullable;
                schema.ReadOnly  = serializerMember.IsReadOnly;
                schema.WriteOnly = serializerMember.IsWriteOnly;

                ApplyFilters(schema, serializerMember.MemberType, schemaRepository, serializerMember.MemberInfo);
            }

            return(schema);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Updates selection in the specified list object for a details open/close event
        /// using the provided key property on the details view object.
        /// </summary>
        /// <param name="list">Data list object to update.</param>
        /// <param name="keyChildProp">The key property on the child details view.</param>
        /// <param name="e">Open/close event of the child details view.</param>
        /// <returns></returns>
        protected virtual bool UpdateListSelection(DataListObject list, DataProperty keyChildProp, ViewEvent e)
        {
            // Find key property in the list with the same name, as the key property in the child details object.
            var keyListProp = list?.Properties?.Where(p => p.IsKey && p.Name == keyChildProp?.Name)?.FirstOrDefault();

            if (keyListProp != null)
            {
                if (e.IsOpened())
                {
                    list.SelectedRows = list.GetData().Where(r => Equals(keyListProp.GetValue(ValueFormat.Internal, r),
                                                                         keyChildProp.InternalValue)).ToList();
                }
                else if (e.IsClosed())
                {
                    list.ClearSelectedRows();
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        public DataProperty Patch(DataProperty request)
        {
            if (true != (request?.Id > 0))
            {
                throw new HttpError(HttpStatusCode.NotFound, "Please specify a valid Id of the DataProperty to patch.");
            }

            request.Select = request.Select ?? new List <string>();

            DataProperty ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    ret = _AssignValues(request, DocConstantPermission.EDIT, ssn);
                });
            }
            return(ret);
        }
Exemplo n.º 9
0
        public RvtProperties(ModelItem mi)
        {
            PropertyCategory pc_Item
                = mi.PropertyCategories.FindCategoryByName(
                      PropertyCategoryNames.Item);

            DataProperty dp
                = pc_Item.Properties.FindPropertyByName(
                      DataPropertyNames.ItemSourceFileName);

            string source_filename = dp.Value.ToDisplayString();

            Debug.Assert(source_filename.EndsWith(".rvt"),
                         "expected Revit source file");

            PropertyCategory pc_Element
                = mi.PropertyCategories
                  .FindCategoryByDisplayName("Element");

            dp = pc_Element.Properties
                 .FindPropertyByDisplayName("Level");

            NamedConstant nc_level = dp.Value.ToNamedConstant();

            Level = nc_level.Name;

            PropertyCategory pc_ElementId
                = mi.PropertyCategories.FindCategoryByName(
                      PropertyCategoryNames.RevitElementId);

            dp = pc_ElementId.Properties.FindPropertyByName(
                DataPropertyNames.RevitElementIdValue);

            VariantData v = dp.Value;

            Debug.Assert(v.IsDisplayString,
                         "expected Revit element id as DisplayString");

            ElementId = int.Parse(
                dp.Value.ToDisplayString());
        }
Exemplo n.º 10
0
        public static DataContentCache BuildCache(Type type)
        {
            DataContentCache dataContentCache = new DataContentCache(type);
            Type             frameworkType    = typeof(FrameworkElement);

            foreach (PropertyInfo propertyInfo in type.GetProperties(PropertyBindingFlags).OrderBy(p => p.GetCustomAttribute <DataProperty>()?.Order))
            {
                DataProperty dataProperty = propertyInfo.GetCustomAttribute <DataProperty>();
                if (dataProperty == null || !frameworkType.IsAssignableFrom(dataProperty.ControlType))
                {
                    continue;
                }
                ConstructorInfo  ctor = dataProperty.ControlType.GetConstructor(new[] { typeof(object[]) });
                FrameworkElement frameworkElement;
                if (ctor == null)
                {
                    frameworkElement = (FrameworkElement)Activator.CreateInstance(dataProperty.ControlType);
                }
                else
                {
                    frameworkElement = (FrameworkElement)Activator.CreateInstance(dataProperty.ControlType, dataProperty.Params);
                }
                if (frameworkElement == null)
                {
                    continue;
                }
                DataCategory dataCategory = propertyInfo.GetCustomAttribute <DataCategory>();
                if (dataCategory != null)
                {
                    dataContentCache.AddElement(new TextBlock {
                        Text = NebulaClient.GetLocString(dataCategory.Category), FontSize = 24
                    });
                }
                DependencyProperty dependencyProperty = null;
                BaseControlHandler.HandleControl(frameworkElement, propertyInfo, dataCategory, dataProperty, ref dependencyProperty);
                HandleControl(frameworkElement, propertyInfo, dataCategory, dataProperty, ref dependencyProperty);
                dataContentCache.AddElement(frameworkElement, dependencyProperty, propertyInfo);
            }

            return(dataContentCache);
        }
Exemplo n.º 11
0
        public IEnumerable <string> Convert <T>(DataProperty configuration, IEnumerable <T> data) where T : class
        {
            if (data == null || !data.Any())
            {
                return(Array.Empty <string>());
            }

            var jArray = new JArray();

            foreach (var dataRecord in data)
            {
                var jObject = ProcessDataRecord(dataRecord, configuration);
                if (jObject != null)
                {
                    jArray.Add(jObject);
                }
            }

            var cultureInfo = configuration.CultureCode.GetCultureInfo();

            if (configuration.PropertySource.IsNullOrEmpty())
            {
                if (configuration.SplitExportResult)
                {
                    return(jArray.Select(item => SerializeObject(item, cultureInfo)).ToList());
                }

                return(new List <string> {
                    SerializeObject(jArray, cultureInfo)
                });
            }

            var wrapperObject = new JObject
            {
                new JProperty(configuration.PropertySource, jArray)
            };

            return(new List <string> {
                SerializeObject(wrapperObject, cultureInfo)
            });
        }
Exemplo n.º 12
0
        public IEnumerable <T> Convert <T>(DataProperty configuration, string data, bool removeDublicates = true) where T : class, IEmpty
        {
            if (data.IsNullOrEmpty())
            {
                return(new List <T>());
            }

            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(data);
            var xmlRoots = xmlDocument.SelectNodes(configuration.PropertySource);

            if (xmlRoots.Count != 1)
            {
                return(new List <T>());
            }

            var dataRecords = ProcessRow <T>(configuration.DataProperties.First(), xmlRoots[0], configuration.CultureCode.GetCultureInfo());

            return(removeDublicates ? RemoveDoublets(configuration.DataProperties.First(), dataRecords) : dataRecords);
        }
Exemplo n.º 13
0
        public IEnumerable <string> Convert <T>(DataProperty configuration, IEnumerable <T> data) where T : class
        {
            var columnHeaderRow = GetColumnHeaderRow(configuration);
            var dataRows        = new List <string[]>();
            var cultureInfo     = configuration.CultureCode.GetCultureInfo();

            if (configuration.HasColumnNamesCSV)
            {
                dataRows.Add(columnHeaderRow);
            }

            if (data != default && data.Any())
            {
                foreach (var dataItem in data)
                {
                    dataRows.AddRange(ProcessDataRecord(dataItem, configuration, columnHeaderRow.Length, cultureInfo, configuration.HasSurroundingQuotationMarksCSV));
                }
            }

            return(new[] { TransformDataRowArraysToDataRowString(dataRows, configuration.SeparatorCSVColumn) });
        }
Exemplo n.º 14
0
        public static XElement ToXml(this DataProperty property)
        {
            var elem = new XElement(
                EventManifestSchema.Namespace + "data",
                new XAttribute("name", property.Name),
                new XAttribute("inType", property.InType.Name.ToPrefixedString()));

            if (property.OutType != null)
            {
                elem.Add(new XAttribute("outType", property.OutType.Name.ToPrefixedString()));
            }
            if (property.Length.IsSpecified)
            {
                elem.Add(new XAttribute("length", property.Length));
            }
            if (property.Count.IsSpecified)
            {
                elem.Add(new XAttribute("count", property.Count));
            }
            return(elem);
        }
Exemplo n.º 15
0
        private List <T> ProcessRow <T>(DataProperty configuration, string[] dataRows)
        {
            var dataRecords = new List <T>();

            var settings = new EdiDataPropertySettings
            {
                DataRows       = dataRows,
                DataProperty   = configuration,
                DataRecordType = typeof(T),
                StartRowIndex  = 0
            };

            var items = ProcessDataProperty(settings, configuration.CultureCode.GetCultureInfo());

            foreach (var item in items)
            {
                dataRecords.Add((T)item);
            }

            return(dataRecords);
        }
Exemplo n.º 16
0
        public async void 数据绑定控件()
        {
            DataProperty <int> hp = new DataProperty <int>();

            Bind(Label, hp, delegate(int value, Text label)
            {
                label.text = value.ToString();
            });


            TimerManager.Schedule(0, 3, 1, delegate(Timer t)
            {
                binder.Clear();
                GameFactory.Destroy(Label.gameObject);
            });


            TimerManager.Schedule(1, 0, 10, delegate(Timer t)
            {
                hp.SetValue(hp.value + 1);
            });
        }
Exemplo n.º 17
0
        private string ProcessDataRecords <T>(IEnumerable <T> dataRecords, DataProperty dataProperty, CultureInfo cultureInfo) where T : class
        {
            var dataRows      = new List <char[]>();
            var maxLineLength = GetMaximumLineLength(dataProperty);
            var maxLineCount  = GetMaxLineCount(dataProperty);

            var dataRecordSettings = new EdiDataRecordSettings
            {
                DataProperty  = dataProperty,
                MaxLineLength = maxLineLength,
                MaxLineCount  = maxLineCount,
                CultureInfo   = cultureInfo
            };

            foreach (var dataRecord in dataRecords)
            {
                dataRecordSettings.DataRecord = dataRecord;
                dataRows.AddRange(ProcessDataRecord(dataRecordSettings));
            }

            return(TransformDataRowArraysToDataRowString(dataRows));
        }
Exemplo n.º 18
0
        private DataProperty BuildDataProperty(Dictionary <string, object> data)
        {
            var    dp = new DataProperty();
            object temp;

            dp.name       = data.TryGetValue("nameOnServer", out temp) ? (string)temp : (string)data["name"];
            dp.dataType   = data.TryGetValue("dataType", out temp) ? (string)temp : (string)data["complexTypeName"];
            dp.isNullable = data.ContainsKey("isNullable") ? (bool)data["isNullable"] : true;

            object validators;

            if (data.TryGetValue("validators", out validators))
            {
                dp.validators = new List <Validator>();
                var validatorData = (List <Dictionary <string, object> >)validators;
                foreach (var vd in validatorData)
                {
                    dp.validators.Add(BuildValidator(vd));
                }
            }
            return(dp);
        }
Exemplo n.º 19
0
        protected IEnumerable <T> RemoveDoublets <T>(DataProperty configuration, IEnumerable <T> dataRecords) where T : class
        {
            if (!(configuration.MappingProperties?.Any() ?? false))
            {
                return(dataRecords);
            }

            var type = typeof(T);
            var resultDataRecords        = new List <T>();
            var propertyInfos            = new List <PropertyInfo>();
            var propertyInfosIEnumerable = type.GetProperties().Where(p => CheckIfIEnumerable(p)).ToList();
            var propertyInfosIClass      = type.GetProperties().Where(p => CheckIfClass(p)).ToList();

            foreach (var mappingProperty in configuration.MappingProperties)
            {
                var propertyInfo = type.GetProperty(mappingProperty);
                if (propertyInfo != null)
                {
                    propertyInfos.Add(propertyInfo);
                }
            }

            foreach (var dataRecord in dataRecords)
            {
                var existingDataRecord = resultDataRecords.SingleOrDefault(d => propertyInfos.All(p => Equals(p.GetValue(d), p.GetValue(dataRecord))));

                if (existingDataRecord == null)
                {
                    resultDataRecords.Add(dataRecord);
                }
                else
                {
                    CompareEnumerableProperties(configuration, propertyInfosIEnumerable, existingDataRecord, dataRecord);
                    CompareClassProperties(configuration, propertyInfosIClass, existingDataRecord, dataRecord);
                }
            }

            return(resultDataRecords);
        }
        private DataProperty CreateDataProperty(
            string name,
            DataType?dataType,
            bool isPartOfKey,
            bool isNullable,
            bool isVersion,
            bool hasDefaultValue,
            object defaultValue,
            StructuralType structuralType,
            int?typeLength,
            object custom)
        {
            var dataProperty = new DataProperty
            {
                NameOnServer    = name,
                DataType        = dataType,
                IsPartOfKey     = isPartOfKey,
                IsNullable      = isNullable,
                MaxLength       = typeLength,
                Custom          = custom,
                ConcurrencyMode = isVersion ? ConcurrencyMode.Fixed : (ConcurrencyMode?)null
            };

            if (hasDefaultValue)
            {
                dataProperty.DefaultValue = defaultValue;
            }

            var validators = _propertyValidatorsProvider.GetValidators(dataProperty, structuralType.Type).ToList();

            if (validators.Count > 0)
            {
                dataProperty.Validators = validators;
            }

            _dataPropertyCreatedCallback?.Invoke(dataProperty, structuralType);

            return(dataProperty);
        }
Exemplo n.º 21
0
        private List <T> ProcessRow <T>(DataProperty configuration, JToken dataObject)
        {
            JArray jToken;

            if (dataObject is JProperty && !dataObject.Path.IsNullOrEmpty() && dataObject.Path.Equals(configuration.PropertySource))
            {
                jToken = dataObject.Children().First() as JArray;
            }
            else if (dataObject is JArray && configuration.PropertySource.IsNullOrEmpty())
            {
                jToken = dataObject as JArray;
            }
            else if (dataObject is JObject)
            {
                jToken = new JArray(dataObject);
            }
            else
            {
                return(new List <T>());
            }

            var dataRecords = new List <T>();
            var settings    = new JSONSettings
            {
                DataProperty = configuration,
                RawDataNode  = jToken,
                DataType     = typeof(T),
                CultureInfo  = configuration.CultureCode.GetCultureInfo()
            };
            var items = ProcessDataProperty(settings);

            foreach (var item in items)
            {
                dataRecords.Add((T)item);
            }

            return(dataRecords);
        }
Exemplo n.º 22
0
        private static void RecurseSearchForAllNotHiddenGeometryItemsWithIds
            (IEnumerable <ModelItem> items, Dictionary <string, ModelItem> itemsLookup)
        {
            foreach (ModelItem item in items)
            {
                if (!item.IsHidden)
                {
                    if (item.HasGeometry)
                    {
                        DataProperty idProp = item.PropertyCategories
                                              .FindPropertyByDisplayName(S1NF0_DATA_TAB_DISPLAY_NAME,
                                                                         ID_PROP_DISPLAY_NAME);
                        if (idProp != null)
                        {
                            string key = Utils.GetDisplayValue(idProp.Value);
                            itemsLookup[key] = item;
                        }
                    }

                    RecurseSearchForAllNotHiddenGeometryItemsWithIds(item.Children, itemsLookup);
                }
            }
        }
Exemplo n.º 23
0
        private static void UpdateTest()
        {
            IDbProvider provider = new SqlDataProvider();

            provider.ConnectionString = $@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={Settings.Instance.Database};Data Source={Settings.Instance.ServerName}";

            var repository = new Repository <Customer>(provider);

            //var name = new StringVariable("FirstName");
            //var value = new StringConstant("Tony");
            //var condition = new ComparativeOperator<string>(ComparativeOperatorType.Equal, name, value);
            //repository.Update(condition, property);

            var property = new DataProperty
            {
                Name  = "FirstName",
                Value = "Diego"
            };

            DataProperty[] properties = { property };

            repository.Update(properties, "23");
        }
Exemplo n.º 24
0
        /// <summary>
        /// Overrides the base method if the value passed is a data property
        /// to return the value of that property in the specified format.
        /// </summary>
        /// <param name="value">A single value to convert to the given format.</param>
        /// <param name="format">The value format to convert the value to.</param>
        /// <returns>The value converted to the given format.</returns>
        protected override object ConvertValue(object value, ValueFormat format)
        {
            DataProperty p = value as DataProperty;

            if (p == null)
            {
                return(value);
            }

            if (format == ValueFormat.DisplayString)
            {
                return(p.DisplayStringValue);
            }
            if (format == ValueFormat.EditString)
            {
                return(p.EditStringValue);
            }
            if (format == ValueFormat.Transport)
            {
                return(p.TransportValue);
            }

            return(p);
        }
Exemplo n.º 25
0
        public IEnumerable <string> Convert <T>(DataProperty configuration, IEnumerable <T> data) where T : class
        {
            if (data == null || !data.Any())
            {
                return(Array.Empty <string>());
            }

            var dataRows    = new List <string>();
            var cultureInfo = configuration.CultureCode.GetCultureInfo();

            if (configuration.CanRepeatEDI)
            {
                dataRows.Add(ProcessDataRecords <T>(data, configuration, cultureInfo));
            }
            else
            {
                foreach (var dataItem in data)
                {
                    dataRows.Add(ProcessDataRecord <T>(dataItem, configuration, cultureInfo));
                }
            }

            return(dataRows);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 指定したデータに新規ファイルを追加する
        /// </summary>
        private DataProperty AddFile(Data data, string fileName, string storedPath, string key)
        {
            DataFile file = new DataFile()
            {
                FileName   = fileName,
                StoredPath = storedPath
            };
            DataProperty property = new DataProperty()
            {
                Data     = data,
                DataFile = file,
                Key      = key
            };

            AddModel <DataFile>(file);
            AddModel <DataProperty>(property);

            if (data.DataProperties != null)
            {
                data.DataProperties.Add(property);
            }

            return(property);
        }
Exemplo n.º 27
0
        public IEnumerable <T> Convert <T>(DataProperty configuration, string data, bool removeDublicates = true) where T : class, IEmpty
        {
            if (data.IsNullOrEmpty())
            {
                return(new List <T>());
            }

            var jsonData = JsonConvert.DeserializeObject(data);

            List <T> dataRecords;

            if (jsonData is JObject)
            {
                var jsonObject = jsonData as JObject;
                if (jsonObject.First is JProperty && jsonObject.First.Children().FirstOrDefault() is JArray)
                {
                    dataRecords = ProcessRow <T>(configuration, jsonObject.First);
                }
                else
                {
                    // process single data object
                    dataRecords = ProcessRow <T>(configuration, jsonObject);
                }
            }
            else if (jsonData is JArray)
            {
                var jsonObject = jsonData as JArray;
                dataRecords = ProcessRow <T>(configuration, jsonObject);
            }
            else
            {
                dataRecords = new List <T>();
            }

            return(removeDublicates ? RemoveDoublets(configuration, dataRecords) : dataRecords);
        }
Exemplo n.º 28
0
        private void GetDataDictionary(String scope, String app, bool usesCache)
        {
            try
            {
                string dictKey = string.Format("Dictionary.{0}.{1}", scope, app);

                if (usesCache)
                {
                    dataDict = (DataDictionary)Session[dictKey];
                }
                else
                {
                    dataDict = null;
                }

                if (dataDict == null)
                {
                    WebHttpClient client = CreateWebClient(_dataServiceUri);
                    dataDict = client.Get <DataDictionary>("/" + app + "/" + scope + "/dictionary?format=xml", true);

                    // sort data objects & properties
                    if (dataDict != null && dataDict.dataObjects.Count > 0)
                    {
                        dataDict.dataObjects.Sort(new DataObjectComparer());

                        foreach (DataObject dataObject in dataDict.dataObjects)
                        {
                            dataObject.dataProperties.Sort(new DataPropertyComparer());

                            // Adding Key elements to TOP of the List.
                            List <String> keyPropertyNames = new List <String>();
                            foreach (KeyProperty keyProperty in dataObject.keyProperties)
                            {
                                keyPropertyNames.Add(keyProperty.keyPropertyName);
                            }
                            var value = "";
                            for (int i = 0; i < keyPropertyNames.Count; i++)
                            {
                                value = keyPropertyNames[i];
                                // removing the property name from the list and adding at TOP
                                List <DataProperty> DataProperties = dataObject.dataProperties;
                                DataProperty        prop           = null;

                                for (int j = 0; j < DataProperties.Count; j++)
                                {
                                    if (DataProperties[j].propertyName == value)
                                    {
                                        prop = DataProperties[j];
                                        DataProperties.RemoveAt(j);
                                        break;
                                    }
                                }

                                if (prop != null)
                                {
                                    DataProperties.Insert(0, prop);
                                }
                            }
                        }
                    }

                    if (usesCache)
                    {
                        Session[dictKey] = dataDict;
                    }
                }

                if (dataDict == null || dataDict.dataObjects.Count == 0)
                {
                    response = response + "Data dictionary of [" + app + "] is empty.";
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error getting dictionary." + ex);
                //response = response + " " + ex.Message.ToString();
                CustomErrorLog objCustomErrorLog = new CustomErrorLog();
                _CustomError = objCustomErrorLog.customErrorLogger(ErrorMessages.errUIGridPages, ex, _logger);
                response     = response + " " + throwJsonResponse(_CustomError);
            }
        }
Exemplo n.º 29
0
        private Response Refresh(XDocument configDoc, string tableName)
        {
            Response response = new Response();

              try
              {
            _dataDictionary = new library.DataDictionary();

            XElement config = configDoc.Element("configuration");
            SQLBuilder sqlBuilder;

            //
            // Parse project assignments
            //
            Dictionary<string, string> projectAssignments = new Dictionary<string, string>();
            IEnumerable<XElement> projectAssignmentElts = config.Element("assignments").Elements("assignment");

            if (projectAssignmentElts != null && projectAssignmentElts.Count() > 0)
            {
              foreach (XElement assignment in projectAssignmentElts)
              {
            string name = assignment.Attribute("name").Value;
            string value = assignment.Attribute("value").Value;

            if (name.StartsWith("@") && value.Length > 0)
            {
              projectAssignments[name] = value;
            }
              }
            }

            //
            // Parse project text replacements
            //
            Dictionary<string, string> projectReplacements = new Dictionary<string, string>();
            IEnumerable<XElement> projectReplacementElts = config.Element("replacements").Elements("replacement");

            if (projectReplacementElts != null && projectReplacementElts.Count() > 0)
            {
              foreach (XElement replacement in projectReplacementElts)
              {
            string placeHolder = replacement.Attribute("placeHolder").Value;
            string name = replacement.Attribute("name").Value;
            string value = replacement.Attribute("value").Value;

            if (placeHolder == string.Empty || name == string.Empty || value == string.Empty)
            {
              continue;
            }

            projectReplacements[placeHolder[0] + name + placeHolder[1]] = value;
              }
            }

            //
            // Get query elements
            //
            IEnumerable<XElement> queryElts = config.Elements("query");

            DBType siteDbType = Utility.GetDBType(_siteConnStr);
            DataTable siteSchemaResult = DBManager.Instance.ExecuteQuery(_siteConnStr, Constants.ORACLE_GET_CURRENT_SCHEMA);
            string siteSchema = siteSchemaResult.Rows[0][0].ToString();

            //
            // Process !SiteData query
            //
            XElement siteQueryElt = (from query in queryElts
                                 where query.Attribute("name").Value == Constants.SITE_DATA_QUERY
                                 select query).First();

            Dictionary<string, string> siteSchemaMap = new Dictionary<string, string>();
            siteSchemaMap["SITE"] = siteSchema;

            sqlBuilder = new SQLBuilder(siteDbType, siteQueryElt, siteSchemaMap, projectAssignments, projectReplacements);
            string siteSelectQuery = sqlBuilder.Build(SQLCommand.SELECT);
            DataTable siteInfo = DBManager.Instance.ExecuteQuery(_siteConnStr, siteSelectQuery);

            //
            // Get actual schemas from !SiteData query
            //
            Dictionary<string, string> schemaMap = new Dictionary<string, string>();

            if (siteInfo != null && siteInfo.Rows.Count > 0)
            {
              foreach (DataRow row in siteInfo.Rows)
              {
            schemaMap[row["SP_SCHEMA_TYPE"].ToString()] = row["USERNAME"].ToString();
              }
            }

            //
            // Process other queries
            //
            if (string.IsNullOrEmpty(tableName))
            {
              queryElts = from query in queryElts
                      where query.Attribute("name").Value != Constants.TEMPLATE_QUERY && query.Attribute("name").Value != Constants.SITE_DATA_QUERY
                      select query;
            }
            else
            {
              queryElts = from query in queryElts
                      where query.Attribute("name").Value != Constants.TEMPLATE_QUERY && query.Attribute("name").Value != Constants.SITE_DATA_QUERY && query.Attribute("destination").Value.ToUpper() == tableName.ToUpper()
                      select query;
            }

            DBType stagingDbType = Utility.GetDBType(_stagingConnStr);

            //   NOTE - although it is possible to make use of an INTO clause to create a selection query that will
            //   also automatically create the destination table, this has limitations, the most serious of which is
            //   it is not safe to assume that the Source DB and Staging DB have the same security requirements. Instead,
            //   we will always assume that security is separate for these two databases and that the connection strings for the
            //   Source and Staging connections provide this information for each individual location. We also cannot assume that
            //   the specified credentials have the power to create a Linked Server connection or that both SQL Server instances
            //   allow ad hoc (OpenDataSource) queries. Instead, the provided credentials are used to copy the data to the
            //   local machine and then bulk copied out to the staging server, bypassing the need for a more sophisticated security
            //   check/edit)

            DBType plantDbType = Utility.GetDBType(_plantSchemaConnStr);

            if (plantDbType == DBType.ORACLE)
            {
              string plantDictConnStr = _settings[Constants.SPPID_PLANT_DICTIONARY];
              if (Utility.IsBase64Encoded(plantDictConnStr))
              {
            plantDictConnStr = EncryptionUtility.Decrypt(plantDictConnStr);
              }

              string pidSchemaConnStr = _settings[Constants.SPPID_PID_SCHEMA];
              if (Utility.IsBase64Encoded(pidSchemaConnStr))
              {
            pidSchemaConnStr = EncryptionUtility.Decrypt(pidSchemaConnStr);
              }

              string pidDictConnStr = _settings[Constants.SPPID_PID_DICTIONARY];
              if (Utility.IsBase64Encoded(pidDictConnStr))
              {
            pidDictConnStr = EncryptionUtility.Decrypt(pidDictConnStr);
              }

              _workingSet = new WorkingSet(_plantSchemaConnStr, plantDictConnStr, pidSchemaConnStr, pidDictConnStr);
            }
            else if (plantDbType == DBType.SQLServer)
            {
              _workingSet = new WorkingSet(_plantSchemaConnStr);
            }
            else
            {
              throw new Exception("SPPID DB type not supported.");
            }

            _workingSet.GrantPrivilege("SELECT");

            foreach (XElement queryElt in queryElts)
            {
              sqlBuilder = new SQLBuilder(stagingDbType, queryElt, schemaMap, projectAssignments, projectReplacements, true);

              response.StatusList.Add(new Status()
              {
            Messages = new Messages()
            {
              "Query [" + queryElt.Attribute("name").Value + "] processed."
            }
              });

              //
              // Delete existing staging table
              //
              string stagingTableName = queryElt.Attribute("destination").Value;
              string deleteQuery = string.Format(Constants.SQLSERVER_DELETE_TEMPLATE, stagingTableName);
              DBManager.Instance.ExecuteNonQuery(_stagingConnStr, deleteQuery);

              //
              // Create new staging table
              //
              string createQuery = sqlBuilder.Build(SQLCommand.CREATE);
              DBManager.Instance.ExecuteNonQuery(_stagingConnStr, createQuery);

              response.StatusList.Add(new Status()
              {
            Messages = new Messages()
            {
              "Staging table [" + stagingTableName + "] created."
            }
              });

              //
              // Fetch data
              //
              string selectQuery = sqlBuilder.Build(SQLCommand.SELECT);
              DataTable result = DBManager.Instance.ExecuteQuery(_plantSchemaConnStr, selectQuery);

              response.StatusList.Add(new Status()
              {
            Messages = new Messages()
            {
              "New data fetched."
            }
              });

              //
              // Bulk copy data to staging table
              //
              SqlBulkCopy bulkCopy = new SqlBulkCopy(_stagingConnStr);
              bulkCopy.DestinationTableName = stagingTableName;
              bulkCopy.WriteToServer(result);

              response.StatusList.Add(new Status()
              {
            Messages = new Messages()
            {
              "Data copied to staging table."
            }
              });

              //
              // Add to data dictionary
              //
              DataObject objDef = new DataObject()
              {
            tableName = stagingTableName,
            objectNamespace = "SPPID",
            objectName = stagingTableName
              };

              foreach (var pair in sqlBuilder.Keys)
              {
            objDef.keyProperties.Add(new KeyProperty()
            {
              keyPropertyName = pair.Key
            });
              }

              foreach (DBField field in sqlBuilder.Fields)
              {
            DataProperty dataProperty = new DataProperty()
            {
              propertyName = field.Name,
              columnName = field.Name,
              dataType = Utility.ResolveDataType(field.DataType),
              isNullable = field.Nullable,
            };

            if (sqlBuilder.Keys.ContainsKey(field.Name))
            {
              dataProperty.keyType = (sqlBuilder.Keys[field.Name] == KeyType.AUTO)
                ? library.KeyType.unassigned : library.KeyType.assigned;
            }

            objDef.dataProperties.Add(dataProperty);
              }

              _dataDictionary.dataObjects.Add(objDef);
            }

            _workingSet.RevokePrivilege("SELECT");
              }
              catch (Exception ex)
              {
            string error = "Error refreshing [" + tableName + "]: " + ex.Message;

            response.Level = StatusLevel.Error;
            response.Messages = new Messages() { error };
            _logger.Error(error);
              }

              return response;
        }
Exemplo n.º 30
0
        private DataObject CreateDataObject(BusinessObject businessObject)
        {
            string propertyName = string.Empty;
              string keyPropertyName = string.Empty;
              string relatedPropertyName = string.Empty;
              string relatedObjectName = string.Empty;
              string relationshipName = string.Empty;
              DataObject dataObject = new DataObject();
              string objectName = businessObject.objectName;
              dataObject.objectName = objectName;
              dataObject.objectNamespace = projectNameSpace;
              dataObject.tableName = objectName;
              dataObject.keyProperties = new List<KeyProperty>();
              dataObject.dataProperties = new List<DataProperty>();
              dataObject.dataRelationships = new List<DataRelationship>();

              if (businessObject.dataFilter != null)
            dataObject.dataFilter = businessObject.dataFilter;

              foreach (BusinessKeyProperty businessKeyProerpty in businessObject.businessKeyProperties)
              {
            KeyProperty keyProperty = new KeyProperty();
            DataProperty dataProperty = new DataProperty();
            keyPropertyName = businessKeyProerpty.keyPropertyName;;
            keyProperty.keyPropertyName = keyPropertyName;
            dataProperty.propertyName = keyPropertyName;
            dataProperty.dataType = DataType.String;
            dataProperty.columnName = keyPropertyName;
            dataProperty.isNullable = false;
            dataProperty.keyType = KeyType.assigned;
            dataObject.keyProperties.Add(keyProperty);
            dataObject.dataProperties.Add(dataProperty);
              }

              foreach (BusinessInterface businessInterface in businessObject.businessInterfaces)
              {
            InterfaceInformation interfaceInfo = GetInterfaceInformation(businessInterface.interfaceName);

            foreach (BusinessProperty businessProperty in businessInterface.businessProperties)
            {
              propertyName = businessProperty.propertyName;

              if (interfaceInfo != null)
              {
            if (HasProperty(interfaceInfo, propertyName))
            {
              DataProperty dataProperty = new DataProperty();

              if (!String.IsNullOrEmpty(businessProperty.dbColumn))
                dataProperty.columnName = businessProperty.dbColumn;
              else
                dataProperty.columnName = propertyName;
              dataProperty.propertyName = propertyName;

              dataProperty.dataType = GetDatatype(businessProperty.dataType);
              dataProperty.isNullable = businessProperty.isNullable;
              dataProperty.isReadOnly = businessObject.isReadOnly;

              if (!String.IsNullOrEmpty(businessProperty.description) != null)
                dataProperty.description = businessObject.description;

              dataObject.dataProperties.Add(dataProperty);
            }
            else
            {
              throw new Exception("Property [" + propertyName + "] not found.");
            }
              }
              else
            throw new Exception("Interface [" + businessInterface.interfaceName + "] not found.");
            }
              }

              foreach (BusinessRelationship businessRelationship in businessObject.businessRelationships)
              {
            DataRelationship dataRelationship = new DataRelationship();
            relationshipName = businessRelationship.relationshipName;
            relatedObjectName = businessRelationship.relatedObjectName;

            if (IsRelated(relationshipName, relatedObjectName, objectName))
            {
              dataRelationship.relatedObjectName = businessRelationship.relatedObjectName;
              dataRelationship.relationshipName = businessRelationship.relationshipName;
              dataRelationship.propertyMaps = new List<PropertyMap>();

              if (businessRelationship.businessRelatedInterfaces != null)
              {
            foreach (BusinessInterface businessInterface in businessRelationship.businessRelatedInterfaces)
            {
              foreach (BusinessProperty businessRelationProperty in businessInterface.businessProperties)
              {
                InterfaceInformation interfaceInfo = GetInterfaceInformation(businessInterface.interfaceName);
                relatedPropertyName = businessRelationProperty.propertyName;

                if (interfaceInfo != null)
                {
                  if (HasProperty(interfaceInfo, relatedPropertyName))
                  {
                    DataProperty dataProperty = new DataProperty();
                    PropertyMap propertyMap = new PropertyMap();
                    propertyMap.relatedPropertyName = relatedPropertyName;
                    dataProperty.propertyName = dataRelationship.relatedObjectName + "_" + relatedPropertyName;
                    dataProperty.dataType = GetDatatype(businessRelationProperty.dataType);

                    if (!String.IsNullOrEmpty(businessRelationProperty.dbColumn))
                      dataProperty.columnName = businessRelationProperty.dbColumn;
                    else
                      dataProperty.columnName = relatedPropertyName;

                    dataRelationship.propertyMaps.Add(propertyMap);
                    dataObject.dataProperties.Add(dataProperty);
                  }
                  else
                  {
                    throw new Exception("Property [" + relatedPropertyName + "] not found.");
                  }
                }
                else
                  throw new Exception("Interface [" + businessInterface.interfaceName + "] not found.");
              }
            }
            dataObject.dataRelationships.Add(dataRelationship);
              }
            }
              }
              return dataObject;
        }
Exemplo n.º 31
0
        private static DataHeader ReadDataHeader(StreamReader reader)
        {
            DataHeader data      = new DataHeader();
            int        readCount = 0;

            // Magic number line ("ply")
            string line = reader.ReadLine();

            readCount += line.Length + 1;
            if (line != "ply")
            {
                throw new ArgumentException("Magic number ('ply') mismatch.");
            }

            // Data format: check if it's binary/little endian.
            line        = reader.ReadLine();
            readCount  += line.Length + 1;
            data.binary = line == "format binary_little_endian 1.0";

            // Read header contents.
            for (bool skip = false; ;)
            {
                // Read a line and split it with white space.
                line       = reader.ReadLine();
                readCount += line.Length + 1;
                if (line == "end_header")
                {
                    break;
                }
                string[] col = line.Split();

                // Element declaration (unskippable)
                if (col[0] == "element")
                {
                    if (col[1] == "vertex")
                    {
                        data.vertexCount = Convert.ToInt32(col[2]);
                        skip             = false;
                    }
                    else
                    {
                        // Don't read elements other than vertices.
                        skip = true;
                    }
                }

                if (skip)
                {
                    continue;
                }

                // Property declaration line
                if (col[0] == "property")
                {
                    DataProperty prop = DataProperty.Invalid;

                    // Parse the property name entry.
                    switch (col[2])
                    {
                    case "red": prop = DataProperty.R8; break;

                    case "green": prop = DataProperty.G8; break;

                    case "blue": prop = DataProperty.B8; break;

                    case "alpha": prop = DataProperty.A8; break;

                    case "x": prop = DataProperty.SingleX; break;

                    case "y": prop = DataProperty.SingleY; break;

                    case "z": prop = DataProperty.SingleZ; break;
                    }

                    switch (col[1])
                    {
                    // Check the property type.
                    case "char":
                    case "uchar":
                    case "int8":
                    case "uint8":
                    {
                        if (prop == DataProperty.Invalid)
                        {
                            prop = DataProperty.Data8;
                        }
                        else if (GetPropertySize(prop) != 1)
                        {
                            throw new ArgumentException("Invalid property type ('" + line + "').");
                        }
                        break;
                    }

                    case "short":
                    case "ushort":
                    case "int16":
                    case "uint16":
                    {
                        switch (prop)
                        {
                        case DataProperty.Invalid: prop = DataProperty.Data16; break;

                        case DataProperty.R8: prop = DataProperty.R16; break;

                        case DataProperty.G8: prop = DataProperty.G16; break;

                        case DataProperty.B8: prop = DataProperty.B16; break;

                        case DataProperty.A8: prop = DataProperty.A16; break;
                        }
                        if (GetPropertySize(prop) != 2)
                        {
                            throw new ArgumentException("Invalid property type ('" + line + "').");
                        }
                        break;
                    }

                    case "int":
                    case "uint":
                    case "float":
                    case "int32":
                    case "uint32":
                    case "float32":
                    {
                        if (prop == DataProperty.Invalid)
                        {
                            prop = DataProperty.Data32;
                        }
                        else if (GetPropertySize(prop) != 4)
                        {
                            throw new ArgumentException("Invalid property type ('" + line + "').");
                        }
                        break;
                    }

                    case "int64":
                    case "uint64":
                    case "double":
                    case "float64":
                    {
                        switch (prop)
                        {
                        case DataProperty.Invalid: prop = DataProperty.Data64; break;

                        case DataProperty.SingleX: prop = DataProperty.DoubleX; break;

                        case DataProperty.SingleY: prop = DataProperty.DoubleY; break;

                        case DataProperty.SingleZ: prop = DataProperty.DoubleZ; break;
                        }
                        if (GetPropertySize(prop) != 8)
                        {
                            throw new ArgumentException("Invalid property type ('" + line + "').");
                        }
                        break;
                    }

                    default:
                        throw new ArgumentException("Unsupported property type ('" + line + "').");
                    }

                    data.properties.Add(prop);
                }
            }

            // Rewind the stream back to the exact position of the reader.
            reader.BaseStream.Position = readCount;

            return(data);
        }
Exemplo n.º 32
0
 set => this.SetValue(DataProperty, value);
    private DataProperty BuildDataProperty(Dictionary<string, object> data) {
      var dp = new DataProperty();
      object temp;
      dp.name = data.TryGetValue("nameOnServer", out temp) ? (string) temp : (string) data["name"];
      dp.dataType = data.TryGetValue("dataType", out temp) ? (string) temp : (string) data["complexTypeName"];
      dp.isNullable = data.ContainsKey("isNullable") ? (bool) data["isNullable"] : true;

      object validators;
      if (data.TryGetValue("validators", out validators)) {
        dp.validators = new List<Validator>();
        var validatorData = (List<Dictionary<string, string>>)validators;
        foreach (var vd in validatorData) {
          dp.validators.Add(BuildValidator(vd));
        }
      }
      return dp;
    }
        private OpenApiSchema GenerateSchemaForMember(
            Type modelType,
            SchemaRepository schemaRepository,
            MemberInfo memberInfo,
            ParameterInfo parameterInfo,
            DataProperty dataProperty = null)
        {
            var dataContract = GetDataContractFor(modelType);

            var schema = _generatorOptions.UseOneOfForPolymorphism && IsBaseTypeWithKnownTypesDefined(dataContract, parameterInfo, out var knownTypesDataContracts)
                ? GeneratePolymorphicSchema(dataContract, schemaRepository, knownTypesDataContracts, parameterInfo)
                : GenerateConcreteSchema(dataContract, schemaRepository, parameterInfo);

            if (_generatorOptions.UseAllOfToExtendReferenceSchemas && schema.Reference != null)
            {
                schema.AllOf = new[] { new OpenApiSchema {
                                           Reference = schema.Reference
                                       } };
                schema.Reference = null;
            }

            if (schema.Reference == null)
            {
                var customAttributes = memberInfo.GetInlineAndMetadataAttributes();

                // Nullable, ReadOnly & WriteOnly are only relevant for Schema "properties" (i.e. where dataProperty is non-null)
                if (dataProperty != null)
                {
                    schema.Nullable = _generatorOptions.SupportNonNullableReferenceTypes
                        ? dataProperty.IsNullable && !customAttributes.OfType <RequiredAttribute>().Any() && !memberInfo.IsNonNullableReferenceType()
                        : dataProperty.IsNullable && !customAttributes.OfType <RequiredAttribute>().Any();

                    schema.ReadOnly  = dataProperty.IsReadOnly;
                    schema.WriteOnly = dataProperty.IsWriteOnly;
                }

                var defaultValueAttribute = customAttributes.OfType <DefaultValueAttribute>().FirstOrDefault();
                if (defaultValueAttribute != null)
                {
                    var defaultAsJson = dataContract.JsonConverter(defaultValueAttribute.Value);
                    schema.Default = OpenApiAnyFactory.CreateFromJson(defaultAsJson);
                }

                var obsoleteAttribute = customAttributes.OfType <ObsoleteAttribute>().FirstOrDefault();
                if (obsoleteAttribute != null)
                {
                    schema.Deprecated = true;
                }

                // NullableAttribute behaves diffrently for Dictionaries
                if (modelType.IsGenericType && modelType.GetGenericTypeDefinition() == typeof(Dictionary <,>))
                {
                    schema.AdditionalProperties.Nullable = !memberInfo.IsDictionaryValueNonNullable();
                }

                schema.ApplyValidationAttributes(customAttributes);

                ApplyFilters(schema, modelType, schemaRepository, memberInfo: memberInfo);
            }

            return(schema);
        }
Exemplo n.º 35
0
    internal static VCard CreateVCard()
    {
        var sortAs = new string[] { "Entenhausen", "Elmstreet" };

        var tel1 = new TextProperty("123");

        tel1.Parameters.TelephoneType = default(TelTypes);
        tel1.Parameters.TelephoneType = TelTypes.Voice | TelTypes.Cell | TelTypes.Text | TelTypes.Msg;

        tel1.Parameters.Preference    = -50;
        tel1.Parameters.Preference    = 500;
        tel1.Parameters.Preference    = 1;
        tel1.Parameters.PropertyClass = default(PropertyClassTypes);
        tel1.Parameters.PropertyClass = PropertyClassTypes.Home | PropertyClassTypes.Work;


        var hobby1 = new TextProperty("Swimming");

        hobby1.Parameters.InterestLevel = InterestLevel.Medium;

        var expertise1 = new TextProperty("C#");

        expertise1.Parameters.ExpertiseLevel = ExpertiseLevel.Average;

        var adr1 = new AddressProperty("Elmstraße 13", "Entenhausen", "01234");

        adr1.Parameters.Label           = "  ";
        adr1.Parameters.Label           = "Elmstreet 13; bei Müller" + Environment.NewLine + "01234 Entenhausen";
        adr1.Parameters.GeoPosition     = new Models.GeoCoordinate(12.98, 7.86);
        adr1.Parameters.TimeZone        = new Models.TimeZoneID(TimeZoneInfo.Local.Id);
        adr1.Parameters.AltID           = "Address";
        adr1.Parameters.Calendar        = "GREGORIAN";
        adr1.Parameters.ContentLocation = VCdContentLocation.Inline;
        adr1.Parameters.Index           = 0;
        adr1.Parameters.Language        = "de";
        adr1.Parameters.SortAs          = sortAs;
        var pidMap = new PropertyIDMapping(5, new Uri("http://folkerkinzel.de"));

        adr1.Parameters.PropertyIDs = new PropertyID[] { new PropertyID(3, pidMap), new PropertyID(2) };
        adr1.Parameters.AddressType = AddressTypes.Dom | AddressTypes.Intl | AddressTypes.Parcel | AddressTypes.Postal;

        var logo1 = new DataProperty(new Uri("https://folker-kinzel.de/logo.jpg"));

        logo1.Parameters.MediaType = "image/jpeg";

        var photo1 = new DataProperty(new Uri("https://folker-kinzel.de/photo.png"));

        logo1.Parameters.MediaType = "image/png";

        var sound1 = new DataProperty(new Uri("https://folker-kinzel.de/audio.mp3"));

        logo1.Parameters.MediaType = "audio/mpeg";

        var key1 = new DataProperty(new Uri("https://folker-kinzel.de/pgp"));

        logo1.Parameters.MediaType = "application/pgp-keys";


        var email1 = new TextProperty("*****@*****.**");

        email1.Parameters.EmailType = "  ";
        email1.Parameters.EmailType = EmailType.SMTP;

        var name1 = new NameProperty("Künzel", "Folker");

        name1.Parameters.SortAs = new string[] { "Kinzel", "Folker" };

        var name2 = new NameProperty("Кинцэл", "Фолкер");

        name2.Parameters.SortAs   = new string[] { "Kinzel", "Folker" };
        name2.Parameters.Language = "ru-RU";
        name2.Parameters.AltID    = "  ";

        var names = new NameProperty[] { name1, name2 };


        var impp1 = new TextProperty("aim:uri.com");

        impp1.Parameters.InstantMessengerType = ImppTypes.Personal;

        var impp2 = new TextProperty("gg:uri.com");

        impp1.Parameters.InstantMessengerType = ImppTypes.Business;

        var impp3 = new TextProperty("gtalk:uri.com");

        impp1.Parameters.InstantMessengerType = ImppTypes.Mobile;

        var impp4  = new TextProperty("com.google.hangouts:uri.com");
        var impp5  = new TextProperty("icq:uri.com");
        var impp6  = new TextProperty("icq:uri.com");
        var impp7  = new TextProperty("xmpp:uri.com");
        var impp8  = new TextProperty("msnim:uri.com");
        var impp9  = new TextProperty("sip:uri.com");
        var impp10 = new TextProperty("skype:uri.com");
        var impp11 = new TextProperty("twitter:uri.com");
        var impp12 = new TextProperty("ymsgr:uri.com");

        var rel1 = new RelationTextProperty("Agent", RelationTypes.Agent);
        var rel2 = new RelationTextProperty("Spouse");

        rel2.Parameters.RelationType = default(RelationTypes);
        rel2.Parameters.RelationType = RelationTypes.Spouse | RelationTypes.CoResident;


        var nonStandard1 = new NonStandardProperty("X-NON-STANDARD", "The value");

        nonStandard1.Parameters.NonStandardParameters
            = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("X-NONSTD", "para-value") };

        var nonStandard2 = new NonStandardProperty("X-WAKEUP", "07:00:00");

        nonStandard2.Parameters.DataType = VCdDataType.Time;

        var nonStandard = new NonStandardProperty[] { nonStandard1, nonStandard2 };

        var xName = XName.Get("{TheNs}TheLocal");
        var xEl   = new XElement(xName, "The content");
        var xml1  = new XmlProperty(xEl);

        var bday = new DateTimeOffsetProperty(new DateTime(1977, 11, 11));

        bday.Parameters.Calendar = "  ";

        var source = new TextProperty("http://neu.de/");

        source.Parameters.Context = " ";
        source.Parameters.Context = "VCARD";

        return(new VCard
        {
            NameViews = names,
            PhoneNumbers = tel1,
            Hobbies = hobby1,
            Interests = hobby1,
            Expertises = expertise1,
            BirthDayViews = bday,
            AnniversaryViews = new DateTimeOffsetProperty(new DateTime(2001, 9, 11)),
            Logos = logo1,
            Photos = photo1,
            Sounds = sound1,
            Keys = key1,
            DeathDateViews = new DateTimeTextProperty("Later"),
            DeathPlaceViews = new TextProperty("Somewhere"),
            BirthPlaceViews = new TextProperty("Dessau"),
            ProdID = new TextProperty("Testcode"),
            Addresses = adr1,
            CalendarAddresses = new TextProperty("Calender address"),
            CalendarUserAddresses = new TextProperty("Calendar user address"),
            FreeOrBusyUrls = new TextProperty("Free Busy"),
            Sources = source,
            TimeZones = new TimeZoneProperty(new TimeZoneID(TimeZoneInfo.Local.Id)),
            DisplayNames = new TextProperty("Folker"),
            OrgDirectories = new TextProperty("OrgDirectory"),
            Profile = new ProfileProperty("Group"),
            Categories = new StringCollectionProperty(new string[] { "Person", "Data" }),
            TimeStamp = new TimeStampProperty(),
            EmailAddresses = email1,
            Roles = new TextProperty("Rechte Hand"),
            Titles = new TextProperty("Sündenbock"),
            UniqueIdentifier = new UuidProperty(),
            URLs = new TextProperty("www.folker.com"),
            DirectoryName = new TextProperty("Webseite"),
            Access = new AccessProperty(VCdAccess.Confidential),
            GenderViews = new GenderProperty(VCdSex.NonOrNotApplicable),
            GeoCoordinates = new GeoProperty(new Models.GeoCoordinate(23.456, 49.654)),
            NickNames = new StringCollectionProperty(new string[] { "Genius", "The Brain" }),
            Kind = new KindProperty(VCdKind.Organization),
            Mailer = new TextProperty("The Mailer"),
            Languages = new TextProperty("de"),
            Notes = new TextProperty("Kommentar"),
            PropertyIDMappings = new PropertyIDMappingProperty(new PropertyIDMapping(7, new Uri("http://folkerkinzel.de"))),

            InstantMessengerHandles = new TextProperty[]
            {
                impp1, impp2, impp3, impp4, impp5, impp6, impp7, impp8, impp9, impp10, impp11, impp12
            },

            Relations = new RelationProperty[] { rel1, rel2 },
            Organizations = new OrganizationProperty("The ÄÖÜ Organization", new string[] { "Department", "Office" }),
            NonStandardProperties = nonStandard,
            XmlProperties = xml1,
        });
    }
Exemplo n.º 36
0
 public static string ToQueryItem(DataProperty dataProperty)
 {
     return ToQueryItem(dataProperty, true);
 }
Exemplo n.º 37
0
 set => base.SetValue(DataProperty, value);
Exemplo n.º 38
0
        private DataDictionary LoadDataObjects()
        {
            try
            {
                string Object_Name = string.Empty;
                DataObject _dataObject = new DataObject();
                KeyProperty _keyproperties = new KeyProperty();
                DataProperty _dataproperties = new DataProperty();
                DataDictionary _dataDictionary = new DataDictionary();
                List<DataProp> dataPrpCollection = new List<DataProp>();

                foreach (var dic in _objectyDictionary)
                {
                    string objectName = dic.Key.Split('_')[1];
                    string url = dic.Value;
                    string jsonString = GetJsonResponseFrom(url);
                    FillDataPropertiesFrom(jsonString, dataPrpCollection, objectName);
                }

                foreach (DataProp dp in dataPrpCollection)
                {
                    if (Object_Name != dp.Object_Name)
                    {
                        if (!string.IsNullOrEmpty(Object_Name))
                            _dataDictionary.dataObjects.Add(_dataObject);
                        _dataObject = new DataObject();
                        Object_Name = dp.Object_Name;
                        _dataObject.objectName = Object_Name;
                        _dataObject.tableName = Object_Name;
                        _dataObject.keyDelimeter = _keyDelimiter;
                    }

                    _dataproperties = new DataProperty();
                    _dataproperties.columnName = dp.columnName;

                    if (dp.isKey)
                    {
                        KeyProperty keyProperty = new KeyProperty();
                        keyProperty.keyPropertyName = dp.columnName;
                        _dataObject.keyProperties.Add(keyProperty);

                        _dataproperties.keyType = KeyType.assigned;
                        _dataproperties.isNullable = false;
                    }
                    else
                    {
                        _dataproperties.keyType = KeyType.unassigned;
                        _dataproperties.isNullable = true;
                    }

                    _dataproperties.propertyName = dp.propertyName;
                    _dataproperties.dataLength = Convert.ToInt32(dp.dataLength);

                    _dataproperties.dataType = dp.dataType;

                    _dataObject.dataProperties.Add(_dataproperties);
                }
                _dataDictionary.dataObjects.Add(_dataObject);

                return _dataDictionary;
            }
            catch (Exception ex)
            {
                _logger.Error("Error in loading data dictionary : " + ex);
                throw ex;
            }
            finally
            {
                //Disconnect();
            }
        }
Exemplo n.º 39
0
        protected DataObject CreateObjectDefinition(Proxy proxy, ClassObject classObject)
        {
            if (classObject.Ids == null || classObject.Ids.Count == 0)
              {
            return null;
              }

              string metadataQuery = string.Empty;

              if (classObject.ObjectType == ObjectType.Tag)
              {
            metadataQuery = string.Format(TAG_METADATA_SQL, (int)ObjectType.Tag);
              }
              else if (classObject.ObjectType == ObjectType.Document)
              {
            metadataQuery = string.Format(DOCUMENT_METADATA_SQL, (int)ObjectType.Document);
              }
              else
              {
            throw new Exception(string.Format("Object type [{0}] not supported.", classObject.ObjectType));
              }

              int status = 0;
              string result = proxy.query(metadataQuery, ref status);
              XmlDocument resultXml = new XmlDocument();
              resultXml.LoadXml(result);

              string type = Enum.GetName(typeof(ObjectType), classObject.ObjectType);
              DataObject objDef = new DataObject();
              objDef.objectNamespace = type;
              objDef.objectName = classObject.Name + "(" + type + ")";
              objDef.tableName = string.Join("_", classObject.Ids.ToArray());
              objDef.keyDelimeter = _keyDelimiter;

              Configuration config = GetConfiguration(objDef);
              if (config == null)
            return null;

              Map codeMap = config.Mappings.ToList<Map>().Find(x => x.Destination == (int)Destination.Code);
              if (codeMap == null)
              {
            throw new Exception("No mapping configured for key property.");
              }

              objDef.keyProperties = new List<KeyProperty>()
              {
            new KeyProperty() { keyPropertyName = codeMap.Column }
              };

              foreach (XmlNode attrNode in resultXml.DocumentElement.ChildNodes)
              {
            DataProperty dataProp = new DataProperty();
            dataProp.columnName = attrNode.SelectSingleNode("char_name").InnerText;

            string propertyName = Utilities.ToPropertyName(dataProp.columnName);
            if (objDef.dataProperties.Find(x => x.propertyName == propertyName) != null)
              continue;

            dataProp.propertyName = propertyName;
            dataProp.dataType = Utilities.ToCSharpType(attrNode.SelectSingleNode("char_data_type").InnerText);
            dataProp.dataLength = Int32.Parse(attrNode.SelectSingleNode("char_length").InnerText);

            if (attrNode.SelectSingleNode("is_system_char").InnerText == "1")
            {
              dataProp.columnName += Utilities.SYSTEM_ATTRIBUTE_TOKEN;
            }
            else
            {
              dataProp.columnName += Utilities.USER_ATTRIBUTE_TOKEN;
            }

            objDef.dataProperties.Add(dataProp);
              }

              // add related properties
              foreach (Map m in config.Mappings.Where(x => x.Destination == (int)Destination.Relationship).Select(m => m))
              {
            DataProperty dataProp = new DataProperty();
            string propertyName = Utilities.ToPropertyName(m.Column);
            DataProperty checkProp = objDef.dataProperties.Find(x => x.propertyName == propertyName);

            if (checkProp != null)  // property already exists, update its column name
            {
              checkProp.columnName = m.Column + Utilities.RELATED_ATTRIBUTE_TOKEN;
            }
            else
            {
              dataProp.columnName = m.Column + Utilities.RELATED_ATTRIBUTE_TOKEN;
              dataProp.propertyName = propertyName;
              dataProp.dataType = DataType.String;
              objDef.dataProperties.Add(dataProp);
            }
              }

              // add other properties
              foreach (Map m in config.Mappings.Where(x => x.Destination != (int)Destination.Relationship &&
            x.Destination != (int)Destination.Attribute && x.Destination != (int)Destination.None).Select(m => m))
              {
            DataProperty dataProp = new DataProperty();
            string propertyName = Utilities.ToPropertyName(m.Column);
            DataProperty checkProp = objDef.dataProperties.Find(x => x.propertyName == propertyName);

            if (checkProp != null)  // property already exists, update its column name
            {
              checkProp.columnName = m.Column + Utilities.OTHER_ATTRIBUTE_TOKEN;
            }
            else
            {
              dataProp.columnName = m.Column + Utilities.OTHER_ATTRIBUTE_TOKEN;
              dataProp.propertyName = propertyName;
              dataProp.dataType = DataType.String;
              objDef.dataProperties.Add(dataProp);
            }
              }

              return objDef;
        }
Exemplo n.º 40
0
        /// <summary>
        /// Initializes the instances of the additional properties by the corresponding property names,
        /// which could be defaulted during current property construction and possibly overwritten
        /// during the parent object initialization before this method is called.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            if (AdditionalPropertyName != null)
                additionalProperty = parent[AdditionalPropertyName];
            if (AdditionalPropertyName2 != null)
                additionalProperty2 = parent[AdditionalPropertyName2];

            OnValueChanged(this, new PropertyChangeEventArgs(PropertyChange.All, null, null));
        }
Exemplo n.º 41
0
        private DataDictionary CreateDataDictionary()
        {
            try
            {

                DataObject _dataObject = null;
                KeyProperty _keyproperties = new KeyProperty();
                DataProperty _dataproperties = new DataProperty();
                DataDictionary _dataDictionary = new DataDictionary();

                foreach (var dic in _objectyDictionary)
                {
                    string objectName = dic.Key;
                    bool isFirstRecored = false;
                    string url = _schemaUrl.Replace("{resource}", dic.Key);
                    string json = GetJsonResponseFrom(url);

                    JObject schemaObject = JObject.Parse(json);

                    foreach (JProperty propery in schemaObject.Properties())
                    {
                        string propertyName = propery.Name;
                        if (propertyName != "links")
                        {
                            if (!isFirstRecored)
                            {
                                isFirstRecored = true;
                                _dataObject = new DataObject();

                                _dataObject.objectName = objectName;
                                _dataObject.tableName = objectName;
                                _dataObject.keyDelimeter = _keyDelimiter;

                            }

                            _dataproperties = new DataProperty();
                            _dataproperties.propertyName = propertyName;
                            _dataproperties.columnName = propertyName;
                            _dataproperties.keyType = KeyType.unassigned;
                            _dataproperties.isNullable = true;

                            foreach(JProperty p in ((JObject)propery.Value).Properties())
                            {
                                if (p.Name == "type")
                                {
                                    _dataproperties.dataType = ResolveDataType(p.Value.ToString());
                                }
                                else if(p.Name == "size")
                                {
                                    if (p.Value.ToString() == "string")
                                        _dataproperties.dataLength = Convert.ToInt32(p.Value.ToString());
                                }
                            }

                            _dataObject.dataProperties.Add(_dataproperties);
                        }
                    }

                    foreach (JProperty propery in schemaObject.Properties())
                    {
                        if (propery.Name == "links")
                        {
                            _selfUrl.Add(objectName, schemaObject["links"]["self"].Value<string>());

                            JArray keyList = (JArray)schemaObject["links"]["key"];
                            for (int i = 0; i < keyList.Count; i++)
                            {
                                DataProperty property = _dataObject.dataProperties.Single<DataProperty>(x => x.propertyName == keyList[i].ToString());
                                property.keyType =  KeyType.assigned;
                                property.isNullable = false;

                                _dataObject.keyProperties.Add(new KeyProperty() { keyPropertyName = property.propertyName });
                            }

                        }
                    }

                    _dataDictionary.dataObjects.Add(_dataObject);
                }

                return _dataDictionary;
            }
            catch (Exception ex)
            {
                _logger.Error("Error in loading data dictionary : " + ex);
                throw ex;
            }
        }
Exemplo n.º 42
0
        private DataDictionary LoadDataObjects(List<string> tableNames)
        {
            try
            {
                DataObjects _dataObjects = new DataObjects();
                DataObject _dataObject = new DataObject();
                KeyProperty _keyproperties = new KeyProperty();
                DataProperty _dataproperties = new DataProperty();
                DataDictionary dataDictionary = new DataDictionary();
                ConnectToAccess();

                foreach (string strname in tableNames)
                {
                    _dataObject = new DataObject();
                    _dataObject.objectName = strname.ToLower();
                    _dataObject.tableName = strname.ToLower();
                    _dataObject.keyDelimeter = "_";

                    DataTable colKey = _connOledb.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new Object[] { null, null, strname });
                    DataView view = colKey.DefaultView;
                    view.Sort = "ORDINAL";
                    colKey = view.ToTable();
                    List<string> tableKeys = new List<string>();
                    foreach (DataRow row in colKey.Rows)
                    {
                        tableKeys.Add(row["COLUMN_NAME"].ToString());
                    }

                    DataTable tableColumns = _connOledb.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, strname, null });
                    foreach (DataRow row in tableColumns.Rows)
                    {
                        _dataproperties = new DataProperty();
                        _dataproperties.columnName = row["COLUMN_NAME"].ToString();
                        _dataproperties.propertyName = row["COLUMN_NAME"].ToString();

                        if (!(row["CHARACTER_MAXIMUM_LENGTH"] is DBNull))
                        {
                            _dataproperties.dataLength = Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]);
                            if(_dataproperties.dataLength == 0)
                                _dataproperties.dataLength = 8000; // Memo Stores up to 8000 characters
                        }
                        else
                            _dataproperties.dataLength = 50;

                        _dataproperties.isNullable = Convert.ToBoolean(row["IS_NULLABLE"]);

                        if (tableKeys.Contains(_dataproperties.columnName))
                        {
                            _keyproperties = new KeyProperty();
                            _keyproperties.keyPropertyName = _dataproperties.columnName;
                            _dataObject.keyProperties.Add(_keyproperties);
                            _dataproperties.keyType = KeyType.assigned;
                        }
                        else
                        {
                            _dataproperties.keyType = KeyType.unassigned;
                        }

                        switch (row["DATA_TYPE"].ToString())
                        {
                            case "11":
                                _dataproperties.dataType = DataType.Boolean;
                                break;
                            case "2":
                            case "3":
                            case "4":
                                _dataproperties.dataType = DataType.Int32;
                                break;
                            case "7":
                                _dataproperties.dataType = DataType.DateTime;
                                break;
                            default:
                                _dataproperties.dataType = DataType.String;
                                break;
                        }
                        _dataObject.dataProperties.Add(_dataproperties);
                    }
                    dataDictionary.dataObjects.Add(_dataObject);
                }
                return dataDictionary;
            }
            catch (Exception ex)
            {
                logger.Error("Error in generating the dictionary.");
                throw ex;
            }
            finally
            {
                _connOledb.Close();
            }
        }
Exemplo n.º 43
0
 set => SetValue(DataProperty, value);
 /// <summary>
 /// Binds the text box to the given property.
 /// Sets the maximum text length to the property size if available.
 /// </summary>
 /// <param name="property">The data property to bind the text box to.</param>
 public override void BindTo(DataProperty property)
 {
     base.BindTo(property);
     ((TextBox)element).MaxLength = (property != null && !property.IsMultiValued && property.Size > 0) ? property.Size : 0;
 }