Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.UCChannelStationDTOne1.IsSelectOneStation = true;
            MasterPageHelper.SetTitle(this, "水位修改");

            this.UCChannelStationDTOne1.QueryEvent += new EventHandler(UCChannelStationDTOne1_QueryEvent);

            if (!IsPostBack)
            {
                if (GetQueryParams())
                {
                    this.Device = DeviceFactory.CreateDevice(_queryDeviceID);
                    StationClass station = this.Device.StationClass;

                    this.UCChannelStationDTOne1.SelectedChannel = station.Channel;
                    this.UCChannelStationDTOne1.SelectedStation = station;

                    DateTime begin = _queryDateTime.Date;
                    DateTime end   = begin.Add(TimeSpan.FromDays(1d));

                    QueryData(_queryDeviceID, begin, end);
                }
            }
            else
            {
                //this.Device = this.UCChannelStationDTOne1.SelectedStation.DeviceCollection[0];
            }
        }
Exemple #2
0
        public List <StationClass> ReadStations()
        {
            List <StationClass> eddbstations = new List <StationClass>();
            string json;

            json = ReadJson(stationFileName);

            if (json == null)
            {
                return(eddbstations);
            }

            JArray systems = (JArray)JArray.Parse(json);

            if (systems != null)
            {
                foreach (JObject jo in systems)
                {
                    StationClass sys = new StationClass(jo, EDDiscovery.SystemInfoSource.EDDB);

                    if (sys != null)
                    {
                        eddbstations.Add(sys);
                    }
                }
            }

            return(eddbstations);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        private void Query()
        {
            StationClass s1 = this.UCCompareCondition1.Station1;
            StationClass s2 = this.UCCompareCondition1.Station2;

            if (s1 == null || s2 == null)
            {
                throw new InvalidOperationException("station1 or station2 is null");
            }

            DataTable st1Tbl  = this.UCCompareCondition1.ReadStation1WLDataTable();
            DataTable st2Tbl  = this.UCCompareCondition1.ReadStation2WLDataTable();
            DataTable st1and2 = st1Tbl.Copy();

            st1and2.Merge(st2Tbl);

            this.UCZedChart1.DataSource = st1and2;


            //this.GridView1.DataSource = st1Tbl;
            //this.GridView1.DataBind();
            this.H1.DataSource = st1Tbl;
            this.H1.Bind();


            //this.GridView2.DataSource = st2Tbl;
            //this.GridView2.DataBind();
            this.H2.DataSource = st2Tbl;
            this.H2.Bind();

            this.UCZedChart1.DataSource = st1and2;
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        private TreeNode CreateStationTreeNode(StationClass s)
        {
            string   stationValue = "s" + s.StationID;
            TreeNode n            = new TreeNode(s.StationName);

            n.Value = stationValue;
            return(n);
        }
Exemple #5
0
        private DataTable GetData()
        {
            DateTime begin = UCCompareAmount1.Begin;
            DateTime end   = UCCompareAmount1.End;

            StationClass station = this.UCCompareAmount1.SelectedStationCollection[0];
            DataTable    tbl     = station.DeviceCollection[0].GetDitchData(begin, end);

            return(tbl);
        }
Exemple #6
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 private int[] GetStationIDs()
 {
     int[] list = new int[this.StationCollection.Count];
     //foreach (StationClass s in this.StationCollection)
     for (int i = 0; i < this.StationCollection.Count; i++)
     {
         StationClass item = this.StationCollection[i];
         list[i] = item.StationID;
     }
     return(list);
 }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        public void Bind(StationClass s)
        {
            this.txtStationName.Text = s.StationName;
            this.txtDeviceType.Text  = s.DeviceCollection[0].DeviceType;

            DeviceClass device = s.DeviceCollection[0];

            BindAlarm(device);
            //AddTestFormula(device);
            BindFormula(device);
            SaveDeviceID(device.DeviceID);
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        private void SaveStationColor()
        {
            StationCollection ss = SessionManager.ChannelSession.StationCollection;

            for (int i = 0; i < this.dlStation.Items.Count; i++)
            {
                DataListItem item     = this.dlStation.Items[i];
                TextBox      txtColor = item.Controls[3] as TextBox;
                StationClass station  = ss[i];
                station.Color = ConvertStringToColor(txtColor.Text);
            }
        }
Exemple #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int id = this.StationID;
         if (id > 0)
         {
             StationClass station = StationFactory.CreateStationByStationID(id);
             this.txtOldStationName.Text = station.StationName;
         }
     }
 }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="channelID"></param>
        private StationCollection GetStationList(int channelID)
        {
            StationCollection list       = new StationCollection();
            DataTable         stationTbl = ChannelDBI.GetStationDataTable(channelID);

            foreach (DataRow row in stationTbl.Rows)
            {
                StationClass sc = new StationClass();
                sc.StationID   = Convert.ToInt32(row["StationID"]);
                sc.StationName = row["Name"].ToString();
                //this.StationCollection.Add(sc);
                list.Add(sc);
            }
            return(list);
        }
        private void DataView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DataView.SelectedItem == null)
            {
                return;
            }

            StationClass itemInfo = DataView.SelectedItem as StationClass;

            if (itemInfo == null || !(itemInfo is StationClass))
            {
                MessageBox.Show("获取选中项出现问题");
                return;
            }

            Text_stationname_Copy.Text = itemInfo.stationname;
        }
