protected void EnrollServer_Click(object sender, EventArgs e) { if (FederationPassword1.Text != FederationPassword2.Text) { RequestFederationStatus.Text = "Passwords do not match!"; return; } FederateRecord newFederate = new FederateRecord(); newFederate.ActivationState = FederateState.Active; newFederate.AllowFederatedDownload = AllowDownload.Checked; newFederate.AllowFederatedSearch = AllowSearch.Checked; newFederate.namespacePrefix = Namespace.Text; newFederate.OrganizationPOC = POCName.Text; newFederate.OrganizationPOCEmail = OrganizationEmail.Text; newFederate.OrganizationPOCPassword = FederationPassword1.Text; newFederate.OrganizationURL = OrganizationURL.Text; newFederate.OrginizationName = OrganizationName.Text; newFederate.RESTAPI = APIURL.Text; newFederate.SOAPAPI = APIURL.Text; System.Net.WebClient wc = new WebClient(); string request = (new JavaScriptSerializer()).Serialize(newFederate); // request = "{\"ActivationState\":0,\"AllowFederatedDownload\":true,\"AllowFederatedSearch\":true,\"RESTAPI\":\"http://localhost/3DRAPI/_3DRAPI.svc\",\"OrganizationPOC\":\"Admin\",\"OrganizationPOCEmail\":\"[email protected]\",\"OrganizationPOCPassword\":\"password\",\"OrganizationURL\":\"http://www.somecompany.com\",\"OrginizationName\":\"Some Company\",\"SOAPAPI\":\"\",\"namespacePrefix\":\"adl\"}"; wc.Headers["Content-Type"] = "application/json; charset=utf-8"; string response = wc.UploadString("http://3dr.adlnet.gov/federation/3DR_Federation_Mgmt.svc/RequestFederation", "POST", request); RequestFederationResponse serverresponse = (new JavaScriptSerializer()).Deserialize <RequestFederationResponse>(response); BindDetails(); RequestFederationStatus.Text = serverresponse.message; }
protected void EnrollServer_Click(object sender, EventArgs e) { if (FederationPassword1.Text != FederationPassword2.Text) { RequestFederationStatus.Text = "Passwords do not match!"; return; } FederateRecord newFederate = new FederateRecord(); newFederate.ActivationState = FederateState.Active; newFederate.AllowFederatedDownload = AllowDownload.Checked; newFederate.AllowFederatedSearch = AllowSearch.Checked; newFederate.namespacePrefix = Namespace.Text; newFederate.OrganizationPOC = POCName.Text; newFederate.OrganizationPOCEmail = OrganizationEmail.Text; newFederate.OrganizationPOCPassword = FederationPassword1.Text; newFederate.OrganizationURL = OrganizationURL.Text; newFederate.OrginizationName = OrganizationName.Text; newFederate.RESTAPI = APIURL.Text; newFederate.SOAPAPI = APIURL.Text; System.Net.WebClient wc = new WebClient(); string request = (new JavaScriptSerializer()).Serialize(newFederate); // request = "{\"ActivationState\":0,\"AllowFederatedDownload\":true,\"AllowFederatedSearch\":true,\"RESTAPI\":\"http://localhost/3DRAPI/_3DRAPI.svc\",\"OrganizationPOC\":\"Admin\",\"OrganizationPOCEmail\":\"[email protected]\",\"OrganizationPOCPassword\":\"password\",\"OrganizationURL\":\"http://www.somecompany.com\",\"OrginizationName\":\"Some Company\",\"SOAPAPI\":\"\",\"namespacePrefix\":\"adl\"}"; wc.Headers["Content-Type"] = "application/json; charset=utf-8"; string response = wc.UploadString("http://3dr.adlnet.gov/federation/3DR_Federation_Mgmt.svc/RequestFederation", "POST", request); RequestFederationResponse serverresponse = (new JavaScriptSerializer()).Deserialize<RequestFederationResponse>(response); BindDetails(); RequestFederationStatus.Text = serverresponse.message; }
private void BindModelDetails() { if (String.IsNullOrEmpty(ContentObjectID)) { Response.Redirect("~/Default.aspx"); } var uri = Request.Url; //string proxyTemplate = "Model.ashx?pid={0}&file={1}&fileid={2}"; vwar.service.host.Metadata co = null; try { string request = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Metadata/json?ID=00-00-00"; FederateRecord fed = GetFederateInfo(PidToNamespace(Request.QueryString["ContentObjectID"])); OrganizationContact.Text = fed.OrganizationPOC; OrganizationContact.NavigateUrl = "mailto:" + fed.OrganizationPOCEmail; OrganizationName.Text = fed.OrginizationName; OrganizationName.NavigateUrl = fed.OrganizationURL; System.Net.WebRequest wr = WebRequest.Create(request); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; string data; var response = (HttpWebResponse)wr.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } co = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Metadata>(data); } catch (System.Net.WebException ex) { System.Net.WebRequest wr = WebRequest.Create(ex.Response.ResponseUri); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; string data; var response = (HttpWebResponse)wr.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } co = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Metadata>(data); } LoginToDlLabel.Visible = false; //model screenshot if (co != null) { if ("Model".Equals(co.AssetType, StringComparison.InvariantCultureIgnoreCase) || true) { //if the content object file is null, dont' try to display // if (co.DisplayFile != string.Empty && co.Location != string.Empty && Permission > ModelPermissionLevel.Searchable) // { // Page.ClientScript.RegisterClientScriptBlock(GetType(), "vload", string.Format("vLoader = new ViewerLoader('{0}', '{1}', '{2}', '{3}', {4});", Page.ResolveClientUrl("~/Public/Serve.ashx?mode=PreviewModel"), // (co.UpAxis != null) ? co.UpAxis : "", // (co.UnitScale != null) ? co.UnitScale : "", co.NumPolygons, "\"" + co.PID.Replace(':','_') + "\""), true); // BodyTag.Attributes["onunload"] += "vLoader.DestroyViewer();"; // } ScreenshotImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Screenshot?ID=00-00-00"; } AddHeaderTag("link", "og:image", ScreenshotImage.ImageUrl); } else if ("Texture".Equals(co.AssetType, StringComparison.InvariantCultureIgnoreCase)) { ScreenshotImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Screenshot?ID=00-00-00"; } TitleLabel.Text = co.Title; AddHeaderTag("meta", "og:title", co.Title); //show hide edit link LoginToDlLabel.Visible = false; vwar.service.host.Review[] reviews = null; try { String request = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Reviews/json?ID=00-00-00"; System.Net.WebRequest wr = WebRequest.Create(request); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; wr.GetResponse().ToString(); var response = (HttpWebResponse)wr.GetResponse(); string data; using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } reviews = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Review[]>(data); } catch (System.Net.WebException ex) { System.Net.WebRequest wr = WebRequest.Create(ex.Response.ResponseUri); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; wr.GetResponse().ToString(); var response = (HttpWebResponse)wr.GetResponse(); string data; using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } reviews = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Review[]>(data); } //rating int rating = 0; foreach (var review in reviews) { rating += review.Rating; } if (reviews.Count() > 0) { rating = rating / reviews.Count(); } ir.CurrentRating = rating; //description DescriptionLabel.Text = String.IsNullOrEmpty(co.Description) ? "No description available." : co.Description; AddHeaderTag("meta", "og:description", co.Description); upAxis.Value = co.UpAxis; unitScale.Value = co.UnitScale; //keywords var keywordsList = string.IsNullOrEmpty(co.Keywords) ? new String[0] : co.Keywords.Split(new char[] { ',' }); foreach (var keyword in keywordsList) { HyperLink link = new HyperLink() { Text = keyword, NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(keyword.Trim()), CssClass = "Hyperlink" }; keywords.Controls.Add(link); keywords.Controls.Add(new LiteralControl(" ")); } this.keywordLabel.Visible = !string.IsNullOrEmpty(co.Keywords); //more details this.MoreDetailsHyperLink.NavigateUrl = co.MoreInformationURL; this.MoreDetailsHyperLink.Text = co.MoreInformationURL; this.MoreDetailsRow.Visible = !string.IsNullOrEmpty(co.MoreInformationURL); string submitterFullName = Website.Common.GetFullUserName(co.DeveloperName); if (co.UploadedDate != null) { UploadedDateLabel.Text = "Uploaded by: " + submitterFullName + " on " + co.UploadedDate.ToString(); } this.SponsorLogoImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/SponsorLogo?ID=00-00-00"; this.SponsorLogoRow.Visible = true; this.SponsorNameLabel.Text = co.SponsorName; this.SponsorNameRow.Visible = !string.IsNullOrEmpty(co.SponsorName); this.DeveloperLogoImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/DeveloperLogo?ID=00-00-00"; //developer name this.DeveloperNameHyperLink.NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(co.DeveloperName); this.DeveloperNameHyperLink.Text = co.DeveloperName; if (String.IsNullOrEmpty(co.ArtistName)) { this.ArtistRow.Visible = false; } else { this.ArtistNameHyperLink.NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(co.ArtistName); this.ArtistNameHyperLink.Text = co.ArtistName; } this.DeveloperRow.Visible = !string.IsNullOrEmpty(co.DeveloperName); this.FormatLabel.Text = "Native format: " + ((string.IsNullOrEmpty(co.Format)) ? "Unknown" : co.Format); //num polygons this.NumPolygonsLabel.Text = co.NumPolygons.ToString(); this.NumPolygonsRow.Visible = !string.IsNullOrEmpty(co.NumPolygons.ToString()); //num textures this.NumTexturesLabel.Text = co.NumTextures.ToString(); this.NumTexturesRow.Visible = !string.IsNullOrEmpty(co.NumTextures.ToString()); //cclrow this.CCLHyperLink.Visible = !string.IsNullOrEmpty(co.License); this.CCLHyperLink.NavigateUrl = co.License; if (!string.IsNullOrEmpty(co.License)) { switch (co.License.ToLower().Trim()) { case "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc-sa"; break; case "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc-nd"; break; case "http://creativecommons.org/licenses/by-nc/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc"; break; case "http://creativecommons.org/licenses/by-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nd/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nd"; break; case "http://creativecommons.org/licenses/by-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-sa/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-sa"; break; case "http://creativecommons.org/publicdomain/mark/1.0/": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/publicdomain/88x31.png"; this.CCLHyperLink.ToolTip = "Public Domain"; break; case "http://creativecommons.org/licenses/by/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by"; break; } } //downloads DownloadsLabel.Text = co.Downloads.ToString(); this.DownloadsRow.Visible = !string.IsNullOrEmpty(co.Downloads.ToString()); //views ViewsLabel.Text = co.Views.ToString(); this.ViewsRow.Visible = !string.IsNullOrEmpty(co.Views.ToString()); //download buton //this.DownloadButton.Visible = Context.User.Identity.IsAuthenticated; this.CommentsGridView.DataSource = reviews; this.CommentsGridView.DataBind(); }