コード例 #1
0
        protected override void ApplyCommand(Session session, QueryJson query)
        {
            Random          rand = new Random(DateTime.Now.Millisecond);
            string          lettersRandom = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890";
            int             len = lettersRandom.Length;
            int             count = int.Parse(GetVariable(query.Message, "Count"));
            GenUserDataJson users = new GenUserDataJson();
            string          log, pass;

            for (int i = 0; i < count; i++)
            {
                log = ""; pass = "";
                for (int j = 0; j < 10; j++)
                {
                    log += lettersRandom[rand.Next(0, len)];
                }
                for (int j = 0; j < 10; j++)
                {
                    pass += lettersRandom[rand.Next(0, len)];
                }
                users.Users.Add(new UserData {
                    Login = log, Password = pass
                });
                DataBaseOperations.CreateUserProfile(log, pass);
            }
            session.Dialog.SendMessage(users);
        }
コード例 #2
0
        protected override void ApplyCommand(Session session, QueryJson query)
        {
            string userName, password;

            userName = GetVariable(query.Message, "UserName");
            password = GetVariable(query.Message, "Password");
            string        userPriv = DataBaseOperations.CheckUserLoginData(userName, password);
            OperationCode code     = OperationCode.UserAuthorized;

            if (userPriv == "Admin")
            {
                session.UserRights = Rights.Admin;
                code = OperationCode.AdminAuthorized;
            }
            else if (userPriv == "User")
            {
                session.UserRights = Rights.User;
                code = OperationCode.UserAuthorized;
            }
            else
            {
                session.Dialog.SendMessage(
                    new Msg(OperationCode.AnswerError, WRONG_LOGIN_OR_PASS));
            }
            session.CreateLog(userName);
            session.WriteLog(userName + " connected!");
            session.Dialog.SendMessage(
                new Msg(code, "Connected"));
        }
コード例 #3
0
        public void CleanUpAfterTests()
        {
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode1   = ("DROP TABLE IF EXISTS TestTable1;");
            SqlCommand    deleteTableCommand1 = new SqlCommand(DropTableSQLCode1, s_connection);

            deleteTableCommand1.ExecuteNonQuery();
            String     DropTableSQLCode2   = ("DROP TABLE IF EXISTS TestTable2;");
            SqlCommand deleteTableCommand2 = new SqlCommand(DropTableSQLCode2, s_connection);

            deleteTableCommand2.ExecuteNonQuery();
            String     DropTableSQLCode4   = ("DROP TABLE IF EXISTS TestTable4;");
            SqlCommand deleteTableCommand4 = new SqlCommand(DropTableSQLCode4, s_connection);

            deleteTableCommand4.ExecuteNonQuery();
            String     DropTableSQLCode5   = ("DROP TABLE IF EXISTS TestTable5;");
            SqlCommand deleteTableCommand5 = new SqlCommand(DropTableSQLCode5, s_connection);

            deleteTableCommand5.ExecuteNonQuery();
            String     DropTableSQLCode6   = ("DROP TABLE IF EXISTS TestTable6;");
            SqlCommand deleteTableCommand6 = new SqlCommand(DropTableSQLCode6, s_connection);

            deleteTableCommand6.ExecuteNonQuery();
            String     DropTableSQLCode7   = ("DROP TABLE IF EXISTS TestTable7;");
            SqlCommand deleteTableCommand7 = new SqlCommand(DropTableSQLCode7, s_connection);

            deleteTableCommand7.ExecuteNonQuery();
            String     DropTableSQLCode8   = ("DROP TABLE IF EXISTS TestTable8;");
            SqlCommand deleteTableCommand8 = new SqlCommand(DropTableSQLCode8, s_connection);

            deleteTableCommand8.ExecuteNonQuery();
        }
コード例 #4
0
        public void TestDeleteTableMethodToMakeSureItActuallyDeletesTheTableFromTheDataBase()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode3   = ("DROP TABLE IF EXISTS TestTable3;");
            SqlCommand    deleteTableCommand3 = new SqlCommand(DropTableSQLCode3, s_connection);

            deleteTableCommand3.ExecuteNonQuery();
            String     TSQLSourceCode3 = "CREATE TABLE TestTable3(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command3        = new SqlCommand(TSQLSourceCode3, s_connection);

            command3.ExecuteNonQuery();
            SqlDataReader myReader  = null;
            int           count     = 0;
            String        sqlString = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TestTable3'";

            //Act
            DataBaseOperations.DeleteTable("TestTable3");
            SqlCommand command = new SqlCommand(sqlString, s_connection);

            myReader = command.ExecuteReader();
            while (myReader.Read())
            {
                count++;
            }

            //Assert
            Assert.AreEqual(0, count);
        }
