public override async void FindAction()
 {
     try
     {
         FormBusyMessage = "Buscando...";
         FormIsBusy      = true;
         if (Model.PageSize > 0)
         {
             Model.HasPaging = true;
         }
         CONRecord data = ((CONRecord)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Find, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""));
         if (data.Entities != null && data.Entities.Count > 0)
         {
             Model.Details = new BindingList <CONRecord>(data.Entities);
         }
         PostFindAction("CONRecords", 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());
     }
 }
Ejemplo n.º 2
0
        //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);
            }
        }
Ejemplo n.º 3
0
        public override String GetQuery(CONRecord data, Boolean byId)
        {
            String dml = base.GetQuery(data, byId);

            if (byId)
            {
                //add more parameters to method for query by id
                if (!String.IsNullOrWhiteSpace(data.LogicalKey))
                {
                    dml += "             AND upper(a.LogicalKey) = :LogicalKey \n";
                }
            }
            else
            {
                //Determine if the boolean values ​​are taken included as part of the consultation
                dml += "             AND a.IsSend = :IsSend \n";
                //dml += "             AND a.IsExternal = :IsExternal \n" ;

                //add more parameters to method for query by any field

                if (data.SQL != null && data.SQL.Id != 0)
                {
                    dml += "             AND a.SQL.Id = :SQL \n";
                }

                dml += " order by a.Id asc ";
            }
            return(dml);
        }
Ejemplo n.º 4
0
        public override void SetQueryParameters(IQuery query, CONRecord data, Boolean byId)
        {
            base.SetQueryParameters(query, data, byId);
            if (byId)
            {
                //add more parameters to method for query by id
                if (!String.IsNullOrWhiteSpace(data.LogicalKey))
                {
                    query.SetString("LogicalKey", data.LogicalKey.ToUpper());
                }
            }
            else
            {
                //Determine if the boolean values ​​are taken included as part of the consultation
                query.SetBoolean("IsSend", data.IsSend);
                //query.SetBoolean("IsExternal",  data.IsExternal);

                //add more parameters to method for query by any field

                if (data.SQL != null && data.SQL.Id != 0)
                {
                    query.SetInt32("SQL", data.SQL.Id);
                }
            }
        }
