public static Task <string[]> GetDescriptions(DatabaseConnectionProperties dbconnprop, string table_name)
 {
     return(Task.Run(new Func <string[]>(() =>
     {
         List <string> descriptions = new List <string>();
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand cmdName = new MySqlCommand("select description from `" + table_name + "`", sqlconn))
                 using (MySqlDataReader reader = cmdName.ExecuteReader())
                     while (reader.Read())
                     {
                         if (reader.IsDBNull(0))
                         {
                             descriptions.Add(null);
                         }
                         else
                         {
                             descriptions.Add(reader.GetString(0));
                         }
                     }
         }
         return descriptions.ToArray();
     })));
 }
        public MainForm()
        {
            InitializeComponent();

            dbconnprop = new DatabaseConnectionProperties("mccsrv0", null, "accesscontrol", "MaMCaq9Jb3fvVr7d");

            try
            {
                if (File.Exists("appstate.bin"))
                {
                    FileStream      fstream    = new FileStream("appstate.bin", FileMode.Open);
                    BinaryFormatter bFormatter = new BinaryFormatter();

                    dbconnprop        = (DatabaseConnectionProperties)bFormatter.Deserialize(fstream);
                    expander_monitors = (List <ExpanderMonitor>)bFormatter.Deserialize(fstream);
                    panel_monitors    = (List <PanelMonitor>)bFormatter.Deserialize(fstream);

                    control_groups = (List <AccessControlGroup>)bFormatter.Deserialize(fstream);

                    fstream.Close();
                }
            }
            catch (Exception ex)
            {
                ErrorLogManager.AppendLog("Failed To Read Configuration From File", true);

                try{ File.Delete("appstate.bin"); }
                catch (Exception ex2) { ErrorLogManager.AppendLog("Failed To Delete Configuration File", true); }
            }

            AccessControlLogManager.DatabaseConnectionProperties = dbconnprop;

            ErrorLogManager.AppendLog("Application Initialized", true);
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //accept button
            dbconnprop = DatabaseConnectionProperties.FromArray(GetTextBoxStrings());

            DialogResult = DialogResult.OK;
        }
Example #4
0
        public static void Perform(string[] args, DatabaseConnectionProperties databaseProperties, SyrinxProperties syrinxProperties, Assembly assembly,
                                   Action <IServiceCollection> serviceHandler = null)
        {
            var parser = new Parser(settings => settings.CaseInsensitiveEnumValues = true);

            parser.ParseArguments <CamundaDeploymentToolOptions>(args)
            .WithParsed(options =>
            {
                var serviceCollection = CreateServices(databaseProperties, syrinxProperties, assembly);
                serviceHandler?.Invoke(serviceCollection);
                using var scope = serviceCollection.BuildServiceProvider(false).CreateScope();
                var service     = scope.ServiceProvider.GetRequiredService <ICamundaDeploymentService>();

                switch (options.Action)
                {
                case MigrationAction.Upgrade:
                    service.Upgrade();
                    break;

                case MigrationAction.Rollback:
                    service.DowngradeToPrevious();
                    break;

                case MigrationAction.Downgrade:
                    service.Downgrade();
                    break;

                default:
                    throw CommonExceptions.CamundaCouldNotBeDeployed();
                }
            })
            .WithNotParsed(_ => throw CommonExceptions.CamundaCouldNotBeDeployed());
        }
Example #5
0
        private async Task addFeatureLayer()
        {
            await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
            {
                ArcGIS.Core.Data.DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.PostgreSQL)
                {
                    AuthenticationMode = AuthenticationMode.DBMS,
                    Instance           = @"127.0.0.1",
                    Database           = "geomapmaker",
                    User     = "******",
                    Password = "******",
                    //Version = "dbo.DEFAULT"
                };

                using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                {
                    // Use the geodatabase
                    CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
                    {
                        WorkspaceConnectionString = geodatabase.GetConnectionString(),
                        GeometryType = esriGeometryType.esriGeometryPoint,
                        OIDFields    = "OBJECTID",
                        Srid         = "4326",
                        SqlQuery     = "select * from public.features where user_id = " + DataHelper.userID + " and ST_GeometryType(geom)='ST_Point'",
                        Dataset      = "features"
                    };
                    featureLayer = (FeatureLayer)LayerFactory.Instance.CreateLayer(sqldc, MapView.Active.Map, layerName: DataHelper.userName + "'s points");
                }
            });
        }
