public List <TTopic> getArchivedTopics(string course_id) { //--Data Base Access Variables-- System.Data.OleDb.OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); System.Data.OleDb.OleDbCommand dbCommand = new OleDbCommand(); dbCommand.Connection = dbConnection; System.Data.OleDb.OleDbDataReader dbDataReader; //------------------------------ dbCommand.CommandText = "SELECT * FROM Topics WHERE course_id = '" + course_id + "' AND finishDateTime IS NOT NULL"; dbConnection.Close(); dbConnection.Open(); dbDataReader = dbCommand.ExecuteReader(); TTopic tTopicAux; List <TTopic> startedTopics = new List <TTopic>(); while (dbDataReader.Read()) { tTopicAux = new TTopic(getCourse(dbDataReader["course_id"].ToString()), dbDataReader["title"].ToString()); tTopicAux.id = Convert.ToInt32(dbDataReader["id"]); tTopicAux.starterTeacher = getUser(dbDataReader["starterTeacher"].ToString()); tTopicAux.startDateTime = Convert.ToDateTime(dbDataReader["startDateTime"]); tTopicAux.finishDateTime = Convert.ToDateTime(dbDataReader["finishDateTime"]); startedTopics.Add(tTopicAux); } dbDataReader.Close(); dbConnection.Close(); return(startedTopics); }
public void finishTopic(TTopic tTopic) { //--Data Base Access Variables-- System.Data.OleDb.OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); System.Data.OleDb.OleDbCommand dbCommand = new OleDbCommand(); dbCommand.Connection = dbConnection; System.Data.OleDb.OleDbTransaction dbTransaction; //----------------------------- dbConnection.Close(); dbConnection.Open(); dbTransaction = dbConnection.BeginTransaction(); dbCommand.Transaction = dbTransaction; try { //---Begin Transaction--- tTopic.finishDateTime = DateTime.Now; //UPDATE Topic dbCommand.CommandText = "UPDATE Topics SET finishDateTime = '" + tTopic.finishDateTime.ToString() + "' WHERE id = " + tTopic.id.ToString(); dbCommand.ExecuteNonQuery();; dbTransaction.Commit(); //----End Transaction---- } catch { dbTransaction.Rollback(); dbCommand.Transaction = null; dbTransaction = null; dbConnection.Close(); } dbCommand.Transaction = null; dbTransaction = null; dbConnection.Close(); }
public List <TTopic> getStartedTopics(string user_id) { //--Data Base Access Variables-- System.Data.OleDb.OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); System.Data.OleDb.OleDbCommand dbCommand = new OleDbCommand(); dbCommand.Connection = dbConnection; System.Data.OleDb.OleDbDataReader dbDataReader; //------------------------------ dbCommand.CommandText = "SELECT * FROM Topics INNER JOIN User_Course_Group ON User_Course_Group.course_id = Topics.course_id AND User_Course_Group.group_id = Topics.group_id WHERE (User_Course_Group.user_id = '" + user_id + "') AND (Topics.finishDateTime IS NULL)"; /*AND (User_Course_Group.is_current = True)*/ dbConnection.Close(); dbConnection.Open(); dbDataReader = dbCommand.ExecuteReader(); TTopic tTopicAux; List <TTopic> startedTopics = new List <TTopic>(); while (dbDataReader.Read()) { tTopicAux = new TTopic(getCourse(dbDataReader["Topics.course_id"].ToString()), dbDataReader["title"].ToString()); tTopicAux.id = Convert.ToInt32(dbDataReader["id"]); tTopicAux.starterTeacher = getUser(dbDataReader["starterTeacher"].ToString()); tTopicAux.startDateTime = Convert.ToDateTime(dbDataReader["startDateTime"]); startedTopics.Add(tTopicAux); } dbDataReader.Close(); dbConnection.Close(); return(startedTopics); }
protected void btnEnterStartedTopic_Click(object sender, EventArgs e) { if (lbStartedTopics.SelectedIndex >= 0) { List <TTopic> listTTopic = (List <TTopic>)Session["startedTopics"]; TTopic tTopic = null; int tTopicId = Convert.ToInt32(lbStartedTopics.SelectedValue); for (int count = 0; count < listTTopic.Count; count++) { tTopic = listTTopic[count]; if (tTopic.id == tTopicId) { break; } } TUser tUser = (TUser)Session["user"]; //Insert in DATABASE DbControl.getInstance().enterTopic(tUser, tTopic); Application["updateAvaiable_" + tTopic.id.ToString()] = Convert.ToInt32(Application["updateAvaiable_" + tTopic.id.ToString()]) + 1; //Notify everybody that a new user entered Session["updateAvaiable"] = Convert.ToInt32(Application["updateAvaiable_" + tTopic.id.ToString()]); Response.Redirect("topic.aspx"); } else { Response.Write("<script>alert('Please, select a topic to enter!');</script>"); } }
internal NTopic(TTopic message) { Topic = new NTopicId(message.Topic); Presences = new List <INUserPresence>(); foreach (var presence in message.Presences) { Presences.Add(new NUserPresence(presence)); } Self = new NUserPresence(message.Self); }
public TTopic createTopic(TUser tUserStarter, TCourse tCourse, string title) { //--Data Base Access Variables-- System.Data.OleDb.OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); System.Data.OleDb.OleDbCommand dbCommand = new OleDbCommand(); dbCommand.Connection = dbConnection; System.Data.OleDb.OleDbDataReader dbDataReader; System.Data.OleDb.OleDbTransaction dbTransaction; //----------------------------- dbConnection.Close(); dbConnection.Open(); dbTransaction = dbConnection.BeginTransaction(); dbCommand.Transaction = dbTransaction; TTopic tTopic = new TTopic(tCourse, title); try { //Begin Transaction tTopic.startDateTime = DateTime.Now; tTopic.starterTeacher = tUserStarter; dbCommand.CommandText = "INSERT INTO Topics (course_id, group_id, title, startDateTime, starterTeacher) VALUES('" + tTopic.tCourse.id + "', '" + tTopic.tCourse.groupId + "', '" + tTopic.title + "', '" + tTopic.startDateTime.ToString() + "', '" + tUserStarter.id + "')"; dbCommand.ExecuteNonQuery(); dbCommand.CommandText = "SELECT * FROM Topics WHERE (course_id = '" + tTopic.tCourse.id + "') AND (group_id = '" + tTopic.tCourse.groupId + "') AND (title = '" + tTopic.title + "') AND (startDateTime = '" + tTopic.startDateTime.ToString() + "')"; dbDataReader = dbCommand.ExecuteReader(); dbDataReader.Read(); tTopic.id = Convert.ToInt32(dbDataReader["id"]); dbDataReader.Close(); dbTransaction.Commit(); //End Transaction } catch { dbTransaction.Rollback(); dbCommand.Transaction = null; dbTransaction = null; dbConnection.Close(); return(null); } dbCommand.Transaction = null; dbTransaction = null; dbDataReader.Close(); dbConnection.Close(); return(tTopic); }
public void enterTopic(TUser tUser, TTopic tTopic) { //--Data Base Access Variables-- System.Data.OleDb.OleDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); System.Data.OleDb.OleDbCommand dbCommand = new OleDbCommand(); dbCommand.Connection = dbConnection; System.Data.OleDb.OleDbTransaction dbTransaction; System.Data.OleDb.OleDbDataReader dbDataReader; //----------------------------- dbConnection.Close(); dbConnection.Open(); dbTransaction = dbConnection.BeginTransaction(); dbCommand.Transaction = dbTransaction; try { //Begin Transaction //Verify if the user is already on-line dbCommand.CommandText = "SELECT * FROM User_Topic WHERE user_id = '" + tUser.id + "' AND finishDateTime IS NULL"; dbDataReader = dbCommand.ExecuteReader(); if (dbDataReader.HasRows) { dbDataReader.Close(); dbCommand.CommandText = "UPDATE User_Topic SET finishDateTime = '" + DateTime.Now.ToString() + "' WHERE user_id = '" + tUser.id + "' AND finishDateTime IS NULL"; dbCommand.ExecuteNonQuery(); } dbDataReader.Close(); dbCommand.CommandText = "INSERT INTO User_Topic (user_id, topic_id, startDateTime) VALUES ('" + tUser.id + "', '" + tTopic.id + "', '" + DateTime.Now.ToString() + "')"; dbCommand.ExecuteNonQuery(); tUser.topic = tTopic; dbTransaction.Commit(); //End Transaction } catch { dbTransaction.Rollback(); dbCommand.Transaction = null; dbTransaction = null; dbConnection.Close(); } dbCommand.Transaction = null; dbTransaction = null; dbConnection.Close(); }
protected void btnJustStartTopic_Click(object sender, EventArgs e) { List <TCourse> listTCourse = (List <TCourse>)Session["currentCourses"]; TCourse tCourse = null; string tCourseId = lbCurrentCourses.SelectedValue; for (int count = 0; count < listTCourse.Count; count++) { tCourse = listTCourse[count]; if (tCourse.id == tCourseId) { break; } } TUser tUser = (TUser)Session["user"]; //Insert in DATABASE TTopic tTopic = DbControl.getInstance().createTopic(tUser, tCourse, tbTopicTitle.Text); addContentToLbStartedTopics(tUser.id); btnCancelTopic_Click(sender, e); }
protected void btnStartAndEnterTopic_Click(object sender, EventArgs e) { List <TCourse> listTCourse = (List <TCourse>)Session["currentCourses"]; TCourse tCourse = null; string tCourseId = lbCurrentCourses.SelectedValue; for (int count = 0; count < listTCourse.Count; count++) { tCourse = listTCourse[count]; if (tCourse.id == tCourseId) { break; } } TUser tUser = (TUser)Session["user"]; //Insert in DATABASE TTopic tTopic = DbControl.getInstance().createTopic(tUser, tCourse, tbTopicTitle.Text); Application["updateAvaiable_" + tTopic.id.ToString()] = 0; Session["updateAvaiable"] = 0; DbControl.getInstance().enterTopic(tUser, tTopic); Response.Redirect("topic.aspx"); }
public void A_Insert() { wojiluOrmTestInit.ClearLog(); wojiluOrmTestInit.InitMetaData(); ConsoleTitleUtil.ShowTestTitle( "Insert" ); //wojilu.file.Delete( "log.txt" ); // �˴�Ӧ���������������� // Ȼ��������������ݣ�ͬʱ����insert sql������Id��ֵ�� // �ܹ����46������ for (int i = 0; i < 20; i++) { // �ڲ������ݵ�ʱ��̬����û���ر���Ҫע��� TPostCategory pcat = new TPostCategory(); pcat.Name = "post���ӷ���"; pcat.Hits = new Random().Next( 1, 100 ); db.insert( pcat ); Assert.Greater( pcat.Id, 0 ); TTopicCategory tcat = new TTopicCategory(); tcat.Name = "topic�������"; tcat.ReplyCount = new Random().Next( 1, 200 ); db.insert( tcat ); Assert.Greater( tcat.Id, 0 ); TPost post = new TPost(); post.Title = "post_34��������Ա�����º�"; post.Body = "ϣ����Ĺ�ȥ�ķ����ִ�Y��¯�ĒY���_��"; post.Uid = "����"; post.Category = pcat; // ��̬������� post.Hits = new Random().Next(); db.insert( post ); Assert.Greater( post.Id, 0 ); TTopic topic = new TTopic(); topic.Title = "topic_������������"; topic.Body = "�����ƺ�����֣��������Ȼ�Dz���˵�ġ����Ǻ�������˵�����ܡ������һ�����䡣"; topic.Uid = "����"; topic.Category = tcat; topic.Hits = new Random().Next( 34, 10039343 ); topic.ReplyCount = 3; db.insert( topic ); Assert.Greater( topic.Id, 0 ); } for (int i = 0; i < 3; i++) { // ����������ӣ�����������ƺ����ӷ���������ͬ������������Ե�ʱ���Ƿ�Ҳ�ڶ�̬��ѯ����� TTopicCategory tcatfake = new TTopicCategory(); tcatfake.Name = "zzTopic���ӷ���"; tcatfake.ReplyCount = new Random().Next( 1, 200 ); db.insert( tcatfake ); Assert.Greater( tcatfake.Id, 0 ); TTopic topicfake = new TTopic(); topicfake.Title = "zzTopic������������"; topicfake.Body = "�����ƺ�����֣��������Ȼ�Dz���˵�ġ����Ǻ�������˵�����ܡ������һ�����䡣"; topicfake.Uid = "����"; topicfake.Category = tcatfake; topicfake.Hits = new Random().Next( 34, 10039343 ); topicfake.ReplyCount = 3; db.insert( topicfake ); Assert.Greater( topicfake.Id, 0 ); // ֱ����Ӹ���ľ������� TCategory category = new TCategory(); category.Name = "post���ӷ���"; db.insert( category ); TDataRoot root = new TDataRoot(); root.Title = "zzParent���Ǹ���֮init��ʼ��"; root.Body = "���������֮init��ʼ��"; root.Category = category; db.insert( root ); } insertAbstractTest(); }
public void A_Insert() { wojiluOrmTestInit.ClearLog(); wojiluOrmTestInit.InitMetaData(); ConsoleTitleUtil.ShowTestTitle("Insert"); //wojilu.file.Delete( "log.txt" ); // 此处应该先向基类添加数据 // 然后向子类添加数据(同时调整insert sql,插入Id的值) // 总共添加46条数据 for (int i = 0; i < 20; i++) { // 在插入数据的时候,多态关联没有特别需要注意的 TPostCategory pcat = new TPostCategory(); pcat.Name = "post帖子分类"; pcat.Hits = new Random().Next(1, 100); db.insert(pcat); Assert.Greater(pcat.Id, 0); TTopicCategory tcat = new TTopicCategory(); tcat.Name = "topic主题分类"; tcat.ReplyCount = new Random().Next(1, 200); db.insert(tcat); Assert.Greater(tcat.Id, 0); TPost post = new TPost(); post.Title = "post_34名美国议员联名致函"; post.Body = "希腊深化的过去的发恩持大扽肯炉衬扽拉歘称"; post.Uid = "张三"; post.Category = pcat; // 多态关联添加 post.Hits = new Random().Next(); db.insert(post); Assert.Greater(post.Id, 0); TTopic topic = new TTopic(); topic.Title = "topic_我是主题帖子"; topic.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。"; topic.Uid = "李四"; topic.Category = tcat; topic.Hits = new Random().Next(34, 10039343); topic.ReplyCount = 3; db.insert(topic); Assert.Greater(topic.Id, 0); } for (int i = 0; i < 3; i++) { // 添加主题帖子,让其分类名称和帖子分类名称相同,便于下面测试的时候看是否也在多态查询结果中 TTopicCategory tcatfake = new TTopicCategory(); tcatfake.Name = "zzTopic帖子分类"; tcatfake.ReplyCount = new Random().Next(1, 200); db.insert(tcatfake); Assert.Greater(tcatfake.Id, 0); TTopic topicfake = new TTopic(); topicfake.Title = "zzTopic我是主题帖子"; topicfake.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。"; topicfake.Uid = "李四"; topicfake.Category = tcatfake; topicfake.Hits = new Random().Next(34, 10039343); topicfake.ReplyCount = 3; db.insert(topicfake); Assert.Greater(topicfake.Id, 0); // 直接添加父类的具体数据 TCategory category = new TCategory(); category.Name = "post帖子分类"; db.insert(category); TDataRoot root = new TDataRoot(); root.Title = "zzParent我是父类之init初始化"; root.Body = "父类的内容之init初始化"; root.Category = category; db.insert(root); } insertAbstractTest(); }
public void A_Insert() { wojiluOrmTestInit.ClearLog(); wojiluOrmTestInit.InitMetaData(); ConsoleTitleUtil.ShowTestTitle( "Insert" ); //wojilu.file.Delete( "log.txt" ); // 此处应该先向基类添加数据 // 然后向子类添加数据(同时调整insert sql,插入Id的值) // 总共添加46条数据 for (int i = 0; i < 20; i++) { // 在插入数据的时候,多态关联没有特别需要注意的 TPostCategory pcat = new TPostCategory(); pcat.Name = "post帖子分类"; pcat.Hits = new Random().Next( 1, 100 ); db.insert( pcat ); Assert.Greater( pcat.Id, 0 ); TTopicCategory tcat = new TTopicCategory(); tcat.Name = "topic主题分类"; tcat.ReplyCount = new Random().Next( 1, 200 ); db.insert( tcat ); Assert.Greater( tcat.Id, 0 ); TPost post = new TPost(); post.Title = "post_34名美国议员联名致函"; post.Body = "希腊深化的过去的发恩持大扽肯炉衬扽拉歘称"; post.Uid = "张三"; post.Category = pcat; // 多态关联添加 post.Hits = new Random().Next(); db.insert( post ); Assert.Greater( post.Id, 0 ); TTopic topic = new TTopic(); topic.Title = "topic_我是主题帖子"; topic.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。"; topic.Uid = "李四"; topic.Category = tcat; topic.Hits = new Random().Next( 34, 10039343 ); topic.ReplyCount = 3; db.insert( topic ); Assert.Greater( topic.Id, 0 ); } for (int i = 0; i < 3; i++) { // 添加主题帖子,让其分类名称和帖子分类名称相同,便于下面测试的时候看是否也在多态查询结果中 TTopicCategory tcatfake = new TTopicCategory(); tcatfake.Name = "zzTopic帖子分类"; tcatfake.ReplyCount = new Random().Next( 1, 200 ); db.insert( tcatfake ); Assert.Greater( tcatfake.Id, 0 ); TTopic topicfake = new TTopic(); topicfake.Title = "zzTopic我是主题帖子"; topicfake.Body = "标题似乎很奇怪,秘密嘛,自然是不能说的。于是乎“不能说的秘密”便成了一个病句。"; topicfake.Uid = "李四"; topicfake.Category = tcatfake; topicfake.Hits = new Random().Next( 34, 10039343 ); topicfake.ReplyCount = 3; db.insert( topicfake ); Assert.Greater( topicfake.Id, 0 ); // 直接添加父类的具体数据 TCategory category = new TCategory(); category.Name = "post帖子分类"; db.insert( category ); TDataRoot root = new TDataRoot(); root.Title = "zzParent我是父类之init初始化"; root.Body = "父类的内容之init初始化"; root.Category = category; db.insert( root ); } insertAbstractTest(); }
/// <summary> /// get song list by topic /// </summary> /// <param name="tTopic"></param> /// <returns></returns> public abstract Task <SongListContent> GetSongListAsync(TTopic tTopic);
public QueuedRequest(TaskCompletionSource <IEnumerable <IServerEvent> > source, TTopic topic) { Source = source; Topic = topic; }
protected void Page_Load(object sender, EventArgs e) { TUser tUser = (TUser)Session["user"]; //User not logged or SESSION EXPIRED if (tUser == null) { Response.Redirect("login.aspx"); } //MOSTRAR MENSAGEM DE NÃO LOGADO OU SESSÃO EXPIRADA if (!Page.IsPostBack) { strongName.InnerText = tUser.name; strongId.InnerText = tUser.id; TTopic tTopic = tUser.topic; //Verify that the USER is NOT in Course if (Session["inTopic"] == null || Convert.ToBoolean(Session["inTopic"]) == false) { content_top.Visible = false; aux_menu.Visible = false; } else { content_top.Visible = true; aux_menu.Visible = true; /* FINISH TOPIC INSIDE A TOPIC IS NO MORE POSSIBLE * if (tUser.isTeacher) * liFinishTopic.Visible = true; * else * liFinishTopic.Visible = false; */ liFinishTopic.Visible = false;//For how long? spanCourse.InnerText = tTopic.tCourse.id + " (" + tTopic.tCourse.groupId + ") - " + tTopic.title; spanStartTime.InnerText = "Started at " + tTopic.startDateTime.ToString(); //ForecastEnd - SUSPENDED FOR A WHILE spanForecastEnd.Visible = false; //strongForecastEnd.InnerText = ((tTopic.startDateTime.AddHours(2)).ToString()); //Responsable Teacher - SUSPENDED FOR A WHILE spanTeacher.Visible = false; /*if (tTopic.tCourse.responsableTeacher != null) * strongTeacher.InnerText = tTopic.tCourse.responsableTeacher.name; * else * spanTeacher.Visible = false;*/ } } if (Request["__EVENTTARGET"] == "leaveTopic") { if (Session["topicId"] != null) { Session.Remove("topicId"); DbControl.getInstance().exitTopic(tUser); } Response.Redirect("home.aspx"); } if (Request["__EVENTTARGET"] == "home") { Response.Redirect("home.aspx"); } if (Request["__EVENTTARGET"] == "myAccount") { Response.Redirect("account.aspx"); } if (Request["__EVENTTARGET"] == "finishTopic") { TTopic tTopic = tUser.topic; DbControl.getInstance().exitTopic(tUser); DbControl.getInstance().finishTopic(tTopic); Response.Redirect("home.aspx"); } }