Exemplo n.º 1
0
        private IEnumerable <ITable> _FetchTables()
        {
            var query  = $@"SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_TYPE FROM [{Name}].[INFORMATION_SCHEMA].[TABLES]";
            var result = DatabaseSystem.ExecuteQuery(query);

            foreach (DataRow row in result.DataSet.Tables[0].Rows)
            {
                TableType tableType;

                switch ((string)row[2])
                {
                case "BASE TABLE":
                    tableType = TableType.Table;
                    break;

                case "VIEW":
                    tableType = TableType.View;
                    break;

                default:
                    continue;
                }

                yield return(new SqlServerTable(this, (string)row[0], (string)row[1], tableType));
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Debug.WriteLine(loaded);
            if (!IsPostBack)
            {
                String productId = null;
                loaded = true;
                if (!String.Equals(Request.QueryString["productID"], null))
                {
                    productId = Request.QueryString["productID"];
                }

                Product product = DatabaseSystem.GetInstance().GetProductForId(productId);
                if (product == null)
                {
                    return;
                }

                FillDropDown();


                Categories.SelectedValue = product.categoryId;
                ProductTitle.Value       = product.title;
                ShortDesc.Value          = product.shortDescription;
                LongDesc.Value           = product.longDescription;
                Price.Value = product.price;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sqlite local database ( FOR TESTS )
 /// </summary>
 public FinishingSystemContext()
 {
     ConnectionStringProp = LocalSqlite;
     dbSysem = DatabaseSystem.Sqlite;
     //ConnectionStringProp = LocalSqlServer;
     //dbSysem = DatabaseSystem.SqlServer;
 }
Exemplo n.º 4
0
        public async Task <SystemSucceededTask> CreateSystem(CreateSystemViewModel model, string userName)
        {
            if (_configurationTypeRepository.GetById(model.ConfigTypeId) == null)
            {
                _logger.ErrorLog("Could not create system " + model.Name, "Create Database System", string.Empty,
                                 userName);
                return(SystemSucceededTask.Failed("Could not create system " + model.Name + "" +
                                                  ", Please select a configuration", string.Empty, false, true));
            }

            if (_vendorRepository.GetById(model.VendorId) == null)
            {
                _logger.ErrorLog("Could not create system " + model.Name, "Create Database System", string.Empty,
                                 userName);
                return(SystemSucceededTask.Failed("Could not create system {model.Name}, Please select a vendor",
                                                  string.Empty, false, true));
            }

            if (_dataBaseEnvironment.GetById(model.EnvironmentId) == null)
            {
                _logger.ErrorLog("Could not create system " + model.Name, "Create Database System", string.Empty,
                                 userName);
                return(SystemSucceededTask.Failed("Could not create system {model.Name}, Please select an rnvironment",
                                                  string.Empty, false, true));
            }
            try
            {
                var dbSysten = new DatabaseSystem()
                {
                    Name                = model.Name,
                    Description         = model.Description,
                    Active              = model.Active,
                    ConfigurationType   = _configurationTypeRepository.GetById(model.ConfigTypeId),
                    Vendor              = _vendorRepository.GetById(model.VendorId),
                    DatabaseEnvironment = _dataBaseEnvironment.GetById(model.EnvironmentId)
                };

                _systemRepository.Add(dbSysten);
                await _systemRepository.SaveChangesAsync();

                _logger.InformationLog("Create Database System " + model.Name + " successfully", "Create Database System",
                                       string.Empty, userName);
                return(SystemSucceededTask.Success("Database System " + model.Name + " created succesfully"));
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Source.Contains("sql"))
                {
                    _logger.ErrorLog(ex.Message, "Create Database System", ex.InnerException.Message, userName);
                    return(SystemSucceededTask.Failed("Could not create system " + model.Name,
                                                      ex.InnerException.Message, false, true));
                }

                _logger.ErrorLog(ex.Message, "Create Database System", ex.InnerException.Message, userName);
                return(SystemSucceededTask.Failed("Could not create system " + model.Name, ex.InnerException.Message,
                                                  false, true));
            }
        }
Exemplo n.º 5
0
 public ActionResult ProductView(int id = -1)
 {
     if (id == -1)
     {
         return(RedirectToAction("Index"));
     }
     ViewBag.product = DatabaseSystem.GetInstance().GetProductForId(id);
     return(View());
 }
Exemplo n.º 6
0
        public ActionResult LogOut()
        {
            foreach (Product p in ((User)Session["User"]).cart.contents)
            {
                DatabaseSystem.GetInstance().Add(p.ProductID, p.Quantity);
            }

            Session["User"] = null;
            return(RedirectToAction("Index", "Products"));
        }
Exemplo n.º 7
0
 private void ContinueHandler()
 {
     DatabaseSystem.testFunc();
     StartCoroutine(FadeOutCoroutine(MainMenu.GetComponent <S_MainMenu>().ChildCanvasGroup, MainMenu, () =>
     {
         // Create a lambda for instantiating our equipment menu at the end
         EquipmentMenu = Instantiate(EquipmentMenuObjectType);
         GameObject EquipmentChildPanel = EquipmentMenu.transform.GetChild(0).gameObject;
         Assert.IsNotNull(EquipmentChildPanel);
         StartCoroutine(FadeInCoroutine(EquipmentChildPanel.GetComponent <CanvasGroup>()));
     }));
 }
Exemplo n.º 8
0
        public TableSystemV2Tests()
        {
            var container = new ServiceContainer();

            container.Register <ITableSystem, TableSystemV2>();
            container.Register <IStoreSystem, InMemoryStoreSystem>();

            var system = new DatabaseSystem(container, new Configuration());

            system.Start();

            database = system.CreateDatabase("testdb", new Configuration(), new IDatabaseFeature[0]);
        }
Exemplo n.º 9
0
        public void AddRecentConnectionString(DatabaseSystem system, Database database)
        {
            RecentConnectionString connectionString = new RecentConnectionString(system, database);

            if (!RecentConnectionStrings.Contains(connectionString))
            {
                RecentConnectionStrings.Insert(0, connectionString);

                const int maxCount = 20;
                if (RecentConnectionStrings.Count > maxCount)
                {
                    RecentConnectionStrings.RemoveRange(maxCount, RecentConnectionStrings.Count - maxCount);
                }
            }
        }
Exemplo n.º 10
0
        public String Remove(int id, int quantity)
        {
            Product p = DatabaseSystem.GetInstance().GetProductForId(id);

            if (!((User)Session["User"]).cart.Remove(id, quantity))
            {
                return("Unable to remove " + p.Title + " from your cart");
            }

            if (!DatabaseSystem.GetInstance().Add(id, quantity))
            {
                return("Unable to remove " + p.Title + " from your cart");
            }

            return("Removed " + quantity + " of " + p.Title + " from your cart");
        }
Exemplo n.º 11
0
        public String Add(int id, int quantity)
        {
            if (Object.Equals(Session["User"], null))
            {
                Session["User"] = new User();
            }

            Product p = DatabaseSystem.GetInstance().GetProductForId(id);

            if (!DatabaseSystem.GetInstance().Remove(id, quantity))
            {
                return("Unable to add " + p.Title + " to your cart");
            }

            ((User)Session["User"]).cart.Add(id, quantity);
            return("Added " + quantity + " of " + p.Title + " to your cart");
        }
Exemplo n.º 12
0
        private void FillDropDown()
        {
            List <Category> categoryList = DatabaseSystem.GetInstance().GetCategories();

            foreach (Category category in categoryList)
            {
                if (Categories.Items.FindByValue(category.categoryId) != null)
                {
                    continue;
                }

                ListItem item = new ListItem();
                item.Text  = category.title;
                item.Value = category.categoryId;
                Categories.Items.Add(item);
            }
        }
Exemplo n.º 13
0
        private void FillDropDown()
        {
            List <Product> products = DatabaseSystem.GetInstance().GetProducts();

            foreach (Product category in products)
            {
                if (Products.Items.FindByValue(category.categoryId) != null)
                {
                    continue;
                }

                ListItem item = new ListItem();
                item.Text  = category.title;
                item.Value = category.productId;
                Products.Items.Add(item);
            }
        }
Exemplo n.º 14
0
        public ActionResult LogIn(String username, String password)
        {
            User u = DatabaseSystem.GetInstance().AuthenticateUser(username, password);

            if (!Object.Equals(u, null))
            {
                if (!Object.Equals(Session["User"], null))
                {
                    u.ImportCart(((User)Session["User"]).cart);
                }

                Session["User"] = u;
                return(RedirectToAction("Index", "Products"));
            }

            ViewBag.error = "Username or password is incorrect";
            return(View());
        }
Exemplo n.º 15
0
        public async Task SendMessageTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Message        message        = new Message("unitTest1", "unitTest1", "unitTestMessage");
            Activity       activity       = new Activity();

            activity.ActivityId     = "99";
            activity.ActivityName   = "unitTest2";
            activity.HomeOwnerId    = "unitTest1";
            activity.ActivityDate   = "2020/02/02";
            activity.ActivityNote   = "unitTest";
            activity.NumberOfPeople = "3";

            await databaseSystem.InsertActivity(activity);

            Assert.IsTrue(await databaseSystem.SendMessage("99", message));
            await databaseSystem.Delete("99", "Activity");
        }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String productId = Request.QueryString["productID"];

            if (!loaded)
            {
                loaded = true;
                //confirm success
                if (DatabaseSystem.GetInstance().DeleteProduct(productId))
                {
                    status.Text = "Product Successfully deleted!";
                }
                else
                {
                    status.Text = "Unable to remove product!";
                }
            }
        }