Example #6
0
 public AltMonitor(ExpanderMonitor expmon, List <PanelMonitor> pnlmons, DatabaseConnectionProperties dbconnprop, string table_name)
 {
     this.expmon     = expmon;
     this.pnlmons    = pnlmons;
     this.dbconnprop = dbconnprop;
     this.table_name = table_name;
 }
Example #7
0
        private Task addFeatureLayer()
        {
            Debug.WriteLine("addFeatureLayer enter");

            return(ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
            {
                ArcGIS.Core.Data.DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.PostgreSQL)
                {
                    AuthenticationMode = AuthenticationMode.DBMS,
                    Instance = @"127.0.0.1",
                    Database = "geomapmaker2",
                    User = "******",
                    Password = "******",
                    //Version = "dbo.DEFAULT"
                };

                using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                {
                    using (FeatureClass featureClass = geodatabase.OpenDataset <FeatureClass>("geomapmaker2.geomapmaker2.line_features"))
                    {
                        var layerParamsQueryDefn = new FeatureLayerCreationParams(featureClass)
                        {
                            IsVisible = true,
                            DefinitionFilter = new CIMDefinitionFilter()
                            {
                                Name = "User",
                                DefinitionExpression = "user_id = " + DataHelper.userID
                            }
                        };
                        featureLayer = LayerFactory.Instance.CreateLayer <FeatureLayer>(layerParamsQueryDefn, MapView.Active.Map);
                    }
                }
            }));
        }
        private async Task openDatabase(JObject props)
        {
            await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
            {
                //Get Layers that are NOT Group layers and are unchecked
                //var layers = MapView.Active.Map.Layers.ToList();
                //MapView.Active.Map.RemoveLayers(layers);

                // Opening a Non-Versioned SQL Server instance.
                ArcGIS.Core.Data.DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.PostgreSQL)
                {
                    AuthenticationMode = AuthenticationMode.DBMS,

                    // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
                    //Instance = @"127.0.0.1",
                    Instance = props["instance"].ToString(),

                    // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
                    //Database = "geomapmaker",
                    Database = props["database"].ToString(),

                    // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
                    //User = "******",
                    User = props["user"].ToString(),
                    //Password = "******",
                    Password = props["password"].ToString(),
                    //Version = "dbo.DEFAULT"
                };

                using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                {
                    DataHelper.connectionString = geodatabase.GetConnectionString();
                    Debug.WriteLine("DataHelper.connectionString set to " + DataHelper.connectionString);

                    // Use the geodatabase

                    /*
                     * CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
                     * {
                     *  WorkspaceConnectionString = geodatabase.GetConnectionString(),
                     *  GeometryType = esriGeometryType.esriGeometryPoint,
                     *  OIDFields = "OBJECTID",
                     *  Srid = "4326",
                     *  //SqlQuery = "select * from geomapmaker2.features where id = " + DataHelper.userID + " and ST_GeometryType(geom)='ST_Point'",
                     *  Dataset = "somepoints"
                     * };
                     * FeatureLayer flyr = (FeatureLayer)LayerFactory.Instance.CreateLayer(sqldc, MapView.Active.Map, layerName: DataHelper.userName + "'s points");
                     */
                    //FeatureClass fC = geodatabase.OpenDataset<FeatureClass>("somepoints");
                    //FeatureLayer flyr = LayerFactory.Instance.CreateFeatureLayer(fC, MapView.Active.Map);
                    var featureClasses = geodatabase.GetDefinitions <FeatureClassDefinition>();
                    foreach (FeatureClassDefinition fCD in featureClasses)
                    {
                        FeatureClass fC   = geodatabase.OpenDataset <FeatureClass>(fCD.GetName());
                        FeatureLayer flyr = LayerFactory.Instance.CreateFeatureLayer(fC, MapView.Active.Map);
                    }
                }
            });
        }
        private void databaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DatabaseConnectionForm dbconfm = new DatabaseConnectionForm(dbconnprop);

            dbconfm.ShowDialog(this);
            dbconnprop = dbconfm.DBConnProp;
            dbconfm.Dispose();
        }
Example #10
0
        public ImportForm(DatabaseConnectionProperties dbconnprop)
        {
            InitializeComponent();

            this.dbconnprop = dbconnprop;

            RefreshTableNames();
        }
