示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("program start!!");
               // ClinetsInfoParser.Parse();
               var tbl=new DataTable();
            tbl.TableName = "custom";
            tbl.Columns.Add("Name");
            tbl.Columns.Add("Producer");
            tbl.Columns.Add("Trash");
            tbl.Columns.Add("Expires");
            tbl.Columns.Add("Quantity");
            tbl.Columns.Add("Trash2");
            tbl.Columns.Add("Division");

            for (int i = 0; i < 15; i++)
                tbl.Rows.Add("Name" + i.ToString(), "Producer" + i.ToString(), i.ToString(), DateTime.Now.ToShortDateString(),
                             i.ToString(),i.ToString(), "Division" + i.ToString());
            var stream=new MemoryStream();
            tbl.WriteXml(stream,XmlWriteMode.WriteSchema);
               var data= Packer.Pack(stream);
               var result = new ConcurrentBag<byte[]>();
            result.Add(data);
            result.ToQueryResult();

                Console.ReadKey();
        }
示例#2
0
        List<QueryResult> IRISIQueryContract.PostQuery(QueryData data)
        {
            var result = new ConcurrentBag<byte[]>();
            //  new List<byte[]>();
            var queryClassesManager = new QueryClassesManager();
            var factory = new QueryClassesFactory();
            try
            {
                queryClassesManager.LoadQueryClasses();
            }
            catch (Exception exp)
            {
                logger.Warn("queryClassesManager, failed \r\n"+exp.ToString());
                throw new FaultException("queryClassesManager, failed");
            }

            var queryClasses = queryClassesManager.Repo.QueryClasses;

            Parallel.ForEach(queryClasses, currentClass =>
                {
                    try
                    {
                      var  instance = factory.Create(currentClass);
                        result.Add(instance.ExecuteQuery(data));
                    }
                    catch (FaultException faultEx)
                    {
                        logger.Warn("failed on executing query \r\n" + faultEx.ToString());
                    }
                    catch (Exception exp)
                    {

                        logger.Warn("failed creating IDataBase instance \r\n" + exp.ToString());
                    }

                });
            List<QueryResult> re=null;
            try
            {
                re = result.ToQueryResult();
            }
            catch (Exception exp)
            {
                logger.Warn("failed creating results list \r\n" + exp.ToString());
                throw new FaultException("failed creating results list");
            }

            return re;
        }