public virtual IActionResult Get([FromBody] RequestSetting requestSetting) { if (requestSetting == null) { requestSetting = new RequestSetting(); } else if (!string.IsNullOrEmpty(requestSetting.FilterText)) { IsFilterServiceInjected(); requestSetting.Filters = AdvanceFilterQuery.GetDefaultFilter( Filters.GetFilters(ControllerName), requestSetting.FilterText ); } var data = Service.GetPage(requestSetting); var result = new JsonActionResult( data, InternalSetting(requestSetting), requestSetting.Page?.RowCount ?? data?.Count ); return(result); }
private void btnDataStreamAdd_Click(object sender, EventArgs e) { frmCreateScriptSetting frmCreateScriptSetting = new frmCreateScriptSetting(); frmCreateScriptSetting.MaxLayerCount = __iMaxLayerIndex + 1; //最大圖層個數=最大圖層索引 + 1 DialogResult cResult = frmCreateScriptSetting.ShowDialog(); frmCreateScriptSetting.Dispose(); if (cResult == DialogResult.OK) { ChartSetting cChartSetting = frmCreateScriptSetting.ChartSetting; RequestSetting cRequestSetting = frmCreateScriptSetting.RequestSetting; __cScriptSetting.DataRequests.Add(cRequestSetting); //加入至腳本設定值內 __cCharts.Add(cChartSetting); string[] sRanges = GetRequestRanges(cRequestSetting.Range); int iDataStream = source.Count + 1; source.Add(CreateDataStreamInfo(iDataStream, cChartSetting, cRequestSetting, true)); source.Refresh(); if (cChartSetting.LayerIndex > __iMaxLayerIndex) { __iMaxLayerIndex = cChartSetting.LayerIndex; } } bool bEnabled = source.Count > 0; btnOK.Enabled = bEnabled; btnDataStreamRemove.Enabled = bEnabled; }
private void CreateSignalObject() { __cSignalObject = ScriptManager.Manager.CreateScript(__cProfile.ScriptName, this) as SignalObject; if (__cSignalObject != null) { string sTitle = string.Format("{0}", __cSignalObject.About.Comment); if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker) delegate { this.Text = sTitle; this.Invalidate(false); }); } else { this.Text = sTitle; this.Invalidate(false); } __cSignalObject.onReady += SignalObject_onReady; __cSignalObject.onScriptParameters += SignalObject_onScriptParameters; __cSignalObject.onTradeResponse += SignalObject_onTradeResponse; OutputWriter cOutputWriter = __cSignalObject.Output as OutputWriter; cOutputWriter.onOutputData += OutputWriter_onOutputData; SignalSetting cSignalSetting = __cProfile.Script as SignalSetting; __cSignalObject.ApplyProperty(cSignalSetting.Property); __cSignalObject.AddDataStreams(RequestSetting.Convert(cSignalSetting.DataRequests)); } }
public bool SendMessage(string message) { try { var url = new Uri(new UriBuilder(Host).Uri, pulishWebRouteCode); var settings = new RequestSetting(url) { Method = "POST" }; var request = new RestRequest <string>(settings); request.ExecuteWithString(); return(true); } catch (Exception ex) { Task.Factory.StartNew((e) => { var exception = e as Exception; if (exception != null && Logger != null) { Logger.Error("Socket客户端消息管道推送消息失败!", exception); } }, ex); } return(false); }
private void btnDataStreamEdit_Click(object sender, EventArgs e) { if (dataGrid.SelectedDataRows.Length > 0) { _DataStreamInfo cInfo = dataGrid.SelectedDataRows[0] as _DataStreamInfo; if (cInfo != null) { int iIndex = cInfo.DataStream - 1; int iDataStream = source.Count; frmCreateScriptSetting frmCreateScriptSetting = new frmCreateScriptSetting(__cCharts[iIndex], __cScriptSetting.DataRequests[iIndex], cInfo.IsNewSetting); frmCreateScriptSetting.MaxLayerCount = __iMaxLayerIndex + 1; //最大圖層個數=最大圖層索引 + 1 DialogResult cResult = frmCreateScriptSetting.ShowDialog(); frmCreateScriptSetting.Dispose(); if (cResult == DialogResult.OK) { ChartSetting cChartSetting = frmCreateScriptSetting.ChartSetting; RequestSetting cRequestSetting = frmCreateScriptSetting.RequestSetting; ModifyDataStreamInfo(cInfo, cChartSetting, cRequestSetting); source.Refresh(); } } } }
private static RequestSetting LoadDefaultSetting(RequestSetting setting, string aipUrl) { if (setting == null) { setting = new RequestSetting(); } //设置uri 信息等默认配置 IPosSettingService settingService = new SettingService(); var systemSettings = settingService.GetSystemSettings(); if (systemSettings == null) { throw new NetException("系统配置不完善,请先配置系统设置项目!"); } var serverConfig = systemSettings.GetCurrentServer(); if (serverConfig == null && !serverConfig.Verfy()) { throw new NetException("服务访问失败,请检查相关服务地址是否配置正确!"); } setting.Host = serverConfig.Host; setting.Port = serverConfig.Port; setting.Schema = serverConfig.Schema; setting.Path = aipUrl; return(setting); }
/// <summary> /// Delete 请求 /// </summary> /// <typeparam name="TParameter"></typeparam> /// <typeparam name="TResult"></typeparam> /// <param name="apiUrl"></param> /// <param name="parameter"></param> /// <param name="uriParameters"></param> /// <returns></returns> public static OperateResult <TResult> Delete <TParameter, TResult>(string apiUrl, TParameter parameter, Dictionary <string, string> uriParameters = null) { try { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "DELETE" }, apiUrl); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } if (!string.IsNullOrWhiteSpace(Token)) { setting.Headers.Add(HttpRequestHeader.Authorization, string.Format("Basic {0}", Token)); } setting = setting.SetUriParameters(uriParameters); return(GetResult <OperateResult <TResult> >(setting)); } catch (Exception ex) { // LoggerFactory.Create(ERPModule.POSClient.GetModuleName(), ).Warn("网络请求发生错误!", ex); return(new OperateResult <TResult>() { Code = "500", Message = "网络请求发生错误,请检查网络是否正常!" + ex.Message }); } }
private static TResult GetResult <TResult>(RequestSetting setting) where TResult : class { using (var request = new RestRequest <TResult>(setting)) { return(request.Execute()); } }
internal frmCreateScriptSetting(ChartSetting chartSetting, RequestSetting requestSetting, bool isNewSetting) { __cChartSetting = chartSetting; __cRequestSetting = requestSetting; __bNewSetting = isNewSetting; InitializeComponent(); InitializeSourceGrid(); }
private static RequestSetting LoadDefaultSetting(RequestSetting setting, string aipUrl, string appkey, string masterSecret) { if (setting == null) { setting = new RequestSetting(); } //设置uri 信息等默认配置 var keyBytes = Encoding.UTF8.GetBytes(string.Format("{0}:{1}", appkey, masterSecret)); var base64_auth_string = Convert.ToBase64String(keyBytes); setting.Headers.Add(string.Format("Authorization: Basic {0}", base64_auth_string)); setting.Host = "api.jpush.cn"; setting.Port = 443; setting.Schema = "https"; setting.Path = aipUrl; return(setting); }
public static TResult Post <TParameter, TResult>(TParameter parameter, Dictionary <string, string> uriParameters = null, string apiUrl = SubmitUrl) where TResult : class { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "POST" }, apiUrl, AppKey, MasterSecret); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } setting = setting.SetUriParameters(uriParameters); return(GetResult <TResult>(setting)); }
private static TOperateResult GetResult <TOperateResult>(RequestSetting setting) where TOperateResult : class { using (var request = new RestRequest <TOperateResult>(setting)) { if (Cookies != null && Cookies.Count > 0) { request.SetRequsetCookie(Cookies); } var result = request.ExecuteWithJsonToObject(); var cookies = request.GetResponeCookie(); if (cookies != null && cookies.Count > 0) { Cookies = cookies; } return(result); } }
private static TResult GetResult <TResult>(RequestSetting setting) where TResult : class { using (var request = new RestRequest <TResult>(setting)) { if (typeof(TResult) == typeof(string)) { return(request.ExecuteWithString() as TResult); } else if (typeof(TResult) == typeof(byte[])) { return(request.ExecuteWithBinary() as TResult); } else { return(request.ExecuteWithJsonToObject()); } } }
public static ApiRetrunResult <TResult> Post <TParameter, TResult>(string apiUrl, TParameter parameter, Dictionary <string, string> uriParameters = null) where TResult : class { RequestSetting setting = LoadDefaultSetting( new RequestSettingWithJsonContent <TParameter>(parameter) { Method = "POST" }, apiUrl); if (uriParameters == null) { uriParameters = new Dictionary <string, string>(); } if (!string.IsNullOrWhiteSpace(Token)) { uriParameters.Add("token", Token); } setting = setting.SetUriParameters(uriParameters); return(GetResult <ApiRetrunResult <TResult> >(setting)); }
private static void ModifyDataStreamInfo(_DataStreamInfo info, ChartSetting chart, RequestSetting request) { string[] sRanges = GetRequestRanges(request.Range); info.SymbolId = request.SymbolId; info.Range = string.Format("{0} {1}", sRanges[1], (sRanges[0][0] == 'f') ? string.Empty : sRanges[0]); info.LastDate = sRanges[2]; info.Period = request.DataPeriod; info.SubChart = (chart.IsSubChart) ? string.Format("SubChart #{0}", chart.LayerIndex + 1) : "Hide"; }
private static _DataStreamInfo CreateDataStreamInfo(int dataStream, ChartSetting chart, RequestSetting request, bool isNewSetting) { string[] sRanges = GetRequestRanges(request.Range); _DataStreamInfo cInfo = new _DataStreamInfo(); cInfo.DataStream = dataStream; cInfo.SymbolId = request.SymbolId; cInfo.Range = string.Format("{0} {1}", sRanges[1], (sRanges[0][0] == 'f') ? string.Empty : sRanges[0]); cInfo.LastDate = sRanges[2]; cInfo.Period = request.DataPeriod; cInfo.SubChart = (chart.IsSubChart) ? string.Format("SubChart #{0}", chart.LayerIndex + 1) : "Hide"; cInfo.IsNewSetting = isNewSetting; return(cInfo); }