Example #1
0
        private void InitTestData()
        {
            WeightRealDataList = new List <WeightRealData>();
            DateTime nowTime = DateTime.Now;

            for (int i = 0; i < 5; i++)
            {
                WeightRealData data = new WeightRealData()
                {
                    clientid = "102", matchid = "gbd000" + i, begintime = nowTime.AddMinutes(-5 - i).ToString("HH:mm:ss"), endtime = nowTime.AddMinutes(-1 - i).ToString("HH:mm:ss")
                };
                List <WeightRecordData> records = new List <WeightRecordData>();
                for (int j = 0; j < 100; j++)
                {
                    WeightRecordData recordD = new WeightRecordData();
                    recordD.recordtime = DateTime.Parse(data.begintime).AddSeconds(j / 10).ToString("HH:mm:ss");
                    recordD.recorddata = 100 * (j / 10);
                    //if (j < 30)
                    //{
                    //    recordD.recorddata = j;
                    //}
                    //else if (j >= 30 && j <= 50)
                    //{
                    //    recordD.recorddata = 50M;
                    //}
                    //else
                    //{
                    //    recordD.recorddata = 50 - (j - 50M);
                    //}
                    records.Add(recordD);
                }
                data.realdata = InfoExchange.ConvertToJson(records);
                WeightRealDataList.Add(data);
            }
        }
Example #2
0
 public static T ObjectClone <T>(T src_obj)
 {
     return
         (InfoExchange.DeConvert <T>(
              InfoExchange.ConvertToJson(src_obj, InfoExchange.SetingsKonwnTypesBinder),
              InfoExchange.SetingsKonwnTypesBinder
              ));
 }
 internal void Inital()
 {
     if (this.DataSource != null)
     {
         foreach (DataItem item in this.DataSource)
         {
             item.Json = InfoExchange.ConvertToJson(item.Data);
             if (item.Data != null && this.PYPropertyName != null && this.PYPropertyName != "")
             {
                 var prp = item.Data.GetType().GetProperty(this.PYPropertyName);
                 if (prp != null)
                 {
                     var value = prp.GetValue(item.Data, null);
                     if (value != null)
                     {
                         item.PY = value.ToString().GetPYString();
                     }
                 }
             }
         }
     }
 }
        public void Execute(object parameter)
        {
            GloablePara = null;
            var ctl = ServiceLocator.Current.GetInstance <Control>(this.Uri);

            var regionManager = ServiceLocator.Current.GetInstance <IRegionManager>();
            var container     = ServiceLocator.Current.GetInstance <IUnityContainer>();

            if (!regionManager.Regions.ContainsRegionWithName(this.RegionName))
            {
                MessageBox.Show(string.Format("未找到区域【{0}】!", this.RegionName));
            }
            var    views = regionManager.Regions[this.RegionName].Views;
            object view  = null;

            foreach (var v in views)
            {
                Type t = v.GetType();
                if (t.FullName == this.Uri)
                {
                    view = v;
                    break;
                }
            }

            if (view == null)
            {
                try
                {
                    regionManager.RegisterViewWithRegion(this.RegionName, () => ctl);
                }
                catch (ViewRegistrationException)
                {
                }
            }

            UriQuery query  = new UriQuery();
            var      adress = new Uri(this.Uri, UriKind.RelativeOrAbsolute);

            if (this.Para != null)
            {
                if (!this.IsGloablePara)
                {
                    query.Add("para", InfoExchange.ConvertToJson(this.Para, InfoExchange.SetingsKonwnTypesBinder));
                    adress = new Uri(this.Uri + query.ToString(), UriKind.Relative);
                }
                else
                {
                    GloablePara = Para;
                }
                if (this.IsSetParaDataContext)
                {
                    ctl.DataContext = Para;
                }
            }

            if (!string.IsNullOrEmpty(this.MenuName))
            {
                query.Add("MenuName", InfoExchange.ConvertToJson(this.MenuName, InfoExchange.SetingsKonwnTypesBinder));
            }

            regionManager.RequestNavigate(this.RegionName, new Uri(this.Uri + query.ToString(), UriKind.Relative));
        }