private static string GetXmlType(DataPropertyType dataPropertyType)
        {
            switch (dataPropertyType)
            {
            case DataPropertyType.Blob:
                return("xs:hexBinary");    //NOXLATE

            case DataPropertyType.Boolean:
                return("xs:boolean");    //NOXLATE

            case DataPropertyType.Byte:
                return("xs:unsignedByte");    //NOXLATE

            case DataPropertyType.DateTime:
                return("xs:dateTime");    //NOXLATE

            case DataPropertyType.Double:
                return("xs:double");    //NOXLATE

            case DataPropertyType.Int16:
                return("xs:short");    //NOXLATE

            case DataPropertyType.Int32:
                return("xs:int");    //NOXLATE

            case DataPropertyType.Int64:
                return("xs:long");    //NOXLATE

            case DataPropertyType.Single:
                return("xs:float");    //NOXLATE

            case DataPropertyType.String:
                return("xs:string");    //NOXLATE

            case DataPropertyType.Clob:
                return("fdo:clob");    //NOXLATE

            default:
                throw new ArgumentException();
            }
        }
        private static ExpressionDataType GetExpressionType(DataPropertyType dt)
        {
            switch (dt)
            {
            case DataPropertyType.Blob:
                return(ExpressionDataType.Data_Blob);

            case DataPropertyType.Boolean:
                return(ExpressionDataType.Data_Boolean);

            case DataPropertyType.Byte:
                return(ExpressionDataType.Data_Byte);

            case DataPropertyType.Clob:
                return(ExpressionDataType.Data_Clob);

            case DataPropertyType.DateTime:
                return(ExpressionDataType.Data_DateTime);

            case DataPropertyType.Double:
                return(ExpressionDataType.Data_Double);

            case DataPropertyType.Int16:
                return(ExpressionDataType.Data_Int16);

            case DataPropertyType.Int32:
                return(ExpressionDataType.Data_Int32);

            case DataPropertyType.Int64:
                return(ExpressionDataType.Data_Int64);

            case DataPropertyType.Single:
                return(ExpressionDataType.Data_Single);

            case DataPropertyType.String:
                return(ExpressionDataType.Data_String);
            }
            throw new ArgumentException();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the CLR type for the specified data type
        /// </summary>
        /// <param name="dataPropertyType"></param>
        /// <returns></returns>
        public static Type GetClrType(DataPropertyType dataPropertyType)
        {
            switch (dataPropertyType)
            {
            case DataPropertyType.Blob:
                return(typeof(byte[]));

            case DataPropertyType.Boolean:
                return(typeof(bool));

            case DataPropertyType.Byte:
                return(typeof(byte));

            case DataPropertyType.Clob:
                return(typeof(char[]));

            case DataPropertyType.DateTime:
                return(typeof(DateTime));

            case DataPropertyType.Double:
                return(typeof(double));

            case DataPropertyType.Int16:
                return(typeof(short));

            case DataPropertyType.Int32:
                return(typeof(int));

            case DataPropertyType.Int64:
                return(typeof(long));

            case DataPropertyType.Single:
                return(typeof(float));

            case DataPropertyType.String:
                return(typeof(string));
            }
            throw new ArgumentException();
        }
Ejemplo n.º 4
0
        private void UpdateUIForClassSelection()
        {
            if (ColumnCombo.SelectedIndex == 0)
            {
                DisableThemeOptions();
            }
            else
            {
                DisplayGroup.Enabled =
                PreviewGroup.Enabled =
                OKBtn.Enabled =
                    true;

                m_values = new Dictionary<object, long>();

                PropertyDefinition col = m_featureClass.FindProperty(ColumnCombo.Text);

                //Not really possible
                if (col == null)
                    throw new Exception(Strings.InvalidColumnNameError);

                string filter = null; //Attempt raw reading initially
                Exception rawEx = null; //Original exception
                bool retry = true;

                while (retry)
                {
                    retry = false;
                    try
                    {
                        IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
                        if (!string.IsNullOrEmpty(vl.Filter))
                            filter = vl.Filter;
                        try
                        {
                            //Either UNIQUE() is an undocumented FDO expression function (!!!)
                            //Or it is FDO expression sugar to work around the fact there is no distinct
                            //flag in the SELECTAGGREGATES operation that's exposed over HTTP. Either
                            //case, try this method first.
                            using (var rd = m_editor.FeatureService.AggregateQueryFeatureSource(
                                                    vl.ResourceId,
                                                    m_featureClass.QualifiedName,
                                                    filter,
                                                    new NameValueCollection() {
                                                        { "value", "UNIQUE(\"" + col.Name + "\")" }
                                                    }))
                            {
                                while (rd.ReadNext() && m_values.Count < MAX_NUMERIC_THEME_RULES) //No more than 100.000 records in memory
                                {
                                    if (!rd.IsNull("value"))
                                    {
                                        object value = rd["value"];
                                        if (!m_values.ContainsKey(value))
                                            m_values.Add(value, 0);

                                        m_values[value]++;
                                    }
                                }
                                rd.Close();
                            }
                        }
                        catch
                        {

                            using (var rd = m_editor.FeatureService.QueryFeatureSource(vl.ResourceId, m_featureClass.QualifiedName, filter, new string[] { col.Name }))
                            {
                                while (rd.ReadNext() && m_values.Count < MAX_NUMERIC_THEME_RULES) //No more than 100.000 records in memory
                                {
                                    if (!rd.IsNull(col.Name))
                                    {
                                        object value = rd[col.Name];
                                        if (!m_values.ContainsKey(value))
                                            m_values.Add(value, 0);

                                        m_values[value]++;
                                    }
                                }
                                rd.Close();
                            }
                        }
                        rawEx = null; //Clear error

                    }
                    catch (Exception ex)
                    {
                        rawEx = ex;
                        if (filter == null && ex.Message.IndexOf("MgNullPropertyValueException") >= 0) //Known issue
                        {
                            retry = true;
                            filter = "NOT " + col.Name + " NULL";
                        }
                    }
                }

                if (rawEx != null)
                {
                    MessageBox.Show(this, string.Format(Strings.DataReadError, rawEx.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ColumnCombo.SelectedIndex = 0;
                    return;
                }

                if (m_values.Count == 0)
                {
                    MessageBox.Show(this, Strings.ColumnHasNoValidDataError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ColumnCombo.SelectedIndex = 0;
                    return;
                }

                if (col.Type == PropertyDefinitionType.Data)
                {
                    DataPropertyDefinition dp = ((DataPropertyDefinition)col);
                    m_dataType = dp.DataType;

                    if (dp.IsNumericType())
                    {
                        if (m_values.Count >= MAX_NUMERIC_THEME_RULES)
                            MessageBox.Show(this, string.Format(Strings.TooMuchDataWarning, MAX_NUMERIC_THEME_RULES), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                        GroupPanel.Enabled = true;
                        RuleCountPanel.Enabled = true;
                        RuleCount.Minimum = 3;

                        if (m_values.Count <= 9)
                        {
                            AggregateCombo.SelectedIndex = AggregateCombo.Items.Count - 1;
                            AggregateCombo_SelectedIndexChanged(this, EventArgs.Empty);

                            RefreshColorBrewerSet();
                        }
                        else
                        {
                            RuleCount.Value = 6;
                            if (!GradientColors.Checked)
                                ColorBrewerColors.Checked = true;

                            if (AggregateCombo.SelectedIndex < 0)
                                AggregateCombo.SelectedIndex = 0;
                            if (AggregateCombo.SelectedIndex == AggregateCombo.Items.Count - 1)
                                AggregateCombo.SelectedIndex = 0;
                        }

                    }
                    else //String type
                    {
                        if (m_values.Count > MAX_INDIVIDUAL_THEME_RULES)
                        {
                            MessageBox.Show(this, string.Format(Strings.TooManyValuesError, MAX_INDIVIDUAL_THEME_RULES), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ColumnCombo.SelectedIndex = 0;
                            return;
                        }

                        RuleCountPanel.Enabled =
                        GroupPanel.Enabled =
                            false;

                        RuleCount.Minimum = 0;

                        //Select "Individual"
                        AggregateCombo.SelectedIndex = AggregateCombo.Items.Count - 1;
                        RuleCount.Value = m_values.Count;
                        GradientColors.Checked = true;

                        DisplayGroup.Enabled =
                        PreviewGroup.Enabled =
                        OKBtn.Enabled =
                            true;
                    }
                }

                RefreshColorBrewerSet();
                RefreshPreview();
            }
        }
 private static IEnumerable<XElement> GetPropertyNodesWithSpecificType(ICollection<XElement> properties, DataPropertyType type)
 {
     return properties.Where(property => string.Equals(XmlTools.GetNamedAttributeValue(property, "type", string.Empty), type.ToString(), StringComparison.InvariantCultureIgnoreCase));
 }
Ejemplo n.º 6
0
 public DataProperty(string name, DataPropertyType type, int?size = null) : this()
 {
     Name = name;
     Type = type;
     Size = size;
 }
 public DataProperty(string id, string value, DataPropertyType propertyType)
 {
     Id = id;
     Value = value;
     PropertyType = propertyType;
 }
Ejemplo n.º 8
0
 private static string GetXmlType(DataPropertyType dataPropertyType)
 {
     switch (dataPropertyType)
     {
         case DataPropertyType.Blob:
             return "xs:hexBinary"; //NOXLATE
         case DataPropertyType.Boolean:
             return "xs:boolean"; //NOXLATE
         case DataPropertyType.Byte:
             return "xs:unsignedByte"; //NOXLATE
         case DataPropertyType.DateTime:
             return "xs:dateTime"; //NOXLATE
         case DataPropertyType.Double:
             return "xs:double"; //NOXLATE
         case DataPropertyType.Int16:
             return "xs:short"; //NOXLATE
         case DataPropertyType.Int32:
             return "xs:int"; //NOXLATE
         case DataPropertyType.Int64:
             return "xs:long"; //NOXLATE
         case DataPropertyType.Single:
             return "xs:float"; //NOXLATE
         case DataPropertyType.String:
             return "xs:string"; //NOXLATE
         case DataPropertyType.Clob:
             return "fdo:clob"; //NOXLATE
         default:
             throw new ArgumentException();
     }
 }
Ejemplo n.º 9
0
 static ExpressionDataType GetExpressionType(DataPropertyType dt)
 {
     switch (dt)
     {
         case DataPropertyType.Blob:
             return ExpressionDataType.Data_Blob;
         case DataPropertyType.Boolean:
             return ExpressionDataType.Data_Boolean;
         case DataPropertyType.Byte:
             return ExpressionDataType.Data_Byte;
         case DataPropertyType.Clob:
             return ExpressionDataType.Data_Clob;
         case DataPropertyType.DateTime:
             return ExpressionDataType.Data_DateTime;
         case DataPropertyType.Double:
             return ExpressionDataType.Data_Double;
         case DataPropertyType.Int16:
             return ExpressionDataType.Data_Int16;
         case DataPropertyType.Int32:
             return ExpressionDataType.Data_Int32;
         case DataPropertyType.Int64:
             return ExpressionDataType.Data_Int64;
         case DataPropertyType.Single:
             return ExpressionDataType.Data_Single;
         case DataPropertyType.String:
             return ExpressionDataType.Data_String;
     }
     throw new ArgumentException();
 }