コード例 #5
0
        public void TestRetrieveNumberOfRowsInTableMethodToMakeSureItRetrievesTheCorrectNumberOfRows()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode4   = ("DROP TABLE IF EXISTS TestTable4;");
            SqlCommand    deleteTableCommand4 = new SqlCommand(DropTableSQLCode4, s_connection);

            deleteTableCommand4.ExecuteNonQuery();
            String     TSQLSourceCode4 = "CREATE TABLE TestTable4(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command4        = new SqlCommand(TSQLSourceCode4, s_connection);

            command4.ExecuteNonQuery();
            String     insertStringRowOne = "INSERT INTO TestTable4(columnone, columntwo) VALUES ('This is rowone columnone', 'This is rowone columntwo');";
            SqlCommand command            = new SqlCommand(insertStringRowOne, s_connection);

            command.ExecuteNonQuery();

            //Act
            int numRowsInTable = DataBaseOperations.RetrieveNumberOfRowsInTable("TestTable4");

            //Assert
            Assert.AreEqual(1, numRowsInTable);
        }
コード例 #6
0
        public void TestCreateTableMethodToMakeSureItActuallyCreatesATableInTheDataBase()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            SqlDataReader myReader            = null;
            int           count               = 0;
            String        tableName           = "TestTable2";
            String        sqlString           = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TestTable2'";
            String        tableCreationString = "(question varchar(4000) not null PRIMARY KEY, answer varchar(4000) not null);";

            //Act
            DataBaseOperations.CreateTable(tableName, tableCreationString);
            SqlCommand command = new SqlCommand(sqlString, s_connection);

            myReader = command.ExecuteReader();
            while (myReader.Read())
            {
                count++;
            }

            //Assert
            Assert.AreNotEqual(0, count);
        }
コード例 #7
0
 public void Initialize()
 {
     new DataBaseOperations();
     DataBaseOperations.ConnectToDB();
     s_connection = DataBaseOperations.Connection;
     UT           = new UserTable();
 }
コード例 #8
0
        public void TestInsertIntoTableMethodToMakeSureTheRowGetsInsertedProperly()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode6   = ("DROP TABLE IF EXISTS TestTable6;");
            SqlCommand    deleteTableCommand6 = new SqlCommand(DropTableSQLCode6, s_connection);

            deleteTableCommand6.ExecuteNonQuery();
            String     TSQLSourceCode6 = "CREATE TABLE TestTable6(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command6        = new SqlCommand(TSQLSourceCode6, s_connection);

            command6.ExecuteNonQuery();
            String insertRowString = "INSERT INTO TestTable6(columnone, columntwo) VALUES ('This is rowone columnone', 'This is rowone columntwo');";
            String retrievedRow    = "";
            String TSQLSourceCode  = ("SELECT * FROM(Select Row_Number() Over (Order By columnone) As RowNum, * From TestTable6) t2 where RowNum = 1;");

            //Act
            DataBaseOperations.InsertIntoTable(insertRowString);
            using (SqlCommand command = new SqlCommand(TSQLSourceCode, s_connection))
            {
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        retrievedRow += reader.GetString(1) + reader.GetString(2);
                    }
                }
            }

            //Assert
            Assert.AreEqual("This is rowone columnoneThis is rowone columntwo", retrievedRow);
        }
コード例 #9
0
        public async Task <DialogTurnResult> FinishOnboardingDialog(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            var view = new MainResponses();

            _state = await _accessor.GetAsync(sc.Context);

            await _accessor.SetAsync(sc.Context, _state, cancellationToken);

            var name = _state.Name;

            var connect = new DataBaseOperations("Server=tcp:yoyopizzaserver.database.windows.net,1433;Initial Catalog=PizzaOrderdb;Persist Security Info=False;User ID=shubham;Password=Dota365365;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");

            connect.addUserInfo(_state);
            //await _responder.ReplyWith(sc.Context, OnboardingResponses.ResponseIds.HaveNameMessage, new { name });
            var attachement = GetGreetingCard(name);
            var opts        = new PromptOptions
            {
                Prompt = new Activity
                {
                    Type        = ActivityTypes.Message,
                    Attachments = new List <Attachment> {
                        attachement
                    },
                },
            };
            await sc.PromptAsync(DialogIds.GreetingPrompt, opts);

            return(await sc.EndDialogAsync());
        }
