public DataSet ExecuteQuery(EDtxReaderType type, int timeout, string cmdText, ParamHelper[] paramList, ref TimeSpan span) { DataSet retv = new DataSet(); if(string.IsNullOrWhiteSpace(usernameTB.Text)) { MessageBox.Show("Username is required"); return retv; } if (string.IsNullOrWhiteSpace(passwordTB.Text)) { MessageBox.Show("Password is required"); return retv; } if (EncryptionRequired) { if (string.IsNullOrWhiteSpace(encryptTB.Text)) { MessageBox.Show("EncryptionKey is required"); return retv; } if (string.IsNullOrWhiteSpace(decryptTB.Text)) { MessageBox.Show("DecryptionKey is required"); return retv; } } IDbConnection conn = QueryHelper.GetConnection(type, usernameTB.Text, passwordTB.Text, encryptTB.Text, decryptTB.Text); if (conn != null) { retv = QueryHelper.ExecuteSelect(type, timeout, conn, cmdText, paramList, ref span); } return retv; }
internal void SetParams(ParamHelper[] value) { clearParamsBtn_Click(null, null); foreach(ParamHelper ph in value) { ParameterItem pi = BuildNewParam(); pi.SetParamDetails( ph); } }
public ActionResult GetProjectAttachmentList() { try { var queryParams = new NameValueCollection(); if (!ParamHelper.CheckParaQ(ref queryParams)) { return(Json(new ResponseEntity <int>(RegularFunction.RegularSqlRegexText), JsonRequestBehavior.AllowGet)); } var query = new ProjectAttachmentQuery(queryParams); var sqlCondition = new StringBuilder(); sqlCondition.Append("ISNULL(IsDelete,0)!=1"); PageRequest preq = new PageRequest { TableName = " [ProjectAttachment] ", Where = sqlCondition.ToString(), Order = " Id DESC ", IsSelect = true, IsReturnRecord = true, PageSize = query.PageSize, PageIndex = query.PageIndex, FieldStr = "*" }; var result = new ProjectAttachmentBLL().GetDataByPage(preq); var response = new ResponseEntity <object>(true, string.Empty, new DataGridResultEntity <ProjectAttachment> { TotalRecords = preq.Out_AllRecordCount, DisplayRecords = preq.Out_PageCount, ResultData = result }); return(Json(response, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new ResponseEntity <object>(-999, string.Empty, ""), JsonRequestBehavior.AllowGet)); } }
public IActionResult GetTradeHistory(long UserId) { StockAccount stockAccount = db.StockAccounts.FirstOrDefault(s => s.UserId == UserId); if (stockAccount == null) { return(Json(new { code = 400, message = "没有数据" })); } else { List <TradeHistory> tradeHistories = db.TradeHistories.Where(s => s.StockAccountId == stockAccount.Id).ToList(); if (tradeHistories.Count == 0) { return(Json(new { code = 400, message = "没有数据" })); } else { return(Json(new { code = 200, data = tradeHistories.OrderByDescending(s => s.TradeTime).Select(s => new { s.Id, s.StockCode, s.StockName, TransactionType = s.TransactionType.ToString(), s.TransactionValue, s.TransactionPrice, s.TransactionAmount, TradeTime = ParamHelper.TalkTimeConvert(s.TradeTime) }) })); } } }
public ActionResult GetBackUserInfoList() { if (CurrenUserInfo == null) { return(Json(new ResponseEntity <dynamic>(-2, "无权限", null), JsonRequestBehavior.AllowGet)); } var queryParams = new NameValueCollection(); if (!ParamHelper.CheckParaQ(ref queryParams)) { return(Json(new ResponseEntity <int>(RegularFunction.RegularSqlRegexText), JsonRequestBehavior.AllowGet)); } var query = new UserInfoQuery(queryParams); var sqlCondition = new StringBuilder(); sqlCondition.Append("ISNULL(IsDelete,0)!=1"); PageRequest preq = new PageRequest { TableName = " [BackUserInfo] ", Where = sqlCondition.ToString(), Order = " Id DESC ", IsSelect = true, IsReturnRecord = true, PageSize = query.PageSize, PageIndex = query.PageIndex, FieldStr = "*" }; var result = new BackUserInfoBLL().GetDataByPage(preq); var response = new ResponseEntity <object>(true, string.Empty, new DataGridResultEntity <BackUserInfo> { TotalRecords = preq.Out_AllRecordCount, DisplayRecords = preq.Out_PageCount, ResultData = result }); return(Json(response, JsonRequestBehavior.AllowGet)); }
private void StyleInfo() { var cfg = ParamHelper.PlatformCfgData; for (var i = 0; i < cfg.SignList.Count; i++) { switch (i) { case 0: cfg.SignList[i].Prec = GetFloat("first"); break; case 1: cfg.SignList[i].Prec = GetFloat("second"); break; case 2: cfg.SignList[i].Prec = GetFloat("third"); break; } } cfg.ServiceProtocol = GetString("sp"); cfg.DevInfo = GetString("di"); cfg.SpecialExplain = GetString("se"); //List<ParamHelper.SignTypeItem> items = new List<ParamHelper.SignTypeItem>(); //items.Add(new ParamHelper.SignTypeItem() //{ // Id = signList.First().Id, // Name = signList.First().Name, // Prec = GetFloat("first") //}); //items.Add(new ParamHelper.SignTypeItem() //{ // Id = signList.First().Id, // Name = signList.First().Name, // Prec = GetFloat("second") //}); //items.Add(new ParamHelper.SignTypeItem() //{ // Id = signList.First().Id, // Name = signList.First().Name, // Prec = GetFloat("third") //}); ParamHelper.UpdateParamvalue("PlatformCfg", ParamHelper.PlatformCfgData); }
/// <summary> /// Executes a call to a language binding class. /// </summary> /// <param name="expr"></param> /// <returns></returns> public object VisitBindingCall(BindingCallExpr expr) { var method = expr.Name; // 1. Resolve the parameters. ParamHelper.ResolveParametersToHostLangValues(expr.ParamListExpressions, expr.ParamList, this); // 2. Push call into stack expr.Ctx.State.Stack.Push(expr.FullName, null); // 3. Call language binding method/function. var binding = new MetaCompiler(); binding.Ctx = expr.Ctx; var result = binding.ExecuteFunction(method, new object[] { expr }); result = FunctionHelper.CheckConvert(result); // 4. Pop the call stack expr.Ctx.State.Stack.Pop(); return(result); }
public void GetTransactions(DateTime date) { var molpayMembers = GetAPIRequests(date); foreach (var member in molpayMembers) { var transactionRequest = new TransactionAPIRequest(); try { transactionRequest.merchantID = member.MerchantId; transactionRequest.rdate = date.ToString("yyyy-MM-dd"); transactionRequest.skey = Encryptor.ToMD5(transactionRequest.rdate + transactionRequest.merchantID + member.VerifyKey).ToLower(); transactionRequest.ResponseData = APIHelper.Get(_url + ParamHelper.ObjToURL(transactionRequest)); var response = JsonConvert.DeserializeObject <List <TransactionAPIResponse> >(transactionRequest.ResponseData); AddMolPayTransaction(response, member); } catch (Exception ex) { Logger.AddLog(transactionRequest.ResponseData, ex.Message); } } }
public HttpResponseMessage SendNewsComment(long NewsId, long UserId, string Point) { IDatabase redisDatabase = RedisHelper.Value.Database; string NewsComment_Key = "NewsId=" + NewsId.ToString() + "&CommentNumber"; NewsComment newsComment = new NewsComment(); User commenter = db.Users.FirstOrDefault(s => s.Id == UserId); try { newsComment.News = db.News.FirstOrDefault(s => s.Id == NewsId); newsComment.NewsId = NewsId; newsComment.UserId = UserId; newsComment.Point = Point; newsComment.Commenter = commenter.Username; newsComment.CommentTime = DateTime.Now; db.NewsComments.Add(newsComment); db.SaveChanges(); redisDatabase.StringIncrement(NewsComment_Key, 1); string NewsComment_Praise_Key = "NewsCommentId=" + newsComment.Id.ToString() + "&PraiseNumber"; redisDatabase.StringSet(NewsComment_Praise_Key, 0); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(ApiResponse.BadRequest("评论失败!")); } return(ApiResponse.Ok(new { newsComment.Id, newsComment.NewsId, newsComment.UserId, NewsCommentTime = ParamHelper.TalkTimeConvert(newsComment.CommentTime), newsComment.Point, newsComment.Commenter, StockAge = "股龄" + commenter.StockAge, commenter.ImageUrl })); }
public void Test_CheckParamEmptyOrNull() { ParamHelper.CheckParamEmptyOrNull("param", "test0", "info0"); var ex = Assert.Throws <ArgumentException>(() => ParamHelper.CheckParamEmptyOrNull(null, "test", "info")); Assert.NotNull(ex); Assert.Equal("test", ex.ParamName); Assert.True(ex.Message.Contains("info")); Assert.True(ex.Message.Contains("test")); ex = Assert.Throws <ArgumentException>(() => ParamHelper.CheckParamEmptyOrNull(string.Empty, "test2", "info2")); Assert.NotNull(ex); Assert.True(ex.Message.Contains("info2")); Assert.True(ex.Message.Contains("test2")); ex = Assert.Throws <ArgumentException>(() => ParamHelper.CheckParamEmptyOrNull("", "test3", "info3")); Assert.NotNull(ex); Assert.Equal("test3", ex.ParamName); Assert.True(ex.Message.Contains("info3")); Assert.True(ex.Message.Contains("test3")); }
public void RuleSet(string ruleSet, Action <IValidatorBuilder <T> > action) { ParamHelper.CheckParamEmptyOrNull(ruleSet, "ruleSet", "Can't be null"); ParamHelper.CheckParamNull(action, "action", "Can't be null"); var upRuleSet = ruleSet.ToUpper(); var updateRuleSet = new NotifyCollectionChangedEventHandler <IValidateRuleBuilder>((o, e) => { if (e.Action != NotifyCollectionChangedAction.Add) { return; } foreach (var item in e.NewItems) { item.RuleSet = upRuleSet; } }); Builders.CollectionChanged += updateRuleSet; action(this); Builders.CollectionChanged -= updateRuleSet; }
public Task <IValidateResult> ValidateAsync(ValidateContext context) { ParamHelper.CheckParamNull(context, "context", "Can't be null"); var list = context.RuleSetList; if (!list.IsEmptyOrNull()) { context.RuleSetList = list.Where(i => !string.IsNullOrEmpty(i)).Select(i => i.ToUpper()).ToArray(); } var rules = m_Rules.Where(i => context.RuleSelector.CanExecute(i, context)).ToArray(); var result = Validation.Provider.GetService <IValidateResult>(); if (!rules.IsEmptyOrNull()) { var tasks = rules.Select(async i => await i.ValidateAsync(context)).ToArray(); var failures = tasks.Where(i => i.IsCompleted) .SelectMany(i => i.Result.Failures); result.Merge(failures); } return(Task.FromResult(result)); }
/// <summary> /// Call a function by passing in all the values. /// </summary> /// <param name="functionName">The name of the function to call.</param> /// <param name="paramListExpressions">List of parameters as expressions to evaluate first to actual values</param> /// <param name="paramVals">List to store the resolved paramter expressions. ( these will be resolved if paramListExpressions is supplied and resolveParams is true. If /// resolveParams is false, the list is assumed to have the values for the paramters to the function.</param> /// <param name="resolveParams">Whether or not to resolve the list of parameter expression objects</param> /// <returns></returns> public object CallByName(string functionName, List <Expr> paramListExpressions, List <object> paramVals, bool resolveParams) { var function = GetByName(functionName); var hasParams = paramListExpressions != null && paramListExpressions.Count > 0; // 1. Resolve parameters if necessary if (resolveParams && function != null && (function.HasArguments || hasParams)) { ParamHelper.ResolveParametersForScriptFunction(function.Meta, paramListExpressions, paramVals); } function.ArgumentValues = paramVals; function.Evaluate(); object result = null; if (function.HasReturnValue) { result = function.ReturnValue; } else { result = LObjects.Null; } return(result); }
public HttpResponseMessage GetRealtimeSingleStockQuotation(string CodeorName) { JObject jObject = null; ParamHelper paramHelper = new ParamHelper(); string Code = CodeorName; if (paramHelper.HaveHanZi(Code) || paramHelper.HaveEnglish(Code)) { Stock tempStock = db.Stocks.FirstOrDefault(s => s.StockName == Code); if (tempStock == null) { return(ApiResponse.NotFound("未找到数据,请输入股票代码试试!")); } Code = tempStock.StockCode; } try { String res = new ShowApiRequest("http://route.showapi.com/131-44", "138438", "dd520f20268747d4bbda22ac31c9cbdf") .addTextPara("code", "600887") .addTextPara("need_k_pic", "0") .addTextPara("needIndex", "0") .post(); jObject = JsonConvert.DeserializeObject <JObject>(res); if (jObject["showapi_res_body"]["ret_code"].ToString() != "0" || jObject["showapi_res_body"]["stockMarket"] == null) { return(ApiResponse.NotFound("未找到数据")); } } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(ApiResponse.BadRequest("糟糕,网络好像出问题了")); } return(ApiResponse.Ok(jObject)); }
public HttpResponseMessage Login(string Phonenumber, string Password) { User loginUser = db.Users.Where(s => s.Phonenumber == Phonenumber).FirstOrDefault(); IDatabase redisDatabase = RedisHelper.Value.Database; if (loginUser == null) { return(ApiResponse.Invalid("Phonenumber", "帐号不存在")); } if (SecurityHelper.MD5Hash(Password) != loginUser.Password) { return(ApiResponse.Invalid("Password", "密码错误")); } else { StockAccount stockAccount = db.StockAccounts.FirstOrDefault(s => s.UserId == loginUser.Id); string TalkNumber_Key = "UserId=" + loginUser.Id.ToString() + "&TalkNumber"; return(ApiResponse.Ok(new { loginUser.Id, loginUser.Username, loginUser.Phonenumber, loginUser.CreateTime, loginUser.ImageUrl, Gender = loginUser.Gender.ToString(), StockAge = loginUser.StockAge, loginUser.FansNumber, loginUser.FollowNumber, TalkNumber = redisDatabase.StringGet(TalkNumber_Key), loginUser.Remark, loginUser.CoinNumber, SumMoney = stockAccount == null? "0":ParamHelper.ConvertNumber(stockAccount.SumMoney) })); } }
public IActionResult GetBuyStockInfo(string NameorCode) { JObject jObject = null; JObject result = null; Double nowPrice = 0; Double diff_rate = 0; Double diff_money = 0; string name = ""; string code = ""; ParamHelper paramHelper = new ParamHelper(); string StockCode = NameorCode; if (paramHelper.HaveEnglish(StockCode) || paramHelper.HaveHanZi(StockCode)) { Stock tempStock = db.Stocks.FirstOrDefault(s => s.StockName == StockCode || s.StockName.Equals(StockCode)); if (tempStock == null) { return(Json(new { code = 404, message = "未找到数据" })); } StockCode = tempStock.StockCode; } try { string res = new ShowApiRequest("http://route.showapi.com/131-46", "138438", "dd520f20268747d4bbda22ac31c9cbdf") .addTextPara("stocks", StockCode) .addTextPara("needIndex", "0") .post(); jObject = JsonConvert.DeserializeObject <JObject>(res); result = JObject.Parse(jObject["showapi_res_body"]["list"].First.ToString()); nowPrice = Double.Parse(result["nowPrice"].ToString()); diff_rate = Double.Parse(result["diff_rate"].ToString()); diff_money = Double.Parse(result["diff_money"].ToString()); code = result["code"].ToString(); name = result["name"].ToString(); if (jObject["showapi_res_body"]["ret_code"].ToString() != "0" || jObject["showapi_res_body"]["list"].Count() == 0) { return(Json(new { code = 404, message = "未找到数据" })); } } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(Json(new { code = 400, message = "糟糕,网络好像出问题了" })); } return(Json(new { name, code, nowPrice, diff_rate = diff_rate + "%", diff_money })); }
public HttpResponseMessage GetStockMainPage(long UserId) { User user = db.Users.FirstOrDefault(s => s.Id == UserId); StockAccount stockAccount = db.StockAccounts.FirstOrDefault(s => s.UserId == UserId); JArray stockList = null; if (stockAccount == null) { return(ApiResponse.BadRequest("建议您先开个户")); } else { List <SimulationStock> simulationStocks = db.SimulationStocks.Where(s => s.StockAccountId == stockAccount.Id && s.Valid == true).ToList(); if (simulationStocks.Count > 0) { string[] stockCodes = simulationStocks.Select(s => s.StockCode).ToArray(); StringBuilder request_string = new StringBuilder(); for (int i = 0; i < stockCodes.Length; i++) { if (i == stockCodes.Length - 1) { request_string.Append(stockCodes[i]); } else { request_string.Append(stockCodes[i] + ","); } } string res = new ShowApiRequest("http://route.showapi.com/131-46", "138438", "dd520f20268747d4bbda22ac31c9cbdf") .addTextPara("stocks", request_string.ToString()) .addTextPara("needIndex", "0") .post(); JObject jObject = JsonConvert.DeserializeObject <JObject>(res); stockList = JArray.Parse(jObject["showapi_res_body"]["list"].ToString()); Double SumStockValue = 0; for (int i = 0; i < simulationStocks.Count; i++) { for (int j = 0; j < stockList.Count; j++) { if (simulationStocks[i].StockCode == stockList[j]["code"].ToString()) { simulationStocks[i].NowPrice = Double.Parse(stockList[j]["nowPrice"].ToString()); SumStockValue += Double.Parse(stockList[j]["nowPrice"].ToString()) * simulationStocks[i].StockNumber; db.Entry(simulationStocks[i]).State = EntityState.Modified; db.SaveChanges(); } } Thread.Sleep(1); } stockAccount.SumStockValue = SumStockValue; stockAccount.SumMoney = SumStockValue + stockAccount.ValidMoney; db.Entry(stockAccount).State = EntityState.Modified; db.SaveChanges(); Thread.Sleep(1); try { stockAccount.Rank = RankCalculation(UserId: UserId); db.Entry(stockAccount).State = EntityState.Modified; db.SaveChanges(); Thread.Sleep(1); } catch (Exception ex) { Console.WriteLine(ex.Message); db.Entry(stockAccount).State = EntityState.Unchanged; return(ApiResponse.BadRequest("糟糕,网络好像出问题了")); } } else { try { stockAccount.Rank = RankCalculation(UserId: UserId); db.Entry(stockAccount).State = EntityState.Modified; db.SaveChanges(); Thread.Sleep(1); } catch (Exception ex) { Console.WriteLine(ex.Message); db.Entry(stockAccount).State = EntityState.Unchanged; return(ApiResponse.BadRequest("糟糕,网络好像出问题了")); } } Thread.Sleep(1); } return(ApiResponse.Ok(new { stockAccount.UserId, stockAccount.SumMoney, SumStockValue = ParamHelper.ConvertNumber(stockAccount.SumStockValue), stockAccount.ValidMoney, Profit_or_Loss = Math.Round(stockAccount.Profit_or_Loss, 2), stockAccount.Rank })); }
public ProductsRepository() { this.ConnString = ParamHelper.GetConnString(); }
public InListChecker(IEnumerable <TProperty> value, Validation validation) : base(default(TProperty), validation) { ParamHelper.CheckParamNull(value, "value", "Can't be null"); m_Value = value; }
public ActionResult GetProjectList() { try { var queryParams = new NameValueCollection(); if (!ParamHelper.CheckParaQ(ref queryParams)) { return(Json(new ResponseEntity <int>(RegularFunction.RegularSqlRegexText), JsonRequestBehavior.AllowGet)); } int userType = CurrenUserInfo.UserType; string loginName = CurrenUserInfo.LoginName; var query = new ProjectQuery(queryParams); var sqlCondition = new StringBuilder(); sqlCondition.Append("ISNULL(IsDelete,0)!=1 and CurrentStatus=1"); //CurrentStatus审批状态为1(同意) if (userType == GDS.Entity.Constant.ConstantDefine.ProjectManager) // { sqlCondition.Append($" and (createby = '{loginName}' or charindex('{loginName}', projectmanager) > 0 or charindex('{loginName}', TeamMembers) > 0) "); } else if (userType == GDS.Entity.Constant.ConstantDefine.User) // { sqlCondition.Append($"and charindex('{loginName}', TeamMembers) > 0"); } if (!string.IsNullOrEmpty(query.DepartId) && query.DepartId != "0") { sqlCondition.Append($" and BusinessDept = {query.DepartId}"); } if (!string.IsNullOrEmpty(query.Status)) { sqlCondition.Append($" and Status = {query.Status}"); } if (!string.IsNullOrEmpty(query.ProjectType)) { sqlCondition.Append($" and ProjectType = {query.ProjectType}"); } if (!string.IsNullOrEmpty(query.Name)) { sqlCondition.Append($" and Name like '%{query.Name}%'"); } if (!string.IsNullOrEmpty(query.ProjectManager)) { sqlCondition.Append($" and ProjectManager like '%{query.ProjectManager}%'"); } if (!string.IsNullOrEmpty(query.No)) { sqlCondition.Append($" and No like '%{query.No}%'"); } PageRequest preq = new PageRequest { TableName = " [View_Project] ", Where = sqlCondition.ToString(), Order = " Id DESC ", IsSelect = true, IsReturnRecord = true, PageSize = query.PageSize, PageIndex = query.PageIndex, FieldStr = "*" }; var result = new ProjectBLL().GetView_ProjectByPage(preq); result.ForEach(project => { project.CreateTimeStr = project.CreateTime.HasValue? project.CreateTime.Value.ToString("yyyy-MM-dd") : string.Empty; }); result = result.OrderByDescending(r => r.CreateTime).ToList(); var response = new ResponseEntity <object>(true, string.Empty, new DataGridResultEntity <View_Project> { TotalRecords = preq.Out_AllRecordCount, DisplayRecords = preq.Out_PageCount, ResultData = result }); return(Json(response, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new ResponseEntity <object>(-999, string.Empty, ""), JsonRequestBehavior.AllowGet)); } }
public IActionResult GetHomePage(long UserId, long MyId) { User user = db.Users.FirstOrDefault(s => s.Id == UserId); IDatabase redisDatabase = RedisHelper.Value.Database; string TalkNumber_Key = "UserId=" + UserId.ToString() + "&TalkNumber"; ParamHelper paramHelper = new ParamHelper(); StockAccount stockAccount = db.StockAccounts.FirstOrDefault(s => s.UserId == user.Id); if (MyId == UserId) { return(Json(new { user.Id, user.Username, user.Remark, Gender = user.Gender.ToString(), StockAge = user.StockAge, user.ImageUrl, user.FansNumber, user.FollowNumber, user.CoinNumber, TalkNumber = redisDatabase.StringGet(TalkNumber_Key), SumMoney = stockAccount == null ? "0" : ParamHelper.ConvertNumber(stockAccount.SumMoney) })); } else { FollowRecord followRecord = db.FollowRecords.FirstOrDefault(s => s.FollowingId == MyId && s.FollowedId == UserId); if (followRecord == null) { return(Json(new { user.Id, user.Username, user.Remark, Gender = user.Gender.ToString(), StockAge = user.StockAge, user.ImageUrl, user.FansNumber, user.FollowNumber, user.CoinNumber, TalkNumber = redisDatabase.StringGet(TalkNumber_Key), SumMoney = stockAccount == null ? "0" : ParamHelper.ConvertNumber(stockAccount.SumMoney), If_Follow = "false" })); } else { return(Json(new { user.Id, user.Username, user.Remark, Gender = user.Gender.ToString(), StockAge = user.StockAge, user.ImageUrl, user.FansNumber, user.FollowNumber, user.CoinNumber, TalkNumber = redisDatabase.StringGet(TalkNumber_Key), SumMoney = stockAccount == null ? "0" : ParamHelper.ConvertNumber(stockAccount.SumMoney), If_Follow = "true" })); } } }
public void SetRules(IEnumerable <IValidateRule> rules) { ParamHelper.CheckParamNull(rules, "rules", "Can't be null"); m_Rules.AddRange(rules); }
public ActionResult GetApprovalList() { try { var queryParams = new NameValueCollection(); if (!ParamHelper.CheckParaQ(ref queryParams)) { return(Json(new ResponseEntity <int>(RegularFunction.RegularSqlRegexText), JsonRequestBehavior.AllowGet)); } int userType = CurrenUserInfo.UserType; string loginName = CurrenUserInfo.LoginName; var query = new ProjectQuery(queryParams); var sqlCondition = new StringBuilder(); sqlCondition.Append("ISNULL(IsDelete,0)!=1 and CurrentStatus=0"); //CurrentStatus审批状态为0(草稿) if (userType != GDS.Entity.Constant.ConstantDefine.Admin) //验证审批权限 { var departmentList = new DepartmentBLL().GetDepartmentByAuditor(loginName); if (departmentList != null && departmentList.Count > 0) { sqlCondition.Append($" and DepartId in ({string.Join(",", departmentList.Select(x => x.Id))}) "); } else { return(Json(new ResponseEntity <dynamic>(10, "权限不足", null), JsonRequestBehavior.AllowGet)); } } //if (userType == GDS.Entity.Constant.ConstantDefine.ProjectManager) // //{ // sqlCondition.Append($" and (createby = '{loginName}' or projectmanager = '{loginName}' or charindex(';{loginName};', ';' + TeamMembers + ';') > 0) "); //} //else if (userType == GDS.Entity.Constant.ConstantDefine.User) // //{ // sqlCondition.Append($"and charindex(';{loginName};', ';' + TeamMembers + ';') > 0"); //} if (userType == GDS.Entity.Constant.ConstantDefine.ProjectManager) // { sqlCondition.Append($" and (createby = '{loginName}' or charindex('{loginName}', projectmanager) > 0 or charindex('{loginName}', TeamMembers) > 0) "); } //else if (userType == GDS.Entity.Constant.ConstantDefine.User) // //{ // sqlCondition.Append($"and charindex(';{loginName};', TeamMembers) > 0"); //} if (!string.IsNullOrEmpty(query.DepartId) && query.DepartId != "0") { sqlCondition.Append($" and BusinessDept = {query.DepartId}"); } if (!string.IsNullOrEmpty(query.ProjectType)) { sqlCondition.Append($" and ProjectType = {query.ProjectType}"); } if (!string.IsNullOrEmpty(query.Name)) { sqlCondition.Append($" and Name like '%{query.Name}%'"); } if (!string.IsNullOrEmpty(query.CreateBy)) { sqlCondition.Append($" and CreateBy like '%{query.CreateBy}%'"); } PageRequest preq = new PageRequest { TableName = " [View_Project] ", Where = sqlCondition.ToString(), Order = " Id DESC ", IsSelect = true, IsReturnRecord = true, PageSize = query.PageSize, PageIndex = query.PageIndex, FieldStr = "*" }; var result = new ProjectBLL().GetView_ProjectByPage(preq); result.ForEach(project => { project.CreateTimeStr = project.CreateTime.HasValue ? project.CreateTime.Value.ToString("yyyy-MM-dd") : string.Empty; }); var response = new ResponseEntity <object>(true, string.Empty, new DataGridResultEntity <View_Project> { TotalRecords = preq.Out_AllRecordCount, DisplayRecords = preq.Out_PageCount, ResultData = result }); return(Json(response, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new ResponseEntity <object>(-999, string.Empty, ""), JsonRequestBehavior.AllowGet)); } }
public IActionResult SearchNews(string SearchText) { if (SearchText.Trim().Length == 0 || SearchText == null || SearchText == "" || SearchText.Equals("")) { return(Json(new { code = 200, data = new string[] { } })); } List <News> news = new List <News>(); if (SearchText.Trim().Length < 5) { news = db.News.Where(s => s.NewsType == Enums.NewsType.首页 && (s.Title.ToLower() == SearchText.ToLower() || s.Title.ToLower().Contains(SearchText) || s.Content.ToLower().Contains(SearchText) || GetSimilarity(s.Title, SearchText) > 0.6)).OrderByDescending(s => s.IssueTime).ToList(); } else { JObject result = null; string cut_sentence; string[] words_array; try { string url = "http://116.62.208.165/api/cut_sentence?Sentence=" + SearchText; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); string retString = myStreamReader.ReadToEnd(); result = JsonConvert.DeserializeObject <JObject>(retString); cut_sentence = result["data"].ToString().Trim(); words_array = cut_sentence.Split(" ").ToArray(); foreach (var item in db.News.Where(s => s.NewsType == Enums.NewsType.首页).ToList()) { for (int i = 0; i < words_array.Length; i++) { if (item.Title.ToLower().Contains(words_array[i].Trim()) || item.Content.ToLower().Contains(words_array[i].Trim())) { news.Add(item); break; } } } } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(Json(new { code = 400, data = "糟糕,网络好像出问题了" } )); } } return(Json(new { code = 200, data = news.Select(s => new { s.Id, Title = s.Title.Length > 18 ? s.Title.Substring(0, 18) + "…" : s.Title, Content = s.Content.Length > 40 ? s.Content.Substring(0, 40) + "…":s.Content, s.Source, IssueTime = ParamHelper.TalkTimeConvert(s.IssueTime) }) })); }
public HttpResponseMessage BuyStocks(long UserId, string NameorCode, int Number) { User user = db.Users.FirstOrDefault(s => s.Id == UserId); StockAccount stockAccount = db.StockAccounts.FirstOrDefault(s => s.UserId == UserId); SimulationStock simulationStock = null; JObject jObject = null; ParamHelper paramHelper = new ParamHelper(); string StockCode = NameorCode; if (paramHelper.HaveEnglish(StockCode) || paramHelper.HaveHanZi(StockCode)) { Stock tempStock = db.Stocks.FirstOrDefault(s => s.StockName == StockCode || s.StockName.Equals(StockCode)); if (tempStock == null) { return(ApiResponse.BadRequest("未找到数据")); } StockCode = tempStock.StockCode; } try { string res = new ShowApiRequest("http://route.showapi.com/131-46", "138438", "dd520f20268747d4bbda22ac31c9cbdf") .addTextPara("stocks", StockCode) .addTextPara("needIndex", "0") .post(); jObject = JsonConvert.DeserializeObject <JObject>(res); if (jObject["showapi_res_body"]["ret_code"].ToString() != "0" || jObject["showapi_res_body"]["list"].Count() == 0) { return(ApiResponse.BadRequest("未找到数据")); } double nowPrice = Double.Parse(jObject["showapi_res_body"]["list"].First["nowPrice"].ToString()); string stockName = jObject["showapi_res_body"]["list"].First["name"].ToString(); if (Number * nowPrice > stockAccount.ValidMoney) { return(ApiResponse.BadRequest("老铁,您的钱好像有点不够")); } else { simulationStock = new SimulationStock() { StockAccount = stockAccount, StockAccountId = stockAccount.Id, StockCode = StockCode, BuyPrice = nowPrice, NowPrice = nowPrice, StockNumber = Number, StockName = stockName, BuyTime = DateTime.Now, Valid = true }; stockAccount.ValidMoney -= Number * nowPrice; stockAccount.SumStockValue = nowPrice * Number; db.SimulationStocks.Add(simulationStock); db.Entry(stockAccount).State = EntityState.Modified; TradeHistory tradeHistory = new TradeHistory() { StockName = stockName, StockCode = StockCode, StockAccountId = stockAccount.Id, TransactionValue = nowPrice * Number, TransactionPrice = nowPrice, TransactionAmount = Number, TransactionType = Enums.TransactionType.买入, TradeTime = DateTime.Now }; db.TradeHistories.Add(tradeHistory); db.SaveChanges(); Thread.Sleep(1); } Thread.Sleep(1); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { db.Entry(stockAccount).State = EntityState.Unchanged; return(ApiResponse.BadRequest("未找到数据")); } return(ApiResponse.Ok(new { simulationStock.BuyPrice, simulationStock.StockName, simulationStock.StockCode, simulationStock.StockNumber, StockSum = simulationStock.BuyPrice * simulationStock.StockNumber, stockAccount.ValidMoney, message = "您买入 " + simulationStock.StockName + "(" + simulationStock.StockCode + ") " + Number + "股" })); }
public static void Main(string[] args) { AssemblyDefinition ad = AssemblyLoader.LoadAssembly("Tests.exe"); TypeDefinition testType = ad.MainModule.GetType("Tests.TypeDefinitionTests"); Console.WriteLine($"Loaded type: {testType}"); TypeReference tr = ParamHelper.FromType( typeof(Dictionary <,>).MakeGenericType(ParamHelper.CreateDummyType("T"), ParamHelper.CreateDummyType("T"))); MethodDefinition md = testType.GetMethod( "Test", typeof(List <>).MakeGenericType(ParamHelper.CreateDummyType("T")), typeof(Dictionary <,>).MakeGenericType( typeof(List <>).MakeGenericType(ParamHelper.CreateDummyType("T")), typeof(List <>).MakeGenericType( typeof(Dictionary <,>).MakeGenericType( ParamHelper.CreateDummyType("U"), ParamHelper.CreateDummyType("T"))))); Console.WriteLine($"Type: {tr}"); Console.WriteLine($"Method: {md}"); InjectionDefinition hd = new InjectionDefinition( testType.GetMethod("Test2"), testType.GetMethod("HookTest1"), InjectFlags.ModifyReturn | InjectFlags.PassInvokingInstance | InjectFlags.PassTag | InjectFlags.PassFields | InjectFlags.PassParametersRef, new[] { 0 }, testType.GetField("testMember")); Console.WriteLine($"Hook def: {hd}"); InjectionDefinition hd2 = testType.GetInjectionMethod( "HookTest1", testType.GetMethod("Test2"), InjectFlags.ModifyReturn | InjectFlags.PassInvokingInstance | InjectFlags.PassTag | InjectFlags.PassFields | InjectFlags.PassParametersRef, new[] { 0 }, testType.GetField("testMember")); InjectionDefinition hd3 = testType.GetInjectionMethod("", null, InjectFlags.None, null, null); /* * testType.GetMethod("Test2") * .InjectWith( * testType.GetMethod("HookTest1"), * 0, * 0, * InjectFlags.All_Ref | InjectFlags.ModifyReturn, * InjectDirection.Before, * new[] {0}, * new[] {testType.GetField("testMember")}); */ InjectionDefinition hd4 = new InjectionDefinition( testType.GetMethod(nameof(TestPartialParams)), testType.GetMethod(nameof(HookTest2)), new InjectValues { TagType = InjectValues.PassTagType.Int32, PassInvokingInstance = true, ModifyReturn = true, ParameterType = InjectValues.PassParametersType.ByValue }.GetCombinedFlags()); hd4.Inject(token: 5); InjectionDefinition hd5 = new InjectionDefinition( testType.GetMethod(nameof(TestPartialParams)), testType.GetMethod(nameof(HookTest3)), new InjectValues { TagType = InjectValues.PassTagType.String, PassInvokingInstance = true, ModifyReturn = true, ParameterType = InjectValues.PassParametersType.ByValue }.GetCombinedFlags()); hd5.Inject(token: "test"); MethodDefinition[] matches = testType.MatchMethod("TestMatch", typeof(int), typeof(string)); Console.WriteLine($"Another hookdef: {hd2}"); Console.WriteLine($"Another hookdef3: {hd3}"); testType.ChangeAccess("hidden.*", recursive: true); hd2.Inject(2, 2); ad.Write("Test_patched.exe"); Console.ReadLine(); }
public override Dictionary <string, string> GetParams(object obj, System.Reflection.PropertyInfo p) { var value = p.GetValue(obj, null); return(ParamHelper.GetParams(value)); }
public CustomChecker(Func <TProperty, IEnumerable <ValidateFailure> > func, Validation validation) : base(validation) { ParamHelper.CheckParamNull(func, nameof(func), "Can't be null"); m_Func = func; }
/// <summary> /// Resolves the parameters. /// </summary> protected void ResolveParams() { ParamHelper.ResolveParametersForScriptFunction(_fmeta, this.ParamListExpressions, this.ParamList); }
public IActionResult GetAllFollowUsers(long UserId) { IDatabase redisDatabase = RedisHelper.Value.Database; IList <FollowRecord> followRecords = db.FollowRecords.Where(s => s.FollowingId == UserId).ToList(); IList <Comment> comments = db.Comments.ToList(); if (followRecords == null || followRecords.Count == 0) { return(Json(new { data = new { } })); } Dictionary <Talk, KeyValuePair <User, string[]> > followTalks = new Dictionary <Talk, KeyValuePair <User, string[]> >(); for (int i = 0; i < followRecords.Count; i++) { User tempUser = db.Users.FirstOrDefault(s => s.Id == followRecords[i].FollowedId); List <Talk> tempTalks = db.Talks.Where(s => s.UserId == tempUser.Id).ToList(); if (tempTalks.Count == 0) { continue; } else { for (int j = 0; j < tempTalks.Count; j++) { string TalkPraise_Key = "TalkId=" + tempTalks[j].Id.ToString() + "&PraiseNumber";//格式例如: TalkId=1&Praise string TalkTransmit_Key = "TalkId=" + tempTalks[j].Id.ToString() + "&TransmitNumber"; string TalkComment_Key = "TalkId=" + tempTalks[j].Id.ToString() + "&CommentNumber"; string TalkRead_Key = "TalkId=" + tempTalks[j].Id.ToString() + "&ReadNumber"; string Talk_User_Praise_Key = "TalkId=" + tempTalks[j].Id.ToString() + "&UserId=" + UserId.ToString(); string TalkPraise_Value = redisDatabase.StringGet(TalkPraise_Key); string TalkTransmit_Value = redisDatabase.StringGet(TalkTransmit_Key); string TalkComment_Value = redisDatabase.StringGet(TalkComment_Key); string TalkRead_Value = (int.Parse(TalkPraise_Value) + int.Parse(TalkComment_Value)).ToString(); string Talk_User_Praise_Value = redisDatabase.KeyExists(Talk_User_Praise_Key).ToString(); followTalks.Add(tempTalks[j], new KeyValuePair <User, string[]>(tempUser, new string[] { TalkPraise_Value, TalkTransmit_Value, TalkComment_Value, TalkRead_Value, Talk_User_Praise_Value })); } } } return(Json(new { data = followTalks.OrderByDescending(s => s.Key.TalkTime).Select(s => new { TalkId = s.Key.Id, Content = s.Key.Content, TalkTime = ParamHelper.TalkTimeConvert(s.Key.TalkTime), PraiseNumber = s.Value.Value[0], TransmitNumber = s.Value.Value[1], CommentNumber = s.Value.Value[2], ReadNumber = s.Value.Value[3], If_Priase = s.Value.Value[4], UserId = s.Value.Key.Id, Username = s.Value.Key.Username, ImageUrl = s.Value.Key.ImageUrl, Pictures = db.Pictures.Where(p => p.TalkId == s.Key.Id).Select(p => p.FileUrl).ToList(), CommentData = s.Key.Comments.Where(c => c.TalkId == s.Key.Id).Select(c => new { c.Id, c.Point, c.UserId, Username = db.Users.FirstOrDefault(u => u.Id == c.UserId).Username, ImageUrl = db.Users.FirstOrDefault(t => t.Id == c.UserId).ImageUrl, CommentTime = ParamHelper.TalkTimeConvert(c.CommentTime), PraiseNumber = redisDatabase.StringGet("CommentId=" + c.Id.ToString() + "&Praise"), Comment_If_Praise = redisDatabase.KeyExists("CommentId=" + c.Id.ToString() + "&UserId=" + UserId.ToString()).ToString() }) }) })); }
void BuildAttributes(dynamic item, Saint.Item sItem) { var attr = new JObject(); var attr_hq = new JObject(); var attr_max = new JObject(); if (sItem is Saint.Items.Equipment sEquipment) { item.equip = 1; if (sEquipment.FreeMateriaSlots > 0) { item.sockets = sEquipment.FreeMateriaSlots; // Only equipment with slots should possibly be forbidden. if (!sItem.IsAdvancedMeldingPermitted) { item.advancedMeldingForbidden = 1; } } if (sEquipment.RepairItem != null && sEquipment.RepairItem.Key > 0) { item.repair_item = sEquipment.RepairItem.Key; } if (sEquipment.IsPvP) { item.pvp = 1; } if (sEquipment.IsCrestWorthy) { item.crestworthy = 1; } if (sEquipment.IsGlamourous) { item.glamourous = 1; } var expertSeals = sEquipment.ExpertDeliverySeals; if (expertSeals > 0) { item.delivery = expertSeals; } if (_armoireIndex.Contains(sItem.Key)) { item.storable = 1; } item.slot = sEquipment.EquipSlotCategory.Key; item.elvl = sEquipment.EquipmentLevel; item.jobs = sEquipment.ClassJobCategory.Key; _builder.Localize.Column(item, sEquipment.ClassJobCategory, "Name", "jobCategories"); // Set all normal and hq parameters specified on the item. Saint.BaseParam[] extraParams = null; foreach (var sParameter in sEquipment.AllParameters) { if (_crafterParams.Contains(sParameter.BaseParam)) { extraParams = _crafterParams; } else if (_gathererParams.Contains(sParameter.BaseParam)) { extraParams = _gathererParams; } ParamHelper.SetValue(sParameter, attr, attr_hq, false); } // Set maximums for every parameter. foreach (var sBaseParam in _baseParams) { ParamHelper.SetMaxValue(sEquipment, sBaseParam, attr_max); } // For gatherer and crafter equ, set normal attributes even // if they're 0 so their maximums always show up. if (extraParams != null) { foreach (var sBaseParam in extraParams) { var key = sBaseParam.Name.ToString(); if (attr_max[key] != null && attr[key] == null && attr_hq[key] == null) { attr[key] = 0; } } } var characterType = sEquipment.GetModelCharacterType(); if (characterType != 0 && !Hacks.NoModelCategories.Contains(sEquipment.ItemUICategory.Key)) { // Record model information for viewer. item.models = new JArray(); item.models.Add(sEquipment.PrimaryModelKey.ToString().Replace(", ", "-")); if (!sEquipment.SecondaryModelKey.IsEmpty) { item.models.Add(sEquipment.SecondaryModelKey.ToString().Replace(", ", "-")); } if (sEquipment.Rarity != 7) { var sEquipSlot = sEquipment.EquipSlotCategory.PossibleSlots.First(); var modelKey = sEquipSlot.GetModelKey(sEquipment.PrimaryModelKey, characterType); // We compare only the primary model key for now. // Not sure if the secondary key is valuable too? if (!_itemsBySlotModelId.TryGetValue(modelKey, out var itemsWithModel)) { itemsWithModel = new List <dynamic>(); _itemsBySlotModelId[modelKey] = itemsWithModel; } itemsWithModel.Add(item); } } // ItemSpecialBonus if (sEquipment.ItemSpecialBonus != null && sEquipment.ItemSpecialBonus.Name != "") { item.special = new JObject(); item.special.bonusId = sEquipment.ItemSpecialBonus.Key; if (sEquipment.ItemSpecialBonusParam > 0) { item.special.bonusParam = sEquipment.ItemSpecialBonusParam; } if (sEquipment.ItemSeries.Key > 0) { item.special.seriesId = sEquipment.ItemSeries.Key; if (!_builder.Db.ItemsBySeriesId.TryGetValue(sEquipment.ItemSeries.Key, out var itemsInSeries)) { _builder.Db.ItemsBySeriesId[sEquipment.ItemSeries.Key] = itemsInSeries = new List <dynamic>(); } itemsInSeries.Add(item); } item.special.attr = new JArray(); foreach (var sParam in sEquipment.SecondaryParameters) { foreach (var paramValue in sParam.Values.Select(pv => ParameterInfo.From(pv))) { if (paramValue.Type != Saint.ParameterType.Sanction && paramValue.Type != Saint.ParameterType.SetBonus && paramValue.Type != Saint.ParameterType.SetBonusCapped && paramValue.Type != Saint.ParameterType.EurekaEffect) { continue; } dynamic obj = new JObject(); obj.name = sParam.BaseParam.Name.ToString(); obj.value = (int)paramValue.Amount; obj.index = paramValue.Index; item.special.attr.Add(obj); } } } } if (sItem is Saint.Items.Usable sUsable) { JObject action = new JObject(); JObject action_hq = new JObject(); foreach (var param in sUsable.Parameters) { ParamHelper.SetValue(param, action, action_hq, true); } if (action.Count > 0) { attr.Add("action", action); } if (action_hq.Count > 0) { attr_hq.Add("action", action_hq); } } if (attr.Count > 0) { item.attr = attr; } if (attr_hq.Count > 0) { item.attr_hq = attr_hq; } if (attr_max.Count > 0) { item.attr_max = attr_max; } }
public IActionResult GetMainPageNewsList(int Page) { IDatabase redisDatabase = RedisHelper.Value.Database; IList <News> news = db.News.Where(s => s.NewsType == Enums.NewsType.首页).OrderByDescending(s => s.IssueTime).ToList(); Console.WriteLine(news.Count); int page = (news.Count / 7) + (news.Count * 1.0 % 7 == 0 ? 0 : 1); if (Page > page) { return(Json(new { code = 400, message = "没有更多数据了" })); } Dictionary <News, string[]> newsList = new Dictionary <News, string[]>(); if ((news.Count - (Page - 1) * 7) >= 7) { for (int i = (Page - 1) * 7; i < Page * 7; i++) { string NewsPraise_Key = "NewsId=" + news[i].Id + "&Praise"; string NewsTransmit_Key = "NewsId=" + news[i].Id + "&Transmit"; string NewsComment_Key = "NewsId=" + news[i].Id + "&CommentNumber"; string NewsRead_Key = "NewsId=" + news[i].Id + "&ReadNumber"; if (redisDatabase.KeyExists(NewsPraise_Key) == false) { redisDatabase.StringSetAsync(NewsPraise_Key, 0); } if (redisDatabase.KeyExists(NewsTransmit_Key) == false) { redisDatabase.StringSetAsync(NewsTransmit_Key, 0); } if (redisDatabase.KeyExists(NewsComment_Key) == false) { redisDatabase.StringSetAsync(NewsComment_Key, 0); } if (redisDatabase.KeyExists(NewsRead_Key) == false) { redisDatabase.StringSetAsync(NewsRead_Key, 0); } string praiseNumber = redisDatabase.StringGet(NewsPraise_Key); string transmitNumber = redisDatabase.StringGet(NewsTransmit_Key); string commentNumber = redisDatabase.StringGet(NewsComment_Key); newsList.Add(news[i], new string[3] { praiseNumber, transmitNumber, commentNumber }); } } else { for (int i = (Page - 1) * 7; i < news.Count; i++) { string NewsPraise_Key = "NewsId=" + news[i].Id + "&Praise"; string NewsTransmit_Key = "NewsId=" + news[i].Id + "&Transmit"; string NewsComment_Key = "NewsId=" + news[i].Id + "&CommentNumber"; string NewsRead_Key = "NewsId=" + news[i].Id + "&ReadNumber"; if (redisDatabase.KeyExists(NewsPraise_Key) == false) { redisDatabase.StringSetAsync(NewsPraise_Key, 0); } if (redisDatabase.KeyExists(NewsTransmit_Key) == false) { redisDatabase.StringSetAsync(NewsTransmit_Key, 0); } if (redisDatabase.KeyExists(NewsComment_Key) == false) { redisDatabase.StringSetAsync(NewsComment_Key, 0); } if (redisDatabase.KeyExists(NewsRead_Key) == false) { redisDatabase.StringSetAsync(NewsRead_Key, 0); } string praiseNumber = redisDatabase.StringGet(NewsPraise_Key); string transmitNumber = redisDatabase.StringGet(NewsTransmit_Key); string commentNumber = redisDatabase.StringGet(NewsComment_Key); newsList.Add(news[i], new string[3] { praiseNumber, transmitNumber, commentNumber }); } } return(Json(new { page, data = newsList.Select(s => new { s.Key.Id, s.Key.Title, IssueTime = ParamHelper.TalkTimeConvert(s.Key.IssueTime), s.Key.PicUrl1, s.Key.Source, PraiseNumber = s.Value[0], TransmitNumber = s.Value[1], CommentNumber = s.Value[2] }) })); }