public insertselect(ddl db, Fields fields, FieldInfo pk_for_auto_newid_seq) { Top = 0; Distinct = false; Tables = null; Joins = null; Where = null; GroupBy = null; Having = null; OrderBy = null; Fields = new selectlist(); foreach (Field f in fields) { if (pk_for_auto_newid_seq != null && f.Name == pk_for_auto_newid_seq.Name) /* [dlatikay 20110729] we can easily auto-increment for the next free integer PK value herein */ { Fields.Add(new selectfield(new selectstatement( new selectlist() { new selectfield(selectfunctiondef.max_inc, f.Name) }, new tableexpressions(pk_for_auto_newid_seq.DeclaringType), null, null ), f.Name)); } else { Fields.Add(new selectparam(db.MakeParamName(f.Name), f.Name, f.Type, f.Size)); } } }
public bool CreateRelation(ddl worker, Type table) { bool success = true; string name; Fields fields; /* derive field list and attributes from table definition */ if (!TableNameFromTableType(table, out name)) { return(false); } if (!FieldCollectionFromTableType(table, true, out fields)) { return(false); } foreach (Field f in fields) { /* execute if it participates in a relation */ if (f.RelatedTable != null && f.RelatedTable.Length > 0) { if (!worker.CreateRelation(name, f)) { success = false; } } } /* final result */ return(success); }
public bool CreateTable(ddl worker, Type table) { string name; string comment; Fields fields; /* derive field list and attributes from table definition */ if (!TableNameFromTableType(table, out name)) { return(false); } if (!TableCommentFromTableType(table, out comment)) { return(false); } if (!FieldCollectionFromTableType(table, true, out fields)) { return(false); } /* execute */ bool result = false; try { result = worker.CreateTable(name, comment, fields); } catch (Exception ex) { throw new InvalidOperationException(String.Format("While attempting to create table \"{0}\" ({1}).", name, comment), ex); } return(result); }
public bool CreateAllRelations(ddl worker) { bool success = true; Module mod = this.GetType().Module; Type[] types = mod.GetTypes(); foreach (Type ty in types) { if (!ty.IsAbstract) { Type[] ifs = ty.GetInterfaces(); if (TypeArrayContains(ifs, typeof(ITable))) { if (!TypeArrayContains(ifs, typeof(IView))) { /* cue with others on error */ if (!CreateRelation(worker, ty)) { success = false; } } } } } /* complete */ return(success); }
internal bool ImportTable(ddl worker, ITable sherm_table, FileStream source) { try { /* deflate it */ using (GZipStream zip = new GZipStream(source, CompressionMode.Decompress)) { using (MemoryStream mem = new MemoryStream()) { /* copy from decompressor */ byte[] buf = new byte[1024]; int bytesread = zip.Read(buf, 0, buf.Length); while (bytesread > 0) { mem.Write(buf, 0, bytesread); bytesread = zip.Read(buf, 0, buf.Length); } /* get its contents */ mem.Position = 0; OnLoadProgress(0); sherm_table.DeserializeContent(worker, mem, OnLoadProgress); OnLoadProgress(100); } } /* succeeded */ return(true); } catch (Exception ex) { /* some error */ OnLoadError(sherm_table.TableName, ex.ToString()); return(false); } }
public override string Parameterlist(ddl db, List <DbParameter> parameters) { if (parameters == null || parameters.Count <= 0) { return(""); } /* compose the procedure's parameter interface for mssql */ syntaxfactory syn = new syntaxfactory(db.Provider); typedesignator typ = syn.GenerateTypedesignator; List <string> list = new List <string>(); foreach (DbParameter parm in parameters) { /* name */ string spar = parm.ParameterName.ToLower(); if (!spar.StartsWith("@")) { spar = "@" + spar; } /* data type */ spar += " " + typ.Complete(parm.DbType, parm.Size, true); /* next */ list.Add(spar); } /* deliver as enter-separated list */ return(String.Join("," + Environment.NewLine, list.ToArray())); }
public override bool SerializeContent(ddl db, Stream destination) { DataSet ds; /* obtain */ try { using (var p = new commandadhoc(db, new selectstatement( /* leave out the actual binary */ new selectlist() { new selectfield("BinID"), new selectfield("iMIME"), new selectfield("sMIME"), new selectfield("LCID"), new selectfield("URI"), new selectfield("Filename"), new selectfield("Label"), new selectliteral(new literal(new Byte[] { 0 }, DbType.Object, 0), "Chunk"), new selectfield("OriginalSizeBytes"), /* added [dlatikay 20120203] */ new selectfield("EOK"), new selectfield("Compression"), new selectfield("crea_who"), new selectfield("crea_when") }, new tableexpressions(this.GetType()), null, null ))) { using (var table = p.ExecuteSelectToNew()) { /* prepare */ if (table.DataSet == null) { ds = new DataSet(); ds.Tables.Add(table); } else { ds = table.DataSet; } /* serialize */ ds.RemotingFormat = SerializationFormat.Binary; BinaryFormatter fmt = new BinaryFormatter(); fmt.Serialize(destination, ds); } } /* succeeded */ return(true); } catch (Exception ex) { /* something went wrong */ throw new DALException("failed to serialize " + TableName + ": " + ex.Message, ex); } }
public bool CreateProceduresCRUD(ddl worker, ITable Tab) { try { return(worker.CreateProceduresCRUD(Tab)); } catch (Exception ex) { throw new DALException(String.Format("Failed to create CRUD procedures for \"{0}\": {1}", Tab.GetType().Name, ex.ToString()), ex); } }
public override string Parameterlist(ddl db, List <DbParameter> parameters) { const string cursor_outparam = "prc OUT sys_refcursor"; if (parameters == null || parameters.Count <= 0) { return(_is_returning_rowset ? String.Format("({0})", cursor_outparam) : String.Empty); } /* compose the procedure's parameter interface for mssql */ var syn = new syntaxfactory(db.Provider); var typ = syn.GenerateTypedesignator; var list = new List <string>(); var mentioned = new List <string>(); foreach (DbParameter parm in parameters) { /* name */ string spar = parm.ParameterName.ToLower(); if (spar.StartsWith("@") || spar.StartsWith(":")) { spar = "p__" + spar.Substring(1); /* DL20130710DIEJFE9EF */ } /* duplicate prevention */ if (!mentioned.Contains(spar)) { mentioned.Add(spar); /* data type */ spar += " " + typ.Complete(parm.DbType, parm.Size, true); /* next */ list.Add(spar); } } /* [dlatikay 20130710] procs which return rowsets need the rowset as an output parameter */ if (_is_returning_rowset) { list.Add(cursor_outparam); } /* deliver as enter-separated list */ var raw = String.Join(",", list.ToArray()); if (String.IsNullOrWhiteSpace(raw) == false) { return(String.Format("({0})", raw)); } else { return(raw); } }
public bool CreateAllVitalProcedures(ddl worker) { bool success = true; Module mod = this.GetType().Module; Type[] types = mod.GetTypes(); List <Icommand> unsorted = new List <Icommand>(); foreach (Type ty in types) { if (!ty.IsAbstract) { Type[] ifs = ty.GetInterfaces(); if (TypeArrayContains(ifs, typeof(Icommand))) { /* cue with others on error */ if (ty.GetCustomAttributes(typeof(VitalAttribute), true).Length > 0) { if (ty.GetConstructor(new Type[] { ((Iddl)worker).GetType() }) != null) /* [dlatikay 20110525] additional fuse */ { try { Icommand Proc = (Icommand)Activator.CreateInstance(ty, (Iddl)worker); /* passing the constructor argument */ unsorted.Add(Proc); } catch { if (Debugger.IsAttached) { Debugger.Break(); } } } } } } } var sorted = unsorted.OrderBy(p => p.GetType().Name); foreach (Icommand proc in sorted) { if (!CreateProcedure(worker, proc, true)) { success = false; } } /* complete */ return(success); }
public bool ExportAllData(ddl worker, bool include_binstorage, bool include_logtables, string dest_directory) { bool success = true; bool take_that; /* enum the tables */ Module mod = this.GetType().Module; var types = new List <Type>(mod.GetTypes()); types.Sort((t1, t2) => t1.Name.CompareTo(t2.Name)); /* added [kwallisc,dlatikay 20101022]; fixed with lambda [dlatikay 20101103] */ foreach (Type ty in types) { if (!ty.IsAbstract) { Type[] ifs = ty.GetInterfaces(); if (TypeArrayContains(ifs, typeof(ITable))) { if (!TypeArrayContains(ifs, typeof(IView))) { /* see whether we should include this one */ take_that = true; if (ty.Name.StartsWith(typeof(doc02Binaries).Name)) /* covering doc02Binaries and doc02BinariesL */ { take_that = include_binstorage; } if (ty.Name.StartsWith("log02") || ty.Name.StartsWith(typeof(sys02CSI).Name) || ty.Name.StartsWith(typeof(doc02FT).Name)) /* CSI AND CSIA added [dlatikay 20101022], doc02FT added [dlatikay 20130926] */ { take_that = include_logtables; } if (take_that) { OnDumpProgress(ty.Name, null); if (ExportTable(worker, ty, dest_directory, TableExportFormat.RawDump, null)) { OnDumpProgress(ty.Name, true); } else { /* cue, but eventually report failure */ OnDumpProgress(ty.Name, false); success = false; } } } } } } return(success); }
public bool CreateAllTables(ddl worker) { bool success = true; Module mod = this.GetType().Module; var types = ListAllSchemaTables(); foreach (Type ty in types) { if (!CreateTable(worker, ty)) { /* cue with others on error */ success = false; } } /* complete */ return(success); }
public bool CreateView(ddl worker, IView view, bool continueonerror) { try { return(worker.CreateView(view)); } catch (Exception ex) { if (continueonerror) { Tracing.WarningDAL("Failed to create view \"{0}\": {1}", view.GetType().Name, ex.ToString()); return(false); } else { throw new DALException(String.Format("Failed to create view \"{0}\": {1}", view.GetType().Name, ex.ToString()), ex); } } }
public updateselect(ddl db, Fields fields) { Top = 0; Distinct = false; Tables = null; Joins = null; Where = new whereclause(fields.PKQueryExpression(db)); GroupBy = null; Having = null; OrderBy = null; Fields = new selectlist(); foreach (Field f in fields) { if (!f.PrimaryKeyConstituent) { Fields.Add(new selectparam(db.MakeParamName(f.Name), f.Name, f.Type, f.Size)); } } }
//método para listar no combobox public List <ddl> Lista() { List <ddl> lista = new List <ddl>(); ddl ddlObj1 = new ddl(); ddlObj1.Id = "F"; ddlObj1.Nome = "FEMININO"; lista.Add(ddlObj1); ddl ddlObj2 = new ddl(); ddlObj2.Id = "M"; ddlObj2.Nome = "MASCULINO"; lista.Add(ddlObj2); return(lista); }
public override bool BulkInsertExecute <Tcollection, Telement>(ddl db, Type ttype, Tcollection data) { using (var bc = new SqlBulkCopy((SqlConnection)conn, SqlBulkCopyOptions.KeepNulls, (SqlTransaction)trans)) { using (var dr = new ShermSqlBulkCopyReader <Tcollection, Telement>()) { /* inject our data */ var columns = dr.Inject(ttype, data); /* commit... */ bc.DestinationTableName = typeof(Telement).Name; /* added [dlatikay 20140808] solving MEA-2014-00343 */ foreach (var col in columns) { bc.ColumnMappings.Add(col, col); } bc.WriteToServer(dr); } } return(true); }
public List <ddl> ddl(Int32 IdFormaPagamento) { using (ISession session = NHibernateHelper.AbreSessao()) { var retorno = session.Query <FormaPagamentoParcelamento>().Where(o => o.FormaPagamento.Id == IdFormaPagamento).OrderBy(o => o.Id).ToList(); List <ddl> lista = new List <ddl>(); foreach (var obj in retorno) { ddl Objddl = new ddl(); Objddl.Id = Convert.ToString(obj.Id); Objddl.Nome = Convert.ToString(obj.QtdParcelas) + "X - Juros em cada Parcela: " + obj.Juros.ToString("###,###,###,##0.00"); //ToString("###,###,###,##0.00") lista.Add(Objddl); } return(lista); } }
public List <ddl> ddl() { using (ISession session = NHibernateHelper.AbreSessao()) { var retorno = session.Query <ParcelamentoStatus>().OrderBy(o => o.Id).ToList(); List <ddl> lista = new List <ddl>(); foreach (var obj in retorno) { ddl Objddl = new ddl(); Objddl.Id = Convert.ToString(obj.Id); Objddl.Nome = Convert.ToString(obj.Descricao); lista.Add(Objddl); } return(lista); } }
public List <ddl> ddl() { using (ISession session = NHibernateHelper.AbreSessao()) { var retorno = session.Query <UnidadeMedida>(). OrderBy(o => o.Descricao).ToList(); List <ddl> lista = new List <ddl>(); foreach (var obj in retorno) { ddl Objddl = new ddl(); Objddl.Id = Convert.ToString(obj.Id); Objddl.Nome = Convert.ToString(obj.Sigla) + " - " + obj.Descricao; lista.Add(Objddl); } return(lista); } }
/// <summary> /// Especially useful for the binary tables, which contain huge chunks (files) /// </summary> private void CopyBinRowwise(ddl db1, ddl db2, string tablename) { var binids_to_copy = new List <int>(); Istatement sel_keys = new plainselect( new string[] { "BinID" }, tablename ); using (var p = new commandadhoc(db1, sel_keys)) { using (var table = p.ExecuteSelectToNew()) { foreach (DataRow dr in table.Rows) { binids_to_copy.Add(Convert.ToInt32(dr[0])); } } } /* prepare a command which selects the data from a row */ /* -!!- continue here if time, ever * when ready, undo commenting out call in above function */ }
public bool CreateProcedure(ddl worker, Icommand proc, bool continueonerror) { try { return(worker.CreateProcedure(proc)); } catch (Exception ex) { var list = from x in Assembly.GetExecutingAssembly().GetTypes() where x.Name.StartsWith("pr") && x.Name.Contains("02") && x.Name.Length > 30 select x; foreach (var name in list) { Debug.WriteLine(name); } if (continueonerror) { Tracing.WarningDAL("Failed to create stored procedure \"{0}\": {1}", proc.GetType().Name, ex.ToString()); return(false); } else { throw new DALException(String.Format("Failed to create stored procedure \"{0}\": {1}", proc.GetType().Name, ex.Message), ex); } } }
public pracc02CubeFillNoContextPerson(ddl _conn) : base(_conn) { sourcetable_rolemember = typeof(acc02RoleMember); }
public override bool DbInsert(ddl db) { throw new NotSupportedException("cannot insert into a view"); }
public override bool DbSelectWithLogging <T>(ddl db, int OK, string lm_who) { throw new NotSupportedException("cannot track changes in a view"); }
public pracc02RoleCloneDash(ddl _conn) : base(_conn) { }
private void fillddlForRoutine(string value, string text) { List<ddl> ddlList = new List<ddl>(); if (ddlRoutineTImeIDnValue.Items.Count == 0) { ddl newddl = new ddl(); newddl.ddlText = text; newddl.ddlValue = value; ddlList.Add(newddl); } else { bool isFount = false; foreach (ListItem li in ddlRoutineTImeIDnValue.Items) { ddl newddl = new ddl(); newddl.ddlText = li.Text; if (li.Value == value) { isFount = true; } newddl.ddlValue = li.Value; ddlList.Add(newddl); } if (!isFount) { ddl newddl = new ddl(); newddl.ddlText = text; newddl.ddlValue = value; ddlList.Add(newddl); } } ddlRoutineTImeIDnValue.Items.Clear(); ddlRoutineTImeIDnValue.DataValueField = "ddlValue"; ddlRoutineTImeIDnValue.DataTextField = "ddlText"; ddlRoutineTImeIDnValue.DataSource = ddlList; ddlRoutineTImeIDnValue.DataBind(); }
public pracc02LoginCreate(ddl _conn) : base(_conn) { }
public pracc02RoleAceGrantAll(ddl _conn) : base(_conn) { }
public pracc02CubeFillNoContext(ddl _conn) : base(_conn) { }
public override string Complete(ddl db, string name, List <DbParameter> parameters, bool is_returning_rowset, string tsql) { _is_returning_rowset = is_returning_rowset; return(base.Complete(db, name, parameters, is_returning_rowset, tsql)); }
public pracc02CubeFillContextStd(ddl _conn) : base(_conn) { }