public ContactFeedEntryWrapper(RequestContext request)
     : base(request, SupportedResourceKinds.contacts)
 {
     this._entity = new Account();
     this._entity.DelimiterClause = @"ContactName IS NOT NULL AND ContactName LIKE '_%'"; //Is not null or empty
     _transformer = new ContactTransform(request);
 }
 public PhoneNumberFeedEntryWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.phoneNumbers)
 {
     this._entity = new Account();
     this._transform = new PhoneNumberTransform(context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
 public void GetResourceSchema(IRequest request)
 {
     RequestContext context = new RequestContext(request.Uri);
     string redirect = String.Format("{0}{1}#{2}", context.DatasetLink, Constants.schema, context.ResourceKind.ToString());
     request.Response.StatusCode = System.Net.HttpStatusCode.Found;
     request.Response.Protocol.SendUnknownResponseHeader("Location", redirect);
 }
 public CommodityFeedEntryWrapper(RequestContext context)
     : base(context, Adapter.Common.SupportedResourceKinds.commodities)
 {
     _entity = new Product();
     _entity.DelimiterClause = @"Discontinued = false";
     _transform = new CommodityTransform(context);
 }
 public PriceFeedEntryWrapper(RequestContext context)
     : base(context, Adapter.Common.SupportedResourceKinds.prices)
 {
     _entity = new Price();
     _transform = new PriceTransform(context);
     _commodityFeedEntryWrapper = FeedEntryWrapperFactory.Create(SupportedResourceKinds.commodities, context);
 }
 public void GetDigest(IRequest request)
 {
     RequestContext context = new RequestContext(request.Uri);
     GetSyncDigestRequestPerformer performer = new GetSyncDigestRequestPerformer();
     performer.Initialize(context);
     performer.DoWork(request);
 }
Esempio n. 7
0
 public EntityWrapperBase(RequestContext context, SupportedResourceKinds resourceKind)
 {
     _context = context;
     _resourceKind = resourceKind;
     _emptyToken = new Token();
     _correlatedResSyncInfoStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetCorrelatedResSyncStore(_context.SdataContext);
 }
 public EmailWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.emails)
 {
     _entity = new Email();
     _transformation = TransformationFactory.GetTransformation
         <ITransformation<EmailDocument, EmailPayload>>
         (SupportedResourceKinds.emails, context);
 }
 public PostalAddressWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.postalAddresses)
 {
     _entity = new Account();
     _transformation = TransformationFactory.GetTransformation<ITransformation<AddressDocument, PostalAddressPayload>>
         (SupportedResourceKinds.postalAddresses, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
Esempio n. 10
0
 public PriceWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.prices)
 {
     _entity = new Price();
     _transformation = TransformationFactory.GetTransformation
         <ITransformation<PriceDocument, PricePayload>>
         (SupportedResourceKinds.prices, context);
 }
 public CommodityGroupWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.commodityGroups)
 {
     _entity = new ProductFamily();
     _transformation = TransformationFactory.GetTransformation
         <ITransformation<ProductFamilyDocument, CommodityGroupPayload>>
         (SupportedResourceKinds.commodityGroups, context);
 }
