예제 #1
0
        public ContactPayload GetTransformedPayload(PersonDocument document, out List <SyncFeedEntryLink> links)
        {
            contacttype    contact = new contacttype();
            ContactPayload payload = new ContactPayload();

            links = new List <SyncFeedEntryLink>();

            contact.uuid          = GetUuid(document.Id, document.CrmId).ToString();
            contact.applicationID = document.Id;
            payload.SyncUuid      = StringToGuid(contact.uuid);
            payload.LocalID       = document.Id;
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.contacts, document.Id));

            links.Add(selfLink);

            contact.familyName = (document.lastname.IsNull) ? null : document.lastname.Value.ToString();
            contact.firstName  = (document.firstname.IsNull) ? null : document.firstname.Value.ToString();
            contact.middleName = (document.middlename.IsNull) ? null : document.middlename.Value.ToString();
            contact.salutation = (document.salutation.IsNull) ? null : document.salutation.Value.ToString();
            contact.suffix     = (document.suffix.IsNull) ? null : document.suffix.Value.ToString();
            contact.title      = (document.title.IsNull) ? null : document.title.Value.ToString();
            contact.fullName   = (document.fullname.IsNull) ? null : document.fullname.Value.ToString();
            if ((!document.primaryperson.IsNull) && (document.primaryperson.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
            {
                contact.primacyIndicator = true;
            }



            payload.Contacttype = contact;
            return(payload);
        }
        public CommodityGroupPayload GetTransformedPayload(ProductFamilyDocument document, out List <SyncFeedEntryLink> links)
        {
            CommodityGroupPayload payload = new CommodityGroupPayload();

            links = new List <SyncFeedEntryLink>();
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.commodityGroups, document.Id));

            links.Add(selfLink);
            payload.CommodityGrouptype.active = false;

            if ((!document.active.IsNull) &&
                document.active.Value.ToString().Equals(Sage.Integration.Northwind.Application.API.Constants.DefaultValues.Active, StringComparison.InvariantCultureIgnoreCase))
            {
                payload.CommodityGrouptype.active = true;
            }

            //payload.CommodityGrouptype.uuid = GetUuid(document.Id, document.CrmId).ToString();
            payload.SyncUuid = GetUuid(document.Id, document.CrmId);
            payload.LocalID  = document.Id;
            payload.CommodityGrouptype.applicationID = document.Id;

            payload.CommodityGrouptype.name        = (document.name.IsNull) ? null : document.name.Value.ToString();
            payload.CommodityGrouptype.label       = payload.CommodityGrouptype.name;
            payload.CommodityGrouptype.description = (document.description.IsNull) ? null : document.description.Value.ToString();

            return(payload);
        }