Exemplo n.º 17
0
        public async Task UpdateActivityTest()
        {
            DatabaseSystem databaseSystem         = new DatabaseSystem();
            Dictionary <string, string> testValue = new Dictionary <string, string>();

            testValue.Add("ActivityId", "99");
            testValue.Add("ActivityName", "unitTest2");
            testValue.Add("HomeOwnerId", "unitTest1");
            testValue.Add("ActivityDate", "1998/02/11");
            testValue.Add("ActivityNote", "unitTest");
            testValue.Add("NumberOfPeople", "3");

            var result = await databaseSystem.UpdateActivity("99", testValue);

            await databaseSystem.Delete("99", "Activity");

            Assert.IsTrue(result);
        }
Exemplo n.º 18
0
        public async Task InsertActivityTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Activity       activity       = new Activity();

            activity.ActivityId     = "99";
            activity.ActivityName   = "unitTest2";
            activity.HomeOwnerId    = "unitTest1";
            activity.ActivityDate   = "2020/02/02";
            activity.ActivityNote   = "unitTest";
            activity.NumberOfPeople = "3";

            var result = await databaseSystem.InsertActivity(activity);

            await databaseSystem.Delete("99", "Activity");

            Assert.IsTrue(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Sqlserver or Sqlite local connections ( FOR TESTS )
        /// </summary>
        /// <param name="system"></param>
        public HostManagerContext(DatabaseSystem system)
        {
            switch (system)
            {
            case DatabaseSystem.SqlServer:
                ConnectionStringProp = LocalSqlServer;
                break;

            case DatabaseSystem.Sqlite:
                ConnectionStringProp = LocalSqlite;

                break;

            default:
                break;
            }
            dbSysem = system;
        }
Exemplo n.º 20
0
        public ActionResult Register(User user)
        {
            User u = DatabaseSystem.GetInstance().GetUserForId(user.Username);

            if (u != null)
            {
                ViewBag.error = "Username already taken";
                return(View("Index"));
            }
            else if (!DatabaseSystem.GetInstance().RegisterUser(user))
            {
                ViewBag.error = "Unable to save user information to database";
                return(View("Index"));
            }

            Session["User"] = user;
            return(RedirectToAction("Index", "Products"));;
        }
Exemplo n.º 21
0
        public async Task UpdateMemberInfoTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Member         member         = new Member();

            member.MemberId   = "unitTest4";
            member.MemberName = "zxczxc";
            member.Password   = "******";
            member.Phone      = "0326598741";
            member.Birthday   = "10/10/1659";
            member.Sexuality  = "女";

            var result = await databaseSystem.UpdateMemberInfo(member);

            await databaseSystem.Delete("unitTest4", "Member");

            Assert.IsTrue(result);
        }