Example #11
0
        Dictionary <string, bool> GetFeatureClassExistsMap(ProSymbolUtilities.SupportedStandardsType standard,
                                                           Geodatabase gdb = null)
        {
            EGDBPrefixName        = string.Empty;
            _egdbConnectionString = string.Empty;

            if (gdb != null)
            {
                GeodatabaseType gdbType = gdb.GetGeodatabaseType();
                if (gdbType == GeodatabaseType.RemoteDatabase)
                {
                    // if an SDE/EGDB, then feature class name format will differ:
                    // Database + User + Feature Class Name
                    DatabaseConnectionProperties dbcps = gdb.GetConnector() as DatabaseConnectionProperties;

                    if (dbcps != null)
                    {
                        EGDBPrefixName = dbcps.Database + "." + dbcps.User + ".";

                        // Also save this connection string to identify this EGDB later
                        _egdbConnectionString = ((Datastore)gdb).GetConnectionString();
                    }
                }
            }

            Dictionary <string, bool> featureClassExists = new Dictionary <string, bool>();

            List <SymbolSetMapping> symbolSetMapping = null;

            switch (standard)
            {
            case ProSymbolUtilities.SupportedStandardsType.app6b: symbolSetMapping = _symbolSetMappingAPP6B; break;

            case ProSymbolUtilities.SupportedStandardsType.app6d: symbolSetMapping = _symbolSetMappingAPP6D; break;

            case ProSymbolUtilities.SupportedStandardsType.mil2525b: symbolSetMapping = _symbolSetMapping2525B; break;

            case ProSymbolUtilities.SupportedStandardsType.mil2525c: symbolSetMapping = _symbolSetMapping2525C; break;

            default:
                symbolSetMapping = _symbolSetMapping2525D;
                break;
            }

            foreach (SymbolSetMapping mapping in symbolSetMapping)
            {
                string featureClassName = EGDBPrefixName + mapping.FeatureClassName;

                if (!featureClassExists.ContainsKey(featureClassName))
                {
                    featureClassExists.Add(featureClassName, false);
                }
            }

            return(featureClassExists);
        }
Example #12
0
        public AccessPropertiesEditor(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid)
        {
            InitializeComponent();

            this.dbconnprop = dbconnprop;
            this.table_name = table_name;
            this.uid        = uid;

            this.Text = table_name + " - " + uid;
        }
        public DatabaseConnectionForm(DatabaseConnectionProperties dbprop)
        {
            InitializeComponent();

            this.dbprop = new DatabaseConnectionProperties(dbprop);

            textBox1.Text = dbprop.Hostname;
            textBox2.Text = dbprop.UID;
            textBox3.Text = dbprop.Password;
        }
        public GroupListForm(List <ExpanderMonitor> expmons, List <PanelMonitor> pnlmons, List <AccessControlGroup> acctlgp, DatabaseConnectionProperties dbconnprop)
        {
            InitializeComponent();

            this.expmons    = expmons;
            this.pnlmons    = pnlmons;
            this.acctlgp    = acctlgp;
            this.dbconnprop = dbconnprop;

            listBox1.DataSource = acctlgp;
        }
