static void Main(string[] args) { ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); DeIdService service = new DeIdService(); security security = new security(); security.user = "******"; security.password = "******"; service.securityValue = security; deid input = new deid(); input.phi = "hi there"; deidResponse output = new deidResponse(); try { output = service.deid(null, input); Console.WriteLine(output.@return); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Console.WriteLine(e.InnerException); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["yonghuming"] == null) { Response.Redirect("default.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT COUNT(*) FROM project"; SqlDataReader dr = cmd.ExecuteReader(); int i; if (dr.Read()) { i = Convert.ToInt32(dr[0].ToString().Trim()); } else { i = 0; } i++; this.prono.Text = "ISN" + i.ToString("0000"); dr.Close(); } catch { conn.Close(); conn.Dispose(); } finally { conn.Close(); conn.Dispose(); } }
public void ProcessRequest(HttpContext context) { try { string tbxUserName = context.Request.Form["tbxUserName"]; string tbxPwd = context.Request.Form["tbxPwd"]; string returnValue = string.Empty; security sec = new security(); Email myEmail = new Email(); //底下為登入後之判斷 AccountInfo accInfo = new sAccount().ExecLogonOutCompany(tbxUserName, encode.sha1en(tbxPwd.ToString())); //如果accinfo不等於空值 if (accInfo != null) { //將該物件accinfo傳給Session["AccountInfo"]保存 context.Session["pwerRowData"] = accInfo; DateTime lastlogdate = DateTime.Parse(accInfo.LastLogDate); DateTime nowdate = DateTime.Now; TimeSpan Total = nowdate.Subtract(lastlogdate); int daysub = Total.Days; login_DB mylog = new login_DB(); if (daysub > 90) { returnValue = "此帳號已超過90天未登入,系統將會重新寄送密碼變更連結,請至您的信箱收取信件並由信內之連結登入"; //寄送密碼變更連結 StringBuilder sb = new StringBuilder(); sb.Append(@"親愛的" + accInfo.Title + " 您好:<br /><br />"); sb.Append(@"由於您已超過90天未登入,系統需要您重新變更密碼再嘗試重新登入<br /><br />"); sb.Append(@"請點擊下方連結回系統變更密碼<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "valid.aspx?vid=" + accInfo.QueryStr + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + accInfo.QueryStr + "</a><br /><br />"); sb.Append(@"謝謝您!"); myEmail.sendEmail(accInfo.Account, "[ITRI]工研院大檔案傳輸密碼通知", sb.ToString(), ""); } else { returnValue = "success"; //更新最後登入日期 mylog.UPDATElastlogdate(accInfo.IDmem); } } else { returnValue = "登入失敗 請檢查您輸入之E-mail與密碼是否正確"; } context.Response.Write(returnValue); } catch (Exception ex) { throw new Exception(MessageUtil.loginlogError + ex.HelpLink); } }
public void ProcessRequest(HttpContext context) { try { string tbxUserName = context.Request.Form["tbxUserName"]; string tbxPwd = context.Request.Form["tbxPwd"]; string returnValue = string.Empty; security sec = new security(); Email myEmail = new Email(); //底下為登入後之判斷 AccountInfo accInfo = new sAccount().ExecLogonOutCompany(tbxUserName, encode.sha1en(tbxPwd.ToString())); //如果accinfo不等於空值 if (accInfo != null) { //將該物件accinfo傳給Session["AccountInfo"]保存 context.Session["pwerRowData"] = accInfo; DateTime lastlogdate = DateTime.Parse(accInfo.LastLogDate); DateTime nowdate = DateTime.Now; TimeSpan Total = nowdate.Subtract(lastlogdate); int daysub = Total.Days; login_DB mylog = new login_DB(); if (daysub > 90) { returnValue = "This account has not logged more than 90 days, the system will re-send password change link to your mailbox"; //寄送密碼變更連結 StringBuilder sb = new StringBuilder(); sb.Append(@"Dear " + accInfo.Title + " :<br /><br />"); sb.Append(@"Since you have more than 90 days are not logged in,<br /> the system requires you to change your password and then try to re-login again <br /><br />"); sb.Append(@"Please click on the link below to change the password back to the system<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "?vid=" + accInfo.QueryStr + "'>" + AppConfig.MailUrl + "?vid=" + accInfo.QueryStr + "</a><br /><br />"); sb.Append(@"Thank you!"); myEmail.sendEmail(accInfo.Account, "[ITRI]Notification from ITRI WebFTP - Change password", sb.ToString(), ""); } else { returnValue = "success"; //更新最後登入日期 mylog.UPDATElastlogdate(accInfo.IDmem); } } else { returnValue = "login Fail, Please check that you enter the E-mail and password are correct"; } context.Response.Write(returnValue); } catch (Exception ex) { throw new Exception(MessageUtil.loginlogError + ex.HelpLink); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["yonghuming"] == null) { Response.Redirect("default.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("alert.aspx"); } string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); if (!IsPostBack) { try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT projectno,projectname FROM history WHERE username = '******'"; SqlDataReader dr = cmd.ExecuteReader(); this.prono.DataSource = dr; this.prono.DataTextField = "projectname"; this.prono.DataValueField = "projectno"; this.prono.DataBind(); } catch { conn.Close(); conn.Dispose(); this.prono.Text = "获取项目信息出错,请重新登录!"; } finally { conn.Close(); conn.Dispose(); } } }
protected void danger(string canshu) { security sc = new security(); if (sc.CheckBadStr(canshu) == 1) { Response.Redirect("alert.aspx"); } if (sc.CheckBadStr(canshu) == 2) { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"内容填写不完全,请重新填写!\")</script>"); } }
protected void Page_Load(object sender, EventArgs e) { security sc = new security(); int xx = sc.flag("临时变量", Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("alert.aspx"); } if (!IsPostBack) { this.male.Checked = true; } }
public void ProcessRequest(HttpContext context) { string tbxforgetAccount = context.Request.Form["tbxforgetAccount"].ToString().Trim(); security sec = new security(); Email myEmail = new Email(); ForGetPassW_DB myForGet = new ForGetPassW_DB(); if (tbxforgetAccount.ToString().Trim() == "") { context.Response.Write("Please enter E-mail"); return; } else { //找出此EMAIL是否已註冊過 DataTable dt = myForGet.SelectEmailExist(tbxforgetAccount.ToUpper()); if (dt.Rows.Count == 1) { //註冊過 寄信給此EMAIL更改連結 並變換QueryStr /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */ Random rdm = new Random(); string[] seeds = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }; int strLen = (int)rdm.Next(5, 11); string randStr = string.Empty; for (int i = 0; i < strLen; i++) { randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper(); } StringBuilder sb = new StringBuilder(); sb.Append(@"Hello: <br /><br />"); sb.Append(@"This Certification letter is from ITRI Secured File Transfer System, <br /><br />"); sb.Append(@"Please click on the following URL to change your password.<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "enVersion/vaildEn.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "enVersion/vaildEn.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />"); myEmail.sendEmail(tbxforgetAccount, "[ITRI]Notification from ITRI WebFTP - Password Assistance", sb.ToString(), ""); myForGet.UpdateMemberQueryStr(sec.encryptquerystring(randStr), dt.Rows[0]["mem_id"].ToString().Trim()); context.Response.Write("success"); } else { context.Response.Write("This E-mail has not been registered"); return; } } }
public void ProcessRequest(HttpContext context) { string tbxforgetAccount = context.Request.Form["tbxforgetAccount"].ToString().Trim(); security sec = new security(); Email myEmail = new Email(); ForGetPassW_DB myForGet = new ForGetPassW_DB(); if (tbxforgetAccount.ToString().Trim() == "") { context.Response.Write("請輸入E-mail"); return; } else { //找出此EMAIL是否已註冊過 DataTable dt = myForGet.SelectEmailExist(tbxforgetAccount.ToUpper()); if (dt.Rows.Count == 1) { //註冊過 寄信給此EMAIL更改連結 並變換QueryStr /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */ Random rdm = new Random(); string[] seeds = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }; int strLen = (int)rdm.Next(5, 11); string randStr = string.Empty; for (int i = 0; i < strLen; i++) { randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper(); } StringBuilder sb = new StringBuilder(); sb.Append(@"您好:<br /><br />"); sb.Append(@"這封認證信函是由 工研院大檔案傳輸系統 所發出的。<br /><br />"); sb.Append(@"請點擊至下列網址修改您的密碼。<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />"); myEmail.sendEmail(tbxforgetAccount, "[ITRI]工研院大檔案傳輸", sb.ToString(), ""); myForGet.UpdateMemberQueryStr(sec.encryptquerystring(randStr), dt.Rows[0]["mem_id"].ToString().Trim()); context.Response.Write("success"); } else { context.Response.Write("此帳號尚未註冊"); return; } } }
public MainWindow() { InitializeComponent(); XmlSerializer xmlsr = new XmlSerializer(typeof(List <DataRow>)); using (FileStream fs = new FileStream(saveFileName, FileMode.Open)) MainWindow.users_db = (List <DataRow>)xmlsr.Deserialize(fs); XmlSerializer xmlsr2 = new XmlSerializer(typeof(security)); using (FileStream fs2 = new FileStream("check.hs", FileMode.Open)) sec = (security)xmlsr2.Deserialize(fs2); if (sec.count_of_trying == 3 && new TimeSpan(0, 5, 0) - (DateTime.Now - sec.bloking_time) < new TimeSpan(0, 5, 0)) { this.IsEnabled = false; timer.Tick += EnableWindow; timer.Interval = new TimeSpan(0, 5, 0) - (DateTime.Now - sec.bloking_time); timer.Start(); MessageBox.Show("Вы все еще заблокированы!", "Внимание.", MessageBoxButton.OK, MessageBoxImage.Warning); } }
/// <summary> /// AES的解密函数 /// </summary> /// <param name="text">需要解密的密文</param> /// <returns></returns> public string GetAESDecrypt(string text) { security secur = new security(); return(secur.AESDecrypt(text)); }
/// <summary> /// DES加密函数:64bit /// </summary> /// <param name="text">需要加密的明文</param> /// <returns></returns> public string GetDESEncrypt(string text) { security secur = new security(); return(secur.DESEncrypt(text)); }
/// <summary> /// 用于MD5加密的函数 /// </summary> /// <param name="text">需要加密的明文</param> /// <returns></returns> public string GetMD5Text(string text) { security secur = new security(); return(secur.MD5Text(text)); }
protected void qtcgsubmit_Click(object sender, EventArgs e) { if (this.qtcgcheck.Checked == true) { bool flag = true; security sc = new security(); if (this.qitachengguo.Text != "") { string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { // 给管理员发送邮件 sendmailclass sd = new sendmailclass(); string value1 = Session["emaildizhi"].ToString(); string value2 = "您的项目“" + Session["xiangmuming"].ToString() + "”有新成果上传,请前往查看!"; string value3 = "成果更新提醒"; sd.sendmailfunction(value1, value2, value3); // 写入数据库 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; string filename = shengcheng(Path.GetExtension(this.qtcgfile.FileName)); cmd.CommandText = "INSERT INTO files VALUES('" + filename + "','" + Session["xiangmuhao"].ToString() + "','" + "其它" + "','" + this.qitachengguo.Text + "','" + Session["yonghuming"].ToString() + "','否','" + Session["emaildizhi"].ToString() + "','" + Session["xingming"].ToString() + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "')"; cmd.ExecuteNonQuery(); // 上传文件 this.qtcgfile.SaveAs(Server.MapPath("/") + "\\files\\" + filename); // 给管理员发送私信 cmd.CommandText = "INSERT INTO webchat VALUES('" + Session["yonghuming"].ToString() + "','" + Session["guanliyuan"].ToString() + "','有新的成果上传,请及时审核!','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','否')"; cmd.ExecuteNonQuery(); } catch { conn.Close(); conn.Dispose(); flag = false; } finally { conn.Close(); conn.Dispose(); if (flag) { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"操作成功!\")</script>"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查输入并保证网络畅通!\")</script>"); } } } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的信息并注意文件格式!\")</script>"); } } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请检查您输入的信息并确认!\")</script>"); } }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); SqlDataReader dr = cmd.ExecuteReader(); dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否'"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充截图类别下拉菜单 if (!IsPostBack) { cmd.CommandText = "SELECT type FROM gallery WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' GROUP BY type"; dr = cmd.ExecuteReader(); this.ruanjianjietu.DataSource = dr; this.ruanjianjietu.DataTextField = "type"; this.ruanjianjietu.DataValueField = "type"; this.ruanjianjietu.DataBind(); dr.Close(); ListItem li = new ListItem(); li.Text = "添加新类别"; li.Value = "添加新类别"; this.ruanjianjietu.Items.Add(li); } // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } } catch { conn.Close(); conn.Dispose(); } finally { conn.Close(); conn.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { // 填充成员信息 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否'"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充正文图片部分 cmd.CommandText = "SELECT title,type,filename FROM gallery WHERE projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY type"; dr = cmd.ExecuteReader(); int cirnum = 0; string temp = ""; while (dr.Read()) { if (temp != dr[1].ToString()) { cirnum++; temp = dr[1].ToString().Trim(); } gallerycontent = gallerycontent + maker.gallerycontent(dr[1].ToString(), dr[0].ToString(), dr[2].ToString(), cirnum); } dr.Close(); cmd.CommandText = "SELECT type FROM gallery WHERE projectno='" + Session["xiangmuhao"].ToString() + "' GROUP BY type"; dr = cmd.ExecuteReader(); int cir = 1; while (dr.Read()) { gallerytitle = gallerytitle + maker.gallerytitle(dr[0].ToString().Trim(), cir); galleryoption = galleryoption + maker.galleryoption(dr[0].ToString().Trim(), cir); cir++; } dr.Close(); // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } } catch { conn.Close(); conn.Dispose(); } finally { conn.Close(); conn.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); codemaker maker = new codemaker(); try { // 填充期刊论文 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT filename,type,info,username,name,dateandtime FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '是' ORDER BY dateandtime DESC,username"; SqlDataReader dr = cmd.ExecuteReader(); int qikan = 1; int huiyi = 1; int shenqingzhl = 1; int shouquanzhl = 1; int qt = 1; while (dr.Read()) { string name; if (dr[3].ToString().Trim() == "System") { name = "系统"; } else { name = dr[4].ToString().Trim(); } if (Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { if (dr[1].ToString().Trim() == "期刊论文") { qklw = qklw + maker.qklw(qikan.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); qikan++; } else if (dr[1].ToString().Trim() == "会议论文") { hylw = hylw + maker.qklw(huiyi.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); huiyi++; } else if (dr[1].ToString().Trim() == "授权专利") { shouquan = shouquan + maker.qklw(shouquanzhl.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); shouquanzhl++; } else if (dr[1].ToString().Trim() == "申请专利") { shenqing = shenqing + maker.qklw(shenqingzhl.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); shenqingzhl++; } else { qita = qita + maker.qklw(qt.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); qt++; } } else { if (dr[1].ToString().Trim() == "期刊论文") { qklw = qklw + maker.qklwpt(qikan.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); qikan++; } else if (dr[1].ToString().Trim() == "会议论文") { hylw = hylw + maker.qklwpt(huiyi.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); huiyi++; } else if (dr[1].ToString().Trim() == "授权专利") { shouquan = shouquan + maker.qklwpt(shouquanzhl.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); shouquanzhl++; } else if (dr[1].ToString().Trim() == "申请专利") { shenqing = shenqing + maker.qklwpt(shenqingzhl.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); shenqingzhl++; } else { qita = qita + maker.qklwpt(qt.ToString(), dr[2].ToString().Trim(), dr[0].ToString().Trim(), name, dr[5].ToString().Trim()); qt++; } } } dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } } catch (Exception ex) { Response.Write("<script>alert(\"" + ex.Message + "\")</script>"); conn.Close(); conn.Dispose(); } finally { conn.Close(); conn.Dispose(); } }
protected void Button1_Click(object sender, EventArgs e) { security ob = new security(); ob.mainCreate(); }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); //try { // 获取登录用户的IP地址并写入数据库 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT * FROM pro" + Session["xiangmuhao"].ToString() + " WHERE username = '******'"; SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) { dr.Close(); Response.Redirect("temp.aspx"); // 如果查询不到结果,说明该成员尚未加入项目,跳转至提示页面 } string ipdizhi; ipdizhi = Request.UserHostAddress.ToString(); dr.Close(); IPSearch.IPLocation wulidizhi; if (ipdizhi != "::1") { IPSearch ips = new IPSearch(); wulidizhi = ips.GetIPLocation(ipdizhi); } else { ipdizhi = "127.0.0.1"; wulidizhi.country = "维护地址"; wulidizhi.area = "主机"; } cmd.CommandText = "INSERT INTO records VALUES('" + Session["yonghuming"].ToString() + "','" + Session["xingming"].ToString() + "','" + DateTime.Now.ToString("MM-dd") + "','" + DateTime.Now.ToLongTimeString().ToString() + "','" + ipdizhi + "','" + Session["xiangmuhao"].ToString() + "','" + wulidizhi.country + wulidizhi.area + "')"; cmd.ExecuteNonQuery(); dr.Close(); // 关闭读取器,以便之后的代码可以调用该读取器 // 绘制项目成果汇总图 string[] name = new string[5] { "期刊论文", "会议论文", "申请专利", "授权专利", "其它" }; string[] number = new string[5]; /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='期刊论文' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[0] = dr[0].ToString().Trim(); } else { number[0] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='会议论文' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[1] = dr[0].ToString().Trim(); } else { number[1] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='申请专利' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[2] = dr[0].ToString().Trim(); } else { number[2] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='授权专利' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[3] = dr[0].ToString().Trim(); } else { number[3] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='其它' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[4] = dr[0].ToString().Trim(); } else { number[4] = "0"; } dr.Close(); DataTable dt = new DataTable(); dt.Columns.Add("hengzuobiao", System.Type.GetType("System.String")); dt.Columns.Add("zongzuobiao", System.Type.GetType("System.String")); for (int i = 0; i <= 4; i++) { DataRow row = dt.NewRow(); row["hengzuobiao"] = name[i]; row["zongzuobiao"] = number[i]; dt.Rows.Add(row); } this.Chart1.DataSource = dt; this.Chart1.Series[0].XValueMember = "hengzuobiao"; this.Chart1.Series[0].YValueMembers = "zongzuobiao"; this.Chart1.ChartAreas["ChartArea1"].AxisX.Title = "类别"; this.Chart1.ChartAreas["ChartArea1"].AxisY.Title = "数量"; Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; this.Chart1.Series[0].IsValueShownAsLabel = true; // 绘制访问量变化统计图 /* * cmd.CommandText = "SELECT COUNT(*),date FROM records WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' GROUP BY date ORDER BY date DESC"; * dr = cmd.ExecuteReader(); * string[] label = new string[7]; * string[] quantity = new string[7]; * * int a; * * for (a = 6; a >= 0; a--) * { * if (dr.Read()) * { * label[a] = dr[1].ToString().Trim(); * quantity[a] = dr[0].ToString().Trim(); * } * else * { * break; * } * } * * dr.Close(); * * DataTable dt1 = new DataTable(); * dt1.Columns.Add("riqi", System.Type.GetType("System.String")); * dt1.Columns.Add("shuliang", System.Type.GetType("System.String")); * int b; * * for (b = 0; b < 7; b++) * { * DataRow row = dt1.NewRow(); * row["riqi"] = label[b]; * row["shuliang"] = quantity[b]; * dt1.Rows.Add(row); * } * * this.Chart2.DataSource = dt1; * this.Chart2.Series[0].XValueMember = "riqi"; * this.Chart2.Series[0].YValueMembers = "shuliang"; * * this.Chart2.ChartAreas[0].AxisX.Title = "日期"; * this.Chart2.ChartAreas[0].AxisY.Title = "访问量"; * Chart2.ChartAreas["ChartArea2"].AxisX.Interval = 1; * this.Chart2.Series[0].IsValueShownAsLabel = true; * dr.Close(); */ // 绘制经费使用情况图 string[] type = new string[7] { "设备费", "材料费", "资料费", "差旅费", "通信费", "劳务费", "其它" }; double[] money = new double[7] { 0, 0, 0, 0, 0, 0, 0 }; /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT flag,money FROM moneyrecord WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); while (dr.Read()) { //string[] tmpstr = dr[0].ToString().Trim().Split(new char[] { '#', '#' }); string[] tmpstr = new string[2]; tmpstr[0] = dr[0].ToString().Trim(); tmpstr[1] = dr[1].ToString().Trim(); if (tmpstr[0].IndexOf("设备费") >= 0) { money[0] = money[0] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("材料费") >= 0) { money[1] = money[1] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("资料费") >= 0) { money[2] = money[2] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("差旅费") >= 0) { money[3] = money[3] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("通信费") >= 0) { money[4] = money[4] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("劳务费") >= 0) { money[5] = money[5] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("其它") >= 0) { money[6] = money[6] + Convert.ToDouble(tmpstr[1]) / 10000; } } dr.Close(); DataTable dt1 = new DataTable(); dt1.Columns.Add("hengzuobiao1", System.Type.GetType("System.String")); dt1.Columns.Add("zongzuobiao1", System.Type.GetType("System.String")); for (int i = 0; i <= 6; i++) { DataRow row = dt1.NewRow(); row["hengzuobiao1"] = type[i]; row["zongzuobiao1"] = money[i].ToString(); dt1.Rows.Add(row); } this.Chart2.DataSource = dt1; this.Chart2.Series[0].XValueMember = "hengzuobiao1"; this.Chart2.Series[0].YValueMembers = "zongzuobiao1"; this.Chart2.ChartAreas["ChartArea2"].AxisX.Title = "类别"; this.Chart2.ChartAreas["ChartArea2"].AxisY.Title = "数量"; Chart2.ChartAreas["ChartArea2"].AxisX.Interval = 1; this.Chart2.Series[0].IsValueShownAsLabel = true; // 填充公告栏内容 cmd.CommandText = "SELECT message,dateandtime FROM publics WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); dr.Read(); gonggao = dr[0].ToString().Trim(); shijian = dr[1].ToString().Trim(); dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充平台人数总占比及总人数 cmd.CommandText = "SELECT COUNT(*) FROM pro" + Session["xiangmuhao"].ToString(); dr = cmd.ExecuteReader(); dr.Read(); double int1 = Convert.ToDouble(dr[0].ToString()); renshu = int1.ToString(); dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM main"; dr = cmd.ExecuteReader(); dr.Read(); double int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); double result = int1 / int2 * 100; rszb = ((int)result).ToString(); // 填充平台经费总占比 cmd.CommandText = "SELECT money FROM project WHERE username='******'"; dr = cmd.ExecuteReader(); dr.Read(); int1 = Convert.ToDouble(dr[0].ToString()); dr.Close(); cmd.CommandText = "SELECT SUM(ALL money) AS tomoney FROM project"; dr = cmd.ExecuteReader(); dr.Read(); int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); result = int1 / int2 * 100; jfzb = ((int)result).ToString(); // 填充平台成果总占比 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); int1 = Convert.ToDouble(dr[0].ToString()); dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM files"; dr = cmd.ExecuteReader(); dr.Read(); int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); result = int1 / int2 * 100; cgzb = ((int)result).ToString(); // 填充访问总流量 cmd.CommandText = "SELECT COUNT(*) FROM records WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); liuliang = dr[0].ToString().Trim(); dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充最近活动 cmd.CommandText = "SELECT dateandtime,message,type FROM messages WHERE projectno ='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); int tmpint = 0; while (dr.Read() && tmpint <= 25) { activity = activity + maker.activity(dr[1].ToString().Trim(), dr[0].ToString().Trim(), dr[2].ToString().Trim()); tmpint++; } dr.Close(); // 填充聊天窗口 cmd.CommandText = "SELECT name,dateandtime,message,username FROM bbs WHERE projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr[3].ToString() == Session["yonghuming"].ToString()) { chatwindow = chatwindow + maker.chatwindow2(dr[0].ToString().Trim(), dr[2].ToString().Trim(), dr[1].ToString().Trim(), dr[3].ToString().Trim()); } else { chatwindow = chatwindow + maker.chatwindow(dr[0].ToString().Trim(), dr[2].ToString().Trim(), dr[1].ToString().Trim(), dr[3].ToString().Trim()); } } dr.Close(); // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } /* * } * catch(Exception ex) * { * conn.Close(); * conn.Dispose(); * Response.Write("<script>alert(\"" + ex.Message + "\")</script>"); * } * finally * { * conn.Close(); * conn.Dispose(); * } * */ }
protected void Page_Load(object sender, EventArgs e) { if (Session["yonghuming"] == null) { Response.Redirect("default.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { string temp1 = Session["yonghuming"].ToString(); string temp2 = Session["xingming"].ToString(); string temp3 = Session["xiangmuhao"].ToString(); string temp4 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT * FROM pro" + temp3 + " WHERE username = '******'"; SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) { cmd.CommandText = "INSERT INTO applies VALUES('" + temp1 + "','" + temp2 + "','" + temp3 + "','" + temp4 + "')"; dr.Close(); cmd.ExecuteNonQuery(); } else { dr.Close(); } sendmailclass sd = new sendmailclass(); cmd.CommandText = "SELECT email FROM main WHERE username='******'"; dr = cmd.ExecuteReader(); if (dr.Read()) { string str1 = dr[0].ToString().Trim(); string str2 = "您管理的项目“" + Session["xiangmuming"].ToString() + "”有新成员加入!"; string str3 = "成员消息"; dr.Close(); sd.sendmailfunction(str1, str2, str3); } else { Exception ex = new Exception(); throw ex; } } catch { conn.Close(); conn.Dispose(); Response.Redirect("../default.aspx"); } finally { conn.Close(); conn.Dispose(); } }
Result iTool.Execute(Job job) { Result result = new Result(job.Id); config permConfig = new config(); security security = new security(); permConfig.ReadConfig(job.DownloadAttachment()); List <site> sites = new List <site>(); foreach (permissionsite permSite in permConfig.permissionSites) { Console.WriteLine(permSite.source); using (SPWeb web = new SPSite(permSite.source).OpenWeb()) { site site = new site(permSite.source, permSite.target); List <folder> folders = new List <folder>(); SPListCollection siteLists = web.Lists; foreach (SPList list in siteLists) { try { if (!permConfig.ignoreList.Contains(list.RootFolder.Name.ToLower())) { if (list.HasUniqueRoleAssignments) { folder folder = AddFolder(list); Helper helper = Helper.Instance; string updatedUrl = helper.MapServerRelativeUrl(folder.serverRelativeUrl, permSite.source, permSite.target); folder.serverRelativeUrl = updatedUrl; site.folders.Add(folder); } SPQuery query = new SPQuery(); query.Query = @" <Where> <BeginsWith> <FieldRef Name='ContentTypeId' /> <Value Type='ContentTypeId'>0x0120</Value> </BeginsWith> </Where>"; query.ViewAttributes = "Scope='RecursiveAll'"; SPListItemCollection items = list.GetItems(query); foreach (SPListItem item in items) { if (item.HasUniqueRoleAssignments) { folder folder = AddFolder(item.Folder, item.RoleAssignments, false); Helper helper = Helper.Instance; string updatedUrl = helper.MapServerRelativeUrl(folder.serverRelativeUrl, permSite.source, permSite.target); folder.serverRelativeUrl = updatedUrl; site.folders.Add(folder); } if (!permSite.ignoreFiles) { List <file> uniqueSPFiles = GetUniquePermissionFiles(list, item); foreach (file uniqueSPFile in uniqueSPFiles) { Helper helper = Helper.Instance; string updatedUrl = helper.MapServerRelativeUrl(uniqueSPFile.serverRelativeUrl, permSite.source, permSite.target); uniqueSPFile.serverRelativeUrl = updatedUrl; site.files.Add(uniqueSPFile); } } } } } catch (Exception ex) { Console.WriteLine(list.Title); Console.WriteLine(ex.Message); } } security.sites.Add(site); } } try { XmlSerializer serializer = new XmlSerializer(typeof(security)); string tmpFile = Scheduler.Instance.CreateTmpFile(); using (TextWriter stream = new StreamWriter(tmpFile)) { using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings { Indent = true })) { writer.WriteStartDocument(); writer.WriteComment(@"You can control what to import on the target by setting the Import attribute on the <Sites> element e.g. Import=""All"" | Import=""Folders"" | Import=""Files"""); writer.WriteComment(@"You can disconnect permission inheritance (if wrongfully inheriting) by setting IgnoreInheritance=""false"""); serializer.Serialize(writer, security); writer.WriteEndDocument(); writer.Flush(); } } result.AddFile(tmpFile); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.InnerException.Message); } return(result); }
protected void Page_Load(object sender, EventArgs e) { string id; id = Request.Browser.Id.ToString(); if (id.IndexOf("ie") > -1) { } security sc = new security(); int xx = sc.flag("临时参数", Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("alert.aspx"); } string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT * FROM server"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Session["gongsi"] = dr[0].ToString().Trim(); Session["youxiang"] = dr[1].ToString().Trim(); Session["guanliyuan"] = dr[2].ToString().Trim(); } else { Session["gongsi"] = ""; Session["youxiang"] = ""; Session["guanliyuan"] = ""; } dr.Close(); } catch { conn.Close(); conn.Dispose(); } finally { conn.Close(); conn.Dispose(); } ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(\"请注意:\\n1. 网站目前位于阿里云服务器,所有文件处于开放状态,请在上传前自行加密。\\n2. " + "由于带宽限制,首次加载带有图片的页面耗时较长,请耐心等待图片加载完成,后续加载将不再有延迟。\\n3. 网站重新开放了邮件通知服务,为了保证您及时接收相关消息," + "请检查垃圾邮件设置(特别是西电学生邮箱),防止邮件被垃圾邮件网关拦截。\\n4." + " 由于带宽限制,上传大文件会耗时较长,请耐心等待。\\n5. 为了加快校内同学访问速度,站内较大的图片资源均放置在校内服务器,外网或手机访问时将无法加载背景图片" + ",但不影响系统的正常使用。\\n6. 为精简服务器文件,2017年9月2日前的文件不再提供下载服务,如需相关文件资料,请自行向管理员申请。\\n7. 网站迁移至阿里云" + "服务器后,可能受到服务器停机维护、断电等情况影响,对此我们会提前通知,如果发现网站无法访问,也请及时通知管理员进行维护。\")</script>"); }
public void ProcessRequest(HttpContext context) { try { string tbxNameQ = context.Request.Form["tbxNameQ"].ToString().Trim(); string tbxAccountQ = context.Request.Form["tbxAccountQ"].ToString().Trim(); string typeQ = context.Request.Form["typeQ"].ToString().Trim(); if (tbxNameQ.ToString().Trim() == "") { context.Response.Write("Please enter your Name"); return; } if (tbxAccountQ.ToString().Trim() == "") { context.Response.Write("Please enter your E-mail Address"); return; } if (!Common.IsVaildEmail(tbxAccountQ)) { context.Response.Write("Email format is not vaild"); return; } if (encode.sqlInjection(tbxNameQ)) { context.Response.Write("Name contains illegal characters"); return; } DataTable dtEmail = Common.AccordEmailIsitFromITRI(tbxAccountQ, ""); if (dtEmail.Rows.Count > 0) { context.Response.Write("Please enter E-mail without ITRI employee"); return; } if (typeQ != "agree") { context.Response.Write("You have not agreed 'User agreement' yet"); return; } else { Random rdm = new Random(); register_DB myreg = new register_DB(); security sec = new security(); Email myEmail = new Email(); DataTable dt = myreg.CheckEmailExist(tbxAccountQ); if (dt.Rows.Count > 0) { context.Response.Write("This Email has been registered"); return; } /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */ string[] seeds = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }; int strLen = (int)rdm.Next(5, 11); string randStr = string.Empty; for (int i = 0; i < strLen; i++) { randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper(); } StringBuilder sb = new StringBuilder(); sb.Append(@"Dear" + tbxNameQ + " :<br /><br />"); sb.Append(@"This letter was sent by ITRIWebFTP system. You received this email because you've registered a new account.<br /><br />"); sb.Append(@" Please go to the url listed below to get your member verification.<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "enVersion/validEn.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />"); //sb.Append(@""); //sb.Append(@""); //sb.Append(@""); //sb.Append(@""); myEmail.sendEmail(tbxAccountQ, "[ITRI] WebFTP Account Notification ", sb.ToString(), ""); myreg.INSERTmember(tbxAccountQ, tbxNameQ, sec.encryptquerystring(randStr)); context.Response.Write("success"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } if (Session["guanliyuan"] == Session["yonghuming"]) { isAdmin = true; } else { isAdmin = false; } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { // 确定是否显示搜索框 if (Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { flag = "false"; } else { flag = "true"; } // 填充成员信息 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); SqlDataReader dr = cmd.ExecuteReader(); dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否'"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充经费使用情况统计图 double yi; double wei; cmd.CommandText = "SELECT SUM(ALL money) AS money FROM moneyrecord WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); if (dr[0].ToString().Trim() != "") { yi = Convert.ToDouble(dr[0].ToString().Trim()); } else { yi = 0; } dr.Close(); cmd.CommandText = "SELECT SUM(ALL money) AS money FROM bonus WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); if (dr[0].ToString().Trim() != "") { wei = Convert.ToDouble(dr[0].ToString().Trim()) - yi; } else { wei = -yi; } //dr.Read(); string[] label = new string[] { "已使用金额", "未使用金额" }; string[] value = new string[] { yi.ToString(), wei.ToString() }; DataTable dt = new DataTable(); dt.Columns.Add("hengzuobiao", System.Type.GetType("System.String")); dt.Columns.Add("zongzuobiao", System.Type.GetType("System.String")); for (int i = 0; i <= 1; i++) { DataRow row = dt.NewRow(); row["hengzuobiao"] = label[i]; row["zongzuobiao"] = value[i]; dt.Rows.Add(row); } this.Chart1.DataSource = dt; Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie; //设置图表类型 Chart1.Series[0].XValueMember = "hengzuobiao"; //X轴数据成员列 Chart1.Series[0].YValueMembers = "zongzuobiao"; //Y轴数据成员列 Chart1.Series[0].IsVisibleInLegend = true; Chart1.Series[0].IsValueShownAsLabel = true; //显示坐标值 dr.Close(); // 填充本人经费使用表 // 填充经费使用情况统计图 //cmd.CommandText = "SELECT money,spent FROM pro" + Session["xiangmuhao"].ToString() + " WHERE username='******'"; cmd.CommandText = "SELECT SUM(ALL money) AS money FROM moneyrecord WHERE name='" + Session["xingming"].ToString() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; double yi1; double wei1; dr = cmd.ExecuteReader(); dr.Read(); if (dr[0].ToString().Trim() != "") { yi1 = Convert.ToDouble(dr[0].ToString().Trim()); } else { yi1 = 0; } dr.Close(); cmd.CommandText = "SELECT SUM(ALL money) AS money FROM bonus WHERE name='" + Session["xingming"].ToString() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); if (dr[0].ToString().Trim() != "") { wei1 = Convert.ToDouble(dr[0].ToString().Trim()) - yi1; } else { wei1 = -yi1; } dr.Close(); string[] label1 = new string[] { "已使用金额", "未使用金额" }; string[] value1 = new string[] { yi1.ToString(), wei1.ToString() }; DataTable dt2 = new DataTable(); dt2.Columns.Add("hengzuobiao1", System.Type.GetType("System.String")); dt2.Columns.Add("zongzuobiao1", System.Type.GetType("System.String")); for (int i = 0; i <= 1; i++) { DataRow row1 = dt2.NewRow(); row1["hengzuobiao1"] = label1[i]; row1["zongzuobiao1"] = value1[i]; dt2.Rows.Add(row1); } this.Chart2.DataSource = dt2; Chart2.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie; //设置图表类型 Chart2.Series[0].XValueMember = "hengzuobiao1"; //X轴数据成员列 Chart2.Series[0].YValueMembers = "zongzuobiao1"; //Y轴数据成员列 Chart2.Series[0].IsVisibleInLegend = true; Chart2.Series[0].IsValueShownAsLabel = true; //显示坐标值 dr.Close(); /* * // 填充经费分配情况统计图 * cmd.CommandText = "SELECT username,name,money FROM pro" + Session["xiangmuhao"].ToString(); * * string[] username = new string[300]; * string[] money = new string[300]; * * dr.Close(); * * dr = cmd.ExecuteReader(); * * int temp = 0; * * while (dr.Read()) * { * username[temp] = dr[1].ToString().Trim() + "(" + dr[2].ToString().Trim() + "万元)"; * money[temp] = dr[2].ToString().Trim(); * * temp++; * } * * DataTable dt1 = new DataTable(); * dt1.Columns.Add("heng", System.Type.GetType("System.String")); * dt1.Columns.Add("zong", System.Type.GetType("System.String")); * * for (num = 0; num < temp; num++) * { * DataRow row1 = dt1.NewRow(); * row1["heng"] = username[num]; * row1["zong"] = money[num]; * dt1.Rows.Add(row1); * } * * this.Chart2.DataSource = dt1; * * Chart2.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie;//设置图表类型 * Chart2.Series[0].XValueMember = "heng";//X轴数据成员列 * Chart2.Series[0].YValueMembers = "zong";//Y轴数据成员列 * Chart2.Series[0].IsVisibleInLegend = true; * Chart2.Series[0].IsValueShownAsLabel = true;//显示坐标值 * * dr.Close(); */ // 填充经费明细表 cmd.CommandText = "SELECT code FROM mingxi WHERE username='******'"; dr = cmd.ExecuteReader(); if (dr.Read()) { mingxi = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "DELETE mingxi WHERE username='******'"; cmd.ExecuteNonQuery(); } else { dr.Close(); if (Session["guanliyuan"].ToString() == Session["yonghuming"].ToString()) { cmd.CommandText = "SELECT dateandtime,flag,username,money,projectno,name FROM moneyrecord WHERE projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; } else { cmd.CommandText = "SELECT dateandtime,flag,username,money,projectno,name FROM moneyrecord WHERE name = '" + Session["xingming"].ToString() + "' and projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; } dr = cmd.ExecuteReader(); int i = 1; while (dr.Read()) { mingxi = mingxi + maker.mingxi(i.ToString(), dr[1].ToString().Trim(), dr[0].ToString().Trim(), dr[3].ToString().Trim(), isGuest(dr[2].ToString().Trim()), dr[5].ToString().Trim(), dr[4].ToString().Trim(), isAdmin); i++; } dr.Close(); if (Session["guanliyuan"].ToString() == Session["yonghuming"].ToString()) { cmd.CommandText = "SELECT dateandtime,flag,username,money,projectno,name FROM bonus WHERE projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; } else { cmd.CommandText = "SELECT dateandtime,flag,username,money,projectno,name FROM bonus WHERE name = '" + Session["xingming"].ToString() + "' and projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; } dr = cmd.ExecuteReader(); while (dr.Read()) { mingxi = mingxi + maker.mingxi(i.ToString(), dr[1].ToString().Trim(), dr[0].ToString().Trim(), dr[3].ToString().Trim(), isGuest(dr[2].ToString().Trim()), dr[5].ToString().Trim(), dr[4].ToString().Trim(), isAdmin); i++; } dr.Close(); } // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } } catch (Exception ex) { conn.Close(); conn.Dispose(); Response.Write("<script>alert(\"" + ex.Message + "\")</script>"); } finally { conn.Close(); conn.Dispose(); } }
public void ProcessRequest(HttpContext context) { try { string tbxNameQ = context.Request.Form["tbxNameQ"].ToString().Trim(); string tbxAccountQ = context.Request.Form["tbxAccountQ"].ToString().Trim(); string typeQ = context.Request.Form["typeQ"].ToString().Trim(); if (tbxNameQ.ToString().Trim() == "") { context.Response.Write("請輸入中文姓名"); return; } if (tbxAccountQ.ToString().Trim() == "") { context.Response.Write("請輸入電子郵件"); return; } if (!Common.IsVaildEmail(tbxAccountQ)) { context.Response.Write("Email格式錯誤"); return; } if (encode.sqlInjection(tbxNameQ)) { context.Response.Write("中文姓名包含不合法字元"); return; } DataTable dtEmail = Common.AccordEmailIsitFromITRI(tbxAccountQ, ""); if (dtEmail.Rows.Count > 0) { context.Response.Write("請輸入院外信箱"); return; } if (typeQ != "agree") { context.Response.Write("您並未同意使用規約 無法接受您的申請"); return; } else { Random rdm = new Random(); register_DB myreg = new register_DB(); security sec = new security(); Email myEmail = new Email(); DataTable dt = myreg.CheckEmailExist(tbxAccountQ); if (dt.Rows.Count > 0) { context.Response.Write("此Email已註冊過帳號"); return; } /* 底下為本來密碼自動產生 不過規格取消 所以拿來用在querystring上 */ string[] seeds = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }; int strLen = (int)rdm.Next(5, 11); string randStr = string.Empty; for (int i = 0; i < strLen; i++) { randStr += seeds[rdm.Next(seeds.Length)].ToString().ToUpper(); } StringBuilder sb = new StringBuilder(); sb.Append(@"親愛的" + tbxNameQ + " 您好:<br /><br />"); sb.Append(@"這封認證信函是由 工研院大檔案傳輸系統 所發出的,您收到這封電子郵件可能是因為您註冊了新的帳號。<br /><br />"); sb.Append(@"請點擊至下列網址,即可通過會員認證並新增您的密碼。<br /><br />"); sb.Append(@"<a href='" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "'>" + AppConfig.MailUrl + "valid.aspx?vid=" + sec.encryptquerystring(randStr) + "</a><br /><br />"); //sb.Append(@""); //sb.Append(@""); //sb.Append(@""); //sb.Append(@""); myEmail.sendEmail(tbxAccountQ, "[ITRI]工研院大檔案傳輸會員驗證", sb.ToString(), ""); myreg.INSERTmember(tbxAccountQ, tbxNameQ, sec.encryptquerystring(randStr)); context.Response.Write("success"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here page_utilities.Set_titles(this, "Upload data"); permss = check_permissions(this.Page, true, new Hashtable()); Initializing_pagevariables(); maxlengths = DB.execProc("select_crm_columns", h_params); error_table.Visible = false; ArrayList file_content_list = new ArrayList(); //read datafile, validate structure of file and fill arraylist bool file_valid = Read_datafile(file_content_list); if (file_valid) { #region (validating entries and sorting out: good records insert into db and store in table, bad ones store in arraylist) foreach (string[] file_content_line in file_content_list) { h_params.Clear(); Insert_Data_to_DB(file_content_line); } #endregion } //.NET 1.1: string pathtotempdir = Server.MapPath(ConfigurationSettings.AppSettings["relativePathToTempdir"]); string pathtotempdir = Server.MapPath(utility.getParameter("path_to_temp")); #region (writing good records file) h_params.Clear(); h_params.Add("campaign_code_FK", campaign); DataTable customers = DB.execProc("select_campaign_customers", h_params); #region (creating, opening of good_data file to write, writing columnheadings) try { good_file_name = campaign + "__"; good_file_name += "datafile.txt"; good_file_path = Path.Combine(pathtotempdir,good_file_name); gooddatafileWriter = new StreamWriter(good_file_path,false, Encoding.Default); //remove and rename columns according to datasource if (file_source == "siebel75") { customers.Columns.Remove("worldsize_siebel63"); customers.Columns.Remove("job_siebel63"); customers.Columns.Remove("business_siebel63"); } if (file_source == "siebel63") { customers.Columns.Remove("world_size"); customers.Columns.Remove("job_code"); customers.Columns.Remove("business_code"); customers.Columns["worldsize_siebel63"].ColumnName = "world_size"; customers.Columns["job_siebel63"].ColumnName = "job_code"; customers.Columns["business_siebel63"].ColumnName = "business_code"; } foreach (DataColumn column in customers.Columns) { #region (column name corrections requested by Lucy Gluckman) switch(column.ColumnName.ToUpper().ToString()) { case "LANGUAGE": column.ColumnName = "CAMPAIGN_LANGUAGE"; break; case "COMPANY_NAME": column.ColumnName = "COMPANY NAME"; break; case "COMPANY_ID": column.ColumnName = "COMPANY CORPORATE ID"; break; case "TOWN": column.ColumnName = "CITY"; break; case "CAMPAIGN_CODE_FK": column.ColumnName = "CAMPAIGN_CODE"; break; } #endregion gooddatafileWriter.Write(column.ColumnName.ToString().ToUpper() + "\t"); } gooddatafileWriter.WriteLine(); } catch(Exception ex) { //delete all uploaded customers because generation of file(s) has failed - no result is visible to RFG user... delete_uploaded_customers(); error_text.Text = String.Format("{0}Upload has failed - please try again!{1}{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}Error by writing in file - Code 004{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}{1}", error_text.Text, ex.ToString()); error_table.Visible = true; } #endregion int i = 0; int end = customers.Columns.Count - 1; customers.PrimaryKey = new DataColumn[] {customers.Columns["rfg_cid"]}; try { foreach(DataRow new_customer in new_customers.Rows) { DataRow customer_row = customers.Rows.Find(new_customer["guid"].ToString()); i = 0; foreach (DataColumn customer_column in customers.Columns) { if (i != end && i != 16) { gooddatafileWriter.Write(customer_row[customer_column].ToString() + "\t"); } else { if (i == 16) { gooddatafileWriter.Write(customer_row[customer_column].ToString() + "\t"); //.Replace("-", "").ToLower() } else { gooddatafileWriter.Write(customer_row[customer_column].ToString()); } } i++; } gooddatafileWriter.WriteLine(); } } catch (Exception ex) { //delete all uploaded customers because generation of file(s) has failed - no result is visible to RFG user... delete_uploaded_customers(); error_text.Text = String.Format("{0}Upload has failed - please try again!{1}{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}Error by writing to file - Code 005{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}{1}", error_text.Text, ex.ToString()); error_table.Visible = true; } #endregion #region (writing corrupt_datafile) #region (creating, opening of bad_data file to write and writing of columnheadings) bad_file_name = campaign + "__corrupt_"; bad_file_name += "datafile.txt"; bad_file_path = Path.Combine(pathtotempdir, bad_file_name); try { baddatafileWriter = new StreamWriter(bad_file_path, false, Encoding.Default); string columnheadings = ""; for (int k = 0; k < correct_uploaded_columns.Count; k++) { if (k != 0) { columnheadings = String.Format("{0}\t", columnheadings); } columnheadings = String.Format("{0}{1}", columnheadings, correct_uploaded_columns[k]); } #region inactive old columnheading // string columnheadings = "COUNTRY\t"; // columnheadings += "CAMPAIGN_LANGUAGE\t"; // columnheadings += "EMAIL_ADDRESS\t"; // columnheadings += "FIRST_NAME\t"; // columnheadings += "LAST_NAME\t"; // columnheadings += "COMPANY CORPORATE ID\t"; // columnheadings += "COMPANY NAME\t"; // columnheadings += "ADDRESS1\t"; // columnheadings += "ADDRESS2\t"; // columnheadings += "ADDRESS3\t"; // columnheadings += "CITY\t"; // columnheadings += "COUNTY\t"; // columnheadings += "POSTCODE\t"; // columnheadings += "TELEPHONE\t"; // columnheadings += "CONTACT_BY_EMAIL\t"; // columnheadings += "SOURCE_DB_ID\t"; // columnheadings += "SIEBEL_ID\t"; // columnheadings += "PURL\t"; // columnheadings += "SOURCE_DB_NAME\t"; // columnheadings += "WORLD_SIZE\t"; // columnheadings += "JOB_CODE\t"; // columnheadings += "BUSINESS_CODE\t"; // columnheadings += "GREETING_STRING\t"; // columnheadings += "EDM_LIST_INDICATOR\t"; // columnheadings += "PERSONAL_TITLE\t"; // columnheadings += "ALLOWANCE_FLAG\t"; // columnheadings += "FLEXFIELD1\t"; // columnheadings += "FLEXFIELD2\t"; // columnheadings += "FLEXFIELD3\t"; // columnheadings += "FLEXFIELD4\t"; // columnheadings += "FLEXFIELD5\t"; // columnheadings += "CAMPAIGN_CODE\t"; #endregion baddatafileWriter.WriteLine(columnheadings); } catch(Exception ex) { //delete all uploaded customers because generation of file(s) has failed - no result is visible to RFG user... delete_uploaded_customers(); error_text.Text = String.Format("{0}Upload has failed - please try again!{1}{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}Error by writing in file - Code 006{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}{1}", error_text.Text, ex.ToString()); error_table.Visible = true; } #endregion try { foreach (string[] row in bad_customers) { foreach(string column in row) { baddatafileWriter.Write(column + "\t"); } baddatafileWriter.WriteLine(); } } catch (Exception ex) { //delete all uploaded customers because generation of file(s) has failed - no result is visible to RFG user... delete_uploaded_customers(); error_text.Text = String.Format("{0}Upload has failed - please try again!{1}{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}Error by writing to file - Code 007{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}{1}", error_text.Text, ex.ToString()); error_table.Visible = true; } #endregion #region (closing files) try { baddatafileWriter.Close(); gooddatafileWriter.Close(); } catch(Exception ex) { error_text.Text = String.Format("{0}{1}Error by accessing files - Code 008{1}", error_text.Text, utility.newline); error_text.Text = String.Format("{0}{1}", error_text.Text, ex.ToString()); error_table.Visible = true; } #endregion Session["campaign"] = campaign; Session["good_records"] = count_good_records; Session["bad_records"] = count_bad_records; Session["good_file_name"] = good_file_name; Session["bad_file_name"] = bad_file_name; if (!error_table.Visible) { Response.Redirect("download_file.aspx", true); } }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); SqlDataReader dr = cmd.ExecuteReader(); dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否'"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充周次下拉菜单 /* * int total; * * cmd.CommandText = "SELECT weeknum FROM weekreport WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and" + " username='******' ORDER BY weeknum DESC"; + dr = cmd.ExecuteReader(); + + if(dr.Read()) + { + total = Convert.ToInt16(dr[0].ToString().Trim()) + 1; + } + else + { + total = 1; + } + + dr.Close(); + + for(int i=0;i<=5;i++,total++) + { + ListItem li = new ListItem(); + li.Text = total.ToString(); + li.Value = total.ToString(); + this.shangchuanuser.Items.Add(li); + } * */ if (!IsPostBack) { // 填充周报告姓名下拉菜单 cmd.CommandText = "SELECT name FROM pro" + Session["xiangmuhao"].ToString(); dr = cmd.ExecuteReader(); this.renming.DataSource = dr; this.renming.DataTextField = "name"; this.renming.DataValueField = "name"; this.renming.DataBind(); dr.Close(); // 填充周次下拉菜单 cmd.CommandText = "SELECT start FROM project WHERE username='******'"; dr = cmd.ExecuteReader(); int jiange = 1; DateTime chushi = DateTime.Now; if (dr.Read()) { string[] items = dr[0].ToString().Trim().Split('/'); chushi = new DateTime(Convert.ToInt16(items[2]), Convert.ToInt16(items[0]), Convert.ToInt16(items[1])); } TimeSpan ts = DateTime.Now.Subtract(chushi); jiange = (int)ts.TotalDays / 7 + 1; ListItem li = new ListItem(); li.Text = jiange.ToString(); li.Value = jiange.ToString(); this.shangchuanuser.Items.Add(li); for (int i = 1; i < jiange + 1; i++) { ListItem li1 = new ListItem(); li1.Text = i.ToString(); li1.Value = i.ToString(); this.zhoucixiala.Items.Add(li1); } dr.Close(); } // 填充周报告表格 if (Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) // 如果本人即管理员,则可以看到所有人的周报告 { cmd.CommandText = "SELECT weeknum,name,proname,filename,dateandtime,checked FROM weekreport WHERE projectno ='" + Session["xiangmuhao"].ToString() + "' and weeknum=" + this.shangchuanuser.SelectedItem.Text + " ORDER BY weeknum"; dr = cmd.ExecuteReader(); while (dr.Read()) { zhoubaogao = zhoubaogao + maker.weekreport(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim()); } dr.Close(); } else // 否则只能看到本人的周报告 { cmd.CommandText = "SELECT weeknum,name,proname,filename,dateandtime,checked FROM weekreport WHERE projectno ='" + Session["xiangmuhao"].ToString() + "' and username='******' and weeknum='" + this.shangchuanuser.SelectedItem.Text + "' ORDER BY weeknum"; dr = cmd.ExecuteReader(); while (dr.Read()) { zhoubaogao = zhoubaogao + maker.weekreport(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim()); } dr.Close(); } // 填充往期周报告表格 string comm; if (this.zhouciorrenming.Checked) { comm = " and weeknum='" + this.zhoucixiala.SelectedItem.Text + "'"; } else { comm = " and name='" + this.renming.SelectedItem.Text + "'"; } if (Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) // 如果本人即管理员,则可以看到所有人的周报告 { cmd.CommandText = "SELECT weeknum,name,proname,filename,dateandtime,checked FROM weekreport WHERE projectno ='" + Session["xiangmuhao"].ToString() + "'" + comm + " ORDER BY weeknum"; dr = cmd.ExecuteReader(); while (dr.Read()) { wangqizhoubaogao = wangqizhoubaogao + maker.weekreport(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim()); } dr.Close(); } else // 否则只能看到本人的周报告 { cmd.CommandText = "SELECT weeknum,name,proname,filename,dateandtime,checked FROM weekreport WHERE projectno ='" + Session["xiangmuhao"].ToString() + "' and username='******' ORDER BY weeknum"; dr = cmd.ExecuteReader(); while (dr.Read()) { wangqizhoubaogao = wangqizhoubaogao + maker.weekreport(dr[0].ToString().Trim(), dr[1].ToString().Trim(), dr[2].ToString().Trim(), dr[3].ToString().Trim(), dr[4].ToString().Trim(), dr[5].ToString().Trim()); } dr.Close(); } } catch (Exception ex) { conn.Close(); conn.Dispose(); Response.Write("<script>alert(\"" + ex.Message + "\")</script>"); } finally { conn.Close(); conn.Dispose(); } }
public ClientHandler(TcpClient client, int clientID) { tcpClient = client; this.clientID = clientID; security = new security(); }