Exemplo n.º 22
0
        protected void Upload_Image_Click(object sender, EventArgs e)
        {
            String jquery;
            String message = null;

            String imageUrl  = Server.MapPath("~/" + "images/product_images/" + File_Upload_Image.FileName);
            String productId = Products.SelectedValue;


            if (File_Upload_Image.HasFile)
            {
                try
                {
                    File_Upload_Image.SaveAs(imageUrl);

                    //save image info to database here
                    if (DatabaseSystem.GetInstance().UploadImage(productId, imageUrl))
                    {
                        message = "Successfully uploaded image!";
                    }
                }
                catch (Exception)
                {
                    message = "Unable to upload image!";
                }
            }
            else
            {
                message = "Unable to upload image!";
            }


            jquery = @"<script>
                $(function() {
                 

               bootbox.alert('" + message + @"', function() {});
                
                });
                </script>";

            Upload_Status.Controls.Add(new LiteralControl(jquery));
        }
Exemplo n.º 23
0
        public async Task InitializationActivityDataTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Activity       activity       = new Activity();

            activity.ActivityId     = "99";
            activity.ActivityName   = "unitTest2";
            activity.HomeOwnerId    = "unitTest1";
            activity.ActivityDate   = "2020/02/02";
            activity.ActivityNote   = "unitTest";
            activity.NumberOfPeople = "3";
            await databaseSystem.InsertActivity(activity);

            List <Activity> activityList = await databaseSystem.InitializationActivityData();

            await databaseSystem.Delete("99", "Activity");

            Assert.IsNotNull(activityList.Find(x => x.ActivityId == "99"));
        }
