public void Execute(XElement element, string name, UrlString parameters, string value) { Assert.ArgumentNotNull((object)element, "element"); Assert.ArgumentNotNull((object)name, "name"); Assert.ArgumentNotNull((object)parameters, "parameters"); Assert.ArgumentNotNull((object)value, "value"); var selectItemOptions = new SelectItemOptions(); var obj1 = (Item)null; if (!string.IsNullOrEmpty(value)) { obj1 = Client.ContentDatabase.GetItem(value); } var path = XElement.Parse(element.ToString()).FirstAttribute.Value; if (!string.IsNullOrEmpty(path)) { var obj2 = Client.ContentDatabase.GetItem(path); if (obj2 != null) { selectItemOptions.FilterItem = obj2; } } selectItemOptions.Root = Client.ContentDatabase.GetItem(new ID(WellKnownIdentifiers.ProfilesContainerId)); selectItemOptions.SelectedItem = obj1 ?? (selectItemOptions.Root != null ? selectItemOptions.Root.Children.FirstOrDefault <Item>() : (Item)null); selectItemOptions.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList("{0FC09EA4-8D87-4B0E-A5C9-8076AE863D9C}"); selectItemOptions.Title = "Select Profile Card"; selectItemOptions.Text = "Select the profile card to use in this rule."; selectItemOptions.Icon = "Business/16x16/chart.png"; selectItemOptions.ShowRoot = false; SheerResponse.ShowModalDialog(selectItemOptions.ToUrlString().ToString(), "1200px", "700px", string.Empty, true); }
public void Execute(XElement element, string name, UrlString parameters, string value) { // Param validations Condition.Requires(element, nameof(element)).IsNotNull(); Condition.Requires(name, nameof(name)).IsNotNull(); Condition.Requires(parameters, nameof(parameters)).IsNotNull(); Condition.Requires(value, nameof(value)).IsNotNull(); var selectItemOptions = new SelectItemOptions(); // Rule Condition item var path = XElement.Parse(element.ToString()).FirstAttribute.Value; if (!string.IsNullOrEmpty(path)) { var ruleConditionItem = Context.ContentDatabase.GetItem(path); if (ruleConditionItem != null) { selectItemOptions.FilterItem = ruleConditionItem; } } // Filter templates selectItemOptions.ShowRoot = false; selectItemOptions.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList(IoTDevice.TemplateID.ToString()); // Selected Item Item deviceItem = null; if (!string.IsNullOrEmpty(value)) { deviceItem = Context.ContentDatabase.GetItem(value); } // Setup component state selectItemOptions.Root = Context.ContentDatabase.GetItem(DeviceRootId); selectItemOptions.SelectedItem = deviceItem; selectItemOptions.Title = "Select IoT Device"; selectItemOptions.Text = "Select the IoT Device to use in this rule."; selectItemOptions.Icon = "/~/icon/office/32x32/password_field.png"; var parameter = parameters["resulttype"]; if (!string.IsNullOrEmpty(parameter)) { selectItemOptions.ResultType = (SelectItemOptions.DialogResultType)Enum.Parse(typeof(SelectItemOptions.DialogResultType), parameter); } SheerResponse.ShowModalDialog(selectItemOptions.ToUrlString().ToString(), "1200px", "700px", string.Empty, true); }
// Methods public void Execute(XElement element, string name, UrlString parameters, string value) { Assert.ArgumentNotNull(element, "element"); Assert.ArgumentNotNull(name, "name"); Assert.ArgumentNotNull(parameters, "parameters"); Assert.ArgumentNotNull(value, "value"); SelectItemOptions options = new SelectItemOptions(); if (!string.IsNullOrEmpty(value)) { Item item = Client.ContentDatabase.GetItem(value); if (item != null) { options.SelectedItem = item; } } string str = parameters["root"]; if (!string.IsNullOrEmpty(str)) { Item item2 = Client.ContentDatabase.GetItem(str); if (item2 != null) { options.Root = item2; } } string str2 = parameters["selection"]; if (!string.IsNullOrEmpty(str2)) { options.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList(str2.Split(new char[] { '|' })); } string str3 = parameters["display"]; if (!string.IsNullOrEmpty(str3)) { options.IncludeTemplatesForDisplay = SelectItemOptions.GetTemplateList(str3.Split(new char[] { '|' })); } options.Title = "Select Item"; options.Text = "Select the item to use in this rule."; options.Icon = "People/16x16/cube_blue.png"; SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true); }
public void Execute(XElement element, string name, UrlString parameters, string value) { // Param validations Condition.Requires(element, nameof(element)).IsNotNull(); Condition.Requires(name, nameof(name)).IsNotNull(); Condition.Requires(parameters, nameof(parameters)).IsNotNull(); Condition.Requires(value, nameof(value)).IsNotNull(); var selectItemOptions = new SelectItemOptions(); // Rule Condition item var path = XElement.Parse(element.ToString()).FirstAttribute.Value; if (!string.IsNullOrEmpty(path)) { var ruleConditionItem = Context.ContentDatabase.GetItem(path); if (ruleConditionItem != null) { selectItemOptions.FilterItem = ruleConditionItem; } } // Filter templates selectItemOptions.ShowRoot = false; selectItemOptions.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList(IoTMessageProperty.TemplateID.ToString()); // Get Method Item var methodId = element.Attribute("MethodId")?.Value; if (string.IsNullOrEmpty(methodId)) { SheerResponse.Alert("Please select a valid IoT Method"); return; } var methodItem = Context.ContentDatabase.GetItem(methodId); if (methodItem == null) { SheerResponse.Alert("Please select a valid IoT Method"); return; } var method = _ioTHubRepository.CastToMethod(methodItem); // Get Return Type item var returnTypeField = method.ReturnType; if (returnTypeField?.TargetItem == null) { SheerResponse.Alert($"The IoT Method item {methodItem.ID} has an invalid value in the 'Return Type' field"); return; } var returnType = _ioTHubRepository.CastToMessageType(returnTypeField.TargetItem); // Selected Item Item propertyItem = null; if (!string.IsNullOrEmpty(value)) { propertyItem = Context.ContentDatabase.GetItem(value); } // Setup component state selectItemOptions.Root = returnType.InnerItem; selectItemOptions.SelectedItem = propertyItem; selectItemOptions.Title = "Select Property"; selectItemOptions.Text = "Select the property to use in this rule."; selectItemOptions.Icon = "/~/icon/office/32x32/password_field.png"; var parameter = parameters["resulttype"]; if (!string.IsNullOrEmpty(parameter)) { selectItemOptions.ResultType = (SelectItemOptions.DialogResultType)Enum.Parse(typeof(SelectItemOptions.DialogResultType), parameter); } SheerResponse.ShowModalDialog(selectItemOptions.ToUrlString().ToString(), "1200px", "700px", string.Empty, true); }