Ejemplo n.º 1
0
        public App(DocumentDetails documentDetails)
        {
            InitializeComponent();

            if (documentDetails.Type.Equals(".Doc", StringComparison.CurrentCultureIgnoreCase))
            {
                documentDetails.Type = "Doc";
                MainPage             = new NavigationPage(new XamDocumentViewer.Standard.MainPage(documentDetails))
                {
                    Title = "My Document Viewer"
                };
            }
            else if (documentDetails.Type.Equals(".Docx", StringComparison.CurrentCultureIgnoreCase))
            {
                documentDetails.Type = "Docx";
                MainPage             = new NavigationPage(new XamDocumentViewer.Standard.MainPage(documentDetails))
                {
                    Title = "My Document Viewer"
                };
            }
            else
            {
                throw new Exception("Invalid document type.");
            }
        }
Ejemplo n.º 2
0
        public void DocumentDetailsShouldBeAddedToProfile()
        {
            string   issuingCountry       = "GBR";
            string   documentNumber       = "1234abc";
            DateTime expirationDate       = new DateTime(2015, 5, 1);
            string   expirationDateString = expirationDate.ToString("yyyy-MM-dd");
            string   documentType         = "DRIVING_LICENCE";
            string   issuingAuthority     = "DVLA";

            string documentDetailsString = string.Format("{0} {1} {2} {3} {4}",
                                                         documentType,
                                                         issuingCountry,
                                                         documentNumber,
                                                         expirationDateString,
                                                         issuingAuthority);

            var attribute = new ProtoBuf.Attribute.Attribute
            {
                Name        = Constants.UserProfile.DocumentDetailsAttribute,
                ContentType = ContentType.String,
                Value       = ByteString.CopyFromUtf8(documentDetailsString)
            };

            _yotiProfile = TestTools.Profile.CreateUserProfileWithSingleAttribute <DocumentDetails>(attribute);

            DocumentDetails actualDocumentDetails = _yotiProfile.DocumentDetails.GetValue();

            Assert.AreEqual(issuingCountry, actualDocumentDetails.IssuingCountry);
            Assert.AreEqual(documentNumber, actualDocumentDetails.DocumentNumber);
            Assert.AreEqual(expirationDate, actualDocumentDetails.ExpirationDate);
            Assert.AreEqual(documentType, actualDocumentDetails.DocumentType);
            Assert.AreEqual(issuingAuthority, actualDocumentDetails.IssuingAuthority);
            Assert.AreEqual(documentDetailsString, actualDocumentDetails.ToString());
        }
Ejemplo n.º 3
0
        public void _10_FinalUWApproval()
        {
            LaunchApplication(DesktopApps.Encompass); Launcher.Initialize().cmb_EnvironmentID_SelectByText(EnvironmentID).btn_Login_Click();

            AttachToProcess(Processes.Encompass, 5);

            Login.Initialize().Login_Username_SendKeys(Underwriter);

            Pipeline.Initialize().Pipeline_SelectCurrentLoan(LoanNumber);

            Encompass_eFolder.Open_eFolder().eFolder_UnderwriterReview("1003"); DocumentDetails.Initialize().chk_Reviewed_Check(true).btn_Close_Click();

            Encompass_eFolder.Initialize().eFolder_UnderwriterReview("Credit Report"); DocumentDetails.Initialize().chk_Reviewed_Check(true).btn_Close_Click();

            Encompass_eFolder.Initialize().eFolder_UnderwriterReview("Underwriting"); DocumentDetails.Initialize().chk_Reviewed_Check(true).btn_Close_Click();

            Encompass_eFolder.Initialize().btn_Close_Click();

            FinalUWApproval
            .Open_FromLogTab()
            .cmb_ULDDPropertyValuationMethodType_SendKeys("None")
            .txt_TotalMortgagedPropertiesCount_SendKeys("1")
            .txt_ULDDInvestorFeatureID_SendKeys("5645646446")
            .cmb_UnderwritingLevelOfPrptyReview_SendKeys("No Appraisal")
            .cmb_DayOneCertainty_SendKeys("NO")
            .txt_UnderwritingClearToCloseDate_SendKeys("030518")
            .chk_FinalUWApprovalTasks_Check()
            .chk_Finish_Check();

            EncompassMain.Initialize().ExitEncompass(); ExitEncompass.Initialize().btn_Yes_Click(); CompliancePreview.Initialize().btn_Close_Click(); TestedApplication.Kill();
        }
        public async Task Run_WithValidRequest_ReturnsCurrentStatus()
        {
            // arrange
            var req    = new DefaultHttpRequest(new DefaultHttpContext());
            var logger = TestFactory.CreateLogger(LoggerTypes.List);
            var now    = DateTime.UtcNow;

            DocumentDetails documentDetails = new DocumentDetails
            {
                Id        = Guid.NewGuid(),
                Body      = "doc123.txt",
                CreatedOn = now,
                Status    =
                {
                    new DocumentStatus
                    {
                        Status    = "ERROR",
                        Detail    = "processing error",
                        CreatedOn = now.AddMinutes(10)
                    }
                }
            };

            // act
            var result = await DocumentStatusRequest.Run(req, documentDetails.Id.ToString(), documentDetails, logger);

            // assert
            result.Should().BeOfType <OkObjectResult>();

            var documentStatusResponse = (DocumentStatusResponse)((OkObjectResult)result).Value;

            documentStatusResponse.CreatedOn.Should().Be(now);
            documentStatusResponse.Status.Should().Be("ERROR");
            documentStatusResponse.UpdatedOn.Should().Be(now.AddMinutes(10));
        }
