private EbDataTable GetLocalData(string search, bool preload) { EbDataTable dt; string sql = HelperFunctions.B64ToString(powerSelect.OfflineQuery.Code).TrimEnd(';'); string WrpdQuery; if (preload) { WrpdQuery = $"SELECT * FROM ({sql}) AS WR LIMIT 100;"; } else { WrpdQuery = $"SELECT * FROM ({sql}) AS WR WHERE WR.{powerSelect.DisplayMember.ColumnName} LIKE '%{search}%' LIMIT 100;"; } try { dt = App.DataDB.DoQuery(WrpdQuery); } catch (Exception ex) { EbLog.Error(ex.Message); dt = new EbDataTable(); } return(dt); }
private List <DbParameter> GetParamLocal(EbDataRow row) { var parameters = new List <DbParameter>(); try { string sql = HelperFunctions.B64ToString(this.OfflineQuery.Code); List <string> _parameters = HelperFunctions.GetSqlParams(sql); foreach (string param in _parameters) { object data = row[param]; if (data != null) { parameters.Add(new DbParameter { ParameterName = param, Value = data }); } } } catch (Exception ex) { EbLog.Info("Visualization get parameters from local error"); EbLog.Error(ex.Message); } return(parameters); }
public async void AutoFill() { if (dataGrid.FormRenderMode == FormMode.EDIT) { return; } if (dataGrid.NetworkType == NetworkMode.Online && !string.IsNullOrEmpty(dataGrid.DataSourceRefId)) { try { MobileDataResponse data = await DataService.Instance.GetDataAsync(dataGrid.DataSourceRefId, 0, 0, dataGrid.Context?.ConvertToParams(), null, null, false, true); if (data != null && data.Data != null && data.Data.Tables.HasLength(2)) { SetValue(data.Data.Tables[1]); } } catch (Exception ex) { EbLog.Error("DataGrid autofill api error : " + ex.Message); } } else if ((dataGrid.NetworkType == NetworkMode.Offline || dataGrid.NetworkType == NetworkMode.Online) && !string.IsNullOrWhiteSpace(dataGrid.OfflineQuery?.Code)) { try { string sql = HelperFunctions.B64ToString(dataGrid.OfflineQuery.Code).TrimEnd(CharConstants.SEMICOLON); List <Param> Param = dataGrid.Context?.ConvertToParams() ?? new List <Param>(); List <DbParameter> dbParameters = new List <DbParameter>(); foreach (Param _p in Param) { dbParameters.Add(new DbParameter { ParameterName = _p.Name, Value = _p.Value, DbType = Convert.ToInt32(_p.Type) }); } EbDataTable dt = App.DataDB.DoQuery(sql, dbParameters.ToArray()); if (dt.Rows.Count > 0) { SetValue(dt); } } catch (Exception ex) { EbLog.Error("DataGrid autofill offline query error : " + ex.Message); } } }
private EbDataTable GetDataFromLocal(string value) { try { string sql = HelperFunctions.B64ToString(this.OfflineQuery.Code).TrimEnd(CharConstants.SEMICOLON); string WrpdQuery = $"SELECT * FROM ({sql}) AS WR WHERE WR.{this.ValueMember.ColumnName} = {value} LIMIT 1"; return(App.DataDB.DoQuery(WrpdQuery)); } catch (Exception ex) { EbLog.Info("power select failed to resolve display member from local"); EbLog.Error(ex.Message); } return(null); }
private DateTime GetMinDate() { DateTime date = DateTime.Now; try { string sql = HelperFunctions.B64ToString(MinValueExpr.Code); EbDataTable dt = App.DataDB.DoQuery(sql); if (dt.Rows.Count > 0) { date = Convert.ToDateTime(dt.Rows[0][0]); } } catch (Exception ex) { EbLog.Error($"Failed to run date min value expression of {Name}: {ex.Message}"); } return(date); }
public string GetCode() { return(HelperFunctions.B64ToString(this.Code)); }