private DocumentMeta AddNewDocument(HeliosObject profileObject) { DocumentMeta meta = FindDocumentMeta(profileObject); if (meta != null) { meta.document.IsSelected = true; return(meta); } HeliosEditorDocument editor = CreateDocumentEditor(profileObject); if (editor != null) { LayoutDocument document = new LayoutDocument(); document.Title = editor.Title; document.IsSelected = true; document.ContentId = HeliosSerializer.GetReferenceName(profileObject); document.Content = CreateDocumentContent(editor); // Since a new LayoutRoot object is created upon de-serialization, the Child LayoutDocumentPane no longer belongs to the LayoutRoot // therefore the LayoutDocumentPane 'DocumentPane' must be referred to dynamically // change added by yzfanimal LayoutDocumentPane DocumentPane = this.DockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); if (DocumentPane != null) { DocumentPane.Children.Add(document); } document.Closed += Document_Closed; meta = AddDocumentMeta(profileObject, document, editor); profileObject.PropertyChanged += DocumentObject_PropertyChanged; } return(meta); }
public ActionResult UploadDocument(int bureauId, int employerId, int employeeId, string description) { if (Request.Files != null && Request.Files.Count > 0) { var file = Request.Files[0]; var employee = _payrollBureauBusinessService.RetrieveEmployee(employeeId); var documentMeta = new DocumentMeta { EmployeeName = employee.Name, PayrollId = employeeId.ToString(), DocumentTypeId = (int)DocumentCategory.Document, FileName = file.FileName.Split('\\').Last().FilterSpecialChars(), CreatedBy = this.User.Identity.GetUserId(), UploadedDate = DateTime.UtcNow, Description = description }; var result = _documentBusinessService.CreateEmployeeDocument(documentMeta, employeeId, User.Identity.GetUserId()); if (result.Succeeded) { return(this.JsonNet(new { Success = true })); } } return(this.JsonNet(new { Success = false, Error = "Error uploading fit note file." })); }
public override T GetCount <T>(DocumentQuery query, DocumentMeta meta = null) { throw new NotImplementedException(); }
public static void AddKeys(this DocumentMeta meta, DocumentKey documentKey) { meta.Keys.Add(documentKey); }
public override void TruncateTypeOf(DocumentMeta meta) { throw new NotImplementedException(); }
public override void OnChangeDocuments(DocumentMeta meta, DocumentContext context) { throw new NotImplementedException(); }
public void Parse(IDocumentEngine engine, DocumentMeta meta, Document document, DocumentStorage storage) { }
public override void Set(DocumentMeta meta, int expire) { Database.Set(CacheOf(meta), meta, expire); }
public override void Remove(DocumentMeta meta) { Database.Remove(CacheOf(meta)); }
public void Add(DocumentMeta value) { List.Add(value); }
private DocumentMeta AddDocumentMeta(HeliosObject profileObject, LayoutDocument document, HeliosEditorDocument editor) { DocumentMeta meta = new DocumentMeta(); meta.editor = editor; meta.document = document; meta.hobj = profileObject; _documents.Add(meta); return meta; }
public override bool LoadDocumentType(string typeOf, bool isInitialize = false) { Logger?.Debug(ScopeType.Engine, $"Load TypeOf: {typeOf}"); var documentType = GetDocumentType(typeOf); var meta = new DocumentMeta(typeOf, documentType, Provider, Option); if (isInitialize && meta.Cache.Lazy) { return(true); } var files = new List <DocumentStorage>(); #region Files var directoryInfo = new DirectoryInfo(meta.Directory); if (directoryInfo.Exists) { var extentions = Option.Extention; var directoryFiles = directoryInfo.GetFiles(extentions, SearchOption.TopDirectoryOnly); meta.HasData = directoryFiles.Length > 0; var parts = new List <int>(); foreach (var file in directoryFiles) { var storage = new DocumentStorage(meta.TypeOf, Provider?.BaseDirectory, file); if (storage.Partition > meta.Partitions.Current) { meta.Partitions.Current = storage.Partition; } if (!parts.Contains(storage.Partition)) { parts.Add(storage.Partition); } files.Add(storage); } parts = parts.OrderBy(p => p).ToList(); foreach (var part in parts) { meta.Partitions.Add(part, 0); } meta.Partitions.Next = meta.Partitions.Current + 1; } #endregion if (files.Count == 0) { Logger?.Debug(ScopeType.Engine, "LoadDocumentType files.count = 0"); return(false); } Logger?.Debug(ScopeType.Engine, $"TypeOf:{typeOf} number of files : {files.Count}"); int bufferSize = Option.BufferSize; var serializer = new JsonSerializer(); var parser = GetDocumentParser(meta.TypeOf, OperationType.Load); foreach (DocumentStorage file in files) { Logger?.Debug(ScopeType.Engine, $"Read TypeOf: {file.TypeOf} - File : {file.Target}"); try { using (FileStream fs = new FileStream(file.Target, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize)) using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, true, bufferSize)) using (JsonReader reader = new JsonTextReader(sr)) { reader.SupportMultipleContent = false; while (reader.Read()) { if (reader.TokenType == JsonToken.StartObject) { var document = GetDocumentFromSource(ref meta, serializer.Deserialize <JObject>(reader), file.Partition); if (Option.SupportDocumentParser && parser != null) { parser.Parse(this, meta, document, file); } meta.SubmitChanges(document, OperationType.Load); Cache.Set(document, meta.Cache.Expire); document.Dispose(); } } } } catch (Exception ex) { Logger?.Fatal($"Exception Read TypeOf: {file.TypeOf} File : {file.Target}", ex); } } Cache.Set(meta, meta.Cache.Expire); Cache.Set(new DocumentSequence(typeOf, meta.Sequence)); documentType.Dispose(); meta.Dispose(); return(true); }
public virtual string CacheOf(DocumentMeta meta) { return(CacheOfMeta(meta.TypeOf)); }
public abstract void Set(DocumentMeta meta, int expire);
public abstract void Remove(DocumentMeta meta);