コード例 #1
0
ファイル: SapController.cs プロジェクト: yuyunyan/externalAPI
        [Route("api/sap/test")]  //sap/update
        public string SapUpdate(Trigger request)
        {
            //depricated
            string host = HttpContext.Current.Request.Url.Host;

            SapXmlExtractor.LogTrigger(request, request.TriggerObject, host);
            return(_sapService.ProcessTrigger(request));
        }
コード例 #2
0
        public AccountHierarchyResponse RemoveAccountFromGroup(string accountId)
        {
            AccountHierarchyResponse response = new AccountHierarchyResponse();

            var groupsAssigned = IsAccountAssignedToHierarchy(accountId);
            var childGroup     = new AccountHierarchyChildResponse();

            foreach (var child in groupsAssigned.Children)
            {
                if (child.AssignedToAccount)
                {
                    childGroup = child;
                }
            }

            var request = new BusinessPartnerHierarchyMaintainRequestMessage_sync();

            //groups
            var groups = new BusinessPartnerHierarchyMaintainRequestGroup[1];

            groups[0]      = new BusinessPartnerHierarchyMaintainRequestGroup();
            groups[0].ID   = childGroup.ChildId;
            groups[0].Name = childGroup.ChildName;
            //groups[0].ParentGroupID = groupsAssigned.ParentGroupId;
            var assignAccount = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner();

            assignAccount.InternalID = accountId;
            var bp = new BusinessPartnerHierarchyMaintainRequestGroup();

            groups[0].BusinessPartner                        = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner[1];
            groups[0].BusinessPartner[0]                     = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner();
            groups[0].BusinessPartner[0]                     = assignAccount;
            groups[0].BusinessPartner[0].actionCode          = ActionCode.Item03;
            groups[0].BusinessPartner[0].actionCodeSpecified = true;

            //new hierarchy id
            BusinessPartnerHierarchyMaintainRequest hierarchy = new BusinessPartnerHierarchyMaintainRequest();

            AccountHierarchyManageService.BusinessPartnerHierarchyID parentId = new AccountHierarchyManageService.BusinessPartnerHierarchyID();
            parentId.Value = groupsAssigned.ParentId;

            //set hierarchy id, name, and groups;
            hierarchy.ID    = parentId;
            hierarchy.Name  = groupsAssigned.ParentName;
            hierarchy.Group = groups;
            request.BusinessPartnerHierarchy    = new BusinessPartnerHierarchyMaintainRequest[1];
            request.BusinessPartnerHierarchy[0] = new BusinessPartnerHierarchyMaintainRequest();
            request.BusinessPartnerHierarchy[0] = hierarchy;

            var xml = SapXmlExtractor.GetXmlString(request);

            BusinessPartnerHierarchyMaintainConfirmationMessage_sync sapResponse = _manageClient.MaintainBundle(request);

            response = SetAccountHierarchyManageResponse(sapResponse);
            //var newResponse = GetAccountHierarchyById(response.ParentId);

            return(response);
        }
コード例 #3
0
        public void SapUpdateQcInspection(Trigger request)
        {
            string host = HttpContext.Current.Request.Url.Host;

            SapXmlExtractor.LogTrigger(request, ObjectTypeEnums.QcInspection.ToString(), host);
            var qc          = _qcInspectionService.QueryQcInspection(request.ID);
            var syncRequest = _qcSync.Create(qc);

            _middlewareService.Sync(syncRequest);
        }
コード例 #4
0
        public void SapUpdateBusinessPartner(Trigger request)
        {
            string host = HttpContext.Current.Request.Url.Host;

            SapXmlExtractor.LogTrigger(request, ObjectTypeEnums.BusinessPartner.ToString(), host);
            var businessPartner = _businessPartnerService.GetBusinessPartnerForIncoming(request.ID);
            var syncRequest     = _businessPartnerSyncRequestCreator.Create(businessPartner);

            _middlewareService.Sync(syncRequest);
        }
