Exemple #1
0
        public override void Init(GenericDataDictionary template, GenericDataObject parentModel)
        {
            template.GetValue("label", out string label);
            _label.Text = label;

            template.GetValue("keyPrefix", out _keyPrefix);
            _prefixLabel.Text = _keyPrefix;

            template.GetValue("slotType", out _linkType);

            parentModel.TryGetValue(_label.Text, out GenericDataObject <string> model);
            if (model != null)
            {
                _model      = model;
                _field.Text = _model.value.Substring(_keyPrefix.Length, _model.value.Length - _keyPrefix.Length);
                OnChanged(_field.Text);
            }
            else
            {
                template.GetValue("key", out string defaultKey);
                _field.Text = defaultKey;
                _model      = parentModel.TryAddValue(_label.Text, string.Empty) as GenericDataObject <string>;
                OnChanged(_field.Text);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LottieComposition"/> class.
 /// </summary>
 /// <param name="name">The name of the composition.</param>
 /// <param name="width">Width of animation canvas as specified in After Effects.</param>
 /// <param name="height">Height of animation canvas as specified in After Effects.</param>
 /// <param name="inPoint">Frame at which animation begins as specified in After Effects.</param>
 /// <param name="outPoint">Frame at which animation ends as specified in After Effects.</param>
 /// <param name="framesPerSecond">FrameRate (frames per second) at which animation data was generated in After Effects.</param>
 /// <param name="is3d">True if the composition is 3d.</param>
 /// <param name="version">The version of the schema of the composition.</param>
 /// <param name="assets">Assets that are part of the composition.</param>
 /// <param name="chars">Character definitions that are part of the composition.</param>
 /// <param name="fonts">Font definitions that are part of the composition.</param>
 /// <param name="layers">The layers in the composition.</param>
 /// <param name="markers">Markers that define named portions of the composition.</param>
 /// <param name="extraData">Extra data that is related to the composition but is not part of the BodyMovin schema.</param>
 public LottieComposition(
     string name,
     double width,
     double height,
     double inPoint,
     double outPoint,
     double framesPerSecond,
     bool is3d,
     Version version,
     AssetCollection assets,
     IEnumerable <Char> chars,
     IEnumerable <Font> fonts,
     LayerCollection layers,
     IEnumerable <Marker> markers,
     GenericDataObject extraData)
     : base(name)
 {
     Is3d            = is3d;
     Width           = width;
     Height          = height;
     InPoint         = inPoint;
     OutPoint        = outPoint;
     FramesPerSecond = framesPerSecond;
     Duration        = TimeSpan.FromSeconds((outPoint - inPoint) / framesPerSecond);
     Version         = version;
     Layers          = layers;
     Assets          = assets;
     Chars           = chars.ToArray();
     ExtraData       = extraData;
     Fonts           = fonts.ToArray();
     Markers         = markers.ToArray();
 }
Exemple #3
0
        private IDataObject FormDataObject(Widget widget)
        {
            IDataObject dataObject = new GenericDataObject();

            try
            {
                dataObject.SetPropertyValue("Id", widget.Id);
                dataObject.SetPropertyValue("Name", widget.Name);
                dataObject.SetPropertyValue("Description", widget.Description);
                dataObject.SetPropertyValue("Length", widget.Length);
                dataObject.SetPropertyValue("Width", widget.Width);
                dataObject.SetPropertyValue("Height", widget.Height);
                dataObject.SetPropertyValue("Weight", widget.Weight);
                dataObject.SetPropertyValue("LengthUOM", widget.LengthUOM);
                dataObject.SetPropertyValue("WeightUOM", widget.WeightUOM);
                dataObject.SetPropertyValue("Material", widget.Material);
                dataObject.SetPropertyValue("Color", widget.Color);
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Error while marshalling a widget into a data object: {1}", ex);
                throw new Exception("Error while marshalling a widget into a data object.", ex);
            }

            return(dataObject);
        }
Exemple #4
0
        internal static IJsonValue GenericDataObjectToJsonValue(GenericDataObject obj)
        {
            if (obj is null)
            {
                return(JsonValue.CreateNullValue());
            }

            switch (obj.Type)
            {
            case GenericDataObjectType.Bool:
                return(JsonValue.CreateBooleanValue(((GenericDataBool)obj).Value));

            case GenericDataObjectType.List:
            {
                var result = new JsonArray();
                foreach (var value in (GenericDataList)obj)
                {
                    result.Add(GenericDataObjectToJsonValue(value));
                }

                return(result);
            }

            case GenericDataObjectType.Map:
            {
                var result = new JsonObject();
                foreach ((var key, var value) in (GenericDataMap)obj)
                {
                    result.Add(key, GenericDataObjectToJsonValue(value));
                }

                return(result);
            }

            case GenericDataObjectType.Number:
                return(JsonValue.CreateNumberValue(((GenericDataNumber)obj).Value));

            case GenericDataObjectType.String:
                return(JsonValue.CreateStringValue(((GenericDataString)obj).Value));

            default:
                throw new InvalidOperationException();
            }
        }
Exemple #5
0
        public void TestPost()
        {
            Response response = _dataLayer.RefreshAll();

            IList <IDataObject> dataObjects = _dataLayer.Get("Spools", new DataFilter(), 25, 0);

            dataObjects = new List <IDataObject>();

            IDataObject dataObject = new GenericDataObject()
            {
                ObjectType = "Spools"
            };

            dataObject.SetPropertyValue("Spool", "01EKG11PS02001");
            dataObject.SetPropertyValue("WorkPackage", "WP1");
            dataObject.SetPropertyValue("ConstructionStatus", "Go!");

            dataObjects.Add(dataObject);

            response = _dataLayer.Post(dataObjects);

            //string orgIdentifier = GetIdentifier(dataObjects[0]);

            //string orgPropValue = Convert.ToString(dataObjects[0].GetPropertyValue(_modifiedProperty)) ?? String.Empty;
            //int newPropValue = 101;

            //// post data object with modified property
            //dataObjects[0].SetPropertyValue(_modifiedProperty, newPropValue);
            //Response response = _dataLayer.Post(dataObjects);
            //Assert.AreEqual(response.Level, StatusLevel.Success);

            //// verify post result
            //dataObjects = _dataLayer.Get(_objectType, new List<string> { orgIdentifier });
            //Assert.AreEqual(dataObjects[0].GetPropertyValue(_modifiedProperty), newPropValue);

            //// reset property to its orginal value
            //dataObjects[0].SetPropertyValue(_modifiedProperty, orgPropValue);
            //response = _dataLayer.Post(dataObjects);
            //Assert.AreEqual(response.Level, StatusLevel.Success);
        }
Exemple #6
0
        public override void Init(GenericDataDictionary template, GenericDataObject parentModel)
        {
            template.GetValue("label", out string label);
            _label.Text = label;

            template.GetValue("keyPrefix", out _keyPrefix);
            template.GetValue("keySize", out _keySize);
            template.GetValue("slotType", out _linkType);

            parentModel.TryGetValue(_label.Text, out GenericDataObject <string> model);
            if (model != null)
            {
                _model = model;
                SetKey(_model.value);
                _model.value = GetKey;
            }
            else
            {
                SetKey();
                _model = parentModel.TryAddValue(_label.Text, GetKey) as GenericDataObject <string>;
            }
        }
Exemple #7
0
        private IDataObject FormDataObject(string objectType, string csvRow)
        {
            try
            {
                IDataObject dataObject = new GenericDataObject
                {
                    ObjectType = objectType,
                };

                XElement commodityElement = new XElement("a");
                  //GetCommodityConfig(objectType);

                if (!String.IsNullOrEmpty(csvRow))
                {
                    IEnumerable<XElement> attributeElements = commodityElement.Element("attributes").Elements("attribute");

                    string[] csvValues = csvRow.Split(',');

                    int index = 0;
                    foreach (var attributeElement in attributeElements)
                    {
                        string name = attributeElement.Attribute("name").Value;
                        string dataType = attributeElement.Attribute("dataType").Value.ToLower();
                        string value = csvValues[index++].Trim();

                        // if data type is not nullable, make sure it has a value
                        if (!(dataType.EndsWith("?") && value == String.Empty))
                        {
                            if (dataType.Contains("bool"))
                            {
                                if (value.ToUpper() == "TRUE" || value.ToUpper() == "YES")
                                {
                                    value = "1";
                                }
                                else
                                {
                                    value = "0";
                                }
                            }
                            else if (value == String.Empty && (
                                     dataType.StartsWith("int") ||
                                     dataType == "double" ||
                                     dataType == "single" ||
                                     dataType == "float" ||
                                     dataType == "decimal"))
                            {
                                value = "0";
                            }
                        }

                        dataObject.SetPropertyValue(name, value);
                    }
                }

                return dataObject;
            }
            catch (Exception ex)
            {
                _logger.Error("Error in FormDataObject: " + ex);

                throw new Exception(
                  "Error while forming a dataObject of type [" + objectType + "] from SPPID.",
                  ex
                );
            }
        }
Exemple #8
0
 // Converts an object to a string. This method exists to support
 // stringifying of objects that may be null.
 internal static string ToString(GenericDataObject obj)
 => obj is null ? "null" : obj.ToString();
Exemple #9
0
        protected IDataObject CreateEmptyDataObject(string objectType, DataObject objDef)
        {
            IDataObject dataObject = new GenericDataObject() { ObjectType = objectType };

              foreach (DataProperty prop in objDef.dataProperties)
              {
            dataObject.SetPropertyValue(prop.propertyName, null);
              }

              return dataObject;
        }
Exemple #10
0
        protected IDataObject ToDataObject(DataRow dataRow, DataObject objectDefinition)
        {
            IDataObject dataObject = null;

              if (dataRow != null)
              {
            try
            {
              dataObject = new GenericDataObject() { ObjectType = objectDefinition.objectName };
            }
            catch (Exception e)
            {
              throw e;
            }

            if (dataObject != null && objectDefinition.dataProperties != null)
            {
              foreach (DataProperty prop in objectDefinition.dataProperties)
              {
            try
            {
              string value = string.Empty;

              if (dataRow.Table.Columns.Contains(prop.propertyName))
              {
                value = Convert.ToString(dataRow[prop.propertyName]);
              }

              dataObject.SetPropertyValue(prop.propertyName, value);
            }
            catch (Exception e)
            {
              throw e;
            }
              }
            }
              }

              return dataObject;
        }
Exemple #11
0
        private IDataObject FormDataObject(Widget widget)
        {
            IDataObject dataObject = new GenericDataObject();

              try
              {
            dataObject.SetPropertyValue("Id", widget.Id);
            dataObject.SetPropertyValue("Name", widget.Name);
            dataObject.SetPropertyValue("Description", widget.Description);
            dataObject.SetPropertyValue("Length", widget.Length);
            dataObject.SetPropertyValue("Width", widget.Width);
            dataObject.SetPropertyValue("Height", widget.Height);
            dataObject.SetPropertyValue("Weight", widget.Weight);
            dataObject.SetPropertyValue("LengthUOM", widget.LengthUOM);
            dataObject.SetPropertyValue("WeightUOM", widget.WeightUOM);
            dataObject.SetPropertyValue("Material", widget.Material);
            dataObject.SetPropertyValue("Color", widget.Color);
              }
              catch (Exception ex)
              {
            _logger.ErrorFormat("Error while marshalling a widget into a data object: {1}", ex);
            throw new Exception("Error while marshalling a widget into a data object.", ex);
              }

              return dataObject;
        }
Exemple #12
0
        private IDataObject ToDataObject(DataRow dataRow, DataObject objectDefinition)
        {
            IDataObject dataObject = null;

            if (dataRow != null)
            {
                try
                {
                    dataObject = new GenericDataObject() { ObjectType = objectDefinition.objectName };
                }
                catch (Exception ex)
                {
                    _logger.Error("Error instantiating data object: " + ex);
                    throw ex;
                }

                if (dataObject != null && objectDefinition.dataProperties != null)
                {
                    foreach (DataProperty objectProperty in objectDefinition.dataProperties)
                    {
                        try
                        {
                            if (dataRow.Table.Columns.Contains(objectProperty.columnName))
                            {
                                object value = dataRow[objectProperty.columnName];

                                if (value.GetType() == typeof(System.DBNull))
                                {
                                    value = null;
                                }

                                dataObject.SetPropertyValue(objectProperty.propertyName, value);
                            }
                            else
                            {
                                _logger.Warn(String.Format("Value for column [{0}] not found in data row of table [{1}]",
                                  objectProperty.columnName, objectDefinition.tableName));
                            }
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("Error getting data row value: " + ex);
                            throw ex;
                        }
                    }
                }
            }
            else
            {
                dataObject = new GenericDataObject() { ObjectType = objectDefinition.objectName };

                foreach (DataProperty objectProperty in objectDefinition.dataProperties)
                {
                    dataObject.SetPropertyValue(objectProperty.propertyName, null);
                }
            }

            return dataObject;
        }
        private IList <IDataObject> LoadDataObjects(string objectType, DataFilter filter)
        {
            try
            {
                bool addDataObject = true, containFilterProperty = false;
                IList <IDataObject> dataObjects     = new List <IDataObject>();
                int index = 0;

                SpreadsheetTable     cfTable        = _provider.GetConfigurationTable(objectType);
                SpreadsheetReference tableReference = cfTable.GetReference();

                WorksheetPart worksheetPart = _provider.GetWorksheetPart(tableReference.SheetName);

                IEnumerable <Row> rows = worksheetPart.Worksheet.Descendants <Row>().Where(r => r.RowIndex > tableReference.StartRow && r.RowIndex <= tableReference.EndRow);

                foreach (Row row in rows)
                {
                    index                 = 0;
                    addDataObject         = true;
                    containFilterProperty = false;
                    IDataObject dataObject = new GenericDataObject
                    {
                        ObjectType = objectType,
                    };

                    foreach (Cell col in row.ChildElements)
                    {
                        index++;
                        string            columnIdx = SpreadsheetReference.GetColumnName(col.CellReference);
                        SpreadsheetColumn column    = cfTable.Columns.First <SpreadsheetColumn>(c => columnIdx.Equals(c.ColumnIdx));

                        if (column != null)
                        {
                            if (index == 1)
                            {
                                if (_provider.GetValue(col) == null)
                                {
                                    addDataObject = false;
                                    break;
                                }
                            }

                            if (filter != null)
                            {
                                foreach (Expression expression in filter.Expressions)
                                {
                                    if (expression.PropertyName.ToLower().Equals(column.Name.ToLower()))
                                    {
                                        containFilterProperty = true;
                                        if (_provider.GetValue(col) == null)
                                        {
                                            addDataObject = false;
                                            break;
                                        }
                                    }
                                }

                                if (filter.Expressions.Count == 0)
                                {
                                    addDataObject = true;
                                }
                            }

                            if (addDataObject)
                            {
                                dataObject.SetPropertyValue(column.Name, _provider.GetValue(col));
                            }
                        }
                    }

                    if (!containFilterProperty && filter != null)
                    {
                        if (filter.Expressions.Count > 0)
                        {
                            addDataObject = false;
                        }
                    }

                    if (addDataObject)
                    {
                        dataObjects.Add(dataObject);
                    }

                    //foreach (var col in cfTable.Columns)
                    //{
                    //    if (!((GenericDataObject)dataObject).Dictionary.ContainsKey(col.Name))
                    //        dataObject.SetPropertyValue(col.Name, null);
                    //}
                }

                return(dataObjects);
            }
            catch (Exception ex)
            {
                _logger.Error("Error in LoadDataObjects: " + ex);
                throw new Exception("Error while loading data objects of type [" + objectType + "].", ex);
            }
            finally
            {
                //  _provider.Dispose();
            }
        }
Exemple #14
0
        private IDataObject FormDataObject(string objectType, string csvRow)
        {
            try
            {
                IDataObject dataObject = new GenericDataObject
                {
                    ObjectType = objectType,
                };

                XElement commodityElement = new XElement("a");
                //GetCommodityConfig(objectType);

                if (!String.IsNullOrEmpty(csvRow))
                {
                    IEnumerable <XElement> attributeElements = commodityElement.Element("attributes").Elements("attribute");

                    string[] csvValues = csvRow.Split(',');

                    int index = 0;
                    foreach (var attributeElement in attributeElements)
                    {
                        string name     = attributeElement.Attribute("name").Value;
                        string dataType = attributeElement.Attribute("dataType").Value.ToLower();
                        string value    = csvValues[index++].Trim();

                        // if data type is not nullable, make sure it has a value
                        if (!(dataType.EndsWith("?") && value == String.Empty))
                        {
                            if (dataType.Contains("bool"))
                            {
                                if (value.ToUpper() == "TRUE" || value.ToUpper() == "YES")
                                {
                                    value = "1";
                                }
                                else
                                {
                                    value = "0";
                                }
                            }
                            else if (value == String.Empty && (
                                         dataType.StartsWith("int") ||
                                         dataType == "double" ||
                                         dataType == "single" ||
                                         dataType == "float" ||
                                         dataType == "decimal"))
                            {
                                value = "0";
                            }
                        }

                        dataObject.SetPropertyValue(name, value);
                    }
                }

                return(dataObject);
            }
            catch (Exception ex)
            {
                _logger.Error("Error in FormDataObject: " + ex);

                throw new Exception(
                          "Error while forming a dataObject of type [" + objectType + "] from SPPID.",
                          ex
                          );
            }
        }
Exemple #15
0
        public void TestPost()
        {
            Response response = _dataLayer.RefreshAll();

              IList<IDataObject> dataObjects = _dataLayer.Get("Spools", new DataFilter(), 25, 0);

              dataObjects = new List<IDataObject>();

              IDataObject dataObject = new GenericDataObject() { ObjectType = "Spools" };

              dataObject.SetPropertyValue("Spool", "01EKG11PS02001");
              dataObject.SetPropertyValue("WorkPackage", "WP1");
              dataObject.SetPropertyValue("ConstructionStatus", "Go!");

              dataObjects.Add(dataObject);

              response = _dataLayer.Post(dataObjects);

              //string orgIdentifier = GetIdentifier(dataObjects[0]);

              //string orgPropValue = Convert.ToString(dataObjects[0].GetPropertyValue(_modifiedProperty)) ?? String.Empty;
              //int newPropValue = 101;

              //// post data object with modified property
              //dataObjects[0].SetPropertyValue(_modifiedProperty, newPropValue);
              //Response response = _dataLayer.Post(dataObjects);
              //Assert.AreEqual(response.Level, StatusLevel.Success);

              //// verify post result
              //dataObjects = _dataLayer.Get(_objectType, new List<string> { orgIdentifier });
              //Assert.AreEqual(dataObjects[0].GetPropertyValue(_modifiedProperty), newPropValue);

              //// reset property to its orginal value
              //dataObjects[0].SetPropertyValue(_modifiedProperty, orgPropValue);
              //response = _dataLayer.Post(dataObjects);
              //Assert.AreEqual(response.Level, StatusLevel.Success);
        }