Beispiel #1
0
 public string AfterAdd(AddScriptVM vm)
 {
     vm.script.UserID = vm.user.ID;
     vm.script.DateOfCreate = DateTime.Now;
     SQL sql = new SQL();
     sql.Connect();
     bool checkInst = sql.CheckNameInstance(vm.script.InOfDb);
     if (!checkInst)
         sql.AddInstanceDb(vm.script.InOfDb);
     vm.script.AddInstance(vm.script.InOfDb, sql.ReturnIdOfInstance(vm.script.InOfDb));
     vm.script.CreateUniqueName();
     if (sql.CheckUniqueName(vm.script.UniqueName))
     {
         return "Ta wersja już istnieje, przejdź do edycji.";
     }
     else
     {
         if (sql.AddNewScript(vm.script))
         {
             sql.Close();
             return "Dodano pomyślnie: " + vm.script.UniqueName;
         }
         else
         {
             sql.Close();
             return "Nie udało się.";
         }
     }
 }
Beispiel #2
0
        //jQuery
        public ActionResult Autocomplete(string term)
        {
            SQL sql = new SQL();
            sql.Connect();
            var items = sql.ReturnAllInstDB();
            sql.Close();

            var filteredItems = items.Where(item => item.IndexOf(term, StringComparison.InvariantCultureIgnoreCase) >= 0);
            return Json(filteredItems, JsonRequestBehavior.AllowGet);
        }
Beispiel #3
0
 public AccountVM(User user)
 {
     SQL sql = new SQL();
     sql.Connect();
     this.Scripts = sql.ReturnAllSCriptsByUser(user);
     foreach(Script item in this.Scripts)
     {
         item.InstOfDb.Name = sql.ReturnNameOfInstance(item.InstOfDb.ID);
     }
     sql.Close();
 }
Beispiel #4
0
        //Konto
        public ActionResult Account(int? page)
        {
            int pageSize = 10;
            int pageNum = (page ?? 1);

            //AccountVM vm = new AccountVM(User.Identity.Name);
            SQL sql = new SQL();
            sql.Connect();
            User user = sql.ReturnUserByName(User.Identity.Name);
            sql.Close();
            AccountVM vm = new AccountVM(user);
            return View(vm.Scripts.ToPagedList(pageNum, pageSize));
        }
Beispiel #5
0
        public void SetModel(string UserName)
        {
            SQL sql = new SQL();
            sql.Connect();
            this.user = sql.ReturnUserByName(UserName);
            this.user.Name = UserName;
            this.script = new Script();
            this.ListOfInstanceDb = new List<string>();
            ListOfInstanceDb = sql.ReturnAllInstDB();
            sql.Close();

            this.ListOfTypeOfDb = new List<string>();
            ListOfTypeOfDb.Add("ORACLE");
            ListOfTypeOfDb.Add("MSSQL");
            ListOfTypeOfDb.Add("POSTGRE");
        }
Beispiel #6
0
        //edytcja skryptu Account
        public string EditScript(Script sc)
        {
            SQL sql = new SQL();
            sql.Connect();

            Script script = sql.ReturnScriptByID(sc.ID);
            script.Content = sc.Content;
            if (script.CheckDate())//jesli true to daty sie zgadzaja
            {
                script.Version += 1;
                //instrukcja dla nadania wersji i unikalnej nazwy
                script.CreateUniqueName();

                while(sql.CheckUniqueName(script.UniqueName))
                {
                    script.Version += 1;
                    script.CreateUniqueName();
                }

                script.DateOfCreate = DateTime.Now;
            }
            else
            {
                script.Version = 0;
                script.CreateUniqueName();
                while (sql.CheckUniqueName(script.UniqueName))
                {
                    script.Version += 1;
                    script.CreateUniqueName();
                }
                script.DateOfCreate = DateTime.Now;
            }
            if (sql.EditScript(script))
            {
                sql.Close();
                return "Edytowano pomyślnie: " + script.UniqueName;
            }
            else
            {
                sql.Close();
                return "Nie udało się.";
            }
        }
Beispiel #7
0
        public PartialViewResult ScriptInfo(int id)
        {
            Script sc = new Script();
            SQL sql = new SQL();
            sql.Connect();
            sc = sql.ReturnScriptByID(id);
            sc.InOfDb = sql.ReturnNameOfInstance(sc.InstOfDb.ID);
            File file = new File();
            sc.Content = file.ReturnContentOfScript(sc.Path);
            sql.Close();

            return PartialView("_ScriptInfo", sc);
        }
Beispiel #8
0
        //usuwanie skryptu
        public ActionResult RemoveScript(int id)
        {
            Script sc = new Script();

            SQL sql = new SQL();
            sql.Connect();
            sc = sql.ReturnScriptByID(id);
            sql.DeleteScriptFromList(sc.ID);
            File f = new File();
            f.RemoveFile(sc.Path);
            sql.DeleteScriptFromScript(sc.ID);
            //AccountVM vm = new AccountVM(User.Identity.Name);
            User user = sql.ReturnUserByName(User.Identity.Name);
            AccountVM vm = new AccountVM(user);
            sql.Close();
            return View("Account", vm);
        }
Beispiel #9
0
        // GET: Home
        public ActionResult Index()
        {
            string name = User.Identity.Name;
            SQL sql = new SQL();
            sql.Connect();
            bool count = sql.CheckUserName(name);
            sql.Close();
            if (count)
            {
                return View();//Użytkownik istnieje
            }
            else
            {
                sql.Connect();
                sql.CreateUserAccount(name);
                sql.Close();

                return View();//stworzono nowego użytkownika
            }
        }