Example #1
0
        /// <summary>
        /// Gets the connect time property.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public DictionaryProperty GetConnectTimeProperty(string name)
        {
            if (this.State != FdoConnectionState.Open && this.State != FdoConnectionState.Pending)
            {
                throw new InvalidOperationException(Res.GetString("ERR_CONNECTION_NOT_OPEN"));
            }

            IConnectionPropertyDictionary dict = this.InternalConnection.ConnectionInfo.ConnectionProperties;
            bool enumerable       = dict.IsPropertyEnumerable(name);
            DictionaryProperty dp = null;

            if (enumerable)
            {
                EnumerableDictionaryProperty ep = new EnumerableDictionaryProperty();
                ep.Values = dict.EnumeratePropertyValues(name);
                dp        = ep;
            }
            else
            {
                dp = new DictionaryProperty();
            }

            dp.Name          = name;
            dp.LocalizedName = dict.GetLocalizedName(name);
            dp.DefaultValue  = dict.GetPropertyDefault(name);
            dp.Protected     = dict.IsPropertyProtected(name);
            dp.Required      = dict.IsPropertyRequired(name);

            return(dp);
        }
Example #2
0
        public static NameValueCollection GetParameters(string title, IConnectionPropertyDictionary dict)
        {
            DictionaryDialog diag = new DictionaryDialog(dict);

            diag.Text = title;
            if (diag.ShowDialog() == DialogResult.OK)
            {
                return(diag.GetProperties());
            }
            return(null);
        }
Example #3
0
        public override int Execute()
        {
            CommandStatus retCode;

            IConnection conn = null;

            try
            {
                conn = FeatureAccessManager.GetConnectionManager().CreateConnection(_provider);
            }
            catch (OSGeo.FDO.Common.Exception ex)
            {
                WriteException(ex);
                return((int)CommandStatus.E_FAIL_CREATE_CONNECTION);
            }

            IConnectionPropertyDictionary dict = conn.ConnectionInfo.ConnectionProperties;

            Console.WriteLine("Connection properties for: {0}", _provider);
            foreach (string name in dict.PropertyNames)
            {
                Console.WriteLine("\nProperty Name: {0}\n\n\tLocalized Name: {1}", name, dict.GetLocalizedName(name));
                Console.WriteLine("\tRequired: {0}\n\tProtected: {1}\n\tEnumerable: {2}",
                                  dict.IsPropertyRequired(name),
                                  dict.IsPropertyProtected(name),
                                  dict.IsPropertyEnumerable(name));
                if (dict.IsPropertyEnumerable(name))
                {
                    Console.WriteLine("\tValues for property:");
                    try
                    {
                        string[] values = dict.EnumeratePropertyValues(name);
                        foreach (string str in values)
                        {
                            Console.WriteLine("\t\t- {0}", str);
                        }
                    }
                    catch (OSGeo.FDO.Common.Exception)
                    {
                        Console.Error.WriteLine("\t\tProperty values not available");
                    }
                }
            }
            retCode = CommandStatus.E_OK;
            return((int)retCode);
        }
Example #4
0
        public DictionaryDialog(IConnectionPropertyDictionary dict)
            : this()
        {
            foreach (string name in dict.PropertyNames)
            {
                string localized    = dict.GetLocalizedName(name);
                bool   required     = dict.IsPropertyRequired(name);
                bool   enumerable   = dict.IsPropertyEnumerable(name);
                string defaultValue = dict.GetPropertyDefault(name);

                string[] values = dict.EnumeratePropertyValues(name);

                if (required)
                {
                    if (enumerable)
                    {
                        DataGridViewRow row = AddRequiredEnumerableProperty(localized, defaultValue, values);
                        if (values.Length > 0)
                        {
                            row.Cells[1].Value = values[0];
                        }
                    }
                    else
                    {
                        AddRequiredProperty(localized, defaultValue);
                    }
                }
                else
                {
                    if (enumerable)
                    {
                        AddOptionalEnumerableProperty(localized, defaultValue, values);
                    }
                    else
                    {
                        AddProperty(localized, defaultValue);
                    }
                }
            }
        }
