private void crosspostSitesGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { CrosspostSite site = crosspostSites[e.Item.DataSetIndex]; site.ProfileName = ((TextBox)e.Item.FindControl("textProfileName")).Text; site.HostName = ((TextBox)e.Item.FindControl("textHostName")).Text; site.Port = int.Parse(((TextBox)e.Item.FindControl("textPort")).Text); site.Endpoint = ((TextBox)e.Item.FindControl("textEndpoint")).Text; site.Username = ((TextBox)e.Item.FindControl("textUsername")).Text; site.ApiType = ((DropDownList)e.Item.FindControl("listApiType")).SelectedValue; TextBox textPassword = ((TextBox)e.Item.FindControl("textPassword")); if (textPassword.Text.Length > 0) { site.Password = textPassword.Text; } // [email protected] 24-MAR-04 // Ensure the correct blog is selected from the ddl DropDownList allBlogNames = (DropDownList)e.Item.FindControl("listAllBlogNames"); if (allBlogNames != null && allBlogNames.SelectedItem.Text != null) { site.BlogName = allBlogNames.SelectedItem.Text; site.BlogId = ((TextBox)e.Item.FindControl(("textBlogId"))).Text; } crosspostSitesGrid.EditItemIndex = -1; DataBind(); changesAlert.Visible = true; }
private void crosspostSitesGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { crosspostSitesGrid.EditItemIndex = e.Item.ItemIndex; DataBind(); // [email protected] // Ensure the correct item in the blog names ddl is selected DropDownList allBlogNames = (DropDownList)crosspostSitesGrid.Items[e.Item.ItemIndex].FindControl("listAllBlogNames"); CrosspostSite site = crosspostSites[e.Item.ItemIndex]; // [email protected] // There seems to be an issue with Blogger and accounts with spaces in // as it sometimes results in two enties in this list split on the space char. // This ensures the page displays even when the list item is missing. if (allBlogNames.Items.FindByValue(site.BlogName) != null) { allBlogNames.SelectedValue = site.BlogName; } }
private void crosspostSitesGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "AddItem") { CrosspostSite newSite = new CrosspostSite(); newSite.ProfileName = "New Profile"; newSite.Port = 80; // luke@jurasource 24-MAR-04 // init all blog names newSite.AllBlogNames = new string[] { "" }; crosspostSites.Insert(0, newSite); crosspostSitesGrid.CurrentPageIndex = 0; crosspostSitesGrid.EditItemIndex = 0; BindGrid(); } else if (e.CommandName == "autoFill") { DropDownList dropDownList = (DropDownList)e.Item.FindControl("blogSoftware"); TextBox textHostName = (TextBox)e.Item.FindControl("textHostName"); TextBox textEndpoint = (TextBox)e.Item.FindControl("textEndpoint"); TextBox textBoxBlogURL = (TextBox)e.Item.FindControl("textBoxBlogURL"); DropDownList dropDownApi = (DropDownList)e.Item.FindControl("listApiType"); string rawBlogUrl = textBoxBlogURL.Text; rawBlogUrl = rawBlogUrl.Replace("http://", ""); string[] blogUrl = rawBlogUrl.Split('/'); textHostName.Text = blogUrl[0]; string endpoint = ""; for (int index = 1; index < blogUrl.Length; index++) { endpoint += "/" + blogUrl[index]; } CrossPostServerInfo currentInfo = (CrossPostServerInfo)crossPostServerInfo.GetValue(dropDownList.SelectedIndex); if (endpoint.Length != 0 && endpoint.EndsWith("/") == false) { endpoint += "/"; } textEndpoint.Text = endpoint + currentInfo.Endpoint; dropDownApi.SelectedIndex = currentInfo.Service; } else if (e.CommandName == "testConnection") { Label labelTestError; labelTestError = ((Label)e.Item.FindControl("labelTestError")); labelTestError.Text = ""; try { TextBox textBlogName; TextBox textPassword; CrosspostSite site = crosspostSites[e.Item.DataSetIndex]; site.ProfileName = ((TextBox)e.Item.FindControl("textProfileName")).Text; site.HostName = ((TextBox)e.Item.FindControl("textHostName")).Text; site.Port = int.Parse(((TextBox)e.Item.FindControl("textPort")).Text); site.Endpoint = ((TextBox)e.Item.FindControl("textEndpoint")).Text; site.Username = ((TextBox)e.Item.FindControl("textUsername")).Text; site.ApiType = ((DropDownList)e.Item.FindControl("listApiType")).SelectedValue; textPassword = ((TextBox)e.Item.FindControl("textPassword")); if (textPassword.Text.Length > 0) { site.Password = textPassword.Text; } textBlogName = ((TextBox)e.Item.FindControl("textBlogName")); UriBuilder uriBuilder = new UriBuilder("http", site.HostName, site.Port, site.Endpoint); BloggerAPIClientProxy proxy = new BloggerAPIClientProxy(); proxy.Url = uriBuilder.ToString(); proxy.UserAgent = "newtelligence dasBlog/1.4"; bgBlogInfo[] blogInfos = proxy.blogger_getUsersBlogs("", site.Username, site.Password); if (blogInfos.Length > 0) { // [email protected] 24-MAR-04 // refresh all the blog names for this crosspost site string[] allBlogNames = new string[blogInfos.Length]; for (int blog = 0; blog < blogInfos.Length; blog++) { allBlogNames[blog] = blogInfos[blog].blogName; } site.AllBlogNames = allBlogNames; // Default the crosspost blog to the first one site.BlogName = textBlogName.Text = blogInfos[0].blogName; site.BlogId = blogInfos[0].blogid; } BindGrid(); } catch (Exception exc) { labelTestError.Text = exc.Message; } finally { } } }
private void crosspostSitesGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if ( e.CommandName == "AddItem" ) { CrosspostSite newSite = new CrosspostSite(); newSite.ProfileName = "New Profile"; newSite.Port=80; // luke@jurasource 24-MAR-04 // init all blog names newSite.AllBlogNames = new string[]{""}; crosspostSites.Insert(0,newSite); crosspostSitesGrid.CurrentPageIndex = 0; crosspostSitesGrid.EditItemIndex = 0; BindGrid(); } else if ( e.CommandName == "autoFill" ) { DropDownList dropDownList = (DropDownList)e.Item.FindControl("blogSoftware"); TextBox textHostName = (TextBox)e.Item.FindControl("textHostName"); TextBox textEndpoint = (TextBox)e.Item.FindControl("textEndpoint"); TextBox textBoxBlogURL = (TextBox)e.Item.FindControl("textBoxBlogURL"); DropDownList dropDownApi = (DropDownList)e.Item.FindControl("listApiType"); string rawBlogUrl = textBoxBlogURL.Text; rawBlogUrl = rawBlogUrl.Replace("http://", ""); string[] blogUrl = rawBlogUrl.Split('/'); textHostName.Text = blogUrl[0]; string endpoint = ""; for (int index = 1; index < blogUrl.Length; index++) { endpoint += "/" + blogUrl[index]; } CrossPostServerInfo currentInfo = (CrossPostServerInfo)crossPostServerInfo.GetValue(dropDownList.SelectedIndex); if (endpoint.Length != 0 && endpoint.EndsWith("/") == false) endpoint += "/"; textEndpoint.Text = endpoint + currentInfo.Endpoint; dropDownApi.SelectedIndex = currentInfo.Service; } else if ( e.CommandName =="testConnection" ) { Label labelTestError; labelTestError = ((Label)e.Item.FindControl("labelTestError")); labelTestError.Text = ""; try { TextBox textBlogName; TextBox textPassword; CrosspostSite site = crosspostSites[e.Item.DataSetIndex]; site.ProfileName = ((TextBox)e.Item.FindControl("textProfileName")).Text; site.HostName = ((TextBox)e.Item.FindControl("textHostName")).Text; site.Port = int.Parse(((TextBox)e.Item.FindControl("textPort")).Text); site.Endpoint = ((TextBox)e.Item.FindControl("textEndpoint")).Text; site.Username = ((TextBox)e.Item.FindControl("textUsername")).Text; site.ApiType = ((DropDownList)e.Item.FindControl("listApiType")).SelectedValue; textPassword = ((TextBox)e.Item.FindControl("textPassword")); if ( textPassword.Text.Length > 0 ) { site.Password = textPassword.Text; } textBlogName = ((TextBox)e.Item.FindControl("textBlogName")); UriBuilder uriBuilder = new UriBuilder("http",site.HostName,site.Port,site.Endpoint); BloggerAPIClientProxy proxy = new BloggerAPIClientProxy(); proxy.Url = uriBuilder.ToString(); proxy.UserAgent="newtelligence dasBlog/1.4"; bgBlogInfo[] blogInfos = proxy.blogger_getUsersBlogs("",site.Username, site.Password); if ( blogInfos.Length > 0 ) { // [email protected] 24-MAR-04 // refresh all the blog names for this crosspost site string[] allBlogNames = new string[blogInfos.Length]; for (int blog=0; blog<blogInfos.Length; blog++) allBlogNames[blog] = blogInfos[blog].blogName; site.AllBlogNames = allBlogNames; // Default the crosspost blog to the first one site.BlogName = textBlogName.Text = blogInfos[0].blogName; site.BlogId = blogInfos[0].blogid; } BindGrid(); } catch( Exception exc ) { labelTestError.Text = exc.Message; } finally { } } }
public CrosspostInfo(CrosspostSite site) { this.site = site; this.isAlreadyPosted = false; this.categories = ""; }