コード例 #1
0
        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            bool done = false;
            StringBuilder stringBuilder = new StringBuilder();

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    try
                    {
                        MachineBusiness business = new MachineBusiness();
                        Machine module = business.QueryByGuid(guid);

                        if (module != null)
                        {
                            string currentIp = module.Ip;
                            this.InitializeUpdateModule(module);

                            module.Ip = this.TextBoxIP.Text;
                            module.Netmask = this.TextBoxNetmask.Text;
                            module.Gateway = this.TextBoxGateway.Text;

                            done = business.Update(module);

                            if (done)
                            {
                                stringBuilder.Append("修改检测仪成功!");

                                string message = string.Empty;

                                MachineSetup setup = new MachineSetup();
                                message = setup.Ip(module, currentIp);
                                stringBuilder.Append(message);
                            }
                            else
                            {
                                stringBuilder.Append("修改检测仪失败!");
                            }
                        }
                        else
                        {
                            stringBuilder.Append("检测仪不存在!");
                        }
                    }
                    catch (Exception exception)
                    {
                        stringBuilder.Append("修改检测仪错误!");
                        Variable.Logger.Log(exception);
                    }
                }
            }

            this.LabelMessage.Text = stringBuilder.ToString();

            this.InitializeBind();
        }
コード例 #2
0
        protected void ButtonAlarm_Click(object sender, EventArgs e)
        {
            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    if ((value != null) && (!string.IsNullOrEmpty(value.Guid)))
                    {
                        DetectorBusiness detectorBusiness = new DetectorBusiness();
                        List<Detector> detectors = detectorBusiness.QueryByMachine(value.Guid);

                        Random random = new Random();
                        if ((detectors != null) && (detectors.Count > 0))
                        {
                            for (int i = 0; i < detectors.Count; i++)
                            {
                                Detector current = detectors[i];
                                switch (current.DetectorType.Type)
                                {
                                    case DetectorTypes.Switch:
                                        current.Value = (ushort)random.Next(0, 2);
                                        break;
                                    case DetectorTypes.DoubleArea:
                                        byte valueA = (byte)random.Next(0, byte.MaxValue);
                                        byte valueB = (byte)random.Next(0, byte.MaxValue);
                                        current.Value = (ushort)((valueA * 0x100) + valueB);
                                        break;
                                }
                            }

                            string ipValue = value.Ip;
                            IPAddress ip = IPAddress.Parse(ipValue);
                            IPEndPoint remoteEP = new IPEndPoint(ip, Variable.Port);
                            List<AbstractInstruction> instructions = new List<AbstractInstruction>();

                            AlarmInstruction instruction = new AlarmInstruction(detectors);
                            instructions.Add(instruction);

                            Terminal.ExecuteInstruction(remoteEP, instructions);
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void InitializeBindInput()
        {
            this.TextBoxIP.Text = string.Empty;
            this.TextBoxNetmask.Text = string.Empty;
            this.TextBoxGateway.Text = string.Empty;

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    this.TextBoxIP.Text = value.Ip;
                    this.TextBoxNetmask.Text = value.Netmask;
                    this.TextBoxGateway.Text = value.Gateway;
                }
            }
        }
コード例 #4
0
        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            bool done = false;
            StringBuilder stringBuilder = new StringBuilder();

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    try
                    {
                        MachineBusiness business = new MachineBusiness();
                        Machine module = business.QueryByGuid(guid);

                        if (module != null)
                        {
                            this.InitializeUpdateModule(module);

                            int intervalValue = int.Parse(this.TextBoxInterval.Text);

                            module.RoomId = this.DropDownListRooms.SelectedValue;
                            module.Name = this.TextBoxName.Text;
                            module.Ip = this.TextBoxIP.Text;
                            module.Interval = intervalValue;
                            module.Mobile = this.TextBoxMobile.Text;

                            Machine machine = business.QueryByNameOrIp(module.Name, module.RoomId, module.Ip);

                            if ((machine == null) || (string.Equals(machine.Guid, module.Guid, StringComparison.CurrentCulture)))
                            {
                                done = business.Update(module);

                                if (done)
                                {
                                    stringBuilder.Append("修改检测仪成功!");

                                    machine = business.QueryByNameOrIp(module.Name, module.RoomId, module.Ip);
                                    if (machine != null)
                                    {
                                        string imageFile = this.MapPath(machine.FloorPlanHref);
                                        this.UploadFileSave(this.FileUploadFloorPlan, imageFile);

                                        string message = string.Empty;

                                        MachineSetup setup = new MachineSetup();
                                        // 设置检测仪上传数据时间间隔
                                        message = setup.Interval(machine);
                                        stringBuilder.Append(message);
                                        // 设置检测仪时间
                                        if (this.RadioButtonListTime.SelectedValue != null)
                                        {
                                            bool sync = false;
                                            try
                                            {
                                                sync = bool.Parse(this.RadioButtonListTime.SelectedValue);
                                            }
                                            finally
                                            {
                                            }
                                            if (sync)
                                            {
                                                message = setup.Time(machine);
                                                stringBuilder.Append(message);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    stringBuilder.Append("修改检测仪失败!");
                                }
                            }
                            else
                            {
                                stringBuilder.Append("检测仪已经存在(名称或IP地址相同)!");
                            }
                        }
                        else
                        {
                            stringBuilder.Append("检测仪不存在!");
                        }
                    }
                    catch (Exception exception)
                    {
                        stringBuilder.Append("修改检测仪错误!");
                        Variable.Logger.Log(exception);
                    }
                }
            }

            this.LabelMessage.Text = stringBuilder.ToString();

            this.InitializeBind();
        }
コード例 #5
0
        private void InitializeBindInput()
        {
            this.RefreshUser();

            User sessionUser = this.Session[Constant.SESSION_KEY_USER] as User;

            this.DropDownListRooms.DataSource = sessionUser.Rooms;
            this.DropDownListRooms.DataTextField = "Name";
            this.DropDownListRooms.DataValueField = "Guid";
            this.DropDownListRooms.DataBind();

            const string KeyText = "Key";
            const string ValueText = "Value";
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add(KeyText);
            dataTable.Columns.Add(ValueText);
            dataTable.Rows.Add(new object[] { "是", true });
            dataTable.Rows.Add(new object[] { "否", false });

            this.RadioButtonListTime.DataSource = dataTable;
            this.RadioButtonListTime.DataTextField = KeyText;
            this.RadioButtonListTime.DataValueField = ValueText;
            this.RadioButtonListTime.DataBind();

            this.TextBoxName.Text = string.Empty;
            this.TextBoxIP.Text = string.Empty;
            this.TextBoxInterval.Text = string.Empty;
            this.TextBoxMobile.Text = string.Empty;
            this.RadioButtonListTime.SelectedIndex = 0;
            this.ImageFloorPlan.ImageUrl = string.Empty;

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    this.DropDownListRooms.SelectedValue = value.RoomId;
                    this.TextBoxName.Text = value.Name;
                    this.TextBoxIP.Text = value.Ip;
                    this.TextBoxInterval.Text = value.Interval.ToString();
                    this.TextBoxMobile.Text = value.Mobile;
                    this.ImageFloorPlan.ImageUrl = value.FloorPlanHref;
                }
            }
        }
