private void AddNewActionListItem(ActionDescription _actionDescription) { ActionDescription newActionDescription = new ActionDescription { GUID = System.Guid.NewGuid(), DisplayName = _actionDescription.DisplayName, ExecutableActionType = _actionDescription.ExecutableActionType, Preconditions = new WorldStateDescription[_actionDescription.Preconditions.Length], Effects = new WorldStateDescription[_actionDescription.Effects.Length], BaseUtility = _actionDescription.BaseUtility, }; for (int i = 0; i < _actionDescription.Preconditions.Length; ++i) { newActionDescription.Preconditions[i] = new WorldStateDescription(_actionDescription.Preconditions[i]); } for (int i = 0; i < _actionDescription.Effects.Length; ++i) { newActionDescription.Effects[i] = new WorldStateDescription(_actionDescription.Effects[i]); } ActionListItem item = CreateActionListItem(newActionDescription); m_ListItemScrollView.Add(item); item.MarkUnsavedChanges(true); AddUnsavedMarker(); UpdateSelectedListItem(item); }
public static void RunTaskSequenceExport(object sender, ScopeNode scopeNode, ActionDescription action, IResultObject selectedResultObjects, PropertyDataUpdated dataUpdatedDelegate, Status status) { using (XmlReader readerFromString = SecureXml.CreateXmlReaderFromString(selectedResultObjects["Sequence"].StringValue)) { XElement taskSequencePackage = new XElement("TaskSequencePackage", new XElement("PackageID", selectedResultObjects["PackageID"].StringValue), new XElement("BootImageID", selectedResultObjects["BootImageID"].StringValue), new XElement("Category", selectedResultObjects["Category"].StringValue), new XElement("DependentProgram", selectedResultObjects["DependentProgram"].StringValue), new XElement("Description", selectedResultObjects["Description"].StringValue), new XElement("Duration", selectedResultObjects["Duration"].IntegerValue), new XElement("Name", selectedResultObjects["Name"].StringValue), new XElement("SourceDate", selectedResultObjects["SourceDate"].DateTimeValue), new XElement("SequenceData", XElement.Load(readerFromString) ) ); SaveFileDialog saveFileDialog1 = new SaveFileDialog { Filter = "XML files(.xml)|*.xml", Title = "Export Task Sequnce to XML", FileName = selectedResultObjects["PackageID"].StringValue }; saveFileDialog1.ShowDialog(); if (saveFileDialog1.FileName != "") { taskSequencePackage.Save(saveFileDialog1.FileName); } } }
private object GetObjectFromRequest(HttpContext context, ActionDescription action) { HttpRequest request = context.Request; if (action.Parameters[0].ParameterType == typeof(string)) // 参数要求以 string 形式接收 { return(request.ReadInputStream()); } if (action.Parameters[0].ParameterType == typeof(XmlDocument)) // 参数要求以 XmlDocument 形式接收 { string xml = request.ReadInputStream(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); return(doc); } Type destType = action.Parameters[0].ParameterType.GetRealType(); XmlSerializer mySerializer = new XmlSerializer(destType); request.InputStream.Position = 0; StreamReader sr = new StreamReader(request.InputStream, request.ContentEncoding); return(mySerializer.Deserialize(sr)); }
public DeviceProgressDialog(ActionDescription action, IResultObject selectedResultObjects, MethodInfo method) : this() { resultObjects = selectedResultObjects; this.method = method; Title = action.DisplayName; }
public object[] GetMultiObjectsFormString(string input, ActionDescription action) { Dictionary <string, object> dict = JsonConvert.DeserializeObject(input) as Dictionary <string, object>; //if( dict.Count != action.Parameters.Length ) // throw new ArgumentException("客户端提交的数据项与服务端的参数项的数量不匹配。"); object[] parameters = new object[action.Parameters.Length]; for (int i = 0; i < parameters.Length; i++) { string name = action.Parameters[i].Name; object value = (from kv in dict where string.Compare(kv.Key, name, StringComparison.OrdinalIgnoreCase) == 0 select kv.Value).FirstOrDefault(); try { if (value != null) { Type destType = action.Parameters[i].ParameterType.GetRealType(); object parameter = JsonConvert.DeserializeObject(value.ToString(), destType, settings); parameters[i] = parameter; } } catch (Exception ex) { throw new InvalidCastException("数据转换失败,当前参数名:" + name, ex); } } return(parameters); }
/// <summary> /// Initializes a new instance of the <see cref="StopLogActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allDescriptions">All descriptions.</param> public StopLogActionViewModel([NotNull] StopLogAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allDescriptions) : base(action, actionDescriptor, allDescriptions) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(actionDescriptor, "actionDescriptor"); Assert.ArgumentNotNull(allDescriptions, "allDescriptions"); }
public object[] GetMultiObjectsFormString(string input, ActionDescription action) { Dictionary <string, object> dict = jss.DeserializeObject(input) as Dictionary <string, object>; //if( dict.Count != action.Parameters.Length ) // throw new ArgumentException("客户端提交的数据项与服务端的参数项的数量不匹配。"); object[] parameters = new object[action.Parameters.Length]; for (int i = 0; i < parameters.Length; i++) { string name = action.Parameters[i].Name; object value = (from kv in dict where string.Compare(kv.Key, name, StringComparison.OrdinalIgnoreCase) == 0 select kv.Value).FirstOrDefault(); if (value != null) { Type destType = action.Parameters[i].ParameterType.GetRealType(); MethodInfo method = s_methodConvertToType.MakeGenericMethod(destType); object parameter = method.FastInvoke(jss, new object[] { value }); parameters[i] = parameter; } } return(parameters); }
public ActionDescriptionViewModel(ActionDescription actionDescription, IActionRepository actionRepository, IMessenger messenger) { if (actionDescription == null) { throw new ArgumentNullException(nameof(actionDescription)); } if (messenger == null) { throw new ArgumentNullException(nameof(messenger)); } _actionRepository = actionRepository; _messenger = messenger; ActionArgumentIdentifier = actionDescription.ActionArgumentIdentifier; ActionIdentifier = actionDescription.ActionIdentifier; ActionTrigger = actionDescription.ActionTrigger; ActionTypeIdentifier = actionDescription.ActionTypeIdentifier; DeviceIdentifier = actionDescription.DeviceIdentifier; DeviceName = actionDescription.DeviceName; Result = actionDescription.Result; DeleteTaskCommand = new TransactionalCommandTask(DeleteTask); }
// This function will get triggered/executed when a new message is written // on an Azure Queue called queue. public static void ProcessQueueMessage([QueueTrigger("queue")] ActionDescription jsonMessage, TextWriter log) { Console.WriteLine(jsonMessage.Email); SmtpClient client = new SmtpClient(); client.Port = 587; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "smtp.gmail.com"; client.EnableSsl = true; MailMessage mail = new MailMessage(); mail.To.Add(new MailAddress(jsonMessage.Email)); ServerMailSettings serverMail = new ServerMailSettings { Mail = "*****@*****.**", Subject = "test mail subject", Body = "Battery level low", Password = "******" }; mail.From = new MailAddress(serverMail.Mail); mail.Subject = serverMail.Subject; mail.Body = serverMail.Body; client.Credentials = new System.Net.NetworkCredential(serverMail.Mail, serverMail.Password); client.Send(mail); }
protected override async Task OnInitializedAsync() { _actionDetails = await Api.Load <ObjectMemberInstance>(Action.details); _actionDescriptor = await Api.Load <ActionDescription>(_actionDetails.DescribedBy); _name = _actionDescriptor.extensions.friendlyName; }
public ProvisioningModeDialog(IResultObject selectedResultObjects, ActionDescription action, bool selectedMode) { InitializeComponent(); resultObjects = selectedResultObjects; mode = selectedMode; Title = action.DisplayName; }
public object GetObjectFromString(string input, ActionDescription action) { Type destType = action.Parameters[0].ParameterType.GetRealType(); MethodInfo deserialize = s_methodDeserialize.MakeGenericMethod(destType); return(deserialize.FastInvoke(jss, new object[] { input })); }
public static void Show(object sender, ScopeNode scopeNode, ActionDescription action, IResultObject selectedObject, PropertyDataUpdated dataUpdatedDelegate, Status Status) { using (CollevalStatisticsDialog dialog = new CollevalStatisticsDialog(action, scopeNode)) { dialog.ShowDialog(); return; } }
/// <summary> /// アクションを実行します。 /// </summary> /// <param name="target">対象ターゲット</param> /// <param name="action">アクション。Nullの場合は何も実行されません。</param> public static void ExecuteAction <T>(TweetViewModel target, ActionDescription <T> action) { if (action == null) { return; } ExecuteAction(target, (dynamic)action.Action, action.ActionArgs); }
/// <summary> /// Initializes a new instance of the <see cref="SendToWindowActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allActionDescriptions">All action descriptions.</param> public SendToWindowActionViewModel([NotNull] SendToWindowAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allActionDescriptions) : base(action, actionDescriptor, allActionDescriptions) { _action = action; _allDescriptors = allActionDescriptions; _actionsToExecute = new ActionsViewModel(action.ActionsToExecute, allActionDescriptions); _actionsToExecute.PropertyChanged += HandleActionDescriptionChange; }
private static ActionViewModelBase CreateNewActionFromType([NotNull] ActionDescription actionDescription) { Assert.ArgumentNotNull(actionDescription, "actionDescription"); var result = actionDescription.CreateActionViewModel(actionDescription.CreateAction()); Assert.IsNotNull(result, "Specified ActionDescription implementation is not correct."); return(result); }
private object GetObjectFromString(string input, ActionDescription action) { if (action.Parameters[0].ParameterType == typeof(string)) // 参数要求以 string 形式接收 { return(input); } return(JsonExtensions.FromJson(input, action.Parameters[0].ParameterType)); }
private object GetObjectFromString(string input, ActionDescription action) { if (action.Parameters[0].ParameterType == typeof(string)) { return(input); } return(JsonConvert.DeserializeObject(input, action.Parameters[0].ParameterType, DefaultJsonSerializerSettings)); }
protected override async Task OnInitializedAsync() { _format = Property.extensions.format; _propertyDetails = await Api.Load <ObjectMemberInstance>(Property.details); _propertyDescriptor = await Api.Load <ActionDescription>(_propertyDetails.DescribedBy); _friendlyName = _propertyDescriptor.extensions.friendlyName; Logger.LogInformation(_propertyDetails); }
/// <summary> /// Initializes a new instance of the <see cref="DisableGroupActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allDescriptions">All descriptions.</param> public DisableGroupActionViewModel([NotNull] DisableGroupAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allDescriptions) : base(action, actionDescriptor, allDescriptions) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(actionDescriptor, "actionDescriptor"); Assert.ArgumentNotNull(allDescriptions, "allDescriptions"); _action = action; // AllGroups = availableGroups.Where(g => !g.IsBuildIn); }
/// <summary> /// Initializes a new instance of the <see cref="SendTextActionViewModel"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="parameterDescriptions">The parameter descriptions.</param> /// <param name="allDescriptions">All descriptions.</param> public SendTextActionViewModel([NotNull] SendTextAction action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ParameterDescription> parameterDescriptions, [NotNull] IEnumerable <ActionDescription> allDescriptions) : base(action, actionDescriptor, parameterDescriptions, allDescriptions) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(actionDescriptor, "actionDescriptor"); Assert.ArgumentNotNull(parameterDescriptions, "parameterDescriptions"); Assert.ArgumentNotNull(allDescriptions, "allDescriptions"); _action = action; }
public LAPSDialog(IResultObject selectedResultObjects, ActionDescription action) { InitializeComponent(); resultObjects = selectedResultObjects; Title = action.DisplayName + ": " + resultObjects["Name"].StringValue; Updater.CheckUpdates(); }
private void ChangeActionType([NotNull] ActionViewModelBase action, [NotNull] ActionDescription newactiontype) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(newactiontype, "newactiontype"); var currentIndex = Actions.IndexOf(action); RemoveAction(action); AddAction(newactiontype, currentIndex); OnPropertyChanged("ActionsCollectionEmpty"); }
public void Write(StringBuilder builder, ActionDescription actionDescription) { if (builder == null || actionDescription == null) { return; } Write(builder, actionDescription.IndentLevel); builder.Append(actionDescription.TextContent); Write(builder, actionDescription.EndLine); }
/// <summary> /// Initializes a new instance of the <see cref="ActionViewModelBase"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="actionDescriptor">The action descriptor.</param> /// <param name="allActionDescriptions">All action descriptions.</param> protected ActionViewModelBase([NotNull] ActionBase action, [NotNull] ActionDescription actionDescriptor, [NotNull] IEnumerable <ActionDescription> allActionDescriptions) { Assert.ArgumentNotNull(action, "action"); Assert.ArgumentNotNull(actionDescriptor, "actionDescriptor"); Assert.ArgumentNotNull(allActionDescriptions, "allActionDescriptions"); _actionDescriptor = actionDescriptor; Action = action; AllActionDescriptions = allActionDescriptions; }
public object GetObjectFromRequest(HttpRequest request, ActionDescription action) { Type destType = action.Parameters[0].ParameterType.GetRealType(); XmlSerializer mySerializer = new XmlSerializer(destType); request.InputStream.Position = 0; StreamReader sr = new StreamReader(request.InputStream, request.ContentEncoding); return(mySerializer.Deserialize(sr)); }
protected override async Task OnInitializedAsync() { // logger.LogInformation(Context); action = await this.Api.Load <ObjectActionInstance>(Context.details); descriptor = await this.Api.Load <ActionDescription>(action.DescribedBy); friendlyName = descriptor.extensions.friendlyName; //logger.LogInformation("descriptor"); //logger.LogInformation(descriptor); }
public object GetObjectFromString(string input, ActionDescription action) { if (action.Parameters[0].ParameterType == typeof(string)) { return(input); } Type destType = action.Parameters[0].ParameterType.GetRealType(); return(Newtonsoft.Json.JsonConvert.DeserializeObject(input, destType, settings)); }
private static ActionViewModelBase CreateNewActionFromType([NotNull] ActionDescription actionDescription) { Assert.ArgumentNotNull(actionDescription, "actionDescription"); var action = actionDescription.CreateAction(); Assert.IsNotNull(action, "ActionDescription failed to create Action."); var result = actionDescription.CreateActionViewModel(action); Assert.IsNotNull(result, "Failed to create ActionViewModel from ActionDescription."); return(result); }
private string GetActionButtonName(ActionDescription action) { //indicate hotkey by using underscore var idx = action.Name.ToLower().IndexOf(char.ToLower(action.HotKey)); //the first upper case character becomes the key return(idx > 0 //lower everything up to the index, upper the index then add the rest ? action.Name.Substring(0, idx).ToLower() + char.ToUpper(action.HotKey) + (action.Name.Length == idx ? "":action.Name.Substring(idx + 1)): action.Name); }