Example #1
0
        private void BandingReport()
        {
            //定义报表参数对象
            List <ReportParameter> parameterList = new List <ReportParameter>();
            var paramDic = RdlcParam();

            foreach (var key in paramDic.Keys)
            {
                parameterList.Add(new ReportParameter(key, paramDic[key]));
            }
            string ReportPath = "Areas\\Report\\Template\\CompanyNetwork.rdlc";

            ReportViewer1.LocalReport.ReportPath             = ReportPath;
            ReportViewer1.LocalReport.ReportEmbeddedResource = "Tablix1";
            ReportViewer1.LocalReport.SetParameters(parameterList);

            DataTable        table = MonitorData.CompanyNetwork("1", SerializerHelper.Deserialize <List <string> >(Request.QueryString["companyID"]));
            ReportDataSource rds   = new ReportDataSource("CompanyNetwork", table); //指定数据源GetTestDataTable()

            ReportViewer1.LocalReport.DataSources.Clear();                          //报表数据源清除,必须
            ReportViewer1.LocalReport.DataSources.Add(rds);                         //报表数据源增加
            ReportViewer1.LocalReport.Refresh();                                    //刷新报表
        }
        public async Task <IEnumerable <Candle> > GetCachedDataAsync(Symbol symbol, string period, DateTime fromDate, DateTime toDate, bool isContinous = false, bool isDevelopment = false)
        {
            var results        = new List <Candle>();
            var cachedFilePath = GetFilePath(symbol, toDate.AddDays(-1).EndOfDay(), period);

            if (!File.Exists(cachedFilePath))
            {
                var cachedData = await SetCacheData(symbol, period, fromDate, toDate.AddDays(-1).EndOfDay(), cachedFilePath);

                if (cachedData != null)
                {
                    results.AddRange(cachedData);
                }
            }
            else
            {
                results.AddRange(await SerializerHelper.Deserialize <IEnumerable <Candle> >(cachedFilePath));
            }

            if (results.Count > 0)
            {
                //patch todays data
                var todaysData = GetData(symbol, period, toDate.StartOfDay(), toDate);
                if (todaysData != null && todaysData.Count() > 0)
                {
                    results.AddRange(todaysData);
                    return(results);
                }
                else if (isDevelopment)
                {
                    return(results);
                }
            }


            return(null);
        }
Example #3
0
        public DefaultValues LoadSettings(string fileName)
        {
            DefaultValues defaultValues;

            try
            {
                var settings = SerializerHelper.Deserialize <Settings>(_ioServices, fileName);

                defaultValues = settings.DefaultValues;
            }
            catch
            {
                defaultValues = TryRestoreSettingsBackup(fileName);
            }

            if (defaultValues == null)
            {
                defaultValues = new DefaultValues();
            }

            if (defaultValues.Users == null)
            {
                defaultValues.Users = new string[0];
            }

            if (defaultValues.RootFolders == null)
            {
                defaultValues.RootFolders = new string[0];
            }

            if (defaultValues.FileExtensions == null)
            {
                defaultValues.FileExtensions = new string[0];
            }

            return(defaultValues);
        }
        private void BandingReport()
        {
            List <string> pkIDList = SerializerHelper.Deserialize <List <string> >(Request.QueryString["PK_ID"]);
            //定义报表参数对象
            List <ReportParameter> parameterList = new List <ReportParameter>();
            var paramDic = RdlcParam(Request.QueryString["reportType"]);

            foreach (var key in paramDic.Keys)
            {
                parameterList.Add(new ReportParameter(key, paramDic[key]));
            }
            string ReportPath = "Areas\\Report\\Template\\ReportingRate.rdlc";

            ReportViewer1.LocalReport.ReportPath             = ReportPath;
            ReportViewer1.LocalReport.ReportEmbeddedResource = "Tablix1";
            ReportViewer1.LocalReport.SetParameters(parameterList);

            DataTable        table = MonitorData.PK_PollutionReportRate(pkIDList, startTime, endTime, Request.QueryString["dataFrom"], dataType);
            ReportDataSource rds   = new ReportDataSource("ReportingRate", table); //指定数据源GetTestDataTable()

            ReportViewer1.LocalReport.DataSources.Clear();                         //报表数据源清除,必须
            ReportViewer1.LocalReport.DataSources.Add(rds);                        //报表数据源增加
            ReportViewer1.LocalReport.Refresh();                                   //刷新报表
        }
