/// <summary> /// Performs the menu action. /// </summary> /// <param name="sender">The sender.</param> public void PerformMenuAction(object sender) { UPMLinkRecordField linkRecordField = (UPMLinkRecordField)sender; ViewReference viewReference = this.viewReferenceDictionary[linkRecordField.Identifier.IdentifierAsString]; this.Delegate.PerformOrganizerAction(sender, viewReference); }
/// <summary> /// Applies the link record identification. /// </summary> /// <param name="recordIdentification">The record identification.</param> /// <returns></returns> public UPMGroup ApplyLinkRecordIdentification(string recordIdentification) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; string menuName = this.TabConfig.Type.Substring(5); this.Menu = configStore.MenuByName(menuName); if (this.Menu == null || this.Menu.Items.Count == 0) { this.ControllerState = GroupModelControllerState.Error; base.Error = new Exception("ConfigurationError"); return(null); } UPMMenuGroup menuGroup = null; uint menuItemNr = 0; this.viewReferenceDictionary = new Dictionary <string, ViewReference>(); foreach (string menuItemName in this.Menu.Items) { Menu menuItem = configStore.MenuByName(menuItemName); if (menuItem.ViewReference == null) { continue; } if (menuGroup == null) { menuGroup = new UPMMenuGroup(this.TabIdentifierForRecordIdentification(recordIdentification)); menuGroup.LabelText = this.TabLabel; } string identifierString = $"menu_{menuItemNr++}_{ menuItem.UnitName}"; IIdentifier identifier = StringIdentifier.IdentifierWithStringId(identifierString); UPMAction menuAction = new UPMAction(identifier); ViewReference linkRecordViewReference = menuItem.ViewReference.ViewReferenceWith(recordIdentification); this.viewReferenceDictionary[identifierString] = linkRecordViewReference; menuAction.SetTargetAction(this, this.PerformMenuAction); if (menuItem.ImageName != null) { menuAction.IconName = menuItem.ImageName; } UPMLinkRecordField field = new UPMLinkRecordField(identifier, menuAction); field.LabelText = menuItem.UnitName; field.StringValue = menuItem.DisplayName; menuGroup.AddField(field); } this.ControllerState = menuGroup != null ? GroupModelControllerState.Finished : GroupModelControllerState.Empty; this.Group = menuGroup; return(menuGroup); }
private UPMStringField CreateStringField( UPConfigFieldControlField fieldConfig, FieldIdentifier fieldIdentifier, UPCRMResultRow resultRow, string recordIdentification, IConfigurationUnitStore configStore) { UPMStringField field; if (fieldConfig.IsLinkedField) { var fieldRecordIdentification = resultRow.PhysicalRecordIdentificationAtFieldIndex(fieldConfig.TabIndependentFieldIndex); if (!string.IsNullOrEmpty(fieldRecordIdentification)) { var linkRecordAction = new UPMAction(StringIdentifier.IdentifierWithStringId("linkRecordActionId")); var showRecordMenu = configStore.DefaultMenuForInfoAreaId(fieldConfig.InfoAreaId); var linkRecordViewReference = showRecordMenu.ViewReference.ViewReferenceWith(fieldRecordIdentification); this.AddViewReferenceForActionKey(linkRecordViewReference, $"{fieldIdentifier}"); linkRecordAction.SetTargetAction(this, this.PerformLinkRecordAction); field = new UPMLinkRecordField(fieldIdentifier, linkRecordAction); } else { field = new UPMStringField(fieldIdentifier); } } else { var linkUrlAction = new UPMAction(StringIdentifier.IdentifierWithStringId("linkUrlActionId")); linkUrlAction.SetTargetAction(this, (sender) => { var url = (sender as UPMURLField)?.StringValue; if (url != null && !url.Contains("://")) { url = "http://" + url; } var deviceService = SimpleIoc.Default.GetInstance <IDeviceService>(); deviceService?.OpenUri(new Uri(url)); }); field = new UPMURLField(fieldIdentifier, linkUrlAction); } return(field); }
public override UPMGroup ApplyContext(Dictionary <string, object> contextDictionary) { if (this.triggerActionGroup == null) { this.triggerActionGroup = new UPMTriggerActionGroup(this._identifier); string executeText = LocalizationKeys.upTextProcessExecute; string descriptionText = String.Empty; string headText = LocalizationKeys.upTextProcessAction; string executingText = LocalizationKeys.upTextProcessExecuting; string doneText = LocalizationKeys.upTextProcessDone; string retryText = LocalizationKeys.upTextRetry; if (!string.IsNullOrEmpty(this.FormItem.Label)) { var textParts = this.FormItem.Label.Split(';'); if (textParts.Length > 2) { string part0 = textParts[0]; if (part0.Length > 0) { headText = part0; } string part1 = textParts[1]; if (part1.Length > 0) { executeText = part1; } if (textParts.Length > 3) { string part2 = textParts[2]; if (part2.Length > 0) { executingText = part2; } if (textParts.Length > 4) { string part3 = textParts[3]; if (part3.Length > 0) { doneText = part3; } descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + part2.Length + part3.Length + 4); } else { descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + part2.Length + 3); } } else { descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + 2); } } else if (textParts.Length > 1) { string part = textParts[0]; if (part.Length > 0) { executeText = part; } descriptionText = this.FormItem.Label.Substring(part.Length + 1); } else { descriptionText = this.FormItem.Label; } } this.triggerActionGroup.ExecutionNote = descriptionText; this.triggerActionGroup.LabelText = headText; this.triggerActionGroup.HtmlMode = false; this.triggerActionGroup.ButtonText = executeText; this.triggerActionGroup.ExecutingText = executingText; this.triggerActionGroup.DoneText = doneText; this.triggerActionGroup.RetryText = retryText; UPMAction menuAction = new UPMAction(this._identifier); this.LinkRecordIdentification = this.FormItem.ViewReference.ContextValueForKey("Func1"); string v = contextDictionary.ValueOrDefault(this.LinkRecordIdentification) as string; if (!string.IsNullOrEmpty(v)) { this.LinkRecordIdentification = v; } this.ActionType = this.FormItem.ViewReference.ContextValueForKey("Func2"); this.ActionConfig = this.FormItem.ViewReference.ContextValueForKey("Func3"); if (this.ActionType == "CopyRecord") { menuAction.SetTargetAction(this, PerformCopyRecordAction); } else if (this.ActionType == "Workflow") { menuAction.SetTargetAction(this, PerformWorkflowAction); } menuAction.LabelText = executeText; UPMLinkRecordField field = new UPMLinkRecordField(this._identifier, menuAction); field.LabelText = executeText; field.StringValue = executeText; this.triggerActionGroup.AddField(field); this.ControllerState = GroupModelControllerState.Finished; this.Group = this.triggerActionGroup; this.AddDependingKeysFromViewReference(this.FormItem.ViewReference); } /* * else if (Thread.IsMainThread() == false) * { * this.PerformSelectorOnMainThreadWithObjectWaitUntilDone(@selector(applyContext:), contextDictionary, true); * return this.triggerActionGroup; * } */ Dictionary <string, object> paramDict = this.ParameterDictionary(); this.triggerActionGroup.Disable = paramDict[".empty"] != null ? true : false; return(this.triggerActionGroup); }