Exemple #12
0
        /// <summary>
        /// 获取候选站点列表
        /// </summary>
        /// <returns></returns>
        public StationCollection GetCandidateStationList()
        {
            StationCollection list = new StationCollection();
            DataTable         tbl  = StationDBI.GetNotAssociateStationDataTable();

            foreach (DataRow row in tbl.Rows)
            {
                int          stationID = Convert.ToInt32(row["StationID"]);
                string       name      = row["Name"].ToString();
                StationClass n         = new StationClass();
                n.StationID   = stationID;
                n.StationName = name;
                list.Add(n);
            }
            list.Remove(this.StationCollection);
            list.Add(GetDeletedStationCollection());
            return(list);
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void UCConditionYear1_QueryEvent(object sender, EventArgs e)
        {
            if (IsValid)
            {
                int          year    = this.UCConditionYear1.Year;
                StationClass station = this.UCConditionYear1.Station;
                if (station.DeviceCollection.Count > 0)
                {
                    DeviceClass device = station.DeviceCollection[0];

                    DataTable tbl = DitchDataYearDBI.ExecuteYearDataTable(year, device, this.DataEnum);

                    H.DataSource = tbl;
                    H.Bind();
                    //this.GridView1.DataSource = tbl;
                    //this.GridView1.DataBind();
                }
            }
        }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        private void BindChannelOrStation(TreeNode selected)
        {
            if (IsChannelTreeNode(selected))
            {
                int          channelID = GetSelectedID(selected);
                ChannelClass c         = ChannelFactory.CreateChannel(channelID);
                this.UCChannel1.Bind(c);

                this.UCChannel1.Visible = true;
                this.UCStation1.Visible = false;
            }
            else
            {
                int          stationID = GetSelectedID(selected);
                StationClass s         = StationFactory.CreateStationByStationID(stationID);
                this.UCStation1.Bind(s);

                this.UCChannel1.Visible = false;
                this.UCStation1.Visible = true;
            }
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        private void QueryData()
        {
            StationCollection selectedStations = this.UCChannelStationDTOne1.SelectedStationCollection;

            if (selectedStations.Count > 0)
            {
                if (selectedStations.Count > 1)
                {
                    // TODO: selected count must == 1
                    //
                }
                else
                {
                    StationClass station  = selectedStations[0];
                    int          deviceID = station.DeviceCollection[0].DeviceID;
                    DateTime     dt       = this.UCChannelStationDTOne1.Begin;
                    DateTime     begin    = dt.Date;
                    DateTime     end      = begin.AddDays(1d);
                    QueryData(deviceID, begin, end);
                }
            }
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool DistributeQueryStringParam_Real()
        {
            string[] paramNames = new string[] { QueryStringNames.StationID };
            Type[]   paramTypes = new Type[] { typeof(int) };

            object [] result;
            bool      b = QueryStringParamPicker.Pick(this.Request.QueryString, paramNames, paramTypes,
                                                      out result);

            if (b)
            {
                int stationid = (int)result[0];
                this.UCConditionDTTwo1.WaterUser = SessionManager.LoginSession.WaterUser;

                StationClass      sc       = StationFactory.CreateStationByStationID(stationid);
                StationCollection stations = new StationCollection();
                stations.Add(sc);
                this.UCConditionDTTwo1.Stations = stations;
                this.UCConditionDTTwo1.Begin    = DateTime.Now.Date;
                this.UCConditionDTTwo1.End      = DateTime.Now.Date + TimeSpan.FromDays(1d);
                return(true);
            }
            return(false);
        }
        private void Button_modify_Click(object sender, RoutedEventArgs e)
        {
            if (DataView.SelectedItem == null)
            {
                return;
            }

            StationClass itemInfo = DataView.SelectedItem as StationClass;

            if (itemInfo == null || !(itemInfo is StationClass))
            {
                MessageBox.Show("获取选中项出现问题");
                return;
            }

            TcpClient     tcpClient     = null;
            NetworkStream networkStream = null;

            try
            {
                tcpClient = new TcpClient();
                tcpClient.Connect(ip_address, port); //建立与服务器的连接
                networkStream = tcpClient.GetStream();
                if (networkStream.CanWrite)
                {
                    var package = new TTS_Core.StationOperationPackage(user, ip_address + ":" + listen_port.ToString(), "server",
                                                                       TTS_Core.Enum_OP.K_MODIFY,
                                                                       itemInfo.stationid, Text_stationname_Copy.Text);

                    byte[] sendBytes = package.DataPackageToBytes(); //注册数据包转化为字节数组
                    networkStream.Write(sendBytes, 0, sendBytes.Length);

                    var newClient   = tcp_listener.AcceptTcpClient();
                    var bytes       = ReadFromTcpClient(newClient); //获取数据
                    var package_rec = new TTS_Core.DataSetPackage(bytes);

                    if (package_rec.forbid != 0 && package_rec.forbid != 1)
                    {
                        MessageBox.Show("出大问题");
                    }

                    if (package_rec.forbid == 1)
                    {
                        MessageBox.Show("修改失败,请检查完整性约束或者是服务器故障");
                    }
                    else
                    {
                        itemInfo.stationname = Text_stationname_Copy.Text;
                        DataView.Items.Insert(DataView.SelectedIndex, itemInfo);
                        DataView.Items.Remove(DataView.SelectedItem);
                        DataView.Items.Refresh();
                    }
                }
            }
            catch
            {
                MessageBox.Show("无法连接到服务器!");
                return;
            }
            finally
            {
                if (networkStream != null)
                {
                    networkStream.Close();
                }
                tcpClient.Close();
            }
        }