Exemplo n.º 1
0
        /// <summary>
        /// Returns the style based on a numeric DataColumn, where style
        /// properties are linearly interpolated between max and min values.
        /// </summary>
        /// <param name="row">Feature</param>
        /// <returns><see cref="Mapsui.Styles.IStyle">Style</see> calculated by a linear interpolation between the min/max styles</returns>
        public IStyle?GetStyle(IFeature row)
        {
            double attr;

            try { attr = Convert.ToDouble(row[ColumnName.ToUpper()]); }
            catch { throw new Exception("Invalid Attribute type in Gradient Theme - Couldn't parse attribute (must be numerical)"); }
            if (MinStyle.GetType() != MaxStyle.GetType())
            {
                throw new ArgumentException("MinStyle and MaxStyle must be of the same type");
            }


            var style = (IStyle)Activator.CreateInstance(MinStyle.GetType()) !;

            if (MinStyle is LabelStyle && MaxStyle is LabelStyle)
            {
                CalculateLabelStyle(style as LabelStyle, MinStyle as LabelStyle, MaxStyle as LabelStyle, attr);
            }
            if (MinStyle is VectorStyle && MaxStyle is VectorStyle)
            {
                CalculateVectorStyle(style as VectorStyle, MinStyle as VectorStyle, MaxStyle as VectorStyle, attr);
            }
            if (MinStyle is SymbolStyle && MaxStyle is SymbolStyle)
            {
                CalculateSymbolStyle(style as SymbolStyle, MinStyle as SymbolStyle, MaxStyle as SymbolStyle, attr);
            }
            return(style);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 内部方法:根据数据表行记录构建实体类型
        /// </summary>
        /// <param name="TabInfo"></param>
        /// <param name="dr"></param>
        /// <returns></returns>
        public static T Generate <T>(T ModelObj, TableDefinition TabInfo, DataRow dr)
        {
            int DefineColsCount = TabInfo.ORMColList.Count;
            int ResultColsCount = dr.ColumnNames.Count;

            if (DefineColsCount > ResultColsCount)
            {
                foreach (string ColumnName in dr.ColumnNames)
                {
                    TabInfo.ORM_TypePropDic[ColumnName.ToUpper()].SetValue(ModelObj, dr[ColumnName]);
                }
            }
            else
            {
                foreach (string ColName in TabInfo.ORMColList)
                {
                    if (dr.ColumnNames.Contains(ColName))
                    {
                        if (dr[ColName] != DBNull.Value)
                        {
                            var          ColVal = dr[ColName];
                            PropertyInfo Prop   = TabInfo.ORM_TypePropDic[ColName.ToUpper()];
                            if (Prop.PropertyType == typeof(int))
                            {
                                Prop.SetValue(ModelObj, Convert.ToInt32(ColVal));
                            }
                            else if (Prop.PropertyType == typeof(long))
                            {
                                Prop.SetValue(ModelObj, Convert.ToInt64(ColVal));
                            }
                            else if (Prop.PropertyType == typeof(decimal))
                            {
                                Prop.SetValue(ModelObj, Convert.ToDecimal(ColVal));
                            }
                            else if (Prop.PropertyType == typeof(DateTime))
                            {
                                Prop.SetValue(ModelObj, Convert.ToDateTime(ColVal));
                            }
                            else if (Prop.PropertyType == typeof(string))
                            {
                                Prop.SetValue(ModelObj, Convert.ToString(ColVal));
                            }
                            else
                            {
                                Prop.SetValue(ModelObj, ColVal);
                            }
                        }
                    }
                }
            }
            return(ModelObj);
        }
Exemplo n.º 3
0
 public string getScript()
 {
     return(string.Format(
                "ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})",
                new string[]
     {
         TableName.ToUpper(),
         ConstraintName.ToUpper(),
         ColumnName.ToUpper(),
         TableReference.ToUpper(),
         ColumnReference.ToUpper()
     }));
 }
Exemplo n.º 4
0
    public StepResult GetResult(Process process, string databaseName)
    {
        var result = new StepResult();

        _process = process;
        var resultRows = new List <Row>();

        // if we have an input step then we need to get the rows from the input step and then
        // update those rows and save back to the database
        if (HasInputStep)
        {
            var resultStep = InputStep.GetResult(_process, DatabaseName);
            foreach (var row in resultStep.Rows)
            {
                foreach (var value in row.Values)
                {
                    if (value.ColumnName.ToUpper() == ColumnName.ToUpper())
                    {
                        value.Value = Value.Replace("'", string.Empty);
                    }
                }

                _process.GetDatabase(DatabaseName).GetTable(TableName).UpdateRow(row.ToReference(_process, TableName, DatabaseName), row.Values);
            }
            resultRows = resultStep.Rows;
        }
        else
        {
            var table = _process.GetDatabase(DatabaseName).GetTable(TableName);
            var rows  = table.GetAllRows();
            foreach (var row in rows)
            {
                foreach (var value in row.Values)
                {
                    if (value.ColumnName == ColumnName)
                    {
                        value.Value = Value;
                    }
                }

                table.UpdateRow(row.ToReference(_process, TableName, DatabaseName), row.Values);
            }

            resultRows = rows;
        }

        result.Rows = resultRows;
        return(result);
    }