Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/21/11 22:07:58 (13 years ago)
Author:
wtollsch
Message:

#1433 AlgorithmClass, Algorithm, ProblemClass, Problem create/update appropriate controller/models/views, File upload (Algorithm / Problem)

Location:
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AdminController.cs

    r6218 r6246  
    66using System.Web.Security;
    77using System.ServiceModel.Security;
    8 //using HLWebPluginHost.OKBService;
    98using System.Diagnostics;
    109using HLWebOKBAdminPlugin.OKBAdministrationService;
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmController.cs

    r6213 r6246  
    66using HLWebOKBAdminPlugin.Models;
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
     8using System.IO;
    89
    910namespace HLWebOKBAdminPlugin.Controllers
     
    7980        }
    8081
     82        public ActionResult UploadFile(FormCollection collection) {
     83            Session["SelectedSubMenu"] = "Algorithm";
     84
     85            long algorithmId = long.Parse(collection.Get("AlgorithmId"));
     86
     87            AlgorithmModel pm = new AlgorithmModel();
     88
     89            foreach (string inputTagName in Request.Files) {
     90                HttpPostedFileBase file = Request.Files[inputTagName];
     91                if (file.ContentLength > 0) {
     92                    // maybe for storage on server
     93                    //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
     94                    if (file.InputStream.CanRead) {
     95                        //file length
     96                        int fileLength = file.ContentLength;
     97
     98                        //bytearray
     99                        byte[] data = new byte[fileLength];
     100
     101                        //initialize input stream
     102                        Stream dataStream = file.InputStream;
     103
     104                        //read file into byte array
     105                        dataStream.Read(data, 0, fileLength);
     106
     107                        //save data
     108                        pm.UpdateAlgorithmData(algorithmId, data);
     109                    }//if
     110                }
     111            }//foreach
     112
     113            return View("Index", pm);
     114        }//UploadFile
     115
    81116        /// <summary>
    82117        /// Controller for Detail View
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs

    r6213 r6246  
    66using HLWebOKBAdminPlugin.Models;
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
     8using System.IO;
    89
    910namespace HLWebOKBAdminPlugin.Controllers
     
    8889            return View("Index", pm);
    8990        }
     91       
     92        public ActionResult UploadFile(FormCollection collection) {
     93            Session["SelectedSubMenu"] = "Problem";
     94
     95            long problemId = long.Parse(collection.Get("ProblemId"));           
     96
     97            ProblemModel pm = new ProblemModel();
     98
     99            foreach (string inputTagName in Request.Files) {
     100                HttpPostedFileBase file = Request.Files[inputTagName];
     101                if (file.ContentLength > 0) {
     102                    // maybe for storage on server
     103                    //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
     104                    if (file.InputStream.CanRead) {
     105                        //file length
     106                        int fileLength = file.ContentLength;
     107
     108                        //bytearray
     109                        byte[] data = new byte[fileLength];
     110
     111                        //initialize input stream
     112                        Stream dataStream = file.InputStream;
     113
     114                        //read file into byte array
     115                        dataStream.Read(data, 0, fileLength);
     116
     117                        //save data
     118                        pm.UpdateProblemData(problemId, data);
     119                    }//if
     120                }
     121            }//foreach
     122
     123            return View("Index", pm);
     124        }//UploadFile
    90125
    91126        /// <summary>
Note: See TracChangeset for help on using the changeset viewer.