コード例 #1
0
 public Document GetDocumentById(int documentId)
 {
     var documents = new Document();
     using (_db)
     {
         documents = _db.tblDocuments.Where(p => p.Id == documentId && p.Active == true).Select(
              p =>
              new Document
              {
                  DocumentId = p.Id,
                  Name = p.Name,
                  ServerPath = p.ServerPath,
                  ServerName = p.ServerName,
                  Active = true,
                  LastUpdated = p.LastUpdated,
                  DocumentType = new DocumentType { TypeId = p.tlbDocumentType.Id, Type = p.tlbDocumentType.Type }
              }).SingleOrDefault();
     }
     return documents;
 }
コード例 #2
0
        private Document MoveFile(Document document)
        {
            var date = Convert.ToDateTime(document.DocumentDate);
            var serverPath = GetFileStore().Replace("\\","/") + date.Year + "/" + date.Month + "/" + date.Day + "/" + document.DocumentType.Type;
            var webPath = "/FileStore/" + date.Year + "/" + date.Month + "/" + date.Day + "/" +
                          document.DocumentType.Type;
            var fileName = document.DocumentId + "_" + document.DocumentType.Type + Path.GetExtension(document.Name);

            var destFile = serverPath + "/" + fileName;
            var sourceFile = GetServerDriveLetter() + document.ServerPath + "/" + document.Name;

            if (!Directory.Exists(serverPath))
            {
                Directory.CreateDirectory(serverPath);
            }

            File.Move(sourceFile, destFile);

            document.Name = fileName;
            document.ServerPath = webPath;

            return document;
        }
コード例 #3
0
 public void SaveDocument(Document document)
 {
     var d = new tblDocument();
     using (_db)
     {
         d = _db.tblDocuments.SingleOrDefault(x => x.Id == document.DocumentId);
         d.ChartId = document.ChartId;
         d.Description = document.Description;
         d.DocumentDate = document.DocumentDate;
         d.LastUpdated = DateTime.Now;
         d.Name = document.Name;
         d.VisitId = document.Visit.VisitId;
         d.TypeId = document.DocumentType.TypeId;
         d.ServerPath = document.ServerPath;
         _db.SubmitChanges();
     }
 }