public override async void DeleteAction() { try { if (Model.IsValid) { Model.UpdatedBy = EasyApp.Current.User.Login; CONSQL data = ((CONSQL)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Remove, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, "")); if (data != null) { Model.Details.Remove(data); } PostDeleteAction(""); MessageBoxResult result = MessageBox.Show("Registro eliminado correctamente", "Eliminando", MessageBoxButton.OK, MessageBoxImage.Question); OnNewCommand(new object()); } else { MessageBox.Show("Hay validaciones pendientes por favor verifique.", "Información", MessageBoxButton.OK, MessageBoxImage.Information); PostDeleteAction("Hay validaciones pendientes por favor verifique."); } } catch (FaultException ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); PostDeleteAction(new BusinessException(ex).GetExceptionMessage()); } catch (Exception ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); PostDeleteAction(new BusinessException(ex).GetExceptionMessage()); } }
public override void SetQueryParameters(IQuery query, CONSQL 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 if (data.MainSQLId == null) { query.SetBoolean("Active", data.Active); } //query.SetBoolean("Automatic", data.Automatic); //query.SetBoolean("GenerateFile", data.GenerateFile); //add more parameters to method for query by any field if (data.Company != null && data.Company.Id != 0) { query.SetInt32("Company", data.Company.Id); } //if (data.MainSQL != null && data.MainSQL.Id != 0) // query.SetInt32("MainSQL", data.MainSQL.Id); if (data.Structure != null && data.Structure.Id != 0) { query.SetInt32("Structure", data.Structure.Id); } } }
public override void FindAction() { try { //Model.SQLSends = new BindingList<CONSQLSend>(); CONSQL data = ((CONSQL)EasyApp.Current.eToolsServer().Execute(Model.Entity, Actions.Find, Options.Light, EasyApp.Current.DefaultDatabaseSettingName, "")); if (data.Entities != null && data.Entities.Count > 0) { Model.Details = new BindingList <CONSQL>(data.Entities); } PostFindAction("CONSQLs", Model.Details.Count, ""); } catch (FaultException ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); FormIsBusy = false; PostFindAction("", 0, new BusinessException(ex).GetExceptionMessage()); } catch (Exception ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); FormIsBusy = false; PostFindAction("", 0, new BusinessException(ex).GetExceptionMessage()); } }
//Enviar public static void OnlySendRecords(DatabaseSetting conf, string documentType) { List <CONRecord> Rec = new List <CONRecord>(); try { CONRecord select = (CONRecord)EasyApp.Current.eToolsServer().Execute(new CONRecord { IsSend = false, DocumentType = documentType }, Actions.Find, Options.All, conf.Name, ""); if (select != null) { Rec.AddRange(select.Entities); } if (Rec != null && Rec.Count > 0) { CONSQL send = (CONSQL)EasyApp.Current.eToolsServer().Execute(new CONSQL { Records = Rec }, Actions.Generate, Options.All, conf.Name, ""); Console.WriteLine("Tarea: Enviar correctamente"); } else { Console.WriteLine("Tarea: No hay registros para enviar"); } } catch (Exception e) { Console.WriteLine("Error al ejecutar el proceso de envio " + e.Message); } }
public async void OnExecuteCommand(object obj) { view.ExecuteView.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; try { CONSQL sqls = new CONSQL(); sqls.Entities = new List <CONSQL>(); sqls.SQLParameters = new List <CONSQLParameter>(); sqls.SQLSends = new List <CONSQLSend>(); if (Model.SQLParameters != null && Model.SQLParameters.Count > 0) { foreach (var item in Model.SQLParameters) { if (item.DateValue != null || item.Int32Value != null || !string.IsNullOrWhiteSpace(item.StringValue) || item.DefaultDateValue != null) { sqls.SQLParameters.Add(new CONSQLParameter { SQLId = item.SQLId, Name = item.Name, IsDate = item.IsDate, IsInt = item.IsInt, IsString = item.IsString, DateValue = item.DateValue, DefaultDateValue = item.DefaultDateValue, Int32Value = item.Int32Value, StringValue = item.StringValue }); } else { throw new Exception("El parametro :" + item.Name + " no tiene valor registrado"); } } } if (view.SQLsGrid.SelectedItems != null && view.SQLsGrid.SelectedItems.Count > 0) { foreach (var item in view.SQLsGrid.SelectedItems) { sqls.Entities.Add((CONSQL)item); } } if (view.Accounting.IsChecked == true) { if (view.IntegratorConfigurationsGrid.SelectedItems != null && view.IntegratorConfigurationsGrid.SelectedItems.Count > 0) { foreach (var item in view.IntegratorConfigurationsGrid.SelectedItems) { sqls.SQLSends.Add((CONSQLSend)item); } } else { throw new Exception("No se ha seleccionado ningun Web Service para hacer el envio de los datos..."); } } sqls.AddAditionalProperty("Accounting", Model.Accounting); CONSQL data = ((CONSQL)await EasyApp.Current.eToolsServer().ExecuteAsync(sqls, Actions.Process, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); MessageBox.Show("Registro ejecutado y guardado correctamente", "", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } view.ExecuteView.IsEnabled = true; }
public override async void SaveAction(bool createNew) { try { if (Model.IsValid) { Model.UpdatedBy = EasyApp.Current.User.Login; CONSQL data = ((CONSQL)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, (Model.Id == 0 ? Actions.Add : Actions.Modify), Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); if (data != null) { if (Model.Details.IndexOf(data) != -1) { Model.Details[Model.Details.IndexOf(data)] = data; } else { Model.Details.Add(data); } Model.Entity = data; } PostSaveAction(""); if (createNew) { MessageBoxResult result = MessageBox.Show("Registro guardado correctamente, desea crear un nuevo registro", "Nuevo Registro", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { OnNewCommand(new object()); } } else { MessageBox.Show("Registro guardado correctamente", "Registro", MessageBoxButton.OK, MessageBoxImage.Information); } } else { MessageBox.Show("Hay validaciones pendientes por favor verifique.", "Información", MessageBoxButton.OK, MessageBoxImage.Information); PostSaveAction("Hay validaciones pendientes por favor verifique."); } } catch (FaultException ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); PostSaveAction(new BusinessException(ex).GetExceptionMessage()); } catch (Exception ex) { MessageBox.Show(new BusinessException(ex).GetExceptionMessage(), "Error", MessageBoxButton.OK); PostSaveAction(new BusinessException(ex).GetExceptionMessage()); } }
public void MappingRules(CONSQL data) { if (data == null) { AddExceptionMessage(Language.DLTABLEVALUENULL, "CONSQL", "CONSQLs"); } if (data.Structure == null) { AddExceptionMessage(Language.DLCOLUMNISREQUIRED, "Structure"); } if (String.IsNullOrWhiteSpace(data.SQLSentence)) { AddExceptionMessage(Language.DLCOLUMNISREQUIRED, "SQLSentence"); } }
public List <CONSQLParameter> GenerateSettings(CONSQLParameter data) { try { CONSQLBLL daoSQL = new CONSQLBLL(Work.Settings); //CONSQLParameterBLL daoParam = daoParam = new CONSQLParameterBLL(Work.Settings); ; CONSQL sql = daoSQL.Execute(new CONSQL { Id = data.SQL.Id }, Actions.Find, Options.Me, ""); //if (sql.SQLParameters != null && sql.SQLParameters.Count > 0) //{ // foreach (CONSQLParameter item in sql.SQLParameters) // { // daoParam.Execute(item, Actions.Remove, Options.All, ""); // } //} List <CONSQLParameter> parameters = new List <CONSQLParameter>(); parameters = GetParameters(sql.SQLSentence); if (!String.IsNullOrWhiteSpace(sql.ExecuteStoreProcedure)) { parameters.AddRange(GetParameters(sql.ExecuteStoreProcedure)); } foreach (CONSQL item in sql.ChildSQLs) { List <CONSQLParameter> parameterChilds = GetParameters(item.SQLSentence); if (!String.IsNullOrWhiteSpace(item.ExecuteStoreProcedure)) { parameterChilds.AddRange(GetParameters(sql.ExecuteStoreProcedure)); } foreach (CONSQLParameter sparam in parameterChilds) { if (parameters.Count(t => t.Name.ToUpper() == sparam.Name.ToUpper()) <= 0) { parameters.Add(sparam); } } } return(parameters); } catch (Exception) { throw; } finally { //daoSQL.Work.Commit(); } }
public override String GetQuery(CONSQL 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.Automatic = :Automatic \n" ; //dml += " AND a.GenerateFile = :GenerateFile \n" ; //add more parameters to method for query by any field if (data.Company != null && data.Company.Id != 0) { dml += " AND a.Company.Id = :Company \n"; } //if (data.MainSQL != null && data.MainSQL.Id != 0) // dml += " AND a.MainSQL.Id = :MainSQL \n"; //if (data.MainSQL == null) // dml += " AND a.MainSQL is null \n"; if (data.MainSQLId == null) { dml += " AND a.MainSQLId is null \n"; dml += " AND a.Active = :Active \n"; } else { dml += " AND a.MainSQLId is not null \n"; } if (data.Structure != null && data.Structure.Id != 0) { dml += " AND a.Structure.Id = :Structure \n"; } dml += " order by a.Id asc "; } return(dml); }
//Ejecutar y enviar public static void SenRecords(DatabaseSetting conf, List <int> ids) { CONSQL param = new CONSQL(); param.Entities = new List <CONSQL>(); try { for (int i = 0; i < ids.Count; i++) { CONSQL select = (CONSQL)EasyApp.Current.eToolsServer().Execute(new CONSQL { Active = true, Id = ids[i] }, Actions.Find, Options.Me, conf.Name, ""); param.Entities.Add(select); } param.AddAditionalProperty("Accounting", true); param.Description = "Schedule"; CONSQL send = (CONSQL)EasyApp.Current.eToolsServer().Execute(param, Actions.Process, Options.All, conf.Name, ""); Console.WriteLine("Tarea: Ejecutar y enviar correctamente"); } catch (Exception e) { Console.WriteLine("Error en el proceso de ejecucion y envio " + e.Message); } }
public override void SaveOrUpdateDetails(CONSQL data) { //base.SaveOrUpdateDetails(data); if (data.SQLDetails != null && data.SQLDetails.Count > 0) { for (int i = 0; i < data.SQLDetails.Count; i++) { data.SQLDetails[i].SQLId = 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].StructureDetail != null) { data.SQLDetails[i].StructureDetailId = data.SQLDetails[i].StructureDetail.Id; } if (data.SQLDetails[i].Id == 0) { data.SQLDetails[i] = Add(data.SQLDetails[i]); } else { data.SQLDetails[i] = Modify(data.SQLDetails[i]); } } } if (data.SQLParameters != null && data.SQLParameters.Count > 0) { for (int i = 0; i < data.SQLParameters.Count; i++) { data.SQLParameters[i].SQLId = data.Id; data.SQLParameters[i].LastUpdate = DateTime.Now; data.SQLParameters[i].UpdatedBy = data.UpdatedBy; if (data.SQLParameters[i].Id == 0) { data.SQLParameters[i] = Add(data.SQLParameters[i]); } else { data.SQLParameters[i] = Modify(data.SQLParameters[i]); } } } if (data.SQLSends != null && data.SQLSends.Count > 0) { for (int i = 0; i < data.SQLSends.Count; i++) { data.SQLSends[i].SQLId = data.Id; data.SQLSends[i].LastUpdate = DateTime.Now; data.SQLSends[i].UpdatedBy = data.UpdatedBy; if (data.SQLSends[i].CONIntegratorConfiguration != null) { data.SQLSends[i].CONIntegratorConfigurationId = data.SQLSends[i].CONIntegratorConfiguration.Id; } if (data.SQLSends[i].Id == 0) { data.SQLSends[i] = Add(data.SQLSends[i]); } else { data.SQLSends[i] = Modify(data.SQLSends[i]); } } } if (data.ChildSQLs != null && data.ChildSQLs.Count > 0) { for (int i = 0; i < data.ChildSQLs.Count; i++) { data.ChildSQLs[i].MainSQLId = data.Id; data.ChildSQLs[i].LastUpdate = DateTime.Now; data.ChildSQLs[i].UpdatedBy = data.UpdatedBy; if (data.ChildSQLs[i].Company != null) { data.ChildSQLs[i].CompanyId = data.ChildSQLs[i].Company.Id; } if (data.ChildSQLs[i].Structure != null) { data.ChildSQLs[i].StructureId = data.ChildSQLs[i].Structure.Id; } if (data.ChildSQLs[i].Connection != null) { data.ChildSQLs[i].ConnectionId = data.ChildSQLs[i].Connection.Id; } if (data.ChildSQLs[i].Id == 0) { data.ChildSQLs[i] = Add(data.ChildSQLs[i]); } else { data.ChildSQLs[i] = Modify(data.ChildSQLs[i]); } SaveOrUpdateDetails(data.ChildSQLs[i]); } } }
public override List <CONSQL> FindAll(CONSQL data, Options option) { return(base.FindAll(data, option)); }
public override CONSQL FindById(CONSQL data) { return(base.FindById(data)); }
public override void AddMoreDetailFindById(CONSQL data) { }
public async void OnSendCommand(object obj) { //FormIsBusy = true; //FormBusyMessage = "Procesando"; try { view.RecordView.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; if (view.RecordGrid.SelectedItems != null && view.RecordGrid.SelectedItems.Count > 0) { List <CONRecord> records = new List <CONRecord>(); //foreach (CONRecord item in view.RecordGrid.SelectedItems) // records.Add(item); //tiempo.Stop(); records.AddRange(view.RecordGrid.SelectedItems.Select(x => x as CONRecord).ToList <CONRecord>()); //Stopwatch tiempo = Stopwatch.StartNew(); //for (int i = 0; i < records.Count; i++) //104320 // records[i] = (CONRecord)EasyApp.Current.eToolsServer().Execute(new CONRecord { Id = records[i].Id }, Actions.Find, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, ""); //tiempo.Stop(); //22079 //Parallel.ForEach(records, currentElement => //{ // currentElement = (CONRecord)EasyApp.Current.eToolsServer().Execute(new CONRecord { Id = currentElement.Id }, Actions.Find, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, ""); //}); //Dictionary<string, List<CONRecord>> reg = new Dictionary<string, List<CONRecord>>(); //List<string> co = (from a in records select a.OperationCenter).Distinct().ToList(); //foreach (string item in co) //{ // List<CONRecord> rec = (from x in records where x.OperationCenter == item select x).ToList(); // reg.Add(item, rec); //} //CONSQL send = null; //Parallel.ForEach(reg.Keys, currentElement => //{ // send = (CONSQL)EasyApp.Current.eToolsServer().Execute(new CONSQL { Records = reg[currentElement] }, Actions.Generate, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""); // //var SqlSends = (CONSQLSend)EasyApp.Current.eToolsServer().Execute(new CONSQLSend { SQLId = currentElement.SQL.Id }, Actions.Find, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""); // //currentElement.SQL.SQLSends = SqlSends.Entities; //}); //tiempo.Stop(); CONSQL send = ((CONSQL)await EasyApp.Current.eToolsServer().ExecuteAsync(new CONSQL { Records = records, ParallelNumber = Model.ParallelNumber }, Actions.Generate, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); if (!(bool)send.GetAditionalProperty("Result")) { MessageBox.Show("Proceso con Errores", "Proceso Terminado", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("Procesado correctamente", "Proceso Terminado", MessageBoxButton.OK, MessageBoxImage.Information); } Model.Details = new BindingList <CONRecord>(); FindAction(); view.RecordView.IsEnabled = true; } } catch (Exception ex) { string a = ((FaultException <BusinessException>)ex).Detail.AppMessageDetails.FirstOrDefault(); Mouse.OverrideCursor = Cursors.Arrow; MessageBox.Show(a, GetLocalizedMessage(Language.ApplicationError), MessageBoxButton.OK, MessageBoxImage.Error); view.RecordView.IsEnabled = true; } }
public static void CreateMastersZapa(DatabaseSetting conf) { CONSQL errors = (CONSQL)EasyApp.Current.eToolsServer().Execute(new CONSQL(), Actions.Generate, Options.Me, conf.Name, ""); }