Beispiel #1
0
        private void GetFileDetailsInDB(string fileName, int rowsReturned, string upload)
        {
            Logger.Info("Verifying database for file deatils");
            int numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(rowsReturned, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT FileName,Created_at,Updated_by,Version FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);

            Logger.Info("Checking " + upload + " file name and versions in database");
            if (upload == "Initial Upload")
            {
                Assert.AreEqual(output[0].firstColumn, fileName);
                Assert.AreEqual(Convert.ToInt16(output[0].forthColumn), 1);
                Assert.AreEqual(output[0].thirdColumn, "ECO Operations");
            }
            else if (upload == "Duplicate Upload")
            {
                Assert.AreEqual(output[0].firstColumn, fileName);
                Assert.AreEqual(output[1].firstColumn, fileName);
                Assert.AreEqual(Convert.ToInt16(output[0].forthColumn), 2);
                Assert.AreEqual(Convert.ToInt16(output[1].forthColumn), 1);
                Assert.AreEqual(output[0].thirdColumn, "ECO Operations");
                Assert.AreEqual(output[1].thirdColumn, "ECO Operations");
            }
            string todaysDate          = DateTime.Now.ToString("M/d/yyyy");
            string dateRetrievedFromDB = output[0].secondColumn;

            Assert.AreEqual(todaysDate, dateRetrievedFromDB.Split(' ')[0]);
        }
Beispiel #2
0
        public void ThenFileWillNotBeProcessed(string p0)
        {
            Logger.Info("Verifying file " + p0 + " is not in Documents Database");
            string nameOfFile = WhichFile(p0);
            int    numOfRows  = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename like '%" + nameOfFile + "%'; ", DatabaseName.Documents);

            Assert.AreEqual(0, numOfRows);
        }
Beispiel #3
0
 public MySQLHelper()
 {
     dbConnectHelper = DBConnectHelper.Instance;
     connection      = new MySqlConnection(
         "Server=" + dbConnectHelper.IP + ";" +
         "Port=" + dbConnectHelper.Port + ";" +
         "Database=" + dbConnectHelper.Schema + ";" +
         "Uid=" + dbConnectHelper.User + ";" +
         "Pwd=" + dbConnectHelper.Pass + ";"
         );
 }
Beispiel #4
0
        public void ThenUploadWillNotBeDoneAndFileRecordWillNotBeCreatedAgain()
        {
            string fileName  = Path.GetFileName(validFile);
            int    numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(1, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT Version FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);

            Assert.AreEqual(1, output.Count);
            Assert.AreEqual(1, Convert.ToInt16(output[0].firstColumn));
        }
Beispiel #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //数据库连接
            var connectionString = ConfigurationManager.ConnectionStrings["DataConnectionString"].ConnectionString;

            DBConnectHelper.SetConnection(connectionString);

            Application.Run(new MainForm());
        }
Beispiel #6
0
        public void ThenFileStatusShouldUpdateToRejectionWithOptionToStartAgain()
        {
            //Implement front end part here before below code
            int rowReturned = DBConnectHelper.RowReturnedQuery("Select * from ECO.MeasuresProcessingError where FileName" +
                                                               " ='MP_311204_December2018_Measure_Processing_Errors.csv' and StatusProcessingError = 5", DatabaseName.ECO);

            Assert.AreEqual(rowReturned, 7);
            bool deleteFile = DBConnectHelper.DeleteRow("dbo.documents", "fileName", Path.GetFileName(suppliersMRNsFile2), DatabaseName.Documents);

            Assert.IsTrue(deleteFile);
            bool deleteErrors = DBConnectHelper.DeleteRow("ECO.MeasuresProcessingError", "fileName", Path.GetFileName(suppliersMRNsFile2), DatabaseName.ECO);

            Assert.IsTrue(deleteErrors);
            StartAgain();
        }
Beispiel #7
0
        public void ThenFileRecordWillContainFilenameUploadedUsernameAndCreationTimestamp(string p0)
        {
            string fileName = Path.GetFileName(validFile);

            switch (p0)
            {
            case "Initial Upload":
                GetFileDetailsInDB(fileName, 1, p0);
                break;

            case "Duplicate Upload":
                GetFileDetailsInDB(fileName, 2, p0);
                bool deleteFile = DBConnectHelper.DeleteRow("dbo.documents", "fileName", fileName, DatabaseName.Documents);
                Assert.IsTrue(deleteFile);
                break;
            }
        }
Beispiel #8
0
        public void ThenFileWillBeProcessedWithRecordCreatedInDatabase(string p0)
        {
            Logger.Info("Verifying database for file deatils");
            string fileName  = WhichFile(p0);
            int    numOfRows = DBConnectHelper.RowReturnedQuery("Select * from dbo.documents where filename = '" + fileName + "'; ", DatabaseName.Documents);

            Assert.AreEqual(1, numOfRows);
            List <DatabaseResult> output = DBConnectHelper.GetQueryResult(
                "SELECT Version,DocId,Created_at FROM dbo.Documents where filename = '" + fileName + "' order by Created_at desc", DatabaseName.Documents);
            string todaysDate          = DateTime.Now.ToString("M/d/yyyy");
            string dateRetrievedFromDB = output[0].thirdColumn.Split(' ')[0];

            Assert.AreEqual(todaysDate, dateRetrievedFromDB);
            bool deleteFile = DBConnectHelper.DeleteRow("dbo.documents", "fileName", fileName, DatabaseName.Documents);

            Assert.IsTrue(deleteFile);
        }
        /// <summary>
        /// 更新数据库信息
        /// </summary>
        private void UpdateDBConnection()
        {
            var initDb = new DBConfig
            {
                DataServer   = this.txtInitDbServer.Text.Trim(),
                DataBase     = this.txtInitDbName.Text.Trim(),
                LoginAccount = this.txtInitDbAccount.Text.Trim(),
                Password     = this.txtInitDbPwd.Text.Trim()
            };

            var downDb = new DBConfig
            {
                DataServer   = this.txtDownDbServer.Text.Trim(),
                DataBase     = this.txtDownDbName.Text.Trim(),
                LoginAccount = this.txtDownDbAccount.Text.Trim(),
                Password     = this.txtDownDbPwd.Text.Trim()
            };

            DBConnectHelper.SetConnection(initDb, downDb);
        }
Beispiel #10
0
 public MainForm()
 {
     InitializeComponent();
     connector    = DBConnectHelper.Instance;
     optionHelper = OptionHelper.Instance;
 }
Beispiel #11
0
 static DBConnectHelper()
 {
     instance = new DBConnectHelper();
 }