public object GetBinding(EbDataSet dataSet, string bindingParam) { try { string[] parts = bindingParam.Split(CharConstants.DOT); if (parts.Length >= 2) { string columnName = parts[1]; string tableExpr = parts[0]; int tableIndex = Convert.ToInt32(tableExpr.Substring(tableExpr.Length - 1)); if (dataSet.TryGetTable(tableIndex, out EbDataTable dt)) { EbDataRow dr = dt.Rows?.FirstOrDefault(); if (dr != null) { return(dr[columnName]); } } } } catch (Exception ex) { EbLog.Error("dashboard control [GetBinding] error, " + ex.Message); } return(null); }
private async Task ImportSolutionData(EbMobileSolutionData solutionData) { if (solutionData == null) { return; } EbDataSet importData = solutionData.GetOfflineData(); DBService.Current.ImportData(importData); UpdateErrorDraftIds(solutionData.DraftIds); await Store.SetJSONAsync(AppConst.APP_COLLECTION, solutionData.Applications); await SetLocationInfo(solutionData.Locations); await SetCurrentUser(solutionData.CurrentUser); await SetSolutionObject(solutionData.CurrentSolution); await SetImagesInPdf(solutionData.Images); if (solutionData.ProfilePages != null && solutionData.ProfilePages.Count > 0) { await Store.SetJSONAsync(AppConst.EXTERNAL_PAGES, solutionData.ProfilePages); ExternalMobilePages = solutionData.ProfilePages; } if (CurrentApplication != null) { CurrentApplication = solutionData.Applications.Find(item => item.AppId == CurrentApplication.AppId); MobilePages = CurrentApplication?.MobilePages; WebObjects = CurrentApplication?.WebObjects; await Store.SetJSONAsync(AppConst.CURRENT_APP, CurrentApplication); } }
public EbDataSet DoQueries(string query, params DbParameter[] parameters) { EbDataSet ds = new EbDataSet(); using (var con = GetNewConnection() as NpgsqlConnection) { try { con.Open(); using (NpgsqlCommand cmd = new NpgsqlCommand(query, con)) { if (parameters != null && parameters.Length > 0) { cmd.Parameters.AddRange(parameters); } using (var reader = cmd.ExecuteReader()) { do { EbDataTable dt = new EbDataTable(); this.AddColumns(dt, reader.GetColumnSchema()); PrepareDataTable(reader, dt); ds.Tables.Add(dt); }while (reader.NextResult()); } } } catch (Npgsql.NpgsqlException npgse) { } } return(ds); }
public override void SetBindingValue(EbDataSet dataSet) { foreach (var ctrl in controls) { ctrl.SetBindingValue(dataSet); } }
public EbDataSet DoQueries(string query, params DbParameter[] parameters) { EbDataSet ds = new EbDataSet(); try { using SqliteConnection con = new SqliteConnection("Data Source=" + this.DbPath); con.Open(); using (SqliteCommand cmd = con.CreateCommand()) { cmd.CommandText = query; if (parameters != null && parameters.Length > 0) { cmd.Parameters.AddRange(this.DbParamToSqlParam(parameters)); } using var reader = cmd.ExecuteReader(); do { EbDataTable dt = new EbDataTable(); PrepareDataTable(reader, dt); ds.Tables.Add(dt); ds.RowNumbers += dt.Rows.Count.ToString() + ","; }while (reader.NextResult()); } con.Close(); } catch (Exception ex) { EbLog.Error("DataBaseAndroid.DoQueries---" + ex.Message); } return(ds); }
public override void SetBindingValue(EbDataSet dataSet) { foreach (EbMobileDashBoardControl ctrl in ChildControls) { ctrl.SetBindingValue(dataSet); } }
public int PersistIntegration(string Sol_Id, EbConnectionFactory infra, int UserId) { int nid = 0; string query = @"INSERT INTO eb_integrations (solution_id, type, preference, eb_integration_conf_id, created_at, created_by, eb_del) VALUES (@solution_id, @type, @preference, @conf_id, NOW(), @uid, 'F') RETURNING id;"; if (Id > 0) { query += @"UPDATE eb_integrations SET eb_del = 'T', modified_at = NOW(), modified_by = @uid WHERE id = @id;"; } DbParameter[] parameters = { infra.DataDB.GetNewParameter("solution_id", EbDbTypes.String, Sol_Id), infra.DataDB.GetNewParameter("type", EbDbTypes.String, this.Type.ToString()), infra.DataDB.GetNewParameter("preference", EbDbTypes.Int32, (int)Preference), infra.DataDB.GetNewParameter("conf_id", EbDbTypes.Int32, this.ConfigId), infra.DataDB.GetNewParameter("uid", EbDbTypes.Int32, UserId), infra.DataDB.GetNewParameter("id", EbDbTypes.Int32, this.Id) }; EbDataSet ds = infra.DataDB.DoQueries(query, parameters); nid = Convert.ToInt32(ds.Tables[0].Rows[0][0]); return(nid); }
public async Task <EbDataSet> GetFormLocalDataAsync(EbMobileForm form, int rowid) { EbDataSet ds = new EbDataSet(); try { //only to remove the warning await Task.Delay(1); EbDataTable masterData = App.DataDB.DoQuery($"SELECT * FROM {form.TableName} WHERE id = {rowid};"); masterData.TableName = form.TableName; ds.Tables.Add(masterData); foreach (var pair in form.ControlDictionary) { if (pair.Value is ILinesEnabled) { string linesQuery = $"SELECT * FROM {(pair.Value as ILinesEnabled).TableName} WHERE {form.TableName}_id = {rowid};"; EbDataTable linesData = App.DataDB.DoQuery(linesQuery); linesData.TableName = (pair.Value as ILinesEnabled).TableName; ds.Tables.Add(linesData); } } } catch (Exception ex) { EbLog.Error(ex.Message); } return(ds); }
public SqlJobGlobals(EbDataSet _ds, ref Dictionary <string, TV> global) { this.Tables = (_ds == null) ? null : _ds.Tables; this.Job = new SqlJobScriptHelper(ref global, this); Params = new NTVDict(); }
public override void SetBindingValue(EbDataSet dataSet) { if (!string.IsNullOrEmpty(BindingParam)) { object value = GetBinding(dataSet, BindingParam); label.Text = value?.ToString(); } }
private static void OnDataPropertyChanged(BindableObject bindable, object oldValue, object newValue) { DashBoardView binding = bindable as DashBoardView; EbDataSet ds = (EbDataSet)newValue; if (ds != null) { binding.BindValues(ds); } }
public CreateUserResponse Post(CreateUserRequest request) { CreateUserResponse resp; string sql = ""; using (var con = this.TenantDbFactory.ObjectsDB.GetNewConnection()) { con.Open(); if (request.Id > 0) { sql = @"UPDATE eb_users SET firstname= @firstname,email= @email WHERE id = @id RETURNING id; INSERT INTO eb_role2user(role_id,user_id,createdby,createdat) SELECT rid,@id,@userid,NOW() FROM UNNEST(array(SELECT unnest(@roles) except SELECT UNNEST(array(SELECT role_id from eb_role2user WHERE user_id = @id AND eb_del = FALSE)))) as rid; UPDATE eb_role2user SET eb_del = true,revokedby = @userid,revokedat =NOW() WHERE role_id IN( SELECT UNNEST(array(SELECT role_id from eb_role2user WHERE user_id = @id AND eb_del = FALSE)) except SELECT UNNEST(@roles)); INSERT INTO eb_user2usergroup(userid,groupid,createdby,createdat) SELECT @id,gid,@userid,NOW() FROM UNNEST(array(SELECT unnest(@group) except SELECT UNNEST(array(SELECT groupid from eb_user2usergroup WHERE userid = @id AND eb_del = FALSE)))) as gid; UPDATE eb_user2usergroup SET eb_del = true,revokedby = @userid,revokedat =NOW() WHERE groupid IN( SELECT UNNEST(array(SELECT groupid from eb_user2usergroup WHERE userid = @id AND eb_del = FALSE)) except SELECT UNNEST(@group));"; } else { sql = @"INSERT INTO eb_users (firstname,email,pwd) VALUES (@firstname,@email,@pwd) RETURNING id,pwd; INSERT INTO eb_role2user (role_id,user_id,createdby,createdat) SELECT id, (CURRVAL('eb_users_id_seq')),@userid,NOW() FROM UNNEST(@roles) AS id; INSERT INTO eb_user2usergroup(userid,groupid,createdby,createdat) SELECT (CURRVAL('eb_users_id_seq')), gid,@userid,NOW() FROM UNNEST(@group) AS gid"; } int[] emptyarr = new int[] { }; DbParameter[] parameters = { this.TenantDbFactory.ObjectsDB.GetNewParameter("firstname", System.Data.DbType.String, request.Colvalues["firstname"]), this.TenantDbFactory.ObjectsDB.GetNewParameter("email", System.Data.DbType.String, request.Colvalues["email"]), this.TenantDbFactory.ObjectsDB.GetNewParameter("roles", NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Integer, (request.Colvalues["roles"].ToString() != string.Empty? request.Colvalues["roles"].ToString().Split(',').Select(n => Convert.ToInt32(n)).ToArray():emptyarr)), this.TenantDbFactory.ObjectsDB.GetNewParameter("group", NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Integer, (request.Colvalues["group"].ToString() != string.Empty? request.Colvalues["group"].ToString().Split(',').Select(n => Convert.ToInt32(n)).ToArray():emptyarr)), this.TenantDbFactory.ObjectsDB.GetNewParameter("pwd", System.Data.DbType.String, string.IsNullOrEmpty(request.Colvalues["pwd"].ToString())? GeneratePassword() : (request.Colvalues["pwd"].ToString() + request.Colvalues["email"].ToString()).ToMD5Hash()), this.TenantDbFactory.ObjectsDB.GetNewParameter("userid", System.Data.DbType.Int32, request.UserId), this.TenantDbFactory.ObjectsDB.GetNewParameter("id", System.Data.DbType.Int32, request.Id) }; EbDataSet dt = this.TenantDbFactory.ObjectsDB.DoQueries(sql, parameters); if (string.IsNullOrEmpty(request.Colvalues["pwd"].ToString()) && request.Id < 0) { using (var service = base.ResolveService <EmailService>()) { // service.Post(new EmailServicesRequest() { To = request.Colvalues["email"].ToString(), Subject = "New User", Message = string.Format("You are invited to join as user. Log in {0}.localhost:53431 using Username: {1} and Password : {2}", request.TenantAccountId, request.Colvalues["email"].ToString(), dt.Tables[0].Rows[0][1]) }); } } resp = new CreateUserResponse { id = Convert.ToInt32(dt.Tables[0].Rows[0][0]) }; } return(resp); }
private void BindValues(EbDataSet dataSet) { if (controls == null) { return; } foreach (EbMobileDashBoardControl ctrl in controls) { ctrl.SetBindingValue(dataSet); } }
public override void SetBindingValue(EbDataSet dataSet) { if (string.IsNullOrEmpty(DataSourceRefId) && !string.IsNullOrEmpty(BindingTable)) { int tableIndex = Convert.ToInt32(BindingTable.Substring(BindingTable.Length - 1)); if (dataSet.TryGetTable(tableIndex, out EbDataTable dt)) { InitView(dt); } } }
public EbDataSet GetOfflineData() { EbDataSet ds = new EbDataSet(); Applications?.ForEach(item => { if (item.OfflineData != null) { ds.Tables.AddRange(item.OfflineData.Tables); } }); return(ds); }
public static EbDataSet ToDataSet(this WebformData data) { EbDataSet ds = new EbDataSet(); try { foreach (KeyValuePair <string, SingleTable> st in data.MultipleTables) { EbDataTable dt = new EbDataTable { TableName = st.Key }; for (int i = 0; i < st.Value.Count; i++) { EbDataRow dr = dt.NewDataRow(); for (int k = 0; k < st.Value[i].Columns.Count; k++) { SingleColumn sc = st.Value[i].Columns[k]; if (i == 0) { EbDataColumn dc = new EbDataColumn { ColumnIndex = k, Type = (EbDbTypes)sc.Type, ColumnName = sc.Name }; dt.Columns.Add(dc); } dr.Add((object)sc.Value); } dt.Rows.Add(dr); } ds.Tables.Add(dt); } } catch (Exception ex) { EbLog.Info("WebformData to dataset operation failed"); EbLog.Error(ex.StackTrace); } return(ds); }
public static string GetSearchResults(IDatabase DataDB, Eb_Solution SolutionObj, User UserObj, string searchTxt) { List <SearchRsltData> _data = new List <SearchRsltData>(); string Qry = @"SELECT COUNT(*) FROM eb_index_table eit WHERE COALESCE(eit.eb_del, 'F') = 'F' AND (SELECT COUNT(*) from json_each_text(eit.data_json :: JSON) WHERE LOWER(value) like '%' || @searchTxt || '%') > 0; SELECT eit.id, eit.display_name, eit.data_json, eit.ref_id, eit.data_id, eit.created_by, eit.created_at, eit.modified_by, eit.modified_at, eit.link_type FROM eb_index_table eit WHERE COALESCE(eit.eb_del, 'F') = 'F' AND (SELECT COUNT(*) from json_each_text(eit.data_json :: JSON) WHERE LOWER(value) like '%' || @searchTxt || '%') > 0 ORDER BY eit.modified_at DESC LIMIT 100; "; EbDataSet ds = DataDB.DoQueries(Qry, new DbParameter[] { DataDB.GetNewParameter("searchTxt", EbDbTypes.String, string.IsNullOrEmpty(searchTxt) ? "" : searchTxt.ToLower()) }); int rowCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]); foreach (EbDataRow dr in ds.Tables[1].Rows) { _data.Add(new SearchRsltData(dr, SolutionObj, UserObj)); } return(JsonConvert.SerializeObject(new SearchResponse() { Data = _data, RowCount = rowCount })); }
public static string ExecuteDecrypt(String ciphertext, string KeyName, string Refid, EbApi Api, EncryptionAlgorithm EncryptionAlgorithm) { string pri_key = ""; string plaintext = ""; try { if (!String.IsNullOrEmpty(KeyName)) { pri_key = Api.Redis.Get <string>("privatekey_" + Api.SolutionId + "_" + KeyName); } if (String.IsNullOrEmpty(pri_key) && !String.IsNullOrEmpty(Refid)) { EbDataReader dataReader = Api.GetEbObject <EbDataReader>(Refid, Api.Redis, Api.ObjectsDB); List <DbParameter> dbParameters = new List <DbParameter> { Api.DataDB.GetNewParameter("keyname", EbDbTypes.String, KeyName) }; EbDataSet dataSet = Api.DataDB.DoQueries(dataReader.Sql, dbParameters.ToArray()); pri_key = dataSet.Tables?[0].Rows[0]["key"].ToString(); Api.Redis.Set <string>("privatekey_" + Api.SolutionId + "_" + KeyName, pri_key); } if (EncryptionAlgorithm == EncryptionAlgorithm.RSA) { plaintext = RSADecrypt(ciphertext, pri_key); } } catch (Exception ex) { throw new ApiException("[ExecuteEncrypt], " + ex.Message); } return(plaintext); }
public void ImportData(EbDataSet dataSet) { EbLog.Info("Importing Data to local DB..."); if (dataSet?.Tables.Count > 0) { EbLog.Info($"Importing {dataSet?.Tables.Count} Tables"); foreach (EbDataTable dt in dataSet.Tables) { EbLog.Info($"Importing Tables {dt.TableName} with {dt.Rows.Count} records"); List <SQLiteColumSchema> ColSchema = new List <SQLiteColumSchema>(); foreach (EbDataColumn col in dt.Columns) { ColSchema.Add(new SQLiteColumSchema { ColumnName = col.ColumnName, ColumnType = SQLiteTableSchema.SQLiteType(col.Type) }); } DropTable(dt.TableName); EbLog.Info($"{dt.TableName} droped."); CreateTable(dt.TableName, ColSchema); EbLog.Info($"{dt.TableName} created."); App.DataDB.DoNonQueryBatch(dt); EbLog.Info($"Importing Tables {dt.TableName} complete."); } } }
private async Task InitializeFormData() { try { if (IsOffline()) { this.formData = await FormDataService.GetFormLocalDataAsync(this.Form, this.RowId); } else if (IsOnline()) { if (webFormData == null) { webFormData = await FormDataService.GetFormLiveDataAsync(this.Page.RefId, this.RowId, App.Settings.CurrentLocId); } this.formData = webFormData?.ToDataSet(); this.filesData = webFormData?.ToFilesMeta(); } } catch (Exception ex) { EbLog.Error($"InitializeFormData error in form edit '{this.Page.DisplayName}'"); EbLog.Error(ex.Message); } }
public DataSourceColumnsResponse Any(DataSourceColumnsRequest request) { string _dsRedisKey = string.Format("{0}_columns", request.RefId); EbDataSet _dataset = null; bool _isPaged = false; DataSourceColumnsResponse resp = this.Redis.Get <DataSourceColumnsResponse>(_dsRedisKey); if (resp == null || resp.Columns == null || resp.Columns.Count == 0) { resp = new DataSourceColumnsResponse(); resp.Columns = new List <ColumnColletion>(); // // getting DATASOURCE needs to be changed LIVE/DEV/TEST scenarios // string _sql_4dsBytea = string.Format(@" //SELECT // EOV.obj_json //FROM // eb_objects_ver EOV, eb_objects EO //WHERE // EO.id = EOV.eb_objects_id AND // EO.obj_last_ver_id = EOV.ver_num AND // EO.id = {0}", request.Id); // var dt = this.DatabaseFactory.ObjectsDB.DoQuery(_sql_4dsBytea); //if (dt.Rows.Count > 0) //{ var _ds = this.Redis.Get <EbDataSource>(request.RefId); // EbSerializers.Json_Deserialize<EbDataSource>(dt.Rows[0][0].ToString()); if (_ds != null) { Log.Info(">>>>>>>>>>>>>>>>>>>>>>>> dscolumns Sql: " /*+ _ds.SqlDecoded()*/); string _sql = _ds.Sql /*Decoded()*/.Replace("@and_search", string.Empty).Replace("@orderby", "1"); _isPaged = (_sql.ToLower().Contains("@offset") && _sql.ToLower().Contains("@limit")); var parameters = new List <System.Data.Common.DbParameter>(); if (_isPaged) { parameters.AddRange(new System.Data.Common.DbParameter[] { this.TenantDbFactory.ObjectsDB.GetNewParameter("@limit", System.Data.DbType.Int32, 0), this.TenantDbFactory.ObjectsDB.GetNewParameter("@offset", System.Data.DbType.Int32, 0) }); } if (request.Params != null) { foreach (Dictionary <string, string> param in request.Params) { parameters.Add(this.TenantDbFactory.ObjectsDB.GetNewParameter(string.Format("@{0}", param["name"]), (System.Data.DbType)Convert.ToInt32(param["type"]), param["value"])); } } Log.Info(">>>>>>>>>>>>>>>>>>>>>>>> dscolumns Parameters Added"); try { _dataset = this.TenantDbFactory.ObjectsDB.DoQueries(_sql, parameters.ToArray()); foreach (var dt in _dataset.Tables) { resp.Columns.Add(dt.Columns); } resp.IsPaged = _isPaged; this.Redis.Set <DataSourceColumnsResponse>(_dsRedisKey, resp); } catch (Exception e) { Log.Info(">>>>>>>>>>>>>>>>>>>>>>>> dscolumns e.Message: " + e.Message); this.Redis.Remove(_dsRedisKey); } } } return(resp); }
private int GetUserIdByEmailOrPhone(IDatabase DataDB, Dictionary <string, string> _d, ref int flag, bool ins, SingleColumn ocF) { int userId = 0; string _s = "SELECT id FROM eb_users WHERE LOWER(#) LIKE LOWER(@#) AND eb_del = 'F' AND (statusid = 0 OR statusid = 1 OR statusid = 2 OR statusid = 4);"; string sql; List <DbParameter> parameters = new List <DbParameter>(); if (ContainsKey(_d, "email"))//01 { sql = _s.Replace("#", "email"); parameters.Add(DataDB.GetNewParameter("email", EbDbTypes.String, _d["email"])); } else { sql = "SELECT 1 WHERE 1 = 0; "; } if (ContainsKey(_d, "phprimary"))//10 { sql += _s.Replace("#", "phnoprimary"); parameters.Add(DataDB.GetNewParameter("phnoprimary", EbDbTypes.String, _d["phprimary"])); } else { sql += "SELECT 1 WHERE 1 = 0; "; } EbDataSet ds = DataDB.DoQueries(sql, parameters.ToArray()); int oProvUserId = ocF == null ? 0 : Convert.ToInt32(ocF.Value); //Dictionary<string, string> _od = ocF == null ? new Dictionary<string, string>() : JsonConvert.DeserializeObject<Dictionary<string, string>>(Convert.ToString(ocF.F)); //int oCreUserId = ContainsKey(_od, "id") ? Convert.ToInt32(_od["id"]) : 0; if (ds.Tables[0].Rows.Count > 0) { userId = Convert.ToInt32(ds.Tables[0].Rows[0][0]); flag = 1; } if (ds.Tables[1].Rows.Count > 0) { int userId2 = Convert.ToInt32(ds.Tables[1].Rows[0][0]); flag |= 2; if (flag == 3) { if (userId != userId2) { if (!ins) { if (userId == oProvUserId && oProvUserId > 0) { _d.RemoveKey("phprimary"); flag &= 1; } if (userId2 == oProvUserId && oProvUserId > 0) { _d.RemoveKey("email"); flag &= 2; userId = oProvUserId; } } if (userId != userId2 && flag == 3) { throw new FormException($"Unable to continue with {_d["email"]} and {_d["phprimary"]}", (int)HttpStatusCode.BadRequest, $"Email and Phone already exists for different users: {_d["email"]}, {_d["phprimary"]}", "EbProvisionUser => GetUserIdByEmailOrPhone"); } } } else if (_d.ContainsKey("email") && _d["email"] != string.Empty && oProvUserId != userId2) { _d.RemoveKey("phprimary"); flag &= 1; return(0); } else { userId = userId2; } } else if (flag == 1 && _d.ContainsKey("phprimary") && _d["phprimary"] != string.Empty && oProvUserId != userId) { _d.RemoveKey("email"); flag &= 2; return(0); } return(userId); }
internal void OnSerializingMethod(StreamingContext context) { OfflineData = null; }
public TableColletion(EbDataSet dataset) { this.DataSet = dataset; }
public AppDataToMob() { MobilePages = new List <MobilePagesWraper>(); WebObjects = new List <WebObjectsWraper>(); OfflineData = new EbDataSet(); }
public static InsertDataFromWebformResponse SubmitErrorAndGetResponse(IDatabase DataDB, EbWebForm Form, InsertDataFromWebformRequest request, Exception ex) { try { Console.WriteLine("SaveErrorSubmission start"); Dictionary <string, string> MetaData = new Dictionary <string, string>(); string Qry = $@" INSERT INTO eb_form_drafts ( title, form_data_json, form_ref_id, message, stack_trace, is_submitted, eb_loc_id, eb_created_by, eb_created_at, eb_del, draft_type, eb_signin_log_id ) VALUES ( @title, @form_data_json, @form_ref_id, @error_message, @error_stacktrace, 'F', {request.CurrentLoc}, {request.UserId}, {DataDB.EB_CURRENT_TIMESTAMP}, 'F', {(int)FormDraftTypes.ErrorBin}, {Form.UserObj.SignInLogId} ); SELECT eb_currval('eb_form_drafts_id_seq');"; string message, stackTrace; if (ex is FormException formEx) { message = formEx.Message + "; " + formEx.MessageInternal; stackTrace = formEx.StackTrace + "; " + formEx.StackTraceInternal; } else { message = ex.Message; stackTrace = ex.StackTrace; } DbParameter[] parameters = new DbParameter[] { DataDB.GetNewParameter("title", EbDbTypes.String, Form.DisplayName), DataDB.GetNewParameter("form_data_json", EbDbTypes.String, request.FormData), DataDB.GetNewParameter("form_ref_id", EbDbTypes.String, Form.RefId), DataDB.GetNewParameter("error_message", EbDbTypes.String, message), DataDB.GetNewParameter("error_stacktrace", EbDbTypes.String, stackTrace) }; EbDataSet ds = DataDB.DoQueries(Qry, parameters); int _id = Convert.ToInt32(ds.Tables[0].Rows[0][0]); Console.WriteLine("SaveErrorSubmission returning"); return(new InsertDataFromWebformResponse() { Message = "Error submission saved", RowId = _id, RowAffected = 1000, AffectedEntries = "Error submission id: " + _id, Status = (int)HttpStatusCode.OK, MetaData = MetaData }); } catch (Exception _ex) { Console.WriteLine("Exception in SubmitErrorAndGetResponse\nMessage" + ex.Message + "\nStackTrace" + ex.StackTrace); if (ex is FormException formEx) { return(new InsertDataFromWebformResponse() { Message = formEx.Message, Status = formEx.ExceptionCode, MessageInt = formEx.MessageInternal + ": " + _ex.Message, StackTraceInt = formEx.StackTraceInternal }); } else { return(new InsertDataFromWebformResponse() { Message = FormErrors.E0132 + ex.Message, Status = (int)HttpStatusCode.InternalServerError, MessageInt = "Exception in SubmitErrorAndGetResponse[service]: " + _ex.Message, StackTraceInt = ex.StackTrace }); } } }
private void PostProcessTransationData(Dictionary <int, FormTransaction> Trans, Dictionary <string, string> DictVmAll) { string Qry = string.Empty; Dictionary <string, Dictionary <string, List <string> > > DictDm = new Dictionary <string, Dictionary <string, List <string> > >(); List <DbParameter> param = new List <DbParameter>(); foreach (TableSchema _table in this.WebForm.FormSchema.Tables) { foreach (ColumnSchema _column in _table.Columns) { bool fetchVm = _column.Control is IEbPowerSelect && !(_column.Control as IEbPowerSelect).IsDataFromApi; fetchVm = fetchVm || (_column.Control is EbSimpleSelect && (_column.Control as EbSimpleSelect).IsDynamic); fetchVm = fetchVm || (_column.Control is EbDGSimpleSelectColumn && (_column.Control as EbDGSimpleSelectColumn).IsDynamic); if (fetchVm) { string key = string.Concat(_table.TableName, "_", _column.ColumnName); if (DictVmAll.ContainsKey(key)) { if (!DictDm.ContainsKey(key)) { if (_column.Control is IEbPowerSelect) { Qry += (_column.Control as IEbPowerSelect).GetDisplayMembersQuery(this.DataDB, this.Service, DictVmAll[key].Substring(0, DictVmAll[key].Length - 1), param); } else if (_column.Control is EbSimpleSelect) { Qry += (_column.Control as EbSimpleSelect).GetDisplayMembersQuery(this.DataDB, this.Service, DictVmAll[key].Substring(0, DictVmAll[key].Length - 1)); } else { Qry += (_column.Control as EbDGSimpleSelectColumn).GetDisplayMembersQuery(this.DataDB, this.Service, DictVmAll[key].Substring(0, DictVmAll[key].Length - 1)); } DictDm.Add(key, new Dictionary <string, List <string> >()); } } } } } EbDataSet ds = DataDB.DoQueries(Qry, param.ToArray()); for (int i = 0; i < ds.Tables.Count; i++) { foreach (EbDataRow row in ds.Tables[i].Rows) { List <string> list = new List <string>(); for (int j = 1; j < row.Count; j++) { list.Add(row[j].ToString()); } if (!DictDm.ElementAt(i).Value.ContainsKey(row[0].ToString())) { DictDm.ElementAt(i).Value.Add(row[0].ToString(), list); } } } foreach (KeyValuePair <int, FormTransaction> trans in Trans) { foreach (KeyValuePair <string, FormTransactionRow> table in trans.Value.Tables) { ReplaceVmWithDm(table.Value.Columns, DictDm, table.Key); } foreach (KeyValuePair <string, FormTransactionTable> table in trans.Value.GridTables) { foreach (KeyValuePair <int, FormTransactionRow> row in table.Value.NewRows) { this.ReplaceVmWithDm(row.Value.Columns, DictDm, table.Key); } foreach (KeyValuePair <int, FormTransactionRow> row in table.Value.DeletedRows) { this.ReplaceVmWithDm(row.Value.Columns, DictDm, table.Key); } foreach (KeyValuePair <int, FormTransactionRow> row in table.Value.EditedRows) { this.ReplaceVmWithDm(row.Value.Columns, DictDm, table.Key); } } } }
public int PersistIntegrationConf(string Sol_Id, EbConnectionFactory infra, int UserId) { int nid = 0; string query = string.Empty; string json = EbSerializers.Json_Serialize(this);// JsonConvert.SerializeObject(this); DbParameter[] parameters = { infra.DataDB.GetNewParameter("solution_id", EbDbTypes.String, Sol_Id), infra.DataDB.GetNewParameter("nick_name", EbDbTypes.String, !(string.IsNullOrEmpty(this.NickName))?this.NickName:string.Empty), infra.DataDB.GetNewParameter("type", EbDbTypes.String, this.Type.ToString()), infra.DataDB.GetNewParameter("con_obj", EbDbTypes.Json, json), infra.DataDB.GetNewParameter("uid", EbDbTypes.Int32, UserId), infra.DataDB.GetNewParameter("id", EbDbTypes.Int32, this.Id) }; if (this.Id <= 0) { query = @" INSERT INTO eb_integration_configs (solution_id, nickname, type, con_obj, created_by, created_at, eb_del) VALUES (@solution_id, @nick_name, @type, @con_obj, @uid, NOW() , 'F') RETURNING id;"; EbDataSet ds = infra.DataDB.DoQueries(query, parameters); nid = Convert.ToInt32(ds.Tables[0].Rows[0][0]); } else { query = @" UPDATE eb_integration_configs SET modified_at = NOW(), modified_by = @uid, eb_del = 'T' WHERE id = @id; INSERT INTO eb_integration_configs (solution_id, nickname, type, con_obj, created_by, created_at, eb_del) VALUES (@solution_id, @nick_name, @type, @con_obj, @uid, NOW() , 'F') RETURNING id;"; EbDataSet ds = infra.DataDB.DoQueries(query, parameters); nid = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (this.Id != 0) { query = @"UPDATE eb_integrations SET eb_integration_conf_id = @nid WHERE eb_integration_conf_id = @oid; "; DbParameter[] parameter = { infra.DataDB.GetNewParameter("nid", EbDbTypes.Int32, nid), infra.DataDB.GetNewParameter("oid", EbDbTypes.Int32, this.Id) }; infra.DataDB.DoNonQuery(query, parameter); } } return(nid); }
private async Task <bool> GetLatestAutoId(List <AppData> Applications) { List <EbMobileAutoIdData> autoIdData = new List <EbMobileAutoIdData>(); try { foreach (AppData app in Applications) { foreach (MobilePagesWraper mobPageWrap in app.MobilePages) { EbMobilePage page = mobPageWrap.GetPage(); if (page.Container is EbMobileForm form) { EbMobileAutoId autoId = (EbMobileAutoId)form.ChildControls.Find(e => e is EbMobileAutoId); if (autoId != null && !string.IsNullOrWhiteSpace(form.TableName)) { string query = autoId.PrefixExpr?.GetCode(); if (!string.IsNullOrWhiteSpace(query) && page.NetworkMode == NetworkMode.Offline) { EbDataTable dt = App.DataDB.DoQuery(query); if (dt.Rows.Count > 0) { autoIdData.Add(new EbMobileAutoIdData() { Table = form.TableName, Column = autoId.Name, Prefix = dt.Rows[0][0]?.ToString() }); } } } } } } if (autoIdData.Count > 0) { RestRequest request = new RestRequest(ApiConstants.PULL_LATEST_AUTOID, Method.POST); RestClient client = new RestClient(App.Settings.RootUrl) { Timeout = ApiConstants.TIMEOUT_IMPORT }; request.AddParameter("data", JsonConvert.SerializeObject(autoIdData)); request.AddHeader(AppConst.BTOKEN, App.Settings.BToken); request.AddHeader(AppConst.RTOKEN, App.Settings.RToken); IRestResponse response = await client.ExecuteAsync(request); if (response.IsSuccessful) { EbDataSet ds = new EbDataSet(); EbMobileAutoIdDataResponse resp = JsonConvert.DeserializeObject <EbMobileAutoIdDataResponse>(response.Content); ds.Tables.Add(resp.OfflineData); DBService.Current.ImportData(ds); EbLog.Info("GetLatestAutoId success"); return(true); } else { EbLog.Warning("GetLatestAutoId failed"); } } } catch (Exception ex) { EbLog.Error("Error in GetLatestAutoId: " + ex.Message); } return(autoIdData.Count > 0 ? false : true); }
public virtual void SetBindingValue(EbDataSet dataSet) { }