コード例 #10
0
        public void TestRetrieveRowFromTableMethodToMakeSureTheRowGetsRetrievedProperly()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode7   = ("DROP TABLE IF EXISTS TestTable7;");
            SqlCommand    deleteTableCommand7 = new SqlCommand(DropTableSQLCode7, s_connection);

            deleteTableCommand7.ExecuteNonQuery();
            String     TSQLSourceCode7 = "CREATE TABLE TestTable7(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command7        = new SqlCommand(TSQLSourceCode7, s_connection);

            command7.ExecuteNonQuery();
            String     insertString = "INSERT INTO TestTable7(columnone, columntwo) VALUES ('This is rowone columnone', 'This is rowone columntwo');";
            SqlCommand command      = new SqlCommand(insertString, s_connection);

            command.ExecuteNonQuery();
            String rowToRetriveSQLCode = ("SELECT * FROM(Select Row_Number() Over (Order By columnone) As RowNum, * From TestTable7) t2 where RowNum = 1;");

            //Act
            String retrievedRow = DataBaseOperations.RetrieveRowFromTable(rowToRetriveSQLCode);

            //Assert
            Assert.AreEqual(("This is rowone columnone" + "\n" + "This is rowone columntwo" + "\n"), retrievedRow);
        }
コード例 #11
0
 public void Initialize()
 {
     new DataBaseOperations();
     DataBaseOperations.ConnectToDB();
     s_connection = DataBaseOperations.Connection;
     TT           = new TerritoryTable();
 }
コード例 #12
0
 public void Initialize()
 {
     new DataBaseOperations();
     DataBaseOperations.ConnectToDB();
     s_connection = DataBaseOperations.Connection;
     QT           = new QuestionTable("TableName");
 }
コード例 #13
0
        private void AccountClosure_Load(object sender, EventArgs e)
        {
            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            collection.AddRange(DataBaseOperations.getAccountIban().ToArray());

            textBoxIBanClosure.AutoCompleteCustomSource = collection;
        }
コード例 #14
0
        protected override void ApplyCommand(Session session, QueryJson query)
        {
            session.WriteLog("Select command: " + query.Message);
            DataTableJson buf = DataBaseOperations.ExecuteDataTable(query);

            buf.Dependence = DataTableDependeces.GetTableDependence(query.TableName);
            session.Dialog.SendMessage(buf);
        }
コード例 #15
0
 protected override void ApplyCommand(Session session, QueryJson query)
 {
     string[] logins = GetVariable(query.Message, "Logins").
                       Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
     foreach (var login in logins)
     {
         DataBaseOperations.DeleteProfile(login);
     }
 }
コード例 #16
0
        public void TestToMakeSureConnectToDBMethodOpensConnectionToTheDataBase()
        {
            //Arrange
            new DataBaseOperations();

            //Act
            DataBaseOperations.ConnectToDB();
            bool ConnectionIsOpen = (DataBaseOperations.Connection.State == ConnectionState.Open);

            //Assert
            Assert.IsTrue(ConnectionIsOpen);
        }
