Пример #1
0
        private static void Execute(OleDbConnection connection, InputParameters input)
        {
            SetNullsNotOk(connection, input);
            HashSet <string> validLinks = new HashSet <string>();

            foreach (DataRow row in GetNonNullDataRows(connection, input))
            {
                string content = Convert.ToString(row[input.LinkField]);
                string address = AccessInterface.ExtractAddress(content);

                if (File.Exists(address))
                {
                    Console.WriteLine("Yes: " + address);
                    validLinks.Add(content);
                }
                else
                {
                    Console.WriteLine("No: " + address);
                }
            }

            Console.WriteLine("\nExecuting query...");
            string condition = getCondition(input, validLinks);
            string sqlTrue   = $"UPDATE [{input.TableName}] SET [{input.OkField}] = True WHERE {condition}";

            AccessInterface.ExecuteUpdateCommand(connection, sqlTrue);
            string sqlFalse = $"UPDATE [{input.TableName}] SET [{input.OkField}] = False WHERE NOT {condition}";

            AccessInterface.ExecuteUpdateCommand(connection, sqlFalse);
            Console.WriteLine("Query executed");
        }
Пример #2
0
        private static DataRowCollection GetNonNullDataRows(OleDbConnection connection, InputParameters input)
        {
            String           sql         = $"SELECT [{input.LinkField}] FROM [{input.TableName}] WHERE [{input.LinkField}] is not null";
            OleDbDataAdapter dataAdapter = AccessInterface.ExecuteSelectCommand(connection, sql);
            DataSet          dataSet     = new DataSet();

            dataAdapter.Fill(dataSet, input.TableName);
            DataTable table = dataSet.Tables[input.TableName];

            return(table.Rows);
        }
Пример #3
0
        private static void Execute(InputParameters input)
        {
            Console.WriteLine("Trying to connect...");
            OleDbConnection connection = AccessInterface.GetConnection(input.FileName);

            connection.Open();
            Console.WriteLine("Connected.");
            Execute(connection, input);
            //Clean(connection, input, false);
            connection.Close();
        }
Пример #4
0
        private static void Clean(OleDbConnection connection, InputParameters input, bool state)
        {
            string sql = $"UPDATE [{input.TableName}] SET [{input.OkField}] = {state}";

            AccessInterface.ExecuteUpdateCommand(connection, sql);
        }
Пример #5
0
        private static void SetNullsNotOk(OleDbConnection connection, InputParameters input)
        {
            string sql = $"UPDATE [{input.TableName}] SET [{input.OkField}] = False WHERE [{input.LinkField}] is null";

            AccessInterface.ExecuteUpdateCommand(connection, sql);
        }