コード例 #5
0
        public void SapUpdateAccountHierarchy(Trigger request)
        {
            string host = HttpContext.Current.Request.Url.Host;

            SapXmlExtractor.LogTrigger(request, ObjectTypeEnums.AccountHierarchy.ToString(), host);
        }
コード例 #6
0
        public AccountHierarchyResponse SetAccountToGroup(AccountHierarchyRequest accountHierarchy, string accountId)
        {
            AccountHierarchyResponse response = new AccountHierarchyResponse();

            var groupsAssigned = IsAccountAssignedToHierarchy(accountId);

            if (!string.IsNullOrEmpty(groupsAssigned.ParentId))
            {
                var removeResponse = RemoveAccountFromGroup(accountId);
                if (removeResponse.Errors.Count > 0)
                {
                    return(removeResponse);
                }
            }

            var request = new BusinessPartnerHierarchyMaintainRequestMessage_sync();

            //groups
            var groups = new BusinessPartnerHierarchyMaintainRequestGroup[1];

            groups[0]               = new BusinessPartnerHierarchyMaintainRequestGroup();
            groups[0].ID            = accountHierarchy.childGroupId;
            groups[0].ParentGroupID = accountHierarchy.ParentGroupId;
            var assignAccount = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner();

            assignAccount.InternalID = accountId;
            var bp = new BusinessPartnerHierarchyMaintainRequestGroup();

            groups[0].BusinessPartner                        = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner[1];
            groups[0].BusinessPartner[0]                     = new BusinessPartnerHierarchyMaintainRequestGroupBusinessPartner();
            groups[0].BusinessPartner[0]                     = assignAccount;
            groups[0].BusinessPartner[0].actionCode          = ActionCode.Item01;
            groups[0].BusinessPartner[0].actionCodeSpecified = true;


            //new hierarchy id
            BusinessPartnerHierarchyMaintainRequest hierarchy = new BusinessPartnerHierarchyMaintainRequest();

            AccountHierarchyManageService.BusinessPartnerHierarchyID parentId = new AccountHierarchyManageService.BusinessPartnerHierarchyID();
            parentId.Value = accountHierarchy.ParentId;

            //set hierarchy id, name, and groups;
            hierarchy.ID    = parentId;
            hierarchy.Name  = accountHierarchy.ParentName;
            hierarchy.Group = groups;
            request.BusinessPartnerHierarchy    = new BusinessPartnerHierarchyMaintainRequest[1];
            request.BusinessPartnerHierarchy[0] = new BusinessPartnerHierarchyMaintainRequest();
            request.BusinessPartnerHierarchy[0] = hierarchy;

            string requestXml = SapXmlExtractor.GetXmlString(request);
            BusinessPartnerHierarchyMaintainConfirmationMessage_sync sapResponseCheck = new BusinessPartnerHierarchyMaintainConfirmationMessage_sync();

            try
            {
                sapResponseCheck = _manageClient.CheckMaintainBundle(request);
            }
            catch (Exception ex)
            {
            }

            if (sapResponseCheck.Log != null)
            {
                if (sapResponseCheck.Log.MaximumLogItemSeverityCode.Equals("3"))
                {
                    return(SetAccountHierarchyManageResponse(sapResponseCheck));
                }
            }

            BusinessPartnerHierarchyMaintainConfirmationMessage_sync sapResponse = _manageClient.MaintainBundle(request);

            response = SetAccountHierarchyManageResponse(sapResponse);
            var newResponse = GetAccountHierarchyById(response.ParentId, accountId);

            return(newResponse);
        }
コード例 #7
0
        public void SapUpdatePurchaseOrder(Trigger request)
        {
            string host = HttpContext.Current.Request.Url.Host;

            SapXmlExtractor.LogTrigger(request, ObjectTypeEnums.PurchaseOrder.ToString(), host);
        }
