public override void Execute() { base.Execute(); var files = _fileCollectionCombineable != null ? _fileCollectionCombineable.Files : new[] { BasicActivator.SelectFile("File to add") }; List <SupportingDocument> created = new List <SupportingDocument>(); foreach (var f in files) { var doc = new SupportingDocument((ICatalogueRepository)_targetCatalogue.Repository, _targetCatalogue, f.Name); doc.URL = new Uri(f.FullName); doc.SaveToDatabase(); created.Add(doc); } Publish(_targetCatalogue); Emphasise(created.Last()); foreach (var doc in created) { Activate(doc); } }
/// <summary> /// Extracts the <paramref name="doc"/> into the supplied <paramref name="directory"/> (unless overridden to put it somewhere else) /// </summary> /// <param name="doc"></param> /// <param name="directory"></param> /// <param name="listener"></param> /// <returns></returns> protected virtual bool TryExtractSupportingDocument(SupportingDocument doc, DirectoryInfo directory, IDataLoadEventListener listener) { SupportingDocumentsFetcher fetcher = new SupportingDocumentsFetcher(doc); listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Preparing to copy " + doc + " to directory " + directory.FullName)); try { var outputPath = fetcher.ExtractToDirectory(directory); if (_request is ExtractDatasetCommand) { var result = (_request as ExtractDatasetCommand).CumulativeExtractionResults; var supplementalResult = result.AddSupplementalExtractionResult(null, doc); supplementalResult.CompleteAudit(this.GetType(), outputPath, 0); } else { var extractGlobalsCommand = (_request as ExtractGlobalsCommand); Debug.Assert(extractGlobalsCommand != null, "extractGlobalsCommand != null"); var result = new SupplementalExtractionResults(extractGlobalsCommand.RepositoryLocator.DataExportRepository, extractGlobalsCommand.Configuration, null, doc); result.CompleteAudit(this.GetType(), outputPath, 0); extractGlobalsCommand.ExtractionResults.Add(result); } return(true); } catch (Exception e) { listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Failed to copy file " + doc + " to directory " + directory.FullName, e)); return(false); } }
public async Task CreateInitiative() { var newInitiativeMessages = new List <InitiativeCreatedEventArgs>(); serviceProvider.GetRequiredService <SynchronousInitiativeMessageReceiver>() .CreatedHandlers.Add((e, token) => { newInitiativeMessages.Add(e); return(Task.CompletedTask); }); var initiativeRepository = serviceProvider.GetRequiredService <IInitiativeRepository>(); // create a basic initiative var newInitiative = Initiative.Create( title: "Test Idea", description: "Test creating initiatives", ownerPersonId: 1, businessContactId: 2 ); // add some supporting documents newInitiative.AddSupportingDocument( SupportingDocument.Create("My Document", "www.edmonton.ca", SupportingDocumentsType.BusinessCases)); newInitiative.AddSupportingDocument( SupportingDocument.Create("Document2", "github.com", SupportingDocumentsType.Other)); // add some stakeholders newInitiative.AddStakeholder(3, StakeholderType.BusinessContact); var newInitiative2 = await initiativeRepository.AddInitiativeAsync(newInitiative); newInitiative2.Should().NotBeNull(); newInitiative2.Title.Should().Be("Test Idea"); newInitiative2.SupportingDocuments.Count().Should().Be(2); newInitiativeMessages.Count().Should().Be(1); }
public ActionResult DeleteConfirmed(int id) { SupportingDocument supportingDocument = Service.Get(id); Service.RemoveByEntity(supportingDocument); return(RedirectToAction("Index")); }
private void CheckDocument(SupportingDocument document, ICheckNotifier notifier) { if (document == null) { notifier.OnCheckPerformed(new CheckEventArgs("SupportingDocument has not been set", CheckResult.Fail)); return; } try { var toCopy = document.GetFileName(); if (toCopy != null && toCopy.Exists) { notifier.OnCheckPerformed( new CheckEventArgs("Found SupportingDocument " + toCopy.Name + " and it exists", CheckResult.Success)); } else { notifier.OnCheckPerformed( new CheckEventArgs("SupportingDocument " + document + "(ID=" + document.ID + ") does not map to an existing file despite being flagged as Extractable", CheckResult.Fail)); } } catch (Exception e) { notifier.OnCheckPerformed(new CheckEventArgs("Could not check supporting documents of " + _catalogue, CheckResult.Fail, e)); } }
public ActionResult Edit([Bind(Include = "SupportingDocumentId,SupportingDocumentName,SupportingDocumentLink,LeaveApplicationId")] SupportingDocument supportingDocument) { if (ModelState.IsValid) { Service.Update(supportingDocument, supportingDocument.SupportingDocumentId); return(RedirectToAction("Index")); } return(View(supportingDocument)); }
protected override void SetBindings(BinderWithErrorProviderFactory rules, SupportingDocument databaseObject) { base.SetBindings(rules, databaseObject); Bind(tbID, "Text", "ID", s => s.ID); Bind(tbDescription, "Text", "Description", s => s.Description); Bind(tbName, "Text", "Name", s => s.Name); Bind(cbExtractable, "Checked", "Extractable", s => s.Extractable); Bind(cbIsGlobal, "Checked", "IsGlobal", s => s.IsGlobal); }
public void test_SupportingDocument_CreateAndDestroy() { Catalogue cata = new Catalogue(CatalogueRepository, "deleteme"); SupportingDocument doc = new SupportingDocument(CatalogueRepository, cata, "davesFile"); Assert.AreEqual(doc.Name, "davesFile"); doc.DeleteInDatabase(); cata.DeleteInDatabase(); }
public ActionResult Edit([Bind(Include = "SupportingDocumentId,SupportingDocumentName,SupportingDocumentLink")] SupportingDocument supportingDocument) { supportingDocument.LeaveApplicationId = SupportingDocumentsController.MainId; Output.Write("Leave application id for supporting document: " + supportingDocument.LeaveApplicationId); if (ModelState.IsValid) { Service.Update(supportingDocument, supportingDocument.SupportingDocumentId); return(RedirectToAction("Index")); } return(View(supportingDocument)); }
public override void SetDatabaseObject(IActivateItems activator, SupportingDocument databaseObject) { base.SetDatabaseObject(activator, databaseObject); _supportingDocument = databaseObject; //populate various textboxes ticketingControl1.TicketText = _supportingDocument.Ticket; tbUrl.Text = _supportingDocument.URL != null ? _supportingDocument.URL.AbsoluteUri : ""; CommonFunctionality.AddHelp(cbExtractable, "SupportingDocument.Extractable"); CommonFunctionality.AddHelp(cbIsGlobal, "SupportingSqlTable.IsGlobal"); }
// GET: SupportingDocuments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SupportingDocument supportingDocument = Service.Get(id); if (supportingDocument == null) { return(HttpNotFound()); } return(View(supportingDocument)); }
// GET: SupportingDocuments/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SupportingDocument supportingDocument = Service.Get(id); if (supportingDocument == null) { return(HttpNotFound()); } ViewBag.LeaveApplicationId = SupportingDocumentsController.MainId; return(View(supportingDocument)); }
public void test_SupportingDocument_CreateChangeSaveDestroy() { Catalogue cata = new Catalogue(CatalogueRepository, "deleteme"); SupportingDocument doc = new SupportingDocument(CatalogueRepository, cata, "davesFile"); doc.Description = "some exciting file that dave loves"; doc.SaveToDatabase(); Assert.AreEqual(doc.Name, "davesFile"); Assert.AreEqual(doc.Description, "some exciting file that dave loves"); SupportingDocument docAfterCommit = CatalogueRepository.GetObjectByID <SupportingDocument>(doc.ID); Assert.AreEqual(docAfterCommit.Description, doc.Description); doc.DeleteInDatabase(); cata.DeleteInDatabase(); }
public override void Execute() { base.Execute(); FileInfo[] files = null; if (_fileCollectionCommand != null) { files = _fileCollectionCommand.Files; } else { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; if (fileDialog.ShowDialog() == DialogResult.OK) { files = fileDialog.FileNames.Select(f => new FileInfo(f)).Where(fi => fi.Exists).ToArray(); } else { return; } } List <SupportingDocument> created = new List <SupportingDocument>(); foreach (var f in files) { var doc = new SupportingDocument((ICatalogueRepository)_targetCatalogue.Repository, _targetCatalogue, f.Name); doc.URL = new Uri(f.FullName); doc.SaveToDatabase(); created.Add(doc); } Publish(_targetCatalogue); Emphasise(created.Last()); foreach (var doc in created) { Activate(doc); } }
private string ExtractToDirectory(DirectoryInfo directory, SupportingDocument supportingDocument) { if (!supportingDocument.IsReleasable()) { throw new Exception("Cannot extract SupportingDocument " + supportingDocument + " because it was not evaluated as IsReleasable()"); } FileInfo toCopy = supportingDocument.GetFileName(); if (!Directory.Exists(Path.Combine(directory.FullName, "SupportingDocuments"))) { Directory.CreateDirectory(Path.Combine(directory.FullName, "SupportingDocuments")); } //copy with overwritte File.Copy(toCopy.FullName, Path.Combine(directory.FullName, "SupportingDocuments", toCopy.Name), true); return(Path.Combine(directory.FullName, "SupportingDocuments", toCopy.Name)); }
public ActionResult UploadSupportingDocuments() { long id = Convert.ToInt64(Request.Form["ID"]); if (Request.Files.Count > 0) { CloudStorageAccount cloudStorageAccount = GetConnectionString(); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(ConfigurationManager.AppSettings["ContainerName"]); for (int fileNum = 0; fileNum < Request.Files.Count; fileNum++) { string fileName = Path.GetFileName(Request.Files[fileNum].FileName); if (Request.Files[fileNum] != null && Request.Files[fileNum].ContentLength > 0) { CloudBlockBlob azureBlockBlob = cloudBlobContainer.GetBlockBlobReference(fileName); azureBlockBlob.UploadFromStream(Request.Files[fileNum].InputStream); SupportingDocument detail = new SupportingDocument(); detail.TempPolicyNo = id; detail.FileName = fileName; detail.CreatedBy = (int)Session["UserId"]; if (fileNum == 0) { detail.DisplayFileName = "Aadhar Document"; } else if (fileNum == 1) { detail.DisplayFileName = "Pan Document"; } else if (fileNum == 2) { detail.DisplayFileName = "Medical Checkup Document"; } manager.InsertSupportingDocument(detail); } } } List <SupportingDocument> listDocument = manager.GetSupportingDocument(id); return(Json(listDocument, JsonRequestBehavior.AllowGet)); }
public void SupportingDocument_To_SupportingDocument_COPY_IsValid() { // Arrange var userId = Guid.NewGuid(); const int expectedSupportingDocRevisions = 0; var supportingDocRevision = new SupportingDocumentRevision { Id = Guid.NewGuid(), FileName = "FileName", GdnId = "ID" }; supportingDocRevision.SetCreatedNow(userId); var supportingDocument = new SupportingDocument { Id = Guid.NewGuid(), Key = "P&G", Name = "PG agency name", CostStageRevisionId = Guid.NewGuid(), Generated = true, Required = true, SupportingDocumentRevisions = new List <SupportingDocumentRevision> { supportingDocRevision } }; supportingDocument.SetCreatedNow(userId); // Act var model = _mapper.Map <SupportingDocument>(supportingDocument); // Assert model.Id.Should().Be(Guid.Empty); model.Key.Should().Be(model.Key); model.Name.Should().Be(model.Name); model.CanManuallyUpload.Should().Be(model.CanManuallyUpload); model.Generated.Should().Be(model.Generated); model.Required.Should().Be(model.Required); model.SupportingDocumentRevisions.Count.Should().Be(expectedSupportingDocRevisions); }
public SupportingDocument CreateDocument(int year, int companyType, int companyId, bool isUU, bool isUKIK, bool isND, string uKIKDocType, byte[] fileData, string fileName) { SupportingDocument doc = new SupportingDocument { Year = year, CompanyType = companyType, ProjectCompanyId = companyId, IsUU = isUU, IsUKIK = isUKIK, IsND = isND, Data = fileData, FileName = fileName, UKIKDocType = !string.IsNullOrEmpty(uKIKDocType) ? getUkikDocTypeId(uKIKDocType) : (int?)null }; using (var context = new WebKikDataContext()) { var document = context.SupportingDocuments.Add(doc); context.SaveChanges(); return(document); } // return null; }
public Int64 InsertSupportingDocument(SupportingDocument detail) { try { using (IDbConnection db = new SqlConnection(ConnectionString)) { string sql = "EXEC uspSupportingDocument @TempPolicyNo,@DisplayFileName,@FileName,@CreatedBy"; var returnId = db.ExecuteScalar <int>(sql, new { TempPolicyNo = detail.TempPolicyNo, DisplayFileName = detail.DisplayFileName, FileName = detail.FileName, CreatedBy = detail.CreatedBy }); return(returnId); } } catch (Exception ex) { return(0); } return(detail.TempPolicyNo); }
public ActionResult SaveSupooritngDoc() { // The Name of the Upload component is "files" //if (SupportingDocFiles != null) //{ // foreach (var file in SupportingDocFiles) // { // // Some browsers send file names with full path. // // We are only interested in the file name. // var fileName = Path.GetFileName(file.FileName); // var physicalPath = Path.Combine(Server.MapPath("~/Attachments/"), fileName); // // The files are not actually saved in this demo // TempData["fileName"] = fileName; // file.SaveAs(physicalPath); // try // { // pd = new ProjectDocument(); // pd.Title = fileName.Split('.')[0]; // pd.FileName = fileName; // pd.Created = DateTime.Now; // pd.Createdby = AppSession.UserId; // pd.Modified = DateTime.Now; // pd.Modifiedby = AppSession.UserId; // _dbContextHelper.AttachToContext(pd); // ViewBag.SupportingProjectDocId = pd.Id; // } // catch (Exception ex) // { // } // } //} List <int> lstspd = new List <int>(); string path = Server.MapPath("~/Attachments/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (string key in Request.Files) { HttpPostedFileBase postedFile = Request.Files[key]; postedFile.SaveAs(path + postedFile.FileName); try { spd = new SupportingDocument(); spd.Title = postedFile.FileName.Split('.')[0]; spd.FileName = postedFile.FileName; spd.Created = DateTime.Now; spd.Createdby = AppSession.UserId; spd.Modified = DateTime.Now; spd.Modifiedby = AppSession.UserId; _dbContextHelper.AttachToContext(spd); ViewBag.ProjectDocId = spd.Id; lstspd.Add(spd.Id); ViewBag.SupportingProjectDocId = lstspd; } catch (Exception ex) { } } // Return an empty string to signify success IntializeViewdata(); return(View("ngCreate")); }
private void CreateLookupsEtc() { //an extractable file var filename = Path.Combine(TestContext.CurrentContext.WorkDirectory, "bob.txt"); File.WriteAllText(filename, "fishfishfish"); var doc = new SupportingDocument(CatalogueRepository, _catalogue, "bob"); doc.URL = new Uri("file://" + filename); doc.Extractable = true; doc.SaveToDatabase(); //an extractable global file (comes out regardless of datasets) var filename2 = Path.Combine(TestContext.CurrentContext.WorkDirectory, "bob2.txt"); File.WriteAllText(filename2, "fishfishfish2"); var doc2 = new SupportingDocument(CatalogueRepository, _catalogue, "bob2"); doc2.URL = new Uri("file://" + filename2); doc2.Extractable = true; doc2.IsGlobal = true; doc2.SaveToDatabase(); //an supplemental table in the database (not linked against cohort) var tbl = CreateDataset <Biochemistry>(Database, 500, 1000, new Random(50)); var sql = new SupportingSQLTable(CatalogueRepository, _catalogue, "Biochem"); var server = new ExternalDatabaseServer(CatalogueRepository, "myserver", null); server.SetProperties(tbl.Database); sql.ExternalDatabaseServer_ID = server.ID; sql.SQL = "SELECT * FROM " + tbl.GetFullyQualifiedName(); sql.Extractable = true; sql.SaveToDatabase(); //an supplemental (global) table in the database (not linked against cohort) var tbl2 = CreateDataset <HospitalAdmissions>(Database, 500, 1000, new Random(50)); var sql2 = new SupportingSQLTable(CatalogueRepository, _catalogue, "Hosp"); sql2.ExternalDatabaseServer_ID = server.ID; sql2.SQL = "SELECT * FROM " + tbl2.GetFullyQualifiedName(); sql2.Extractable = true; sql2.IsGlobal = true; sql2.SaveToDatabase(); DataTable dtLookup = new DataTable(); dtLookup.Columns.Add("C"); dtLookup.Columns.Add("D"); dtLookup.Rows.Add("F", "Female"); dtLookup.Rows.Add("M", "Male"); dtLookup.Rows.Add("NB", "Non Binary"); var lookupTbl = tbl2.Database.CreateTable("z_fff", dtLookup); Import(lookupTbl, out TableInfo ti, out ColumnInfo[] columnInfos); var lookup = new Lookup(CatalogueRepository, columnInfos[0], _columnToTransform, columnInfos[1], ExtractionJoinType.Left, null); //we need a CatalogueItem for the description in order to pick SetUp the Lookup as associated with the Catalogue var ci = new CatalogueItem(CatalogueRepository, _catalogue, "SomeDesc"); ci.ColumnInfo_ID = columnInfos[1].ID; ci.SaveToDatabase(); }
protected override void Seed(Models.ApplicationDbContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. var Region1 = new Region() { Id = 1, Title = "Region1" }; var Region2 = new Region() { Id = 2, Title = "Region2" }; var Region3 = new Region() { Id = 3, Title = "Region3" }; var Region4 = new Region() { Id = 4, Title = "Region4" }; var Region5 = new Region() { Id = 5, Title = "Region5" }; var SubRegion1 = new SubRegion() { Id = 1, Title = "SubRegion1" }; var SubRegion2 = new SubRegion() { Id = 2, Title = "SubRegion2" }; var SubRegion3 = new SubRegion() { Id = 3, Title = "SubRegion3" }; var SubRegion4 = new SubRegion() { Id = 4, Title = "SubRegion4" }; var SubRegion5 = new SubRegion() { Id = 5, Title = "SubRegion5" }; var SupportingDocument1 = new SupportingDocument() { Id = 1, Title = "Docx1", FileName = "DOCX1.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var SupportingDocument2 = new SupportingDocument() { Id = 2, Title = "Docx2", FileName = "DOCX2.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var SupportingDocument3 = new SupportingDocument() { Id = 3, Title = "Docx3", FileName = "DOCX3.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var SupportingDocument4 = new SupportingDocument() { Id = 4, Title = "Docx4", FileName = "DOCX4.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var SupportingDocument5 = new SupportingDocument() { Id = 5, Title = "Docx5", FileName = "DOCX5.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var ProjectDocument1 = new ProjectDocument() { Id = 1, Title = "Docx1", FileName = "DOCX1.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var ProjectDocument2 = new ProjectDocument() { Id = 2, Title = "Docx2", FileName = "DOCX2.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var ProjectDocument3 = new ProjectDocument() { Id = 3, Title = "Docx3", FileName = "DOCX3.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var ProjectDocument4 = new ProjectDocument() { Id = 4, Title = "Docx4", FileName = "DOCX4.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; var ProjectDocument5 = new ProjectDocument() { Id = 5, Title = "Docx5", FileName = "DOCX5.docx", Created = DateTime.Now, Modified = DateTime.Now, Createdby = "714b5a05-bdce-4968-952f-99d6a284f1d0", Modifiedby = "714b5a05-bdce-4968-952f-99d6a284f1d0" }; ApplicationDbContext dbContext = new ApplicationDbContext(); dbContext.Region.AddRange(new List <Region>() { Region1, Region2, Region3, Region4, Region5 }); dbContext.SubRegion.AddRange(new List <SubRegion>() { SubRegion1, SubRegion2, SubRegion3, SubRegion4, SubRegion5 }); dbContext.ProjectDocument.AddRange(new List <ProjectDocument>() { ProjectDocument1, ProjectDocument2, ProjectDocument3, ProjectDocument4, ProjectDocument5 }); dbContext.SuportingDocument.AddRange(new List <SupportingDocument>() { SupportingDocument1, SupportingDocument2, SupportingDocument3, SupportingDocument4, SupportingDocument5 }); dbContext.SaveChanges(); }
public Int64 InsertSupportingDocument(SupportingDocument detail) { return(manager.InsertSupportingDocument(detail)); }
public SupportingDocumentsFetcher(SupportingDocument document) { _document = document; _catalogue = document.Repository.GetObjectByID <Catalogue>(document.Catalogue_ID); _singleDocument = true; }
public object GetState(SupportingDocument global) { return(GetState((IMapsDirectlyToDatabaseTable)global)); }