Example #5
0
        private DataTable CreateDataTable(RequestData data)
        {
            /*
             * 1, 获取列头前台绑定信息(字段)
             * 4, 判断数据类型
             * 5,获取数据源
             * 6,组装合并DataTable返回完整数据
             */
            DataTable      createTable = new DataTable();
            List <dynamic> getCols     = SerializerHelper.Deserialize <List <dynamic> >(data.Get("Cols"));

            //List<dynamic> getRows = null;
            getCols.ForEach(m =>
                            { createTable.Columns.Add(m["field"]); });
            //createTable.Columns.Add("WEB_STATE");
            //createTable.Columns.Add("COMPANY_NAME");
            //createTable.Columns.Add("PK_NAME");
            //createTable.Columns.Add("ALERT_TIME");
            GetWebStateList(data, createTable, getCols);



            return(createTable);
        }
Example #6
0
 public static TResult Deserialize <T, TResult>(T data) where TResult : class
 {
     return(SerializerHelper.Deserialize <T, TResult>(data));
 }
        public void SerializerHelperTest()
        {
            Quota quota = new Quota()
            {
                Amount                = 100_0000,
                AuctionPrice          = 110,
                BiddingPrice          = 90,
                BuyPrice1             = 91,
                BuyPrice2             = 92,
                BuyPrice3             = 93,
                BuyPrice4             = 94,
                BuyPrice5             = 95,
                BuyStrand1            = 1000,
                BuyStrand2            = 2000,
                BuyStrand3            = 3000,
                BuyStrand4            = 4000,
                BuyStrand5            = 5000,
                ClosingPriceYesterday = 95,
                Code              = "000001",
                Count             = 10000,
                CurrentPrice      = 100,
                DayHighPrice      = 110,
                DayLowPrice       = 90,
                Market            = Markets.ShangHai,
                Name              = "上证指数",
                OpeningPriceToday = 105,
                SellPrice1        = 115,
                SellPrice2        = 114,
                SellPrice3        = 113,
                SellPrice4        = 112,
                SellPrice5        = 111,
                SellStrand1       = 1000,
                SellStrand2       = 2000,
                SellStrand3       = 3000,
                SellStrand4       = 4000,
                SellStrand5       = 5000,
                Stock             = new Stock("000001", Markets.ShangHai, "上证指数"),
                UpdateTime        = new DateTime(2020, 12, 31, 12, 30, 15),
            };

            // 将导致循环引用问题
            // quota.Stock.Quotas.Add(quota);

            var content = SerializerHelper.Serialize(quota);

            Assert.IsFalse(string.IsNullOrWhiteSpace(content));

            var newQuota = SerializerHelper.Deserialize <Quota>(content);

            Assert.AreEqual(quota.Amount, newQuota.Amount);
            Assert.AreEqual(quota.AuctionPrice, newQuota.AuctionPrice);
            Assert.AreEqual(quota.BiddingPrice, newQuota.BiddingPrice);
            Assert.AreEqual(quota.BuyPrice1, newQuota.BuyPrice1);
            Assert.AreEqual(quota.BuyPrice2, newQuota.BuyPrice2);
            Assert.AreEqual(quota.BuyPrice3, newQuota.BuyPrice3);
            Assert.AreEqual(quota.BuyPrice4, newQuota.BuyPrice4);
            Assert.AreEqual(quota.BuyPrice5, newQuota.BuyPrice5);
            Assert.AreEqual(quota.BuyStrand1, newQuota.BuyStrand1);
            Assert.AreEqual(quota.BuyStrand2, newQuota.BuyStrand2);
            Assert.AreEqual(quota.BuyStrand3, newQuota.BuyStrand3);
            Assert.AreEqual(quota.BuyStrand4, newQuota.BuyStrand4);
            Assert.AreEqual(quota.BuyStrand5, newQuota.BuyStrand5);
            Assert.AreEqual(quota.ClosingPriceYesterday, newQuota.ClosingPriceYesterday);
            Assert.AreEqual(quota.Code, newQuota.Code);
            Assert.AreEqual(quota.Count, newQuota.Count);
            Assert.AreEqual(quota.CurrentPrice, newQuota.CurrentPrice);
            Assert.AreEqual(quota.DayHighPrice, newQuota.DayHighPrice);
            Assert.AreEqual(quota.DayLowPrice, newQuota.DayLowPrice);
            Assert.AreEqual(quota.Market, newQuota.Market);
            Assert.AreEqual(quota.Name, newQuota.Name);
            Assert.AreEqual(quota.OpeningPriceToday, newQuota.OpeningPriceToday);
            Assert.AreEqual(quota.SellPrice1, newQuota.SellPrice1);
            Assert.AreEqual(quota.SellPrice2, newQuota.SellPrice2);
            Assert.AreEqual(quota.SellPrice3, newQuota.SellPrice3);
            Assert.AreEqual(quota.SellPrice4, newQuota.SellPrice4);
            Assert.AreEqual(quota.SellPrice5, newQuota.SellPrice5);
            Assert.AreEqual(quota.SellStrand1, newQuota.SellStrand1);
            Assert.AreEqual(quota.SellStrand2, newQuota.SellStrand2);
            Assert.AreEqual(quota.SellStrand3, newQuota.SellStrand3);
            Assert.AreEqual(quota.SellStrand4, newQuota.SellStrand4);
            Assert.AreEqual(quota.SellStrand5, newQuota.SellStrand5);
            Assert.AreEqual(quota.UpdateTime, newQuota.UpdateTime);

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int index = 0; index < 10000; index++)
            {
                _ = SerializerHelper.Serialize(quota);
            }
            stopwatch.Stop();
            Console.WriteLine($"序列化 10000 次耗时:{stopwatch.ElapsedMilliseconds} ms");
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 1000);

            stopwatch.Restart();
            for (int index = 0; index < 10000; index++)
            {
                _ = SerializerHelper.Deserialize <Quota>(content);
            }
            stopwatch.Stop();
            Console.WriteLine($"反序列化 10000 次耗时:{stopwatch.ElapsedMilliseconds} ms");
            Assert.IsTrue(stopwatch.ElapsedMilliseconds < 1000);
        }