Example #15
0
        /// <summary>
        /// Illustrates deleting rows from a table in an enterprise geodatabase.
        /// </summary>
        /// <returns></returns>
        private static async Task EnterpriseGeodabaseWorkFlow()
        {
            // Opening a Non-Versioned SQL Server instance.

            DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
            {
                AuthenticationMode = AuthenticationMode.DBMS,

                // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
                Instance = @"testMachine\testInstance",

                // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
                Database = "LocalGovernment",

                // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
                User     = "******",
                Password = "******",
                Version  = "dbo.DEFAULT"
            };

            using (Geodatabase geodatabase = new Geodatabase((connectionProperties)))
            {
                using (Table enterpriseTable = geodatabase.OpenDataset <Table>("LocalGovernment.GDB.piCIPCost"))
                {
                    EditOperation editOperation = new EditOperation();
                    editOperation.Callback(context =>
                    {
                        QueryFilter openCutFilter = new QueryFilter {
                            WhereClause = "ACTION = 'Open Cut'"
                        };

                        using (RowCursor rowCursor = enterpriseTable.Search(openCutFilter, false))
                        {
                            while (rowCursor.MoveNext())
                            {
                                using (Row row = rowCursor.Current)
                                {
                                    // In order to update the Map and/or the attribute table. Has to be called before the delete
                                    context.Invalidate(row);

                                    row.Delete();
                                }
                            }
                        }
                    }, enterpriseTable);

                    bool editResult = editOperation.Execute();

                    // If the table is non-versioned this is a no-op. If it is versioned, we need the Save to be done for the edits to be persisted.

                    bool saveResult = await Project.Current.SaveEditsAsync();
                }
            }
        }
 public static Task <bool> ContainsUID(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid)
 {
     return(Task.Run(() =>
     {
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             return ContainsUID(sqlconn, table_name, uid);
         }
     }));
 }
 public static Task DeleteRow(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid)
 {
     return(Task.Run(() =>
     {
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand sqlcmd = new MySqlCommand("delete from `" + table_name + "` where uid=" + uid, sqlconn))
                 sqlcmd.ExecuteNonQuery();
         }
     }));
 }
        /// <summary>
        /// Since the LocalGovernment Geodatabase does not have AttributedRelationshipClasses, the following method illustrates the behavior
        /// if such a dataset existed.
        /// </summary>
        public void MainMethodCode()
        {
            // Opening a Non-Versioned SQL Server instance.

            DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
            {
                AuthenticationMode = AuthenticationMode.DBMS,

                // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
                Instance = @"testMachine\testInstance",

                // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
                Database = "LocalGovernment",

                // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
                User     = "******",
                Password = "******",
                Version  = "dbo.DEFAULT"
            };

            using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                using (AttributedRelationshipClass attributedRelationshipClass = geodatabase.OpenDataset <AttributedRelationshipClass>("LocalGovernment.GDB.ParcelToBuilding"))
                    using (FeatureClass parcelFeatureClass = geodatabase.OpenDataset <FeatureClass>("LocalGovernment.GDB.Parcel"))
                        using (FeatureClass buildingFeatureClass = geodatabase.OpenDataset <FeatureClass>("LocalGovernment.GDB.Building"))
                        {
                            QueryFilter parcelQueryFilter = new QueryFilter {
                                WhereClause = "APN = 1234 OR APN = 5678"
                            };
                            QueryFilter buildingQueryFilter = new QueryFilter {
                                WhereClause = "BUILDID = 4321 OR BUILDID = 8765"
                            };

                            Selection parcelsSelection  = parcelFeatureClass.Select(parcelQueryFilter, SelectionType.ObjectID, SelectionOption.Normal);
                            Selection buildingSelection = buildingFeatureClass.Select(buildingQueryFilter, SelectionType.ObjectID, SelectionOption.Normal);

                            IReadOnlyList <AttributedRelationship> relationshipsForOrigin      = null;
                            IReadOnlyList <AttributedRelationship> relationshipsForDestination = null;

                            try
                            {
                                relationshipsForOrigin      = attributedRelationshipClass.GetRelationshipsForOriginRows(parcelsSelection.GetObjectIDs());
                                relationshipsForDestination = attributedRelationshipClass.GetRelationshipsForDestinationRows(buildingSelection.GetObjectIDs());
                            }
                            finally
                            {
                                Dispose(relationshipsForOrigin);
                                Dispose(relationshipsForDestination);
                            }
                        }
        }
