/// <summary> /// Processes the specified commerce context. /// </summary> /// <param name="commerceContext">The commerce context.</param> /// <returns>User site terms</returns> public virtual async Task <IEnumerable <Customer> > Process(CommerceContext commerceContext) { using (CommandActivity.Start(commerceContext, this)) { var sqlContext = ConnectionHelper.GetProfilesSqlContext(commerceContext); var rows = await sqlContext.GetAllProfiles().ConfigureAwait(false); var migratedCustomers = new List <Customer>(); foreach (DataRow row in rows) { try { var cloneContext = this.CloneCommerceContext(commerceContext); var csCustomer = await _migrateCustomerPipeline.Run(row, cloneContext).ConfigureAwait(false); MergeMessages(commerceContext, cloneContext.CommerceContext); if (csCustomer != null) { migratedCustomers.Add(csCustomer); } } catch (Exception ex) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "EntityNotFound", new object[] { row["u_user_id"] as string, ex }, $"Customer {row["u_user_id"] as string} was not migrated.").ConfigureAwait(false); } } return(migratedCustomers); } }
public async Task <bool> EndItemListing(CommerceContext commerceContext, SellableItem sellableItem, string reason) { using (var activity = CommandActivity.Start(commerceContext, this)) { //Instantiate the call wrapper class try { var apiCall = new EndItemCall(await GetEbayContext(commerceContext)); if (sellableItem.HasComponent <EbayItemComponent>()) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); var reasonCodeType = EndReasonCodeType.NotAvailable; switch (reason) { case "NotAvailable": reasonCodeType = EndReasonCodeType.NotAvailable; break; case "CustomCode": reasonCodeType = EndReasonCodeType.CustomCode; break; case "Incorrect": reasonCodeType = EndReasonCodeType.Incorrect; break; case "LostOrBroken": reasonCodeType = EndReasonCodeType.LostOrBroken; break; case "OtherListingError": reasonCodeType = EndReasonCodeType.OtherListingError; break; case "SellToHighBidder": reasonCodeType = EndReasonCodeType.SellToHighBidder; break; case "Sold": reasonCodeType = EndReasonCodeType.Sold; break; default: reasonCodeType = EndReasonCodeType.CustomCode; break; } if (string.IsNullOrEmpty(ebayItemComponent.EbayId)) { ebayItemComponent.Status = "LostSync"; } else { if (ebayItemComponent.Status != "Ended") { //Call Ebay and End the Item Listing try { apiCall.EndItem(ebayItemComponent.EbayId, reasonCodeType); ebayItemComponent.Status = "Ended"; } catch (Exception ex) { if (ex.Message == "The auction has already been closed.") { //Capture a case where the listing has expired naturally and it can now no longer be ended. reason = "Expired"; ebayItemComponent.Status = "Ended"; } else { commerceContext.Logger.LogError(ex, $"EbayCommand.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "EbayCommand.EndItemListing", new [] { ex }, ex.Message).ConfigureAwait(false); } } } } ebayItemComponent.ReasonEnded = reason; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Ended", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Ended"); var persistResult = await this._commerceCommander.PersistEntity(commerceContext, sellableItem).ConfigureAwait(false); var listRemoveResult = await this._commerceCommander.Command <ListCommander>() .RemoveItemsFromList(commerceContext, "Ebay_Listed", new List <String>() { sellableItem.Id }).ConfigureAwait(false); } } catch (Exception ex) { commerceContext.Logger.LogError($"Ebay.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.EndItemListing.Exception", new Object[] { ex }, ex.Message).ConfigureAwait(false); } return(true); } }
public async Task <ItemType> PrepareItem(CommerceContext commerceContext, SellableItem sellableItem) { using (var activity = CommandActivity.Start(commerceContext, this)) { //Instantiate the call wrapper class var apiCall = new AddFixedPriceItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false)); var item = await this._commerceCommander.Pipeline <IPrepareEbayItemPipeline>().Run(sellableItem, commerceContext.PipelineContextOptions).ConfigureAwait(false); item.Description = sellableItem.Description; item.Title = sellableItem.DisplayName; item.SubTitle = "Test Item"; var listPricingPolicy = sellableItem.GetPolicy <ListPricingPolicy>(); var listPrice = listPricingPolicy.Prices.FirstOrDefault(); item.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = System.Convert.ToDouble(listPrice.Amount, System.Globalization.CultureInfo.InvariantCulture) }; item.ConditionID = 1000; //new item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection(); item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal); item.PaymentMethods.Add(BuyerPaymentMethodCodeType.VisaMC); item.PayPalEmailAddress = "*****@*****.**"; item.PostalCode = "98014"; item.DispatchTimeMax = 3; item.ShippingDetails = new ShippingDetailsType(); item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection(); item.ShippingDetails.ShippingType = ShippingTypeCodeType.Flat; ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType(); shipservice1.ShippingService = "USPSPriority"; shipservice1.ShippingServicePriority = 1; shipservice1.ShippingServiceCost = new AmountType(); shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.USD; shipservice1.ShippingServiceCost.Value = 5.0; shipservice1.ShippingServiceAdditionalCost = new AmountType(); shipservice1.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.USD; shipservice1.ShippingServiceAdditionalCost.Value = 1.0; item.ShippingDetails.ShippingServiceOptions.Add(shipservice1); //ShippingServiceOptionsType shipservice2 = new ShippingServiceOptionsType(); //shipservice2.ShippingService = "US_Regular"; //shipservice2.ShippingServicePriority = 2; //shipservice2.ShippingServiceCost = new AmountType(); //shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.USD; //shipservice2.ShippingServiceCost.Value = 1.0; //shipservice2.ShippingServiceAdditionalCost = new AmountType(); //shipservice2.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.USD; //shipservice2.ShippingServiceAdditionalCost.Value = 1.0; //item.ShippingDetails.ShippingServiceOptions.Add(shipservice2); //item.Variations. item.ReturnPolicy = new ReturnPolicyType { ReturnsAcceptedOption = "ReturnsAccepted" }; //Add pictures item.PictureDetails = new PictureDetailsType(); //Specify GalleryType item.PictureDetails.GalleryType = GalleryTypeCodeType.None; item.PictureDetails.GalleryTypeSpecified = true; return(item); } }
public EntityView Process(CommerceContext commerceContext, EntityView entityView) { using (CommandActivity.Start(commerceContext, this)) { var pluginPolicy = commerceContext.GetPolicy <PluginPolicy>(); try { var masterListEntityView = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = "topologies View", Name = "TopologiesView", UiHint = "List", Icon = pluginPolicy.Icon }; entityView.ChildViews.Add(masterListEntityView); var childView = new EntityView { EntityId = string.Empty, ItemId = "Topology01", DisplayName = "Topology01", Name = "Topology01", Icon = pluginPolicy.Icon }; childView.Properties.Add(new ViewProperty { Name = "Name", RawValue = "Topology01" }); childView.Properties.Add(new ViewProperty { Name = "Type", RawValue = "OneBox" }); childView.Properties.Add(new ViewProperty { Name = "Description", RawValue = "OneBox Topology" }); masterListEntityView.ChildViews.Add(childView); var childView2 = new EntityView { EntityId = string.Empty, ItemId = "Topology02", DisplayName = "Topology02", Name = "Topology02", Icon = pluginPolicy.Icon }; childView2.Properties.Add(new ViewProperty { Name = "Name", RawValue = "Topology02" }); childView2.Properties.Add(new ViewProperty { Name = "Type", RawValue = "SimpleHa" }); childView2.Properties.Add(new ViewProperty { Name = "Description", RawValue = "Simple HA configuration" }); masterListEntityView.ChildViews.Add(childView2); } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(entityView); } }
public async Task <EntityView> Process(CommerceContext commerceContext, EntityView entityView) { using (CommandActivity.Start(commerceContext, this)) { try { var activeCartsView = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = "Active Carts List View", Name = "CustomDevOps-ListView-ActiveCarts", UiHint = "Table", Icon = commerceContext.GetPolicy <CartUiPolicy>().Icon }; entityView.ChildViews.Add(activeCartsView); CommerceList <Cart> carts = await _commerceCommander.Command <FindEntitiesInListCommand>().Process <Cart>(commerceContext, CommerceEntity.ListName <Cart>(), 0, int.MaxValue); foreach (Cart cart in carts.Items) { var cartView = new EntityView { EntityId = cart.Id, ItemId = cart.Id, DisplayName = cart.DisplayName, Name = cart.Name, Icon = commerceContext.GetPolicy <CartUiPolicy>().Icon }; cartView.Properties.Add(new ViewProperty { Name = "Name", RawValue = cart.Name, UiType = "EntityLink" }); cartView.Properties.Add(new ViewProperty { Name = "ShopName", RawValue = cart.ShopName }); cartView.Properties.Add(new ViewProperty { Name = "Last Changed", RawValue = cart.DateUpdated }); cartView.Properties.Add(new ViewProperty { Name = "Lines", RawValue = cart.Lines.Count }); cartView.Properties.Add(new ViewProperty { Name = "Subtotal", RawValue = cart.Totals.SubTotal }); cartView.Properties.Add(new ViewProperty { Name = "Adjustments", RawValue = cart.Totals.AdjustmentsTotal }); cartView.Properties.Add(new ViewProperty { Name = "Grandtotal", RawValue = cart.Totals.GrandTotal }); activeCartsView.ChildViews.Add(cartView); } } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewRunningMinions.Exception: Message={ex.Message}"); } return(entityView); } }
/// <summary> /// Processes the specified commerce context. /// </summary> /// <param name="commerceContext">The commerce context.</param> /// <param name="sourceEnvironmentName">Name of the source environment.</param> /// <param name="newEnvironmentName">New name of the environment.</param> /// <param name="newArtifactStoreId">The new artifact store identifier.</param> /// <returns> /// User site terms /// </returns> public virtual async Task <bool> Process(CommerceContext commerceContext, string sourceEnvironmentName, string newEnvironmentName, Guid newArtifactStoreId) { using (CommandActivity.Start(commerceContext, this)) { var migrationSqlPolicy = commerceContext.GetPolicy <MigrationSqlPolicy>(); if (migrationSqlPolicy == null) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "InvalidOrMissingPropertyValue", new object[] { "MigrationSqlPolicy" }, $"{this.GetType()}. Missing MigrationSqlPolicy"); return(false); } if (string.IsNullOrEmpty(migrationSqlPolicy.SourceStoreSqlPolicy.Server)) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "InvalidOrMissingPropertyValue", new object[] { "MigrationSqlPolicy" }, $"{this.GetType()}. Empty server name in the MigrationSqlPolicy"); return(false); } var migrationPolicy = commerceContext.GetPolicy <MigrationPolicy>(); if (migrationPolicy == null) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "InvalidOrMissingPropertyValue", new object[] { "MigrationPolicy" }, $"{this.GetType()}. Missing MigrationPolicy"); return(false); } Guid id; if (!Guid.TryParse(migrationSqlPolicy.ArtifactStoreId, out id)) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "InvalidOrMissingPropertyValue", new object[] { "MigrationSqlPolicy.ArtifactStoreId" }, "MigrationSqlPolicy. Invalid ArtifactStoreId"); return(false); } var context = commerceContext.GetPipelineContextOptions(); var findArg = new FindEntityArgument(typeof(CommerceEnvironment), $"{CommerceEntity.IdPrefix<CommerceEnvironment>()}{newEnvironmentName}"); var findResult = await this._findEntityPipeline.Run(findArg, context); var newEnvironment = findResult as CommerceEnvironment; if (newEnvironment != null) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "InvalidOrMissingPropertyValue", new object[] { newEnvironmentName }, $"Environment {newEnvironmentName} already exists."); return(false); } findArg = new FindEntityArgument(typeof(CommerceEnvironment), $"{CommerceEntity.IdPrefix<CommerceEnvironment>()}{migrationPolicy.DefaultEnvironmentName}"); findResult = await this._findEntityPipeline.Run(findArg, context); var sourceEnvironment = findResult as CommerceEnvironment; if (sourceEnvironment == null) { await commerceContext.AddMessage( commerceContext.GetPolicy <KnownResultCodes>().Error, "EntityNotFound", new object[] { migrationPolicy.DefaultEnvironmentName }, $"Entity {migrationPolicy.DefaultEnvironmentName} was not found."); return(false); } if (sourceEnvironment.HasPolicy <EntityShardingPolicy>()) { commerceContext.AddUniqueObjectByType(sourceEnvironment.GetPolicy <EntityShardingPolicy>()); sourceEnvironment.RemovePolicy(typeof(EntityShardingPolicy)); } // set sql policies var sqlPoliciesCollection = new List <KeyValuePair <string, EntityStoreSqlPolicy> > { new KeyValuePair <string, EntityStoreSqlPolicy>("SourceGlobal", migrationSqlPolicy.SourceStoreSqlPolicy) }; // Get sql Policy set var ps = await this._findEntityPipeline.Run(new FindEntityArgument(typeof(PolicySet), $"{CommerceEntity.IdPrefix<PolicySet>()}{migrationPolicy.SqlPolicySetName}"), context); if (ps == null) { context.CommerceContext.Logger.LogError($"PolicySet {migrationPolicy.SqlPolicySetName} was not found."); } else { sqlPoliciesCollection.Add(new KeyValuePair <string, EntityStoreSqlPolicy>("DestinationShared", ps.GetPolicy <EntityStoreSqlPolicy>())); } commerceContext.AddUniqueObjectByType(sqlPoliciesCollection); sourceEnvironment.Name = sourceEnvironmentName; sourceEnvironment.ArtifactStoreId = id; sourceEnvironment.Id = $"{CommerceEntity.IdPrefix<CommerceEnvironment>()}{sourceEnvironmentName}"; sourceEnvironment.SetPolicy(migrationSqlPolicy.SourceStoreSqlPolicy); var migrateEnvironmentArgument = new MigrateEnvironmentArgument(sourceEnvironment, newArtifactStoreId, newEnvironmentName); var result = await this._migrateEnvironmentPipeline.Run(migrateEnvironmentArgument, context); return(result); } }
public override bool Execute(CommandActivity commandActivity) { const string incomingTypeVeReferenceId = "ABC5B6D0-6764-4801-AC36-7B42B80F63D3"; const string incomingTypeGsReferenceId = "64E46ED4-14C2-4E3D-A5D0-F3E2E39C2E73"; var restoreCtxId = ApplicationContext.CurrentID; try { var sourceFileCase = (FileCase)commandActivity.WorkItem; if (sourceFileCase == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } if (!sourceFileCase.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(sourceFileCase)); } //Parse tenant information from incoming string targetTenantId = String.Empty; var sourceIncoming = sourceFileCase.BaseFile.BaseIncomings .Where(i => i.IncomingType.ToHasReferenceID().ReferenceID.ToUpper() == incomingTypeVeReferenceId.ToUpper()) .OrderByDescending(t => t.CreatedAt) .FirstOrDefault(); if (sourceIncoming == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.IncomingNotFound .ToLocalizedName() .FormatWith(sourceFileCase.BaseFile)); } var targetFileCaseUri = new Uri(sourceIncoming.GetProperty("#LHIND_Mitbericht_SourceFileCaseUrl") as string); targetTenantId = HttpUtility.ParseQueryString(targetFileCaseUri.Query).Get("TenantID"); var sourceFileCaseUrl = UrlProvider.Current.GetOpenWorkListItemUrl(sourceFileCase); //Create eCH-0147 container var messageExport = Containers.Global.Resolve <IMessageExport>(); var eCHExport = messageExport.Export(sourceFileCase); sourceFileCase.AddFileCaseContent(eCHExport); //switch tenant using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) using (TenantSection.SwitchToTenant(Tenant.FindByUnqiueIdentifier(targetTenantId))) { //Create new incoming, set specialdata properties var incoming = Incoming.NewObject(); ApplicationContext.CurrentID = incoming.ApplicationContextID; incoming.Subject = sourceFileCase.DisplayName + " - eCH Response"; incoming.IncomingType = new ReferenceHandle <IncomingTypeClassificationType>(incomingTypeGsReferenceId) .GetObject(); incoming.ExternalNumber = sourceFileCase.FormattedNumber; incoming.Remark = sourceFileCase.WorkInstruction; using (new SpecialdataIgnoreReadOnlySection()) incoming.SetProperty("#LHIND_Mitbericht_SourceFileCaseUrl", sourceFileCaseUrl); var targeteCHDocument = Document.NewObject(incoming); ((IDocument)targeteCHDocument).Name = sourceFileCase.GetMultilingualValue(fc => fc.Title) + " (" + sourceFileCase.FormattedNumber + ") - eCH Import"; targeteCHDocument.PhysicallyPresent = false; targeteCHDocument.Type = (DocumentClassificationType)ClassificationType.GetObject(Rubicon.Gever .Bund.EGovInterface.Domain.WellKnownObjects.DocumentClassification.EchImport.GetObjectID()); using (SecurityFreeSection.Activate()) using (TenantSection.DisableQueryRestrictions()) using (var handle = eCHExport.ActiveContent.GetContent()) { targeteCHDocument.ActiveContent.SetContent(handle, "zip", "application/zip"); var targetFile = ImportHelper.TenantKnowsObject(targeteCHDocument, true); if (targetFile != null) { incoming.LeadingGroup = targetFile.LeadingGroup; incoming.Insert(targetFile); } else { incoming.LeadingGroup = UserHelper.Current.GetActaNovaUserExtension().StandardGroup != null ? UserHelper.Current.GetActaNovaUserExtension().StandardGroup.AsTenantGroup() : UserHelper.Current.OwningGroup.AsTenantGroup(); } } ClientTransaction.Current.Commit(); } } catch (Exception ex) { s_logger.Error(ex.Message, ex); throw; } finally { ApplicationContext.CurrentID = restoreCtxId; } return(true); }
public override bool Execute(CommandActivity commandActivity) { //Set template reference for FF const string fileCaseFfTypeReferenceId = "589AFF8A-7737-40DE-BBA4-8FA2A3178058"; const string incomingTypeVeReferenceId = "ABC5B6D0-6764-4801-AC36-7B42B80F63D3"; var restoreCtxId = ApplicationContext.CurrentID; try { var sourceFileCase = (FileCase)commandActivity.WorkItem; if (sourceFileCase == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } if (!sourceFileCase.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(sourceFileCase)); } //Read specialdata and document values //Null values handled via SpecialdataCalculatedProperty.ExpressionString var terminGs = sourceFileCase.GetProperty("#LHIND_Mitbericht_TerminGs").ToString() ?? ""; var datum = sourceFileCase.GetProperty("#LHIND_Mitbericht_Datum").ToString() ?? ""; var titelIdp = sourceFileCase.GetProperty("#LHIND_Mitbericht_TitelIdp") ?? ""; var bemerkungen = sourceFileCase.GetProperty("#LHIND_Mitbericht_Bemerkungen") ?? ""; var ffAmt = (sourceFileCase.GetProperty("#LHIND_Mitbericht_FederführendesAmt") == null) ? "" : (sourceFileCase.GetProperty("#LHIND_Mitbericht_FederführendesAmt") as SpecialdataCatalogValue) .DisplayName; var mbAemter = (sourceFileCase.GetProperty("#LHIND_Mitbericht_MitbeteiligtFdListe") == null) ? "" : String.Join(", ", (sourceFileCase.GetProperty("#LHIND_Mitbericht_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection).ToList() .Select(m => m.WrappedValue.GetProperty("DisplayName")) .ToList() .ToArray()); var rueckmeldung = (sourceFileCase.GetProperty("#LHIND_Mitbericht_Rückmeldung") == null) ? "" : String.Join(", ", (sourceFileCase.GetProperty("#LHIND_Mitbericht_Rückmeldung") as SpecialdataListPropertyValueCollection).ToList() .Select(m => m.WrappedValue.GetProperty("DisplayName")) .ToList() .ToArray()); var auftragsart = (sourceFileCase.GetProperty("#LHIND_Mitbericht_AuftragsartMitberichtsverfahren") == null) ? "" : (sourceFileCase.GetProperty("#LHIND_Mitbericht_AuftragsartMitberichtsverfahren") as SpecialdataCatalogValue).DisplayName; var rueckfragenAn = (sourceFileCase.GetProperty("#LHIND_Mitbericht_RückfragenAn") == null) ? "" : (sourceFileCase.GetProperty("#LHIND_Mitbericht_RückfragenAn") as TenantUser).DisplayName; var istFederfuehrung = (sourceFileCase.Type.ToHasReferenceID().ReferenceID.ToUpper() == fileCaseFfTypeReferenceId.ToUpper()); var sourceFileCaseUrl = UrlProvider.Current.GetOpenWorkListItemUrl(sourceFileCase); //Create eCH-0147 container var messageExport = Containers.Global.Resolve <IMessageExport>(); var eCHExport = messageExport.Export(sourceFileCase); sourceFileCase.AddFileCaseContent(eCHExport); //switch tenant using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) using (TenantSection.SwitchToTenant(UserHelper.Current.Tenant)) { //Create new incoming, set specialdata properties var incoming = Incoming.NewObject(); ApplicationContext.CurrentID = incoming.ApplicationContextID; incoming.Subject = sourceFileCase.DisplayName + " - eCH-Dossier"; incoming.IncomingType = new ReferenceHandle <IncomingTypeClassificationType>(incomingTypeVeReferenceId).GetObject(); incoming.ExternalNumber = sourceFileCase.FormattedNumber; incoming.Remark = sourceFileCase.WorkInstruction; using (new SpecialdataIgnoreReadOnlySection()) { incoming.SetProperty("#LHIND_Mitbericht_VE_TerminGs", terminGs); incoming.SetProperty("#LHIND_Mitbericht_VE_TitelIdp", titelIdp); incoming.SetProperty("#LHIND_Mitbericht_VE_FederführendesAmt", ffAmt); incoming.SetProperty("#LHIND_Mitbericht_VE_MitbeteiligtFdListe", mbAemter); incoming.SetProperty("#LHIND_Mitbericht_VE_Rückmeldung", rueckmeldung); incoming.SetProperty("#LHIND_Mitbericht_VE_AuftragsartMitberichtsverfahren", auftragsart); incoming.SetProperty("#LHIND_Mitbericht_VE_Bemerkungen", bemerkungen); incoming.SetProperty("#LHIND_Mitbericht_VE_Datum", datum); incoming.SetProperty("#LHIND_Mitbericht_VE_RückfragenAn", rueckfragenAn); incoming.SetProperty("#LHIND_Mitbericht_SourceFileCaseUrl", sourceFileCaseUrl); incoming.SetProperty("#LHIND_Mitbericht_VE_IstFederfuehrung", istFederfuehrung); } var targeteCHDocument = Document.NewObject(incoming); ((IDocument)targeteCHDocument).Name = sourceFileCase.GetMultilingualValue(fc => fc.Title) + " (" + sourceFileCase.FormattedNumber + ") - eCH Import"; targeteCHDocument.PhysicallyPresent = false; targeteCHDocument.Type = (DocumentClassificationType)ClassificationType.GetObject(Rubicon.Gever .Bund.EGovInterface.Domain.WellKnownObjects.DocumentClassification.EchImport.GetObjectID()); using (TenantSection.DisableQueryRestrictions()) using (var handle = eCHExport.ActiveContent.GetContent()) targeteCHDocument.ActiveContent.SetContent(handle, "zip", "application/zip"); var targetFile = ImportHelper.TenantKnowsObject(targeteCHDocument, true); if (targetFile != null) { incoming.LeadingGroup = targetFile.LeadingGroup; incoming.Insert(targetFile); } else { incoming.LeadingGroup = UserHelper.Current.GetActaNovaUserExtension().StandardGroup != null ? UserHelper.Current.GetActaNovaUserExtension().StandardGroup.AsTenantGroup() : UserHelper.Current.OwningGroup.AsTenantGroup(); } ClientTransaction.Current.Commit(); } } catch (Exception ex) { s_logger.Error(ex.Message, ex); throw; } finally { ApplicationContext.CurrentID = restoreCtxId; } return(true); }
public async Task <ItemType> PrepareItem(CommerceContext commerceContext, SellableItem sellableItem) { ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType { ShippingService = "USPSPriority", ShippingServicePriority = 1, ShippingServiceCost = new AmountType { currencyID = CurrencyCodeType.USD, Value = 5.0 } }; using (CommandActivity.Start(commerceContext, this)) { var item = await this._commerceCommander.Pipeline <IPrepareEbayItemPipeline>().Run(sellableItem, commerceContext.GetPipelineContextOptions()); item.Description = sellableItem.Description; item.Title = sellableItem.DisplayName; item.SubTitle = "Test Item"; var listPricingPolicy = sellableItem.GetPolicy <ListPricingPolicy>(); var listPrice = listPricingPolicy.Prices.FirstOrDefault(); item.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = System.Convert.ToDouble(listPrice.Amount) }; item.ConditionID = 1000; item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection { BuyerPaymentMethodCodeType.PayPal, BuyerPaymentMethodCodeType.VisaMC }; item.PayPalEmailAddress = "*****@*****.**"; item.PostalCode = "98014"; item.DispatchTimeMax = 3; item.ShippingDetails = new ShippingDetailsType { ShippingServiceOptions = new ShippingServiceOptionsTypeCollection(), ShippingType = ShippingTypeCodeType.Flat }; shipservice1.ShippingServiceAdditionalCost = new AmountType { currencyID = CurrencyCodeType.USD, Value = 1.0 }; item.ShippingDetails.ShippingServiceOptions.Add(shipservice1); item.ReturnPolicy = new ReturnPolicyType { ReturnsAcceptedOption = "ReturnsAccepted" }; // Add pictures item.PictureDetails = new PictureDetailsType { GalleryType = GalleryTypeCodeType.None, GalleryTypeSpecified = true }; return(item); } }
public async Task <EntityView> Process(CommerceContext commerceContext, EntityView entityView) { using (CommandActivity.Start(commerceContext, this)) { var pluginPolicy = commerceContext.GetPolicy <PluginPolicy>(); try { var masterListEntityView = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = "Resources", Name = "Resources", UiHint = "Table", Icon = pluginPolicy.Icon }; entityView.ChildViews.Add(masterListEntityView); var appServices = await this._commerceCommander.Command <ListCommander>().GetListItems <AppService>(commerceContext, "AppServices", 0, 999); foreach (var appService in appServices) { var childView = new EntityView { EntityId = string.Empty, ItemId = appService.Id, DisplayName = appService.Name, Name = appService.Name, Icon = pluginPolicy.Icon }; masterListEntityView.ChildViews.Add(childView); childView.Properties.Add(new ViewProperty { Name = "Name", RawValue = appService.Name, UiType = "EntityLink" }); childView.Properties.Add(new ViewProperty { Name = "Type", RawValue = appService.ServiceType }); var hostProperty = new ViewProperty { Name = "Host", RawValue = appService.Host, UiType = "Html", OriginalType = "Html" }; var hostUrl = hostProperty.RawValue; if (appService.ServiceType.Contains("CommerceEngine")) { if (appService.ServiceType.Contains("Azure")) { hostProperty.RawValue = $"<a href='http://{hostUrl + "/api/$metadata"}' target='_blank'>Commerce Engine</a> "; } else { hostUrl = hostUrl + "/api/$metadata"; } } else if (appService.ServiceType.Contains("Sitecore")) { hostProperty.RawValue = $"<a href='https://{hostUrl}' target='_blank'>(Shop) {hostUrl}</a>"; if (appService.ServiceType == "Sitecore-CM") { hostProperty.RawValue = hostProperty.RawValue + $"<br><a href='https://{hostUrl}/sitecore' target='_blank'>(admin){hostUrl}/sitecore</a>"; } } else if (appService.ServiceType.Contains("Azure")) { if (appService.ServiceType == "Azure-AI") { hostProperty.RawValue = $"<a href='http://{hostUrl}' target='_blank'>Azure Application Insights</a> "; } else { hostProperty.RawValue = hostProperty.RawValue + $"<br><a href='https://portal.azure.com/#resource/subscriptions/4f5f5859-08fe-47cf-8a9e-4684708594c7/resourceGroups/yalsitecore/providers/Microsoft.Web/sites/yalsitecore-solutionstorefront-shop/appServices' target='_blank'>(azure){appService.Host}</a>"; } } else { hostProperty.RawValue = $"<a href='http://{hostUrl}' target='_blank'>{hostUrl}</a>"; } childView.Properties.Add(hostProperty); } } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(entityView); } }
public override bool Execute(CommandActivity commandActivity) { const string targetIncomingTypeReferenceId = "7CFEE47F-72C7-4DDF-B2C1-71CA03E1A808"; var restoreCtxId = ApplicationContext.CurrentID; try { var hostObject = (FileCase)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } var sourceFileCaseUrl = UrlProvider.Current.GetOpenWorkListItemUrl(hostObject); //Create eCH-0147 container var messageExport = Containers.Global.Resolve <IMessageExport>(); var eCHExport = messageExport.Export(hostObject); hostObject.AddFileCaseContent(eCHExport); //switch tenant using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) using (TenantSection.SwitchToTenant(UserHelper.Current.Tenant)) { //Create new incoming, set specialdata properties var incoming = Incoming.NewObject(); ApplicationContext.CurrentID = incoming.ApplicationContextID; incoming.Subject = hostObject.DisplayName + " - eCH-Dossier"; incoming.IncomingType = new ReferenceHandle <IncomingTypeClassificationType>(targetIncomingTypeReferenceId).GetObject(); incoming.ExternalNumber = hostObject.FormattedNumber; incoming.Remark = hostObject.WorkInstruction; using (new SpecialdataIgnoreReadOnlySection()) incoming.SetProperty("#LHIND_Antrag_sourceFileCaseUrl", sourceFileCaseUrl); var targeteCHDocument = Document.NewObject(incoming); ((IDocument)targeteCHDocument).Name = hostObject.GetMultilingualValue(fc => fc.Title) + " (" + hostObject.FormattedNumber + ") - eCH Import"; targeteCHDocument.PhysicallyPresent = false; targeteCHDocument.Type = (DocumentClassificationType)ClassificationType.GetObject(Rubicon.Gever .Bund.EGovInterface.Domain.WellKnownObjects.DocumentClassification.EchImport.GetObjectID()); using (TenantSection.DisableQueryRestrictions()) using (var handle = eCHExport.ActiveContent.GetContent()) targeteCHDocument.ActiveContent.SetContent(handle, "zip", "application/zip"); var targetFile = ImportHelper.TenantKnowsObject(targeteCHDocument, true); if (targetFile != null) { incoming.LeadingGroup = targetFile.LeadingGroup; incoming.Insert(targetFile); } else { incoming.LeadingGroup = UserHelper.Current.GetActaNovaUserExtension().StandardGroup != null ? UserHelper.Current.GetActaNovaUserExtension().StandardGroup.AsTenantGroup() : UserHelper.Current.OwningGroup.AsTenantGroup(); } ClientTransaction.Current.Commit(); } } catch (Exception ex) { s_logger.Error(ex.Message, ex); throw; } finally { ApplicationContext.CurrentID = restoreCtxId; } return(true); }
public override bool Execute(CommandActivity commandActivity) { //Set templates for FileCase creation. const string fileCaseFfTemplateReferenceId = "9B9A5D57-3DC5-41A6-81DB-6D4ADC1335E6"; const string fileCaseMbTemplateReferenceId = "7AAA0700-CA11-4759-B250-DF3BC05B9754"; var startFileCases = new List <FileCase>(); try { var hostObject = (File)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } //Create FF FileCase var fileCaseTemplateFf = new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject(); if (fileCaseTemplateFf == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseFfTemplateReferenceId)); } var newTitle = String.Empty; var ffGroup = hostObject.GetProperty("#LHIND_Antrag_Ff") as TenantGroup; if (ffGroup != null) { var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf); ffFileCase.LeadingGroup = ffGroup; newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName); ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(ffFileCase); } //Create MB FileCases var fileCaseTemplateMb = new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject(); if (fileCaseTemplateMb == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseMbTemplateReferenceId)); } var mbFileCaseRecipients = hostObject.GetProperty("#LHIND_Antrag_Mb") as SpecialdataListPropertyValueCollection; foreach (var fileCaseRecipient in mbFileCaseRecipients) { var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb); mbFileCase.LeadingGroup = fileCaseRecipient.Unwrap() as TenantGroup; newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName); mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(mbFileCase); } ClientTransaction.Current.Commit(); foreach (var startFileCase in startFileCases) { startFileCase.StartObject(); } ClientTransaction.Current.Commit(); } catch (Exception ex) { s_logger.Error(ex.Message, ex); ClientTransaction.Current.Rollback(); throw; } return(true); }
public async Task <EntityView> Process(CommerceContext commerceContext, EntityView entityView) { using (CommandActivity.Start(commerceContext, this)) { var pluginPolicy = commerceContext.GetPolicy <PluginPolicy>(); try { var environmentListEntityView = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = "Environments List View", Name = "DevOps-ListView-Environments", UiHint = "Table", Icon = pluginPolicy.Icon }; entityView.ChildViews.Add(environmentListEntityView); var environments = await this._commerceCommander.Command <ListCommander>() .GetListItems <CommerceEnvironment>(this._commerceCommander.GetGlobalContext(commerceContext), CommerceEntity.ListName <CommerceEnvironment>(), 0, 99); foreach (var environment in environments) { var environmentView = new EntityView { EntityId = string.Empty, ItemId = environment.Id, DisplayName = environment.Name, Name = environment.Name, Icon = pluginPolicy.Icon }; environmentView.Properties.Add(new ViewProperty { Name = "Name", RawValue = environment.Name, UiType = "EntityLink" }); environmentView.Properties.Add(new ViewProperty { Name = "ArtifactId", RawValue = environment.ArtifactStoreId.ToString("N") }); environmentView.Properties.Add(new ViewProperty { Name = "DateCreated", RawValue = environment.DateCreated }); environmentView.Properties .Add(new ViewProperty { Name = "Policies", RawValue = environment.Policies.Count }); environmentView.Properties .Add(new ViewProperty { Name = "Components", RawValue = environment.Components.Count }); environmentListEntityView.ChildViews.Add(environmentView); } } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(entityView); } }
public override bool Execute(CommandActivity commandActivity) { //Set template reference for FF var fileCaseFfTypeReferenceId = "A8DE3E44-A236-4CBA-91A0-AD16A2D734BA"; var incomingTypeVeReferenceId = "3A655116-6B6E-4246-B2ED-7A213FD61493"; var restoreCtxId = ApplicationContext.CurrentID; try { var sourceFileCase = (FileCase)commandActivity.WorkItem; if (sourceFileCase == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } if (!sourceFileCase.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(sourceFileCase)); } //Read specialdata and document values var terminGsObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_TerminGs").ToString(); var terminGs = ""; if (terminGsObject != null) { terminGs = terminGsObject; } var datumObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_Datum").ToString(); var datum = ""; if (datumObject != null) { datum = datumObject; } var ffAmtObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_FederfuhrendesAmt") as SpecialdataCatalogValue; var ffAmt = ""; if (ffAmtObject != null) { ffAmt = ffAmtObject.DisplayName; } var rueckfragenAnObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_RückfragenAn") as TenantUser; var rueckfragenAn = ""; if (rueckfragenAnObject != null) { rueckfragenAn = rueckfragenAnObject.DisplayName; } var mbAemterCatalogValues = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection; var mbAemter = string.Join(", ", mbAemterCatalogValues.ToList() .Select(m => m.WrappedValue.GetProperty("DisplayName")) .ToList() .ToArray()); var title = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_TitelIdp") as string; var auftragsartObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_AuftragsartMitberichtsverfahren") as SpecialdataCatalogValue; var auftragsart = ""; if (auftragsartObject != null) { auftragsart = auftragsartObject.DisplayName; } var rueckmeldungCatalogValues = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_RückmeldungAn") as SpecialdataListPropertyValueCollection; var rueckmeldung = string.Join(", ", rueckmeldungCatalogValues.ToList() .Select(m => m.WrappedValue.GetProperty("DisplayName")) .ToList() .ToArray()); var bemerkungObject = sourceFileCase.GetProperty("#LHIND_MitberichtExtern_Bemerkungen") as string; var bemerkung = ""; if (bemerkungObject != null) { bemerkung = bemerkungObject; } var sourceFileCaseUrl = UrlProvider.Current.GetOpenWorkListItemUrl(sourceFileCase); bool istFederfuehrung = sourceFileCase.Type.ToHasReferenceID().ReferenceID.ToUpper() == fileCaseFfTypeReferenceId.ToUpper(); //Create eCH-0147 container var messageExport = Containers.Global.Resolve <IMessageExport>(); var eChExport = messageExport.Export(sourceFileCase); sourceFileCase.AddFileCaseContent(eChExport); //switch tenant using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) using (TenantSection.SwitchToTenant(UserHelper.Current.Tenant)) { //Create new incoming, set specialdata properties var incoming = Incoming.NewObject(); ApplicationContext.CurrentID = incoming.ApplicationContextID; incoming.Subject = sourceFileCase.DisplayName + " - eCH-Dossier"; incoming.IncomingType = new ReferenceHandle <IncomingTypeClassificationType>(incomingTypeVeReferenceId).GetObject(); incoming.ExternalNumber = sourceFileCase.FormattedNumber; incoming.Remark = sourceFileCase.WorkInstruction; using (new SpecialdataIgnoreReadOnlySection()) { incoming.SetProperty("#LHIND_MitberichtExtern_VE_TerminGs", terminGs); incoming.SetProperty("#LHIND_MitberichtExtern_VE_Titel", title); incoming.SetProperty("#LHIND_MitberichtExtern_VE_FfAmt", ffAmt); incoming.SetProperty("#LHIND_MitberichtExtern_VE_Mitbeteiligt", mbAemter); incoming.SetProperty("#LHIND_MitberichtExtern_VE_Rückmeldung", rueckmeldung); incoming.SetProperty("#LHIND_MitberichtExtern_VE_AuftragsartMitbericht", auftragsart); incoming.SetProperty("#LHIND_MitberichtExtern_VE_Bemerkungen", bemerkung); incoming.SetProperty("#LHIND_MitberichtExtern_VE_Datum", datum); incoming.SetProperty("#LHIND_MitberichtExtern_VE_RückfragenAn", rueckfragenAn); incoming.SetProperty("#LHIND_MitberichtExtern_SourceFileCaseUrl", sourceFileCaseUrl); incoming.SetProperty("#LHIND_MitberichtExtern_VE_IstFederfuehrung", istFederfuehrung); } var targeteChDocument = Document.NewObject(incoming); ((IDocument)targeteChDocument).Name = sourceFileCase.GetMultilingualValue(fc => fc.Title) + " (" + sourceFileCase.FormattedNumber + ") - eCH Import"; targeteChDocument.PhysicallyPresent = false; targeteChDocument.Type = (DocumentClassificationType)ClassificationType.GetObject(WellKnownObjects .DocumentClassification.EchImport.GetObjectID()); using (TenantSection.DisableQueryRestrictions()) using (var handle = eChExport.ActiveContent.GetContent()) { targeteChDocument.ActiveContent.SetContent(handle, "zip", "application/zip"); } var targetFile = ImportHelper.TenantKnowsObject(targeteChDocument, true); if (targetFile != null) { incoming.LeadingGroup = targetFile.LeadingGroup; incoming.Insert(targetFile); } else { incoming.LeadingGroup = UserHelper.Current.GetActaNovaUserExtension().StandardGroup != null ? UserHelper.Current.GetActaNovaUserExtension().StandardGroup.AsTenantGroup() : UserHelper.Current.OwningGroup.AsTenantGroup(); } ClientTransaction.Current.Commit(); } } catch (Exception ex) { s_logger.Error(ex.Message); throw; } finally { ApplicationContext.CurrentID = restoreCtxId; } return(true); }
public override bool Execute(CommandActivity commandActivity) { //Set templates for FileCase creation. var fileCaseFfTemplateReferenceId = "B475F10A-94ED-4E75-9C64-DF6890569093"; var fileCaseMbTemplateReferenceId = "8087873D-755F-40D4-84C6-1BA7EB8C26AC"; var startFileCases = new List <FileCase>(); try { var hostObject = (File)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } //Create FF FileCase var fileCaseTemplateFf = new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject(); if (fileCaseTemplateFf == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseFfTemplateReferenceId)); } var newTitle = String.Empty; var ffCatalogValue = hostObject.GetProperty("#LHIND_MitberichtExtern_FederfuhrendesAmt") as SpecialdataCatalogValue; if (ffCatalogValue != null) { var ffGroup = ffCatalogValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup; if (ffGroup == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined .ToLocalizedName() .FormatWith(ffCatalogValue)); } var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf); ffFileCase.LeadingGroup = ffGroup; newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName); ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(ffFileCase); } //Create MB FileCases var fileCaseTemplateMb = new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject(); if (fileCaseTemplateMb == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseMbTemplateReferenceId)); } var mbCatalogValues = hostObject.GetProperty("#LHIND_MitberichtExtern_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection; foreach (var mbCatalogValue in mbCatalogValues) { var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup; if (mbGroup == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined .ToLocalizedName() .FormatWith(ffCatalogValue)); } var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb); mbFileCase.LeadingGroup = mbGroup; newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName); mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(mbFileCase); } ClientTransaction.Current.Commit(); foreach (var startFileCase in startFileCases) { startFileCase.StartObject(); } ClientTransaction.Current.Commit(); } catch (Exception ex) { s_logger.Error(ex.Message, ex); ClientTransaction.Current.Rollback(); throw; } return(true); }
public async Task <ItemType> AddItem(CommerceContext commerceContext, SellableItem sellableItem) { using (var activity = CommandActivity.Start(commerceContext, this)) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); try { //Instantiate the call wrapper class var apiCall = new AddFixedPriceItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false)); var item = await PrepareItem(commerceContext, sellableItem).ConfigureAwait(false); //Send the call to eBay and get the results FeeTypeCollection feeTypeCollection = apiCall.AddFixedPriceItem(item); foreach (var feeItem in feeTypeCollection) { var fee = feeItem as FeeType; ebayItemComponent.Fees.Add(new AwardedAdjustment { Adjustment = new Money(fee.Fee.currencyID.ToString(), System.Convert.ToDecimal(fee.Fee.Value)), AdjustmentType = "Fee", Name = fee.Name }); } ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Added", EventUser = commerceContext.CurrentCsrId() }); ebayItemComponent.EbayId = item.ItemID; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); await commerceContext.AddMessage("Info", "EbayCommand.AddItem", new [] { item.ItemID }, $"Item Listed:{item.ItemID}").ConfigureAwait(false); return(item); } catch (Exception ex) { if (ex.Message.Contains("It looks like this listing is for an item you already have on eBay")) { var existingId = ex.Message.Substring(ex.Message.IndexOf("(") + 1); existingId = existingId.Substring(0, existingId.IndexOf(")")); await commerceContext.AddMessage("Warn", "EbayCommand.AddItem", new [] { existingId }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}").ConfigureAwait(false); ebayItemComponent.EbayId = existingId; ebayItemComponent.Status = "Listed"; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Existing Listing Linked", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); } else { commerceContext.Logger.LogError($"Ebay.AddItem.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.AddItem.Exception", new [] { ex }, ex.Message).ConfigureAwait(false); ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = $"Error-{ex.Message}", EventUser = commerceContext.CurrentCsrId() }); } } return(new ItemType()); } }
public override bool Execute(CommandActivity commandActivity) { //Set templates for FileCase creation. const string fileCaseFfTemplateReferenceId = "6220CB49-8E09-4AB7-B4F1-673C6C91CC7E"; const string fileCaseMbTemplateReferenceId = "56E01B36-E6DE-4DA3-ABE8-95C6551A76D3"; var startFileCases = new List <FileCase>(); try { var hostObject = (File)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } //Create FF FileCase var fileCaseTemplateFf = new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject(); if (fileCaseTemplateFf == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseFfTemplateReferenceId)); } var newTitle = String.Empty; var ffCatalogValue = hostObject.GetProperty("#LHIND_Mitbericht_FederführendesAmt") as SpecialdataCatalogValue; if (ffCatalogValue != null) { var ffGroup = ffCatalogValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup; if (ffGroup == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined .ToLocalizedName() .FormatWith(ffCatalogValue)); } var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf); ffFileCase.LeadingGroup = ffGroup; newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName); ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(ffFileCase); } //Create MB FileCases var fileCaseTemplateMb = new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject(); if (fileCaseTemplateMb == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseMbTemplateReferenceId)); } var mbCatalogValues = hostObject.GetProperty("#LHIND_Mitbericht_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection; foreach (var mbCatalogValue in mbCatalogValues) { var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup; if (mbGroup == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined .ToLocalizedName() .FormatWith(ffCatalogValue)); } var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb); mbFileCase.LeadingGroup = mbGroup; newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName); mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(mbFileCase); } ClientTransaction.Current.Commit(); foreach (var startFileCase in startFileCases) { startFileCase.StartObject(); } ClientTransaction.Current.Commit(); } catch (Exception ex) { s_logger.Error(ex.Message, ex); ClientTransaction.Current.Rollback(); throw; } return(true); }
public async Task <ItemType> RelistItem(CommerceContext commerceContext, SellableItem sellableItem) { using (CommandActivity.Start(commerceContext, this)) { var apiCall = new eBay.Service.Call.RelistItemCall(await this.GetEbayContext(commerceContext)); if (sellableItem.HasComponent <EbayItemComponent>()) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); try { var item = await this.PrepareItem(commerceContext, sellableItem); item.ItemID = ebayItemComponent.EbayId; // Send the call to eBay and get the results var feeResult = apiCall.RelistItem(item, new StringCollection()); ebayItemComponent.EbayId = item.ItemID; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); foreach (var feeItem in feeResult) { var fee = feeItem as FeeType; ebayItemComponent.Fees.Add(new AwardedAdjustment { Adjustment = new Money(fee.Fee.currencyID.ToString(), System.Convert.ToDecimal(fee.Fee.Value)), AdjustmentType = "Fee", Name = fee.Name }); } ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Relisted", EventUser = commerceContext.CurrentCsrId() }); return(item); } catch (Exception ex) { if (ex.Message.Contains("It looks like this listing is for an item you already have on eBay")) { var existingId = ex.Message.Substring(ex.Message.IndexOf("(") + 1); existingId = existingId.Substring(0, existingId.IndexOf(")")); await commerceContext.AddMessage("Warn", "Ebay.RelistItem", new object[] { }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}"); ebayItemComponent.EbayId = existingId; ebayItemComponent.Status = "Listed"; sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed"); } else { commerceContext.Logger.LogError($"Ebay.RelistItem.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new object[] { ex }, ex.Message); } } } else { commerceContext.Logger.LogError("EbayCommand.RelistItem.Exception: Message=ebayCommand.RelistItem.NoEbayItemComponent"); await commerceContext.AddMessage("Error", "Ebay.RelistItem.Exception", new object[] { }, "ebayCommand.RelistItem.NoEbayItemComponent"); } return(new ItemType()); } }
public override bool Execute(CommandActivity commandActivity) { const string fileCaseTemplateReferenceId = "04248329-15C8-40C8-8888-90DF1C782A56"; try { var hostObject = (File)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } var fileCaseTemplate = new ReferenceHandle <FileCaseTemplate>(fileCaseTemplateReferenceId).GetObject(); if (fileCaseTemplate == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseTemplateReferenceId)); } var startFileCases = new List <FileCase>(); var fileCaseRecipientGroups = hostObject.GetProperty("#LHIND_Mitbericht_VE_WeiterleitenAn") as SpecialdataListPropertyValueCollection; if (fileCaseRecipientGroups == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoRecipients .ToLocalizedName() .FormatWith(hostObject)); } foreach (var recipientGroup in fileCaseRecipientGroups) { var newFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplate); if (newFileCase == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } newFileCase.LeadingGroup = recipientGroup.Unwrap() as TenantGroup; var newTitle = hostObject.GetMultilingualValue(fc => fc.Title) + " [" + hostObject.FormattedNumber + "] - " + newFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName); newFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(newFileCase); } ClientTransaction.Current.Commit(); foreach (var startFileCase in startFileCases) { startFileCase.StartObject(); } ClientTransaction.Current.Commit(); } catch (Exception ex) { s_logger.Error(ex.Message, ex); ClientTransaction.Current.Rollback(); throw; } return(true); }
public override bool Execute(CommandActivity commandActivity) { //Set templates for FileCase creation. var fileCaseFfTemplateReferenceId = "F0754977-092B-481B-8A59-AA806FFE1499"; var startFileCases = new List <FileCase>(); try { var hostObject = (File)commandActivity.WorkItem; if (hostObject == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile .ToLocalizedName() .FormatWith(commandActivity)); } if (!hostObject.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(hostObject)); } //Create FF FileCase var fileCaseTemplateFf = new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject(); if (fileCaseTemplateFf == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate .ToLocalizedName() .FormatWith(fileCaseFfTemplateReferenceId)); } var newTitle = String.Empty; var ffCatalogValue = hostObject.GetProperty("#LHIND_Monatsgespraeche_Federfuehrung") as SpecialdataCatalogValue; if (ffCatalogValue != null) { var ffGroup = ffCatalogValue.GetProperty("#LHIND_Monatsgespraeche_Spoc") as TenantGroup; if (ffGroup == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined .ToLocalizedName() .FormatWith(ffCatalogValue)); } var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf); ffFileCase.LeadingGroup = ffGroup; newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName); ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle); startFileCases.Add(ffFileCase); } ClientTransaction.Current.Commit(); foreach (var startFileCase in startFileCases) { startFileCase.StartObject(); } ClientTransaction.Current.Commit(); } catch (Exception ex) { s_logger.Error(ex.Message, ex); ClientTransaction.Current.Rollback(); throw; } return(true); }
public async Task <List <InventorySet> > Process(CommerceContext commerceContext, List <CreateStoreInventorySetArgument> inputArgumentList, List <string> productsToAssociate, string catalogName) { CreateStoreInventoryCommand createStoreInventoryCommand = this; List <InventorySet> sets = new List <InventorySet>(); using (CommandActivity.Start(commerceContext, createStoreInventoryCommand)) { await createStoreInventoryCommand.PerformTransaction(commerceContext, async() => { CommercePipelineExecutionContextOptions pipelineContextOptions = commerceContext.PipelineContextOptions; foreach (CreateStoreInventorySetArgument arg in inputArgumentList) { InventorySet inventorySet2 = await this._createStoreInventorySetPipeline.Run(arg, pipelineContextOptions).ConfigureAwait(false); if (inventorySet2 != null) { sets.Add(inventorySet2); } else { // find the entity set id and add - for further processng in associate sets.Add(new InventorySet() { Id = CommerceEntity.IdPrefix <InventorySet>() + arg.Name }); } } }); } // Update all products if no input passed if (productsToAssociate.Count == 0) { var products = await this._getProductsToUpdateInventoryPipeline.Run(catalogName, commerceContext.PipelineContextOptions).ConfigureAwait(false); productsToAssociate = products; if (productsToAssociate == null) { return(null); } } // Once Done.. then assign inventory to products in the sets // Associate Sellable Item to Inventory Set foreach (var product in productsToAssociate) { using (CommandActivity.Start(commerceContext, createStoreInventoryCommand)) { var productIds = product.Split('|'); string variantId = null; var productId = product.Split('|').FirstOrDefault(); if (productIds.Count() > 1) { variantId = product.Split('|').Skip(1).FirstOrDefault(); } SellableItemInventorySetsArgument args = new SellableItemInventorySetsArgument() { InventorySetIds = sets.Select(x => x.Id).ToList(), SellableItemId = productId, VariationId = variantId }; bool result = await this._associateStoreInventoryToSellableItem.Run(args, commerceContext.PipelineContextOptions).ConfigureAwait(false); } } return(sets); }
public override bool Execute(CommandActivity commandActivity) { //Set template reference for FF var incomingTypeVeReferenceId = "2AC5CF72-AC04-4346-980F-214B34FD9FD0"; var restoreCtxId = ApplicationContext.CurrentID; try { var sourceFileCase = (FileCase)commandActivity.WorkItem; if (sourceFileCase == null) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase .ToLocalizedName() .FormatWith(commandActivity)); } if (!sourceFileCase.CanEdit(true)) { throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable .ToLocalizedName() .FormatWith(sourceFileCase)); } //Read specialdata and document values var terminGs = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_TerminGs").ToString() ?? ""; var datum = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_Datum").ToString() ?? ""; var title = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_TitelIdp") as string; var ffAmtObject = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_Federfuehrung") as SpecialdataCatalogValue; var ffAmt = ""; if (ffAmtObject != null) { ffAmt = ffAmtObject.DisplayName; } var auftrag = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_Auftrag") as string; var bemerkung = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_Bemerkungen") as string; var rueckfragenAnObject = sourceFileCase.GetProperty("#LHIND_Monatsgespraeche_RueckfragenAn") as TenantUser; var rueckfragenAn = ""; if (rueckfragenAnObject != null) { rueckfragenAn = rueckfragenAnObject.DisplayName; } var sourceFileCaseUrl = UrlProvider.Current.GetOpenWorkListItemUrl(sourceFileCase); //Create eCH-0147 container var messageExport = Containers.Global.Resolve <IMessageExport>(); var eChExport = messageExport.Export(sourceFileCase); sourceFileCase.AddFileCaseContent(eChExport); //switch tenant using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) using (TenantSection.SwitchToTenant(UserHelper.Current.Tenant)) { //Create new incoming, set specialdata properties var incoming = Incoming.NewObject(); ApplicationContext.CurrentID = incoming.ApplicationContextID; incoming.Subject = sourceFileCase.DisplayName + " - eCH-Dossier"; incoming.IncomingType = new ReferenceHandle <IncomingTypeClassificationType>(incomingTypeVeReferenceId).GetObject(); incoming.ExternalNumber = sourceFileCase.FormattedNumber; incoming.Remark = sourceFileCase.WorkInstruction; using (new SpecialdataIgnoreReadOnlySection()) { incoming.SetProperty("#LHIND_Monatsgespraeche_VE_TerminGs", terminGs); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_Titel", title); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_Federführung", ffAmt); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_Auftrag", auftrag); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_Bemerkungen", bemerkung); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_Datum", datum); incoming.SetProperty("#LHIND_Monatsgespraeche_VE_RückfragenAn", rueckfragenAn); incoming.SetProperty("#LHIND_Monatsgespraeche_SourceFileCaseUrl", sourceFileCaseUrl); } var targeteChDocument = Document.NewObject(incoming); ((IDocument)targeteChDocument).Name = sourceFileCase.GetMultilingualValue(fc => fc.Title) + " (" + sourceFileCase.FormattedNumber + ") - eCH Import"; targeteChDocument.PhysicallyPresent = false; targeteChDocument.Type = (DocumentClassificationType)ClassificationType.GetObject(WellKnownObjects .DocumentClassification.EchImport.GetObjectID()); using (TenantSection.DisableQueryRestrictions()) using (var handle = eChExport.ActiveContent.GetContent()) { targeteChDocument.ActiveContent.SetContent(handle, "zip", "application/zip"); } var targetFile = ImportHelper.TenantKnowsObject(targeteChDocument, true); if (targetFile != null) { incoming.LeadingGroup = targetFile.LeadingGroup; incoming.Insert(targetFile); } else { incoming.LeadingGroup = UserHelper.Current.GetActaNovaUserExtension().StandardGroup != null ? UserHelper.Current.GetActaNovaUserExtension().StandardGroup.AsTenantGroup() : UserHelper.Current.OwningGroup.AsTenantGroup(); } ClientTransaction.Current.Commit(); } } catch (Exception ex) { s_logger.Error(ex.Message); throw; } finally { ApplicationContext.CurrentID = restoreCtxId; } return(true); }
public async Task <bool> Process(CommerceContext commerceContext) { using (CommandActivity.Start(commerceContext, this)) { var customerTotals = new Dictionary <string, OrdersTotals>(); try { var orderTotals = await this._commerceCommander.GetEntity <OrdersTotals>(commerceContext, "Orders_Totals", true); if (!orderTotals.IsPersisted) { orderTotals.Id = "Orders_Totals"; } orderTotals.LastRunStarted = DateTimeOffset.UtcNow; orderTotals.LastRunEnded = DateTimeOffset.MinValue; orderTotals.MonitorCycle++; var batchSize = 300; var arg = new FindEntitiesInListArgument(typeof(CommerceEntity), "Orders", System.Convert.ToInt32(orderTotals.LastSkip), batchSize); var ordersBatch = await this._commerceCommander.Pipeline <FindEntitiesInListPipeline>().Run(arg, commerceContext.GetPipelineContextOptions()); while (ordersBatch.List.Items.Count > 0) { var returnedOrders = ordersBatch.List.Items.OfType <Order>(); foreach (var order in returnedOrders) { orderTotals.Totals.GrandTotal.Amount = orderTotals.Totals.GrandTotal.Amount + order.Totals.GrandTotal.Amount; orderTotals.Totals.SubTotal.Amount = orderTotals.Totals.SubTotal.Amount + order.Totals.SubTotal.Amount; orderTotals.Totals.PaymentsTotal.Amount = orderTotals.Totals.PaymentsTotal.Amount + order.Totals.PaymentsTotal.Amount; orderTotals.Totals.AdjustmentsTotal.Amount = orderTotals.Totals.AdjustmentsTotal.Amount + order.Totals.AdjustmentsTotal.Amount; foreach (var adjustment in order.Adjustments) { var adjustmentType = orderTotals.Adjustments.FirstOrDefault(p => p.Name == adjustment.AdjustmentType); if (adjustmentType == null) { adjustmentType = new TotalsAdjustmentsModel { Name = adjustment.AdjustmentType }; orderTotals.Adjustments.Add(adjustmentType); } adjustmentType.Adjustment.Amount = adjustmentType.Adjustment.Amount + adjustment.Adjustment.Amount; } if (order.HasComponent <ContactComponent>()) { OrdersTotals orderTotalsByCust = null; var orderContactComponent = order.GetComponent <ContactComponent>(); var customerTotalsId = $"Order_Totals_ByCust_{orderContactComponent.CustomerId.Replace("Entity-Customer-", "")}"; if (customerTotals.ContainsKey(customerTotalsId)) { orderTotalsByCust = customerTotals[customerTotalsId]; } else { orderTotalsByCust = await this._commerceCommander .GetEntity <OrdersTotals>(commerceContext, customerTotalsId, true); } if (!orderTotalsByCust.IsPersisted) { orderTotalsByCust.Id = customerTotalsId; } else { if (orderTotalsByCust.OrderCount == 0 || orderTotalsByCust.MonitorCycle != orderTotals.MonitorCycle) { orderTotalsByCust.Totals.GrandTotal.Amount = 0; orderTotalsByCust.Totals.SubTotal.Amount = 0; orderTotalsByCust.Totals.PaymentsTotal.Amount = 0; orderTotalsByCust.Totals.AdjustmentsTotal.Amount = 0; orderTotalsByCust.MonitorCycle = orderTotals.MonitorCycle; orderTotalsByCust.Adjustments.Clear(); } } orderTotalsByCust.OrderCount++; orderTotalsByCust.LastSkip = orderTotalsByCust.LastSkip + batchSize; orderTotalsByCust.Totals.GrandTotal.Amount = orderTotalsByCust.Totals.GrandTotal.Amount + order.Totals.GrandTotal.Amount; orderTotalsByCust.Totals.SubTotal.Amount = orderTotalsByCust.Totals.SubTotal.Amount + order.Totals.SubTotal.Amount; orderTotalsByCust.Totals.PaymentsTotal.Amount = orderTotalsByCust.Totals.PaymentsTotal.Amount + order.Totals.PaymentsTotal.Amount; orderTotalsByCust.Totals.AdjustmentsTotal.Amount = orderTotalsByCust.Totals.AdjustmentsTotal.Amount + order.Totals.AdjustmentsTotal.Amount; foreach (var adjustment in order.Adjustments) { var adjustmentType = orderTotalsByCust.Adjustments.FirstOrDefault(p => p.Name == adjustment.AdjustmentType); if (adjustmentType == null) { adjustmentType = new TotalsAdjustmentsModel { Name = adjustment.AdjustmentType }; orderTotalsByCust.Adjustments.Add(adjustmentType); } adjustmentType.Adjustment.Amount = adjustmentType.Adjustment.Amount + adjustment.Adjustment.Amount; } } orderTotals.OrderCount++; } orderTotals.LastSkip = orderTotals.LastSkip + batchSize; orderTotals.History.Add(new HistoryEntryModel { Name = "MonitorTotals.BatchCompleted", EventMessage = $"Completed batch: {orderTotals.LastSkip}" }); orderTotals.LastRunEnded = DateTimeOffset.UtcNow; orderTotals.LastSkip = (orderTotals.LastSkip - batchSize) + returnedOrders.Count(); await this._commerceCommander.PersistEntity(commerceContext, orderTotals); foreach (var orderCustomerTotal in customerTotals) { await this._commerceCommander.PersistEntity(commerceContext, orderCustomerTotal.Value); } customerTotals.Clear(); await Task.Delay(100); arg = new FindEntitiesInListArgument(typeof(CommerceEntity), "Orders", System.Convert.ToInt32(orderTotals.LastSkip), batchSize); ordersBatch = await this._commerceCommander.Pipeline <FindEntitiesInListPipeline>().Run(arg, commerceContext.GetPipelineContextOptions()); } } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewEnvironments.Exception: Message={ex.Message}"); } return(true); } }
public async Task <EntityView> Process(CommerceContext commerceContext, EntityView entityView) { var settingsuiPolicy = commerceContext.GetPolicy <SettingsUiPolicy>(); using (CommandActivity.Start(commerceContext, this)) { try { var view = new EntityView { EntityId = string.Empty, ItemId = string.Empty, DisplayName = settingsuiPolicy.ViewName, Name = settingsuiPolicy.ViewName, UiHint = "Table", Icon = commerceContext.GetPolicy <SettingsUiPolicy>().Icon }; entityView.ChildViews.Add(view); CommerceList <Setting> settings = await _commerceCommander.Command <FindEntitiesInListCommand>().Process <Setting>(commerceContext, CommerceEntity.ListName <Setting>(), 0, int.MaxValue); if (!settings.Items.Any()) { Setting setting = await _commerceCommander.Command <GetSettingCommand>().Process(commerceContext, DefaultSettingsEntity); if (setting == null) { setting = await _commerceCommander.Command <CreateSettingCommand>().Process(commerceContext, new CreateSettingArg(DefaultSettingsEntity, DefaultSettingsEntity)); } settings = await _commerceCommander.Command <FindEntitiesInListCommand>().Process <Setting>(commerceContext, CommerceEntity.ListName <Setting>(), 0, int.MaxValue); } foreach (var setting in settings.Items) { var basicDataEntityView = new EntityView { EntityId = setting.Id, ItemId = setting.Id, DisplayName = setting.DisplayName, Name = setting.Name, Icon = commerceContext.GetPolicy <SettingsUiPolicy>().Icon }; basicDataEntityView.Properties.Add(new ViewProperty { Name = "Name", RawValue = setting.Name, UiType = "EntityLink" }); basicDataEntityView.Properties.Add(new ViewProperty { Name = "Is Active", RawValue = setting.IsActive }); view.ChildViews.Add(basicDataEntityView); } } catch (Exception ex) { commerceContext.Logger.LogError($"ChildViewRunningMinions.Exception: Message={ex.Message}"); } return(null); //return entityView; } }