/// <summary> /// Löscht das angegebene Document. /// </summary> /// <param name="document"></param> public void Delete(Document document) { Require.NotNull(document, nameof(document)); DeleteContent(document); DocumentDao.Delete(document); }
public ActionResult Category(long id, int page = 1, int pageSize = 8) { var category = new DocumentCategoryDao().ViewDetail(id); ViewBag.Category = category; int total = 0; var model = new DocumentDao().ListAllToPage(id, ref total, page, pageSize); ViewBag.Total = total; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)total / (double)pageSize); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
// GET: Home public ActionResult Index() { var document = new DocumentDao(); ViewBag.NewDocument = document.ListDocumentNew(8); return(View()); }
public ActionResult Edit(long id) { var dao = new DocumentDao(); var document = dao.GetById(id); SetViewBag(document.CategotyID); return(View(document)); }
public ActionResult Detail(string searchString, int page = 1, int pageSize = 5) { var dao = new DocumentDao(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
public string getListaDocumentos() { IDocumentDao DocumentDao = new DocumentDao(); Documentos listaDocumentos = DocumentDao.ListaDocumentos(); var json = new JavaScriptSerializer().Serialize(listaDocumentos); return(json); }
public Document Create(UploadedFile uploadedFile) { Require.NotNull(uploadedFile, nameof(uploadedFile)); Document document = new Document(uploadedFile); CreateContent(uploadedFile); document = DocumentDao.Save(document); return(document); }
public ActionResult Detail(long id) { var model = new DocumentDao(); var category = new DocumentCategoryDao(); var document = model.ViewDetail(id); ViewBag.ListDocument = model.ListDocument(document.CategotyID, 4); ViewBag.ListCategory = category.ListAll(); ViewBag.Category = category.ViewDetail(document.CategotyID.Value); return(View(document)); }
// GET: Admin/Login public ActionResult Index() { var document = new DocumentDao(); var feedback = new FeedbackDao(); ViewBag.FeedbackCount = feedback.GetCountFeedback(); ViewBag.DocumentCount = document.GetTotalDocument(); ViewBag.TotalView = document.GetTotalView(); ViewBag.Feedback = feedback.GetFeedback(); return(View()); }
public Document Create(string originalFileName, string fileName, string contentType, int contentLength, bool persist = true) { Document document = new Document(originalFileName, Path.GetFileName(fileName), contentType, contentLength); if (persist) { DocumentDao.Save(document); DocumentDao.Flush(); } return(document); }
private Document GetCurrentDocument() { var dao = new DocumentDao(); var converter = new DocumentConverter(); var document = converter.Convert(dao.GetByDraftee(DrafteeId)); if (document == null) { document = new Document(); document.DrafteeId = DrafteeId; } return(document); }
public string getDocumentoPorId(int IdDocumento) { FiltroDocumento documentoFiltro = new FiltroDocumento(); documentoFiltro.IdDocumento = IdDocumento; IDocumentDao DocumentDao = new DocumentDao(); Documento documento = DocumentDao.DocumentById(documentoFiltro); var json = new JavaScriptSerializer().Serialize(documento); return(json); }
public string getListaDocumentosPorNombre(string nombreDocumento) { FiltroDocumento documentoFiltro = new FiltroDocumento(); documentoFiltro.NombreDocumento = nombreDocumento; IDocumentDao DocumentDao = new DocumentDao(); Documentos documento = DocumentDao.DocumentByName(documentoFiltro); var json = new JavaScriptSerializer().Serialize(documento); return(json); }
public string getListaDocumentosPorFecha(string fechaInicial, string fechaFinal) { FiltroDocumento documentoFiltro = new FiltroDocumento(); documentoFiltro.fechaInicial = fechaInicial; documentoFiltro.fechaFinal = fechaFinal; IDocumentDao DocumentDao = new DocumentDao(); Documentos documento = DocumentDao.DocumentByDate(documentoFiltro); var json = new JavaScriptSerializer().Serialize(documento); return(json); }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { FillData(GetCurrentDraftee()); var dao = new DocumentDao(); var converter = new DocumentConverter(); var document = converter.Convert(dao.GetByDraftee(DrafteeId)); if (document != null) { Document = document; } else { Document = new Document(); Document.DrafteeId = DrafteeId; } }
private void EditButton_OnClick(object sender, RoutedEventArgs e) { var validator = new DocumentValidator(); if (validator.Validate(Document)) { var dao = new DocumentDao(); dao.InsertUpdate(Document); Close(); } else { MessageBox.Show( this, string.Format("Данные не прошли проверку.\nСообщение об ошибке: \"{0}\"", validator.Message), "Сообщение"); } }
public ActionResult Edit(Document model) { if (ModelState.IsValid) { var dao = new DocumentDao(); var result = dao.Update(model); if (result) { SetAlert("Edit User Successful!!", "success"); return(RedirectToAction("Index", "Document")); } else { ModelState.AddModelError("", "Update document not successfull!!"); } } SetViewBag(model.CategotyID); return(View()); }
public ActionResult Create(Document model) { if (ModelState.IsValid) { var dao = new DocumentDao(); long id = dao.Insert(model); if (id > 0) { SetAlert("Add Document Successful!!", "success"); return(RedirectToAction("Index", "Document")); } else { ModelState.AddModelError("", "Add document not successfull!!"); } } SetViewBag(); return(View()); }
public ActionResult ListDocSearch(string searchString, int page = 1, int pageSize = 1) { int total = 0; var model = new DocumentDao().ListDocSearch(searchString, ref total, page, pageSize); ViewBag.SearchString = searchString; ViewBag.Total = total; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(total / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
private void LoadDoc(Int32 docId) { IDataReader rdr = DocumentDao.GetDocument(docId); if (rdr.Read()) { Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", string.Format("attachment; Filename = {0}.pdf", "NPC")); byte[] buffer = new byte[ONE_KB]; long idx = 0, size = 0; //Write the BLOB chunk by chunk. while ((size = rdr.GetBytes(1, idx, buffer, 0, ONE_KB)) == ONE_KB) { Response.BinaryWrite(buffer); idx += ONE_KB; } //Write the last bytes. if (size > 0) { byte[] remaining = new byte[size]; Array.Copy(buffer, 0, remaining, 0, size); Response.BinaryWrite(remaining); } Response.Flush(); Response.Close(); } rdr.Close(); }
public void Setup() { _tested = new DocumentDao(); }
public ActionResult saveDocument(Document document) { // if(model.ProjectId=="" || model.MainSection.) // return Redirect("../Document/AddDocument"); string result = ""; StringBuilder client = new StringBuilder(); //client stringBulder is used for holding <ClientSide Type=""> data like wise server,database,service, StringBuilder server = new StringBuilder(); StringBuilder database = new StringBuilder(); StringBuilder service = new StringBuilder(); StringBuilder param = new StringBuilder(); //param is used for holding client,server, database, service data's string commonRow = Request.Form["common_row"]; //used for store added client,server.database, service data's ex: it store client_row0,server_row0,database_row0,service_row0 string[] commonArray = commonRow.Split(','); string clients, servers, databases, services; document.created_by = Request.Form["CreatedBy"]; string created_by = document.created_by; int document_id = 0; document.docFunList = new List <DocumentFunction>(); DocumentDao docDao = new DocumentDao(); try { if (document.Image != null) { List <project> projctList = doctDto.GetProject(); string projectname = projctList.Where(w => w.Id == document.ProjectId).Select(s => s.ProjectName).First(); string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"].ToString(); string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"].ToString(); var s3client = new AmazonS3Client(AWSAccessKey, AWSSecretKey, Amazon.RegionEndpoint.USEast1); TransferUtility utility = new TransferUtility(s3client); TransferUtilityUploadRequest request = new TransferUtilityUploadRequest(); Stream inputstream = document.Image.InputStream != null ? document.Image.InputStream : null; string contenttype = "image/jpeg"; string FileName = document.MainSection; string Extension = document.Image.FileName.Split('.')[1]; string bucket = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["imagebucket"]) ? ConfigurationManager.AppSettings["imagebucket"] : string.Empty; FileName = FileName + "." + Extension; request.BucketName = bucket + projectname; request.CannedACL = S3CannedACL.PublicRead; request.Key = FileName; request.InputStream = inputstream; request.ContentType = contenttype; utility.Upload(request); Amazon.S3.IO.S3FileInfo fileinfo = new Amazon.S3.IO.S3FileInfo(s3client, bucket + projectname, Path.GetFileName(FileName)); if (fileinfo.Exists) { document.ImageName = FileName; var res = "success"; } } string root = "<Root>" + "<Document ProjectId=\"" + document.ProjectId + "\" MainSection=\"" + document.MainSection + "\" Controller=\"" + document.Controller + "\" Action=\"" + document.Action + "\" Url=\"" + document.Url + "\" SubSection=\"" + document.SubSection + "\" FunctionalityDescription=\"" + document.FunctionalityDescription + "\" Image=\"" + document.ImageName + "\" >"; clients = "<ClientSide Type=\"" + "Client" + "\">"; servers = "<ServerSide Type =\"" + "server" + "\">"; databases = "<Database Type=\"" + "Database" + "\">"; services = "<Service Type=\"" + "service" + "\"> "; param.Append(root); client.Append(clients); server.Append(servers); database.Append(databases); service.Append(services); foreach (string str in commonArray) { if (string.IsNullOrEmpty(str)) { continue; } DocumentFunction docFun = new DocumentFunction(); docFun.FunctionName = Request.Form[str + "Name"]; if (!string.IsNullOrEmpty(docFun.FunctionName)) { docFun.Input = Request.Form[str + "input"]; docFun.Output = Request.Form[str + "output"]; docFun.FunctionDescription = Request.Form[str + "dDescription"]; docFun.ServerSideScripting = Request.Form[str + "server"]; docFun.Database = Request.Form[str + "database"]; docFun.Service = Request.Form[str + "service"]; docFun.LinkingMethod = Request.Form[str + "linkmethod"]; docFun.Procedure = Request.Form[str + "procedure"]; docFun.TableorViewUsed = Request.Form[str + "tables"]; docFun.CreatedBy = Request.Form["CreatedBy"]; docFun.Type = str.Substring(0, str.IndexOf('_')); //get the function type whether it is client or server or database or service document.docFunList.Add(docFun); string source = "<Source FunctionName=\"" + docFun.FunctionName + "\" FunctionDescription =\"" + docFun.FunctionDescription + "\" Input=\"" + docFun.Input + "\"" + " Output =\"" + docFun.Output + "\" ServerSideScripting =\"" + docFun.ServerSideScripting + "\" Database =\"" + docFun.Database + "\" Service =\"" + docFun.Service + "\" LinkingMethod =\"" + docFun.LinkingMethod + "\" Procedure =\"" + docFun.Procedure + "\" TableorViewUsed =\"" + docFun.TableorViewUsed + "\" />"; if (docFun.Type.ToString() == "client") { client.Append(source); } else if (docFun.Type.ToString() == "server") { server.Append(source); } else if (docFun.Type.ToString() == "database") { database.Append(source); } else if (docFun.Type.ToString() == "service") { service.Append(source); } } } client.Append("</ClientSide>"); server.Append("</ServerSide>"); database.Append("</Database>"); service.Append("</Service>"); param.Append(client); param.Append(server); param.Append(database); param.Append(service); param.Append("</Document></Root>"); result = docDao.InsertNewDocument(param, document.Id, created_by); } catch (Exception e) { } //if (result == "success") // return "success"; //else // return "failed"; if (document != null && document.Id != 0) { return(RedirectToAction("EditDocument", "Document", new { docid = document.Id, from = "update" })); } else { return(RedirectToAction("AddDocument", "Document")); } }