Example #8
0
 /// <summary>
 /// DEPRECATED Method to pass the m_list to the serializer helper
 /// </summary>
 /// <param name="fileName"></param>
 public void TextDeserialize(string fileName)
 {
     m_list = SerializerHelper.Deserialize <List <T> >(fileName, SerializeFormat.TXT);
 }
Example #9
0
 private IEnumerable <FileEntry> ReadVersion2File(string fileName) => SerializerHelper.Deserialize <Files>(_ioServices, fileName).Entries;
Example #10
0
        public ExitCode Update()
        {
            if (!_config.Enabled)
            {
                CommonUnitity.OnLog(this, new EventArgs <string>("local config file not allowed update."));
                return(ExitCode.Default);
            }

            try
            {
                _remoteConfig =
                    SerializerHelper.Deserialize(typeof(RemoteConfig), RequestUrl(_config.ServerUrl)) as RemoteConfig;
            }
            catch (Exception ex)
            {
                CommonUnitity.OnLog(this, new EventArgs <string>(ex.Message));
                return(ExitCode.Default);
            }
            if (_remoteConfig == null)
            {
                CommonUnitity.OnLog(this, new EventArgs <string>("load remote config file failed."));
                return(ExitCode.Default);
            }

            if (!_remoteConfig.Enable)
            {
                CommonUnitity.OnLog(this, new EventArgs <string>("remote server not allowed update."));
                return(ExitCode.Default);
            }

            if (!CommonUnitity.ForceUpdate)
            {
                CommonUnitity.ForceUpdate = _remoteConfig.ForceUpdate;
            }

            List <DownloadFileInfo> downloadList = new List <DownloadFileInfo>();

            string dir = AppDomain.CurrentDomain.BaseDirectory;

            foreach (RemoteFile remoteFile in _remoteConfig.UpdateFileList)
            {
                string localFile = Path.Combine(dir, remoteFile.LocalPath);
                if (remoteFile.Md5.Equals(HashHelper.ComputeSHA1(localFile), StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }

                CommonUnitity.OnLog(this, new EventArgs <string>("FileToBeDownload:" + remoteFile));
                downloadList.Add(new DownloadFileInfo(remoteFile.Url, remoteFile.LocalPath, remoteFile.LastVer, remoteFile.Size));

                if (remoteFile.NeedRestart)
                {
                    _bNeedRestart = true;
                }
            }

            _downloadFileListTemp = downloadList;

            ExitCode exitCode = 0;

            if (_downloadFileListTemp != null && !_downloadFileListTemp.IsEmpty())
            {
                if (CommonUnitity.ForceUpdate)
                {
                    exitCode = StartDownload(downloadList);
                }
                else
                {
                    DownloadConfirm dc = new DownloadConfirm(downloadList);
                    if (this.OnShow != null)
                    {
                        this.OnShow();
                    }

                    if (DialogResult.OK == dc.ShowDialog())
                    {
                        exitCode = StartDownload(downloadList);
                    }
                    else
                    {
                        exitCode = ExitCode.SkipUpdate;
                        CommonUnitity.OnLog(this, new EventArgs <string>("Update skipped."));
                        Application.Exit();
                    }
                }
            }
            return(exitCode);
        }
Example #11
0
        public ActionResult InsertConfigEnt(RequestData data)
        {
            string     levelId = data.Get("LevelId");
            string     peakId  = data.Get("peakId");
            string     getGuid = Guid.NewGuid().ToString();
            PostResult result  = new PostResult();

            try
            {
                if (!string.IsNullOrEmpty(peakId))
                {
                    var getEnt = SqlModel.Select(T_THEPEAK_ENT_SUB_LIST.GUID)

                                 .From(DB.T_THEPEAK_ENT_SUB_LIST)

                                 .Where(T_THEPEAK_ENT_SUB_LIST.THEPEAKID == int.Parse(peakId)).ExecToDynamicList();
                    if (getEnt.Count > 0)
                    {
                        getGuid = getEnt[0]["GUID"];
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(levelId))
                    {
                        //获取配置中的各项类型

                        var getConfigEnt = SqlModel.SelectAll(
                            T_THEPEAK_LEVEL_CONFIG.ID.As("ConfigId"),
                            T_THEPEAK_LEVEL_LIST_INFO.ID.As("LeveId")
                            )

                                           .From(DB.T_THEPEAK_LEVEL_CONFIG)
                                           .LeftJoin(DB.T_THEPEAK_LEVEL_LIST_INFO).On(T_THEPEAK_LEVEL_LIST_INFO.ID == T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID)
                                           .Where(T_THEPEAK_LEVEL_CONFIG.PEAK_LEVE_ID == levelId).ExecToDynamicList();
                        T_THEPEAK_ENT_SUB_LISTModel modelEnt = new T_THEPEAK_ENT_SUB_LISTModel();

                        //  modelEnt.Delete(T_THEPEAK_ENT_SUB_LIST.THEPEAKID.IsNull() & T_THEPEAK_ENT_SUB_LIST.GUID != getGuid);


                        //往企业关系表插入值
                        getConfigEnt.ForEach(
                            m =>
                        {
                            modelEnt = SerializerHelper.Deserialize <T_THEPEAK_ENT_SUB_LISTModel>(SerializerHelper.Serialize(m), new List <string>()
                            {
                                "ID"
                            });
                            if (StringHelper.DynamicToString(m["IS_STOP"]) == "1")
                            {
                                modelEnt.ENT_PEAK_TYPE = 1;
                            }
                            else if (StringHelper.DynamicToString(m["LIMIT_TYPE"]) == "TheLimit")
                            {
                                modelEnt.ENT_PEAK_TYPE = 2;
                            }
                            else if (StringHelper.DynamicToString(m["LIMIT_TYPE"]) == "limitTime")
                            {
                                modelEnt.ENT_PEAK_TYPE = 3;
                            }
                            modelEnt.COMPANY_ID   = m["COMPANY_ID"];
                            modelEnt.LEVEL_ID     = m["PEAK_LEVE_ID"];
                            modelEnt.CONTROL_MEAS = m["PEAK_LEVE_ID"];
                            modelEnt.GUID         = getGuid;
                            modelEnt.IS_SELECT    = 1;
                            // modelEnt.ID = null;


                            modelEnt.Insert();
                        });


                        //   result.Data = modelEnt.GUID;
                        // result.Success = true;
                    }
                    else
                    {
                        result.Success = false;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            result.Data    = getGuid;
            result.Success = true;



            return(Json(result));
        }
Example #12
0
        private void DeserializeDockPanel(string path)
        {
            var state = SerializerHelper.Deserialize <DockPanelState>(path);

            DockPanel.RestoreDockPanelState(state, GetContentBySerializationKey);
        }
Example #13
0
        public void CanSerializeAndDeserialize()
        {
            var dt = new DateTime(2009, 12, 25, 11, 48, 33).AddMilliseconds(983);

            var actionResult = new ActionResult();

            var rs1_ = new ResultSet();

            actionResult.ResultSets.Add(rs1_);
            rs1_.Schema.Columns.Add(new Column {
                Name = "Id", DbType = "int", ClrType = typeof(int)
            });
            rs1_.Schema.Columns.Add(new Column {
                Name = "Name", DbType = "varchar", ClrType = typeof(string)
            });
            rs1_.Schema.Columns.Add(new Column {
                Name = "Price", DbType = "decimal", ClrType = typeof(decimal)
            });
            rs1_.Schema.Columns.Add(new Column {
                Name = "Expiry", DbType = "date", ClrType = typeof(DateTime)
            });

            rs1_.Rows.Add(new ResultSetRow());
            rs1_.Rows[0]["Id"]     = 12;
            rs1_.Rows[0]["Name"]   = "NVC001";
            rs1_.Rows[0]["Price"]  = 12.6m;
            rs1_.Rows[0]["Expiry"] = dt;

            rs1_.Rows.Add(new ResultSetRow());
            rs1_.Rows[1]["Id"]     = 12;
            rs1_.Rows[1]["Name"]   = "NVC001";
            rs1_.Rows[1]["Price"]  = 12.6m;
            rs1_.Rows[1]["Expiry"] = null;

            // 2nd resultset
            var rs2_ = new ResultSet();

            actionResult.ResultSets.Add(rs2_);
            rs2_.Schema.Columns.Add(new Column {
                Name = "Cola", DbType = "int", ClrType = typeof(int)
            });
            rs2_.Schema.Columns.Add(new Column {
                Name = "Colb", DbType = "varchar", ClrType = typeof(string)
            });

            rs2_.Rows.Add(new ResultSetRow());
            rs2_.Rows[0]["Cola"] = 19;
            rs2_.Rows[0]["Colb"] = null;

            var xml = SerializerHelper.SerializeObject(actionResult);

            var ar = SerializerHelper.Deserialize <ActionResult>(xml);

            Assert.IsNotNull(ar);
            Assert.IsNotNull(ar.ResultSets);
            Assert.AreEqual(2, ar.ResultSets.Count);

            Assert.IsNotNull(ar.ResultSets[0]);
            Assert.IsNotNull(ar.ResultSets[0].Schema);
            Assert.IsNotNull(ar.ResultSets[0].Schema.Columns);
            Assert.AreEqual(4, ar.ResultSets[0].Schema.Columns.Count);
            Assert.IsNotNull(ar.ResultSets[0].Rows);
            Assert.AreEqual(2, ar.ResultSets[0].Rows.Count);

            Assert.IsNotNull(ar.ResultSets[1]);
            Assert.IsNotNull(ar.ResultSets[1].Schema);
            Assert.IsNotNull(ar.ResultSets[1].Schema.Columns);
            Assert.AreEqual(2, ar.ResultSets[1].Schema.Columns.Count);
            Assert.IsNotNull(ar.ResultSets[1].Rows);
            Assert.AreEqual(1, ar.ResultSets[1].Rows.Count);
        }
Example #14
0
        public void CanDeserializeActionResultUsingXmlSerializer()
        {
            var dt1 = new DateTime(2000, 1, 15, 16, 33, 12).AddMilliseconds(788);
            var dt2 = new DateTime(2001, 2, 18, 7, 59, 55).AddMilliseconds(250);

            var sb = new StringBuilder();

            sb.Append("<ActionResult xmlns=\"http://tempuri.org/ActionResult.xsd\">");
            sb.Append("<ResultSets>");
            sb.Append("<ResultSet>");
            sb.Append("<Schema>");
            sb.Append("<Columns>");
            sb.Append("<Column name=\"Id\" dbType=\"int\" clrType=\"System.Int32\" />");
            sb.Append("<Column name=\"Name\" dbType=\"varchar\" clrType=\"System.String\" />");
            sb.Append("<Column name=\"Price\" dbType=\"decimal\" clrType=\"System.Decimal\" />");
            sb.Append("<Column name=\"Expiry\" dbType=\"date\" clrType=\"System.DateTime\" />");
            sb.Append("</Columns>");
            sb.Append("</Schema>");
            sb.Append("<Rows>");
            sb.Append("<Row>");
            sb.Append("<Id>12</Id>");
            sb.Append("<Name>NVC001</Name>");
            sb.Append("<Price>12.6</Price>");
            sb.Append("<Expiry>" + XmlConvert.ToString(dt1, XmlDateTimeSerializationMode.Utc) + "</Expiry>");
            sb.Append("</Row>");
            sb.Append("<Row>");
            sb.Append("<Id>15</Id>");
            sb.Append("<Name>NVC002</Name>");
            sb.Append("<Price>12.8</Price>");
            sb.Append("<Expiry>" + XmlConvert.ToString(dt2, XmlDateTimeSerializationMode.Utc) + "</Expiry>");
            sb.Append("</Row>");
            sb.Append("</Rows>");
            sb.Append("</ResultSet>");

            sb.Append("<ResultSet>");
            sb.Append("<Schema>");
            sb.Append("<Columns>");
            sb.Append("<Column name=\"Cola\" dbType=\"int\" clrType=\"System.Int32\" />");
            sb.Append("<Column name=\"Colb\" dbType=\"varchar\" clrType=\"System.String\" />");
            sb.Append("</Columns>");
            sb.Append("</Schema>");
            sb.Append("<Rows>");
            sb.Append("<Row>");
            sb.Append("<Cola>22</Cola>");
            sb.Append("</Row>");
            sb.Append("</Rows>");
            sb.Append("</ResultSet>");

            sb.Append("</ResultSets>");
            sb.Append("</ActionResult>");


            var xml = sb.ToString();//

            var ar = SerializerHelper.Deserialize <ActionResult>(xml);

            Assert.IsNotNull(ar.ResultSets);
            Assert.AreEqual(2, ar.ResultSets.Count);

            // 1st resultset
            var rs1 = ar.ResultSets[0];

            Assert.IsNotNull(rs1.Rows);
            Assert.AreEqual(2, rs1.Rows.Count);
            Assert.IsNotNull(rs1);
            Assert.IsNotNull(rs1.Schema);
            Assert.IsNotNull(rs1.Schema.Columns);
            Assert.AreEqual(4, rs1.Schema.Columns.Count);

            Assert.AreEqual("Id", rs1.Schema.Columns[0].Name);
            Assert.AreEqual("int", rs1.Schema.Columns[0].DbType);
            Assert.AreSame(typeof(int), rs1.Schema.Columns[0].ClrType);

            Assert.AreEqual("Name", rs1.Schema.Columns[1].Name);
            Assert.AreEqual("varchar", rs1.Schema.Columns[1].DbType);
            Assert.AreSame(typeof(string), rs1.Schema.Columns[1].ClrType);

            Assert.AreEqual("Price", rs1.Schema.Columns[2].Name);
            Assert.AreEqual("decimal", rs1.Schema.Columns[2].DbType);
            Assert.AreSame(typeof(decimal), rs1.Schema.Columns[2].ClrType);

            Assert.AreEqual("Expiry", rs1.Schema.Columns[3].Name);
            Assert.AreEqual("date", rs1.Schema.Columns[3].DbType);
            Assert.AreSame(typeof(DateTime), rs1.Schema.Columns[3].ClrType);

            Assert.AreEqual(2, rs1.Rows.Count);
            Assert.IsNotNull(rs1.Rows[0]);
            Assert.AreEqual(4, rs1.Rows[0].Count);
            Assert.AreEqual(12, rs1.Rows[0]["Id"]);
            Assert.AreSame(typeof(int), rs1.Rows[0]["Id"].GetType());
            Assert.AreEqual("NVC001", rs1.Rows[0]["Name"]);
            Assert.AreSame(typeof(string), rs1.Rows[0]["Name"].GetType());
            Assert.AreEqual(12.6m, rs1.Rows[0]["Price"]);
            Assert.AreSame(typeof(decimal), rs1.Rows[0]["Price"].GetType());
            Assert.AreEqual(dt1, rs1.Rows[0]["Expiry"]);
            Assert.AreSame(typeof(DateTime), rs1.Rows[0]["Expiry"].GetType());

            Assert.IsNotNull(rs1.Rows[1]);
            Assert.AreEqual(4, rs1.Rows[1].Count);
            Assert.AreEqual(15, rs1.Rows[1]["Id"]);
            Assert.AreSame(typeof(int), rs1.Rows[1]["Id"].GetType());
            Assert.AreEqual("NVC002", rs1.Rows[1]["Name"]);
            Assert.AreSame(typeof(string), rs1.Rows[1]["Name"].GetType());
            Assert.AreEqual(12.8m, rs1.Rows[1]["Price"]);
            Assert.AreSame(typeof(decimal), rs1.Rows[1]["Price"].GetType());
            Assert.AreEqual(dt2, rs1.Rows[1]["Expiry"]);
            Assert.AreSame(typeof(DateTime), rs1.Rows[1]["Expiry"].GetType());


            // 2nd resultset
            var rs2 = ar.ResultSets[1];

            Assert.IsNotNull(rs2);
            Assert.IsNotNull(rs2.Schema);
            Assert.IsNotNull(rs2.Schema.Columns);
            Assert.AreEqual(2, rs2.Schema.Columns.Count);

            Assert.AreEqual("Cola", rs2.Schema.Columns[0].Name);
            Assert.AreEqual("int", rs2.Schema.Columns[0].DbType);
            Assert.AreSame(typeof(int), rs2.Schema.Columns[0].ClrType);

            Assert.AreEqual("Colb", rs2.Schema.Columns[1].Name);
            Assert.AreEqual("varchar", rs2.Schema.Columns[1].DbType);
            Assert.AreSame(typeof(string), rs2.Schema.Columns[1].ClrType);

            Assert.IsNotNull(rs2.Rows[0]);
            Assert.AreEqual(2, rs2.Rows[0].Count);
            Assert.AreEqual(22, rs2.Rows[0]["Cola"]);
            Assert.AreSame(typeof(int), rs2.Rows[0]["Cola"].GetType());
            Assert.AreEqual(DBNull.Value, rs2.Rows[0]["Colb"]);
            Assert.AreSame(DBNull.Value.GetType(), rs2.Rows[0]["Colb"].GetType());
        }
Example #15
0
 public static object Deserialize <T>(T data, Type type)
 {
     return(SerializerHelper.Deserialize(data, type));
 }
Example #16
0
        static void Main(string[] args)
        {
            //Config Parse
            WriteLine("===== Config Parse =====");
            ConfigStruct config       = new ConfigStruct();
            string       rString      = "";
            int          numArgAccept = ConfigStruct.Parse(config, args, ref rString);;

            if (numArgAccept < 0)
            {
                ErrorWriteLine(rString);
                return;
            }

            WriteLine("Args Parsed Num:" + numArgAccept);
            ArgsShow(config);

            //Hex Load
            WriteLine("===== Hex Load =====");
            AddressDataGroup <byte> dataGroup = new AddressDataGroup <byte>();

            try
            {
                IntelHexLoader            hexLoader = new IntelHexLoader();
                IntelHexLoader.ResultEnum r         = hexLoader.Load(config.HexFile, dataGroup);
                if (dataGroup.Groups.Count != 1)
                {
                    ErrorWriteLine("Hex Not Have One Data Section.");
                    return;
                }
                if (r != IntelHexLoader.ResultEnum.Success)
                {
                    ErrorWriteLine(r.ToString());
                    return;
                }
                WriteLine("Hex Data Size:" + dataGroup.Groups[0].Datas.Count);
            }
            catch (Exception ee)
            {
                ErrorWriteLine(ee.Message);
                return;
            }

            //FlashSection Load
            JobMaker.FlashSectionStruct[] FlashSection = null;
            if (config.FlashSectionFile != "")
            {
                try
                {
                    WriteLine("===== FlashSection Load =====");
                    FlashSection = (JobMaker.FlashSectionStruct[])SerializerHelper.Deserialize(config.FlashSectionFile, typeof(JobMaker.FlashSectionStruct[]));
                    WriteLine("FlashSection Num:" + FlashSection.Length);
                }
                catch (Exception ee)
                {
                    ErrorWriteLine(ee.Message);
                    //return;
                }
            }

            //Job Make
            List <Job> jobs = new List <Job>();

            try
            {
                WriteLine("===== Job Make =====");
                JobMaker.EraseWrite(jobs, dataGroup, config.EraseOpt, FlashSection, true);

                if (config.JumpToFlash)
                {
                    JobMaker.Go(jobs, dataGroup.Groups[0].Address);
                }

                WriteLine("Job Num:" + jobs.Count);
            }
            catch (Exception ee)
            {
                ErrorWriteLine(ee.Message);
                return;
            }

            //CAN Open
            ICAN CANDev = null;

            try
            {
                WriteLine("===== CAN Open =====");
                string   dllPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, config.CANDevFile);
                Assembly ass     = Assembly.LoadFile(dllPath);
                Type     tCAN    = ass.GetType(config.CANDevClass);
                CANDev = (ICAN)Activator.CreateInstance(tCAN);
                bool rOpen = CANDev.Open(config.CANDeviceNo);
                if (!rOpen)
                {
                    ErrorWriteLine("CAN Open Fail.");
                    return;
                }
                bool rStart = CANDev.Start(config.CANPortNo, config.CANBPS, false, config.CANSendOnce, false);
                if (!rOpen)
                {
                    ErrorWriteLine("CAN Start Fail.");
                    return;
                }
                WriteLine("CAN Open Success");
            }
            catch (Exception ee)
            {
                ErrorWriteLine(ee.Message);
                return;
            }

            //JobExecutor Init
            WriteLine("===== JobExecutor Init =====");
            JobExecutor JE = new JobExecutor(CANDev, config.CANPortNo);

            JE.IsShowSendRecive = config.ShowReceiveSend;
            JE.TimeoutSpan      = new TimeSpan(0, 0, config.Timeout);
            JE.TimeoutSpanErase = new TimeSpan(0, 0, config.TimeoutErase);
            JE.OnStateChange   += JE_OnStateChange;
            JE.SetJob(jobs.ToArray());

            //Run
            WriteLine("===== JobExecutor Running =====");
            while (JE.IsRunning)
            {
                JE.BackgroundRun(false);
                Thread.Sleep(100);
            }
            WriteLine("End With:" + JE.JobsState);
        }
Example #17
0
 /// <summary>
 /// Method that fetches data from SerializerHelper class after binary deserialization to m_list
 /// </summary>
 /// <param name="fileName"></param>
 public void BinaryDeserialize(string fileName)
 {
     m_list = SerializerHelper.Deserialize <List <T> >(fileName, SerializeFormat.Bin);
 }
Example #18
0
 /// <summary>
 /// Method that fetches data from SerializerHelper class after binary deserialization to m_list
 /// </summary>
 /// <param name="fileName"></param>
 public void XMLDesrialize(string fileName)
 {
     m_list = SerializerHelper.Deserialize <List <T> >(fileName, SerializeFormat.XML);
 }
Example #19
0
        private DataTable CreateDataTable(RequestData data)
        {
            /*
             * 1, 获取列头前台绑定信息(字段)
             * 4, 判断数据类型
             * 5,获取数据源
             * 6,组装合并DataTable返回完整数据
             */
            DataTable      createTable = new DataTable();
            string         dataType    = data.Get("DataBusiness");
            List <dynamic> getCols     = SerializerHelper.Deserialize <List <dynamic> >(data.Get("Cols"));

            //List<dynamic> getRows = null;
            getCols.ForEach(m =>
                            { createTable.Columns.Add(m["field"]); });
            switch (dataType)
            {
            case "TotalEmission":
                GetTotalEmissionSource(data, createTable);
                break;

            case "DataTransfer":
                GetDataTransferSource(data, createTable);
                break;

            case "ExcessivePollut":
                GetExcessivePollutSource(data, createTable);
                break;

            case "ExceptionStain":
                GetExceptionStainSource(data, createTable);
                break;

            case "ExceptionPFL":
                GetExceptionPFLSource(data, createTable);
                break;

            case "MNDownLine":
                GetMNDownLineSource(data, createTable);
                break;

            case "ControlFacilities":
                GetControlFacilitiesSource(data, createTable);
                break;

            case "DataAcquisition":
                GetDataAcquisitionSource(data, createTable);
                break;

            case "Monitoring":
                GetMonitoringSource(data, createTable);
                break;

            case "Governance":
                GetGovernanceSource(data, createTable);
                break;

            default:
                GetExceptionPFLSource(data, createTable);
                break;
            }



            return(createTable);
        }