예제 #3
0
        public PostalAddressPayload GetTransformedPayload(AddressDocument document, out List <SyncFeedEntryLink> links)
        {
            PostalAddressPayload payload = new PostalAddressPayload();

            links = new List <SyncFeedEntryLink>();


            payload.SyncUuid = GetUuid(document.Id, document.CrmId);
            payload.LocalID  = document.Id;
            payload.PostalAddresstype.uuid          = payload.SyncUuid.ToString();
            payload.PostalAddresstype.applicationID = document.Id;
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.postalAddresses, document.Id));

            links.Add(selfLink);

            payload.PostalAddresstype.active      = true;
            payload.PostalAddresstype.address1    = (document.address1.IsNull) ? null : document.address1.Value.ToString();
            payload.PostalAddresstype.address2    = (document.address2.IsNull) ? null : document.address2.Value.ToString();
            payload.PostalAddresstype.address3    = (document.address3.IsNull) ? null : document.address3.Value.ToString();
            payload.PostalAddresstype.address4    = (document.address4.IsNull) ? null : document.address4.Value.ToString();
            payload.PostalAddresstype.country     = (document.country.IsNull) ? null : document.country.Value.ToString();
            payload.PostalAddresstype.deleted     = false;
            payload.PostalAddresstype.stateRegion = (document.state.IsNull) ? null : document.state.Value.ToString();
            payload.PostalAddresstype.townCity    = (document.City.IsNull) ? null : document.City.Value.ToString();
            payload.PostalAddresstype.zipPostCode = (document.postcode.IsNull) ? null : document.postcode.Value.ToString();
            if ((!document.primaryaddress.IsNull) && (document.primaryaddress.Value.ToString().Equals("true", StringComparison.InvariantCultureIgnoreCase)))
            {
                payload.PostalAddresstype.primacyIndicator = true;
            }
            payload.PostalAddresstype.type = postalAddressTypeenum.Correspondance;
            return(payload);
        }
        public PricePayload GetTransformedPayload(PriceDocument document, out List <SyncFeedEntryLink> links)
        {
            PricePayload payload = new PricePayload();

            links = new List <SyncFeedEntryLink>();
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.prices, document.Id));

            links.Add(selfLink);

            //payload.Pricetype.uuid = GetUuid(document.Id, document.CrmId).ToString();
            payload.SyncUuid = GetUuid(document.Id, document.CrmId);
            payload.LocalID  = document.Id;
            payload.Pricetype.applicationID = document.Id;

            if ((!document.active.IsNull) &&
                document.active.Value.ToString().Equals(Sage.Integration.Northwind.Application.API.Constants.DefaultValues.Active, StringComparison.InvariantCultureIgnoreCase))
            {
                payload.Pricetype.active = true;
            }

            payload.Pricetype.priceSpecified = !(document.price.IsNull);
            if (payload.Pricetype.priceSpecified)
            {
                payload.Pricetype.price = (decimal)document.price.Value;
            }

            return(payload);
        }
        public PhoneNumberPayload GetTransformedPayload(PhoneDocument document, out List <SyncFeedEntryLink> links)
        {
            links = new List <SyncFeedEntryLink>();
            PhoneNumberPayload payload = new PhoneNumberPayload();

            payload.PhoneNumbertype.areaCode    = (document.areacode.IsNull) ? null : document.areacode.Value.ToString();
            payload.PhoneNumbertype.countryCode = (document.countrycode.IsNull) ? null : document.countrycode.Value.ToString();
            payload.PhoneNumbertype.number      = (document.number.IsNull) ? null : document.number.Value.ToString();
            payload.PhoneNumbertype.text        = (document.fullnumber.IsNull) ? null : document.fullnumber.Value.ToString();

            if (!document.type.IsNull)
            {
                if (document.type.Value.ToString().Equals("Business", StringComparison.InvariantCultureIgnoreCase))
                {
                    payload.PhoneNumbertype.type = "general";
                }
                if (document.type.Value.ToString().Equals("Fax", StringComparison.InvariantCultureIgnoreCase))
                {
                    payload.PhoneNumbertype.type = "fax";
                }
            }

            payload.SyncUuid = GetUuid(document.Id, document.CrmId);
            payload.LocalID  = document.Id;
            payload.PhoneNumbertype.applicationID = document.Id;
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.phoneNumbers, document.Id));

            links.Add(selfLink);

            return(payload);
        }
        public CommodityPayload GetTransformedPayload(ProductDocument document, out List <SyncFeedEntryLink> links)
        {
            CommodityPayload payload = new CommodityPayload();

            links = new List <SyncFeedEntryLink>();
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.commodities, document.Id));

            links.Add(selfLink);
            if (!document.productfamilyid.IsNull)
            {
                string commodityGroupUuid = GetCommodityGroupUuid(document.productfamilyid.Value.ToString());
                if (!String.IsNullOrEmpty(commodityGroupUuid))
                {
                    SyncFeedEntryLink commodityGroupLink = SyncFeedEntryLink.CreateRelatedLink(selfLink.Href, SupportedResourceKinds.commodityGroups.ToString(), _commodityGroupUuidPayloadPath, commodityGroupUuid);
                    links.Add(commodityGroupLink);
                }
            }
            if (!document.uomcategory.IsNull)
            {
                string uomGroupUuid = GetUnitOfMeasureGroupUuid(document.uomcategory.Value.ToString());
                if (!String.IsNullOrEmpty(uomGroupUuid))
                {
                    SyncFeedEntryLink uomGroupLink = SyncFeedEntryLink.CreateRelatedLink(selfLink.Href, SupportedResourceKinds.unitsOfMeasureGroup.ToString(), _commodityGroupUuidPayloadPath, uomGroupUuid);
                    links.Add(uomGroupLink);
                }
            }
            payload.SyncUuid = GetUuid(document.Id, document.CrmId);
            payload.LocalID  = document.Id;

            payload.Commoditytype.uuid          = payload.SyncUuid.ToString();
            payload.Commoditytype.applicationID = document.Id;

            if ((!document.active.IsNull) &&
                document.active.Value.ToString().Equals(Sage.Integration.Northwind.Application.API.Constants.DefaultValues.Active, StringComparison.InvariantCultureIgnoreCase))
            {
                payload.Commoditytype.active = true;
            }

            payload.Commoditytype.name = (document.name.IsNull) ? null : document.name.Value.ToString();


            return(payload);
        }
        public EmailPayload GetTransformedPayload(EmailDocument document, out List <SyncFeedEntryLink> links)
        {
            emailtype email = new emailtype();

            links = new List <SyncFeedEntryLink>();
            EmailPayload payload = new EmailPayload();

            payload.SyncUuid    = GetUuid(document.Id, document.CrmId);
            payload.LocalID     = document.Id;
            email.uuid          = payload.SyncUuid.ToString();
            email.applicationID = document.Id;
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.emails, document.Id));

            links.Add(selfLink);
            email.type    = (document.type.IsNull) ? null : document.type.Value.ToString();;
            email.address = (document.emailaddress.IsNull) ? null : document.emailaddress.Value.ToString();;

            payload.Emailtype = email;

            return(payload);
        }
        public SalesOrderPayload GetTransformedPayload(OrderDocument document, out List <SyncFeedEntryLink> links)
        {
            SalesOrderPayload payload    = new SalesOrderPayload();
            salesOrdertype    salesOrder = new salesOrdertype();

            #region initial values

            //salesOrder.active = true;
            //salesOrder.activeSpecified = true;
            //salesOrder.allocationStatus = null;
            //salesOrder.allocationStatusSpecified = false;
            //salesOrder.applicationID = null;
            //salesOrder.buyerContact = new contacttype();
            //salesOrder.carrierCompany = new operatingCompanylist();
            //salesOrder.carrierNetPrice = null;
            //salesOrder.carrierNetPriceSpecified = false;
            //salesOrder.carrierPurchaseInvoice = new purchaseInvoicelist();
            //salesOrder.carrierReference = null;
            //salesOrder.carrierSalesInvoice = new salesInvoicelist();
            //salesOrder.carrierTaxCodes = new taxCodelist();
            //salesOrder.carrierTaxPrice = null;
            //salesOrder.carrierTaxPriceSpecified = false;
            //salesOrder.carrierTotalPrice = null;
            //salesOrder.carrierTotalPriceSpecified = false;
            //salesOrder.carrierTradingAccount = new tradingAccountlist();
            //salesOrder.cases = new caselist();
            //salesOrder.chargesTotal = null;
            //salesOrder.chargesTotalSpecified = false;
            //salesOrder.contract = null;
            //salesOrder.copyFlag = false;
            //salesOrder.copyFlagSpecified = false;
            //salesOrder.costTotal = null;
            //salesOrder.costTotalSpecified = false;
            //salesOrder.

            //salesOrder.accountingType = tradingAccountAccountingTypeenum.Unknown;
            //salesOrder.customerSupplierFlag = (document.type.IsNull) ? null : document.type.Value.ToString();
            //salesOrder.active = true;
            //salesOrder.postalAddresses = new postalAddresslist();
            //salesOrder.contacts = new contactlist();
            //salesOrder.phones = new phoneNumberlist();
            //salesOrder.deleted = false;
            //salesOrder.deliveryContact = null;
            //salesOrder.deliveryMethod = null;
            //salesOrder.deliveryRule = false;
            //salesOrder.emails = new emaillist();
            //salesOrder.applicationID = document.Id;
            //salesOrder.uuid = GetUuid(document.Id, document.CrmId).ToString();
            //salesOrder.label = SupportedResourceKinds.TradingAccounts.ToString();
            //salesOrder.name = (document.name.IsNull) ? null : document.name.Value.ToString();

            //Many more things should set to default values

            #endregion

            #region salesorder lines

            int salesOrderLinesCount = document.orderitems.documents.Count;
            salesOrder.salesOrderLines = new salesOrderLinetype[salesOrderLinesCount];
            for (int index = 0; index < salesOrderLinesCount; index++)
            {
                List <SyncFeedEntryLink> dummyLinks;
                LineItemDocument         lineItem = document.orderitems.documents[index] as LineItemDocument;
                SalesOrderLinePayload    salesOrderLinePayload;
                salesOrderLinePayload             = _salesOrderLineTransformation.GetTransformedPayload(lineItem, out dummyLinks);
                salesOrder.salesOrderLines[index] = salesOrderLinePayload.SalesOrderLinetype;
            }

            #endregion

            payload.SalesOrdertype = salesOrder;
            links = new List <SyncFeedEntryLink>();
            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.salesOrders, document.Id));
            links.Add(selfLink);

            return(payload);
        }
