public void BasicProcessing() { try { IOrganizationService service = this.GetCRMService("https://farahtrial.crm4.dynamics.com", "*****@*****.**", "India@123"); this.CheckConnectivity(service); Guid nonProductCustomer = new Guid("C01AE383-543F-E511-A93E-6C3BE5A8D044"); //Guid productCustomer = new Guid("FEE6C9C7-6878-4666-A67A-C4DE175B6B10"); Guid productCustomer = new Guid("F8DE8DD0-F738-48D3-81B8-C310AB8509F2"); Guid sndPepsiDirect = new Guid("9A81A8A6-2AAC-E611-810D-3863BB2EB148"); Guid sndOthers = new Guid("66E6849A-CE28-E611-80FA-3863BB2E83E8"); MSCRMHelper crmHelper = new MSCRMHelper(); //crmHelper.Convert(service); Entity nonProductCustomerRecord = crmHelper.RetrieveCustomerData(nonProductCustomer, service); Entity productCustomerRecord = crmHelper.RetrieveCustomerData(productCustomer, service); Entity sndOtherRecord = crmHelper.RetrieveSND(sndOthers, service); Entity sndPepsiDirectRecord = crmHelper.RetrieveSND(sndPepsiDirect, service); Entity reRouteRecord = new Entity(); Entity routeRecord = new Entity(); if (sndPepsiDirectRecord.Contains(Constant.SNDMethod.RouteNumber)) { reRouteRecord = crmHelper.RetrieveReroute(((EntityReference)sndPepsiDirectRecord[Constant.SNDMethod.RouteNumber]).Id, productCustomerRecord.Id, service); } BasicValidations baseValidation = new BasicValidations(); string validationMessage1 = baseValidation.RunBasicValidations(nonProductCustomerRecord, new Entity(), service); Console.WriteLine("Non Product Validation Message: " + validationMessage1); string validationMessage2 = baseValidation.RunBasicValidations(productCustomerRecord, sndOtherRecord, service); Console.WriteLine("InCorrect SND Mehtod Validation: " + validationMessage2); string validationMessage3 = baseValidation.RunBasicValidations(productCustomerRecord, sndPepsiDirectRecord, service); Console.WriteLine("All Correct: " + validationMessage3); LockedOrderValidation validateLock = new LockedOrderValidation(); Guid existingOrderId = validateLock.RunLockedOrderValidations(productCustomer, true, service); if (existingOrderId == Guid.Empty) { CopyOrderShell orderShell = new CopyOrderShell(); orderShell.ManageOrderShellCopy(productCustomerRecord, sndPepsiDirectRecord, reRouteRecord.ToEntityReference(), DateTime.Now, string.Empty, service); } } catch (Exception ex) { throw ex; } }
private EntityCollection RetrieveOrderShellLineItems(Guid orderShellHeaderId, string customerLocation, IOrganizationService service) { try { EntityCollection orderShellItemCollection = new EntityCollection(); QueryExpression orderShellItemQuery = new QueryExpression(); orderShellItemQuery.EntityName = Constant.OrderShellLineItem.EntityName; orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.ProductId); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry1); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry2); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry3); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry4); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry5); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.DeliveryHistry6); //orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.BrandSetProductFlag); //orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.NotFound_Package); //orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.ReturnCode); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.BrandSetSubTypeCode); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.LastDeliveryDate); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.BOCode); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.BOQuantity); orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.BrandSetProductFlag); //orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.NotCreated_CampaignId); //orderShellItemQuery.ColumnSet.AddColumn(Constant.OrderShellLineItem.NotCreated_CampConId); ConditionExpression shellHeaderIdCondition = new ConditionExpression(); shellHeaderIdCondition.AttributeName = Constant.OrderShellLineItem.HeaderId; shellHeaderIdCondition.Operator = ConditionOperator.Equal; shellHeaderIdCondition.Values.Add(orderShellHeaderId); ConditionExpression nonVisibilityCondition = new ConditionExpression(); nonVisibilityCondition.AttributeName = Constant.OrderShellLineItem.NonVisbleLineItems; nonVisibilityCondition.Operator = ConditionOperator.NotEqual; nonVisibilityCondition.Values.Add(true); FilterExpression orderShellFilter = new FilterExpression(); orderShellFilter.AddCondition(shellHeaderIdCondition); orderShellFilter.AddCondition(nonVisibilityCondition); orderShellFilter.FilterOperator = LogicalOperator.And; LinkEntity locationProductLink = new LinkEntity(); locationProductLink.LinkFromAttributeName = Constant.OrderShellLineItem.ProductLocationId; locationProductLink.LinkToAttributeName = Constant.LocationProduct.Id; locationProductLink.LinkFromEntityName = Constant.OrderShellLineItem.EntityName; locationProductLink.LinkToEntityName = Constant.LocationProduct.EntityName; locationProductLink.JoinOperator = JoinOperator.LeftOuter; locationProductLink.EntityAlias = "LP"; locationProductLink.Columns.AddColumn(Constant.LocationProduct.LocationItemInvFlag); locationProductLink.Columns.AddColumn(Constant.LocationProduct.PDUnavailable); locationProductLink.Columns.AddColumn(Constant.LocationProduct.ProductId); LinkEntity productLink = new LinkEntity(); productLink.LinkFromEntityName = Constant.LocationProduct.EntityName; productLink.LinkToEntityName = Constant.Product.EntityName; productLink.LinkToAttributeName = Constant.Product.Id; productLink.LinkFromAttributeName = Constant.LocationProduct.ProductId; productLink.JoinOperator = JoinOperator.LeftOuter; productLink.EntityAlias = "P"; productLink.Columns.AddColumn(Constant.Product.Pacakge); productLink.Columns.AddColumn(Constant.Product.ProductMixCode); productLink.Columns.AddColumn(Constant.Product.EmptyCo2Flag); locationProductLink.LinkEntities.Add(productLink); orderShellItemQuery.LinkEntities.Add(locationProductLink); orderShellItemQuery.Criteria = orderShellFilter; MSCRMHelper crmHelper = new MSCRMHelper(); QueryExpression convertedQuery = crmHelper.Convert(service); orderShellItemCollection = service.RetrieveMultiple(orderShellItemQuery); return(orderShellItemCollection); } catch (Exception ex) { throw ex; } }