public static void GetDefaultDatabaseProcedure(EventNotificationData eventData, string storedProcedureName) { var parameters = new List <OdbcParameter>(); //Define parameters parameters.Add(new OdbcParameter { ParameterName = "StudentId", OdbcType = OdbcType.VarChar, Size = 9, Value = eventData.PropertyValues[EventPropertyConstants.StudentId].Value <string>() }); parameters.Add(new OdbcParameter { ParameterName = "AwardYear", OdbcType = OdbcType.VarChar, Size = 4, Value = eventData.PropertyValues[EventPropertyConstants.AwardYear].IsNullOrEmpty() ? string.Empty : (eventData.PropertyValues[EventPropertyConstants.AwardYear].Value <string>().Substring(2, 2) + eventData.PropertyValues[EventPropertyConstants.AwardYear].Value <string>().Substring(7, 2)) }); parameters.Add(new OdbcParameter { ParameterName = "TransactionCategoryId", OdbcType = OdbcType.Int, Value = eventData.PropertyValues[EventPropertyConstants.SvTransactionCategoryId].IsNullOrEmpty() ? 0 : eventData.PropertyValues[EventPropertyConstants.SvTransactionCategoryId].Value <int>() }); parameters.Add(new OdbcParameter { ParameterName = "EventNotificationId", OdbcType = OdbcType.Int, Value = eventData.PropertyValues[EventPropertyConstants.EventNotificationId].Value <int>() }); if (!eventData.PropertyValues[EventPropertyConstants.SvDocumentId].IsNullOrEmpty() && eventData.PropertyValues[EventPropertyConstants.SvDocumentId].Value <int>() > 0) { var manager = new DocumentManager(); DocumentMetaData metaData = manager.GetDocumentMetaData(eventData.PropertyValues[EventPropertyConstants.SvDocumentId].Value <int>()); parameters.Add(new OdbcParameter { ParameterName = "DocumentName", OdbcType = OdbcType.VarChar, Size = 128, Value = metaData != null ? metaData.DocumentName : string.Empty }); } else { parameters.Add(new OdbcParameter { ParameterName = "DocumentName", OdbcType = OdbcType.VarChar, Size = 128, Value = string.Empty }); } ClientDatabaseManager.ExecuteDatabaseStoredProcedure("{CALL " + storedProcedureName + " (?, ?, ?, ?, ?)}", parameters); }
public void ExportLinks(string space, string protocol, string qvsCluster, string qvwsMachine, string category, string csvFileName) { protocol = string.IsNullOrEmpty(protocol) ? "http" : protocol; links = new List <string>(); try { if (client != null) { ServiceInfo qvs = FindService(client, ServiceTypes.QlikViewServer, qvsCluster.Trim()); if (qvs == null) { commSupport.PrintMessage("Could not find QlikView Server", true); } ServiceInfo qvwsService = FindService(client, ServiceTypes.QlikViewWebServer, qvwsMachine.Trim()); if (qvwsService == null) { commSupport.PrintMessage("Could not find Qvws", true); } string qvwsUrl = qvwsService.Address.Scheme + "://" + qvwsService.Address.Host; links.Add("Name" + delimiter + "URL" + delimiter + "Description" + delimiter + "Space" + delimiter + "Type" + delimiter + "DateCreated"); client.ClearQVSCache(QVSCacheObjects.UserDocumentList); List <DocumentNode> userDocs = client.GetUserDocuments(qvs.ID); List <DocumentFolder> userDocFolders = client.GetUserDocumentFolders(qvs.ID, DocumentFolderScope.All); bool filterForCategories = !string.IsNullOrEmpty(category); foreach (DocumentNode userDoc in userDocs) { DocumentFolder docFolder = userDocFolders.FirstOrDefault(x => x.ID.Equals(userDoc.FolderID)); string mountName = string.Empty; if (docFolder != null) { mountName = docFolder.General.Path.ToLower(); } if (filterForCategories) { DocumentMetaData dmd = client.GetDocumentMetaData(userDoc, DocumentMetaDataScope.All); if (dmd.DocumentInfo.Category.ToLower().Equals(category.ToLower())) { ComposeDocumentLinkUrl(mountName, userDoc.RelativePath, qvwsUrl, userDoc.Name, qvsCluster, space, ""); } } else { ComposeDocumentLinkUrl(mountName, userDoc.RelativePath, qvwsUrl, userDoc.Name, qvsCluster, space, ""); } } WriteToCSVFile(csvFileName); } else { commSupport.PrintMessage("Could not create connection to QMS", true); } } catch (Exception e) { commSupport.PrintMessage("Exception when exporting links, run help command for information about usage: Exeception:" + e.Message, true); } }
private static void AddAuthorization(Guid qvsId, string doc, string name) { DocumentNode docNode = FindDoc(qvsId, doc); DocumentMetaData dm = apiClient.GetDocumentMetaData(docNode, DocumentMetaDataScope.Authorization); dm.Authorization.Access.Add(GetNewDocumentAcessEntry(name)); apiClient.SaveDocumentMetaData(dm); }
private static void RemoveAuthorization(Guid qvsId, string doc, string name) { DocumentNode docNode = FindDoc(qvsId, doc); DocumentMetaData dm = apiClient.GetDocumentMetaData(docNode, DocumentMetaDataScope.Authorization); DocumentAccessEntry dae = dm.Authorization.Access.Find(e => e.UserName == name); dm.Authorization.Access.Remove(dae); apiClient.SaveDocumentMetaData(dm); }
public PreparedDocumentExport(string documentName, string documentRoot, CodeExportResult code, DocumentMetaData metaData) { DocumentName = documentName; DocumentRoot = documentRoot; Code = code; MetaData = metaData; }
public bool UploadDocument(DocumentMetaData meta, object content) { if (!Documents.ContainsKey(meta.Name)) { var newDocument = DocumentFactory.CreateDocument(meta.Name); syncManager.SetContent(newDocument, content); Documents[meta.Name] = newDocument; return(true); } return(false); }
private static void OutputUserDocumentsAccessEntries(Guid qvsId) { List <DocumentNode> docs = apiClient.GetUserDocuments(qvsId); WriteDocumentAccessEntryHeader(); foreach (DocumentNode dn in docs) { DocumentMetaData m = apiClient.GetDocumentMetaData(dn, DocumentMetaDataScope.Authorization); foreach (DocumentAccessEntry dae in m.Authorization.Access) { WriteUserDocumentAccessEntry(dn, dae); } //WriteUserDocumentAccessEntry(dn.Name, dn.ID, m.Authorization.Access[0].UserName, m.Authorization.Access[0] } }
public async Task <IOTAwareContext> OpenDocumentAsync(string name) { var meta = new DocumentMetaData { Name = name, ClientId = this.Id }; if ((await Service.OpenDocumentAsync(meta))) { var openedDocument = DocumentFactory.CreateDocument(name); Documents[name] = openedDocument; syncManager.SetContent(openedDocument, await Service.SynchronizeDocumentAsync(meta)); return(openedDocument); } return(null); }
public bool CreateDocument(DocumentMetaData document) { if (!Documents.ContainsKey(document.Name)) { var newInstance = DocumentFactory.CreateDocument(document.Name); Documents[document.Name] = newInstance; var to = Clients.Where(c => c.Key != document.ClientId); Parallel.ForEach(to, c => c.Value.Client.NotifyDocumentCreated(document.Name)); return(true); } else { return(false); } }
public BulkDocumentMetaData(string indexName, string typeName) { if (string.IsNullOrEmpty(indexName)) { throw new ArgumentNullException(nameof(indexName)); } if (string.IsNullOrEmpty(typeName)) { throw new ArgumentNullException(nameof(typeName)); } MetaData = new DocumentMetaData { IndexName = indexName, TypeName = typeName, DocumentId = Guid.NewGuid().ToString("D") }; }
public async Task GetLatestItems() { var indexingBuffer = new IndexingBuffer( 20000, 20000, (indexBuffer, indexSize, contentBuffer, contentSize) => { var enumerable = new SortedIndexedDocumentEnumerable( indexBuffer, indexSize, contentBuffer); var allItems = enumerable.GetLatestItems(3).ToArray(); dynamic content1 = allItems[0].content; dynamic content2 = allItems[1].content; dynamic content3 = allItems[2].content; Assert.NotEqual(content1.name, content2.name); Assert.NotEqual(content2.name, content3.name); return(Task.CompletedTask); }); var doc1 = new { name = "Joe" }; var doc2 = new { name = "Bob" }; var doc3 = new { name = "Arthur" }; var buffer1 = Serialize(doc1); var buffer2 = Serialize(doc2); var buffer3 = Serialize(doc3); var meta1 = new DocumentMetaData("joe", null, 1, buffer1.Length); var meta2 = new DocumentMetaData("bob", null, 2, buffer2.Length); var meta3 = new DocumentMetaData("ar", null, 3, buffer3.Length); await indexingBuffer.WriteAsync(meta1, buffer1); await indexingBuffer.WriteAsync(meta2, buffer2); await indexingBuffer.WriteAsync(meta3, buffer3); await indexingBuffer.FlushAsync(); }
public static void ProcessPostedEvent(JObject notificationEvent) { try { using (var dbContext = new CampusLogicContext()) { var eventData = new EventNotificationData(notificationEvent); int eventNotificationId = eventData.PropertyValues[EventPropertyConstants.EventNotificationId].Value <int>(); var eventHandler = campusLogicConfigSection.EventNotifications.Cast <EventNotificationHandler>().FirstOrDefault(x => x.EventNotificationId == eventNotificationId) ?? campusLogicConfigSection.EventNotifications.Cast <EventNotificationHandler>().FirstOrDefault(x => x.EventNotificationId == 0); //If no specific handler was provided check for the catch all handler if (eventHandler != null) { //Enhance the Event Data for certain situations //Check if the transaction category was one of the three appeal types if (!eventData.PropertyValues[EventPropertyConstants.SvTransactionCategoryId].IsNullOrEmpty()) { if (((TransactionCategory)eventData.PropertyValues[EventPropertyConstants.SvTransactionCategoryId].Value <int>() != TransactionCategory.Verification && (TransactionCategory)eventData.PropertyValues[EventPropertyConstants.SvTransactionCategoryId].Value <int>() != TransactionCategory.Generic) && eventData.PropertyValues[EventPropertyConstants.EventNotificationName].Value <string>() == "Transaction Completed") { if (eventData.PropertyValues[EventPropertyConstants.SvTransactionId].IsNullOrEmpty()) { throw new Exception("A transaction Id is needed to get the appeal meta data"); } var manager = new AppealManager(); manager.GetAuthorizationForSV(); eventData.PropertyValues[EventPropertyConstants.TransactionOutcomeId] = manager.GetAppealMetaData(eventData.PropertyValues[EventPropertyConstants.SvTransactionId].Value <int>()).Result.ToString(); } } //Was a documentId sent over? If so, populate the Document Metadata. if (!eventData.PropertyValues[EventPropertyConstants.SvDocumentId].IsNullOrEmpty() && eventData.PropertyValues[EventPropertyConstants.SvDocumentId].Value <int>() > 0) { var manager = new DocumentManager(); DocumentMetaData documentMetaData = manager.GetDocumentMetaData(eventData.PropertyValues[EventPropertyConstants.SvDocumentId].Value <int>()); eventData.DocumentMetaData = documentMetaData; } //Check if this event notification is a communication event. If so, we need to call back to SV to get metadata about the communication if (eventNotificationId >= 300 && eventNotificationId <= 399) { if (eventData.PropertyValues[EventPropertyConstants.AdditionalInfoId].IsNullOrEmpty() || eventData.PropertyValues[EventPropertyConstants.AdditionalInfoId].Value <int>() == 0) { throw new Exception("An AdditionalInfoId is needed to get the communication event meta data"); } var manager = new CommunicationManager(); manager.GetAuthorizationForSV(); CommunicationActivityMetadata communicationActivityMetadata = manager.GetCommunicationActivityMetaData(eventData.PropertyValues[EventPropertyConstants.AdditionalInfoId].Value <int>()).Result; eventData.CommunicationActivityMetadata = communicationActivityMetadata; } //Check if this event notification is a Scholarship Universe Event (700's). If so, we need to call back to SU to get the metadata if (eventNotificationId >= 700 && eventNotificationId <= 799) { if (!eventData.PropertyValues[EventPropertyConstants.SuScholarshipAwardId].IsNullOrEmpty() && !eventData.PropertyValues[EventPropertyConstants.SuClientTermId].IsNullOrEmpty()) { var manager = new ScholarshipManager(); AwardPostItemData awardPostItemData = manager.GetAwardPostItemData( eventData.PropertyValues[EventPropertyConstants.SuScholarshipAwardId].Value <int>(), eventData.PropertyValues[EventPropertyConstants.SuClientTermId].Value <int>()); eventData.AwardPostItemData = awardPostItemData; } } // populate PropertyValues with all the values that have been gathered eventData.PopulatePropertyValues(); //Now Send it to the correct handler if (eventHandler.HandleMethod == "DatabaseCommandNonQuery") { DatabaseCommandNonQueryHandler(eventData, eventHandler.DbCommandFieldValue); } else if (eventHandler.HandleMethod == "DatabaseStoredProcedure") { DatabaseStoredProcedure(eventData, eventHandler.DbCommandFieldValue); } else if (eventHandler.HandleMethod == "DocumentRetrieval") { DocumentRetrievalHandler(eventData); } else if (eventHandler.HandleMethod == "DocumentRetrievalAndStoredProc") { DocumentRetrievalHandler(eventData); DatabaseStoredProcedure(eventData, eventHandler.DbCommandFieldValue); } else if (eventHandler.HandleMethod == "DocumentRetrievalAndNonQuery") { DocumentRetrievalHandler(eventData); DatabaseCommandNonQueryHandler(eventData, eventHandler.DbCommandFieldValue); } else if (eventHandler.HandleMethod == "FileStore") { FileStoreHandler(eventData); } else if (eventHandler.HandleMethod == "FileStoreAndDocumentRetrieval") { DocumentRetrievalHandler(eventData); //SV-2383: Moving the File Store handler *after* the Document Retrieval Handler so that if the Doc handler fails, it won't log the same event on retry. FileStoreHandler(eventData); } else if (eventHandler.HandleMethod == "AwardLetterPrint") { logger.Info("detect this is the AwardLetterPrint"); AwardLetterDocumentRetrievalHandler(eventData); } else if (eventHandler.HandleMethod == "BatchProcessingAwardLetterPrint") { logger.Info("detect this is the BatchProcessingAwardLetterPrint"); BatchProcessRetrievalHandler(ConfigConstants.AwardLetterPrintBatchType, eventHandler.BatchName, eventData); } else if (eventHandler.HandleMethod == "ApiIntegration") { ApiIntegrationsHandler(eventHandler.ApiEndpointName, eventData); } else if (eventHandler.HandleMethod == "PowerFAIDS") { PowerFaidsHandler(eventData); } } //Update the received event with a processed date time var eventId = eventData.PropertyValues[EventPropertyConstants.Id].Value <string>(); var storedEvent = dbContext.ReceivedEvents.FirstOrDefault(x => x.Id == eventId); if (storedEvent != null) { storedEvent.ProcessedDateTime = DateTime.UtcNow; dbContext.SaveChanges(); } } } catch (Exception ex) { //Log here any exceptions logger.ErrorFormat("DataService ProcessPostedEvent Error: {0}", ex); throw; } }
public IEnumerable <Operation> GetLog(DocumentMetaData document) { return(Documents[document.Name].Log); }
private void Button1Click1(object sender, EventArgs e) { Form metaDataExamples = new DocumentMetaData(); metaDataExamples.ShowDialog(); }
public void Consume(CreateDocumentMetaData command) { var document = new DocumentMetaData(command.AggregateId, command.Title, command.UtcTime); _repo().Save(document, CombGuid.Generate(), null); }
private void DisplayDocumentMetaData(DocumentMetaData m) { txtResult.Clear(); txtResult.Text += String.Format("Page Count: {0}, Mime Type: {1}, Extension: {2}{3}", m.PageCount, m.MimeType, m.Extension, Environment.NewLine); }
public bool OpenDocument(DocumentMetaData document) { return(Documents.ContainsKey(document.Name)); }
public object SynchronizeDocument(DocumentMetaData document) { return(syncManager.GetContent(Documents[document.Name])); }
public async void InsertData() { try { var oListData = ClientContext.Web.Lists.GetByTitle("Aftaler & dokumenter"); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query></Query></View>"; ListItemCollection oListDataItem = oListData.GetItems(camlQuery); ClientContext.Load(oListDataItem); ClientContext.Load(oListDataItem, t => t.Include(p => p.Id, p => p.ContentType, p => p.DisplayName, p => p.FieldValuesAsText)); ClientContext.ExecuteQuery(); log.Info($"Aftaler & dokumenter List data pulled successfully."); foreach (ListItem oItem in oListDataItem) { DocumentCategory category; List <PartnerType> partnerTypes = new List <PartnerType>(); try { log.Info($"Document data processing started Id :{oItem.GetId()}"); DocumentMetaData doc = new DocumentMetaData() { CreatedBy = oItem.GetAuthor(), CreatedDate = oItem.GetCreateDate(), LastModifiedBy = oItem.GetEditor(), LastModifiedDate = oItem.GetModifiedDate(), }; doc.ExpirationDate = oItem.GetModifiedDate(); if (oItem["RelatedPartnerType"] != null) { var childIdField = oItem["RelatedPartnerType"] as FieldLookupValue[]; if (childIdField != null) { foreach (var lookupValue in childIdField) { if (!DKBSDbContext.PartnerType.ToList().Exists(p => p.PartnerTypeTitle.ToLower() == lookupValue.LookupValue.ToLower())) { var partnerType = new PartnerType() { PartnerTypeTitle = lookupValue.LookupValue, CreatedBy = doc.CreatedBy, CreatedDate = doc.CreatedDate, LastModified = doc.LastModifiedDate, LastModifiedBy = doc.LastModifiedBy }; DKBSDbContext.PartnerType.Add(partnerType); DKBSDbContext.SaveChanges(); partnerTypes.Add(partnerType); } else { var partnerType = DKBSDbContext.PartnerType.FirstOrDefault(p => p.PartnerTypeTitle.ToLower() == lookupValue.LookupValue.ToLower()); if (partnerType != null) { partnerTypes.Add(partnerType); } } } } } ClientContext.Load(oItem.ContentType); ClientContext.ExecuteQuery(); if (!DKBSDbContext.DocumentCategory.ToList().Exists(p => p.CategoryName.ToLower() == oItem.ContentType.Name.ToLower())) { category = new Domain.DocumentCategory { CategoryName = oItem.ContentType.Name, CreatedBy = doc.CreatedBy, CreatedDate = doc.CreatedDate, LastModified = doc.LastModifiedDate, LastModifiedBy = doc.LastModifiedBy }; DKBSDbContext.DocumentCategory.Add(category); DKBSDbContext.SaveChanges(); } else { category = DKBSDbContext.DocumentCategory.FirstOrDefault(p => p.CategoryName.ToLower() == oItem.ContentType.Name.ToLower()); } if (oItem.FileSystemObjectType == FileSystemObjectType.File) { Microsoft.SharePoint.Client.File lfile = oItem.File; ClientContext.Load(lfile); ClientContext.ExecuteQuery(); doc.FileName = oItem.File.Name; log.Info($"Document uploading started FileName :{doc.FileName}"); var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ClientContext, lfile.ServerRelativeUrl); var url = await _storageService.SaveDocumentAsync(fileInfo.Stream, doc.FileName, category.DocumentCategoryId); log.Info($"Document uploaded sucessfully. started FileName :{doc.FileName} Category: {oItem.ContentType.Name}"); } var document = new Document() { DocumentCategoryId = category.DocumentCategoryId, ExpirationDate = doc.ExpirationDate, CreatedBy = doc.CreatedBy, CreatedDate = doc.CreatedDate, LastModified = doc.LastModifiedDate, LastModifiedBy = doc.LastModifiedBy, Details = doc.Detail, DocumentName = doc.FileName, FileName = doc.FileName }; foreach (var partnerType in partnerTypes) { var partnerTypeDoc = new PartnerTypeDocument(); partnerTypeDoc.DocumentId = document.DocumentId; partnerTypeDoc.PartnerTypeId = partnerType.PartnerTypeId; document.PartnerTypeDocuments.Add(partnerTypeDoc); } DKBSDbContext.Document.Add(document); DKBSDbContext.SaveChanges(); log.Info($"Document upload successfully Name :{doc.FileName}"); } catch (Exception ex) { ErrorCount += 1; log.Error($"Unable to upload file. Id:{oItem.GetId()}", ex); } } } catch (Exception ex) { ErrorCount += 1; log.Error("Unable to get documents data from sharepoint.", ex); } log.Info($"Total ErrorCount:{ErrorCount}"); }