コード例 #6
0
        private void InitializeBindInput()
        {
            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    if (value != null)
                    {
                        this.RoomId = value.RoomId;
                        this.MachineId = value.Guid;
                        this.ImageFloorPlan.ImageUrl = value.FloorPlanHref;
                        this.ImageFloorPlan.Visible = true;
                    }
                }
            }
        }
コード例 #7
0
        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            StringBuilder stringBuilder = new StringBuilder();

            DateTime now = DateTime.Now;
            DateTime beginDate = new DateTime(now.Year, now.Month, 1);
            DateTime endDate = beginDate.AddMonths(1).AddSeconds(-1);

            try
            {
                if (!string.IsNullOrEmpty(this.TextBoxBeginDate.Text))
                {
                    beginDate = DateTime.Parse(this.TextBoxBeginDate.Text);
                }
                if (!string.IsNullOrEmpty(this.TextBoxEndDate.Text))
                {
                    endDate = DateTime.Parse(this.TextBoxEndDate.Text);
                    endDate = endDate.AddDays(1).AddSeconds(-1);
                }
            }
            finally
            {
            }

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness machineBusiness = new MachineBusiness();
                    this.Machine = machineBusiness.QueryByGuid(guid);

                    if (this.Machine != null)
                    {
                        if (!string.IsNullOrEmpty(this.Machine.RoomId))
                        {
                            RoomBusiness roomBusiness = new RoomBusiness();
                            this.Room = roomBusiness.QueryByGuid(this.Machine.RoomId);
                        }

                        if (!string.IsNullOrEmpty(this.Machine.Guid))
                        {
                            DetectorBusiness detectorBusiness = new DetectorBusiness();
                            this.Detectors = detectorBusiness.QueryByMachine(this.Machine.Guid);

                            this.NormalDataCaches = detectorBusiness.QueryNormalDataCacheByMachine(this.Machine.Guid, beginDate, endDate);
                            this.AlarmDataCaches = detectorBusiness.QueryAlarmDataCacheByMachine(this.Machine.Guid, beginDate, endDate);

                            MessageCacheBusiness messageCacheBusiness = new MessageCacheBusiness();
                            this.MessageCaches = messageCacheBusiness.QueryByMachine(this.Machine.Guid, beginDate, endDate);
                        }
                    }
                }
                else
                {
                    stringBuilder.Append("没有选择检测仪!");
                }
            }

            this.LabelMessage.Text = stringBuilder.ToString();
        }
