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 async Task <ActionResult> SignUpCustomer([FromBody] SignUpViewModel model, [FromHeader(Name = "x-requestid")] string requestId) { var response = new ActionResultModel(); Guid.TryParse(requestId, out Guid guid); var command = new SignUpAsCustomerCommand(model.Email, model.Password); var identifiedCommand = new IdentifiedCommand <SignUpAsCustomerCommand, SignUpResultDto>(command, guid); var result = await _mediator.Send(identifiedCommand); response.Code = result.Code; response.Message = result.Message; if (!result.Succeeded) { response.Data = result.Errors; return(BadRequest(result)); } response.Data = new SignUpResultViewModel { Token = await _authService.GenerateJwtAsync(result.User), User = new UserViewModel { Id = result.User.Id, Email = result.User.Email } }; return(Ok(response)); }
public ActionResultModel DeleteAuthor(int id) { var result = new ActionResultModel(); // Author has books where he is sole author if (_bookRepository.Books.Any(b => b.Authors.Any(a => a.Id == id) && b.Authors.Count == 1)) { result.State = ActionResultState.Error; result.Errors.Add("This author has a book(s), where he is the sole author, so it can not be removed"); } else { if (_authorRepository.GetAuthor(id) != null) { _authorRepository.Delete(id); result.State = ActionResultState.Ok; } else { result.State = ActionResultState.NotFound; result.Errors.Add("Author not found"); } } return(result); }
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); }); }
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 JsonResult DelRange(int[] ids) { ActionResultModel<string> model = new ActionResultModel<string>(); model.isSuccess = ls.DeleteRange(ids); model.respnseInfo = model.isSuccess ? "删除成功" : "删除失败"; return Json(model); }
public JsonResult Add(list list) { ActionResultModel<string> model = new ActionResultModel<string>(); model.isSuccess = ls.Save(list); model.respnseInfo = model.isSuccess ? "添加成功" : "添加失败"; return Json(model); }
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 <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); }); }
/// <summary> /// Возвращает контент популярности /// </summary> private static string GetPopularityString(ActionResultModel result) { var popularityPrefix = string.Empty; switch (result.Action) { case ActionType.NewTrack: case ActionType.Feat: popularityPrefix = "Скачиваний: "; break; case ActionType.NewClip: case ActionType.Battle: popularityPrefix = "Просмотров: "; break; case ActionType.Concert: popularityPrefix = "Посещение: "; break; case ActionType.Traning: return(string.Empty); } return($"{popularityPrefix}{NumberFormatter.FormatValue(result.Popularity)}"); }
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(() => { 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); }); }
/// <summary> /// 上海工资条封面图片 /// </summary> /// <returns></returns> public JsonResult UploadSalaryImg() { var models = new ActionResultModel <string>() { isSuccess = false }; if (Request.Files.Count <= 0) { return(Json(models)); } if (Request.Files[0].ContentLength >= 1000 * 1024) { models.respnseInfo = "文件超过1000M!"; return(Json(models)); } string[] imgType = { ".jpeg", ".jpg", ".bmp", ".gif", ".png" }; if (!imgType.Contains(Path.GetExtension(Request.Files[0].FileName))) { models.respnseInfo = "文件类型不匹配!"; return(Json(models)); } string fileName = DateTime.Now.ToString("yyyyMMddHHmmss"); string saveFolder = Server.MapPath("/Areas/WeChatPush/Views/_img/" + fileName + Path.GetExtension(Request.Files[0].FileName)); Request.Files[0].SaveAs(saveFolder); models.isSuccess = true; models.respnseInfo = "/Areas/WeChatPush/Views/_img/" + fileName + Path.GetExtension(Request.Files[0].FileName); return(Json(models, "text/html")); }
/// <summary> /// 保存角色权限信息 /// </summary> /// <param name="roleModel"></param> /// <param name="permissionList"></param> /// <returns></returns> public JsonResult SaveRole(Sys_Role roleModel, string permissionList, bool isEdit) { List <U_Module> rolePermissionList = new List <U_Module>(); if (!string.IsNullOrEmpty(permissionList)) { rolePermissionList = Common.JsonHelper.JsonToModel <List <U_Module> >(permissionList); rolePermissionList = rolePermissionList.Distinct().ToList(); } var models = new ActionResultModel <string>(); models.isSuccess = false; models.respnseInfo = "0"; if (_al.IsExist_RoleName(roleModel, isEdit)) { models.respnseInfo = "2";//角色名称已经存在 } else { models.isSuccess = _al.SaveRole(roleModel, rolePermissionList, isEdit); if (models.isSuccess) { models.respnseInfo = "1";//保存成功 } else { models.respnseInfo = "0";//保存失败 } } return(Json(models, JsonRequestBehavior.AllowGet)); }
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 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 async Task <ActionResultModel> DeleteKnowledgeBase(string key, string knowledgeBaseId, List <string> sources) { ActionResultModel result = new ActionResultModel(); var uri = Constants.CONITIVE_HOST + Constants.QNA_SERVICE + Constants.QNA_METHOD + knowledgeBaseId; try { var filesSrc = string.Join(',', sources.Select(s => s.AddDoubleQuotes())); // Patch delete existed source var deletePatchJsonFormat = string.Format(KnowledgeBaseTemplate.UPDATE_JSON_FORMAT, string.Empty, Constants.KNOWLEDGE_BASE_NAME.AddDoubleQuotes(), filesSrc); result = await KnowledgeBaseManger.Instance.UpdateKonwledgeBase(key, uri, deletePatchJsonFormat); if (result.ResultStatus != ActionStatus.Success) { result.ResultMessage = "Patch [delete] failed: " + result.ResultMessage; return(result); } } catch (Exception ex) { result.ResultMessage = $"Patch [delete] failed, message: {ex.Message}"; } return(result); }
/// <summary> /// 更新用户部门 /// </summary> /// <param name="vguid">部门Vguid</param> /// <returns></returns> public JsonResult UpdateDepartment(string vguid, string personVguid, string labelStr) { var models = new ActionResultModel <string>(); models.isSuccess = _ul.UpdateDepartment(vguid, personVguid, labelStr); models.respnseInfo = models.isSuccess == true ? "1" : "0"; return(Json(models, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 将支付历史表中营收状态为未匹配的重新插入到营收表(ThirdPartyPublicPlatformPayment)中 /// </summary> /// <param name="vguidList"></param> /// <returns></returns> public JsonResult Insert2Revenue(List <Guid> vguidList) { var models = new ActionResultModel <string>(); models.isSuccess = _weChatRevenueLogic.Insert2Revenue(vguidList); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models)); }
/// <summary> /// 判断推送消息是否过期 /// </summary> /// <param name="pushContentVguid"></param> /// <returns></returns> public JsonResult IsValid(Guid pushContentVguid, string billNo) { var models = new ActionResultModel <string>(); models.isSuccess = _weChatRevenueLogic.IsValid(pushContentVguid, billNo); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models)); }
/// <summary> /// 批量删除草稿知识 /// </summary> /// <param name="vguidList">主键</param> /// <returns></returns> public JsonResult DeleteKnowledgeBase(Guid[] vguidList) { var models = new ActionResultModel <string>(); models.isSuccess = _draftLogic.DeleteKnowledgeBase(vguidList); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models)); }
/// <summary> /// 用户是否已经操作过协议 /// </summary> /// <param name="agreementInfo"></param> /// <returns></returns> public JsonResult IsExistAgreementOperationInfo(Business_ProtocolOperations_Information agreementInfo) { var models = new ActionResultModel <string>(); models.isSuccess = _pl.IsExistAgreementOperationInfo(agreementInfo); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models)); }
public JsonResult DeleteTreeMenuDetail(int id) { var model = new ActionResultModel <string>(); model.isSuccess = _db.Delete <SysBest_MenuAddress>(m => m.Id == id); model.responseInfo = model.isSuccess.IIF("删除菜单详情成功!", "删除菜单详情失败!"); return(Json(model)); }
/// <summary> /// 删除付款历史 /// </summary> /// <param name="vguidList">主键</param> /// <returns></returns> public JsonResult DeletePaymentHistory(List <Guid> vguidList) { var models = new ActionResultModel <string>(); models.isSuccess = _weChatRevenueLogic.DeletePaymentHistory(vguidList); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models, JsonRequestBehavior.AllowGet)); }
public JsonResult EditTreeMenuDetail(SysBest_MenuAddress entity) { var model = new ActionResultModel <string>(); model.isSuccess = _db.Update <SysBest_MenuAddress>(entity); model.responseInfo = model.isSuccess.IIF("编辑菜单详情成功!", "编辑菜单详情失败!"); return(Json(model)); }
/// <summary> /// 删除扫码历史 /// </summary> /// <param name="vguidList"></param> /// <returns></returns> public JsonResult DeletedScanHistory(Guid[] vguidList) { var model = new ActionResultModel <string>(); model.isSuccess = _scanHistoryLogic.DeletedScanHistory(vguidList); model.respnseInfo = model.isSuccess ? "1" : "0"; return(Json(model)); }
public static MvcHtmlString ActionResult(this HtmlHelper html, ActionResultModel model) { INakedObject nakedObject = html.Framework().NakedObjectManager.CreateAdapter(model.Result, null, null); string title = GetCollectionTitle(nakedObject, html); title = model.Action.Name + ": " + (string.IsNullOrWhiteSpace(title) ? nakedObject.Spec.UntitledName : title); return(CommonHtmlHelper.WrapInDiv(title, IdHelper.ObjectName)); }
/// <summary> /// 删除选中的角色列表数据(批量删除) /// </summary> /// <param name="roleTypeVguid"></param> /// <returns></returns> public JsonResult DeleteRoleType(string[] roleTypeVguid) { var models = new ActionResultModel <string>(); models.isSuccess = false; models.isSuccess = _al.DeleteRoleType(roleTypeVguid); return(Json(models, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 批量审核问卷 /// </summary> /// <param name="vguidList"></param> /// <returns></returns> public JsonResult CheckedQuestion(string[] vguidList) { var models = new ActionResultModel <string>(); models.isSuccess = _el.CheckedQuestion(vguidList); models.respnseInfo = models.isSuccess == true ? "1" : "0"; return(Json(models, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 将习题状态变成草稿 /// </summary> /// <param name="vguidList"></param> /// <returns></returns> public JsonResult BackToDraftStatus(List <Guid> vguidList) { var models = new ActionResultModel <string>(); models.isSuccess = _checkedLogic.BackToDraftStatus(vguidList); models.respnseInfo = models.isSuccess ? "1" : "0"; return(Json(models, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 当前人是否推送过 /// </summary> /// <param name="businessPersonnelVguid"></param> /// <param name="wechatMainVguid"></param> /// <returns></returns> public JsonResult IsPushed(string businessPersonnelVguid, string wechatMainVguid) { var model = new ActionResultModel <String>(); model.isSuccess = _wl.IsPushed(businessPersonnelVguid, wechatMainVguid); model.respnseInfo = model.isSuccess ? "1" : "0"; return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult Del(int id) { using (SqlSugarClient db = SugarDao.GetInstance()) { ActionResultModel<string> model = new ActionResultModel<string>(); model.isSuccess = db.Delete<GridTable,int>(id); model.responseInfo = model.isSuccess ? "删除成功" : "删除失败"; return Json(model); } }
public JsonResult Edit(GridTable gt) { using (SqlSugarClient db = SugarDao.GetInstance()) { ActionResultModel<string> model = new ActionResultModel<string>(); string message = string.Empty; var isValid = ValidationSugar.PostValidation("validate_key_grid_index", out message); if (isValid)//后台验证数据完整性 { model.isSuccess = db.Update<GridTable>(gt, it => it.id == gt.id); model.respnseInfo = model.isSuccess ? "编辑成功" : "编辑失败"; } else { model.isSuccess = false; model.respnseInfo = message; } return Json(model); } }
public JsonResult Add(GridTable gt) { using (SqlSugarClient db = SugarDao.GetInstance()) { string message = string.Empty; var isValid = ValidationSugar.PostValidation("validate_key_grid_index", out message); ActionResultModel<string> model = new ActionResultModel<string>(); if (isValid)//后台验证数据完整性 { model.isSuccess = db.Insert(gt) != DBNull.Value; model.responseInfo = model.isSuccess ? "添加成功" : "添加失败"; } else { model.isSuccess = false; model.responseInfo = message; } return Json(model); } }
internal static string ActionResultLink(this HtmlHelper html, string linkText, string actionName, ActionResultModel arm, object titleAttr) { var no = html.Facade().GetObject(arm.Result); string id = Encode(html.Facade().OidTranslator.GetOidTranslation(no)); int pageSize = arm.PageSize; int page = arm.Page; string format = arm.Format; string url = html.GenerateUrl(actionName, html.Facade().GetObjectTypeShortName(arm.Result), new RouteValueDictionary(new { id, pageSize, page, format })); var linkTag = new TagBuilder("a"); linkTag.MergeAttribute("href", url); linkTag.SetInnerText(linkText); if (titleAttr != null) { linkTag.MergeAttributes(new RouteValueDictionary(titleAttr)); } return linkTag.ToString(); }