public string GetAttachedOwlFile() { Session model_Session = new Session(); RdfFile model_RdfFile = new RdfFile(); string FileName = null; string CurrentUser = User.Identity.Name; if (CurrentUser.Equals("")) { //If there is no Session(User does not login) will user the defualt user [email protected] CurrentUser = "******"; model_Session = _ISession.SessionByUserId(CurrentUser); //To get the FileId from Session Table by UserId model_RdfFile = _IRdfFile.Details(model_Session.FileId); //To get the File Name from RdfFile Table by FileId } else { model_Session = _ISession.SessionByUserId(CurrentUser); //To get the FileId from Session Table by UserId model_RdfFile = _IRdfFile.Details(model_Session.FileId); //To get the File Name from RdfFile Table by FileId } if (model_RdfFile == null) { FileName = "Error"; } else { FileName = model_RdfFile.FileName; } return(FileName); }
public JsonResult Upload() { RdfFile model = new RdfFile(); string _FileName = string.Empty; if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any()) { var file = System.Web.HttpContext.Current.Request.Files["MyFile"]; var IsPublic = System.Web.HttpContext.Current.Request.Form["IsPublic"];//True Make it Pulic //Read OWL only... var _ext = Path.GetExtension(file.FileName); if (_ext.Equals(".owl")) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); Random rng = new Random(); int rand = rng.Next(1000); var _comPath = Server.MapPath("/DataSets/Id_") + rand + "_" + fileName; _FileName = "Id_" + rand + "_" + fileName; ViewBag.Msg = _comPath; var path = _comPath; // Saving file in Original Mode file.SaveAs(path); //here to add Image Path to You Database , model.FileName = _FileName; model.UserId = User.Identity.Name;//Need to read it form Identity model.IsPublic = Convert.ToBoolean(IsPublic); model.UploadDate = DateTime.Now; model.Size = (file.ContentLength / 1024); _IRdfFile.Save(model); // SaveToXMLDB(_FileName); //From Old Version // AttachOWLFile(_FileName);//From Old Version } } else { TempData["FileType"] = string.Format(""); return(Json("false")); } } return(Json(Convert.ToString(_FileName), JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadGateway)); } RdfFile model = _IRdfFile.Details(Id); if (model == null) { return(HttpNotFound()); } return(View(model)); }
public ActionResult DeleteConfirm(int?Id) { RdfFile model = _IRdfFile.Details(Id); if (model.UserId == User.Identity.Name) { RdfFile model_deleted = _IRdfFile.Delete(Id); if (model_deleted != null) { TempData["message"] = string.Format("{0} has been deleted successfully", model.FileName); } return(RedirectToAction("LoadOwlPublicFiles")); } TempData["message"] = string.Format("You Can't Delete this File {0} , it is not your file.", model.FileName); return(RedirectToAction("LoadOwlPublicFiles")); }