Example #5
0
        public static IConnection SDFConnection(string SDFFile)
        {
            try
            {
                Debug.Write("\nSDF File to connect: >> " + SDFFile + "\n");
                //first get an instance of the connection manager
                IConnectionManager connman = FeatureAccessManager.GetConnectionManager();
                con = connman.CreateConnection("OSGeo.SDF");


                //check connection state

                //get connection dictionary
                IConnectionPropertyDictionary props = con.ConnectionInfo.ConnectionProperties;

                props.SetProperty("File", SDFFile);
                props.SetProperty("ReadOnly", "FALSE");

                if (con.ConnectionState == OSGeo.FDO.Connections.ConnectionState.ConnectionState_Open)
                {
                    con.Close();
                }
            }
            catch (OSGeo.FDO.Common.Exception ge)
            {
                bool ok = ge.Message.Contains("read-only");
                Debug.Write(ge.ToString());
            }
            catch (SystemException ex)
            {
                bool ok = ex.Message.Contains("read-only");
                Debug.Write(ex.ToString());
            }

            return(con);
        }
        public DictionaryDialog(IConnectionPropertyDictionary dict)
            : this()
        {
            foreach (string name in dict.PropertyNames)
            {
                string localized = dict.GetLocalizedName(name);
                bool required = dict.IsPropertyRequired(name);
                bool enumerable = dict.IsPropertyEnumerable(name);
                string defaultValue = dict.GetPropertyDefault(name);

                string[] values = dict.EnumeratePropertyValues(name);

                if (required)
                {
                    if (enumerable)
                    {
                        DataGridViewRow row = AddRequiredEnumerableProperty(localized, defaultValue, values);
                        if(values.Length > 0)
                            row.Cells[1].Value = values[0];
                    }
                    else
                        AddRequiredProperty(localized, defaultValue);
                }
                else
                {
                    if (enumerable)
                        AddOptionalEnumerableProperty(localized, defaultValue, values);
                    else
                        AddProperty(localized, defaultValue);
                }
            }
        }
 public static NameValueCollection GetParameters(string title, IConnectionPropertyDictionary dict)
 {
     DictionaryDialog diag = new DictionaryDialog(dict);
     diag.Text = title;
     if (diag.ShowDialog() == DialogResult.OK)
     {
         return diag.GetProperties();
     }
     return null;
 }
Example #8
0
        public static string addSchemtoSDF(string SDFFile, string schemaName, string schemaDesc)
        {
            try
            {
                FeatureSchema      schema1    = new FeatureSchema(schemaName, schemaDesc);
                IConnectionManager conmanager = FeatureAccessManager.GetConnectionManager();

                //sdf fdo connection
                using (IConnection connect = SDFConnection(SDFFile))
                {
                    //get connection dict
                    IConnectionPropertyDictionary conprop = connect.ConnectionInfo.ConnectionProperties;

                    connect.Open();

                    //check connection state
                    OSGeo.FDO.Connections.ConnectionState connstate = connect.ConnectionState;
                    if (connstate != OSGeo.FDO.Connections.ConnectionState.ConnectionState_Open)
                    {
                        result = "\nCannot read SDF File \n" + SDFFile;
                    }
                    else
                    {
                        //add spatial context to the schema
                        SDF.SDFSchemaManager.spatial_context(connect);

                        result = "Read SDF File \n" + SDFFile;

                        //create command to alter schema
                        IApplySchema applyschema = (IApplySchema)connect.CreateCommand(CommandType.CommandType_ApplySchema) as IApplySchema;

                        //FeatureClassCollection fcoll;
                        ClassCollection fcoll = schema1.Classes;

                        //create all feature class
                        FeatureClass class_points     = new FeatureClass("Points", "Point information");
                        FeatureClass class_alignment  = new FeatureClass("Alignments", "Alignment information");
                        FeatureClass class_parcels    = new FeatureClass("Parcels", "Parcels information");
                        FeatureClass class_pipes      = new FeatureClass("Pipes", "Pipes information");
                        FeatureClass class_structures = new FeatureClass("Structures", "Structures information");

                        //add properties here
                        Schema_manager.add_property(class_points, connect);
                        Schema_manager.add_property(class_alignment, connect);
                        Schema_manager.add_property(class_parcels, connect);
                        Schema_manager.add_property(class_pipes, connect);
                        Schema_manager.add_property(class_structures, connect);

                        schema1.Classes.Add(class_points);
                        schema1.Classes.Add(class_alignment);
                        schema1.Classes.Add(class_parcels);
                        schema1.Classes.Add(class_pipes);
                        schema1.Classes.Add(class_structures);

                        //create property definition for each feature class

                        applyschema.FeatureSchema = schema1;
                        applyschema.Execute();
                        result = "Successfully Created SDF file with blank Schema \n" + SDFFile;
                    }
                    connect.Close();
                }
            }
            catch (SystemException ex)
            {
            }
            return(result);
        }