Пример #1
0
 protected void SG_uploadButton_Click(object sender, EventArgs e)
 {
     if (SG_fileUpload.PostedFile.ContentLength > 1024)
     {
         SG_uploadLabel.CssClass = "text-danger";
         SG_uploadLabel.Text     = "Rozmiar pliku musi być mniejszy niż 1 KB (obecny rozmiar: " + (SG_fileUpload.PostedFile.ContentLength / 1024) + " KB)";
     }
     else if (SG_fileUpload.HasFile)
     {
         string SG_serverPath = Page.MapPath("./SG_Pliki/");;
         string SG_filePath   = SG_serverPath + SG_fileUpload.FileName;
         if (!File.Exists(SG_filePath))
         {
             SG_fileUpload.SaveAs(SG_filePath);
             SG_DBManager.addRecord(SG_fileUpload.FileName, HttpContext.Current.User.Identity.Name);
             SG_fileListView.DataBind();
             SG_uploadLabel.CssClass = "text-primary";
             SG_uploadLabel.Text     = "Pomyślnie dodano plik '" + SG_fileUpload.FileName + "'";
         }
         else
         {
             SG_uploadLabel.CssClass = "text-warning";
             SG_uploadLabel.Text     = "Plik '" + SG_fileUpload.FileName + "' już znajduje się na serwerze.";
         }
     }
     else
     {
         SG_uploadLabel.CssClass = "text-warning";
         SG_uploadLabel.Text     = "Nie wybrano pliku.";
     }
     SG_checkFileCount();
 }
Пример #2
0
        protected void SG_LinkButton_delete_Command(object sender, CommandEventArgs e)
        {
            string   SG_filename = (string)e.CommandArgument;
            string   SG_filepath = Page.MapPath("./SG_Pliki/") + SG_filename;
            FileInfo SG_file     = new FileInfo(SG_filepath);

            if (SG_file.Exists)
            {
                SG_file.Delete();
                SG_DBManager.deleteFileRecord(SG_filename);
                SG_fileListView.DataBind();
            }
            SG_resetLabels();
        }
Пример #3
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Check if files in folder correspond to the filelist in database
            // if file is missing - delete record from database
            ArrayList SG_filelist   = SG_DBManager.dbFileList();
            string    SG_serverPath = Server.MapPath("./SG_Pliki/");

            foreach (string SG_filename in SG_filelist)
            {
                string SG_filePath = SG_serverPath + SG_filename;
                if (!File.Exists(SG_filePath))
                {
                    SG_DBManager.deleteFileRecord(SG_filename);
                }
            }
        }
Пример #4
0
 private void SG_checkFileCount()
 {
     if (SG_DBManager.numberOfFilesForUser(HttpContext.Current.User.Identity.Name) >= 2)
     {
         SG_overflowLabel.Visible  = true;
         SG_overflowLabel.CssClass = "text-info";
         SG_overflowLabel.Text     = "Możesz dodać maksymalnie 2 pliki, zwolnij miejsce, aby dodać plik.";
         SG_fileUpload.Enabled     = false;
         SG_uploadButton.Enabled   = false;
         SG_uploadButton.CssClass  = "btn btn-outline-secondary disabled";
     }
     else
     {
         SG_uploadButton.CssClass = "btn btn-outline-info";
         SG_uploadButton.Enabled  = true;
         SG_fileUpload.Enabled    = true;
         SG_overflowLabel.Visible = false;
         SG_overflowLabel.Text    = "";
     }
 }