public SinglePropertyMapping(SingleColumn column, IMemberAccessor member, int fileIndex, int workIndex) { this.column = column; this.member = member; this.FileIndex = fileIndex; this.WorkIndex = workIndex; }
private static void AddValue(Dictionary <string, string> _data, SingleColumn Column) { string _key, _val; if (Column.Control is EbDGColumn DGCol) { _key = DGCol.Title ?? DGCol.Name; } else { _key = Column.Control.Label ?? Column.Control.Name; } if (Column.Control is IEbPowerSelect) { _val = Column.D.Select(e => e.Value.Select(_e => _e.Value).Join(", ")).Join(" \n"); } else { _val = Convert.ToString(Column.Value); } if (string.IsNullOrWhiteSpace(_val)) { return; } if (_data.ContainsKey(_key)) { _data[_key] += " \n" + _val; } else { _data.Add(_key, _val); } }
public static Dictionary <string, List <FileMetaInfo> > ToFilesMeta(this WebformData data) { Dictionary <string, List <FileMetaInfo> > files = new Dictionary <string, List <FileMetaInfo> >(); try { foreach (KeyValuePair <string, SingleTable> st in data.ExtendedTables) { foreach (SingleRow row in st.Value) { if (row.Columns.Count > 0) { SingleColumn info = row.Columns[0]; List <FileMetaInfo> fileMeta = JsonConvert.DeserializeObject <List <FileMetaInfo> >(info.Value.ToString()); files.Add(st.Key, fileMeta); } } } } catch (Exception ex) { EbLog.Error(ex.Message); EbLog.Error(ex.StackTrace); } return(files); }
public SinglePropertyMapping(SingleColumn column, IMemberAccessor member, int physicalIndex, int logicalIndex) { this.column = column; Member = member; PhysicalIndex = physicalIndex; LogicalIndex = logicalIndex; }
static CreditText ParseSingle(XmlReader reader, GUISkin skin) { SingleColumn text = new SingleColumn(); text.style = skin.GetStyle(reader.GetAttribute("style")); text.text = reader.ReadInnerXml(); //Debug.Log ("Parsed single, Text = " + text.text + ", Style = " + text.style.ToString()); return(text); }
//for simple parameterization public ParameterizeCtrl_Params(IDatabase DataDB, List <DbParameter> param, SingleColumn cField, int i, User usr) { this.DataDB = DataDB; this.param = param; this.cField = cField; this.i = i; this.usr = usr; this.ins = true; this._cols = string.Empty; this._vals = string.Empty; this._colvals = string.Empty; }
protected override Task <ExtractedPDF> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken, Application client) { var inputFilePath = Data.Get(context); if (string.IsNullOrWhiteSpace(inputFilePath)) { throw new ArgumentNullException(Resources.PdfDataArgumentDisplayName); } var ocrFlag = OCR.Get(context); var textFlag = Text.Get(context); var metadataFlag = Metadata.Get(context); var tablesFlag = Tables.Get(context); var singleColumnFlag = SingleColumn.Get(context); return(client.ExtractPDF(inputFilePath, ocrFlag, textFlag, metadataFlag, tablesFlag, singleColumnFlag)); }
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); }
//for system/mobile notification public DbParameter[] GetParameters(EbWebForm _this, IDatabase DataDB, Dictionary <string, string> QryParams) { List <DbParameter> _p = new List <DbParameter>(); int _idx = 0; foreach (KeyValuePair <string, string> p in QryParams) { SingleTable Table = null; if (_this.FormData.MultipleTables.ContainsKey(p.Value)) { Table = _this.FormData.MultipleTables[p.Value]; } else if (_this.FormDataBackup?.MultipleTables.ContainsKey(p.Value) == true) { Table = _this.FormDataBackup.MultipleTables[p.Value]; } else { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} not found in MultipleTables"); } TableSchema _table = _this.FormSchema.Tables.Find(e => e.TableName == p.Value); if (_table.TableType != WebFormTableTypes.Normal) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but it is not a normal table"); } if (Table.Count != 1) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but table is empty"); } SingleColumn Column = Table[0].Columns.Find(e => e.Control?.Name == p.Key); if (Column?.Control == null) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but data not available"); } ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(DataDB, _p, Column, _idx, _this.UserObj); Column.Control.ParameterizeControl(args, _this.CrudContext); _idx = args.i; _p[_idx - 1].ParameterName = p.Key; } return(_p.ToArray()); }
private void CheckDGUniqe(SingleRow Row, ColumnSchema _column, TableSchema _table, List <string> Vals, EbWebForm WebForm) { if (Row.IsDelete) { return; } SingleColumn cField = Row.GetColumn(_column.ColumnName); if (cField == null || cField.Value == null || (Double.TryParse(Convert.ToString(cField.Value), out double __val) && __val == 0)) { return; } if (Vals.Contains(Convert.ToString(cField.Value))) { string msg2 = $" {(WebForm == MasterForm ? "" : "(DataPusher)")} {(cField.Control.Hidden ? "[Hidden]" : "")}"; string msg1 = $"Value in the '{(cField.Control as EbDGColumn).Title ?? cField.Control.Name}' column ({_table.Title ?? _table.ContainerName} Grid) must be unique" + msg2; msg2 = $"DG column is not unique. Control name: {_table.ContainerName}.{cField.Control.Name}" + msg2; throw new FormException(msg1, (int)HttpStatusCode.BadRequest, msg2, "EbWebFormCollection -> ExecUniqueCheck"); } Vals.Add(Convert.ToString(cField.Value)); }
public static List <T> GetFirstColumn <T>(this DBConnectionWrapper conn, Sql sql, DBTransactionWrapper trans = null) { IDbCommand command = conn.CreateCommand(sql, trans); var mapping = DBObjectMapping <SingleColumn <T> > .Get().ColumnMappingList.Single(); List <T> ret = new List <T>(); try { using (IDataReader reader = command.ExecuteReader()) { SingleColumn <T> obj = new SingleColumn <T>(); Action <SingleColumn <T>, IDataRecord, int> setter = null; if (reader.Read()) { setter = mapping.GetPropSetterForRecord(reader.GetFieldType(0)); reader.SetProperty(obj, mapping, setter, 0); ret.Add(obj.Val); } while (reader.Read()) { reader.SetProperty(obj, mapping, setter, 0); ret.Add(obj.Val); } } } catch (DbException ex) { //throw; throw new SqlCmdException("Error occurred when running SQL!", sql, ex); } return(ret); }
public SinglePropertyMapping(SingleColumn column, PropertyInfo property) { this.column = column; this.property = property; }
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); }
public void Update(IDatabase DataDB, List <DbParameter> param, ref string fullqry, ref string _extqry, ref int i) { ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(DataDB, param, i, _extqry); foreach (EbWebForm WebForm in this) { args.SetFormRelated(WebForm.TableName, WebForm.UserObj, WebForm); WebForm.DoRequiredCheck(WebForm == MasterForm); foreach (TableSchema _table in WebForm.FormSchema.Tables.FindAll(e => e.TableType != WebFormTableTypes.Review && !e.DoNotPersist)) { if (!WebForm.FormData.MultipleTables.ContainsKey(_table.TableName)) { continue; } foreach (SingleRow row in WebForm.FormData.MultipleTables[_table.TableName]) { args.ResetColVals(); if (row.RowId > 0) { SingleRow bkup_Row = WebForm.FormDataBackup.MultipleTables[_table.TableName].Find(e => e.RowId == row.RowId); if (bkup_Row == null) { Console.WriteLine($"Row edit request ignored(Row not in backup table). \nTable name: {_table.TableName}, RowId: {row.RowId}, RefId: {WebForm.RefId}"); continue; } string t = string.Empty; if (!row.IsDelete) { foreach (SingleColumn cField in row.Columns) { if (cField.Control != null) { SingleColumn ocF = bkup_Row.Columns.Find(e => e.Name.Equals(cField.Name)); args.UpdateSet(cField, ocF); cField.Control.ParameterizeControl(args, WebForm.CrudContext); } else { args.UpdateSet(cField); WebForm.ParameterizeUnknown(args); } } } else if (WebForm.DataPusherConfig == null && !_table.TableName.Equals(WebForm.TableName)) { List <TableSchema> _tables = WebForm.FormSchema.Tables.FindAll(e => e.IsDynamic && e.TableType == WebFormTableTypes.Grid); foreach (TableSchema _tbl in _tables) { t += $@"UPDATE {_tbl.TableName} SET eb_del = 'T', eb_lastmodified_by = @eb_modified_by, eb_lastmodified_at = {DataDB.EB_CURRENT_TIMESTAMP} WHERE {_table.TableName}_id = @{_table.TableName}_id_{args.i} AND {WebForm.TableName}_id = @{WebForm.TableName}_id AND COALESCE(eb_del, 'F') = 'F'; "; param.Add(DataDB.GetNewParameter(_table.TableName + "_id_" + args.i, EbDbTypes.Int32, row.RowId)); args.i++; } } string _qry = QueryGetter.GetUpdateQuery(WebForm, DataDB, _table.TableName, row.IsDelete); fullqry += string.Format(_qry, args._colvals, row.RowId); fullqry += t; } else { args.ResetColsAndVals(); foreach (SingleColumn cField in row.Columns) { args.InsertSet(cField); if (cField.Control != null) { cField.Control.ParameterizeControl(args, WebForm.CrudContext); } else { WebForm.ParameterizeUnknown(args); } } string _qry = QueryGetter.GetInsertQuery(WebForm, DataDB, _table.TableName, WebForm.TableRowId == 0); fullqry += string.Format(_qry, args._cols, args._vals); } fullqry += WebForm.InsertUpdateLines(_table.TableName, row, args); } } string IdParamName = WebForm.TableName + FormConstants._id + (WebForm.DataPusherConfig != null ? WebForm.CrudContext : string.Empty); param.Add(DataDB.GetNewParameter(IdParamName, EbDbTypes.Int32, WebForm.TableRowId)); if (!param.Exists(e => e.ParameterName == WebForm.TableName + FormConstants._eb_ver_id)) { param.Add(DataDB.GetNewParameter(WebForm.TableName + FormConstants._eb_ver_id, EbDbTypes.Int32, WebForm.RefId.Split(CharConstants.DASH)[4])); param.Add(DataDB.GetNewParameter(WebForm.TableName + FormConstants._refid, EbDbTypes.String, WebForm.RefId)); } } args.CopyBack(ref _extqry, ref i); }
public void ExecUniqueCheck(IDatabase DataDB, DbConnection DbCon) { string fullQuery = string.Empty; List <DbParameter> Dbparams = new List <DbParameter>(); List <EbControl> UniqueCtrls = new List <EbControl>(); int paramCounter = 0, mstrFormCtrls = 0; EbSystemColumns SysCols = this.MasterForm.SolutionObj.SolutionSettings.SystemColumns; foreach (EbWebForm WebForm in this) { if (WebForm.DataPusherConfig?.AllowPush == false) { continue; } foreach (TableSchema _table in WebForm.FormSchema.Tables.FindAll(e => e.TableType == WebFormTableTypes.Normal)) { if (!(WebForm.FormData.MultipleTables.TryGetValue(_table.TableName, out SingleTable Table) && Table.Count > 0)) { continue; } foreach (ColumnSchema _column in _table.Columns.FindAll(e => e.Control.Unique && !e.Control.BypassParameterization)) { SingleColumn cField = Table[0].GetColumn(_column.ColumnName); if (cField == null || cField.Value == null || (Double.TryParse(Convert.ToString(cField.Value), out double __val) && __val == 0)) { continue; } if (WebForm.FormDataBackup != null) { if (WebForm.FormDataBackup.MultipleTables.TryGetValue(_table.TableName, out SingleTable TableBkUp) && TableBkUp.Count > 0) { SingleColumn ocField = TableBkUp[0].GetColumn(_column.ColumnName); if (ocField != null && Convert.ToString(cField.Value).Trim().ToLower() == Convert.ToString(ocField.Value ?? string.Empty).Trim().ToLower()) { continue; } } } fullQuery += string.Format("SELECT id FROM {0} WHERE {5}{1}{6} = {5}@{1}_{2}{6} AND COALESCE({3}, {4}) = {4} AND id <> {7};", //check eb_ver_id here! _table.TableName, //0 _column.ColumnName, //1 paramCounter, //2 SysCols[SystemColumns.eb_del], //3 SysCols.GetBoolFalse(SystemColumns.eb_del), //4 _column.Control.EbDbType == EbDbTypes.String ? "LOWER(TRIM(" : string.Empty, //5 _column.Control.EbDbType == EbDbTypes.String ? "))" : string.Empty, //6 WebForm.TableRowId); //7 Dbparams.Add(DataDB.GetNewParameter($"{_column.ColumnName}_{paramCounter++}", _column.Control.EbDbType, cField.Value)); UniqueCtrls.Add(_column.Control); if (WebForm == MasterForm) { mstrFormCtrls++; } } } } if (fullQuery != string.Empty) { EbDataSet ds; if (DbCon == null) { ds = DataDB.DoQueries(fullQuery, Dbparams.ToArray()); } else { ds = DataDB.DoQueries(DbCon, fullQuery, Dbparams.ToArray()); } for (int i = 0; i < ds.Tables.Count; i++) { if (ds.Tables[i].Rows.Count > 0) { if (mstrFormCtrls > i) { throw new FormException($"{UniqueCtrls[i].Label} must be unique", (int)HttpStatusCode.BadRequest, $"Value of {UniqueCtrls[i].Label} is not unique. Control name: {UniqueCtrls[i].Name}", "EbWebFormCollection -> ExecUniqueCheck"); } else { throw new FormException($"{UniqueCtrls[i].Label} in data pusher must be unique", (int)HttpStatusCode.BadRequest, $"Value of {UniqueCtrls[i].Label} in data pusher is not unique. Control name: {UniqueCtrls[i].Name}", "EbWebFormCollection -> ExecUniqueCheck"); } } } } }
public void Update_Batch(IDatabase DataDB, List <DbParameter> param, ref string fullqry, ref string _extqry, ref int i) { ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(DataDB, param, i, _extqry); foreach (EbWebForm WebForm in this) { args.SetFormRelated(WebForm.TableName, WebForm.UserObj, WebForm); EbDataPusherConfig conf = WebForm.DataPusherConfig; foreach (KeyValuePair <string, SingleTable> entry in WebForm.FormData.MultipleTables) { foreach (SingleRow row in entry.Value) { args.ResetColVals(); if (row.RowId > 0) { //SingleRow bkup_Row = WebForm.FormDataBackup.MultipleTables[entry.Key].Find(e => e.RowId == row.RowId); //if (bkup_Row == null) //{ // Console.WriteLine($"Row edit request ignored(Row not in backup table). \nTable name: {entry.Key}, RowId: {row.RowId}, RefId: {WebForm.RefId}"); // continue; //} string t = string.Empty; if (!row.IsDelete) { foreach (SingleColumn cField in row.Columns) { if (cField.Control != null) { SingleColumn ocF = null;// bkup_Row.Columns.Find(e => e.Name.Equals(cField.Name)); args.UpdateSet(cField, ocF); cField.Control.ParameterizeControl(args, WebForm.CrudContext); } else { args.UpdateSet(cField); WebForm.ParameterizeUnknown(args); } } } string _qry = QueryGetter.GetUpdateQuery_Batch(WebForm, DataDB, entry.Key, row.IsDelete, row.RowId); fullqry += string.Format(_qry, args._colvals); fullqry += t; } else { args.ResetColsAndVals(); foreach (SingleColumn cField in row.Columns) { args.InsertSet(cField); if (cField.Control != null) { cField.Control.ParameterizeControl(args, WebForm.CrudContext); } else { WebForm.ParameterizeUnknown(args); } } string _qry = QueryGetter.GetInsertQuery_Batch(WebForm, DataDB, entry.Key); fullqry += string.Format(_qry, args._cols, args._vals); } fullqry += WebForm.InsertUpdateLines(entry.Key, row, args); } } if (!param.Exists(e => e.ParameterName == WebForm.TableName + FormConstants._eb_ver_id)) { param.Add(DataDB.GetNewParameter(WebForm.TableName + FormConstants._eb_ver_id, EbDbTypes.Int32, WebForm.RefId.Split(CharConstants.DASH)[4])); param.Add(DataDB.GetNewParameter(WebForm.TableName + FormConstants._refid, EbDbTypes.String, WebForm.RefId)); } } args.CopyBack(ref _extqry, ref i); }
protected static IColumnDefinition CreateColumnDefinition(TextColumnDefinition definition) { if (definition == null) { throw new ArgumentNullException(nameof(definition), "Column definition is not provided."); } string columnName = definition.Caption ?? definition.ColumnName; if (string.IsNullOrWhiteSpace(columnName)) { throw new ArgumentNullException(nameof(definition), $"{nameof(definition.ColumnName)} cannot be empty."); } if (definition.ColumnType == null) { return(new IgnoredColumn(columnName)); } switch (Type.GetTypeCode(definition.ColumnType)) { case TypeCode.Empty: case TypeCode.Object: case TypeCode.DBNull: throw new ArgumentException($"Invalid column type: {definition.ColumnType.FullName}"); case TypeCode.Boolean: var boolColumn = new BooleanColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.TrueString != null) { boolColumn.TrueString = definition.TrueString; } if (definition.FalseString != null) { boolColumn.FalseString = definition.FalseString; } if (definition.DefaultValue != null) { boolColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (definition.NullValues != null && definition.NullValues.Length > 0) { boolColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(boolColumn); case TypeCode.Char: var charColumn = new CharColumn(columnName) { IsNullable = definition.IsNullable, AllowTrailing = definition.AllowTrailing }; if (definition.DefaultValue != null) { charColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } return(charColumn); case TypeCode.SByte: var sbyteColumn = new SByteColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { sbyteColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { sbyteColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { sbyteColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { sbyteColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { sbyteColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(sbyteColumn); case TypeCode.Byte: var byteColumn = new ByteColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { byteColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { byteColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { byteColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { byteColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { byteColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(byteColumn); case TypeCode.Int16: var shortColumn = new Int16Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { shortColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { shortColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { shortColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { shortColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { shortColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(shortColumn); case TypeCode.UInt16: var ushortColumn = new UInt16Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { ushortColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { ushortColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { ushortColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { ushortColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { ushortColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(ushortColumn); case TypeCode.Int32: var intColumn = new Int32Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { intColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { intColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { intColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { intColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { intColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(intColumn); case TypeCode.UInt32: var uintColumn = new UInt32Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { uintColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { uintColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { uintColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { uintColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { uintColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(uintColumn); case TypeCode.Int64: var longColumn = new Int64Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { longColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { longColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { longColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { longColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { longColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(longColumn); case TypeCode.UInt64: var ulongColumn = new UInt64Column(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { ulongColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { ulongColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { ulongColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { ulongColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { ulongColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(ulongColumn); case TypeCode.Single: var singleColumn = new SingleColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { singleColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { singleColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { singleColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { singleColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { singleColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(singleColumn); case TypeCode.Double: var doubleColumn = new DoubleColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { doubleColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { doubleColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { doubleColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { doubleColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { doubleColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(doubleColumn); case TypeCode.Decimal: var decimalColumn = new DecimalColumn(columnName) { IsNullable = definition.IsNullable }; if (definition.NumberStyles.HasValue) { decimalColumn.NumberStyles = definition.NumberStyles.Value; } if (definition.DefaultValue != null) { decimalColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { decimalColumn.OutputFormat = definition.OutputFormat; } if (!string.IsNullOrWhiteSpace(definition.Culture)) { decimalColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { decimalColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(decimalColumn); case TypeCode.DateTime: var datetimeColumn = new DateTimeColumn(columnName) { IsNullable = definition.IsNullable }; if (!string.IsNullOrWhiteSpace(definition.InputFormat)) { datetimeColumn.InputFormat = definition.InputFormat; } if (!string.IsNullOrWhiteSpace(definition.OutputFormat)) { datetimeColumn.OutputFormat = definition.OutputFormat; } if (definition.DefaultValue != null) { datetimeColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (!string.IsNullOrWhiteSpace(definition.Culture)) { datetimeColumn.FormatProvider = new CultureInfo(definition.Culture); } if (definition.NullValues != null && definition.NullValues.Length > 0) { datetimeColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(datetimeColumn); case TypeCode.String: var stringColumn = new StringColumn(columnName) { IsNullable = definition.IsNullable, Trim = definition.Trim }; if (definition.DefaultValue != null) { stringColumn.DefaultValue = DefaultValue.Use(definition.DefaultValue); } if (definition.NullValues != null && definition.NullValues.Length > 0) { stringColumn.NullFormatter = new NullFormatter(definition.NullValues, definition.NullComparison); } return(stringColumn); default: throw new ArgumentException("Invalid column type for text import/export."); } }
public void UpdateSet(SingleColumn cField, SingleColumn ocF = null) { this.ins = false; this.cField = cField; this.ocF = ocF; }
public void InsertSet(SingleColumn cField) { this.ins = true; this.cField = cField; this.ocF = null; }
private static void GetCSharpFormGlobalsRec_NEW(FG_WebForm fG_WebForm, EbControlContainer _container, WebformData _formdata, WebformData _formdataBkUp) { SingleTable Table = _formdata.MultipleTables.ContainsKey(_container.TableName) ? _formdata.MultipleTables[_container.TableName] : new SingleTable(); SingleTable TableBkUp = _formdataBkUp != null && _formdataBkUp.MultipleTables.ContainsKey(_container.TableName) ? _formdataBkUp.MultipleTables[_container.TableName] : new SingleTable(); if (_container is EbDataGrid) { fG_WebForm.DataGrids.Add(GetDataGridGlobal(_container as EbDataGrid, Table, _formdata.DGsRowDataModel[_container.TableName])); } else if (_container is EbReview) { fG_WebForm.Review = GetReviewGlobal(_container as EbReview, Table, TableBkUp); } else { foreach (EbControl _control in _container.Controls) { if (_control is EbControlContainer) { GetCSharpFormGlobalsRec_NEW(fG_WebForm, _control as EbControlContainer, _formdata, _formdataBkUp); } else { object data = null; Dictionary <string, object> Metas = new Dictionary <string, object>(); if (_control is EbAutoId && fG_WebForm.__mode == "new")// && fG_WebForm.id == 0 { data = FG_Constants.AutoId_PlaceHolder; } else { SingleColumn psSC = null; if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null && !(_control is EbAutoId)) //(!(_control is EbAutoId) || (_control is EbAutoId && fG_WebForm.__mode == "edit")))// && fG_WebForm.id > 0 { data = Table[0][_control.Name]; psSC = Table[0].GetColumn(_control.Name); } else if (TableBkUp.Count > 0 && TableBkUp[0].GetColumn(_control.Name) != null) { data = TableBkUp[0][_control.Name]; psSC = TableBkUp[0].GetColumn(_control.Name); } else if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null)// Hint: For BatchDataPusher, AutoId available in 'Table' only { data = Table[0][_control.Name]; psSC = Table[0].GetColumn(_control.Name); } if (psSC != null && _control is IEbPowerSelect) { Metas.Add(FG_Constants.Columns, psSC.R); } } if (_control is EbAutoId ebAI) { Metas.Add(FG_Constants.SerialLength, ebAI.Pattern?.SerialLength ?? 0); } fG_WebForm.FlatCtrls.Controls.Add(new FG_Control(_control.Name, _control.ObjType, data, Metas)); } } } }
private string[] GetApproverEntityValues(ref int i, EbReviewStage nextStage, out bool hasPerm) { string _col = string.Empty, _val = string.Empty; this.webForm.MyActNotification = new MyActionNotification() { ApproverEntity = nextStage.ApproverEntity, SendPushNotification = !nextStage.HideNotification }; if (nextStage.ApproverEntity == ApproverEntityTypes.Role) { _col = "role_ids"; _val = $"@role_ids_{i}"; string roles = nextStage.ApproverRoles == null ? string.Empty : nextStage.ApproverRoles.Join(","); this.param.Add(this.DataDB.GetNewParameter($"role_ids_{i++}", EbDbTypes.String, roles)); this.webForm.MyActNotification.RoleIds = nextStage.ApproverRoles; hasPerm = this.webForm.UserObj.RoleIds.Any(e => nextStage.ApproverRoles.Contains(e)); } else if (nextStage.ApproverEntity == ApproverEntityTypes.UserGroup) { _col = "usergroup_id"; _val = $"@usergroup_id_{i}"; this.param.Add(this.DataDB.GetNewParameter($"usergroup_id_{i++}", EbDbTypes.Int32, nextStage.ApproverUserGroup)); this.webForm.MyActNotification.UserGroupId = nextStage.ApproverUserGroup; hasPerm = this.webForm.UserObj.UserGroupIds.Any(e => e == nextStage.ApproverUserGroup); } else if (nextStage.ApproverEntity == ApproverEntityTypes.Users || nextStage.ApproverEntity == ApproverEntityTypes.DynamicRole) { string t1 = string.Empty, t2 = string.Empty, t3 = string.Empty; List <DbParameter> _params = new List <DbParameter>(); int _idx = 0, ErrCod = (int)HttpStatusCode.BadRequest; string ErrMsg = "GetFirstMyActionInsertQuery: Review control parameter {0} is not idetified"; foreach (KeyValuePair <string, string> p in nextStage.QryParams) { if (EbFormHelper.IsExtraSqlParam(p.Key, this.webForm.TableName)) { continue; } SingleTable _Table = null; if (this.webForm.FormData.MultipleTables.ContainsKey(p.Value)) { _Table = this.webForm.FormData.MultipleTables[p.Value]; } else if (this.webForm.FormDataBackup != null && this.webForm.FormDataBackup.MultipleTables.ContainsKey(p.Value)) { _Table = this.webForm.FormDataBackup.MultipleTables[p.Value]; } else { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} not found in MultipleTables"); } TableSchema _table = this.webForm.FormSchema.Tables.Find(e => e.TableName == p.Value); if (_table.TableType != WebFormTableTypes.Normal) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but it is not a normal table"); } if (_Table.Count != 1) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but table is empty"); } SingleColumn Column = _Table[0].Columns.Find(e => e.Control?.Name == p.Key); if (Column == null || Column.Control == null) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but data not available"); } ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(this.DataDB, _params, Column, _idx, this.webForm.UserObj); Column.Control.ParameterizeControl(args, this.webForm.CrudContext); _idx = args.i; _params[_idx - 1].ParameterName = p.Key; } List <int> ids = new List <int>(); EbFormHelper.AddExtraSqlParams(_params, this.DataDB, this.webForm.TableName, this.webForm.TableRowId, this.webForm.LocationId, this.webForm.UserObj.UserId); string qry = nextStage.ApproverEntity == ApproverEntityTypes.Users ? nextStage.ApproverUsers.Code : nextStage.ApproverRoleQuery.Code; EbDataTable dt = this.DataDB.DoQuery(qry, _params.ToArray()); foreach (EbDataRow dr in dt.Rows) { int.TryParse(dr[0].ToString(), out int temp); if (!ids.Contains(temp)) { ids.Add(temp); } } _val = $"'{ids.Join(",")}'"; if (nextStage.ApproverEntity == ApproverEntityTypes.Users) { _col = "user_ids"; this.webForm.MyActNotification.UserIds = ids; hasPerm = ids.Any(e => e == this.webForm.UserObj.UserId); } else { _col = "role_ids"; this.webForm.MyActNotification.RoleIds = ids; hasPerm = this.webForm.UserObj.RoleIds.Any(e => ids.Contains(e)); } } else { throw new FormException("Unable to process review control", (int)HttpStatusCode.InternalServerError, "Invalid value for ApproverEntity : " + nextStage.ApproverEntity, "From GetMyActionInsertUpdateQuery"); } if (this.webForm.UserObj.Roles.Contains(SystemRoles.SolutionOwner.ToString()) || this.webForm.UserObj.Roles.Contains(SystemRoles.SolutionAdmin.ToString())) { hasPerm = true; } return(new string[] { _col, _val }); }