コード例 #8
0
        protected void ButtonOK_Click(object sender, EventArgs e)
        {
            bool done = false;
            StringBuilder stringBuilder = new StringBuilder();

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    try
                    {
                        MachineBusiness business = new MachineBusiness();
                        Machine module = business.QueryByGuid(guid);

                        if (module != null)
                        {
                            this.InitializeUpdateModule(module);

                            module.Alarm = bool.Parse(this.RadioButtonListMobileAlarm.SelectedValue);
                            module.MobileA = this.TextBoxMobileA.Text;
                            module.MobileB = this.TextBoxMobileB.Text;
                            module.MobileC = this.TextBoxMobileC.Text;

                            done = business.Update(module);

                            if (done)
                            {
                                stringBuilder.Append("修改检测仪成功!");

                                string message = string.Empty;

                                MachineSetup setup = new MachineSetup();
                                message = setup.Threshold(module);
                                stringBuilder.Append(message);
                                message = setup.MobileAlarm(module);
                                stringBuilder.Append(message);
                                message = setup.Mobile(module);
                                stringBuilder.Append(message);
                            }
                            else
                            {
                                stringBuilder.Append("修改检测仪失败!");
                            }
                        }
                        else
                        {
                            stringBuilder.Append("检测仪不存在!");
                        }
                    }
                    catch (Exception exception)
                    {
                        stringBuilder.Append("修改检测仪错误!");
                        Variable.Logger.Log(exception);
                    }
                }
            }

            this.LabelMessage.Text = stringBuilder.ToString();

            this.InitializeBind();
        }