Exemplo n.º 24
0
        protected void Edit_Click(object sender, EventArgs e)
        {
            String message;
            String msgTitle;
            String productId = Request.QueryString["productID"];

            Debug.WriteLine("Cat: " + Categories.SelectedValue + "\nTitle: " + ProductTitle.Value + "\nShort: " + ShortDesc.Value + "\nLong: " + LongDesc.Value + "Price: " + Price.Value);

            if (DatabaseSystem.GetInstance().UpdateProduct(new Product(
                                                               productId, Categories.SelectedValue,
                                                               ProductTitle.Value, ShortDesc.Value,
                                                               LongDesc.Value, Price.Value)))
            {
                message  = "Successfully updated product: " + ProductTitle.Value;
                msgTitle = "Update Successful";
            }
            else
            {
                message  = "Unable to update the product " + ProductTitle.Value;
                msgTitle = "Unable to Update Product";
            }

            String jquery = @"<script>
                    $(function() {
               
                            bootbox.dialog({
                                message: '" + message + @"',
                                title: '" + msgTitle + @"',
                                buttons: {
                                    main: {
                                        label: 'OK',
                                        callback: function(){
                                            window.location.href = 'DataManagement.aspx';
                                        }
                                    }
                                }
                            });
                    });
                    </script>";

            Viewport_Edit.Controls.Add(new LiteralControl(jquery));
        }
Exemplo n.º 25
0
        protected void Add_Click(object sender, EventArgs e)
        {
            String message;
            String msgTitle;
            String categoryId       = Categories.SelectedValue;
            String title            = ProductTitle.Value;
            String shortDescription = ShortDesc.Value;
            String longDescription  = LongDesc.Value;
            String price            = Price.Value;


            if (DatabaseSystem.GetInstance().AddProduct(new Product(categoryId, title, shortDescription, longDescription, price)))
            {
                message  = "Successfully added new product: " + title;
                msgTitle = "Product Added";
            }
            else
            {
                message  = "Unable to add new product: " + title;
                msgTitle = "Unable To Add Product";
            }

            String jquery = @"<script>
                    $(function() {
               
                            bootbox.dialog({
                                message: '" + message + @"',
                                title: '" + msgTitle + @"',
                                buttons: {
                                    main: {
                                        label: 'OK',
                                        callback: function(){
                                            window.location.href = 'DataManagement.aspx';
                                        }
                                    }
                                }
                            });
                    });
                    </script>";

            Viewport_Add.Controls.Add(new LiteralControl(jquery));
        }