Example #19
0
 private static IServiceCollection CreateServices(DatabaseConnectionProperties databaseProperties, SyrinxProperties syrinxProperties, Assembly assembly) => new ServiceCollection()
 .AddSingleton <ILoggerStore>(factory => new LoggerStore(databaseProperties.LogStoreConnectionString, Scope))
 .AddSingleton(factory => new CamundaDeploymentParameters
 {
     Assembly = assembly
 })
 .AddScoped <IOperationService>(factory =>
 {
     var loggerStore = factory.GetService <ILoggerStore>();
     var dataStoreConnectionString = databaseProperties.DataStoreConnectionString;
     return(new OperationService(loggerStore, dataStoreConnectionString, Scope));
 })
 .AddScoped <ISyrinxCamundaClientService>(factory => new SyrinxCamundaClientService(syrinxProperties))
 .AddScoped <ICamundaDeploymentService, CamundaDeploymentService>();
        public static Task RenameTable(DatabaseConnectionProperties dbconnprop, string original_table_name, string new_table_name)
        {
            return(Task.Run(() =>
            {
                using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
                {
                    string cmdstr = "RENAME TABLE `accesscontrol`.`" + original_table_name + "` TO `" + new_table_name + "`;";
                    sqlconn.Open();

                    using (MySqlCommand sqlcmd = new MySqlCommand(cmdstr, sqlconn))
                        sqlcmd.ExecuteNonQuery();
                }
            }));
        }
        public static Task CreateTable(DatabaseConnectionProperties dbconnprop, string table_name)
        {
            return(Task.Run(() =>
            {
                using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
                {
                    string cmdstr = "CREATE TABLE `accesscontrol`.`" + table_name + "` (`uid` BIGINT NOT NULL COMMENT '',`description` VARCHAR(255) NULL COMMENT '',`notes` BLOB NULL COMMENT '',`data` BLOB NULL COMMENT '',PRIMARY KEY (`uid`)  COMMENT '');";
                    sqlconn.Open();

                    using (MySqlCommand sqlcmd = new MySqlCommand(cmdstr, sqlconn))
                        sqlcmd.ExecuteNonQuery();
                }
            }));
        }
 public static Task SetDescription(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid, string description)
 {
     return(Task.Run(() =>
     {
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand cmdName = new MySqlCommand("update `" + table_name + "` set description = @description where uid=" + uid, sqlconn))
             {
                 cmdName.Parameters.AddWithValue("@description", description);
                 cmdName.ExecuteNonQuery();
             }
         }
     }));
 }
 public static Task SetAccessProperties(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid, AccessProperties accessprops)
 {
     return(Task.Run(() =>
     {
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand cmdName = new MySqlCommand("update `" + table_name + "` set data = @data where uid=" + uid, sqlconn))
             {
                 cmdName.Parameters.AddWithValue("@data", accessprops == null ? null : Utilities.ConvertObjectToByteArray <AccessProperties>(accessprops));
                 cmdName.ExecuteNonQuery();
             }
         }
     }));
 }
        public static Task DeleteTable(DatabaseConnectionProperties dbconnprop, string table_name)
        {
            return(Task.Run(() =>
            {
                using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
                {
                    sqlconn.Open();

                    using (MySqlCommand sqlcmd = new MySqlCommand("drop table `" + table_name + "`", sqlconn))
                        sqlcmd.ExecuteNonQuery();

                    sqlconn.Close();
                }
            }));
        }
Example #25
0
        private async void databaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dbconnprop = DatabaseConnectionProperties.FromArray(GetTextBoxStrings());

            MCv2Persistance.Instance.Config.DatabaseConfiguration.DatabaseConnectionProperties = dbconnprop;

            List <string> files_to_import = new List <string>();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Multiselect      = true;
                ofd.Filter           = "Supported Extentions (*.db2bak)|*.db2bak";
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                ofd.FileName         = "";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    files_to_import.AddRange(ofd.FileNames);
                }
            }

            if (files_to_import.Count() == 0)
            {
                return;
            }

            ProgressDialog pgd = new ProgressDialog("Restoring Database");

            pgd.Show();
            pgd.SetMarqueeStyle();

            foreach (var file in files_to_import)
            {
                pgd.LabelText = "Processing " + file;

                try
                {
                    await DBBackupAndRestore.Restore(file, DatabaseConnectionProperties.FromArray(GetTextBoxStrings()));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured while restoring from " + file + ".");
                }
            }

            pgd.Dispose();
        }
