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(); }
public string Ip(Machine value, string currentIp) { string result = null; StringBuilder stringBuilder = new StringBuilder(); string ipValue = value.Ip; string netmaskValue = value.Netmask; string gatewayValue = value.Gateway; IPAddress ip = IPAddress.Parse(currentIp); IPEndPoint remoteEP = new IPEndPoint(ip, Variable.Port); List<AbstractInstruction> instructions = new List<AbstractInstruction>(); IpInstruction instruction = new IpInstruction(ipValue, netmaskValue, gatewayValue); instructions.Add(instruction); ProcessResult processResult = Terminal.ExecuteInstruction(remoteEP, instructions); if (processResult != null) { stringBuilder.Append(processResult.Message); if (!processResult.Done) { MachineBusiness business = new MachineBusiness(); value.Ip = currentIp; bool done = business.Update(value); if (done) { stringBuilder.Append("恢复检测仪IP地址成功!"); } else { stringBuilder.Append(string.Format("恢复检测仪IP地址失败,请重新设置检测仪IP地址为{0}!", currentIp)); } } } result = stringBuilder.ToString(); return result; }
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(); }
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(); }