Exemplo n.º 26
0
        public async Task InitializationMemberDataTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Member         member         = new Member();

            member.MemberId   = "unitTest4";
            member.MemberName = "zxczxc";
            member.Password   = "******";
            member.Phone      = "0326598741";
            member.Birthday   = "10/10/1659";
            member.Sexuality  = "女";

            await databaseSystem.UpdateMemberInfo(member);

            List <Member> memberList = await databaseSystem.InitializationMemberData();

            await databaseSystem.Delete("unitTest4", "Member");

            Assert.IsNotNull(memberList.Find(x => x.MemberId == "unitTest4"));
        }
Exemplo n.º 27
0
        public ActionResult Index(int id = -1)
        {
            List <Product>        products    = DatabaseSystem.GetInstance().GetProductsForCategory(id);
            List <SelectListItem> catDropDown = new List <SelectListItem>();

            catDropDown.Add(new SelectListItem {
                Value = "-1", Text = "All"
            });
            foreach (Category c in DatabaseSystem.GetInstance().GetCategories())
            {
                catDropDown.Add(new SelectListItem {
                    Value = String.Format("{0}", c.CategoryID),
                    Text  = c.Title
                });
            }

            ViewBag.categories = catDropDown;
            ViewBag.products   = products;


            return(View());
        }
Exemplo n.º 28
0
        protected void Delete_Category_Click(object sender, EventArgs e)
        {
            String jquery;

            Viewport_Data.Controls.Clear();


            if (Categories.SelectedIndex > -1)
            {
                String selectedCatID = Categories.SelectedItem.Value;

                if (DatabaseSystem.GetInstance().DeleteCategory(selectedCatID))
                {
                    jquery = @"<script>
                    $(function() {
               
                            bootbox.alert('Successfully removed category " + Categories.SelectedItem.Text + " !', function() {});});</script>";

                    Categories.Items.Clear();
                    FillDropDown();
                }
                else
                {
                    jquery = @"<script>
                    $(function() {
               
                            bootbox.alert('Unable to remove category " + Categories.SelectedItem.Text + " !', function() {});});</script>";
                }
            }
            else
            {
                jquery = @"<script>
                $(function() {
               
                        bootbox.alert('Error, selected index is < 0 !', function() {});});</script>";
            }

            Viewport_Data.Controls.Add(new LiteralControl(jquery));
        }
Exemplo n.º 29
0
        public async Task UpdateInvitedListTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            Member         member         = new Member();

            member.MemberId   = "unitTest4";
            member.MemberName = "zxczxc";
            member.Password   = "******";
            member.Phone      = "0326598741";
            member.Birthday   = "10/10/1659";
            member.Sexuality  = "女";

            Dictionary <string, string> newInvitedList = new Dictionary <string, string>();

            newInvitedList.Add("1", "asd123");

            await databaseSystem.UpdateMemberInfo(member);

            var result = await databaseSystem.UpdateInvitedList("unitTest4", newInvitedList);

            await databaseSystem.Delete("unitTest4", "Member");

            Assert.IsTrue(result);
        }
Exemplo n.º 30
0
        public async Task GetChatDataTest()
        {
            DatabaseSystem databaseSystem = new DatabaseSystem();
            List <Message> messages       = new List <Message>();

            Message  message  = new Message("unitTest1", "unitTest1", "unitTestMessage");
            Activity activity = new Activity();

            activity.ActivityId     = "99";
            activity.ActivityName   = "unitTest2";
            activity.HomeOwnerId    = "unitTest1";
            activity.ActivityDate   = "2020/02/02";
            activity.ActivityNote   = "unitTest";
            activity.NumberOfPeople = "3";
            await databaseSystem.InsertActivity(activity);

            await databaseSystem.SendMessage("99", message);

            messages = await databaseSystem.GetChatData("99");

            await databaseSystem.Delete("99", "Activity");

            Assert.AreEqual("unitTest1", messages[0].MemberId);
        }
 public RecentConnectionString(DatabaseSystem system, Database database)
 {
     DatabaseSystem = system;
     ConnectionString = database.ConnectionString;
     Name = database.Name;
 }