Ejemplo n.º 5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            DocumentDetails    docObj   = new DocumentDetails();
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            try
            {
                if (cbnDocumentID.SelectedIndex == -1)
                {
                    throw new ELibraryException("Select Document ID");
                }
                docObj.DocumentID = Convert.ToInt32(cbnDocumentID.SelectedValue);
                if (docBLObj.DeleteDocumentBL(docObj))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Deleted')", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Deletion Failed')", true);
                }
                InitializeCombo();
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
            }
        }
Ejemplo n.º 6
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "status/{id}")] HttpRequest req, string id,
            [CosmosDB(
                 databaseName: "DocumentProxy",
                 collectionName: "Documents",
                 Id = "{id}",
                 CreateIfNotExists = true,
                 ConnectionStringSetting = "CosmosDBConnection")] DocumentDetails document,
            ILogger log)
        {
            log.LogInformation($"Get Status for {id}.");

            if (document == null)
            {
                return(new BadRequestObjectResult("Invalid request"));
            }

            var latestUpdate = document.Status.LastOrDefault();
            var response     = new DocumentStatusResponse
            {
                Body      = document.Body,
                CreatedOn = document.CreatedOn,
                Status    = latestUpdate?.Status,
                Detail    = latestUpdate?.Detail,
                UpdatedOn = latestUpdate == null ? document.CreatedOn : latestUpdate.CreatedOn
            };

            return(new OkObjectResult(response));
        }
Ejemplo n.º 7
0
        public async Task ConcurrentDownloadOfDocument()
        {
            DocumentDetails document = null;

            using (var db = new DataContext()) {
                document = await db.Documents.OrderByDescending(d => d.Length).Select(d => new DocumentDetails {
                    ID = d.ID, Length = d.Length
                }).FirstOrDefaultAsync();
            }

            if (!Directory.Exists("DownloadsTest"))
            {
                Directory.CreateDirectory("DownloadsTest");
            }

            foreach (var file in Directory.GetFiles("DownloadsTest"))
            {
                File.Delete(file);
            }

            System.Collections.Generic.List <Task> tasks = new System.Collections.Generic.List <Task>();

            for (int i = 0; i < 10; i++)
            {
                tasks.Add(DownloadDocument(document.ID, document.Length, i));
            }

            await Task.WhenAll(tasks.ToArray());
        }
 public void ShouldFailForMoreThanOneConsecutiveSpaces(string stringToParse)
 {
     Assert.ThrowsException <FormatException>(() =>
     {
         DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom(stringToParse);
     });
 }
        private void DisplayCart()
        {
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            gvShoppingCart.DataSource = null;
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Author", typeof(string)));
            dt.Columns.Add(new DataColumn("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("", typeof(Control)));
            dt.Columns.Add(new DataColumn("DocumentID", typeof(string)));
            if (Session["DocList"] != null)
            {
                docIDList = (List <int>)Session["DocList"];
                foreach (int docID in docIDList)
                {
                    DocumentDetails doc = docBLObj.GetDocumentByID(docID);
                    DataRow         dr  = dt.NewRow();
                    dr["Title"]      = doc.Title;
                    dr["Author"]     = doc.Author;
                    dr["DocumentID"] = doc.DocumentID;

                    dr["Price"] = doc.Price;

                    dt.Rows.Add(dr);
                }
            }
            gvShoppingCart.DataSource = dt;
            gvShoppingCart.DataBind();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// searches document by id and returns it
        /// </summary>
        /// <param name="docId">document id</param>
        /// <returns>document object</returns>
        public DocumentDetails GetDocumentByID(int docId)
        {
            DocumentDetails docObj = null;

            DbParameter p1 = DBHelper.CreateParameter("@docId", docId);

            commandObj = DBHelper.CreateCommand("select * from Document_Details where Document_ID=@docId", CommandType.Text, p1);
            try

            {
                DataTable table = DBHelper.ExecuteReader(commandObj);

                if (table.Rows.Count == 1)
                {
                    docObj                     = new DocumentDetails();
                    docObj.DocumentID          = Convert.ToInt32(table.Rows[0][0]);
                    docObj.DocumentName        = Convert.ToString(table.Rows[0][1]);
                    docObj.DocumentDescription = Convert.ToString(table.Rows[0][2]);
                    docObj.DocumentPath        = Convert.ToString(table.Rows[0][3]);
                    docObj.DocumentTypeID      = Convert.ToInt32(table.Rows[0][4]);
                    docObj.DisciplineID        = Convert.ToInt32(table.Rows[0][5]);
                    docObj.Title               = Convert.ToString(table.Rows[0][6]);
                    docObj.Author              = Convert.ToString(table.Rows[0][7]);
                    docObj.Price               = Convert.ToDouble(table.Rows[0][9]);
                    docObj.UploadDate          = Convert.ToDateTime(table.Rows[0][8]);
                }

                return(docObj);
            }
            catch (DbException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 11
0
        private void GetBooksBought()
        {
            ELibraryDocumentBL docBL     = new ELibraryDocumentBL();
            UserDetails        userObj   = (UserDetails)Session["UserObj"];
            List <int>         docIDList = docBL.GetDocumentsBoughtBL(userObj.UserID);

            gvPurchased.DataSource = null;
            if (docIDList != null)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("Title", typeof(string)));
                dt.Columns.Add(new DataColumn("Author", typeof(string)));
                dt.Columns.Add(new DataColumn("Description", typeof(string)));
                dt.Columns.Add(new DataColumn("Price", typeof(string)));

                foreach (int docId in docIDList)
                {
                    DocumentDetails doc = docBL.GetDocumentByID(docId);
                    DataRow         dr  = dt.NewRow();
                    dr["Title"]       = doc.Title;
                    dr["Author"]      = doc.Author;
                    dr["Description"] = doc.DocumentDescription;
                    dr["Price"]       = doc.Price;
                    dt.Rows.Add(dr);
                }
                gvPurchased.DataSource = dt;
                gvPurchased.DataBind();
            }
        }
Ejemplo n.º 12
0
        public void DownloadUploadedfile(string PartnerCode, string FileName)
        {
            tblProspectDocument objtblDocuments    = new tblProspectDocument();
            HierarchyData       objHierarchyData   = new HierarchyData();
            DocumentDetails     objDocumentDetails = new DocumentDetails();
            tblOrganization     objtblOrganization = null;

            if (PartnerCode != null)
            {
                objtblOrganization = Context.tblOrganizations.Where(a => a.PartnerCode == PartnerCode).FirstOrDefault();
            }
            var    directorypath   = System.Web.HttpContext.Current.Server.MapPath("Upload");
            var    PolicyFileName  = Path.Combine(directorypath, Path.GetFileName(FileName));
            string result          = PolicyFileName;
            string Filecontenttype = Context.tblProspectDocuments.Where(a => a.OrganizationID == objtblOrganization.OrganizationID).FirstOrDefault().DocType;

            objDocumentDetails.FileContent = Encoding.ASCII.GetBytes(Context.tblProspectDocuments.Where(a => a.OrganizationID == objtblOrganization.OrganizationID).FirstOrDefault().DocPath);
            System.Web.HttpContext.Current.Response.ContentType = Filecontenttype;
            System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(PolicyFileName));
            System.Web.HttpContext.Current.Response.Charset = "";
            System.Web.HttpContext.Current.Response.OutputStream.Write(objDocumentDetails.FileContent, 0, objDocumentDetails.FileContent.Length);
            System.Web.HttpContext.Current.Response.Flush();
            System.Web.HttpContext.Current.Response.Close();

            if (System.IO.File.Exists(result))
            {
                System.Web.HttpContext.Current.Response.OutputStream.Dispose();
                System.IO.File.Delete(result);
            }
        }
Ejemplo n.º 13
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "request")] HttpRequest req,
            [CosmosDB(
                 databaseName: "DocumentProxy",
                 collectionName: "Documents",
                 CreateIfNotExists = true,
                 ConnectionStringSetting = "CosmosDBConnection")] IAsyncCollector <DocumentDetails> documents,
            ILogger log)
        {
            try
            {
                log.LogInformation("Document request started.");

                // would probably want some validation of body size
                string requestBody    = await new StreamReader(req.Body).ReadToEndAsync();
                var    requestDetails = JsonConvert.DeserializeObject <RequestDetails>(requestBody);

                if (string.IsNullOrWhiteSpace(requestDetails?.Body))
                {
                    return(new BadRequestObjectResult("Invalid request"));
                }

                // create id
                var documentId = Guid.NewGuid();

                // call 3rd party service
                // the documentId is included in the url so that the subsequent callback request can be matched to the original request.
                var callbackUrl       = $"/callback/{documentId}";
                var docServiceRequest = new DocServiceRequest
                {
                    Body     = requestDetails.Body,
                    Callback = callbackUrl
                };
                // This should be injected with DI
                IDocServiceClient docServiceClient = new DocServiceClient();
                await docServiceClient.RequestAsync(docServiceRequest);

                // saved results to db
                var document = new DocumentDetails
                {
                    Id        = documentId,
                    Body      = requestDetails.Body,
                    CreatedOn = DateTime.UtcNow
                };
                await documents.AddAsync(document);

                // return results
                return(new OkObjectResult($"{documentId}"));
            }
            catch (Exception exception)
            {
                // most likely errors to occur
                //  Error communitcating with 3rd party service
                //  Error communitcating with Cosmos DB
                log.LogError(exception, "Error processing request");
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }
        }
        /// <summary>
        /// method to move the document to the path ~/ELibInc/ELibDocuments and
        /// correspoding folder Freebie or Premium
        /// </summary>
        /// <param name="docObj">Document details object</param>
        /// <returns>true/false</returns>
        private bool MoveDocumentBL(DocumentDetails docObj)
        {
            bool isMoved = false;
            ELibraryDocumentDAL eLibDALObj = new ELibraryDocumentDAL();

            //string currentFolder = Directory.GetCurrentDirectory();
            //string targetFolder = Directory.GetParent(currentFolder).ToString();
            //targetFolder = Directory.GetParent(targetFolder).ToString();
            //targetFolder = Directory.GetParent(targetFolder).ToString();

            string targetFolder = @"C:";

            targetFolder = targetFolder + @"\ELibDocuments";

            string docTypeName     = eLibDALObj.GetDocumentType(docObj.DocumentTypeID);
            string targetSubFolder = targetFolder + @"\" + docTypeName;

            int docNameExt = eLibDALObj.GetDocExtDAL();


            string sourceFilePath = docObj.DocumentPath;
            string targetFilePath = targetSubFolder + @"\" + docObj.DocumentName + "_" + docNameExt.ToString() + ".pdf";


            try
            {
                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }


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

                File.Copy(sourceFilePath, targetFilePath, true);
                isMoved             = true;
                docObj.DocumentPath = targetFilePath;
            }
            catch (IOException ex)
            {
                throw ex;
            }
            catch (ELibraryException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }



            return(isMoved);
        }
