- Timestamp:
- 05/21/11 22:07:58 (14 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AdminController.cs
r6218 r6246 6 6 using System.Web.Security; 7 7 using System.ServiceModel.Security; 8 //using HLWebPluginHost.OKBService;9 8 using System.Diagnostics; 10 9 using HLWebOKBAdminPlugin.OKBAdministrationService; -
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmController.cs
r6213 r6246 6 6 using HLWebOKBAdminPlugin.Models; 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 using System.IO; 8 9 9 10 namespace HLWebOKBAdminPlugin.Controllers … … 79 80 } 80 81 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 81 116 /// <summary> 82 117 /// Controller for Detail View -
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs
r6213 r6246 6 6 using HLWebOKBAdminPlugin.Models; 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 using System.IO; 8 9 9 10 namespace HLWebOKBAdminPlugin.Controllers … … 88 89 return View("Index", pm); 89 90 } 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 90 125 91 126 /// <summary>
Note: See TracChangeset
for help on using the changeset viewer.