コード例 #17
0
        private void buttonChangePassword_Click(object sender, EventArgs e)
        {
            try
            {
                LoginEmployee.ChangePasswordLogin changePassword = new LoginEmployee.ChangePasswordLogin();
                changePassword.loginEmployee = new LoginEmployee.LoginEmployee();

                changePassword.loginEmployee.Username = textBoxUserNameChangePass.Text;
                changePassword.loginEmployee.Password = textBoxPasswordOLd.Text;
                changePassword.NewPassword            = textBoxNewPassword.Text;
                changePassword.NewPasswordConfirm     = textBoxConfirmNewPassword.Text;

                if (DataBaseOperations.checkUser(changePassword.loginEmployee.Username,
                                                 changePassword.loginEmployee.Password) == true)
                {
                    if (changePassword.NewPassword == changePassword.NewPasswordConfirm)
                    {
                        DataBaseOperations.changePasswordUserEmployee(changePassword);

                        MessageBox.Show("Password successfully changed .",
                                        "Change password .", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);

                        textBoxUserNameChangePass.Clear();
                        textBoxPasswordOLd.Clear();
                        textBoxNewPassword.Clear();
                        textBoxConfirmNewPassword.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Тhe new password and the confirm new password are different !",
                                        "Change password .", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Username or current password are incorrectly entered !",
                                    "Change password .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #18
0
ファイル: userloginpage.aspx.cs プロジェクト: kipatil/DotNet
    protected void Button1_Click1(object sender, EventArgs e)
    {
        if (name.Text != "" && pwd.Text != "")
        {
            SqlDataReader dr = (DataBaseOperations.ReadData("Select email_id,pwd From tbl_user_reg Where email_id='" + name.Text + "' and pwd=" + pwd.Text + ""));
            if (dr.Read() == true)
            {
                Session.Clear();
                Session["u_id"] = dr[0].ToString();


                st  = "select u_id,fname,email_id,mob from tbl_user_reg where email_id='" + name.Text + "' and pwd='" + pwd.Text + "'";
                cm  = new SqlCommand(st, db);
                dr1 = cm.ExecuteReader();
                if (dr1.Read() == true)
                {
                    Session.Clear();
                    Session["u_id"]     = dr1[0].ToString();
                    Session["fname"]    = dr1[1].ToString();
                    Session["email_id"] = dr1[2].ToString();
                    Session["mobile"]   = dr1[3].ToString();
                }
                dr1.Close();
                Response.Redirect("UserHomePage.aspx");
                dr.Close();

                //if (chkRemPwd.Checked == true)
                //{
                //    Response.Cookies["uname"].Value = name.Text;
                //    Response.Cookies["password"].Value = pwd.Text;
                //    Response.Cookies["uname"].Expires = DateTime.Now.AddMonths(1);
                //    Response.Cookies["password"].Expires = DateTime.Now.AddMonths(1);
                //    Response.Write("Email-Id and Password are stored in the memory");
                //}
            }
            else
            {
                Response.Write("<script>alert('Invalid UserName And Password');</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('UserName And Password Should Not Be Blank');</script>");
        }
    }
コード例 #19
0
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            try
            {
                LoginEmployee.RegisterEmployee registerEmployee = new LoginEmployee.RegisterEmployee();

                registerEmployee.UsernameRegister = textBoxUserNameRegister.Text;

                if (DataBaseOperations.checkUsername(registerEmployee.UsernameRegister) == false)
                {
                    if (registerEmployee.PasswordRegister == registerEmployee.PasswordRegisterConfirm)
                    {
                        registerEmployee.PasswordRegister        = textBoxPasswordRegister.Text;
                        registerEmployee.PasswordRegisterConfirm = textBoxPassRegisterConfirm.Text;

                        DataBaseOperations.registerEmployee(registerEmployee);

                        MessageBox.Show("The registration is successful.",
                                        "Register .", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);

                        textBoxUserNameRegister.Clear();
                        textBoxPasswordRegister.Clear();
                        textBoxPassRegisterConfirm.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Passwords are different .",
                                        "Register ", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Тhere is a registered employee with such a username .",
                                    "Register ", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #20
0
 protected void Button1_Click1(object sender, EventArgs e)
 {
     if (name.Text != "" && pwd.Text != "")
     {
         SqlDataReader dr = (DataBaseOperations.ReadData("select admin_id,email_id,pwd from tbl_admin where email_id='" + name.Text + "' and pwd='" + pwd.Text + "'"));
         if (dr.Read())
         {
             Session.Clear();
              Session["a_id"] = dr[0].ToString();
             Response.Redirect("AdminHomePage.aspx");
             dr.Close();
         }
         else { Response.Write("<script>alert('Invalid UserName And Password');</script>"); }
     }
     else
     {
         Response.Write("<script>alert('UserName And Password Should Not Be Blank');</script>");
     }
 }
コード例 #21
0
        public void TestRetrieveNumberOfColsInTableMethodToMakeSureItRetrievesTheCorrectNumberOfRows()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode5   = ("DROP TABLE IF EXISTS TestTable5;");
            SqlCommand    deleteTableCommand5 = new SqlCommand(DropTableSQLCode5, s_connection);

            deleteTableCommand5.ExecuteNonQuery();
            String     TSQLSourceCode5 = "CREATE TABLE TestTable5(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command5        = new SqlCommand(TSQLSourceCode5, s_connection);

            command5.ExecuteNonQuery();

            //Act
            int numColsInTable = DataBaseOperations.RetrieveNumberOfColsInTable("TestTable5");

            //Assert
            Assert.AreEqual(2, numColsInTable);
        }
コード例 #22
0
        public void TableExistsMethodTest()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection       = DataBaseOperations.Connection;
            String        DropTableSQLCode   = ("DROP TABLE IF EXISTS TestTable1;");
            SqlCommand    deleteTableCommand = new SqlCommand(DropTableSQLCode, s_connection);

            deleteTableCommand.ExecuteNonQuery();
            String     TSQLSourceCode = "CREATE TABLE TestTable1(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command        = new SqlCommand(TSQLSourceCode, s_connection);

            command.ExecuteNonQuery();

            //Act
            bool tableExist = DataBaseOperations.TableExists("TestTable1");

            //Assert
            Assert.AreEqual(true, tableExist);
        }
コード例 #23
0
        private async Task <DialogTurnResult> SpecialMenu(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var pizzaOrderState = await _pizzaOrderingState.GetAsync(stepContext.Context, () => null);

            var connect       = new DataBaseOperations(configuration.GetValue <string>("sqlDb:connectionString"));
            var specialPizzas = connect.GetSpecialPizzas();

            if (pizzaOrderState.IsSpecialPizza == null)
            {
                var menuCarousal   = CreateMenuCarousal(specialPizzas, pizzaOrderState.Size);
                var customizeCard  = CreateAdaptiveCardCustomizePizza();
                var customActivity = new Activity
                {
                    Type             = ActivityTypes.Message,
                    Text             = $"{configuration.GetValue<string>("PizzaOrderDialog:SpecialMenu")}",
                    AttachmentLayout = AttachmentLayoutTypes.Carousel,
                    Attachments      = menuCarousal,
                };
                var opts = new PromptOptions
                {
                    Prompt = new Activity
                    {
                        Type             = ActivityTypes.Message,
                        Text             = $"",
                        AttachmentLayout = AttachmentLayoutTypes.Carousel,
                        Attachments      = new List <Attachment>()
                        {
                            customizeCard
                        },
                    },
                };
                await stepContext.Context.SendActivityAsync(customActivity);

                return(await stepContext.PromptAsync(SpecialMenuPrompt, opts));
            }
            else
            {
                return(await stepContext.NextAsync());
            }
        }
コード例 #24
0
        private void buttonGetDetailsClosure_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxIBanClosure.Text == "")
                {
                    MessageBox.Show("Please enter IBAN on customer !",
                                    "Account closure .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    Customer customer = new Customer();                                            //
                    customer = DataBaseOperations.GetCustomerInformation(textBoxIBanClosure.Text); //

                    dataGridViewInforamtionCustomer.Rows.Add(
                        customer.Id,
                        customer.account.Iban,
                        customer.FullName,
                        customer.Egn,
                        customer.gender,
                        customer.Address,
                        customer.PostalCode,
                        customer.City,
                        customer.Country,
                        customer.MobilePhone,
                        customer.HomePhone,
                        customer.Email,
                        customer.DataOfAccount);

                    modelAccountCustomer = DataBaseOperations.getBalance(textBoxIBanClosure.Text);
                    textBoxAccountBalanceClosure.Text = modelAccountCustomer.Balance.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #25
0
        private async Task <bool> validateOrderId(PromptValidatorContext <string> promptContext, CancellationToken cancellationToken)
        {
            var pizzaStatusModel = await _pizzaStatusModel.GetAsync(promptContext.Context, () => new PizzaStatusModel());

            var value = promptContext.Recognized.Value?.Trim() ?? string.Empty;

            // Get cognitive models for locale
            if (Enumerable.Range(1, 100).Contains(Convert.ToInt32(value)))
            {
                pizzaStatusModel.OrderId = Convert.ToInt32(value);
                var connect = new DataBaseOperations(configuration.GetValue <string>("sqlDb:connectionString"));
                var order   = connect.Get(pizzaStatusModel.OrderId);
                if (order != null)
                {
                    pizzaStatusModel.DeliveryTime = Convert.ToDateTime(order["time"]);
                    if ((int)((pizzaStatusModel.DeliveryTime - DateTime.Now.AddMinutes(330)).TotalMinutes) <= 0)
                    {
                        await promptContext.Context.SendActivityAsync($"This order has been delivered at {(pizzaStatusModel.DeliveryTime).ToShortDateString()}, {(pizzaStatusModel.DeliveryTime).ToShortTimeString()}.").ConfigureAwait(false);

                        return(true);
                    }
                    else
                    {
                        await promptContext.Context.SendActivityAsync($"Your order will reach you hot in {(int)((pizzaStatusModel.DeliveryTime - DateTime.Now.AddMinutes(330)).TotalMinutes)} minutes.").ConfigureAwait(false);

                        return(true);
                    }
                }
                await promptContext.Context.SendActivityAsync($"There is no order with this order Id. Please try again.").ConfigureAwait(false);

                return(false);
            }
            else
            {
                await promptContext.Context.SendActivityAsync($"Issue with the order Id.").ConfigureAwait(false);

                return(false);
            }
        }
コード例 #26
0
        public void TestDeleteRowFromTableMethodToMakeSureItDeletesARowFromTheDataBase()
        {
            //Arrange
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            SqlConnection s_connection        = DataBaseOperations.Connection;
            String        DropTableSQLCode8   = ("DROP TABLE IF EXISTS TestTable8;");
            SqlCommand    deleteTableCommand8 = new SqlCommand(DropTableSQLCode8, s_connection);

            deleteTableCommand8.ExecuteNonQuery();
            String     TSQLSourceCode8 = "CREATE TABLE TestTable8(columnone varchar(4000) not null PRIMARY KEY, columntwo varchar(4000) not null);";
            SqlCommand command8        = new SqlCommand(TSQLSourceCode8, s_connection);

            command8.ExecuteNonQuery();
            String     insertStringRowOne = "INSERT INTO TestTable8(columnone, columntwo) VALUES ('This is rowone columnone', 'This is rowone columntwo');";
            SqlCommand command            = new SqlCommand(insertStringRowOne, s_connection);

            command.ExecuteNonQuery();
            String rowToDelete         = ("DELETE FROM TestTable8 WHERE columnone='This is rowone columnone';");
            int    numberOfRowsInTable = 0;
            String NumRowsCountSQLCode = "SELECT COUNT(*) FROM TestTable8;";

            //Act
            DataBaseOperations.DeleteRowFromTable(rowToDelete);
            using (SqlCommand cmd = new SqlCommand(NumRowsCountSQLCode, s_connection))
            {
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        numberOfRowsInTable = reader.GetInt32(0);
                    }
                }
            }

            //Assert
            Assert.AreEqual(0, numberOfRowsInTable);
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: likeye/ItEventsParser
        static void Main(string[] args)
        {
            EmailService       emailService = new EmailService();
            EventsParser       eventsParser = new EventsParser();
            DataBaseOperations dbOperations = new DataBaseOperations();

            var eventList = eventsParser.Parse(new ParseConfiguration()
            {
                City = ParseCity(ConfigurationManager.AppSettings["city"]),
                Type = ConfigurationManager.AppSettings["type"],
                Cost = ParseCost(ConfigurationManager.AppSettings["cost"])
            });

            var events = eventList as IList <Event> ?? eventList.ToList();

            ShowParsedList(events);

            Console.WriteLine();
            while (true)
            {
                Console.WriteLine("*** calling MyMethod *** ");
                dbOperations.Insert(events);

                try
                {
                    var eventsListFromDb = dbOperations.ReadAllToList();
                    emailService.Send(eventsListFromDb);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.WriteLine("\n All done");
                Thread.Sleep(60 * 1000 * int.Parse(ConfigurationManager.AppSettings["time"]));
            }
        }
コード例 #28
0
        public static int Deletecar(int SNO)
        {
            int a = DataBaseOperations.Deletecar(SNO);

            return(a);
        }
コード例 #29
0
        public static int Updatecar(int SNO, string NAME, int MODEL, int PRICE)
        {
            int a = DataBaseOperations.Updatecar(SNO, NAME, MODEL, PRICE);

            return(a);
        }
コード例 #30
0
        public void TestDataBaseConnection()
        {
            var dataBaseOperations = new DataBaseOperations();

            Assert.IsTrue(dataBaseOperations.TestDataBaseConnection());
        }