Ejemplo n.º 1
0
Archivo: SQL.cs Proyecto: SebaWic/MSKS
        //dodawanie nowego skryptu
        public bool AddNewScript(Script script)
        {
            string query = "INSERT INTO Script VALUES(@UserID, @DateOfCreate, @Path, @NameOfProject, @TypeOfDb, (SELECT Id FROM InstanceOfDb WHERE Name = @name), @UniqueName, @Version)";
            string query2 = "INSERT INTO ListOfScript VALUES(@UserID, (SELECT Id FROM Script WHERE UniqueName = @UniqueName))";
            query += query2;
            SqlCommand cmd = new SqlCommand(query, con);
            script.Path = "C:\\Praca inzynierska\\Projekt\\Pliki\\" + script.UniqueName;
            cmd.Parameters.AddWithValue("@UserID", script.UserID);
            cmd.Parameters.AddWithValue("@DateOfCreate", script.DateOfCreate);
            cmd.Parameters.AddWithValue("@Path", script.Path);
            cmd.Parameters.AddWithValue("@NameOfProject", script.NameOfProject);
            cmd.Parameters.AddWithValue("@TypeOfDb", script.TypeOfDb);
            cmd.Parameters.AddWithValue("@name", script.InstOfDb.Name);
            cmd.Parameters.AddWithValue("@UniqueName", script.UniqueName);
            cmd.Parameters.AddWithValue("@Version", script.Version);

            int rows = cmd.ExecuteNonQuery();
            if (rows == 2)
            {
                File file = new File();
                if (file.CreateFile(script.Path, script.Content))
                    return true;
                else
                    return false;
            }
            else
                return false;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }