示例#1
0
 public void InsertTemplate(String virtualPath, String docType, String description, String userName)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         File file = (from p in dockerEntities.Files
                      where p.VirtualPath == virtualPath
                      select p).First();
         DCE_Templates template = new DCE_Templates();
         template.FileID           = file.ID;
         template.Name             = file.Name;
         template.VirtualPath      = file.VirtualPath;
         template.DateTimeUploaded = DateTime.Now;
         template.Description      = description;
         template.UserID           = (from a in dockerEntities.aspnet_Users where a.UserName == userName select a.UserId).First();
         template.DocumentType     = docType;
         try {
             dockerEntities.DCE_Templates.Add(template);
             dockerEntities.SaveChanges();
         } catch (DbEntityValidationException e) {
             foreach (var eve in e.EntityValidationErrors)
             {
                 System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                 foreach (var ve in eve.ValidationErrors)
                 {
                     System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                 }
             }
         }
     }
 }
示例#2
0
 public void InsertOCRContents(String fileName, String fileContents, String skipPages)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         DCE_Templates dCE_Templates = (from p in dockerEntities.DCE_Templates
                                        where p.Name == fileName
                                        select p).First();
         dCE_Templates.DocumentOCRContent = fileContents;
         dCE_Templates.SkipPages          = skipPages;
         dockerEntities.SaveChanges();
     }
 }
示例#3
0
 public DCE_Templates GetTemplateByVirtualPath(String virtualPath)
 {
     using (DockerDBEntities dockerEntities = new DockerDBEntities()) {
         DCE_Templates template = (from p in dockerEntities.DCE_Templates
                                   where p.VirtualPath == virtualPath
                                   select p).FirstOrDefault();
         if (template != null)
         {
             return(template);
         }
         else
         {
             return(null);
         }
     }
 }
示例#4
0
 private UploadedTemplates GenerateUploadedTemplates(DCE_Templates template)
 {
     if (template != null)
     {
         UploadedTemplates uploadedTemplate = new UploadedTemplates {
             Name             = template.Name,
             DocumentType     = template.DocumentType,
             VirtualPath      = template.VirtualPath,
             DateTimeUploaded = template.DateTimeUploaded.ToString(),
             Description      = template.Description,
             FileID           = template.FileID
         };
         return(uploadedTemplate);
     }
     return(null);
 }
示例#5
0
        public ActionResult GenerateKeywords(String virtualPath)
        {
            DCEOperations    dceOps           = new DCEOperations();
            TemplateKeywords templateKeywords = new TemplateKeywords();

            templateKeywords.Keywords = GetKeywordsByVirtualPath(virtualPath);
            DCE_Templates template = dceOps.GetTemplateByVirtualPath(virtualPath);

            if (template != null)
            {
                templateKeywords.Template  = GenerateUploadedTemplates(template);
                templateKeywords.SkipPages = template.SkipPages;
            }
            templateKeywords.TemplateOCRContent = template.DocumentOCRContent;
            return(View(templateKeywords));
        }
示例#6
0
        public ActionResult GenerateKeywords(TemplateKeywords templateKeywords, String virtualPath, String inputKeyword, String templateDocType, String submit)
        {
            DCEOperations dceOps   = new DCEOperations();
            DCE_Templates template = dceOps.GetTemplateByVirtualPath(virtualPath);

            if (template != null)
            {
                templateKeywords.Template  = GenerateUploadedTemplates(template);
                templateKeywords.SkipPages = template.SkipPages;
            }
            templateKeywords.TemplateOCRContent = template.DocumentOCRContent;
            switch (submit)
            {
            case "System Generation":
                templateKeywords.GeneratedBySystem = true;
                List <InputtedKeyword> arr = dceOps.GetKeywordsGeneratedBySystem(templateKeywords.Template);
                templateKeywords.Keywords = dceOps.GetKeywordsGeneratedBySystem(templateKeywords.Template);
                break;

            case "Keyword Checking":
                if (inputKeyword.Trim() == "")
                {
                    ViewData["GenerateKeywordsReturnMsg"] = "Input Keyword is empty ...";
                }
                else
                {
                    templateKeywords.GeneratedBySystem = true;
                    templateKeywords.Keywords          = dceOps.GetKeywordByInput(templateKeywords.Template, inputKeyword);
                }
                break;

            case "Added Keywords":
                return(RedirectToAction("GenerateKeywords", new { virtualPath = virtualPath }));

            case "Update":
                DocumentsOperations docOps = new DocumentsOperations();
                docOps.RenameDocumentTypeByVirtualPath(templateKeywords.Template.VirtualPath, templateDocType);
                templateKeywords.Template.DocumentType = templateDocType;
                break;

            default:
                templateKeywords.GeneratedBySystem = false;
                templateKeywords.Keywords          = GetKeywordsByVirtualPath(virtualPath);
                break;
            }
            return(View(templateKeywords));
        }
示例#7
0
        public void DownloadDCETEmplateJson(String virtualPath)
        {
            DCEOperations             dceOps   = new DCEOperations();
            DCE_Templates             template = dceOps.GetTemplateByVirtualPath(virtualPath);
            DCETemplateKeywordsInJson retJson  = new DCETemplateKeywordsInJson();

            if (template != null)
            {
                retJson.DocType = template.DocumentType;
                List <DCEKeysList> dceKeysList = new List <DCEKeysList>();
                foreach (InputtedKeyword keyword in GetKeywordsByVirtualPath(virtualPath))
                {
                    dceKeysList.Add(new DCEKeysList {
                        Keyword = keyword.Keyword, Rank = keyword.Rank
                    });
                    retJson.Score += keyword.Rank;
                }
                retJson.KeysList = dceKeysList;
            }
            HttpContext httpContext = this.HttpContext.ApplicationInstance.Context;

            UtilityOperations.DownloadJson(JsonConvert.SerializeObject(retJson), template.DocumentType, httpContext);
        }