Example #1
0
        private void simpleActionCncilr_Execute(object sender, DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs e)
        {
            if (View != null && View.ObjectSpace != null)
            {
                IObjectSpace       objectSpace = Application.CreateObjectSpace();
                CriteriaOperator[] operands    = new CriteriaOperator[1];
                operands[0] = new BinaryOperator("Concilia", true, BinaryOperatorType.NotEqual);

                SortProperty[] sortCollection = new SortProperty[1];
                sortCollection[0] = new SortProperty("FechaDoc", SortingDirection.Ascending);

                IList arr = objectSpace.CreateCollection(typeof(DocumentoSalida),
                                                         new GroupOperator(operands), sortCollection);
                Ventas vta = objectSpace.FindObject <Ventas>(null);

                foreach (string file in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.xml"))
                {
                    XmlDocument xml = new XmlDocument();

                    xml.Load(file);
                    XmlNodeList nl = xml.GetElementsByTagName("tfd:TimbreFiscalDigital");
                    if (nl != null && nl.Count > 0)
                    {
                        XmlNode se = nl[0].Attributes.GetNamedItem("UUID");
                        XmlNode fe = nl[0].Attributes.GetNamedItem("FechaTimbrado");
                        if (se != null)
                        {
                            foreach (DocumentoSalida fac in arr)
                            {
                                if (!string.IsNullOrEmpty(fac.Uuid))
                                {
                                    if (se.Value == fac.Uuid)
                                    {
                                        string aux;

                                        /*
                                         * string aux = Directory.GetCurrentDirectory();
                                         * aux = Path.Combine(aux, "Pdfs");*/
                                        aux = Path.Combine(vta.VntCfdi.RutaPdfVnts, fac.Tipo.ToString());
                                        aux = NegocioAdmin.CreaDirs(aux, fac.FechaDoc);

                                        aux = Path.Combine(aux, Path.GetFileName(file));
                                        // string.Format("{0}-{1}.xml", it.ReciboN, it.Uuid));
                                        File.Move(file, aux);

                                        // CreaPdfImprime(false, true, objectSpace);
                                        // NegocioNom.ImprFto("ReciboItem", false, true, NegocioNom.NamePdf(it), it, objectSpace);
                                        fac.Concilia = true;
                                    }
                                }
                            }
                        }
                    }
                }
                objectSpace.CommitChanges();
            }
        }