コード例 #9
0
        private void InitializeBindInput()
        {
            this.GridViewDetectors.DataSource = null;
            this.GridViewDetectors.DataBind();
            this.RadioButtonListMobileAlarm.SelectedValue = false.ToString();
            this.TextBoxMobileA.Text = string.Empty;
            this.TextBoxMobileB.Text = string.Empty;
            this.TextBoxMobileC.Text = string.Empty;

            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    if ((value != null) && (!string.IsNullOrEmpty(value.Guid)))
                    {
                        DetectorBusiness detectorBusiness = new DetectorBusiness();
                        List<Detector> detectors = detectorBusiness.QueryByMachine(value.Guid);

                        DataTable dataTable = new DataTable();
                        dataTable.Columns.Add("C1");
                        dataTable.Columns.Add("C2");
                        dataTable.Columns.Add("C3");
                        dataTable.Columns.Add("C4");
                        dataTable.Columns.Add("C5");
                        dataTable.Columns.Add("C6");
                        for (int i = 0; i < detectors.Count; i++)
                        {
                            object[] datas = new object[dataTable.Columns.Count];
                            datas[0] = detectors[i].Serial;
                            datas[1] = detectors[i].DetectorType.Name;
                            if (detectors[i].DetectorType.Type == Support.Resource.DetectorTypes.Switch)
                            {
                                datas[2] = detectors[i].DetectorType.DescriptionA;
                                datas[3] = detectors[i].DetectorType.DescriptionB;
                                datas[4] = string.Empty;
                                datas[5] = string.Empty;
                            }
                            else
                            {
                                datas[2] = string.Format("{0}阀值下限{1}{2}", detectors[i].DetectorType.DescriptionA, detectors[i].MinimumA, detectors[i].DetectorType.UnitA);
                                datas[3] = string.Format("{0}阀值上限{1}{2}", detectors[i].DetectorType.DescriptionA, detectors[i].MaximumA, detectors[i].DetectorType.UnitA);
                                datas[4] = string.Format("{0}阀值下限{1}{2}", detectors[i].DetectorType.DescriptionB, detectors[i].MinimumB, detectors[i].DetectorType.UnitB);
                                datas[5] = string.Format("{0}阀值上限{1}{2}", detectors[i].DetectorType.DescriptionB, detectors[i].MaximumB, detectors[i].DetectorType.UnitB);
                            }
                            dataTable.Rows.Add(datas);
                        }

                        this.GridViewDetectors.DataSource = dataTable;
                        this.GridViewDetectors.DataBind();

                        this.RadioButtonListMobileAlarm.SelectedValue = value.Alarm.ToString();
                        this.TextBoxMobileA.Text = value.MobileA;
                        this.TextBoxMobileB.Text = value.MobileB;
                        this.TextBoxMobileC.Text = value.MobileC;
                    }
                }
            }
        }
コード例 #10
0
        protected void ButtonMessage_Click(object sender, EventArgs e)
        {
            if (this.DropDownListMachines.SelectedValue != null)
            {
                string guid = this.DropDownListMachines.SelectedValue;
                if (!string.IsNullOrEmpty(guid))
                {
                    MachineBusiness business = new MachineBusiness();
                    Machine value = business.QueryByGuid(guid);

                    if ((value != null) && (!string.IsNullOrEmpty(value.Guid)))
                    {
                        DetectorBusiness detectorBusiness = new DetectorBusiness();
                        List<Detector> detectors = detectorBusiness.QueryByMachine(value.Guid);

                        Random random = new Random();
                        if ((detectors != null) && (detectors.Count > 0))
                        {
                            int address = random.Next(0, detectors.Count);
                            Detector detector = detectors[address];
                            bool result = false;
                            int resultRandom = random.Next(0, 2);
                            if (resultRandom == 0)
                            {
                                result = true;
                            }

                            string ipValue = value.Ip;
                            IPAddress ip = IPAddress.Parse(ipValue);
                            IPEndPoint remoteEP = new IPEndPoint(ip, Variable.Port);
                            List<AbstractInstruction> instructions = new List<AbstractInstruction>();

                            MessageInstruction instruction = new MessageInstruction(detector.DetectorType.Code, result, DateTime.Now);
                            instructions.Add(instruction);

                            Terminal.ExecuteInstruction(remoteEP, instructions);
                        }
                    }
                }
            }
        }