Example #26
0
        public DatabaseConnectionEditor(DatabaseConnectionProperties dbconnprop, bool IsCancellable)
        {
            this.dbconnprop = dbconnprop;

            InitializeComponent();

            if (File.Exists("auto_backup.db2bak"))
            {
                restoreDBFromAutosaveToolStripMenuItem.Enabled = true;
            }

            if (!IsCancellable)
            {
                button2.Enabled = false;
            }

            tbs = new TextBox[] { textBox1, textBox4, textBox2, textBox3 };

            text_change_handler = new EventHandler(HandleTextChanged);

            tb_background_checker = new Task(async() =>
            {
                tb_bg_check_active = true;

                await TestTextBoxValues();

                DateTime last_check = DateTime.Now;
                while (tb_bg_check_active)
                {
                    while (DateTime.Now - last_check < tb_bg_check_ival)
                    {
                        if (!tb_bg_check_active)
                        {
                            return;
                        }
                        else
                        {
                            await Task.Delay(250);
                        }
                    }

                    await TestTextBoxValues();

                    last_check = DateTime.Now;
                }
            });
        }
        public void MainMethodCode()
        {
            // Opening a Non-Versioned SQL Server instance.

            DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
            {
                AuthenticationMode = AuthenticationMode.DBMS,

                // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
                Instance = @"testMachine\testInstance",

                // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
                Database = "LocalGovernment",

                // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
                User     = "******",
                Password = "******",
                Version  = "dbo.DEFAULT"
            };

            using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
                using (FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition <FeatureClassDefinition>("LocalGovernment.GDB.ServiceRequestComment"))
                {
                    int   rankIndex = featureClassDefinition.FindField("RANK");
                    Field field     = featureClassDefinition.GetFields()[rankIndex];

                    Domain domain = field.GetDomain();

                    RangeDomain rangeDomain = (RangeDomain)domain;

                    // Will be "ServiceRequestRanking".
                    string name = rangeDomain.GetName();

                    // Will be FieldType.Integer.
                    FieldType fieldType = rangeDomain.GetFieldType();

                    // Will be "A factor assigned to unassigned service requests indicating importance".
                    string description = rangeDomain.GetDescription();

                    // Will be 1.
                    int minValue = Convert.ToInt32(rangeDomain.GetMinValue());

                    // Will be 5.
                    int maxValue = Convert.ToInt32(rangeDomain.GetMaxValue());
                }
        }
 public static Task <UInt64[]> GetUIDs(DatabaseConnectionProperties dbconnprop, string table_name)
 {
     return(Task.Run(new Func <UInt64[]>(() =>
     {
         List <UInt64> uids = new List <UInt64>();
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand cmdName = new MySqlCommand("select uid from `" + table_name + "`", sqlconn))
                 using (MySqlDataReader reader = cmdName.ExecuteReader())
                     while (reader.Read())
                     {
                         uids.Add(reader.GetUInt64(0));
                     }
         }
         return uids.ToArray();
     })));
 }
 public static Task AddRow(DatabaseConnectionProperties dbconnprop, string table_name, UInt64 uid, string description, string[] notes, AccessProperties accessprop)
 {
     return(Task.Run(() =>
     {
         using (MySqlConnection sqlconn = new MySqlConnection(dbconnprop.ConnectionString))
         {
             sqlconn.Open();
             using (MySqlCommand sqlcmd = new MySqlCommand("insert into `" + table_name + "` (uid, description, notes, data) values (@uid, @description, @notes, @data)", sqlconn))
             {
                 sqlcmd.Parameters.AddWithValue("@uid", uid);
                 sqlcmd.Parameters.AddWithValue("@description", description);
                 sqlcmd.Parameters.AddWithValue("@notes", notes == null ? null : Utilities.ConvertObjectToByteArray <string[]>(notes));
                 sqlcmd.Parameters.AddWithValue("@data", accessprop == null ? null : Utilities.ConvertObjectToByteArray <AccessProperties>(accessprop));
                 sqlcmd.ExecuteNonQuery();
             }
         }
     }));
 }
        private static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.Error.WriteLine("Error: No se han especificado parámetros.");
                Console.Error.WriteLine("El formato es: MuestraAtributosBBDDGeometriasArchivoBinD.exe [tabla de códigos] [base de datos.mdb] [archivo bin a enumerar]");
                Console.Error.WriteLine("Ejemplo: MuestraAtributosBBDDGeometriasArchivoBinD.exe prueba.Tab.xml prueba.mdb prueba.bind");
                return;
            }

            try
            {
                var tabla = DigiTab.Load(args[0]);

                var parámetrosbbdd = new DatabaseConnectionProperties
                {
                    ConnectionString = $"Provider=Microsoft.ACE.OLEDB.16.0;Data Source={args[1]};Persist Security Info=False",
                    DataModel        = "CATDBS"
                };

                using (var archivoEntrada = new BinDouble(args[2], parámetrosbbdd, tabla))
                {
                    foreach (var entidad in archivoEntrada)
                    {
                        var atributos = archivoEntrada.GetDatabaseAttributes(entidad);

                        foreach (var código in entidad.Codes)
                        {
                            foreach (var clave in atributos[código.Name])
                            {
                                Console.WriteLine($"{clave.Key}: {clave.Value}");
                            }
                        }

                        Console.Write("-----------------");
                    }
                }
            }
            catch (Exception excepción)
            {
                Console.Error.WriteLine("Se localizó el siguiente error:");
                Console.Error.WriteLine(excepción.Message);
            }
        }