예제 #1
0
        public static void Migrate()
        {
            AzusaContext   context = AzusaContext.GetInstance();
            PostgresDriver driver  = (PostgresDriver)context.DatabaseDriver;
            List <AttachmentMigrationCandidate> candidates = driver.GetAttachmentMigrationCandidates().ToList();

            driver.BeginTransaction();
            foreach (AttachmentMigrationCandidate candidate in candidates)
            {
                int mid = candidate.MediaId;
                if (candidate.CICM != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.CICM, 11, mid));
                }
                if (candidate.JedecId != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.JedecId, 15, mid));
                }
                if (candidate.MHddLog != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.MHddLog, 12, mid));
                }
                if (candidate.Priv != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.Priv, 14, mid));
                }
                if (candidate.ScsiInfo != null)
                {
                    driver.InsertAttachment(MigrateElement(candidate.ScsiInfo, 13, mid));
                }
            }

            driver.EndTransaction(true);
        }
예제 #2
0
 /// <summary>
 /// PostgreSQL ODBC connection stringet ad vissza.
 /// </summary>
 /// <param name="driver">x64-es, vagy x86-os driverre van szükség?</param>
 /// <returns>PostgreSQL ODBC connection stringet ad vissza.</returns>
 string getConnectionString(PostgresDriver driver)
 {
     if (driver == PostgresDriver.x64)
     {
         return(string.Format("Driver={{PostgreSQL Unicode(x64)}};Server={0};Port={1};Database={2};Uid={3};Pwd={4};", server, port, database, username, password));
     }
     else
     if (driver == PostgresDriver.x86)
     {
         return(string.Format("Driver={{PostgreSQL Unicode}};Server={0};Port={1};Database={2};Uid={3};Pwd={4};", server, port, database, username, password));
     }
     else
     {
         return("");
     }
 }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string connString = "Server=127.0.0.1;Port=5433;Username=Alexandr;Password=1828bd;Database=postgres";
            //string connString = "Host=localhost;Username=Alexandr;Password=1828bd;Database=postgres";
            var conn = new NpgsqlConnection(connString);
            var hashPasswordCreator = new HashPasswordCreator();

            try
            {
                var driver = new PostgresDriver(conn);
                Application.Run(new MainForm(driver, hashPasswordCreator));
                driver.StopPostgresServer();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Сообщение об ошибке", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }