public ActionResult DeleteConfirmed(int id) { QuotationType quotationType = db.QuotationTypes.Find(id); db.QuotationTypes.Remove(quotationType); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ReadQuotation() { string filename = "UBL-Quotation-2.0-Example.xml"; QuotationType doc = UblDoc <QuotationType> .Create(filename); Assert.AreEqual("Busy Street", doc.SellerSupplierParty.Party.PostalAddress.StreetName.Value); bool areEqual = UblXmlComparer.IsCopyEqual <QuotationType>(filename, doc); Assert.IsTrue(areEqual, "Written UBL doc differs from original"); }
public BaseStockQuotation(int stockShares, StockIdentifier stockIdentifier, string ownerName, decimal price, Guid ownerId, QuotationType type) { _stockShares = stockShares; _stockIdentifier = stockIdentifier; _ownerName = ownerName; _price = price; _ownerId = ownerId; _type = type; }
public ActionResult Create([Bind(Include = "Type")] QuotationType quotationType) { var user = UserManager.FindById(User.Identity.GetUserId()); if (ModelState.IsValid) { db.Insert(quotationType, user.Id); return(RedirectToAction("Index")); } return(View(quotationType)); }
// GET: QuotationTypes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuotationType quotationType = db.QuotationTypes.Find(id); if (quotationType == null) { return(HttpNotFound()); } return(View(quotationType)); }
public ActionResult Edit([Bind(Include = "Id,Type")] QuotationType model) { var user = UserManager.FindById(User.Identity.GetUserId()); if (ModelState.IsValid) { var quotationType = db.QuotationTypes.Find(model.Id); quotationType.Type = model.Type; db.UpdateEntity(quotationType, user.Id); return(RedirectToAction("Index")); } return(View(model)); }
public static QuotationType Create() { var doc = new QuotationType { UBLVersionID = "2.0", CustomizationID = "urn:oasis:names:specification:ubl:schema:xsd:Quotation-2-draft", ProfileID = "bpid:urn:oasis:names:draft:bpss:ubl-2-sbs-request-for-quotation-draft", ID = "QIY7655", CopyIndicator = false, UUID = "4D07786B-DA6D-439F-82D1-6FFFC7F4E3B1", IssueDate = "2005-06-20", Note = new TextType[] { new TextType { Value = "sample" } }, ValidityPeriod = new PeriodType { StartDate = "2005-06-20", EndDate = "2005-07-20" }, RequestForQuotationDocumentReference = new DocumentReferenceType { ID = "G867B", UUID = "8D076867-AE6D-439F-8281-5AAFC7F4E3B1", IssueDate = "2005-06-19" }, SellerSupplierParty = new SupplierPartyType { CustomerAssignedAccountID = "CO001", Party = new PartyType { PartyName = new PartyNameType[] { new PartyNameType { Name = "Consortial" } }, PostalAddress = new AddressType { StreetName = "Busy Street", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Farthing", PostalZone = "AA99 1BB", CountrySubentity = "Heremouthshire", AddressLine = new AddressLineType[] { new AddressLineType { Line = "The Roundabout" } }, Country = new CountryType { IdentificationCode = "GB" } }, PartyTaxScheme = new PartyTaxSchemeType[] { new PartyTaxSchemeType { RegistrationName = "Farthing Purchasing Consortium", CompanyID = "175 269 2355", ExemptionReason = new TextType[] { new TextType { Value = "N/A" } }, TaxScheme = new TaxSchemeType { ID = "VAT", TaxTypeCode = "VAT" } } }, Contact = new ContactType { Name = "Mrs Bouquet", Telephone = "0158 1233714", Telefax = "0158 1233856", ElectronicMail = "*****@*****.**" } } }, OriginatorCustomerParty = new CustomerPartyType { Party = new PartyType { PartyName = new PartyNameType[] { new PartyNameType { Name = "The Terminus" } }, PostalAddress = new AddressType { StreetName = "Avon Way", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Bridgtow", PostalZone = "ZZ99 1ZZ", CountrySubentity = "Avon", AddressLine = new AddressLineType[] { new AddressLineType { Line = "3rd Floor, Room 5" } }, Country = new CountryType { IdentificationCode = "GB" } }, PartyTaxScheme = new PartyTaxSchemeType[] { new PartyTaxSchemeType { RegistrationName = "Bridgtow District Council", CompanyID = "12356478", ExemptionReason = new TextType[] { new TextType { Value = "Local Authority" } }, TaxScheme = new TaxSchemeType { ID = "UK VAT", TaxTypeCode = "VAT" } } }, Contact = new ContactType { Name = "S Massiah", Telephone = "0127 98876545", Telefax = "0127 98876546", ElectronicMail = "*****@*****.**" } } }, Delivery = new DeliveryType[] { new DeliveryType { DeliveryAddress = new AddressType { StreetName = "Avon Way", BuildingName = "Thereabouts", BuildingNumber = "56A", CityName = "Bridgtow", PostalZone = "ZZ99 1ZZ", CountrySubentity = "Avon", AddressLine = new AddressLineType[] { new AddressLineType { Line = "3rd Floor, Room 5" } }, Country = new CountryType { IdentificationCode = "GB" } }, RequestedDeliveryPeriod = new PeriodType { StartDate = "2005-06-29", StartTime = "09:30:47.0Z", EndDate = "2005-06-29", EndTime = "09:30:47.0Z" } } }, DeliveryTerms = new DeliveryTermsType { SpecialTerms = new TextType[] { new TextType { Value = "1% deduction for late delivery as per contract" } } }, PaymentMeans = new PaymentMeansType { PaymentMeansCode = "20", PayeeFinancialAccount = new FinancialAccountType { ID = "12345678", Name = "Farthing Purchasing Consortium", AccountTypeCode = "Current", CurrencyCode = "GBP", FinancialInstitutionBranch = new BranchType { ID = "10-26-58", Name = "Open Bank Ltd, Bridgstow Branch ", FinancialInstitution = new FinancialInstitutionType { ID = "10-26-58", Name = "Open Bank Ltd", Address = new AddressType { StreetName = "City Road", BuildingName = "Banking House", BuildingNumber = "12", CityName = "London", PostalZone = "AQ1 6TH", CountrySubentity = @"London ", AddressLine = new AddressLineType[] { new AddressLineType { Line = "5th Floor" } }, Country = new CountryType { IdentificationCode = "GB" } } }, Address = new AddressType { StreetName = "Busy Street", BuildingName = "The Mall", BuildingNumber = "152", CityName = "Farthing", PostalZone = "AA99 1BB", CountrySubentity = "Heremouthshire", AddressLine = new AddressLineType[] { new AddressLineType { Line = "West Wing" } }, Country = new CountryType { IdentificationCode = "GB" } } }, Country = new CountryType { IdentificationCode = "GB" } } }, TransactionConditions = new TransactionConditionsType { Description = new TextType[] { new TextType { Value = "order response required; payment is by BACS or by cheque" } } }, AllowanceCharge = new AllowanceChargeType[] { new AllowanceChargeType { ChargeIndicator = false, AllowanceChargeReasonCode = "17", MultiplierFactorNumeric = 0.10M, Amount = new AmountType { currencyID = "GBP", Value = 10.00M } } }, DestinationCountry = new CountryType { IdentificationCode = "GB", Name = "Great Britain" }, TaxTotal = new TaxTotalType[] { new TaxTotalType { TaxAmount = new AmountType { currencyID = "GBP", Value = 17.50M }, TaxEvidenceIndicator = false, TaxSubtotal = new TaxSubtotalType[] { new TaxSubtotalType { TaxableAmount = new AmountType { currencyID = "GBP", Value = 100.00M }, TaxAmount = new AmountType { currencyID = "GBP", Value = 17.50M }, TaxCategory = new TaxCategoryType { ID = "A", TaxScheme = new TaxSchemeType { ID = "UK VAT", TaxTypeCode = "VAT" } } } } } }, QuotedMonetaryTotal = new MonetaryTotalType { LineExtensionAmount = new AmountType { currencyID = "GBP", Value = 100.00M }, TaxExclusiveAmount = new AmountType { currencyID = "GBP", Value = 90.00M }, PayableAmount = new AmountType { currencyID = "GBP", Value = 107.50M } }, QuotationLine = new QuotationLineType[] { new QuotationLineType { ID = "1", Note = new TextType[] { new TextType { Value = "sample" } }, LineItem = new LineItemType { ID = "1", Quantity = new QuantityType { unitCode = "KGM", Value = 100M }, LineExtensionAmount = new AmountType { currencyID = "GBP", Value = 100.00M }, TotalTaxAmount = new AmountType { currencyID = "GBP", Value = 17.50M }, Price = new PriceType { PriceAmount = new AmountType { currencyID = "GBP", Value = 100.00M }, BaseQuantity = new QuantityType { unitCode = "KGM", Value = 1M } }, Item = new ItemType { Description = new TextType[] { new TextType { Value = "Acme beeswax" } }, Name = "beeswax", BuyersItemIdentification = new ItemIdentificationType { ID = "6578489" }, SellersItemIdentification = new ItemIdentificationType { ID = "17589683" } } } } } }; doc.Xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(new[] { new XmlQualifiedName("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"), new XmlQualifiedName("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"), }); return(doc); }
public static bool UpdateExistingQuotation(this Highlight highlight, QuotationType quotationType, Location location) { // Static Variables Reference reference = location.Reference; List <Annotation> annotationsAtThisLocation = location.Annotations.ToList(); List <KnowledgeItem> quotations = reference.Quotations.Where(q => q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).Count() > 0).ToList(); List <KnowledgeItem> quotationsOfRelevantQuotationType = quotations.Where(q => q.QuotationType == quotationType && q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).Count() > 0).ToList(); List <KnowledgeItem> quotationsOfRelevantQuotationTypeAtThisLocation = quotationsOfRelevantQuotationType.Where(d => ((Annotation)d.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).ToList().FirstOrDefault().Target).Location == location).ToList(); List <Annotation> annotationsOfRelevantTypeAtThisLocation = quotationsOfRelevantQuotationTypeAtThisLocation.Select(d => (Annotation)d.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).ToList().FirstOrDefault().Target).ToList(); List <Annotation> equivalentAnnotationsWithQuotation = highlight.EquivalentAnnotations().Where(a => a.EntityLinks != null && a.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).Count() > 0).ToList(); if (equivalentAnnotationsWithQuotation == null) { return(false); } Annotation existingAnnotation = equivalentAnnotationsWithQuotation.Intersect(annotationsOfRelevantTypeAtThisLocation).FirstOrDefault(); if (existingAnnotation == null) { return(false); } // Dynamic Variables string highlightContents = highlight.GetContents(); // The Magic if (!string.IsNullOrEmpty(highlightContents)) { if (existingAnnotation != null) { if (existingAnnotation.EntityLinks != null && existingAnnotation.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).Count() > 0) { KnowledgeItem existingQuotation = (KnowledgeItem)existingAnnotation.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).FirstOrDefault().Source; switch (quotationType) { case QuotationType.QuickReference: existingQuotation.CoreStatement = highlightContents; break; default: existingQuotation.Text = highlightContents; break; } return(true); } } } else { return(true); } return(false); }
public static QuotationType Create() { var doc = new QuotationType { UBLVersionID = "2.0", CustomizationID = "OIOUBL-2.1", ProfileID = new IdentifierType { schemeAgencyID = "320", schemeID = "urn:oioubl:id:profileid-1.2", Value = "Procurement-QuoSim-1.0" }, ID = "QIY7655", CopyIndicator = false, UUID = "4D07786B-DA6D-439F-82D1-6FFFC7F4E3B1", IssueDate = "2008-05-01", IssueTime = "11:32:26.0Z", Note = new TextType[] { new TextType { languageID = "da-dk", Value = "Bestilling af computere" } }, ValidityPeriod = new PeriodType { StartDate = "2008-05-01", EndDate = "2008-05-06" }, RequestForQuotationDocumentReference = new DocumentReferenceType { ID = "G867B", UUID = "93T5G3G5-HYA3-7267-BVG3-GS46SW44WG53", IssueDate = "2008-04-19" }, SellerSupplierParty = new SupplierPartyType { CustomerAssignedAccountID = "LEV00123", Party = new PartyType { EndpointID = new IdentifierType { schemeID = "DK:CVR", Value = "DK18296799" }, PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IdentifierType { schemeID = "DK:CVR", Value = "DK18296799" } } }, PartyName = new PartyNameType[] { new PartyNameType { Name = "Delcomputer A/S" } }, PostalAddress = new AddressType { AddressFormatCode = new CodeType { listAgencyID = "320", listID = "urn:oioubl:codelist:addressformatcode-1.1", Value = "StructuredDK" }, StreetName = "Arne Jacobsens Allé", BuildingNumber = "15", CityName = "København S", PostalZone = "2300", Country = new CountryType { IdentificationCode = "DK" } }, PartyTaxScheme = new PartyTaxSchemeType[] { new PartyTaxSchemeType { CompanyID = new IdentifierType { schemeID = "DK:SE", Value = "DK18296799" }, TaxScheme = new TaxSchemeType { ID = new IdentifierType { schemeAgencyID = "320", schemeID = "urn:oioubl:id:taxschemeid-1.1", Value = "63" }, Name = "Moms" } } }, PartyLegalEntity = new PartyLegalEntityType[] { new PartyLegalEntityType { RegistrationName = "Delcomputer A/S", CompanyID = new IdentifierType { schemeID = "DK:CVR", Value = "18296799" } } } } }, OriginatorCustomerParty = new CustomerPartyType { Party = new PartyType { EndpointID = new IdentifierType { schemeAgencyID = "9", schemeID = "GLN", Value = "5798000416604" }, PartyIdentification = new PartyIdentificationType[] { new PartyIdentificationType { ID = new IdentifierType { schemeAgencyID = "9", schemeID = "GLN", Value = "5798000416604" } } }, PartyName = new PartyNameType[] { new PartyNameType { Name = "Gentofte Kommune" } }, PostalAddress = new AddressType { AddressFormatCode = new CodeType { listAgencyID = "320", listID = "urn:oioubl:codelist:addressformatcode-1.1", Value = "StructuredDK" }, StreetName = "Bernstorffsvej", BuildingNumber = "161", CityName = "Charlottenlund", PostalZone = "2920", Country = new CountryType { IdentificationCode = "DK" } }, PartyTaxScheme = new PartyTaxSchemeType[] { new PartyTaxSchemeType { CompanyID = new IdentifierType { schemeID = "DK:SE", Value = "DK12345678" }, TaxScheme = new TaxSchemeType { ID = new IdentifierType { schemeAgencyID = "320", schemeID = "urn:oioubl:id:taxschemeid-1.1", Value = "63" }, Name = "Moms" } } }, PartyLegalEntity = new PartyLegalEntityType[] { new PartyLegalEntityType { RegistrationName = "Gentofte Kommune", CompanyID = new IdentifierType { schemeID = "DK:CVR", Value = "DK12345678" } } }, Contact = new ContactType { ID = "12345678", Name = "Sille Schyberg" } } }, Delivery = new DeliveryType[] { new DeliveryType { DeliveryAddress = new AddressType { AddressFormatCode = new CodeType { listAgencyID = "320", listID = "urn:oioubl:codelist:addressformatcode-1.1", Value = "StructuredDK" }, StreetName = "Bernstorffsvej", BuildingNumber = "161", CityName = "Charlottenlund", PostalZone = "2920", AddressLine = new AddressLineType[] { new AddressLineType { Line = "IT-afdelingen" }, new AddressLineType { Line = "1. sal" } }, Country = new CountryType { IdentificationCode = "DK" } }, RequestedDeliveryPeriod = new PeriodType { StartDate = "2008-05-06", StartTime = "09:30:47.0Z", EndDate = "2008-05-10", EndTime = "09:30:47.0Z" } } }, DeliveryTerms = new DeliveryTermsType { SpecialTerms = new TextType[] { new TextType { Value = "1% reduktion i kontraktsummen pr. dags forsinkelse jf. SKI kontrakt" } } }, QuotedMonetaryTotal = new MonetaryTotalType { LineExtensionAmount = new AmountType { currencyID = "DKK", Value = 197750.00M }, TaxExclusiveAmount = new AmountType { currencyID = "DKK", Value = 49437.50M }, TaxInclusiveAmount = new AmountType { currencyID = "DKK", Value = 247187.50M }, PayableAmount = new AmountType { currencyID = "DKK", Value = 247187.50M } }, QuotationLine = new QuotationLineType[] { new QuotationLineType { ID = "1", Note = new TextType[] { new TextType { Value = "Computer" } }, LineItem = new LineItemType { ID = "DELL1052665", Quantity = new QuantityType { unitCode = "EA", Value = 35M }, LineExtensionAmount = new AmountType { currencyID = "DKK", Value = 150500.00M }, TotalTaxAmount = new AmountType { currencyID = "DKK", Value = 37625.00M }, Price = new PriceType { PriceAmount = new AmountType { currencyID = "DKK", Value = 4300.00M }, BaseQuantity = new QuantityType { unitCode = "EA", Value = 1M } }, Item = new ItemType { Description = new TextType[] { new TextType { Value = "Stationær computer" } }, Name = "Dell PrecisionTM T3400" } } }, new QuotationLineType { ID = "2", Note = new TextType[] { new TextType { Value = "Skærm" } }, LineItem = new LineItemType { ID = "DELL2363463", Quantity = new QuantityType { unitCode = "EA", Value = 35M }, LineExtensionAmount = new AmountType { currencyID = "DKK", Value = 43750.00M }, TotalTaxAmount = new AmountType { currencyID = "DKK", Value = 10937.50M }, Price = new PriceType { PriceAmount = new AmountType { currencyID = "DKK", Value = 1250.00M }, BaseQuantity = new QuantityType { unitCode = "EA", Value = 1M } }, Item = new ItemType { Description = new TextType[] { new TextType { Value = "Fladskærm" } }, Name = "FP/BL 1908WFP" } } }, new QuotationLineType { ID = "3", Note = new TextType[] { new TextType { Value = "Mus" } }, LineItem = new LineItemType { ID = "DELL2367452", Quantity = new QuantityType { unitCode = "EA", Value = 35M }, LineExtensionAmount = new AmountType { currencyID = "DKK", Value = 1750.00M }, TotalTaxAmount = new AmountType { currencyID = "DKK", Value = 437.50M }, Price = new PriceType { PriceAmount = new AmountType { currencyID = "DKK", Value = 50.00M }, BaseQuantity = new QuantityType { unitCode = "EA", Value = 1M } }, Item = new ItemType { Description = new TextType[] { new TextType { Value = "Mus" } }, Name = "Dell Quietkey USB-tastatur, sort - Dansk (QWERTY)" } } }, new QuotationLineType { ID = "4", Note = new TextType[] { new TextType { Value = "Tastatur" } }, LineItem = new LineItemType { ID = "DELL8436783", Quantity = new QuantityType { unitCode = "EA", Value = 35M }, LineExtensionAmount = new AmountType { currencyID = "DKK", Value = 1750.00M }, TotalTaxAmount = new AmountType { currencyID = "DKK", Value = 437.50M }, Price = new PriceType { PriceAmount = new AmountType { currencyID = "DKK", Value = 50.00M }, BaseQuantity = new QuantityType { unitCode = "EA", Value = 1M } }, Item = new ItemType { Description = new TextType[] { new TextType { Value = "Tastatur" } }, Name = "Dell Quietkey USB-tastatur, sort - Dansk (QWERTY)" } } } } }; doc.Xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(new[] { new XmlQualifiedName("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"), new XmlQualifiedName("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"), }); return(doc); }
public AnnotationsImporterColorPicker(QuotationType quotationType, List <ColorPt> existingColorPts, out List <ColorPt> selectedColorPts) { InitializeComponent(quotationType, existingColorPts, out selectedColorPts); }
public static KnowledgeItem CombineQuotations(List <KnowledgeItem> quotations) { if (quotations.Count() == 1) { return(quotations.FirstOrDefault()); } if (quotations.Count == 0) { return(null); } // Static Variables PreviewControl previewControl = PreviewMethods.GetPreviewControl(); if (previewControl == null) { return(null); } PdfViewControl pdfViewControl = previewControl.GetPdfViewControl(); if (pdfViewControl == null) { return(null); } Document document = pdfViewControl.Document; if (document == null) { return(null); } Reference reference = quotations.FirstOrDefault().Reference; if (reference == null) { return(null); } Project project = Program.ActiveProjectShell.Project; if (project == null) { return(null); } List <Location> locations = quotations.GetPDFLocations().Distinct().ToList(); if (locations.Count != 1) { return(null); } Location location = locations.FirstOrDefault(); List <QuotationType> quotationTypes = quotations.Select(q => q.QuotationType).Distinct().ToList(); var itemToRemove = quotationTypes.SingleOrDefault(q => q == QuotationType.Highlight); quotationTypes.Remove(itemToRemove); QuotationType quotationType = quotationTypes.FirstOrDefault(); if (quotationTypes.Count == 0) { quotationType = QuotationType.Highlight; } // Dynamic Variables KnowledgeItem newQuotation = new KnowledgeItem(reference, quotationType); string text = string.Empty; List <Quad> quads = new List <Quad>(); List <PageRange> pageRangesList = new List <PageRange>(); string pageRangeText = string.Empty; List <PageWidth> store = new List <PageWidth>(); // The Magic if (document != null) { for (int i = 1; i <= document.GetPageCount(); i++) { pdftron.PDF.Page page = document.GetPage(i); if (page.IsValid()) { var re = page.GetCropBox(); store.Add(new PageWidth(location, i, re.Width())); } else { store.Add(new PageWidth(location, i, 0.00)); } } } quotations.Sort(new KnowledgeItemComparer(store)); foreach (KnowledgeItem quotation in quotations) { if (!string.IsNullOrEmpty(quotation.Text)) { text = MergeRTF(text, quotation.TextRtf); } if (!string.IsNullOrEmpty(quotation.PageRange.OriginalString)) { pageRangesList.Add(quotation.PageRange); } } pageRangesList = PageRangeMerger.MergeAdjacent(pageRangesList); pageRangeText = PageRangeMerger.PageRangeListToString(pageRangesList); newQuotation.TextRtf = text; newQuotation.PageRange = pageRangeText; newQuotation.PageRange = newQuotation.PageRange.Update(quotations[0].PageRange.NumberingType); newQuotation.PageRange = newQuotation.PageRange.Update(quotations[0].PageRange.NumeralSystem); reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); return(newQuotation); }
public static KnowledgeItem CreateNewQuickReferenceFromAnnotationContent(this TextContent textContent, string pageRangeString, Reference reference, QuotationType quotationType) { Project project = Program.ActiveProjectShell.Project; if (project == null) { return(null); } KnowledgeItem newQuotation = new KnowledgeItem(reference, quotationType); newQuotation.CoreStatement = textContent.Text; newQuotation.PageRange = pageRangeString; return(newQuotation); }
public static KnowledgeItem CreateNewQuotationFromHighlightContents(this string highlightContents, string pageRangeString, Reference reference, QuotationType quotationType) { Project project = Program.ActiveProjectShell.Project; if (project == null) { return(null); } KnowledgeItem newQuotation = new KnowledgeItem(reference, quotationType); newQuotation.Text = highlightContents; newQuotation.PageRange = pageRangeString; return(newQuotation); }
public static bool CreateNewQuotationAndAnnotationFromHighlight(this Highlight highlight, QuotationType quotationType, bool ImportEmptyAnnotations, bool RedrawAnnotations, List <Annotation> temporaryAnnotations) { string highlightContents = highlight.GetContents(); if (string.IsNullOrEmpty(highlightContents) && !ImportEmptyAnnotations) { return(false); } Project project = Program.ActiveProjectShell.Project; if (project == null) { return(false); } PreviewControl previewControl = PreviewMethods.GetPreviewControl(); if (previewControl == null) { return(false); } PdfViewControl pdfViewControl = previewControl.GetPdfViewControl(); if (pdfViewControl == null) { return(false); } Document document = pdfViewControl.Document; if (document == null) { return(false); } Location location = previewControl.ActiveLocation; if (location == null) { return(false); } Reference reference = location.Reference; if (reference == null) { return(false); } // Dynamic variables KnowledgeItem newQuotation = null; KnowledgeItem newDirectQuotation = null; TextContent textContent = null; // Does any other annotation with the same quads already exist? Annotation existingAnnotation = highlight.EquivalentAnnotations().FirstOrDefault(); if ((string.IsNullOrEmpty(highlightContents) && ImportEmptyAnnotations) || quotationType == QuotationType.Comment) { Annotation temporaryAnnotation = temporaryAnnotations.Where(a => !highlight.AsAnnotationQuads().TemporaryQuads().Except(a.Quads.ToList()).Any()).FirstOrDefault(); if (temporaryAnnotation != null) { pdfViewControl.GoToAnnotation(temporaryAnnotation); textContent = (TextContent)pdfViewControl.GetSelectedContentFromType(pdfViewControl.GetSelectedContentType(), -1, false, true); location.Annotations.Remove(temporaryAnnotation); } else { return(false); } } int startPage = 1; if (reference.PageRange.StartPage.Number != null) { startPage = reference.PageRange.StartPage.Number.Value; } string pageRangeString = (startPage + highlight.GetPage().GetIndex() - 1).ToString(); Annotation knowledgeItemIndicationAnnotation = highlight.CreateKnowledgeItemIndicationAnnotation(RedrawAnnotations); switch (quotationType) { case QuotationType.Comment: if (!string.IsNullOrEmpty(highlightContents)) { newQuotation = highlightContents.CreateNewQuotationFromHighlightContents(pageRangeString, reference, quotationType); reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); newQuotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); if (AnnotationsImporterColorPicker.ImportDirectQuotationLinkedWithCommentSelected) { Annotation newDirectQuotationIndicationAnnotation = highlight.CreateKnowledgeItemIndicationAnnotation(RedrawAnnotations); newDirectQuotation = textContent.CreateNewQuotationFromAnnotationContent(pageRangeString, reference, QuotationType.DirectQuotation); reference.Quotations.Add(newDirectQuotation); project.AllKnowledgeItems.Add(newDirectQuotation); newDirectQuotation.LinkWithKnowledgeItemIndicationAnnotation(newDirectQuotationIndicationAnnotation); EntityLink commentDirectQuotationLink = new EntityLink(project); commentDirectQuotationLink.Source = newQuotation; commentDirectQuotationLink.Target = newDirectQuotation; commentDirectQuotationLink.Indication = EntityLink.CommentOnQuotationIndication; project.EntityLinks.Add(commentDirectQuotationLink); newQuotation.CoreStatement = newDirectQuotation.CoreStatement + " (Comment)"; newQuotation.CoreStatementUpdateType = UpdateType.Manual; } } else if (string.IsNullOrEmpty(highlightContents) && ImportEmptyAnnotations) { newQuotation = textContent.CreateNewQuotationFromAnnotationContent(pageRangeString, reference, quotationType); reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); newQuotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); if (AnnotationsImporterColorPicker.ImportDirectQuotationLinkedWithCommentSelected) { Annotation newDirectQuotationIndicationAnnotation = highlight.CreateKnowledgeItemIndicationAnnotation(RedrawAnnotations); newDirectQuotation = textContent.CreateNewQuotationFromAnnotationContent(pageRangeString, reference, QuotationType.DirectQuotation); reference.Quotations.Add(newDirectQuotation); project.AllKnowledgeItems.Add(newDirectQuotation); newDirectQuotation.LinkWithKnowledgeItemIndicationAnnotation(newDirectQuotationIndicationAnnotation); EntityLink commentDirectQuotationLink = new EntityLink(project); commentDirectQuotationLink.Source = newQuotation; commentDirectQuotationLink.Target = newDirectQuotation; commentDirectQuotationLink.Indication = EntityLink.CommentOnQuotationIndication; project.EntityLinks.Add(commentDirectQuotationLink); newQuotation.CoreStatement = newDirectQuotation.CoreStatement + " (Comment)"; newQuotation.CoreStatementUpdateType = UpdateType.Manual; } } break; case QuotationType.QuickReference: if (!string.IsNullOrEmpty(highlightContents)) { newQuotation = highlightContents.CreateNewQuickReferenceFromHighlightContents(pageRangeString, reference, quotationType); } else if (string.IsNullOrEmpty(highlightContents) && ImportEmptyAnnotations) { newQuotation = textContent.CreateNewQuickReferenceFromAnnotationContent(pageRangeString, reference, quotationType); } reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); newQuotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); break; default: if (!string.IsNullOrEmpty(highlightContents)) { newQuotation = highlightContents.CreateNewQuotationFromHighlightContents(pageRangeString, reference, quotationType); reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); newQuotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); } else if (string.IsNullOrEmpty(highlightContents) && ImportEmptyAnnotations) { newQuotation = textContent.CreateNewQuotationFromAnnotationContent(pageRangeString, reference, quotationType); reference.Quotations.Add(newQuotation); project.AllKnowledgeItems.Add(newQuotation); newQuotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); } break; } if (existingAnnotation != null) { existingAnnotation.LinkWithKnowledgeItemIndicationAnnotation(knowledgeItemIndicationAnnotation); existingAnnotation.Visible = false; } return(true); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent(QuotationType quotationType, List <ColorPt> existingColorPts, out List <ColorPt> selectedColorPts) { selectedColorPts = new List <ColorPt>(); ImportEmptyAnnotationsSelected = false; RedrawAnnotationsSelected = true; ImportDirectQuotationLinkedWithCommentSelected = true; string colorPickerCaption = string.Empty; switch (quotationType) { case QuotationType.Comment: colorPickerCaption = "Select the colors of all comments."; break; case QuotationType.DirectQuotation: colorPickerCaption = "Select the colors of all direct quotations."; ImportEmptyAnnotationsSelected = true; break; case QuotationType.IndirectQuotation: colorPickerCaption = "Select the colors of all indirect quotations."; break; case QuotationType.QuickReference: colorPickerCaption = "Select the colors of all quick references."; ImportEmptyAnnotationsSelected = true; break; case QuotationType.Summary: colorPickerCaption = "Select the colors of all summaries."; break; default: break; } int formWidth = 300; int formHeight = existingColorPts.Count * 50 + 160; if (formWidth < 400) { formWidth = 375; } int buttonWidth = 75; int buttonHeight = 25; int padding = 10; this.BackColor = System.Drawing.Color.White; this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.textbox1 = new TextBox(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(formWidth / 5, formHeight - 40); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(buttonWidth, buttonHeight); this.button1.TabIndex = 0; this.button1.Text = "OK"; this.button1.UseVisualStyleBackColor = true; // // button2 // this.button2.Location = new System.Drawing.Point(formWidth - buttonWidth - formWidth / 5, formHeight - 40); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(buttonWidth, buttonHeight); this.button2.TabIndex = 1; this.button2.Text = "Cancel"; this.button2.UseVisualStyleBackColor = true; // // textbox 1 System.Drawing.Font font = new System.Drawing.Font("Calibri", 13.0f); this.textbox1.Location = new System.Drawing.Point(padding, padding); this.textbox1.Text = colorPickerCaption; this.textbox1.Font = font; this.textbox1.ForeColor = System.Drawing.Color.DarkSlateBlue; this.textbox1.Size = new System.Drawing.Size(formWidth - 20, buttonHeight); this.textbox1.BackColor = this.BackColor; this.textbox1.BorderStyle = BorderStyle.None; // // // AnnotationsImporterColorPicker // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(formWidth, formHeight); this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(textbox1); this.CancelButton = this.button2; this.Name = "AnnotationsImporterColorPicker"; this.Text = "Color Picker"; this.ResumeLayout(false); int i = 0; List <CheckBox> checkBoxes = new List <CheckBox>(); foreach (ColorPt existingColorPt in existingColorPts) { List <ColorPt> selectedColorPtsInBox = selectedColorPts; int existingColorPtR = System.Convert.ToInt32(existingColorPt.Get(0) * 255); int existingColorPtG = System.Convert.ToInt32(existingColorPt.Get(1) * 255); int existingColorPtB = System.Convert.ToInt32(existingColorPt.Get(2) * 255); int existingColorPtA = System.Convert.ToInt32((1 - existingColorPt.Get(3)) * 255); checkBoxes.Add(new CheckBox()); CheckBox checkBox = checkBoxes[i]; checkBox.Tag = i.ToString(); System.Drawing.Color foreColor = System.Drawing.Color.FromArgb(existingColorPtA, existingColorPtR, existingColorPtG, existingColorPtB); checkBox.ForeColor = foreColor; checkBox.BackColor = System.Drawing.Color.White; checkBox.Width = formWidth - 30; checkBox.Font = new System.Drawing.Font(checkBox.Font.FontFamily, checkBox.Font.Size, System.Drawing.FontStyle.Bold); checkBox.AutoSize = true; checkBox.Location = new System.Drawing.Point(padding, padding + buttonHeight + padding + i * padding + i * buttonHeight); this.Controls.Add(checkBox); checkBox.Click += new EventHandler((sender, e) => ColorCheckboxClick(sender, e, checkBox, existingColorPt, selectedColorPtsInBox, out selectedColorPtsInBox)); selectedColorPts = selectedColorPtsInBox; i++; } // The Options if (quotationType == QuotationType.Comment) { CheckBox ImportDirectQuotationLinkedWithCommentCheckBox = new CheckBox(); ImportDirectQuotationLinkedWithCommentCheckBox.Checked = ImportDirectQuotationLinkedWithCommentSelected; ImportDirectQuotationLinkedWithCommentCheckBox.Width = formWidth - 30; ImportDirectQuotationLinkedWithCommentCheckBox.Text = "Import direct quotation linked with comment."; ImportDirectQuotationLinkedWithCommentCheckBox.Location = new System.Drawing.Point(padding, formHeight - (40 + 3 * (buttonHeight + padding))); this.Controls.Add(ImportDirectQuotationLinkedWithCommentCheckBox); ImportDirectQuotationLinkedWithCommentCheckBox.Click += new EventHandler((sender, e) => YesNoCheckboxClick(sender, e, ImportDirectQuotationLinkedWithCommentCheckBox, ImportDirectQuotationLinkedWithCommentSelected, "ImportDirectQuotationLinkedWithComment")); } CheckBox redrawAnnotationsCheckBox = new CheckBox(); redrawAnnotationsCheckBox.Checked = RedrawAnnotationsSelected; redrawAnnotationsCheckBox.Width = formWidth - 30; redrawAnnotationsCheckBox.Text = "Redraw annotations."; redrawAnnotationsCheckBox.Location = new System.Drawing.Point(padding, formHeight - (40 + 2 * (buttonHeight + padding))); this.Controls.Add(redrawAnnotationsCheckBox); redrawAnnotationsCheckBox.Click += new EventHandler((sender, e) => YesNoCheckboxClick(sender, e, redrawAnnotationsCheckBox, RedrawAnnotationsSelected, "RedrawAnnotations")); CheckBox emptyAnnotationsCheckBox = new CheckBox(); emptyAnnotationsCheckBox.Checked = ImportEmptyAnnotationsSelected; emptyAnnotationsCheckBox.Width = formWidth - 30; emptyAnnotationsCheckBox.Text = "Import empty annotations."; emptyAnnotationsCheckBox.Location = new System.Drawing.Point(padding, formHeight - (40 + buttonHeight + padding)); this.Controls.Add(emptyAnnotationsCheckBox); emptyAnnotationsCheckBox.Click += new EventHandler((sender, e) => YesNoCheckboxClick(sender, e, emptyAnnotationsCheckBox, ImportEmptyAnnotationsSelected, "ImportEmptyAnnotations")); // The Buttons button1.Click += new EventHandler(cmdOK_Click); button2.Click += new EventHandler(cmdCancel_Click); }
public StockQuotationProposal( int stockShares, StockIdentifier stockIdentifier, string ownerName, decimal price, Guid ownerId, QuotationType type) : base(stockShares, stockIdentifier, ownerName, price, ownerId, type) { }
public static void AnnotationsImport(QuotationType quotationType) { // Static Variables PreviewControl previewControl = PreviewMethods.GetPreviewControl(); if (previewControl == null) { return; } PdfViewControl pdfViewControl = previewControl.GetPdfViewControl(); if (pdfViewControl == null) { return; } Document document = pdfViewControl.Document; if (document == null) { return; } Location location = previewControl.ActiveLocation; if (location == null) { return; } List <Reference> references = Program.ActiveProjectShell.Project.References.Where(r => r.Locations.Contains(location)).ToList(); if (references == null) { return; } if (references.Count != 1) { MessageBox.Show("The document is not linked with exactly one reference. Import aborted."); } Reference reference = references.FirstOrDefault(); if (references == null) { return; } LinkedResource linkedResource = location.Address; string pathToFile = linkedResource.Resolve().LocalPath; PreviewBehaviour previewBehaviour = location.PreviewBehaviour; // Dynamic Variables string colorPickerCaption = string.Empty; List <ColorPt> selectedColorPts = new List <ColorPt>(); int annotationsImportedCount = 0; bool ImportEmptyAnnotations = false; bool RedrawAnnotations = true; // The Magic Form commentAnnotationsColorPicker = new AnnotationsImporterColorPicker(quotationType, document.ExistingColors(), out selectedColorPts); DialogResult dialogResult = commentAnnotationsColorPicker.ShowDialog(); RedrawAnnotations = AnnotationsImporterColorPicker.RedrawAnnotationsSelected; ImportEmptyAnnotations = AnnotationsImporterColorPicker.ImportEmptyAnnotationsSelected; if (dialogResult == DialogResult.Cancel) { MessageBox.Show("Import of external highlights cancelled."); return; } List <Annotation> temporaryAnnotations = new List <Annotation>(); if (ImportEmptyAnnotations || quotationType == QuotationType.Comment) { for (int pageIndex = 1; pageIndex <= document.GetPageCount(); pageIndex++) { pdftron.PDF.Page page = document.GetPage(pageIndex); if (page.IsValid()) { List <Annot> annotsToDelete = new List <Annot>(); for (int j = 0; j < page.GetNumAnnots(); j++) { Annot annot = page.GetAnnot(j); if (annot.GetSDFObj() != null && (annot.GetType() == Annot.Type.e_Highlight || annot.GetType() == Annot.Type.e_Unknown)) { Highlight highlight = new Highlight(annot); if (highlight == null) { continue; } ColorPt annotColorPt = annot.GetColorAsRGB(); if (selectedColorPts.Where(e => e.Get(0) == annotColorPt.Get(0) && e.Get(1) == annotColorPt.Get(1) && e.Get(2) == annotColorPt.Get(2) && e.Get(3) == annotColorPt.Get(3) ).Count() == 0) { continue; } Annotation temporaryAnnotation = highlight.TemporaryAnnotation(); location.Annotations.Add(temporaryAnnotation); temporaryAnnotations.Add(temporaryAnnotation); } } // end for (int j = 1; j <= page.GetNumAnnots(); j++) } // end if (page.IsValid()) } // end for (int i = 1; i <= document.GetPageCount(); i++) previewControl.ShowNoPreview(); location.PreviewBehaviour = PreviewBehaviour.SkipEntryPage; previewControl.ShowLocationPreview(location); document = new Document(pathToFile); } //Uncomment here to get an overview of all annotations //int x = 0; //foreach (Annotation a in location.Annotations) //{ // System.Diagnostics.Debug.WriteLine("Annotation " + x.ToString()); // int y = 0; // foreach (Quad q in a.Quads) // { // System.Diagnostics.Debug.WriteLine("Quad " + y.ToString()); // System.Diagnostics.Debug.WriteLine("IsContainer: " + q.IsContainer.ToString()); // System.Diagnostics.Debug.WriteLine("MinX: " + q.MinX.ToString()); // System.Diagnostics.Debug.WriteLine("MinY: " + q.MinY.ToString()); // System.Diagnostics.Debug.WriteLine("MaxX: " + q.MaxX.ToString()); // System.Diagnostics.Debug.WriteLine("MaxY: " + q.MaxY.ToString()); // y = y + 1; // } // x = x + 1; //} int v = 0; for (int pageIndex = 1; pageIndex <= document.GetPageCount(); pageIndex++) { pdftron.PDF.Page page = document.GetPage(pageIndex); if (page.IsValid()) { List <Annot> annotsToDelete = new List <Annot>(); for (int j = 0; j < page.GetNumAnnots(); j++) { Annot annot = page.GetAnnot(j); if (annot.GetSDFObj() != null && (annot.GetType() == Annot.Type.e_Highlight || annot.GetType() == Annot.Type.e_Unknown)) { Highlight highlight = new Highlight(annot); if (highlight == null) { continue; } ColorPt annotColorPt = annot.GetColorAsRGB(); if (selectedColorPts.Where(e => e.Get(0) == annotColorPt.Get(0) && e.Get(1) == annotColorPt.Get(1) && e.Get(2) == annotColorPt.Get(2) && e.Get(3) == annotColorPt.Get(3) ).Count() == 0) { continue; } // Uncomment here to get an overview of all highlights //System.Diagnostics.Debug.WriteLine("Highlight " + v.ToString()); //int w = 0; //foreach (Quad q in highlight.AsAnnotationQuads()) //{ // System.Diagnostics.Debug.WriteLine("Quad " + w.ToString()); // System.Diagnostics.Debug.WriteLine("IsContainer: " + q.IsContainer.ToString()); // System.Diagnostics.Debug.WriteLine("MinX: " + q.MinX.ToString()); // System.Diagnostics.Debug.WriteLine("MinY: " + q.MinY.ToString()); // System.Diagnostics.Debug.WriteLine("MaxX: " + q.MaxX.ToString()); // System.Diagnostics.Debug.WriteLine("MaxY: " + q.MaxY.ToString()); // w = w + 1; //} //v = v + 1; if (highlight.UpdateExistingQuotation(quotationType, location)) { annotationsImportedCount++; continue; } if (highlight.CreateNewQuotationAndAnnotationFromHighlight(quotationType, ImportEmptyAnnotations, RedrawAnnotations, temporaryAnnotations)) { annotationsImportedCount++; continue; } } } // end for (int j = 1; j <= page.GetNumAnnots(); j++) foreach (Annot annot in annotsToDelete) { page.AnnotRemove(annot); } } // end if (page.IsValid()) } // end for (int i = 1; i <= document.GetPageCount(); i++) foreach (Annotation annotation in temporaryAnnotations) { location.Annotations.Remove(annotation); } location.PreviewBehaviour = previewBehaviour; MessageBox.Show(annotationsImportedCount.ToString() + " highlights have been imported."); }