public override String GetQuery(CONStructureDetail data, Boolean byId) { String dml = base.GetQuery(data, byId); if (byId) { //add more parameters to method for query by id } else { //Determine if the boolean values are taken included as part of the consultation //dml += " AND a.IsRequired = :IsRequired \n" ; //dml += " AND a.Visible = :Visible \n" ; //add more parameters to method for query by any field if (data.Structure != null && data.Structure.Id != 0) { dml += " AND a.Structure.Id = :Structure \n"; } dml += " order by a.Id asc "; } return(dml); }
public void AddDetails(CONStructureDetail data) { if (data.SQLDetails != null && data.SQLDetails.Count > 0) { for (int i = 0; i < data.SQLDetails.Count; i++) { data.SQLDetails[i].StructureDetailId = data.Id; data.SQLDetails[i].LastUpdate = DateTime.Now; data.SQLDetails[i].UpdatedBy = data.UpdatedBy; if (data.SQLDetails[i].Equivalence != null) { data.SQLDetails[i].EquivalenceId = data.SQLDetails[i].Equivalence.Id; } //if (data.SQLDetails[i].MainSQLDetail != null) // data.SQLDetails[i].MainSQLDetailId = data.SQLDetails[i].MainSQLDetail.Id; if (data.SQLDetails[i].SQL != null) { data.SQLDetails[i].SQLId = data.SQLDetails[i].SQL.Id; } if (data.SQLDetails[i].Id == 0) { data.SQLDetails[i] = cONSQLDetailDl.Add(data.SQLDetails[i]); } else { data.SQLDetails[i] = cONSQLDetailDl.Modify(data.SQLDetails[i]); } } } }
public override CONStructureDetail Execute(CONStructureDetail data, Actions action, Options option, string token) { try { if (action == Actions.Add || action == Actions.Modify || action == Actions.Remove || (action == Actions.Find && (option == Options.Me || option == Options.Exist))) { if ((action == Actions.Add || action == Actions.Modify) && option == Options.All) { BenginTransaction(); cONSQLDetailDl = new CONSQLDetailBLL(Work); } data = base.Execute(data, action, option, token); if (action == Actions.Find && option == Options.Me) { cONSQLDetailDl = new CONSQLDetailBLL(this.Work.Settings); data.SQLDetails = cONSQLDetailDl.FindAll(new CONSQLDetail { StructureDetailId = data.Id }, Options.All); } if ((action == Actions.Add || action == Actions.Modify) && option == Options.All) { AddDetails(data); } //if (option == Options.All) // Work.Commit(); return(data); } else if (action == Actions.Find && (option == Options.All || option == Options.Light)) { if (option == Options.All) { data.Entities = FindAll(data, Options.All); } else if (option == Options.Light) { data.Entities = FindAll(data, Options.Light); } return(data); } else { throw new NotImplementedException(GetLocalizedMessage(Language.DLACTIONNOTIMPLEMENT, action.ToString(), option.ToString())); } } catch (FaultException <BusinessException> f) { Rollback(); throw f; } catch (Exception e) { Rollback(); throw new BusinessException(e).GetFaultException(); } finally { Commit(); } }
public override void SetQueryParameters(IQuery query, CONStructureDetail data, Boolean byId) { base.SetQueryParameters(query, data, byId); if (byId) { //add more parameters to method for query by id } else { //Determine if the boolean values are taken included as part of the consultation //query.SetBoolean("IsRequired", data.IsRequired); //query.SetBoolean("Visible", data.Visible); //add more parameters to method for query by any field if (data.Structure != null && data.Structure.Id != 0) { query.SetInt32("Structure", data.Structure.Id); } } }
public override List <CONStructureDetail> FindAll(CONStructureDetail data, Options option) { return(base.FindAll(data, option)); }
public override CONStructureDetail FindById(CONStructureDetail data) { return(base.FindById(data)); }
public override void AddMoreDetailFindById(CONStructureDetail data) { }
public override void SaveOrUpdateDetails(CONStructureDetail data) { base.SaveOrUpdateDetails(data); }
public CONSQLDetail GetColumnsFromSQL(CONSQLDetail data) { MappingRules(data.SQL); if (!HasErrors) { Database daacess = new Database(UtilBLL.GetConnectionString(data.SQL.Connection), UtilBLL.GetConnectionDBType(data.SQL.Connection.DbType)); SECConnectionBLL dlConnection = new SECConnectionBLL(Work.Settings); CONStructureDetailBLL dlStructureDetail = new CONStructureDetailBLL(Work.Settings); cONSQLDetailDl = new CONSQLDetailBLL(Work.Settings); data.SQL.Connection = dlConnection.FindById(data.SQL.Connection); if (data.SQL != null && data.SQL.Id != 0 && !data.SQL.GenerateFile) { List <CONSQLDetail> details = cONSQLDetailDl.FindAll(new CONSQLDetail { SQL = data.SQL }, Options.All); foreach (CONSQLDetail item in details) { cONSQLDetailDl.Remove(item); } } ResultList result = daacess.ExecuteQuery(data.SQL.SQLSentence, new List <SQLParameter>(), 1); List <CONSQLDetail> columns = new List <CONSQLDetail>(); if (result.GetColumns() != null && result.GetColumns().Count > 0) { for (int i = 0; i < result.GetColumns().Count; i++) { CONSQLDetail sqlColumn = new CONSQLDetail(); sqlColumn.Secuence = Int16.Parse(i.ToString()); sqlColumn.Field = result.GetColumnName(i); sqlColumn.DBType = result.GetColumnType(i); columns.Add(sqlColumn); } } data.SQL.Structure.StructureDetails = dlStructureDetail.FindAll(new CONStructureDetail { Structure = data.SQL.Structure }, Options.All); if (data.SQL.Structure.StructureDetails != null && data.SQL.Structure.StructureDetails.Count > 0) { foreach (CONSQLDetail item in columns) { CONStructureDetail sDetail = data.SQL.Structure.StructureDetails.FirstOrDefault(x => x.Field.ToUpper() == item.Field.ToUpper()); if (data != null) { item.StructureDetail = sDetail; } } if (columns.Count() < (data.SQL.Structure.StructureDetails.Count() - 4) && !data.SQL.GenerateFile) { string message = " Las columnas Pendientes de Mapeo son: \n"; List <CONStructureDetail> pending = new List <CONStructureDetail>(); for (int i = 4; i < data.SQL.Structure.StructureDetails.Count(); i++) { var exist = columns.FirstOrDefault(x => x.StructureDetail.Field.ToUpper() == data.SQL.Structure.StructureDetails[i].Field.ToUpper()); if (exist == null && data.SQL.Structure.StructureDetails[i].Visible) { pending.Add(data.SQL.Structure.StructureDetails[i]); } } if (pending.Count > 0) { foreach (var item in pending) { message += item.Field + ",\n"; } throw new Exception("La consulta SQL no tiene el nro de columnas minimo requerido. Nro Minimo de Columnas = " + (data.SQL.Structure.StructureDetails.Count()) + "\n" + message.ToUpper()); } } } //List<CONStructureDetail> pendingMapping = new List<CONStructureDetail>(); //foreach (CONStructureDetail item in data.SQL.Structure.StructureDetails) //{ // CONSQLDetail exist = columns.FirstOrDefault(x => x.StructureDetail.Id == item.Id); // if (exist == null && item.Visible) // pendingMapping.Add(item); //} //if (pendingMapping.Count > 0) //{ // data.ServerMessage = "Falta por mapear las columnas: "; // foreach (CONStructureDetail item in pendingMapping) // { // data.ServerMessage += item.Field + ", "; // } // data.ServerMessage += "Por favor verifique e intente de nuevo."; //} data.Entities = columns; return(data); } else { Work.Rollback(); BusinessException exception = new BusinessException(GetLocalizedMessage(Language.DLBUSINESSEXCEPTION)); foreach (string item in ExceptionMessages) { exception.AppMessageDetails.Add(item); } throw exception.GetFaultException(); } }
public override void FindByIdRules(CONStructureDetail data) { base.FindByIdRules(data); }
public override void RemoveRules(CONStructureDetail data) { base.RemoveRules(data); }
public override void ModifyRules(CONStructureDetail data) { base.ModifyRules(data); data.LastUpdate = DateTime.Now; }
public override void CommonRules(CONStructureDetail data) { base.CommonRules(data); }