/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// ----------------------------------------------------------------------------- protected void Page_Load(object sender, System.EventArgs e) { try { errorMessage = ""; topcmm_123flashchatController objtopcmm_123flashchats = new topcmm_123flashchatController();// One23FlashChatController(); List<topcmm_123flashchatInfo> coltopcmm_123flashchats; // get the content from the One23FlashChat table coltopcmm_123flashchats = objtopcmm_123flashchats.Gettopcmm_123flashchats(ModuleId); if (coltopcmm_123flashchats.Count == 0) { // add the content to the One23FlashChat table topcmm_123flashchatInfo objtopcmm_123flashchat = new topcmm_123flashchatInfo();// One23FlashChatInfo(); objtopcmm_123flashchat.ModuleId = ModuleId; objtopcmm_123flashchat.Content = System.Web.HttpUtility.HtmlDecode(Localization.GetString("DefaultContent", LocalResourceFile)); objtopcmm_123flashchat.CreatedByUser = this.UserId; objtopcmm_123flashchats.Addtopcmm_123flashchat(objtopcmm_123flashchat); // get the content from the One23FlashChat table coltopcmm_123flashchats = objtopcmm_123flashchats.Gettopcmm_123flashchats(ModuleId); } foreach (topcmm_123flashchatInfo a in coltopcmm_123flashchats) { //if(a.Content.Contains ("<")&&a.Content.Contains ("</" string strContent = System.Web.HttpUtility.HtmlDecode(a.Content); if (System.Text.RegularExpressions.Regex.IsMatch(strContent, @"<.*>.*</.*>")) { a.Content = strContent; } else a.Content = "<room type=\"1\" value=\"1\">default room</room>"; } id = coltopcmm_123flashchats[0].ItemId.ToString (); HyperLink1.NavigateUrl = EditUrl("ItemID", id); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml(coltopcmm_123flashchats[0].Content); XmlElement root = xmlD.DocumentElement; typeID = root.Attributes["type"].Value; if (typeID == "1") { string[] strsInfor = RoomsAndChaters.GetInformation(RoomsAndChaters.GetServerDataPath()); if (strsInfor.Length == 1||strsInfor.Length ==0) { outPutStr = "Error to read information of 123flashchat.Please check up configuration in the Edit Page"; hlkEach.Visible = false; } else { roomCount = strsInfor[2]; connections = strsInfor[0]; loginUser = strsInfor[1]; userList = RoomsAndChaters.GetChatterList(RoomsAndChaters.GetServerDataPath()); outPutStr = "There are <b>" + roomCount + "</b> rooms <br/>" + "There are <b>" + connections + "</b> connections <br/>" + "There are <b>" + loginUser + "</b> logon users<br/>" + "User List:" + userList; hlkEach.NavigateUrl = ResolveUrl("123FlashChatPanel.aspx"); } } else if (typeID == "2")//free { outPutStr = root.Attributes["value"].Value.Substring (root.Attributes["value"].Value.LastIndexOf ("/")+1); hlkEach.NavigateUrl = ResolveUrl("123FlashChatHostAndFree.aspx") + "?initurl=" + root.Attributes["value"].Value + "&type=2"; } else if (typeID == "3")//host { outPutStr = root.Attributes["value"].Value; hlkEach.NavigateUrl = ResolveUrl("123FlashChatPanel.aspx") + "?type=3"; } HyperLink1.Visible = IsEditable; Image1.Visible = IsEditable; } catch (System.Net.WebException eWeb) { Exceptions.ProcessModuleLoadException("friendly",this,eWeb ,false ); errorMessage = "Can't connect to 123flashchat server.Please try again later"; } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void Page_Load(object sender, System.EventArgs e) { try { // Determine ItemId of topcmm_123flashchat to Update if ((Request.QueryString["ItemId"] != null)) { ItemId = Int32.Parse(Request.QueryString["ItemId"]); } // If this is the first visit to the page, bind the role data to the datalist if (Page.IsPostBack == false) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); if (!Null.IsNull(ItemId)) { // get content topcmm_123flashchatController objtopcmm_123flashchats = new topcmm_123flashchatController(); topcmm_123flashchatInfo objtopcmm_123flashchat = objtopcmm_123flashchats.Gettopcmm_123flashchat(ModuleId, ItemId); if ((objtopcmm_123flashchat != null)) { string strContent = System.Web.HttpUtility.HtmlDecode(objtopcmm_123flashchat.Content); if (System.Text.RegularExpressions.Regex.IsMatch(strContent, @"<.*>.*</.*>")) { objtopcmm_123flashchat.Content = strContent; } else objtopcmm_123flashchat.Content = "<room type=\"1\" value=\"1\">default room</room>"; XmlDocument xmlD = new XmlDocument(); string decoderContent = HttpUtility.HtmlDecode(objtopcmm_123flashchat.Content); xmlD.LoadXml(decoderContent); XmlElement root = xmlD.DocumentElement; //╪стьxml XmlAttribute xatType = root.Attributes["type"]; if (xatType != null) { if (xatType.Value == "1") { //Dictionary<int, string> rooms = RoomsAndChaters.GetRooms(); //if (rooms.Count > 0) //{ // foreach (KeyValuePair<int, string> eachKeyValue in rooms) // { // ListItem newListItem = new ListItem(eachKeyValue.Value, eachKeyValue.Key.ToString()); // ddlRooms.Items.Add(newListItem); // } // ddlRooms.SelectedIndex = 0; //} ddlType.SelectedIndex = 0; string valueItem = root.Attributes["value"].Value; //ddlRooms.SelectedIndex = ddlRooms.Items.IndexOf(ddlRooms.Items.FindByValue(valueItem)); tbxAddress.Text = RoomsAndChaters.GetServerPath(); } else if (xatType.Value == "2") { ddlType.SelectedIndex = 1; string valueItem = root.Attributes["value"].Value; tbxFreeName.Text = root.InnerText; //tbxFree.Text = valueItem; } else if (xatType.Value == "3") { ddlType.SelectedIndex = 2; string valueItem = root.Attributes["value"].Value; tbxHostName.Text = root.InnerText; tbxHost.Text = valueItem; } } else { ddlType.SelectedIndex = 0; } //string valueItem = root.Name.Substring(1); //decoderContent.Substring(1, decoderContent.IndexOf('>') - 1); ctlAudit.CreatedByUser = objtopcmm_123flashchat.CreatedByUserName; ctlAudit.CreatedDate = objtopcmm_123flashchat.CreatedDate.ToString(); } else { // security violation attempt to access item not related to this Module Response.Redirect(Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; ctlAudit.Visible = false; } } //serverTempPath = tbxAddress.Text; } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdDelete_Click runs when the delete button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void cmdDelete_Click(object sender, EventArgs e) { try { // Only attempt to delete the item if it exists already if (!Null.IsNull(ItemId)) { topcmm_123flashchatController objtopcmm_123flashchats = new topcmm_123flashchatController(); objtopcmm_123flashchats.Deletetopcmm_123flashchat(ModuleId, ItemId); } // Redirect back to the portal home page Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdUpdate_Click runs when the update button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void cmdUpdate_Click(object sender, EventArgs e) { try { topcmm_123flashchatController objtopcmm_123flashchats = new topcmm_123flashchatController(); topcmm_123flashchatInfo objtopcmm_123flashchat = new topcmm_123flashchatInfo(); XmlDocument xmlD = new XmlDocument(); xmlD.LoadXml("<room></room>"); XmlElement root = xmlD.DocumentElement; if (ddlType.SelectedValue == "1") { XmlAttribute xatNodeValue = xmlD.CreateAttribute("value"); XmlAttribute xatNodeType = xmlD.CreateAttribute("type"); xatNodeType.Value = ddlType.SelectedValue; root.Attributes.Append(xatNodeValue); root.Attributes.Append(xatNodeType); } else if (ddlType.SelectedValue == "2") //free { root.InnerText = tbxFreeName.Text.Trim(); XmlAttribute xatNodeValue = xmlD.CreateAttribute("value"); xatNodeValue.Value = "http://free.123flashchat.com/room/" + tbxFreeName.Text.Trim();//tbxFree.Text.Trim(); XmlAttribute xatNodeType = xmlD.CreateAttribute("type"); xatNodeType.Value = ddlType.SelectedValue; root.Attributes.Append(xatNodeValue); root.Attributes.Append(xatNodeType); } else if (ddlType.SelectedValue == "3") //host { root.InnerText = tbxHostName.Text.Trim(); XmlAttribute xatNodeValue = xmlD.CreateAttribute("value"); string valueUrl = tbxHost.Text.Trim(); if (valueUrl[valueUrl.Length - 1] == '/') { valueUrl = valueUrl.Substring(0, valueUrl.Length - 1); } xatNodeValue.Value = valueUrl; WebClient wc = new WebClient(); string result = wc.DownloadString(valueUrl); Match matchEmbed = Regex.Match(result, "(?<=<EMBED\\s+src=\").*?(?=\")", RegexOptions.IgnoreCase | RegexOptions.Multiline); Match matchParam = Regex.Match(result, "(?<=<PARAM.*VALUE=\")http.*(?=\")", RegexOptions.IgnoreCase | RegexOptions.Multiline); Match matchvar = Regex.Match(result, "(?<=var.*=\")http.*(?=\")", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (matchParam.Captures.Count > 0) { string urlParam = matchParam.Value; RoomsAndChaters.setChatUrl(urlParam); } else if (matchEmbed.Captures.Count > 0) { string urlEmbed = matchEmbed.Value; RoomsAndChaters.setChatUrl(urlEmbed); } else if (matchvar.Captures.Count > 0) { string urlVar = matchvar.Value; RoomsAndChaters.setChatUrl(urlVar); } XmlAttribute xatNodeType = xmlD.CreateAttribute("type"); xatNodeType.Value = ddlType.SelectedValue; root.Attributes.Append(xatNodeValue); root.Attributes.Append(xatNodeType); } objtopcmm_123flashchat.ModuleId = ModuleId; objtopcmm_123flashchat.ItemId = ItemId; objtopcmm_123flashchat.Content = xmlD.InnerXml; objtopcmm_123flashchat.CreatedByUser = this.UserId; if (Null.IsNull(ItemId)) { // add the content within the topcmm_123flashchat table objtopcmm_123flashchats.Addtopcmm_123flashchat(objtopcmm_123flashchat); } else { // update the content within the topcmm_123flashchat table objtopcmm_123flashchats.Updatetopcmm_123flashchat(objtopcmm_123flashchat); } Response.Redirect(Globals.NavigateURL(), true); } catch (WebException we) { labelHost.Text = "Sorry,can't connect to this address"; } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }