Beispiel #1
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 private void InitDataSource()
 {
     try
     {
         m_listSubCenter          = CDBDataMgr.Instance.GetAllSubCenter();
         m_listStation            = CDBDataMgr.GetInstance().GetAllStation();
         m_listSoilStation        = CDBSoilDataMgr.GetInstance().GetAllSoilStation();
         m_listStationCombination = new List <CEntityStation>(m_listStation.ToArray()); //可以的啦
     }
     catch (Exception ex) { }
 }
Beispiel #2
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitDataSource()
        {
            try
            {
                m_listSubCenter          = CDBDataMgr.Instance.GetAllSubCenter();
                m_listStation            = CDBDataMgr.GetInstance().GetAllStation();
                m_listSoilStation        = CDBSoilDataMgr.GetInstance().GetAllSoilStation();
                m_listStationCombination = new List <CEntityStation>(m_listStation.ToArray()); //可以的啦
            }
#pragma warning disable CS0168                                                                 // 声明了变量“ex”,但从未使用过
            catch (Exception ex) { }
#pragma warning restore CS0168                                                                 // 声明了变量“ex”,但从未使用过
        }
Beispiel #3
0
        /// <summary>
        /// 初始化分中心、站点信息
        /// </summary>
        //private void InitStation()
        //{
        //    var m_listStation = CDBDataMgr.GetInstance().GetAllStation();
        //    var m_listSubCenter = CDBDataMgr.GetInstance().GetAllSubCenter();

        //    var dics = new Dictionary<CEntitySubCenter, IList<CEntityStation>>();

        //    var listSubcenters = new List<int>();
        //    foreach (var center in m_listSubCenter)
        //    {
        //        int subcenterId = center.SubCenterID;

        //        var listStations = new List<CEntityStation>();
        //        foreach (var station in m_listStation)
        //        {
        //            if (station.SubCenterID.HasValue && station.SubCenterID == subcenterId)
        //            {
        //                listStations.Add(station);
        //            }
        //        }

        //        if (!listSubcenters.Contains(subcenterId))
        //        {
        //            dics.Add(center, listStations);
        //        }
        //    }
        //    InitStation(dics);
        //}
        private void InitStation()
        {
            var m_listStation     = CDBDataMgr.GetInstance().GetAllStation();
            var m_listSubCenter   = CDBDataMgr.GetInstance().GetAllSubCenter();
            var m_listSoilStation = CDBSoilDataMgr.GetInstance().GetAllSoilStation();

            //   var dics = new Dictionary<CEntitySubCenter, IList<CEntityStation>>();
            var dics     = new Dictionary <CEntitySubCenter, IList <Object> >();
            var dicsSoil = new Dictionary <CEntitySubCenter, IList <CEntitySoilStation> >();

            var listSubcenters = new List <int>();

            foreach (var center in m_listSubCenter)
            {
                int subcenterId = center.SubCenterID;

                var listStations     = new List <Object>();
                var listSoilStations = new List <Object>();
                foreach (var station in m_listStation)
                {
                    if (station.SubCenterID.HasValue && station.SubCenterID == subcenterId)
                    {
                        listStations.Add(station);
                    }
                }

                foreach (var soilstation in m_listSoilStation)
                {
                    if (soilstation.SubCenterID.HasValue && soilstation.SubCenterID == subcenterId)
                    {
                        listStations.Add(soilstation);
                    }
                }

                if (!listSubcenters.Contains(subcenterId))
                {
                    dics.Add(center, listStations);
                    //  dics.Add(center, listSoilStations);
                    //  dicsSoil.Add(center, listSoilStations);
                }
            }
            if (!this.IsHandleCreated)
            {
                InitStation(dics);
            }
            else
            {
                instance.Invoke(new Action(() => { InitStation(dics); }));
            }
        }
Beispiel #4
0
        private void tsButImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            try
            {
                dlg.Title  = "选择水位流量文件";
                dlg.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
                DialogResult result = dlg.ShowDialog();
                if (DialogResult.OK == result)
                {
                    // 打开文件,并进行处理
                    //CMessageBox msgBox = new CMessageBox() { MessageInfo = "正在处理数据" };
                    //msgBox.ShowDialog(this);
                    StreamReader reader = new StreamReader(dlg.FileName, Encoding.Default);
                    string       linebuffer;
                    int          linenumber   = 0;
                    string       strErrorInfo = "";
                    // List<string> gprs = m_proxySoilStation.getAllGprs();
                    List <string> gprs     = m_proxyStation.getAllGprs();
                    List <string> soilgprs = m_proxySoilStation.getAllGprs();
                    for (int i = 0; i < soilgprs.Count; i++)
                    {
                        gprs.Add(soilgprs[i]);
                    }
                    while ((linebuffer = reader.ReadLine()) != null && linebuffer.Length > 18)
                    {
                        // 处理一行数据
                        linenumber += 1;
                        if (!DealWithLineData(linebuffer, linenumber, ref strErrorInfo, ref gprs))
                        {
                            // 数据非法
                            //msgBox.CloseDialog();
                            MessageBox.Show(strErrorInfo); // 显示错误信息
                            return;
                        }
                    }
                    reader.Close();
                    //msgBox.CloseDialog();

                    if (m_listImport.Count > 0)
                    {
                        m_proxySoilStation.AddSoilStationRange(m_listImport);
                        for (int i = 0; i < m_listImport.Count; i++)
                        {
                            CDBSoilDataMgr.GetInstance().m_mapStaionSoilInfo.Add(m_listImport[i].StationID, m_listImport[i]);
                        }
                        m_listImport.Clear();
                    }

                    MessageBox.Show("数据导入成功");

                    m_dgvSoilStatioin.ClearAllRows();
                    CDBSoilDataMgr.Instance.UpdateAllSoilStation();
                    // 加载数据
                    m_dgvSoilStatioin.Revert();
                }//end of ok
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                this.Focus(); //防止窗体最小化
            }
        }