public static Task<DocumentReference> New (string path, string defaultExt, IFileSystem fs, DocumentConstructor dctor, string contents = null) { var dir = Path.GetDirectoryName (path); var ext = Path.GetExtension (path); if (string.IsNullOrEmpty (ext)) ext = defaultExt; var baseName = Path.GetFileNameWithoutExtension (path); return New (dir, baseName, ext, fs, dctor, contents); }
public DocumentReference (IFile file, DocumentConstructor dctor, bool isNew) { if (file == null) throw new ArgumentNullException ("file"); if (dctor == null) throw new ArgumentNullException ("dctor"); File = file; IsNew = isNew; this.dctor = dctor; }
public DocumentReference(IFile file, DocumentConstructor dctor, bool isNew) { if (file == null) { throw new ArgumentNullException("file"); } if (dctor == null) { throw new ArgumentNullException("dctor"); } File = file; IsNew = isNew; this.dctor = dctor; }
public ActionResult Document(long id, int year, EditMode?mode, long?creatorID) { Document currentDocument = null; long currentUserID = User.Identity.GetUserId <long>(); if (!creatorID.HasValue)//если обычный пользователь, то его id и есть id создателя { creatorID = currentUserID; } if (_documentRepository.IsDocumentAllowUser(mode, id, currentUserID)) { currentDocument = _documentRepository.GetByYear(id, creatorID.Value, year); if (currentDocument == null) { var documentType = _documentTypeRepository.GetById(id); if (documentType != null) { var creator = _userRepository.GetById(creatorID.Value); currentDocument = new Document { DocumentType = documentType, DateCreated = DateTime.Now, DateChanged = DateTime.Now, Creator = creator }; _documentRepository.Add(currentDocument); } else { return(HttpNotFound()); } } var documentConstructor = new DocumentConstructor { DocumentID = currentDocument.DocumentID, MaxPoint = currentDocument.DocumentType.MaxPoint, Name = currentDocument.DocumentType.Name, Mode = mode, CreatorID = creatorID.Value }; return(View(documentConstructor)); } return(HttpNotFound()); }
async Task LoadDocsUnsafe() { // Console.WriteLine ("LOAD"); var fs = FileSystemManager.Shared.ActiveFileSystem; SetTitle(); DocumentConstructor dctor = DocumentAppDelegate.Shared.App.CreateDocument; // // Get the items // var files = await fs.ListFiles(Directory); var newItems = (from f in files select new DocumentsViewItem( new DocumentReference(f, dctor, isNew: false))).ToList(); foreach (var item in newItems) { if (item.Reference.File.IsDirectory) { if (fs.ListFilesIsFast) { // Console.WriteLine ("Listing subrefs for " + item.Reference.File); item.SubReferences = (from f in await fs.ListFiles(item.Reference.File.Path) where !f.IsDirectory select new DocumentReference(f, dctor, isNew: false)).ToList(); } else { item.SubReferences = new List <DocumentReference> (); } } } loadedOnce = true; SortNewItems(newItems); SetNewItems(newItems); }
public static async Task<DocumentReference> New (string directory, string baseName, string ext, IFileSystem fs, DocumentConstructor dctor, string contents = null) { if (ext [0] != '.') { ext = '.' + ext; } // // Get a name // var n = baseName + ext; var i = 1; var p = Path.Combine (directory, n); var files = await fs.ListFiles (directory); while (files.Exists (x => x.Path == p)) { i++; n = baseName + " " + i + ext; p = Path.Combine (directory, n); } return new DocumentReference (await fs.CreateFile (p, contents), dctor, isNew: true); }
async Task LoadDocsUnsafe() { // Console.WriteLine ("LOAD"); var fs = FileSystemManager.Shared.ActiveFileSystem; SetTitle(); DocumentConstructor dctor = DocumentAppDelegate.Shared.App.CreateDocument; // // Get the items // var files = await fs.ListFiles(Directory); var newItems = (from f in files select new DocumentsViewItem( new DocumentReference(f, dctor, isNew: false))).ToList(); foreach (var item in newItems) { if (item.Reference.File.IsDirectory) { if (fs.ListFilesIsFast) { // Console.WriteLine ("Listing subrefs for " + item.Reference.File); item.SubReferences = (from f in await fs.ListFiles(item.Reference.File.Path) where !f.IsDirectory select new DocumentReference(f, dctor, isNew: false)).ToList(); } else { item.SubReferences = new List <DocumentReference> (); } } } // // Sort them // if (SortOrder == DocumentsSort.Date) { newItems.Sort((a, b) => b.ModifiedTime.CompareTo(a.ModifiedTime)); foreach (var item in newItems) { if (item.SubReferences != null) { item.SubReferences.Sort((a, b) => b.ModifiedTime.CompareTo(a.ModifiedTime)); } } } else { newItems.Sort((a, b) => string.Compare(a.Reference.Name, b.Reference.Name, StringComparison.OrdinalIgnoreCase)); foreach (var item in newItems) { if (item.SubReferences != null) { item.SubReferences.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); } } } items = newItems; Docs = newItems.Select(x => x.Reference).ToList(); ReloadData(); UpdateToolbar(false); }
public void MapBuildingFormElements() { ConstructingFormElements = DocumentConstructor.CunstructDocument(OrginalText); }
public DocumentProcessor() { DocumentBuilder = new DocumentBuilder(); DocumentConstructor = new DocumentConstructor(); DocumentEvaluator = new DocumentEvaluator(); }
public static async Task <DocumentReference> New(string directory, string baseName, string ext, IFileSystem fs, DocumentConstructor dctor, string contents = null) { if (ext [0] != '.') { ext = '.' + ext; } // // Get a name // var n = baseName + ext; var i = 1; var p = Path.Combine(directory, n); var files = await fs.ListFiles(directory); while (files.Exists(x => x.Path == p)) { i++; n = baseName + " " + i + ext; p = Path.Combine(directory, n); } return(new DocumentReference(await fs.CreateFile(p, contents), dctor, isNew: true)); }
public static Task <DocumentReference> New(string path, string defaultExt, IFileSystem fs, DocumentConstructor dctor, string contents = null) { var dir = Path.GetDirectoryName(path); var ext = Path.GetExtension(path); if (string.IsNullOrEmpty(ext)) { ext = defaultExt; } var baseName = Path.GetFileNameWithoutExtension(path); return(New(dir, baseName, ext, fs, dctor, contents)); }