public ActionResult Index(NhanVienModel model) { /*var tendn = collection["username"]; * var matkhau = collection["password"]; * * if (String.IsNullOrEmpty(tendn)) * { * ViewData["Loi1"] = "Phải nhập tên tài khoản"; * } * else if (String.IsNullOrEmpty(matkhau)) * { * ViewData["Loi2"] = "Phải nhập mật khẩu"; * }*/ if (ModelState.IsValid) { ConnectClass cc = new ConnectClass(); NHANVIEN kq = cc.Login(model.USERNAME, model.PASS); if (kq != null) { Session["TaiKhoanAdmin"] = kq; Session["ABC"] = kq.TENHIENTHI; FormsAuthentication.SetAuthCookie(model.USERNAME, true); return(RedirectToAction("Test", "Test1")); } else { ViewBag.Thongbao = " Tên Đăng Nhập or Mật khẩu Không đúng..."; } ///ViewData["Loi3"] = " Tên Đăng Nhập or Mật khẩu Không đúng..."; } return(View()); }
/// <summary> /// Serialize constructor from a file /// </summary> /// <param name="file">save file as...</param> public Serializing(string file) { Console.WriteLine("Serialize activating..."); if (string.IsNullOrEmpty(file)) { throw new ArgumentNullException("file"); } using (var stream = File.Open(file, FileMode.Open)) { var serial = new XmlSerializer(typeof(ExcelWorkbook)); book = (ExcelWorkbook)serial.Deserialize(stream); } if (book == null) { throw new NullReferenceException("template must not be null. may be failed to making excel template."); } if (book.ConnectionString != null) { this.conn = new ConnectClass(DbProviderFactories.GetFactory(book.ConnectionString.Type), book.ConnectionString.Text); if (book.ConnectionString.Timeout < 0) { conn.CommandTimeout = 0; } else if (book.ConnectionString.Timeout < 0) { conn.CommandTimeout = book.ConnectionString.Timeout; } } Console.WriteLine("Serialize initialzed."); }
protected override Dictionary <string, int> GetChanlesInfo(string NavUrl) { Dictionary <string, int> ret = new Dictionary <string, int>(); AccessWebServerClass wcc = new AccessWebServerClass(); string strHtml = AccessWebServerClass.GetData(NavUrl); if (strHtml == null) { return(ret); } Regex regTr = new Regex(@"www\.kcai(.*?)\.com"); MatchCollection mcs = regTr.Matches(strHtml); List <string> list = new List <string>(); string urlModel = "https://www.kcai{0}.com"; Task[] tasks = new Task[mcs.Count]; for (int i = 0; i < mcs.Count; i++) { string name = mcs[i].Value.Replace("www.kcai", "").Replace(".com", ""); DateTime begT = DateTime.Now; string url = string.Format(urlModel, name); ConnectClass cls = new ConnectClass(ret, name, url); //new Thread(new ThreadStart(cls.ConnectToUrl)).Start(); tasks[i] = new Task(cls.ConnectToUrl); tasks[i].Start(); ////string reqdata = AccessWebServerClass.GetData(url); ////DateTime endT = DateTime.Now; ////if(reqdata == null) ////{ //// ret.Add(name, 0); //// continue; ////} ////int rate = (int)(reqdata.Length/ endT.Subtract(begT).TotalSeconds); ////ret.Add(name, rate); } Task.WaitAll(tasks); return(ret); }
/// <summary> /// Serialize constructor from a file /// </summary> /// <param name="file">save file as...</param> public Serializing(string file) { Console.WriteLine("Serialize activating..."); if (string.IsNullOrEmpty(file)) throw new ArgumentNullException("file"); using (var stream = File.Open(file, FileMode.Open)) { var serial = new XmlSerializer(typeof(ExcelWorkbook)); book = (ExcelWorkbook) serial.Deserialize(stream); } if (book == null) throw new NullReferenceException("template must not be null. may be failed to making excel template."); if (book.ConnectionString != null) { this.conn = new ConnectClass(DbProviderFactories.GetFactory(book.ConnectionString.Type), book.ConnectionString.Text); if (book.ConnectionString.Timeout < 0) conn.CommandTimeout = 0; else if (book.ConnectionString.Timeout < 0) conn.CommandTimeout = book.ConnectionString.Timeout; } Console.WriteLine("Serialize initialzed."); }