コード例 #8
0
        public MaterialResponse SetMaterial(MaterialRequest material)
        {
            var checkExisting = QueryMaterial(material.PartNumber);

            if (!string.IsNullOrEmpty(checkExisting.ExternalId))
            {
                return(checkExisting);
            }

            var request = new MaterialMaintainRequestBundleMessage_sync_V1();

            request.Material = new MaterialMaintainRequestBundleMaterial_sync_V1[1];
            var sapMaterial = new MaterialMaintainRequestBundleMaterial_sync_V1();

            sapMaterial.descriptionListCompleteTransmissionIndicator          = true;
            sapMaterial.descriptionListCompleteTransmissionIndicatorSpecified = true;
            sapMaterial.detailListCompleteTransmissionIndicator          = true;
            sapMaterial.detailListCompleteTransmissionIndicatorSpecified = true;

            sapMaterial.ProductCategoryID   = material.CommodityExternalID;
            sapMaterial.BaseMeasureUnitCode = "EA";

            sapMaterial.IdentifiedStockTypeCode       = new MaterialManageService.IdentifiedStockTypeCode();
            sapMaterial.IdentifiedStockTypeCode.Value = "04";

            sapMaterial.Description                = new MaterialMaintainRequestBundleDescription[1];
            sapMaterial.Description[0]             = new MaterialMaintainRequestBundleDescription();
            sapMaterial.Description[0].Description = new MaterialManageService.SHORT_Description();
            var truncatedString = material.PartNumber + " {" + material.Mfg;

            truncatedString = truncatedString.Substring(0, (truncatedString.Length > 39 ? 39 : truncatedString.Length));
            sapMaterial.Description[0].Description.Value = truncatedString + "}";

            if (!string.IsNullOrEmpty(material.Description))
            {
                sapMaterial.Detail                      = new MaterialBundleMaintainRequestText[1];
                sapMaterial.Detail[0]                   = new MaterialBundleMaintainRequestText();
                sapMaterial.Detail[0].ContentText       = new MaterialManageService.Text();
                sapMaterial.Detail[0].ContentText.Value = material.Description;
            }

            sapMaterial.Purchasing = new MaterialMaintainRequestBundlePurchasing();
            sapMaterial.Purchasing.LifeCycleStatusCodeSpecified = true;
            sapMaterial.Purchasing.LifeCycleStatusCode          = MaterialManageService.ProductProcessUsabilityLifeCycleStatusCode.Item2;
            sapMaterial.Purchasing.PurchasingMeasureUnitCode    = "EA";

            _sapOrgs             = _sapService.SetOrgsFromDb();
            sapMaterial.Planning = SetPlanningData(_sapOrgs.Planning);
            sapMaterial.AvailabilityConfirmation = SetAvailabilityData(_sapOrgs.Availability);
            sapMaterial.Sales     = SetSalesData(_sapOrgs.Sales);
            sapMaterial.Logistics = SetLogisticsData(_sapOrgs.Logistics);

            sapMaterial.MFGPartNumber      = material.PartNumber;
            sapMaterial.Manufacturer       = material.Mfg;
            sapMaterial.ECCN               = material.ECCN;
            sapMaterial.StrippedPartNumber = material.PartNumberStrip;
            sapMaterial.DatasheetURL       = material.DatasheetURL;
            sapMaterial.IHSID              = material.SourceDataID.ToString();
            sapMaterial.MSL             = material.MSL;
            sapMaterial.EURoHSSpecified = true;
            sapMaterial.EURoHS          = material.EURoHS;
            sapMaterial.HTSCode         = material.HTS;

            if (!string.IsNullOrEmpty(material.ExternalId))
            {
                sapMaterial.InternalID       = new MaterialManageService.ProductInternalID();
                sapMaterial.InternalID.Value = material.ExternalId;
            }

            request.Material[0] = sapMaterial;
            var xmlParser   = SapXmlExtractor.GetXmlString(request);
            var setResponse = ParseManageResponse(_manageClient.MaintainBundle_V1(request));

            if (string.IsNullOrEmpty(setResponse.ExternalId))
            {
                return(setResponse);
            }

            return(SetMaterialValuationData(setResponse.ExternalId));
        }