Esempio n. 1
0
        static void CodePatchMain(string[] args)
        {
            DatabaseConnectionString connectionString = new DatabaseConnectionString();
            connectionString.ServerName = "SERVER14";
            connectionString.DatabaseName = "RMTSv2";
            connectionString.UseIntegratedAuthentication = false;
            connectionString.Username = "******";
            connectionString.Password = "******";

            Database database;

            using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
            {
                connection.Open();

                database = Database.FromConnection(connection);
            }

            Dictionary<string, string> fieldMappings = GetColumnTypeMappings(database);

            Dictionary<string, string> functionMap = new Dictionary<string,string>();
            functionMap["char"] = "FieldCasts.FromChar";
            functionMap["nvarchar"] = "FieldCasts.FromNVarChar";
            functionMap["nchar"] = "FieldCasts.FromNChar";
            functionMap["float"] = "FieldCasts.FromFloat";
            functionMap["real"] = "FieldCasts.FromReal";
            functionMap["datetime"] = "FieldCasts.FromDateTime";
            functionMap["bit"] = "FieldCasts.FromBit";
            functionMap["varchar"] = "FieldCasts.FromVarChar";
            functionMap["text"] = "FieldCasts.FromText";
            functionMap["ntext"] = "FieldCasts.FromNText";
            functionMap["numeric"] = "FieldCasts.FromNumeric";
            functionMap["int"] = "FieldCasts.FromInt";
            functionMap["image"] = "FieldCasts.FromImage";
            functionMap["varbinary"] = "FieldCasts.FromVarBinary";
            functionMap["smallint"] = "FieldCasts.FromSmallInt";
            functionMap["tinyint"] = "FieldCasts.FromTinyInt";

            DirectoryInfo info = new DirectoryInfo(@"C:\Versioning\Haulage");

            FileInfo[] files = info.GetFiles("*.vb", SearchOption.AllDirectories);

            Set<string> unknownFields = new Set<string>();

            foreach (FileInfo file in files)
            {
                using (StreamReader reader = new StreamReader(file.FullName))
                {
                    string entireFile = reader.ReadToEnd();

                    _fields.Replace(entireFile, (MatchEvaluator)delegate(Match match)
                    {
                        Console.WriteLine(match.Value);

                        string characterBeforeIdentifier = match.Groups[1].Value;
                        string recordSetIdentifier = match.Groups[2].Value;
                        string fieldName = match.Groups[3].Value;

                        string converterName = "FieldCasts.Identity";

                        if (fieldMappings.ContainsKey(fieldName.ToLower()))
                        {
                            string fieldType = fieldMappings[fieldName.ToLower()];

                            converterName = functionMap[fieldType];
                        }
                        else
                        {
                            unknownFields.UnionUpdate(fieldName.ToLower());
                        }

                        string replacementText = string.Format("{0}{1}({2}.Fields(\"{3}\").Value)",
                            characterBeforeIdentifier, converterName, recordSetIdentifier, fieldName);

                        Console.WriteLine("    " + replacementText);

                        return replacementText;
                    });
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DatabaseConnectionString connectionString = new DatabaseConnectionString();
            connectionString.ServerName = ".\\SQLEXPRESS";
            connectionString.DatabaseName = "Avance";
            connectionString.UseIntegratedAuthentication = false;
            connectionString.Username = "******";
            connectionString.Password = "******";

            Database database;

            using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
            {
                connection.Open();

                database = Database.FromConnection(connection);
            }

            Plan plan = new Plan(database);

            plan.AddPrecondition("InvoiceLineSource", "CourierJobId");
            plan.AddPrecondition("JobDriverEffort", "JobId");
            plan.AddPrecondition("Transfer", "JobNoteId");
            plan.AddPrecondition("Transfer", "WaypointId");

            Dependencies.CreateDependenciesGraph(database);
        }
Esempio n. 3
0
        private static DatabaseConnectionString ParseConnectionString(string argument)
        {
            Match match = _connectionStringExpression.Match(argument);

            DatabaseConnectionString connectionString = new DatabaseConnectionString();

            if (match.Groups[1].Success)
            {
                connectionString.Username = match.Groups[2].Value;
                connectionString.Password = match.Groups[3].Value;
                connectionString.UseIntegratedAuthentication = false;
            }
            else
            {
                connectionString.UseIntegratedAuthentication = true;
            }

            connectionString.ServerName = match.Groups[4].Value;
            connectionString.DatabaseName = match.Groups[5].Value;
            connectionString.ConnectionTimeout = 10;
            return connectionString;
        }
        private void SetUpDatabaseConnection()
        {
            DatabaseConnectionString connectionString = new DatabaseConnectionString();

            connectionString.ServerName = "SERVER14";
            connectionString.DatabaseName = "Entrust";
            connectionString.Username = "******";
            connectionString.Password = "******";
            connectionString.UseIntegratedAuthentication = false;

            _adapter = new DataAccessAdapter(connectionString.ToString());
        }