Esempio n. 12
0
 public PhoneNumberWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.phoneNumbers)
 {
     _entity = new Account();
     _transformation = TransformationFactory.GetTransformation<ITransformation<PhoneDocument, PhoneNumberPayload>>
         (SupportedResourceKinds.phoneNumbers, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
 public SalesOrderFeedEntryWrapper(RequestContext context)
     : base(context, Adapter.Common.SupportedResourceKinds.salesOrders)
 {
     _entity = new Order();
     _tradingAccountsFeedEntryWrapper = FeedEntryWrapperFactory.Create(SupportedResourceKinds.tradingAccounts, context);
     _commoditiesFeedEntryWrapper = FeedEntryWrapperFactory.Create(SupportedResourceKinds.commodities, context);
     _unitsOfMeasureFeedEntryWrapper = FeedEntryWrapperFactory.Create(SupportedResourceKinds.unitsOfMeasure, context);
 }
Esempio n. 14
0
 public UnitOfMeasureWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.unitsOfMeasure)
 {
     _entity = new UnitOfMeasure();
     _transformation = TransformationFactory.GetTransformation
         <ITransformation<UnitOfMeasureDocument, UnitOfMeasurePayload>>
         (SupportedResourceKinds.unitsOfMeasure, context);
 }
Esempio n. 15
0
 public ContactWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.contacts)
 {
     _entity = new Account();
     _transformation = TransformationFactory.GetTransformation<ITransformation<PersonDocument, ContactPayload>>
         (SupportedResourceKinds.contacts, context);
     _tradingAccountUuidPayloadPath = _resourceKind.ToString() + "/" + SupportedResourceKinds.tradingAccounts.ToString();
 }
 public static string BuildBaseUrl(RequestContext requestContext, RequestKeywordType keyword)
 {
     string resourceKindName = requestContext.ResourceKind.ToString();
     string keywordAsString = GetKeywordAsString(keyword);
     if (null == keywordAsString)
         return string.Format("{0}{1}", requestContext.DatasetLink, resourceKindName);
     else
         return string.Format("{0}{1}/{2}", requestContext.DatasetLink, resourceKindName, keywordAsString);
 }
        public static IFeedEntryEntityWrapper Create(SupportedResourceKinds resourceKind,
           RequestContext context)
        {
            IFeedEntryEntityWrapper result;
            switch (resourceKind)
            {
                case SupportedResourceKinds.contacts:
                    result = new ContactFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.tradingAccounts:
                    result = new TradingAccountsFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.postalAddresses:
                    result = new PostalAddressFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.salesOrders:
                    result = new SalesOrderFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.phoneNumbers:
                    result = new PhoneNumberFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.emails:
                    result = new EmailFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.commodityGroups:
                    result = new CommodityGroupFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.commodities:
                    result = new CommodityFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.unitsOfMeasure:
                    result = new UnitOfMeasureFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.priceLists:
                    result = new PriceListFeedEntryWrapper(context);
                    return result;

                case SupportedResourceKinds.prices:
                    return new PriceFeedEntryWrapper(context);

               // case SupportedResourceKinds.salesInvoices:
                 //   return new SalesInvoiceFeedEntryWrapper(context);

                default:
                    throw new InvalidOperationException("Resource Kind not supported.");
            }
        }
Esempio n. 18
0
        public TransformationBase(RequestContext context, SupportedResourceKinds resourceKind)
        {
            _context = context;
            _datasetLink = _context.DatasetLink;
            _config = _context.Config;
            _resourceKind = resourceKind;

            _resourceKindString = _resourceKind.ToString();
            _originApplication = _datasetLink + _resourceKindString;

            _correlatedResSyncInfoStore = NorthwindAdapter.StoreLocator.GetCorrelatedResSyncStore(_context.SdataContext);
        }
Esempio n. 19
0
        public void DeleteRequest(IRequest request)
        {
            string requestGuid = Guid.NewGuid().ToString();
            try
            {
                LogRequest(request, requestGuid);
                RequestPerformerLocator requestPerformerLocator = RequestReceiver.NorthwindAdapter.RequestPerformerLocator; ;
                IRequestPerformer requestPerformer = null;
                RequestContext context = new RequestContext(request.Uri);
                switch (context.RequestType)
                {
                    case RequestType.Resource:
                        requestPerformer = requestPerformerLocator.Resolve<DeleteResourceRequestPerformer>(context);
                        if (null != requestPerformer)
                            requestPerformer.DoWork(request);
                        else
                            throw new RequestException("The request is not supported.");
                        break;
                    case RequestType.SyncSource:
                    case RequestType.SyncTarget:
                        requestPerformerLocator = RequestReceiver.NorthwindAdapter.RequestPerformerLocator;
                        Exception error;
                        if (requestPerformerLocator.Delete(context, out error))
                            request.Response.StatusCode = System.Net.HttpStatusCode.OK;
                        else
                        {
                            if (error == null)
                                request.Response.StatusCode = System.Net.HttpStatusCode.NotFound;
                            else
                                throw error;
                        }
                        break;
                    case RequestType.Linked:
                        requestPerformer = requestPerformerLocator.Resolve<DeleteLinkingRequestPerformer>(context);
                        if (null == requestPerformer)
                            throw new RequestException("The request is not supported.");

                        requestPerformer.DoWork(request);

                        break;
                    default:
                        throw new NotSupportedException("This Request was not supported");

                }
                LogResponse(request, requestGuid);
            }
            catch (Exception e)
            {

                LogException(e, requestGuid);
                throw;
            }
        }
        public static FeedLinkCollection CreatePageFeedLinks(RequestContext requestContext, int totalResults, RequestKeywordType keyword)
        {
            FeedLinkCollection feedLinks = new FeedLinkCollection();
            PageController builder = GetPageLinkBuilder(requestContext, totalResults, keyword);

            feedLinks.Add(new FeedLink(builder.GetLinkSelf(), LinkType.Self, MediaType.Atom, "Current Page"));
            feedLinks.Add(new FeedLink(builder.GetLinkFirst(), LinkType.First, MediaType.Atom, "First Page"));
            feedLinks.Add(new FeedLink(builder.GetLinkLast(), LinkType.Last, MediaType.Atom, "Last Page"));

            string linkUrl;
            if (builder.GetLinkNext(out linkUrl))
                feedLinks.Add(new FeedLink(linkUrl, LinkType.Next, MediaType.Atom, "Next Page"));
            if (builder.GetLinkPrevious(out linkUrl))
                feedLinks.Add(new FeedLink(linkUrl, LinkType.Previous, MediaType.Atom, "Previous Page"));

            return feedLinks;
        }
