//-----------------------------------------------
 public CEasyQueryFromEasyQueryASourcesSpecifique(
     CEasyQuery queryPointee,
     CEasyQuerySource source)
 {
     m_queryPointee = queryPointee;
     m_listeSources.AddSource(source);
 }
Exemple #2
0
        //-------------------------------------------------------
        protected override void MyDraw(CContextDessinObjetGraphique ctx)
        {
            Rectangle rct = RectangleAbsolu;

            rct.Inflate(-c_nTailleOmbre / 2, -c_nTailleOmbre / 2);
            rct.Offset(c_nTailleOmbre / 2, c_nTailleOmbre / 2);
            ctx.Graphic.FillRectangle(Brushes.LightGray, rct);
            rct.Offset(-c_nTailleOmbre, -c_nTailleOmbre);
            ctx.Graphic.FillRectangle(Brushes.White, rct);
            ctx.Graphic.DrawRectangle(Pens.Black, rct);

            CEasyQuery query = Query;

            Rectangle rctHeader = new Rectangle(rct.Location, new Size(rct.Width, HeaderHeight));

            ctx.Graphic.DrawRectangle(Pens.Black, rctHeader);
            rctHeader.Inflate(-1, -1);

            DrawHeader(ctx, rctHeader);
            //Dessins des colonnes
            if (m_bIsExpanded)
            {
                Rectangle rctCols = new Rectangle(rct.Left + 1, rctHeader.Bottom + 2, rct.Width - 2, rct.Height - rctHeader.Height - 2);
                DrawColumns(ctx, rctCols);
            }
            if (m_postFilter != null)
            {
                m_postFilter.Draw(this, ctx);
            }
        }
Exemple #3
0
        //------------------------------------------------
        public static CEasyQueryAvecSource FromQuery(CEasyQuery query)
        {
            CEasyQueryAvecSource qas = new CEasyQueryAvecSource();

            byte[] data = null;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    CSerializerSaveBinaire ser = new CSerializerSaveBinaire(writer);
                    CResultAErreur         res = query.Serialize(ser);

                    data = stream.GetBuffer();
                    writer.Close();
                    writer.Dispose();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            using (MemoryStream stream = new MemoryStream(data))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    CSerializerReadBinaire ser = new CSerializerReadBinaire(reader);
                    CResultAErreur         res = qas.BaseSerialize(ser);
                    qas.Sources = query.Sources;
                    reader.Close();
                    stream.Close();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            return(qas);
        }
Exemple #4
0
        //------------------------------------------------
        public CEasyQuery GetEasyQuerySansSource()
        {
            CEasyQuery qss = new CEasyQuery();

            byte[] data = null;
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    CSerializerSaveBinaire ser = new CSerializerSaveBinaire(writer);
                    CResultAErreur         res = BaseSerialize(ser);
                    data = stream.GetBuffer();
                    writer.Close();
                    writer.Dispose();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            using (MemoryStream stream = new MemoryStream(data))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    CSerializerReadBinaire ser = new CSerializerReadBinaire(reader);
                    CResultAErreur         res = qss.Serialize(ser);
                    qss.Sources = Sources;
                    reader.Close();
                    stream.Close();
                    if (!res)
                    {
                        return(null);
                    }
                }
            }
            return(qss);
        }
Exemple #5
0
        //-------------------------------------------------------
        protected override CResultAErreur GetDatasHorsCalculees(CListeQuerySource sources)
        {
            CEasyQuery     query  = Query;
            CResultAErreur result = CResultAErreur.True;

            if (result && TableDefinition == null)
            {
                result.EmpileErreur(I.T("Table object must be specified |20001"));
            }
            if (query == null || sources == null)
            {
                result.EmpileErreur(I.T("Query needs a source to provide datas|20000"));
            }
            CEasyQuerySource source = sources.GetSourceFromId(TableDefinition.SourceId);

            if (source == null)
            {
                result.EmpileErreur(I.T("Query needs a source to provide datas|20000"));
            }


            if (result)
            {
                IEnumerable <string> lstCols = new List <string>();

                if (m_definitionTable != null && m_listeColonnes != null && m_listeColonnes.Count() != m_definitionTable.Columns.Count())
                {
                    lstCols = from c in m_listeColonnes where c is CColumnEQFromSource select((CColumnEQFromSource)c).IdColumnSource;
                }


                ITableDefinitionRequetableCAML tblCAML = TableDefinition as ITableDefinitionRequetableCAML;
                if (tblCAML != null && m_CAMLQuery != null)
                {
                    result = tblCAML.GetDatasWithCAML(source, Parent as CEasyQuery, m_CAMLQuery, lstCols.ToArray());
                }
                else
                {
                    result = TableDefinition.GetDatas(source, lstCols.ToArray());
                }

                if (result && result.Data is DataTable)
                {
                    DataTable table = result.Data as DataTable;
                    foreach (DataColumn col in new ArrayList(table.Columns))
                    {
                        IColumnDefinition  def   = TableDefinition.Columns.FirstOrDefault(c => c.ColumnName.ToUpper() == col.ColumnName.ToUpper());
                        IColumnDeEasyQuery laCol = null;
                        if (def == null || (laCol = GetColonneFor(def)) == null)
                        {
                            table.Columns.Remove(col);
                        }
                        else
                        {
                            col.ColumnName = laCol.ColumnName;
                            col.ExtendedProperties[CODEQBase.c_extPropColonneId] = laCol.Id;
                        }
                    }
                    if (tblCAML == null && m_CAMLQuery != null)
                    {
                        string strRowFilter = m_CAMLQuery.GetRowFilter(Parent as CEasyQuery);
                        if (strRowFilter.Length > 0)
                        {
                            HashSet <DataRow> rows = new HashSet <DataRow>();
                            foreach (DataRow row in table.Select(strRowFilter))
                            {
                                rows.Add(row);
                            }
                            foreach (DataRow row in new ArrayList(table.Rows))
                            {
                                if (!rows.Contains(row))
                                {
                                    table.Rows.Remove(row);
                                }
                            }
                            table.AcceptChanges();
                        }
                    }
                    //Vérifie et corrige le type des colonnes
                    foreach (CColumnEQFromSource col in Columns)
                    {
                        DataColumn colDeTable = table.Columns[col.ColumnName];
                        if (colDeTable != null && col.DataType != colDeTable.DataType)
                        {
                            col.DataType = colDeTable.DataType;
                        }
                    }
                }
            }
            if (!result)
            {
                result.EmpileErreur(I.T("Error on table @1|20002"));
            }
            return(result);
        }