예제 #9
0
        public TradingAccountPayload GetTransformedPayload(AccountDocument document, out List <SyncFeedEntryLink> links)
        {
            links = new List <SyncFeedEntryLink>();
            TradingAccountPayload payload        = new TradingAccountPayload();
            tradingAccounttype    tradingAccount = new tradingAccounttype();

            tradingAccount.accountingType       = tradingAccountAccountingTypeenum.Unknown;
            tradingAccount.customerSupplierFlag = (document.customerSupplierFlag.IsNull) ? null : document.customerSupplierFlag.Value.ToString();
            tradingAccount.active = true;
            //tradingAccount.postalAddresses = new postalAddresstype[0]();
            //tradingAccount.contacts = new contacttype[0]();
            //tradingAccount.phones = new phoneNumbertype[0]();
            tradingAccount.deleted         = false;
            tradingAccount.deliveryContact = null;
            tradingAccount.deliveryMethod  = null;
            tradingAccount.deliveryRule    = false;
            //tradingAccount.emails = new emailtype[0]();
            tradingAccount.applicationID = document.Id;
            payload.SyncUuid             = GetUuid(document.Id, document.CrmId);
            payload.LocalID      = document.Id;
            tradingAccount.uuid  = payload.SyncUuid.ToString();
            tradingAccount.label = SupportedResourceKinds.tradingAccounts.ToString();
            tradingAccount.name  = (document.name.IsNull) ? null : document.name.Value.ToString();


            //Many more things should set to default values


            // adresses
            int adressCount = document.addresses.documents.Count;

            tradingAccount.postalAddresses = new postalAddresstype[adressCount];
            for (int index = 0; index < adressCount; index++)
            {
                List <SyncFeedEntryLink> addressLinks;
                AddressDocument          address = document.addresses.documents[index] as AddressDocument;
                PostalAddressPayload     postalAdressPayload;
                postalAdressPayload = _postalAdressTransformation.GetTransformedPayload(address, out addressLinks);
                tradingAccount.postalAddresses[index] = postalAdressPayload.PostalAddresstype;
                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.postalAddresses.ToString(), postalAdressPayload.LocalID),
                              "postalAddresses",
                              "postalAddresses[" + index.ToString() + "]",
                              postalAdressPayload.SyncUuid.ToString()));
            }

            //emails
            int emailsCount = document.emails.documents.Count;

            tradingAccount.emails = new emailtype[emailsCount];
            for (int index = 0; index < emailsCount; index++)
            {
                List <SyncFeedEntryLink> emailLinks;
                EmailDocument            email = document.emails.documents[index] as EmailDocument;
                EmailPayload             EmailPayload;
                EmailPayload = _emailAdressTransformation.GetTransformedPayload(email, out emailLinks);
                tradingAccount.emails[index] = EmailPayload.Emailtype;

                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.emails.ToString(), EmailPayload.LocalID),
                              "emails",
                              "emails[" + index.ToString() + "]",
                              EmailPayload.SyncUuid.ToString()));
            }


            //phones
            int phonesCount = document.phones.documents.Count;

            tradingAccount.phones = new phoneNumbertype[phonesCount];
            for (int index = 0; index < phonesCount; index++)
            {
                List <SyncFeedEntryLink> phoneLinks;
                PhoneDocument            phone = document.phones.documents[index] as PhoneDocument;
                PhoneNumberPayload       phoneNumberPayload;
                phoneNumberPayload           = _phoneNumberTransformation.GetTransformedPayload(phone, out phoneLinks);
                tradingAccount.phones[index] = phoneNumberPayload.PhoneNumbertype;

                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.phoneNumbers.ToString(), phoneNumberPayload.LocalID),
                              "phones",
                              "phones[" + index.ToString() + "]",
                              phoneNumberPayload.SyncUuid.ToString()));
            }

            //contacts
            int contactsCount = document.people.documents.Count;

            tradingAccount.contacts = new contacttype[contactsCount];
            for (int index = 0; index < contactsCount; index++)
            {
                List <SyncFeedEntryLink> contactLinks;
                PersonDocument           person = document.people.documents[index] as PersonDocument;
                ContactPayload           contactPayload;
                contactPayload = _contactTransformation.GetTransformedPayload(person, out contactLinks);
                tradingAccount.contacts[index] = contactPayload.Contacttype;
                links.Add(SyncFeedEntryLink.CreateRelatedLink(
                              Common.ResourceKindHelpers.GetSingleResourceUrl(
                                  _context.DatasetLink, SupportedResourceKinds.contacts.ToString(), contactPayload.LocalID),
                              "contacts",
                              "contacts[" + index.ToString() + "]",
                              contactPayload.SyncUuid.ToString()));
            }


            payload.TradingAccount = tradingAccount;

            SyncFeedEntryLink selfLink = SyncFeedEntryLink.CreateSelfLink(String.Format("{0}{1}('{2}')", _datasetLink, SupportedResourceKinds.tradingAccounts, document.Id));

            links.Add(selfLink);
            return(payload);
        }