Esempio n. 21
0
        public void BuildSqlStatement(RequestContext requestContext, out string additionalClause, out OleDbParameter[] oleDbParameters)
        {
            oleDbParameters = null;
            additionalClause = string.Empty;
            List<OleDbParameter> oleDbParameterList = new List<OleDbParameter>();

            if (requestContext.SdataUri.WhereExpression != null)
            {
                string expression = _expressionParser.GetExpressionDispatch(requestContext.SdataUri.WhereExpression, ref oleDbParameterList);
                if (!string.IsNullOrEmpty(expression))
                {
                    additionalClause = string.Format("where ( {0} )", expression);
                    oleDbParameters = oleDbParameterList.ToArray();
                }
            }
            if (!String.IsNullOrEmpty(requestContext.SdataUri.OrderBy))
            {
                additionalClause += " " + _orderByParser.Get(requestContext.SdataUri.OrderBy);
            }
        }
        public static PageController GetPageLinkBuilder(RequestContext requestContext, int totalResults, RequestKeywordType keyword)
        {
            string url = BuildBaseUrl(requestContext, keyword);

            int count;// = (int)requestContext.SdataUri.Count;
            int startIndex;// = (int)requestContext.SdataUri.StartIndex;
            #warning THIS IS A WORKAROUND UNTIL SIF IS 1 BASED!
            string strStartIndex;
            if (!requestContext.SdataUri.QueryArgs.TryGetValue("startIndex", out strStartIndex))
                startIndex = 1;
            else
                startIndex = Convert.ToInt32(strStartIndex);
            //if (startIndex == 0) { startIndex = 1; }
            #warning THIS IS A WORKAROUND UNTIL SIF SUPPORTS COUNT=0 AND COUNT NOT SET
            string strCount;
            if (!requestContext.SdataUri.QueryArgs.TryGetValue("count", out strCount))
                count = -1;
            else
                count = Convert.ToInt32(strCount);
            return new PageController(startIndex, DEFAULT_ITEMS_PER_PAGE, totalResults, count, url);
        }
        public void GetSchema(IRequest request)
        {
            Assembly assembly = GetSchemaAssembly();
            RequestContext context = new RequestContext(request.Uri);
            XmlSchema xmlschema = null;
            using (StreamReader sr = new StreamReader(assembly.GetManifestResourceStream("Sage.Integration.Northwind.Adapter.crmErp"+VER+".xsd")))
            {
                xmlschema = XmlSchema.Read(sr, null);
            }

            // replace common import url
            foreach (XmlSchemaImport schemaInportObj in xmlschema.Includes)
            {
                if (schemaInportObj.Namespace == "http://schemas.sage.com/sc/2009")
                {
                    schemaInportObj.SchemaLocation = string.Format("{0}{1}/import/common"+VER, context.DatasetLink, Constants.schema);
                    break;
                }
            }

            request.Response.ContentType = Sage.Common.Syndication.MediaType.Xml;
            request.Response.Xml = GetXml(xmlschema);
        }
 public void Initialize(RequestContext requestContext)
 {
     _requestContext = requestContext;
 }
 void IRequestPerformer.Initialize(RequestContext requestContext)
 {
     _requestContext = requestContext;
 }
 public PostalAddressFeedEntryWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.postalAddresses)
 {
     this._entity = new Account();
     this._transform = new PostalAdressTransform(context);
 }
 public SalesOrderLineWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.salesOrderLines)
 {
     _entity = new Order();
 }
 public static int GetPageNumber(RequestContext requestContext)
 {
     return ((int)(requestContext.SdataUri.StartIndex / FeedMetadataHelpers.DEFAULT_ITEMS_PER_PAGE)) + 1;
 }
 public void PostSyncTarget(IRequest request, Feed<UnitOfMeasureFeedEntry> feed)
 {
     RequestContext context = new RequestContext(request.Uri);
     PostSyncTargetRequestPerformer performer = NorthwindAdapter.RequestPerformerLocator.Resolve<PostSyncTargetRequestPerformer>(context);
     performer.DoWork(request, feed, feed.Digest);
 }
 public void GetSyncTarget(IRequest request)
 {
     RequestContext context = new RequestContext(request.Uri);
     GetSyncTargetRequestPerformer performer = NorthwindAdapter.RequestPerformerLocator.Resolve<GetSyncTargetRequestPerformer>(context);
     performer.DoWork(request);
 }