Пример #1
0
        public To M(Ti i) {
            var m = A(i);
            var n = B(m);
            var o = C(n);

            return o;
        }
        private Table Delete(Node Root)
        {
            int Impact = 0;

            From(Root.Children[0]);
            if (Root.Children.Count > 1)
            {
                Where(Root.Children[1]);
            }
            foreach (Table Ti in Tables)
            {
                foreach (int i in Filters[Ti.Name])
                {
                    Ti.RemoveRecord(i);
                }
                Impact      = Math.Max(Impact, Filters[Ti.Name].Count);
                Ti.Records -= Filters[Ti.Name].Count;
            }
            Result         = Impact.ToString() + " records affected";
            AfterEffect[1] = true;
            AfterEffect[2] = true;
            return(null);
        }
Пример #3
0
 public void Process(Ti message) {
     _Process(message);
 }
Пример #4
0
 private Tm A(Ti i) {
     return new Tm();
 }
Пример #5
0
        public static bool Catalogo(List <ProductoCatalogo> productos)
        {
            Document document = new Document(PageSize.LETTER, 30, 30, 30, 30);

            //MemoryStream
            MemoryStream PDFData = new MemoryStream();
            PdfWriter    writer  = PdfWriter.GetInstance(document, new FileStream(Application.StartupPath + "\\Catalogo.pdf", FileMode.Create));


            // First, create our fonts
            var       portadaFont            = FontFactory.GetFont("Arial", 25, Font.BOLD, BaseColor.WHITE);
            var       portadaDescriptionFont = FontFactory.GetFont("Arial", 14, Font.NORMAL, BaseColor.WHITE);
            var       productNameFont        = FontFactory.GetFont("Arial", 16, Font.BOLD, BaseColor.BLACK);
            var       productNameFontLess    = FontFactory.GetFont("Arial", 15, Font.BOLD, BaseColor.BLACK);
            var       productNameFontLess12  = FontFactory.GetFont("Arial", 12, Font.BOLD, BaseColor.BLACK);
            var       productDescriptionFont = FontFactory.GetFont("Arial", 14, Font.NORMAL, BaseColor.BLACK);
            var       productPricesFont      = FontFactory.GetFont("Arial", 12, Font.NORMAL, BaseColor.BLACK);
            Rectangle pageSize = writer.PageSize;

            // Open the Document for writing
            document.Open();
            //Add elements to the document here
            #region PortadaCatalogo
            //Seccion para la creacion de la portada del catalogo
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\Recursos\\Agosto.png");
            logo.SetAbsolutePosition(0, 0);
            document.Add(logo);
            #endregion

            #region DeclaracionTablasYCeldas
            PdfPTable Ti             = new PdfPTable(2);
            PdfPTable subTable       = new PdfPTable(1);
            PdfPTable tableNameImage = new PdfPTable(1);
            PdfPTable tableprices    = new PdfPTable(3);
            PdfPCell  principalCell  = new PdfPCell();
            PdfPCell  cel            = new PdfPCell();
            PdfPCell  productCel     = new PdfPCell();
            #endregion


            int      cont = -1;
            string   fileName;
            DateTime fileCreationDatetime;
            foreach (ProductoCatalogo aux in productos)
            {
                if (cont == 4 || cont == -1)
                {
                    if (cont != -1)
                    {
                        document.Add(Ti);
                    }
                    #region Cabecera
                    //Aqui se pretende generar el codigo que nos permitira agregar los productos
                    document.NewPage();
                    fileName             = string.Empty;
                    fileCreationDatetime = DateTime.Now;
                    document.AddHeader("Principal", "Guadalajara, Jalisco, México a " + fileCreationDatetime.ToString(@"yyyyMMdd"));
                    logo = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\Recursos\\Cabecera.png");
                    logo.SetAbsolutePosition(10, document.PageSize.Height - 30);
                    logo.ScaleToFit(pageSize);
                    document.Add(logo);
                    Ti = new PdfPTable(2);
                    Ti.HorizontalAlignment = 0;
                    Ti.WidthPercentage     = 100;
                    Ti.SetWidths(new float[] { 100, 100 });  // then set the column's __relative__ widths
                    Ti.SpacingBefore      = 100;
                    Ti.DefaultCell.Border = Rectangle.NO_BORDER;
                    #endregion

                    cont = 0;
                }
                #region AgregarProductos
                //Agregamos las propiedades de la tabla de nombre e imagenes
                tableNameImage = new PdfPTable(1);
                tableNameImage.SpacingBefore       = 15;
                tableNameImage.HorizontalAlignment = 0;
                tableNameImage.WidthPercentage     = 100;
                tableNameImage.SetWidths(new float[] { 100 });  // then set the column's __relative__ widths
                tableNameImage.SpacingBefore      = 15;
                tableNameImage.DefaultCell.Border = Rectangle.NO_BORDER;
                //Agregamos el nombre del producto
                if (aux.Descripcion.Length > 32)
                {
                    cel = new PdfPCell(new Phrase(aux.Descripcion, productNameFontLess12));
                }
                else if (aux.Descripcion.Length > 28)
                {
                    cel = new PdfPCell(new Phrase(aux.Descripcion, productNameFontLess));
                }
                else
                {
                    cel = new PdfPCell(new Phrase(aux.Descripcion, productNameFont));
                }
                cel.FixedHeight         = 20;
                cel.MinimumHeight       = 20;
                cel.Border              = Rectangle.NO_BORDER;
                cel.BackgroundColor     = BaseColor.WHITE;
                cel.HorizontalAlignment = 1;
                tableNameImage.AddCell(cel);
                //Agregamos la imagen del producto
                cel                     = new PdfPCell();
                cel.Border              = Rectangle.NO_BORDER;
                cel.BackgroundColor     = BaseColor.WHITE;
                cel.HorizontalAlignment = Element.ALIGN_CENTER;
                cel.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cel.Image               = Image.GetInstance(Imagenes.ResizeImage(System.Drawing.Image.FromFile(Application.StartupPath + "\\Imagenes\\" + aux.Imagen), 500, 500), BaseColor.WHITE);
                tableNameImage.AddCell(cel);


                //Agregamos el codigo del producto
                cel                     = new PdfPCell(new Phrase(aux.Codigo, productDescriptionFont));
                cel.Border              = Rectangle.NO_BORDER;
                cel.BackgroundColor     = BaseColor.WHITE;
                cel.HorizontalAlignment = 1;
                tableNameImage.AddCell(cel);
                //cel = new PdfPCell(tableNameImage);
                //subTable.SetWidths(new float[] { 100 });
                //subTable.DefaultCell.Border = Rectangle.NO_BORDER;
                //subTable.AddCell(cel);
                //Agregamos las propiedades de la tabla de productos
                tableprices = new PdfPTable(3);
                tableprices.SetWidths(new float[] { 25, 25, 25 });
                tableprices.DefaultCell.Border = Rectangle.NO_BORDER;
                //Agregamos las celdas de productos
                //celda de precio publico
                productCel = new PdfPCell(new Phrase("Publico", productDescriptionFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.LIGHT_GRAY;
                tableprices.AddCell(productCel);
                //Celda de precio distribuidor
                productCel = new PdfPCell(new Phrase("Distribuidor", productDescriptionFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.LIGHT_GRAY;
                tableprices.AddCell(productCel);
                //Celda de precio minimo
                productCel = new PdfPCell(new Phrase("Minimo", productDescriptionFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.LIGHT_GRAY;
                tableprices.AddCell(productCel);
                //Info de las celdas
                //publico
                productCel = new PdfPCell(new Phrase(aux.PrecioPublico.ToString("$0.00"), productPricesFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.WHITE;
                tableprices.AddCell(productCel);
                //distribuidor
                productCel = new PdfPCell(new Phrase(aux.PrecioDistribuidor.ToString("$0.00"), productPricesFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.WHITE;
                tableprices.AddCell(productCel);
                //Minimo
                productCel = new PdfPCell(new Phrase(aux.PrecioMinimo.ToString("$0.00"), productPricesFont));
                productCel.HorizontalAlignment = 1;
                productCel.Border          = Rectangle.RECTANGLE;
                productCel.BackgroundColor = BaseColor.WHITE;
                tableprices.AddCell(productCel);
                //Agregamos la tabla de nombre a imagen a la celda principal y lo agregamos a la tabla auxiliar
                principalCell = new PdfPCell(tableNameImage);
                subTable      = new PdfPTable(1);
                subTable.AddCell(principalCell);
                //Agregamos la tabla de productos a la celda principal
                principalCell = new PdfPCell(tableprices);
                //Agregamos la celda principal a la sub tabla
                subTable.AddCell(principalCell);
                //Convertimos la sub tabla a una celda y lo agregamos a la tabla principal
                principalCell = new PdfPCell(subTable);
                //Agregamos la primer celda a la tabla principal
                Ti.AddCell(principalCell);
                #endregion
                cont++;
            }
            document.Add(Ti);
            #region ContraPortada
            //Seccion para la creacion de la portada del catalogo
            document.NewPage();
            logo = iTextSharp.text.Image.GetInstance(Application.StartupPath + "\\Recursos\\ContraPortada.png");
            logo.SetAbsolutePosition(0, 0);
            document.Add(logo);
            #endregion
            document.Close();
            return(true);
        }
Пример #6
0
        public static string getBigAnswer(byte[] bytes)
        {
            string getAnswer  = String.Empty;
            int    indexShift = 4;
            /**/
            string newLine       = Environment.NewLine;
            string empty         = "\t";
            uint   Ni            = BitConverter.ToUInt32(bytes, 0x0 + indexShift);
            uint   Tn            = BitConverter.ToUInt16(bytes, 0x4 + indexShift);     //kas 100 ms čia, 0xFFFF - riba, po kurios stoja
            double Tn_in_seconds = (double)Tn * 0.1;                                   //Tn dabar čia bus sekundėmis, jį grąžiname;
            uint   HV45          = BitConverter.ToUInt16(bytes, 0x6 + indexShift);     //HV45, dauginant 1,0498V gaunama įtampa nuo 0 iki 4,5 kV;
            double HV45_d        = (double)HV45 * 1.0498;                              //00HV45 šaltinio įtampa 0-4,5kV skalėje;
            uint   HV35          = BitConverter.ToUInt16(bytes, 0x8 + indexShift);     //00HV35, 3,5-4,5 kV skalėje;
            double HV35_d        = 3490 - HV35 * 0.1813;                               //00HV35 vertė voltais, 3,5-4,5 kV skalėje;
            uint   PWM           = bytes[0xa + indexShift];                            //PWM vertė?
            uint   Ti            = bytes[0xb + indexShift];                            //
            /**/
            uint   Tm      = BitConverter.ToUInt32(bytes, 0x60 + indexShift);          //tm trukmė milisekundėmis; be konvertavimo grąžinama;
            double HV45_15 = BitConverter.ToUInt16(bytes, 0x64 + indexShift) * 0.1813; //įtampa 00HV45_15 voltais 0-4,5kV skalėje; jau konvertuota;
            uint   Iin     = BitConverter.ToUInt16(bytes, 0x66 + indexShift);          //iin vertė, kokiais vienetais?

            //Viskas sujungiama į string'ą:
            getAnswer = Ni.ToString() + empty + Tn_in_seconds.ToString() + empty + HV45_d.ToString() + empty + HV35_d.ToString() + empty + PWM.ToString() + empty + Ti.ToString() + empty + Tm.ToString() + empty + HV45_15.ToString() + empty + Iin.ToString() + newLine;

            return(getAnswer);
        }
        private Table Select(Node Root)
        {
            From(Root.Children[1]);

            SelectKeys(Root.Children[0]);

            Key ForeignKey = Tables.Last().Keys.First();

            for (int i = 2; i < Root.Children.Count; i++)
            {
                if (Joiners.ContainsKey(Root.Children[i].HostedToken.Type))
                {
                    ForeignKey = Joiners[Root.Children[i].HostedToken.Type](Root.Children[i]).Keys.First();
                    SelectKeys(Root.Children[0]);
                }
                else if (Conditionals.ContainsKey(Root.Children[i].HostedToken.Type))
                {
                    Conditionals[Root.Children[i].HostedToken.Type](Root.Children[i]);
                }
            }

            Table Response = new Table(Tables[0].Name + ((Tables.Count > 1)?"featuring " + Tables[1].Name:""));

            Response.Records = Filters.Last().Value.Count; //the last table is treated as a reference point for joiners
                                                           //therfore left join inverse the 2 tables to maintain
                                                           //Where the last table will be joined completely

            Dictionary <string, List <int> > KIndices = new Dictionary <string, List <int> >();

            foreach (Table Ti in Tables)
            {
                KIndices.Add(Ti.Name, new List <int>());
                foreach (Key Ki in KeyIDs[Ti.Name])
                {
                    Response.Keys.Add(new Key(Ki, true));
                    KIndices[Ti.Name].Add(Ti.getKeyIndex(Ki.Name));
                }
            }

            Dictionary <int, int> assistiveIndex = indexFilter(ForeignKey);

            byte[] nullarr = { 0, 0, 0, 0, 0, 0, 0, 0 }; // \u0000 standard null
            for (int i = 0; i < Response.Records; i++)
            {
                List <byte[]> Record = new List <byte[]>();     //Assembling records that span multiple tables

                if (assistiveIndex.ContainsKey(BitConverter.ToInt32(Tables.Last().Keys[0].DATA[Filters[Tables.Last().Name][i]], 0)) &&
                    i < Filters[Tables.First().Name].Count)
                {
                    Record.AddRange(Tables.First().RetrieveRecord(KIndices[Tables.First().Name], assistiveIndex[BitConverter.ToInt32(Tables.Last().Keys[0].DATA[Filters[Tables.Last().Name][i]], 0)]));
                    if (Tables.Count > 1)
                    {
                        Record.AddRange(Tables.Last().RetrieveRecord(KIndices[Tables.Last().Name], Filters[Tables.Last().Name][i]));
                    }
                }
                else
                {
                    Record.AddRange(Enumerable.Repeat(nullarr, (KIndices[Tables.First().Name].Count)));
                    Record.AddRange(Tables.Last().RetrieveRecord(KIndices[Tables.Last().Name], Filters[Tables.Last().Name][i]));
                }
                Response.AppendRecord(Enumerable.Range(0, Response.KeysCount).ToList(), Record);
            }

            return(Response);
        }