public Option <Any> Invoke(object obj, Any command, TContext context) { var decodedCommand = ServiceMethod.InputType.ParseFrom(command?.Value); var ctx = new InvocationContext <TContext>(decodedCommand, context); var result = Method.Invoke(obj, Parameters.Select(x => x.Apply(ctx)).ToArray()); return(HandleResult()(result)); }
private void TurnOffThing(AObject obj) { if (!obj.IsSwitch) { Print("这不是一个能够开关的东西。\n\n"); return; } if (!obj.SwitchState) { Print("它已经是关着的了。\n\n"); } else { HandleResult res = CRoom.BeforeTurningOff(CRoom, Variables, obj); if (res == HandleResult.Continue) { res = obj.OnTurningOff(obj, Variables); if (res == HandleResult.Continue) { obj.SwitchState = false; Print("你关闭了它。\n\n"); } } CRoom.PostTurningOff(CRoom, Variables, obj); } }
public async Task <HandleResult> GetSeo([FromBody] JObject form) { string num = form["num"].ToStr(); string columnNum = form["columnNum"].ToStr(); if (num.IsEmpty() || columnNum.IsEmpty()) { return(HandleResult.Error("无效数据")); } var data = await _service.GetByNumAndColumn(columnNum, num); if (data == null) { return(HandleResult.Error("无效数据")); } var content = new ContentData(data); return(HandleResult.Success(new { content.SeoTitle, content.SeoKeyword, content.SeoDesc })); }
public async Task <HandleResult> GetCascaderData(string columnNum, string labelFieldName, string currentFieldName) { var data = await GetDictionaryDataByColumnNum(columnNum); var resData = new List <CascaderDataType>(); if (data.Count > 0) { var firstItem = data[0]; if (!firstItem.ContainsKey(labelFieldName) || !firstItem.ContainsKey(currentFieldName)) { return(HandleResult.Error("无效字段")); } resData = GetCascaderData(data, "", currentFieldName, labelFieldName); } return(new HandleResult { IsSuccess = true, Data = resData }); }
public async Task <HandleResult> Upload(IFormFile file, IFormCollection form = null) { string folderPath = Path.GetFullPath($"wwwroot{GetSaveWebFolderPath()}"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string fileName = file.FileName; string fileExt = Path.GetExtension(fileName); if (ExistBack(fileExt)) { return(HandleResult.Error("非法文件,无法上传")); } if (!ExistWhite(fileExt)) { return(HandleResult.Error("文件后缀不在可信范围内")); } string savePath = GetSavePath(folderPath, fileName, fileExt); await using (var stream = File.Create(savePath)) { await file.CopyToAsync(stream); } return(UploadSuccessAfter(savePath, form)); }
public ActionResult Login(string Name, string Pw) { HandleResult hr = new HandleResult(); if (string.IsNullOrEmpty(Name) || Commons.IsIncludeSqlInjection(Name)) { hr.StatsCode = 103; hr.Message = "姓名不合法"; return(Content(JsonConvert.SerializeObject(hr))); } if (string.IsNullOrEmpty(Pw) || Commons.IsIncludeSqlInjection(Pw)) { hr.StatsCode = 104; hr.Message = "密码不合法"; return(Content(JsonConvert.SerializeObject(hr))); } AdminUserEntity model = AdminUserBLL.GetLoginByName(Name); if (model != null) { if (model.PassWord == Commons.GetMD5Hash(Pw)) { Authentication.SetAuthCookie(model.Id, HttpUtility.UrlEncode(model.UserName, Encoding.GetEncoding("UTF-8"))); hr.StatsCode = 200; hr.Message = "登陆成功"; return(Content(JsonConvert.SerializeObject(hr))); } hr.Message = "用户不存在或密码错误"; return(Content(JsonConvert.SerializeObject(hr))); } hr.Message = "用户不存在或密码错误"; return(Content(JsonConvert.SerializeObject(hr))); }
/// <summary> /// 添加未审核友情链接 /// </summary> /// <param name="blog"></param> /// <returns></returns> public HandleResult <bool> AddFriendshipLink(BlogFriendshipLinkDto friendshipLinkDto) { var handleResult = new HandleResult <bool>(); var friendshipLink = Mapper.Map <BlogFriendshipLink>(friendshipLinkDto); int intcount = _blogFriendshipLinkDAL.GetCount(t => t.FriendshipLinkUrl.Equals(friendshipLink.FriendshipLinkUrl) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted)); if (intcount > 0) { handleResult.Msg = "已经有该站点"; handleResult.Result = false; } else { friendshipLink.CreateTime = DateTime.Now; friendshipLink.EditTime = DateTime.Now; friendshipLink.DeleteSign = (int)DeleteSign.Sing_Deleted; friendshipLink.CreateUserId = Guid.Empty.ToString(); friendshipLink.FriendshipLinkSfsh = (int)Sfsh.Unreviewed; if (Add(friendshipLink)) { handleResult.Msg = "添加成功"; } else { handleResult.Msg = "添加失败"; handleResult.Result = false; } } return(handleResult); }
public async Task <HandleResult> Edit([FromBody] ModelTable model) { var info = model.Id > 0 ? await _service.GetById(model.Id) : new ModelTable(); if (info == null) { return(HandleResult.Error("无效数据")); } bool isUpdate = info.Id > 0; if (!isUpdate) { var verify = await _service.GetByTableName(model.TableName); if (verify != null && verify.Id != info.Id) { return(HandleResult.Error("表名已存在")); } } info.Init(); ReactForm.SetEditModelValue(info, model, isUpdate); var res = isUpdate ? await _service.Update(info) : await _service.Add(info); if (res.IsSuccess && !isUpdate) { _service.CreateTable(info); } return(res); }
public async Task <HandleResult> Edit([FromBody] Column model) { var info = model.Id > 0 ? await _service.GetById(model.Id) : new Column(); if (info == null) { return(HandleResult.Error("无效数据")); } if (model.ParentNum.IsNotEmpty() && string.Equals(info.Num, model.ParentNum, StringComparison.OrdinalIgnoreCase)) { return(HandleResult.Error("无效数据")); } info.Init(); ReactForm.SetEditModelValue(info, model, info.Id > 0); info.SiteNum = model.SiteNum; if (info.ParentNum.IsEmpty()) { info.ParentNum = ""; } var res = info.Id > 0 ? await _service.Update(info) : await _service.Add(info); return(res); }
public async Task <HandleResult> CreateField(ModelField info) { var model = await _modelTableService.GetByNum(info.ModelNum); if (model == null) { return(HandleResult.Error("模型不存在")); } var tableName = $"CMS_U_{model.TableName}"; var count = 0; switch (info.OptionType) { case ReactFormItemType.RangePicker: count += await GetDapper().CreateField($"{info.Name}Start", tableName, info.OptionType); count += await GetDapper().CreateField($"{info.Name}End", tableName, info.OptionType); break; default: count = await GetDapper().CreateField(info.Name, tableName, info.OptionType); break; } return(new HandleResult { IsSuccess = count > 0 }); }
public void Write(HandleResult output) { using (StreamWriter sw = new StreamWriter(path, true, Encoding.Default)) { sw.WriteLine(output); } }
/// <summary> /// 暂离 /// </summary> public void ShortLeave() { int newLogId = -1; clientobject.EnterOutLogData.EnterOutlog.Remark = string.Format("在离开终端刷卡暂时离开,保留{0} {1}号座位{2}分钟", clientobject.EnterOutLogData.Student.AtReadingRoom.Name, clientobject.EnterOutLogData.Student.EnterOutLog.ShortSeatNo, NowReadingRoomState.GetSeatHoldTime(clientobject.EnterOutLogData.Student.AtReadingRoom.Setting.SeatHoldTime, ServiceDateTime.Now)); HandleResult result = EnterOutOperate.AddEnterOutLog(clientobject.EnterOutLogData.EnterOutlog, ref newLogId);//插入进出记录 if (result == HandleResult.Successed) { if (popMessage != null) { popMessage(this, new PopMessage(TipType.ShortLeave, "暂离成功")); } } else { if (popMessage != null) { popMessage(this, new PopMessage(TipType.Exception, "操作失败")); } } }
public void StartRequest(string Url, string method, bool isJSON, CookieContainer cookie, string PostData, HandleResult handle) { if (string.IsNullOrEmpty(method)) { method = "GET"; } this._postData = PostData; this.handle = handle; var webRequest = (HttpWebRequest)WebRequest.Create(Url); if (isJSON) { webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; webRequest.Headers["X-Requested-With"] = "XMLHttpRequest"; } if (cookie != null) { webRequest.CookieContainer = cookie; } webRequest.Method = method; try { webRequest.BeginGetResponse(new AsyncCallback(HandleResponse), webRequest); } catch { } }
protected IActionResult ActionResult(HandleResult result) { return(new JsonResult(result) { StatusCode = (int)result.StatusCode }); }
public async Task <HandleResult> FormFields([FromBody] JObject form) { string columnNum = form["columnNum"].ToStr(); if (columnNum.IsEmpty()) { return(HandleResult.Error("无效数据")); } string parentNum = form["parentNum"].ToStr(); int id = form["id"].ToInt(); var data = id > 0 ? await _service.GetById(columnNum, id) : new Category { ParentNum = parentNum, }; if (data == null) { return(HandleResult.Error("无效数据")); } return(new HandleResult { IsSuccess = true, Data = new { EditData = data, Field = ReactForm.ToFormFields <Category>(data.Id > 0) } }); }
public ActionResult GetPlatFormList(string platForms, decimal percent) { HandleResult hr = new HandleResult(); List <PlatResultEntity> resultList = new List <PlatResultEntity>(); List <BitcoinEntity> platCoinlist = new List <BitcoinEntity>(); List <string> platFormList = platForms.ToStringList(); foreach (var item in platFormList) { RequestEntity requestEnt = new RequestEntity(); requestEnt.postUrl = "https://www.feixiaohao.com/exchange/" + item; requestEnt.method = "get"; requestEnt.host = "www.feixiaohao.com"; string htmlDetail = RequestHelper.ImplementOprater(requestEnt); string msg = ""; List <BitcoinEntity> list = new List <BitcoinEntity>(); bool matchResult = HtmlDetailHelper.HandlePlatFornHtml(item, htmlDetail, ref list, ref msg); if (!matchResult) { LogHelper.LogInfo(item + ": " + msg); continue; } platCoinlist.AddRange(list); } resultList = HtmlDetailHelper.CompareCoinData(platCoinlist, percent); hr.StatsCode = 200; hr.Message = "成功"; hr.Data = resultList; return(Json(hr)); }
public async Task <HandleResult> Edit([FromBody] Site model) { var info = model.Id > 0 ? await _service.GetById(model.Id) : new Site(); if (info == null) { return(HandleResult.Error("无效数据")); } info.Init(); ReactForm.SetEditModelValue(info, model, info.Id > 0); var res = info.Id > 0 ? await _service.Update(info) : await _service.Add(info); if (res.IsSuccess) { if (info.IsDefault) { await _service.RemoveOtherDefault(info.Id); } string siteFolderPath = Path.GetFullPath($"./Views/{info.SiteFolder}"); if (!Directory.Exists(siteFolderPath)) { Directory.CreateDirectory(siteFolderPath); } } return(res); }
public async Task <HandleResult> GetFields([FromBody] JObject form) { string columnNum = form["columnNum"].ToStr(); if (columnNum.IsEmpty()) { return(HandleResult.Error("请选择栏目")); } var column = await _columnService.GetByNum(columnNum); if (column == null) { return(HandleResult.Error("栏目不存在")); } if (column.ModelNum.IsEmpty()) { return(HandleResult.Error("栏目未绑定模型")); } return(new HandleResult { IsSuccess = true, Data = new { fields = await _columnFieldService.GetByColumnNum(columnNum) } }); }
private bool Enter(AObject obj) { if (!obj.IsEnterable) { Print("你没法进入那里。\n\n"); return(false); } if (obj.IsOpenable && !obj.OpenState) { // In case the player automatically attempts to open it but failed Print("你进不去,门还没有打开。\n\n"); return(false); } HandleResult res = obj.OnEntering(obj, Variables); if (res == HandleResult.Continue) { Print($"你走进{obj.Name}。\n\n"); if (CRoom.IsPlayerLit) { // bring player's torch into the next room CRoom.IsPlayerLit = false; obj.RoomTo.IsPlayerLit = true; } Variables.currentRoom = obj.RoomTo; if (CRoom.IsWarm) { Variables.temperature = 0; } DescribeRoom(); } return(true); }
public async Task <HandleResult> Export([FromBody] JObject form) { string columnNum = form["columnNum"].ToStr(); if (columnNum.IsEmpty()) { return(HandleResult.Error()); } var fields = await _columnFieldService.GetByColumnNum(columnNum); var dataResp = await _service.PageByColumn(columnNum, new SqlServerPageRequest { Current = 1, Size = 1000 }); if (dataResp.Data.Count() <= 0) { return(HandleResult.Error("未能查询出数据")); } var fullPath = Path.GetFullPath("wwwroot/Export.xls"); var webPath = $"/temp/数据导出_{DateTime.Now:yyyyMMddHHmmss}.xls"; var saveFullPath = Path.GetFullPath($"wwwroot/{webPath}"); using (var excel = new ExcelUtil(fullPath)) { var column = new ExcelRowItem(); var columnIndex = 0; foreach (var columnField in fields) { column.Add(columnField.Explain, excel.GetColumnLetter(columnIndex)); columnIndex++; } excel.SetRowValue(0, column); var contentData = dataResp.Data.ToList(); excel.CirculateLetterSetValue(1, (dataIndex, row) => { var item = contentData[dataIndex]; var contentDataColumnIndex = 0; foreach (var columnField in fields) { row.Add(item[columnField.Name].ToStr(), excel.GetColumnLetter(contentDataColumnIndex)); contentDataColumnIndex++; } return(contentData.Count - 1 > dataIndex); }); excel.Save(saveFullPath); } return(HandleResult.Success(webPath)); }
public async Task <HandleResult> Clear([FromBody] JArray nums) { if (nums == null || nums.Count <= 0) { return(HandleResult.Error("请选择要清空的数据")); } return(await _service.Clear(nums.Select(temp => temp.ToStr()).ToArray())); }
/// <summary> /// 通知页 /// </summary> /// <returns></returns> protected ActionResult Notification(string message = "您的操作有误", HandleResult result = HandleResult.Error) { return(Notification(new Notification { Message = message, Flag = result }, routeValue: new { area = "Home" })); }
/// <summary> /// 点击关闭 /// </summary> public void CloseButton() { if (WindowClose != null) { OperateResule = HandleResult.None; WindowClose(OperateResule); } }
/// <summary> /// 点击取消 /// </summary> public void CancelButton() { if (WindowClose != null) { OperateResule = HandleResult.Failed; WindowClose(OperateResule); } }
private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { if (_isSave) { HandleResult = new HandleResult(new [] { (Bitmap)_drawingManager.LastRecordedBitmap.Clone() }, true); } SaveCurrentState(); }
/// <summary> /// 点击确认 /// </summary> public void OKButton() { if (WindowClose != null) { OperateResule = HandleResult.Successed; WindowClose(OperateResule); } }
public async Task <HandleResult> Edit(JObject form, string accountNum) { var num = form["num"].ToStr(); var columnNum = form["columnNum"].ToStr(); if (columnNum.IsEmpty()) { return(HandleResult.Error("无效的提交数据")); } var cm = await _columnService.GetModelByNum(columnNum); if (cm == null) { return(HandleResult.Error("无效的提交数据")); } var column = cm?.Column; var model = cm?.ModelTable; var oldData = num.IsEmpty() ? null : await _dapper.GetByNum(model.SqlCategoryTableName, num); var id = oldData?.Id ?? 0; var parentNum = form["parentNum"].ToStr(); if (oldData != null && oldData.Num == parentNum) { return(HandleResult.Error("父类别不能是自身")); } var contentEdit = new DynamicTableSqlHelper(model.SqlCategoryTableName); contentEdit.AddFieldAndValue("Name", form["name"].ToStr()); contentEdit.AddFieldAndValue("ParentNum", parentNum); if (id > 0) { contentEdit.AddFieldAndValue("UpdateAccountNum", accountNum); contentEdit.AddFieldAndValue("UpdateDate", DateTime.Now); } else { contentEdit.AddFieldAndValue("Num", RandomHelper.CreateNum()); contentEdit.AddFieldAndValue("CreateDate", DateTime.Now); contentEdit.AddFieldAndValue("UpdateDate", DateTime.Now); contentEdit.AddFieldAndValue("CreateAccountNum", accountNum); contentEdit.AddFieldAndValue("UpdateAccountNum", accountNum); contentEdit.AddFieldAndValue("IsDel", false); contentEdit.AddFieldAndValue("Status", 0); contentEdit.AddFieldAndValue("SiteNum", column.SiteNum); contentEdit.AddFieldAndValue("ColumnNum", columnNum); } var sql = id > 0 ? contentEdit.GetUpdateSql(id) : contentEdit.GetAddSql(); var res = await _dapper.Execute(sql, contentEdit.GetValue()); return(res > 0 ? HandleResult.Success() : HandleResult.Error("操作失败")); }
public ActionResult doSave(FormCollection form) { HandleResult hr = new HandleResult(); hr.StatsCode = 500; hr.Message = "提交失败"; if (string.IsNullOrWhiteSpace(form["people"])) { hr.Message = "请输入联系人。"; return(Json(hr)); } if (string.IsNullOrWhiteSpace(form["phone"])) { hr.Message = "请输入手机号。"; return(Json(hr)); } else if (!Regex.IsMatch(form["phone"], "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$")) { hr.Message = "手机号码格式不对。"; return(Json(hr)); } if (string.IsNullOrWhiteSpace(form["reason"])) { hr.Message = "请输入推荐原因。"; return(Json(hr)); } else if (form["reason"].ToString().Length > 500) { hr.Message = "推荐原因不能超过500个字符。"; return(Json(hr)); } int stationId = Convert.ToInt32(form["station"]); int collectType = Convert.ToInt32(form["type"]); if (!Enum.IsDefined(typeof(Enums.eStation), stationId)) { hr.Message = "站点不存在。"; return(Json(hr)); } CollectInfoEntity entityCollect = new CollectInfoEntity(); entityCollect.StationId = stationId; entityCollect.CollectType = collectType; entityCollect.UserName = form["people"].Trim(); entityCollect.Phone = form["phone"].Trim(); entityCollect.Reason = form["reason"].Trim(); entityCollect.AddTime = DateTime.Now; CollectInfoBLL.Insert(entityCollect); hr.StatsCode = 200; hr.Message = "提交成功"; return(Json(hr)); }
/// <summary> /// 释放座位 /// </summary> /// <param name="cardNo"></param> /// <returns></returns> public string SeatLeave(string cardNo, string clientNo, string remark) { ReaderInfo reader = null; try { reader = GetReader(cardNo, true); } catch (Exception ex) { throw new Exception("获取读者状态遇到异常"); } if (reader != null) { if (reader.EnterOutLog == null) { throw new Exception("释放座位失败,您还没有选座。"); } switch (reader.EnterOutLog.EnterOutState) { case EnterOutLogType.BookingConfirmation: //预约入座 case EnterOutLogType.SelectSeat: //选座 case EnterOutLogType.ContinuedTime: //续时 case EnterOutLogType.ComeBack: //暂离回来 case EnterOutLogType.ReselectSeat: //重新选座 case EnterOutLogType.WaitingSuccess: //读者通过等待座位入座 case EnterOutLogType.ShortLeave: //读者暂离 reader.EnterOutLog.EnterOutState = EnterOutLogType.Leave; string rem = ",释放" + reader.EnterOutLog.ReadingRoomName + "第" + reader.EnterOutLog.ShortSeatNo + "号座位"; reader.EnterOutLog.Remark = remark + rem; reader.EnterOutLog.Flag = Operation.Reader; reader.EnterOutLog.EnterOutTime = DateTime.Now; reader.EnterOutLog.TerminalNum = clientNo; int newId = -1; HandleResult returnResult = AddEnterOutLogInfo(reader.EnterOutLog, ref newId); if (returnResult == HandleResult.Successed) { return(""); } else { throw new Exception("未知原因释放座位失败"); } case EnterOutLogType.Leave: throw new Exception("您当前没有座位。"); default: throw new Exception("您当前没有座位。"); } } else { throw new Exception("执行遇到错误"); } }
/// <summary> /// 释放座位,返回操作结果 /// </summary> /// <param name="school"></param> /// <param name="reader"></param> /// <returns></returns> public string FreeSeat(string cardNo) { ReaderInfo reader = null; try { reader = seatManage.GetReader(cardNo, true); } catch (Exception ex) { throw new Exception("获取读者状态遇到异常"); } if (reader != null) { if (reader.EnterOutLog == null) { throw new Exception("释放座位失败,您还没有选座。"); } switch (reader.EnterOutLog.EnterOutState) { case EnterOutLogType.BookingConfirmation: //预约入座 case EnterOutLogType.SelectSeat: //选座 case EnterOutLogType.ContinuedTime: //续时 case EnterOutLogType.ComeBack: //暂离回来 case EnterOutLogType.ReselectSeat: //重新选座 case EnterOutLogType.WaitingSuccess: //读者通过等待座位入座 case EnterOutLogType.ShortLeave: //读者暂离 reader.EnterOutLog.EnterOutState = EnterOutLogType.Leave; reader.EnterOutLog.Remark = "读者通过手机客户端释放座位。"; reader.EnterOutLog.Flag = Operation.Reader; reader.EnterOutLog.EnterOutTime = DateTime.Now; int newId = -1; HandleResult returnResult = seatManage.AddEnterOutLogInfo(reader.EnterOutLog, ref newId); if (returnResult == HandleResult.Successed) { return("座位已释放留给下一个读者使用,谢谢。"); } else { throw new Exception("未知原因释放座位失败"); } case EnterOutLogType.Leave: throw new Exception("您当前没有座位。"); default: throw new Exception("您当前没有座位。"); } } else { throw new Exception("执行遇到错误"); } }
public void BeginRequest(HandleResult handle) { if (this.Certificate != null) { //这一句一定要写在创建连接的前面。使用回调的方法进行证书验证。 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CertificateValidation); } this.handle = handle; var webRequest = (HttpWebRequest)System.Net.WebRequest.Create(this.Url); this.SetDefaultOptions(webRequest); try { webRequest.BeginGetResponse(new AsyncCallback(HandleResponse), webRequest); //ThreadPool.QueueUserWorkItem(obj => webRequest.BeginGetResponse(new AsyncCallback(HandleResponse), webRequest)); } catch (ProtocolViolationException protocolViolationException) { throw; } catch (WebException webException) { throw; } catch (InvalidOperationException invalidOperationException) { throw; } finally { if (webRequest != null) { webRequest.Abort(); } } }
public void StartRequest(string Url, HandleResult handle) { this.handle = handle; var webRequest = (HttpWebRequest)WebRequest.Create(Url); webRequest.Method = "GET"; try { webRequest.BeginGetResponse(new AsyncCallback(HandleResponse), webRequest); } catch { } }