Ejemplo n.º 5
0
        public override void SaveOrUpdateDetails(CONRecord data)
        {
            base.SaveOrUpdateDetails(data);
            if (data.Errors1 != null && data.Errors1.Count > 0)
            {
                for (int i = 0; i < data.Errors1.Count; i++)
                {
                    data.Errors1[i].RecordId   = data.Id;
                    data.Errors1[i].LastUpdate = DateTime.Now;
                    data.Errors1[i].UpdatedBy  = data.UpdatedBy;
                    if (data.Errors1[i].Id == 0)
                    {
                        data.Errors1[i] = Add(data.Errors1[i]);
                    }
                    else
                    {
                        data.Errors1[i] = Modify(data.Errors1[i]);
                    }
                }
            }
            if (data.RecordDetails != null && data.RecordDetails.Count > 0)
            {
                for (int i = 0; i < data.RecordDetails.Count; i++)
                {
                    data.RecordDetails[i].RecordId   = data.Id;
                    data.RecordDetails[i].LastUpdate = DateTime.Now;
                    data.RecordDetails[i].UpdatedBy  = data.UpdatedBy;

                    if (data.RecordDetails[i].SQL != null)
                    {
                        data.RecordDetails[i].SQLId = data.RecordDetails[i].SQL.Id;
                    }

                    if (data.IsExternal)
                    {
                        data.RecordDetails[i].Fields = new Dictionary <string, string>();
                    }
                    else
                    {
                        data.RecordDetails[i].GetPlaintText();
                    }
                    data.RecordDetails[i].XMLData = XMLSerializer.SerializeToString <Dictionary <string, string> >(data.RecordDetails[i].Fields);

                    if (data.RecordDetails[i].Id == 0)
                    {
                        data.RecordDetails[i] = Add(data.RecordDetails[i]);
                    }
                    else
                    {
                        data.RecordDetails[i] = Modify(data.RecordDetails[i]);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public override void FindByIdRules(CONRecord data)
 {
     if (data == null)
     {
         AddExceptionMessage(Language.DLTABLEVALUENULL, "CONRecord", "CONRecords");
     }
     if (data.Id == 0 && string.IsNullOrWhiteSpace(data.LogicalKey))
     {
         AddExceptionMessage(Language.DLTABLEIDNOTNULL, "CONRecord");
     }
 }
Ejemplo n.º 7
0
 public override void CommonRules(CONRecord data)
 {
     if (data.IsExternal)
     {
         data.Fields = new Dictionary <string, string>();
     }
     else
     {
         data.GetPlaintText();
     }
     data.XMLData = XMLSerializer.SerializeToString <Dictionary <string, string> >(data.Fields);
     base.CommonRules(data);
 }
Ejemplo n.º 8
0
 public void OnMarkNotSendCommand(object obj)
 {
     try
     {
         view.RecordView.IsEnabled = false;
         CONRecord file = new CONRecord();
         //CONRecordDetail filesDetails = new CONRecordDetail();
         //var option = MessageBox.Show("Si desea generar un archivo por cada documento, selecione Si\nSi desea generar un unico archivo por todos los documentos, seleccione No","Como Generar el Archivo?", MessageBoxButton.);
         //if (option.ToString() != "Cancel")
         //{
         if (view.RecordGrid.SelectedItems != null && view.RecordGrid.SelectedItems.Count > 0)
         {
             List <CONRecord> records = new List <CONRecord>();
             foreach (var item in view.RecordGrid.SelectedItems)
             {
                 records.Add((CONRecord)item);
             }
             foreach (CONRecord item2 in records)
             {
                 item2.IsSend = false;
                 var a = ((CONRecord)EasyApp.Current.eToolsServer().Execute(item2, Actions.Modify, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, ""));
             }
             MessageBox.Show("Archivos marcados como no enviados correctamente ", "Proceso Terminado", MessageBoxButton.OK, MessageBoxImage.Information);
             view.RecordView.IsEnabled = true;
             this.NewAction();
         }
         else
         {
             MessageBox.Show("Seleccione al menos 1 registro", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
         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;
     }
 }
Ejemplo n.º 9
0
        public void OnGenerateFilesCommand(object obj)
        {
            try
            {
                view.RecordView.IsEnabled = false;
                CONRecord file = new CONRecord();
                //CONRecordDetail filesDetails = new CONRecordDetail();
                //var option = MessageBox.Show("Si desea generar un archivo por cada documento, selecione Si\nSi desea generar un unico archivo por todos los documentos, seleccione No","Como Generar el Archivo?", MessageBoxButton.);
                //if (option.ToString() != "Cancel")
                //{
                if (view.RecordGrid.SelectedItems != null && view.RecordGrid.SelectedItems.Count > 0)
                {
                    if (stringXML == null)
                    {
                        List <CONRecord> records = new List <CONRecord>();
                        //stringXML = new StringBuilder();
                        foreach (var item in view.RecordGrid.SelectedItems)
                        {
                            records.Add((CONRecord)item);
                        }
                        //if (option.ToString() == "Yes")
                        //{
                        //    files = ((CONRecord)await EasyApp.Current.eToolsServer().ExecuteAsync(new CONRecord { Entities = records }, Actions.Generate, Options.Light, EasyApp.Current.DefaultDatabaseSettingName, ""));
                        //}
                        //else if (option.ToString() == "No")
                        //{
                        //files = ((CONRecord)await EasyApp.Current.eToolsServer().ExecuteAsync(new CONRecord { Entities = records }, Actions.Generate, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""));
                        foreach (CONRecord item in records)
                        {
                            item.RecordDetails = ((CONRecordDetail)EasyApp.Current.eToolsServer().Execute(new CONRecordDetail {
                                Record = item
                            }, Actions.Find, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")).Entities;
                        }
                        file = ((CONRecord)EasyApp.Current.eToolsServer().Execute(new CONRecord {
                            Entities = records
                        }, Actions.Generate, Options.All, EasyApp.Current.DefaultDatabaseSettingName, ""));
                        foreach (CONRecord item in file.Entities)
                        {
                            string archivo             = item.PlainText;
                            System.IO.StreamWriter exp = new System.IO.StreamWriter("C:\\Users\\Public\\Documents\\" + item.LogicalKey.ToString() + ".txt");
                            exp.Write(archivo);
                            exp.Close();
                        }


                        //}
                    }

                    MessageBox.Show("Archivos Generados Correctamente en la ruta: C:\\Users\\Public\\Documents\\ ", "Proceso Terminado", MessageBoxButton.OK, MessageBoxImage.Information);
                    view.RecordView.IsEnabled = true;
                }
                else
                {
                    MessageBox.Show("Seleccione al menos 1 registro", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                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;
            }
        }
Ejemplo n.º 10
0
 public override List <CONRecord> FindAll(CONRecord data, Options option)
 {
     return(base.FindAll(data, option));
 }
Ejemplo n.º 11
0
 public override CONRecord FindById(CONRecord data)
 {
     return(base.FindById(data));
 }
Ejemplo n.º 12
0
 public override void AddMoreDetailFindById(CONRecord data)
 {
 }
Ejemplo n.º 13
0
 public void AddDetails(CONRecord data)
 {
 }
Ejemplo n.º 14
0
 public override CONRecord Execute(CONRecord 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();
                 cONErrorDl        = new CONErrorBLL(Work);
                 cONRecordDetailDl = new CONRecordDetailBLL(Work);
             }
             data = base.Execute(data, action, option, token);
             if (action == Actions.Find && option == Options.Me && data != null)
             {
                 cONErrorDl        = new CONErrorBLL(this.Work.Settings);
                 cONRecordDetailDl = new CONRecordDetailBLL(this.Work.Settings);
                 data.Errors1      = cONErrorDl.FindAll(new CONError {
                     RecordId = data.Id
                 }, Options.All);
                 data.RecordDetails = cONRecordDetailDl.FindAll(new CONRecordDetail {
                     RecordId = 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 if (action == Actions.Process && (option == Options.All || option == Options.Light))
         {
             //data = ExecuteSQL(data);
             return(data);
         }
         else if (action == Actions.Generate && (option == Options.All || option == Options.Light))
         {
             if (option == Options.All)
             {
                 data = GenerateOneFile(data);
             }
             //if (option == Options.Light)
             //data = GenerateManyFiles(data);
             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();
     }
 }
Ejemplo n.º 15
0
        public CONRecord GenerateOneFile(CONRecord param)
        {
            List <CONRecord> files             = new List <CONRecord>();
            string           idOperationCenter = "";
            string           idDocumentType    = "";
            StringBuilder    stringXML         = new StringBuilder();


            for (int i1 = 0; i1 < param.Entities.Count; i1++)
            {
                int j = 1;
                stringXML = new StringBuilder();
                CONInitial inicial = new CONInitial {
                    RecordNumber = j.ToString(), RecordType = "0", SubRecordType = "0", Version = "01", Company = param.Entities[i1].Company + ""
                };
                stringXML.AppendLine(inicial.PlainText);
                j++;

                if (param.Entities[i1].IsDocument())
                {
                    int?recordType = null;
                    if (param.Entities[i1].RecordType == 450 || param.Entities[i1].RecordType == 461)
                    {
                        recordType = 350;
                    }
                    else
                    {
                        recordType = param.Entities[i1].RecordType;
                    }

                    idOperationCenter = "F" + recordType + "_ID_CO";
                    idDocumentType    = "F" + recordType + "_ID_TIPO_DOCTO";
                }

                if (param.Entities[i1].IsDocument() && param.Entities[i1].DocumentNumber == 0)
                {
                    param.Entities[i1].DocumentNumber = GetConsecutive(param.Entities[i1].Fields[idOperationCenter] + "" + param.Entities[i1].Fields[idDocumentType]);
                }


                param.Entities[i1].RecordNumber = j;
                j++;
                stringXML.AppendLine(param.Entities[i1].PlainText.Replace("&", " "));
                if (param.Entities[i1].RecordDetails != null && param.Entities[i1].RecordDetails.Count > 0)
                {
                    for (int i = 0; i < param.Entities[i1].RecordDetails.Count; i++)
                    {
                        param.Entities[i1].RecordDetails[i].RecordNumber   = j;
                        param.Entities[i1].RecordDetails[i].DocumentNumber = param.Entities[i1].DocumentNumber;
                        stringXML.AppendLine(param.Entities[i1].RecordDetails[i].PlainText.Replace("&", " "));
                        j++;
                    }
                }



                CONFinal final = new CONFinal {
                    RecordNumber = j.ToString(), RecordType = "9999", SubRecordType = "0", Version = "01", Company = param.Entities[i1].Company + ""
                };
                stringXML.Append(final.PlainText);
                param.Entities[i1].PlainText = stringXML.ToString();
                j = 0;
            }
            return(param);
        }
Ejemplo n.º 16
0
 public override void RemoveRules(CONRecord data)
 {
     base.RemoveRules(data);
 }
Ejemplo n.º 17
0
 public override void ModifyRules(CONRecord data)
 {
     base.ModifyRules(data);
     data.LastUpdate = DateTime.Now;
 }