public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { var p = ObjectConvert.Get <StartProcessActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, string>(); result.Result.Add((int)StartProcessResultType.IsSuccess, "false"); result.Result.Add((int)StartProcessResultType.Handle, ""); result.Result.Add((int)StartProcessResultType.Id, ""); p.Path = ActionParameterConverter.ConvertToString(taskID, p.Path); p.Args = ActionParameterConverter.ConvertToString(taskID, p.Args); Debug.WriteLine("启动进程:" + p.Path); try { ProcessStartInfo psi = new ProcessStartInfo(p.Path, p.Args); var res = Process.Start(psi); if (res != null) { result.Result[(int)StartProcessResultType.Handle] = res.Handle.ToString(); result.Result[(int)StartProcessResultType.Id] = res.Id.ToString(); } result.Result[(int)StartProcessResultType.IsSuccess] = "true"; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); }); }
private void ImportGroupAction(Core.Action.Models.ActionModel action, int parentID = 0) { //创建头 var builder = ActionBuilder.BuilderByAction(action); var actionModel = builder.GetActionItemModel(); var a = action.Parameter as BaseGroupActionParamsModel; var parameter = ObjectConvert.Get <BaseGroupActionParamsModel>(action.Parameter); actionModel.ParentID = parentID; AddItem(actionModel, builder); //创建action子级 if (parameter.Actions.Count > 0) { foreach (var item in parameter.Actions) { ImportAction(item, actionModel.ID); } } //创建end action var endActionModel = ActionData.GetCreateActionItemModel(UI.Types.ActionType.LoopsEnd); endActionModel.ID = GetCreateActionID(); endActionModel.ParentID = actionModel.ID; AddItem(endActionModel); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { var p = ObjectConvert.Get <OpenURLActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, string>(); result.Result.Add((int)CommonResultKeyType.IsSuccess, "false"); p.URL = ActionParameterConverter.ConvertToString(taskID, p.URL); try { ProcessStartInfo psi = new ProcessStartInfo { FileName = p.URL, UseShellExecute = true }; Process.Start(psi); result.Result[(int)CommonResultKeyType.IsSuccess] = "true"; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <DownloadFileParamsModel>(action.Parameter); p.Url = ActionParameterConverter.ConvertToString(taskID, p.Url); p.SavePath = ActionParameterConverter.ConvertToString(taskID, p.SavePath); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)DownloadFileResultType.IsSuccess, false); result.Result.Add((int)DownloadFileResultType.SavePath, p.SavePath); try { var wc = new WebClient(); foreach (var item in p.Headers) { wc.Headers.Add(item.Key, item.Value); } wc.DownloadFile(p.Url, p.SavePath); result.Result[(int)DownloadFileResultType.IsSuccess] = true; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <LoopsActionParamsModel>(action.Parameter); int i = 0; if (p.Count <= 0) { p.Count = 1; } var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)LoopsResultType.Index, "1"); ActionTaskResulter.Add(taskID, result); while (true) { result.Result[(int)LoopsResultType.Index] = i.ToString(); ActionTask.Invoke(taskID, p.Actions, taskID == ActionTask.TestTaskID, true); i++; if (i == p.Count) { break; } } OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { var p = ObjectConvert.Get <SnippingActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, string>(); result.Result.Add((int)SnippingResultType.IsSuccess, "false"); result.Result.Add((int)SnippingResultType.SavePath, p.SavePath); p.SavePath = ActionParameterConverter.ConvertToString(taskID, p.SavePath); try { var sr = CommonWin32API.GetScreenResolution(); Bitmap bitmap = new Bitmap(sr.Width, sr.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(sr.Width, sr.Height)); EncoderParameters encoderParams = new EncoderParameters(); EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, new long[] { 100 }); encoderParams.Param[0] = encoderParam; var codecInfo = ImageCodecInfo.GetImageEncoders().FirstOrDefault(ici => ici.MimeType == "image/jpeg"); bitmap.Save(p.SavePath, codecInfo, encoderParams); result.Result[(int)SnippingResultType.IsSuccess] = "true"; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { var p = ObjectConvert.Get <WriteFileActionParameterModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, string>(); result.Result.Add((int)CommonResultKeyType.IsSuccess, "false"); p.FilePath = ActionParameterConverter.ConvertToString(taskID, p.FilePath); p.Content = ActionParameterConverter.ConvertToString(taskID, p.Content); Debug.WriteLine("write file:" + p.FilePath); try { File.WriteAllText(p.FilePath, p.Content); result.Result[(int)CommonResultKeyType.IsSuccess] = "true"; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <SystemNotificationActionParamsModel>(action.Parameter); p.Title = ActionParameterConverter.ConvertToString(taskID, p.Title); p.Content = ActionParameterConverter.ConvertToString(taskID, p.Content); p.Icon = ActionParameterConverter.ConvertToString(taskID, p.Icon); p.Url = ActionParameterConverter.ConvertToString(taskID, p.Url); try { NotificationService notificationService = new NotificationService(); notificationService.ShowNotification(p.Title, p.Content, p.ToastScenarioType, p.Icon, p.ToastActionType, p.Url); } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 //ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { this.taskID = taskID; actionID = action.ID; return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <DialogActionParamsModel>(action.Parameter); p.Title = ActionParameterConverter.ConvertToString(taskID, p.Title); p.Content = ActionParameterConverter.ConvertToString(taskID, p.Content); p.Image = ActionParameterConverter.ConvertToString(taskID, p.Image); try { callID = new Random().Next(9999) + DateTime.Now.Second; PipeCallFunction.Call(new Structs.PipeCallFunctionStruct() { ID = callID, CallFunctionType = UI.Types.PipeCallFunctionType.Dialog, Data = p }); PipeCallFunction.OnCallFeedback += PipeCallFunction_OnCallFeedback; } catch (Exception e) { OnEventStateChanged?.Invoke(taskID, actionID, ActionInvokeStateType.Done); LogHelper.Error(e.ToString()); } }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <JsonDeserializeActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)CommonResultKeyType.IsSuccess, false.ToString()); p.Content = ActionParameterConverter.ConvertToString(taskID, p.Content); Debug.WriteLine("JsonDeserialize:" + p.Content); try { //尝试用正则表达式取出有效范围 var regx = Regex.Match(p.Content, @"\{([\s\S]*)\}"); if (regx.Success) { p.Content = regx.Value; } result.Result[-1] = JsonConvert.DeserializeObject <object>(p.Content); result.Result[(int)CommonResultKeyType.IsSuccess] = true; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <SoundPlayActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)CommonResultKeyType.IsSuccess, false); p.Path = ActionParameterConverter.ConvertToString(taskID, p.Path); try { PlaySound(p.Path); result.Result[(int)CommonResultKeyType.IsSuccess] = true; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public static object GetObj(ProjectModel project) { var res = project.ConditionData; switch ((EventType)project.EventID) { case EventType.OnProcessCreated: res = ObjectConvert.Get <ProcessCreatedConditionModel>(project.ConditionData); break; case EventType.OnIntervalTimer: res = ObjectConvert.Get <IntervalTimerConditionModel>(project.ConditionData); break; case EventType.OnFileChanged: res = ObjectConvert.Get <FileChangedConditionModel>(project.ConditionData); break; case EventType.OnTimeChanged: res = ObjectConvert.Get <TimeChangedConditionModel>(project.ConditionData); break; case EventType.WIFIConnectedEvent: res = ObjectConvert.Get <WIFIConnectedEventConditionModel>(project.ConditionData); break; case EventType.BluetoothEvent: res = ObjectConvert.Get <BluetoothEventConditionModel>(project.ConditionData); break; } return(res); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <ReadFileActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)ReadFileResultType.IsSuccess, false); result.Result.Add((int)ReadFileResultType.Content, string.Empty); p.FilePath = ActionParameterConverter.ConvertToString(taskID, p.FilePath); Debug.WriteLine("read file:" + p.FilePath); try { result.Result[(int)ReadFileResultType.Content] = File.ReadAllText(p.FilePath); result.Result[(int)ReadFileResultType.IsSuccess] = true; } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <RegexActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)RegexResultType.Count, "0"); p.Content = ActionParameterConverter.ConvertToString(taskID, p.Content); try { var matchs = Regex.Matches(p.Content, p.Regex); int i = 0; foreach (Match match in matchs) { result.Result.Add(i, match.Value); i++; } result.Result[(int)RegexResultType.Count] = matchs.Count.ToString(); } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <GetIPAddressActionParamsModel>(action.Parameter); var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, object>(); result.Result.Add((int)GetIPAddressResultType.IsSuccess, false); result.Result.Add((int)GetIPAddressResultType.IP, string.Empty); try { if (p.Type == Core.Types.IPAddressType.LocalIPV4) { //获取内网ipv4 var host = Dns.GetHostEntry(Dns.GetHostName()); string ipaddress = string.Empty; foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ipaddress = ip.ToString(); } } if (!string.IsNullOrEmpty(ipaddress)) { result.Result[(int)GetIPAddressResultType.IsSuccess] = true; result.Result[(int)GetIPAddressResultType.IP] = ipaddress; } } else if (p.Type == Core.Types.IPAddressType.PublicIPV4 && System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { //获取公网ipv4 var httprequest = new HttpRequest(); httprequest.Url = "https://202020.ip138.com/"; httprequest.Headers = new Dictionary <string, string>(); httprequest.Headers.Add("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1"); string html = httprequest.GetAsync().Result.Content; var reg = Regex.Match(html, @"(?<ip>(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d))"); if (reg.Success && !string.IsNullOrEmpty(reg.Groups["ip"].Value)) { result.Result[(int)GetIPAddressResultType.IsSuccess] = true; result.Result[(int)GetIPAddressResultType.IP] = reg.Groups["ip"].Value; } } } catch (Exception e) { LogHelper.Error(e.ToString()); } //返回数据 ActionTaskResulter.Add(taskID, result); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
private void GetIFChildrenMaxID(Core.Action.Models.ActionModel action) { var parameter = ObjectConvert.Get <IFActionParameterModel>(action.Parameter); foreach (var paction in parameter.PassActions.Concat(parameter.NoPassActions)) { GetMaxID(paction); } }
private void GetGroupChildrenMaxID(Core.Action.Models.ActionModel action) { var parameter = ObjectConvert.Get <BaseGroupActionParamsModel>(action.Parameter); foreach (var paction in parameter.Actions) { GetMaxID(paction); } }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <DelayActionParamsModel>(action.Parameter); Task.Delay(p.Seconds * 1000).Wait(); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { bool isPass = false; var p = ObjectConvert.Get <IFActionParameterModel>(action.Parameter); string left, right; //获取左输入 left = ActionParameterConverter.ConvertToString(taskID, p.LeftInput); //获取右输入 right = ActionParameterConverter.ConvertToString(taskID, p.RightInput); switch (p.Condition) { case Types.IFActionConditionType.Equal: isPass = left == right; break; case Types.IFActionConditionType.UnEqual: isPass = left != right; break; case Types.IFActionConditionType.Has: isPass = left.IndexOf(right) != -1; break; case Types.IFActionConditionType.Miss: isPass = left.IndexOf(right) == -1; break; } if (isPass) { ActionTask.Invoke(taskID, p.PassActions, taskID == ActionTask.TestTaskID, true); } else { ActionTask.Invoke(taskID, p.NoPassActions, taskID == ActionTask.TestTaskID, true); } var result = new ActionResultModel(); result.ID = action.ID; result.Result = new Dictionary <int, string>(); result.Result.Add((int)CommonResultKeyType.IsSuccess, isPass.ToString()); //result.Result = new Dictionary<int, ActionResultValueModel>(); //result.Result.Add((int)CommonResultKeyType.Status, new ActionResultValueModel() //{ // Type = ActoinResultValueType.BOOL, // Value = isPass //}); //返回数据 ActionTaskResulter.Add(taskID, result); }); }
public System.Action GenerateAction(int taskID, ActionModel action) { return(() => { OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Runing); var p = ObjectConvert.Get <SetDeviceVolumeActionParamsModel>(action.Parameter); p.Volume = ActionParameterConverter.ConvertToString(taskID, p.Volume); AudioHelper.SetMasterVolume(int.Parse(p.Volume)); OnEventStateChanged?.Invoke(taskID, action.ID, ActionInvokeStateType.Done); }); }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <JsonDeserializeActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as JsonDeserializeActionInputModel; data.Content = parameter.Content; } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <OpenURLActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as OpenURLActionInputModel; data.URL = parameter.URL; } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <DelayActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as DelayActionInputModel; data.Seconds = parameter.Seconds.ToString(); } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <SetDeviceVolumeActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as SetDeviceVolumeActionInputModel; data.Volume = parameter.Volume; } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <GetIPAddressActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as GetIPAddressActionInputModel; data.Type = GetIPAddressActionData.GetIPAddressType((int)parameter.Type); } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <ReadFileActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as ReadFileActionInputModel; data.FilePath = parameter.FilePath; } }
public bool IsCheck() { var p = ObjectConvert.Get <WriteFileActionParameterModel>(parameter); if (p == null) { return(false); } else if (p.FilePath == string.Empty) { return(false); } return(true); }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <KillProcessActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as KillProcessActionInputModel; data.ProcessName = parameter.ProcessName; data.IsFuzzy = parameter.IsFuzzy; } }
public void ImportAction(Core.Action.Models.ActionModel action) { this.action = action; //构建ui action actionItem.ID = action.ID; var parameter = ObjectConvert.Get <StartProcessActionParamsModel>(action.Parameter); if (parameter != null) { var data = inputData as StartProcessActionInputModel; data.Path = parameter.Path; data.Args = parameter.Args; } }
private void ImportIFAction(Core.Action.Models.ActionModel action) { if (action.Action != Core.Action.Types.ActionType.IF) { return; } //创建if action var builder = ActionBuilder.BuilderByAction(action); var ifActionModel = builder.GetActionItemModel(); var ifParameter = ObjectConvert.Get <IFActionParameterModel>(action.Parameter); //var ifParameter = ObjectConvert.Get<IFActionParameterModel>(action.Parameter); //var ifActionModel = ActionData.GetCreateActionItemModel(UI.Types.ActionType.IF); //ifActionModel.ID = action.ID; //var ifActionInputData = new IFActionInputModel(); //ifActionInputData.Left = ifParameter.LeftInput; //ifActionInputData.Right = ifParameter.RightInput; //ifActionInputData.Condition = IFActionConditionData.GetCombox((int)ifParameter.Condition); AddItem(ifActionModel, builder); //创建pass子级 if (ifParameter.PassActions.Count > 0) { foreach (var passaction in ifParameter.PassActions) { ImportAction(passaction, ifActionModel.ID); } } //创建else action var elseActionModel = ActionData.GetCreateActionItemModel(UI.Types.ActionType.IFElse); elseActionModel.ID = GetCreateActionID(); elseActionModel.ParentID = ifActionModel.ID; AddItem(elseActionModel); //创建unpass子级 if (ifParameter.NoPassActions.Count > 0) { foreach (var passaction in ifParameter.NoPassActions) { ImportAction(passaction, ifActionModel.ID); } } //创建end action var endActionModel = ActionData.GetCreateActionItemModel(UI.Types.ActionType.IFEnd); endActionModel.ID = GetCreateActionID(); endActionModel.ParentID = ifActionModel.ID; AddItem(endActionModel); }