protected void btnSave2_Click(object sender, EventArgs e) { OrganizationBLL objBll = new OrganizationBLL(); if (txtTime.Text != "") { if (txtTime.Text.IndexOf(":") == -1) { SessionSet.PageMessage = "同步时间格式错误!"; return; } else { if (txtTime.Text.Length > 5 || txtTime.Text.Length < 4) { SessionSet.PageMessage = "同步时间格式错误!"; return; } else { string[] str = txtTime.Text.Split(':'); if (str.Length > 2) { SessionSet.PageMessage = "同步时间格式错误!"; return; } else { try { int h = Convert.ToInt32(str[0]); int m = Convert.ToInt32(str[1]); if (h > 23 || h < 0) { SessionSet.PageMessage = "同步时间格式错误!"; return; } if (m > 59 || m < 0) { SessionSet.PageMessage = "同步时间格式错误!"; return; } } catch { SessionSet.PageMessage = "同步时间格式错误!"; return; } } } } } objBll.UpdateOrgSynchronizeTime(Convert.ToInt32(OrgList.SelectedValue), txtTime.Text); string strPath = "C:\\oracle\\product\\10.2.0\\db_1\\NETWORK\\ADMIN\\tnsnames.ora"; if (txtIPAddress.Text.Trim() != "") { if (!Regex.IsMatch(txtIPAddress.Text, "^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$")) { SessionSet.PageMessage = "IP地址格式不正确!"; return; } if (File.Exists(strPath)) { string strName = Pub.GetChineseSpell(OrgList.SelectedItem.Text); StreamReader objReader = new StreamReader(strPath, true); string strContent = objReader.ReadToEnd(); objReader.Close(); string strOldIP = objBll.GetOrgIPAddress(Convert.ToInt32(OrgList.SelectedValue)); if (strContent.IndexOf(strOldIP) == -1 || strOldIP == "") { //新增 StreamWriter objWriter = new StreamWriter(strPath, true); objWriter.WriteLine(strName + OrgList.SelectedValue + " ="); objWriter.WriteLine(" (DESCRIPTION ="); objWriter.WriteLine(" (ADDRESS_LIST ="); objWriter.WriteLine(" (ADDRESS = (PROTOCOL = TCP)(HOST = " + txtIPAddress.Text + ")(PORT = 1521))"); objWriter.WriteLine(" )"); objWriter.WriteLine(" (CONNECT_DATA ="); objWriter.WriteLine(" (SERVICE_NAME = RailExam)"); objWriter.WriteLine(" )"); objWriter.WriteLine(" )"); objWriter.WriteLine(""); objWriter.Close(); } else { //修改 strContent = strContent.Replace(strOldIP, txtIPAddress.Text); StreamWriter objWriter = new StreamWriter(strPath, false); objWriter.Write(strContent); objWriter.Close(); } objBll.UpdateOrgService(Convert.ToInt32(OrgList.SelectedValue), strName + OrgList.SelectedValue, txtIPAddress.Text, chkUpload.Checked); } } else { if (File.Exists(strPath)) { string strOldIP = objBll.GetOrgIPAddress(Convert.ToInt32(OrgList.SelectedValue)); string strNetName = objBll.GetOrgNetName(Convert.ToInt32(OrgList.SelectedValue)); if (strOldIP != "") { //删除 StreamReader objReader = new StreamReader(strPath, true); string strContent = objReader.ReadToEnd(); objReader.Close(); string str = strNetName + "=" + "\r\n" + " (DESCRIPTION =" + "\r\n" + " (ADDRESS_LIST =" + "\r\n" + " (ADDRESS = (PROTOCOL = TCP)(HOST = " + strOldIP + ")(PORT = 1521))" + "\r\n" + " )" + "\r\n" + " (CONNECT_DATA =" + "\r\n" + " (SERVICE_NAME = RailExam)" + "\r\n" + " )" + "\r\n" + " )" + "\r\n"; strContent = strContent.Replace(str, ""); StreamWriter objWriter = new StreamWriter(strPath, false); objWriter.Write(strContent); objWriter.Close(); } objBll.UpdateOrgService(Convert.ToInt32(OrgList.SelectedValue), "", txtIPAddress.Text, chkUpload.Checked); } } SetControlEnable(2, true); }