public void ProcessRequest(HttpContext context) { context.Response.Buffer = true; context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); context.Response.AddHeader("pragma", "no-cache"); context.Response.AddHeader("cache-control", ""); context.Response.CacheControl = "no-cache"; context.Response.ContentType = "text/plain"; StringBuilder error = new StringBuilder(); string userName = StringClass.EncodeString(context.Request.Form["txtEmail"].Trim()); string userPwd = context.Request.Form["txtPwd"]; string userCPwd = context.Request.Form["txtCPwd"]; string checkCode = context.Request.Form["txtUserVal"]; if (!CheckInput.CheckEmail(userName)) { error.Append("The email format is incorrect, Please check!<br>"); } if (userPwd.Length < 6) { error.Append("The password should not be less than 6 digits.!<br>"); } else { if (userPwd != userCPwd) { error.Append("Repeated password is different from the previous!<br>"); } } if (checkCode != context.Session["ValidateCode"].ToString()) { error.Append("Wrong Validation Code!"); } string userID = Guid.NewGuid().ToString().ToLower(); if (error.ToString() == "") { Model.t_rol_user model = new Model.t_rol_user(); model.ID = userID; model.Username = userName; model.Password = StringClass.EncryptPassword(userPwd, StringClass.PasswordFormat.MD5_32); model.IsValid = 1; model.CreatedDate = DateTime.Now; // Get the RoleID by RoleName. For normal User DataSet Ds = roleBll.GetRoleIDByRoleName("User"); if (Ds.Tables[0].Rows.Count == 0) { WindowClass.WindowBack("Failed to get User's Role ID!"); } else { model.RoleID = Ds.Tables[0].Rows[0]["ID"].ToString(); } error.Append((new BLL.t_rol_user()).RegisterUser(model)); } if (error.ToString() != "") { context.Response.Write(error.ToString()); return; } else { Model.t_rol_user model = new Model.t_rol_user(); model = userBll.GetModel(userID); if (model != null) { context.Session["User"] = model; model = null; context.Response.Write("<script language='javascript'>window.location.href='/../Views/index.aspx';</script>"); } else { WindowClass.WindowBack("Failed to get User model!"); context.Response.Write("<script language='javascript'>window.location.href='/../Views/User/Login.aspx';</script>"); } } }
private void InitRequest() { // Algorithm Training Time Comparison DataSet TrainingDS = trainingTimeBll.GetAllList(); if (TrainingDS.Tables[0].Rows.Count != 0) { knn1kTrainingTime.Text = TrainingDS.Tables[0].Rows[0]["TrainingTimeOne"].ToString(); kknn1kTrainingTime.Text = TrainingDS.Tables[0].Rows[1]["TrainingTimeOne"].ToString(); gbm1kTrainingTime.Text = TrainingDS.Tables[0].Rows[2]["TrainingTimeOne"].ToString(); lg1kTrainingTime.Text = TrainingDS.Tables[0].Rows[3]["TrainingTimeOne"].ToString(); rf1kTrainingTime.Text = TrainingDS.Tables[0].Rows[4]["TrainingTimeOne"].ToString(); nb1kTrainingTime.Text = TrainingDS.Tables[0].Rows[5]["TrainingTimeOne"].ToString(); nnet1kTrainingTime.Text = TrainingDS.Tables[0].Rows[6]["TrainingTimeOne"].ToString(); knn10kTrainingTime.Text = TrainingDS.Tables[0].Rows[0]["TrainingTimeTwo"].ToString(); kknn10kTrainingTime.Text = TrainingDS.Tables[0].Rows[1]["TrainingTimeTwo"].ToString(); gbm10kTrainingTime.Text = TrainingDS.Tables[0].Rows[2]["TrainingTimeTwo"].ToString(); lg10kTrainingTime.Text = TrainingDS.Tables[0].Rows[3]["TrainingTimeTwo"].ToString(); rf10kTrainingTime.Text = TrainingDS.Tables[0].Rows[4]["TrainingTimeTwo"].ToString(); nb10kTrainingTime.Text = TrainingDS.Tables[0].Rows[5]["TrainingTimeTwo"].ToString(); nnet10kTrainingTime.Text = TrainingDS.Tables[0].Rows[6]["TrainingTimeTwo"].ToString(); knn100kTrainingTime.Text = TrainingDS.Tables[0].Rows[0]["TrainingTimeThree"].ToString(); kknn100kTrainingTime.Text = TrainingDS.Tables[0].Rows[1]["TrainingTimeThree"].ToString(); gbm100kTrainingTime.Text = TrainingDS.Tables[0].Rows[2]["TrainingTimeThree"].ToString(); lg100kTrainingTime.Text = TrainingDS.Tables[0].Rows[3]["TrainingTimeThree"].ToString(); rf100kTrainingTime.Text = TrainingDS.Tables[0].Rows[4]["TrainingTimeThree"].ToString(); nb100kTrainingTime.Text = TrainingDS.Tables[0].Rows[5]["TrainingTimeThree"].ToString(); nnet100kTrainingTime.Text = TrainingDS.Tables[0].Rows[6]["TrainingTimeThree"].ToString(); } else { WindowClass.WindowBack("Failed to acquire the algorithm training time information."); } // Pull History DataSet pullHistoryDS = pullHistoryBll.GetAllList(); if (pullHistoryDS.Tables[0].Rows.Count != 0) { pullHistoryOne.Text = pullHistoryDS.Tables[0].Rows[4]["PullDate"].ToString(); // The earilier pullHistoryTwo.Text = pullHistoryDS.Tables[0].Rows[3]["PullDate"].ToString(); pullHistoryThree.Text = pullHistoryDS.Tables[0].Rows[2]["PullDate"].ToString(); pullHistoryFour.Text = pullHistoryDS.Tables[0].Rows[1]["PullDate"].ToString(); pullHistoryFive.Text = pullHistoryDS.Tables[0].Rows[0]["PullDate"].ToString(); // The latest TotalNumOne.Text = pullHistoryDS.Tables[0].Rows[4]["NumOfTotal"].ToString(); TotalNumTwo.Text = pullHistoryDS.Tables[0].Rows[3]["NumOfTotal"].ToString(); TotalNumThree.Text = pullHistoryDS.Tables[0].Rows[2]["NumOfTotal"].ToString(); TotalNumFour.Text = pullHistoryDS.Tables[0].Rows[1]["NumOfTotal"].ToString(); TotalNumFive.Text = pullHistoryDS.Tables[0].Rows[0]["NumOfTotal"].ToString(); } else { WindowClass.WindowBack("Failed to acquire the pulling history."); } DataSet spamDS = tweetsListBll.GetSpamTweetsNumber("spammer"); if (spamDS.Tables[0].Rows.Count != 0) { numOfSpams.Text = spamDS.Tables[0].Rows[0][0].ToString(); } DataSet nonSpamDS = tweetsListBll.GetSpamTweetsNumber("non-spammer"); if (nonSpamDS.Tables[0].Rows.Count != 0) { numOfNonSpams.Text = nonSpamDS.Tables[0].Rows[0][0].ToString(); } DataSet totalDS = tweetsListBll.GetTotalNumber(); if (totalDS.Tables[0].Rows.Count != 0) { numOfUndetected.Text = (int.Parse(totalDS.Tables[0].Rows[0][0].ToString()) - int.Parse(spamDS.Tables[0].Rows[0][0].ToString()) - int.Parse(nonSpamDS.Tables[0].Rows[0][0].ToString())).ToString(); } /* * DataSet c50SpamDS = tweetsListBll.GetSpamTweetsCFiveO("spammer"); * if (c50SpamDS.Tables[0].Rows.Count != 0) * { * numOfSpams.Text = c50SpamDS.Tables[0].Rows[0][0].ToString(); * } * * DataSet c50NonSpamDS = tweetsListBll.GetSpamTweetsCFiveO("non-spammer"); * if (c50NonSpamDS.Tables[0].Rows.Count != 0) * { * numOfNonSpams.Text = c50NonSpamDS.Tables[0].Rows[0][0].ToString(); * } * DataSet totalDS = tweetsListBll.GetTotalNumber(); * if (totalDS.Tables[0].Rows.Count != 0) * { * numOfUndetected.Text = (int.Parse(totalDS.Tables[0].Rows[0][0].ToString()) - int.Parse(c50SpamDS.Tables[0].Rows[0][0].ToString()) - int.Parse(c50NonSpamDS.Tables[0].Rows[0][0].ToString())).ToString(); * } */ }
protected void DataPulling_Click(object sender, EventArgs e) { GetMostRecent200HomeTimeLine(); //Random ra = new Random(); //string fileExtentionName = "log"; //string tweetsLogFileSubFolder = DateTime.Now.Year + "_" + DateTime.Now.Month; //string tweetsLogFileName = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + ra.Next(1, 100) + "." + fileExtentionName.ToString(); //string tweetsLogFilePath = Server.MapPath("../Temp/") + tweetsLogFileSubFolder + "/"; //if (!System.IO.Directory.Exists(tweetsLogFilePath)) //{ // System.IO.Directory.CreateDirectory(tweetsLogFilePath); //} // Check how many urls the tweet content containts. string urlPatten = @"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)"; tweetListForTXT = new List <string>(); for (int i = 0; i < tweetList.Count; i++) { string singleTweet = tweetList[i]; string[] temp = singleTweet.Split(','); // Check whether this tweets has been stored in the database already. if (tweetsListBll.ExistsByStatusID(temp[0])) { j++; // Record the number of repeated tweets. continue; } string tweetContentText = temp[temp.Length - 1]; // Get the last item of the array which is the tweet content. string content = tweetContentText.Trim(); string contentWithoutURL = ""; string[] contentTemp = content.Split(' '); numberOfURL = 0; numberOfChar = 0; numberOfChar = 0; for (int j = 0; j < contentTemp.Length; j++) { Regex regex = new Regex(urlPatten); Match m = regex.Match(contentTemp[j]); if (m.Success) { numberOfURL++; } else { contentWithoutURL = contentWithoutURL + contentTemp[j]; } } for (int j = 0; j < contentWithoutURL.Length; j++) { if (Char.IsDigit(contentWithoutURL, j)) { numberOfDigit++; } if (Char.IsLetter(contentWithoutURL, j)) { numberOfChar++; } } TimeSpan timeSpan = DateTime.Now.Subtract(DateTime.Parse(temp[2])).Duration(); timeDifference = timeSpan.Days.ToString(); // Select 13 features // tweetListForTXT.Add(timeDifference + "," // account_age counted in days. // + temp[3] + "," // + temp[4] + "," // + temp[5] + "," // + temp[6] + "," // + temp[7] + "," // + temp[8] + "," // + temp[9] + "," // + temp[10] + "," // + temp[11] + "," // + numberOfURL.ToString() + "," // + numberOfChar.ToString() + "," // + numberOfDigit.ToString() + " "); // Insert data to database tweetsListModel.ID = Guid.NewGuid().ToString().ToLower(); tweetsListModel.StatusID = temp[0]; // The unique ID for tweets. tweetsListModel.CreatedByUser = temp[1]; tweetsListModel.AccountCreatedDate = DateTime.Parse(temp[2]); tweetsListModel.AccountAge = timeDifference; tweetsListModel.FollowersCount = temp[3]; tweetsListModel.FriendsCount = temp[4]; tweetsListModel.FavoritesCount = temp[5]; // Number of favorites tweetsListModel.ListedCount = temp[6]; tweetsListModel.StatusesCount = temp[7]; tweetsListModel.RetweetCount = temp[8]; tweetsListModel.FavoriteCount = temp[9]; tweetsListModel.HashTapsCount = temp[10]; tweetsListModel.UserMentionsCount = temp[11]; tweetsListModel.TweetCreatedDate = DateTime.Parse(temp[12]); tweetsListModel.UrlsCount = numberOfURL.ToString(); tweetsListModel.NumberOfChar = numberOfChar.ToString(); tweetsListModel.NumberOfDigits = numberOfDigit.ToString(); tweetsListModel.TweetContent = temp[13]; // Store each pulled tweet. error = tweetsListBll.Add(tweetsListModel); } if (error == "") { pulledData = (numberOfTweetsFetched - j).ToString(); DataSet totalTweetsDS = tweetsListBll.GetTotalNumber(); if (totalTweetsDS.Tables[0].Rows.Count != 0) { totalNumTweets = totalTweetsDS.Tables[0].Rows[0][0].ToString(); } // Store the pulling action in db. pullhistoryModel.ID = Guid.NewGuid().ToString().ToLower(); pullhistoryModel.UserID = User.ID; pullhistoryModel.NumOfPull = pulledData; // How many non-repeated data is pulled. pullhistoryModel.IsSuccessful = 1; // 1 means a successful pull of data from twitter account. pullhistoryModel.PullDate = DateTime.Now; pullhistoryModel.NumOfTotal = totalNumTweets; pulledError = pullhistoryBll.Add(pullhistoryModel); if (pulledError == "") { DataPullingIndication.Text = "Successfully pulled " + pulledData + " latest tweets from your twitter timeline at " + pullhistoryModel.PullDate + "."; } else { WindowClass.WindowBack(pulledError); } } else { WindowClass.WindowBack(error); } //File.WriteAllLines(tweetsLogFilePath + tweetsLogFileName, tweetListForTXT); }