Ejemplo n.º 15
0
        public void ProcessDownload(Library library, DocumentDetails documentInfo)
        {
            using (var smtpClient = new SmtpClient())
            {
                smtpClient.EnableSsl             = emailSettings.UseSsl;
                smtpClient.Host                  = emailSettings.ServerName;
                smtpClient.Port                  = emailSettings.ServerPort;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials
                    = new NetworkCredential(emailSettings.Username, emailSettings.Password);

                if (emailSettings.WriteAsFile)
                {
                    smtpClient.DeliveryMethod
                        = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                    smtpClient.PickupDirectoryLocation = emailSettings.FileLocation;
                    smtpClient.EnableSsl = false;
                }

                StringBuilder body = new StringBuilder()
                                     .AppendLine("Новый заказ обработан")
                                     .AppendLine("---")
                                     .AppendLine("Товары:");

                foreach (var line in library.Lines)
                {
                    var subtotal = line.Event.Price * line.Quantity;
                    body.AppendFormat("{0} x {1} (итого: {2:c}",
                                      line.Quantity, line.Event.Name, subtotal);
                }

                body.AppendFormat("Общая стоимость: {0:c}", library.ComputeTotalValue())
                .AppendLine("---")
                .AppendLine("Доставка:")
                .AppendLine(documentInfo.Name)
                .AppendLine(documentInfo.Line1)
                .AppendLine(documentInfo.Line2 ?? "")
                .AppendLine(documentInfo.Line3 ?? "")
                .AppendLine(documentInfo.Type)
                .AppendLine(documentInfo.Comment)
                .AppendLine("---")
                .AppendFormat("Подарочная упаковка: {0}",
                              documentInfo.GiftWrap ? "Да" : "Нет");

                MailMessage mailMessage = new MailMessage(
                    emailSettings.MailFromAddress,                      // От кого
                    emailSettings.MailToAddress,                        // Кому
                    "Новый заказ отправлен!",                           // Тема
                    body.ToString());                                   // Тело письма

                if (emailSettings.WriteAsFile)
                {
                    mailMessage.BodyEncoding = Encoding.UTF8;
                }

                smtpClient.Send(mailMessage);
            }
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Index(string id)
        {
            DocumentDetails document = null;

            if (id != null)
            {
                document = await _documentService.FetchDocument(id);
            }
            return(View(document));
        }
Ejemplo n.º 17
0
        public ActionResult SCDocumentList()
        {
            List <DocumentDetails> lstStandardizedSolutions = new List <DocumentDetails>();
            string    productPath = "/sitecore/Media Library/Files/SCEBFiles/EBStandardizedSolutions";
            ChildList fileItems   = Sitecore.Context.Database.GetItem(productPath).Children;
            //var itemId = Sitecore.Context.Database.GetItem(productPath).ID;
            //////var itemId = Sitecore.Context.Database.GetItem(RenderingContext.Current.Rendering.DataSource).ID;
            //Sitecore.Data.Items.MediaItem itemMedia = new Sitecore.Data.Items.MediaItem(Sitecore.Context.Database.GetItem(itemId));
            //var fileType = xmlMedia.Fields["Extension"].Value;
            //if (fileType == "xml" || fileType == "XML")
            //{
            //    //JavaScriptSerializer serializer = new JavaScriptSerializer();
            //    var stream = MediaManager.GetMedia(xmlMedia).GetStream().Stream;
            //    using (StreamReader r = new StreamReader(stream))
            //    {
            //       var myData = r.ReadToEnd();
            //    }
            //}
            //MultilistField msf = Sitecore.Context.Item.Fields[""];
            //MediaManager.GetMedia("/sitecore/media library/Files/SCEBFiles/EBStandardizedSolutions");
            string pdfData = string.Empty;

            foreach (var imgItem in fileItems)
            {
                //Sitecore.Data.Items.Item sampleItem = Sitecore.Context.Database.GetItem("/sitecore/media library/Files/yourhtmlfile");
                Sitecore.Data.Items.Item sampleMedia = (Sitecore.Data.Items.Item)imgItem;
                Media xxx      = MediaManager.GetMedia(sampleMedia);
                var   fileType = sampleMedia.Fields["Extension"].Value;
                if (fileType == "pdf" || fileType == "PDF")
                {
                    using (var reader = new StreamReader(xxx.GetStream().Stream))
                    {
                        pdfData = reader.ReadToEnd();
                    }
                }

                var documentDetails = new DocumentDetails();
                //documentDetails.Scource = HashingUtils.ProtectAssetUrl(Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(imgItem)));
                //Sitecore.Data.Items.MediaItem itemMedia = new Sitecore.Data.Items.MediaItem(Sitecore.Context.Database.GetItem(itemId));
                documentDetails.Type    = fileType;
                documentDetails.Name    = xxx.MediaData.MediaItem.Title;
                documentDetails.Image   = xxx.MediaData.MediaItem.Name;
                documentDetails.Scource = xxx.MediaData.MediaItem.Path;
                lstStandardizedSolutions.Add(documentDetails);
            }
            //LanguageCollection languageCollection = LanguageManager.GetLanguages(Context.Database);
            //foreach (Language language in languageCollection)
            //{
            //    string url = GetItemUrl(Context.Item, language);
            //    list.Add(language.CultureInfo.DisplayName, url);

            //}

            return(View(lstStandardizedSolutions));
        }
        public void ShouldParseRedactedAadhar()
        {
            DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom("NATIONAL_ID IND ********6421 - UIDAI");

            Assert.IsNotNull(result);
            Assert.AreEqual(Constants.DocumentDetails.DocumentTypeNationalId, result.DocumentType);
            Assert.AreEqual("IND", result.IssuingCountry);
            Assert.AreEqual("********6421", result.DocumentNumber);
            Assert.IsNull(result.ExpirationDate);
            Assert.AreEqual("UIDAI", result.IssuingAuthority);
        }
Ejemplo n.º 19
0
 private DocumentDetails TransformFull(DocumentContent content)
 {
     if (content != null)
     {
         var document = new DocumentDetails();
         Transform(content, document);
         document.Buffer = content.Buffer;
         return(document);
     }
     return(null);
 }
        public void ShouldParseMandatoryAttributes()
        {
            DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom("PASSPORT GBR 1234abc");

            Assert.IsNotNull(result);
            Assert.AreEqual(Constants.DocumentDetails.DocumentTypePassport, result.DocumentType);
            Assert.AreEqual("GBR", result.IssuingCountry);
            Assert.AreEqual("1234abc", result.DocumentNumber);
            Assert.IsNull(result.ExpirationDate);
            Assert.IsNull(result.IssuingAuthority);
        }
        public void ShouldParseOneOptionalAttribute()
        {
            DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom("AADHAAR IND 1234abc 2016-05-01");

            Assert.IsNotNull(result);
            Assert.AreEqual(Constants.DocumentDetails.DocumentTypeAadhaar, result.DocumentType);
            Assert.AreEqual("IND", result.IssuingCountry);
            Assert.AreEqual("1234abc", result.DocumentNumber);
            Assert.AreEqual(new DateTime(2016, 05, 01), result.ExpirationDate);
            Assert.IsNull(result.IssuingAuthority);
        }
        public void ShouldIgnoreAThirdOptionalAttribute()
        {
            DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom("DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA someThirdAttribute");

            Assert.IsNotNull(result);
            Assert.AreEqual(Constants.DocumentDetails.DocumentTypeDrivingLicense, result.DocumentType);
            Assert.AreEqual("GBR", result.IssuingCountry);
            Assert.AreEqual("1234abc", result.DocumentNumber);
            Assert.AreEqual(new DateTime(2016, 05, 01), result.ExpirationDate);
            Assert.AreEqual("DVLA", result.IssuingAuthority);
        }
        public void ShouldParseWhenOneOptionalAttributeIsMissing()
        {
            DocumentDetails result = DocumentDetailsAttributeParser.ParseFrom("PASS_CARD GBR 1234abc - DVLA");

            Assert.IsNotNull(result);
            Assert.AreEqual(Constants.DocumentDetails.DocumentTypePassCard, result.DocumentType);
            Assert.AreEqual("GBR", result.IssuingCountry);
            Assert.AreEqual("1234abc", result.DocumentNumber);
            Assert.IsNull(result.ExpirationDate);
            Assert.AreEqual("DVLA", result.IssuingAuthority);
        }
 private static Document ConstructDynamoDocument(DocumentDetails newDocument)
 {
     return(new Document
     {
         ["CominoDocumentNumber"] = newDocument.CominoDocumentNumber,
         ["DocumentCreatorUserName"] = newDocument.DocumentCreator,
         ["LetterType"] = newDocument.LetterType,
         ["DocumentType"] = newDocument.DocumentType,
         ["InitialTimestamp"] = newDocument.Date,
         ["Status"] = "Waiting",
     });
 }
Ejemplo n.º 25
0
        private async Task TryConvertToPdf(string html, DocumentDetails document, string timestamp)
        {
            try
            {
                await _convertHtmlToPdf.Execute(html, document.LetterType, document.Id);
            }
            catch (Exception error)
            {
                await HandleError(timestamp, error, "Failed converting HTML to PDF.");
            }

            await _logger.LogMessage(timestamp, "Converted To Pdf");
        }
Ejemplo n.º 26
0
        private async Task TryStoreInS3(DocumentDetails document, string timestamp)
        {
            try
            {
                var result = await _savePdfToS3.SavePdfDocument(document.Id);

                Console.WriteLine($"> s3PutResult: \n{JsonConvert.SerializeObject(result)}");
            }
            catch (Exception error)
            {
                await HandleError(timestamp, error, "Failed to save to S3.");
            }

            await _logger.LogMessage(timestamp, "Stored in S3 - Ready for approval");
        }
        /// <summary>
        /// Creates a Document Provenance.
        /// </summary>
        /// <returns>DocumentProvenance</returns>
        public static DocumentDetails CreateDocumentProvenance(Boolean mandatorySectionsOnly)
        {
            DocumentDetails documentDetails = DiagnosticImagingReport.CreateDocumentProvenance();

            // Result Status
            documentDetails.ReportDate = new ISO8601DateTime(DateTime.Now);

            // Result Status
            documentDetails.ReportStatus = BaseCDAModel.CreateResultStatus(Hl7V3ResultStatus.FinalResults, "Final Results"); // or BaseCDAModel.CreateResultStatus(Hl7V3ResultStatus.FinalResults)

            // Result Status
            documentDetails.ReportDescription = "Report Description";

            return(documentDetails);
        }
        /// <summary>
        /// Get document by ID makes call to DAL method GetDocumentByID
        /// </summary>
        /// <param name="docId">document id</param>
        /// <returns>document object</returns>
        public DocumentDetails GetDocumentByID(int docId)
        {
            DocumentDetails     docObj     = null;
            ELibraryDocumentDAL eLibDALObj = new ELibraryDocumentDAL();

            try
            {
                docObj = eLibDALObj.GetDocumentByID(docId);
            }
            catch (ELibraryException ex)
            {
                throw ex;
            }
            return(docObj);
        }
        /// <summary>
        /// method to add document. makes call to data access layer method AddDocumentDetailsDAL
        /// </summary>
        /// <param name="docObj">Document details object</param>
        /// <returns>true/false</returns>
        public bool AddNewDocumentBL(DocumentDetails docObj)
        {
            bool isAdded = false;
            ELibraryDocumentDAL eLibDALObj = new ELibraryDocumentDAL();

            if (ValidateDocumentDetailsBL(docObj))
            {
                if (eLibDALObj.AddDocumentDetailsDAL(docObj))
                {
                    isAdded = true;
                }
            }

            return(isAdded);
        }
        public async Task <bool> SaveDocument(DocumentDetails newDocument)
        {
            var documentItem = ConstructDynamoDocument(newDocument);
            var putConfig    = ConditionalOnTimestampUniqueness(newDocument.Date);

            try{
                await _documentsTable.PutItemAsync(documentItem, putConfig);

                return(true);
            }
            catch (ConditionalCheckFailedException)
            {
                Console.WriteLine($"Record already exists in local database: {newDocument.Id}");
                return(false);
            }
        }