protected void Page_Load(object sender, EventArgs e) { if (library.IsLoggedOn() && ProjectId != null) { var nodeListingProvider = new NodeListingProvider(); Member mem = Member.GetCurrentMember(); IListingItem project = nodeListingProvider.GetListing((int)ProjectId); _defaultFile = project.DefaultScreenshot; if ((project.VendorId == mem.Id) || Utils.IsProjectContributor(mem.Id, (int)ProjectId)) { holder.Visible = true; RebindFiles(); library.RegisterJavaScriptFile("swfUpload", "/scripts/swfupload/SWFUpload.js"); library.RegisterJavaScriptFile("swfUpload_cb", "/scripts/swfupload/callbacks.js"); library.RegisterJavaScriptFile("swfUpload_progress", "/scripts/swfupload/fileprogress.js"); MemberGuid = mem.UniqueId.ToString(); ProjectGuid = project.ProjectGuid.ToString(); } } }
private void MarkFileAsCurrent(string releaseFile) { var nodeListingProvider = new NodeListingProvider(); IListingItem project = nodeListingProvider.GetListing((int)ProjectId); project.CurrentReleaseFile = releaseFile; nodeListingProvider.SaveOrUpdate(project); _defaultFile = project.CurrentReleaseFile; }
private void MarkFileAsCurrent(string defaultScreenshot) { var nodeListingProvider = new NodeListingProvider(); IListingItem project = nodeListingProvider.GetListing((int)ProjectId); project.DefaultScreenshot = defaultScreenshot; nodeListingProvider.SaveOrUpdate(project); _defaultFile = project.DefaultScreenshot; }
protected void Page_Load(object sender, EventArgs e) { if (library.IsLoggedOn() && ProjectId != null) { var nodeListingProvider = new NodeListingProvider(); Member mem = Member.GetCurrentMember(); IListingItem project = nodeListingProvider.GetListing((int)ProjectId); _defaultFile = project.CurrentReleaseFile; if ((project.VendorId == mem.Id) || Utils.IsProjectContributor(mem.Id, (int)ProjectId)) { holder.Visible = true; RebindFiles(); library.RegisterJavaScriptFile("swfUpload", "/scripts/swfupload/SWFUpload.js"); library.RegisterJavaScriptFile("swfUpload_cb", "/scripts/swfupload/callbacks.js"); library.RegisterJavaScriptFile("swfUpload_progress", "/scripts/swfupload/fileprogress.js"); MemberGuid = mem.UniqueId.ToString(); ProjectGuid = project.ProjectGuid.ToString(); string umboptions = ""; foreach (UmbracoVersion uv in UmbracoVersion.AvailableVersions().Values) { umboptions += string.Format("<input type='checkbox' name='wiki_version' value='{0}' /><span> {1}</span></br>", uv.Version, uv.Name); } lt_versions.Text = umboptions; string[] dotnetversions = { "", "2.0", "3.5", "4.0", "4.5" }; string dotnetoptions = string.Empty; foreach (var opt in dotnetversions) { dotnetoptions += string.Format("<option value='{0}'>{1}</option>", opt, opt); } lt_dotnetversions.Text = dotnetoptions; } } }
protected void DeleteFile(object sender, CommandEventArgs e) { var mediaProvider = new MediaProvider(); var f = mediaProvider.GetFileById(int.Parse(e.CommandArgument.ToString())); _defaultFile = string.Empty; //update the project var nodeListingProvider = new NodeListingProvider(); IListingItem project = nodeListingProvider.GetListing((int)ProjectId); project.DefaultScreenshot = _defaultFile; nodeListingProvider.SaveOrUpdate(project); var mem = Member.GetCurrentMember(); if (f.CreatedBy == mem.Id || Utils.IsProjectContributor(mem.Id, (int)ProjectId)) { mediaProvider.Remove(f); } RebindFiles(); }
override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); if (_projectId != null) { var nodeListingProvider = new NodeListingProvider(); _project = nodeListingProvider.GetListing((int)_projectId); //check security to make sure the project belongs to the vendor var currentMemberId = Members.GetCurrentMemberId(); var vendorIsCurrentMember = (_project.VendorId == currentMemberId); var isProjectContributor = Utils.IsProjectContributor(currentMemberId, (int)_projectId); if ((vendorIsCurrentMember || isProjectContributor) == false) { //this project does not belong to this member so kick them back to the project list in their profile. Response.Redirect("~/member/profile/projects/"); } } _currentStep = umbraco.helper.Request("editorStep"); ListingCreatorStep _s; if (string.IsNullOrEmpty(_currentStep)) { _s = ListingSteps()["details"]; } else { _s = ListingSteps()[_currentStep]; } loadContent(_s); }
/// <summary> /// Persists the listing object to the database /// </summary> /// <param name="listingItem"></param> public void SaveOrUpdate(IListingItem listingItem) { var contentService = ApplicationContext.Current.Services.ContentService; //check if this is a new listing or an existing one. var isUpdate = listingItem.Id != 0; var content = (isUpdate) ? contentService.GetById(listingItem.Id) : contentService.CreateContent(listingItem.Name, listingItem.CategoryId, "Project"); var packageGuidValue = content.GetValue <string>("packageGuid"); var packageGuidString = Guid.TryParse(packageGuidValue, out Guid packageGuid) ? packageGuid.ToString() : Guid.NewGuid().ToString(); //set all the document properties content.Name = listingItem.Name; content.SetValue("description", listingItem.Description); content.SetValue("version", listingItem.CurrentVersion); content.SetValue("file", listingItem.CurrentReleaseFile); content.SetValue("status", listingItem.DevelopmentStatus); content.SetValue("stable", (listingItem.Stable) ? "1" : "0"); content.SetValue("projectLive", (listingItem.Live) ? "1" : "0"); content.SetValue("listingType", listingItem.ListingType.GetListingTypeAsString()); content.SetValue("gaCode", listingItem.GACode); content.SetValue("category", listingItem.CategoryId); content.SetValue("licenseName", listingItem.LicenseName); content.SetValue("licenseUrl", listingItem.LicenseUrl); content.SetValue("supportUrl", listingItem.SupportUrl); content.SetValue("sourceUrl", listingItem.SourceCodeUrl); content.SetValue("nuGetPackageUrl", listingItem.NuGetPackageUrl); content.SetValue("demoUrl", listingItem.DemonstrationUrl); content.SetValue("openForCollab", listingItem.OpenForCollab); content.SetValue("notAPackage", listingItem.NotAPackage); content.SetValue("packageGuid", packageGuidString); content.SetValue("approved", (listingItem.Approved) ? "1" : "0"); if (isUpdate == false) { content.SetValue("termsAgreementDate", listingItem.TermsAgreementDate); } content.SetValue("owner", listingItem.VendorId); content.SetValue("websiteUrl", listingItem.ProjectUrl); content.SetValue("licenseKey", listingItem.LicenseKey); content.SetValue("isRetired", listingItem.IsRetired); content.SetValue("isNuGetFormat", listingItem.IsNuGetFormat); content.SetValue("retiredMessage", listingItem.RetiredMessage); if (listingItem.PackageFile != null) { var currentFiles = listingItem.PackageFile.Where(x => x.Current && x.Archived == false).ToList(); var supportedDotNetVersions = new List <string>(); foreach ( var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.DotNetVersion) == false && x.DotNetVersion != "nan" && supportedDotNetVersions.Contains(x.DotNetVersion) == false)) { supportedDotNetVersions.Add(currentFile.DotNetVersion); } content.SetValue("dotNetVersion", string.Join(",", supportedDotNetVersions)); var supportedUmbracoVersions = new List <string>(); foreach (var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.UmbVersion.ToVersionString()) == false && x.UmbVersion.ToVersionString() != "nan" && supportedUmbracoVersions.Contains(x.UmbVersion.ToVersionString()) == false)) { supportedUmbracoVersions.Add(currentFile.UmbVersion.ToVersionString()); } content.SetValue("compatibleVersions", string.Join(",", supportedUmbracoVersions)); } //set the files content.SetValue("defaultScreenshotPath", listingItem.DefaultScreenshot); if (listingItem.Tags != null && listingItem.Tags.Any()) { var tags = new List <string>(); foreach (var projectTag in listingItem.Tags.Where(projectTag => tags.Any(x => string.Compare(x, projectTag.Text, StringComparison.InvariantCultureIgnoreCase) == 0))) { tags.Add(projectTag.Text); } content.SetTags("tags", tags, true, "project"); } if (listingItem.DocumentationFile != null) { if (listingItem.DocumentationFile.Any()) { content.SetValue("documentation", listingItem.DocumentationFile.OrderBy(x => x.Current).First().Path); } } if (listingItem.IsRetired) { listingItem.Live = false; } try { contentService.SaveAndPublishWithStatus(content); } catch (SqlException e) { LogHelper.Error <NodeListingProvider>($"Hit error on package name: {content.Name} with id: {content.Id}.", e); // we have some corrupt data that will once in a while give this error: // The INSERT statement conflicted with the FOREIGN KEY constraint "FK_umbracoRedirectUrl". The conflict occurred in database "OurDevAnon2", table "dbo.umbracoNode", column 'uniqueID'. // It seems to work anyways though, renames the node and creates the redirect. } listingItem.Id = content.Id; listingItem.NiceUrl = library.NiceUrl(listingItem.Id); var indexer = ExamineManager.Instance.IndexProviderCollection["projectIndexer"]; if (indexer != null && listingItem.IsRetired) { indexer.DeleteFromIndex(listingItem.Id.ToString()); } }
/// <summary> /// Persists the listing object to the database /// </summary> /// <param name="listingItem"></param> public void SaveOrUpdate(IListingItem listingItem) { var contentService = ApplicationContext.Current.Services.ContentService; //check if this is a new listing or an existing one. var isUpdate = listingItem.Id != 0; var content = (isUpdate) ? contentService.GetById(listingItem.Id) : contentService.CreateContent(listingItem.Name, listingItem.CategoryId, "Project"); Guid packageGuid; var packageGuidValue = content.GetValue <string>("packageGuid"); var packageGuidString = Guid.TryParse(packageGuidValue, out packageGuid) ? packageGuid.ToString() : Guid.NewGuid().ToString(); //set all the document properties content.SetValue("description", listingItem.Description); content.SetValue("version", listingItem.CurrentVersion); content.SetValue("file", listingItem.CurrentReleaseFile); content.SetValue("status", listingItem.DevelopmentStatus); content.SetValue("stable", (listingItem.Stable) ? "1" : "0"); content.SetValue("projectLive", (listingItem.Live) ? "1" : "0"); content.SetValue("listingType", listingItem.ListingType.GetListingTypeAsString()); content.SetValue("gaCode", listingItem.GACode); content.SetValue("category", listingItem.CategoryId); content.SetValue("licenseName", listingItem.LicenseName); content.SetValue("licenseUrl", listingItem.LicenseUrl); content.SetValue("supportUrl", listingItem.SupportUrl); content.SetValue("sourceUrl", listingItem.SourceCodeUrl); content.SetValue("nuGetPackageUrl", listingItem.NuGetPackageUrl); content.SetValue("demoUrl", listingItem.DemonstrationUrl); content.SetValue("openForCollab", listingItem.OpenForCollab); content.SetValue("notAPackage", listingItem.NotAPackage); content.SetValue("packageGuid", packageGuidString); content.SetValue("approved", (listingItem.Approved) ? "1" : "0"); content.SetValue("termsAgreementDate", listingItem.TermsAgreementDate); content.SetValue("owner", listingItem.VendorId); content.SetValue("websiteUrl", listingItem.ProjectUrl); content.SetValue("licenseKey", listingItem.LicenseKey); content.SetValue("isRetired", listingItem.IsRetired); content.SetValue("retiredMessage", listingItem.RetiredMessage); if (listingItem.PackageFile != null) { var currentFiles = listingItem.PackageFile.Where(x => x.Current && x.Archived == false).ToList(); var supportedDotNetVersions = new List <string>(); foreach ( var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.DotNetVersion) == false && x.DotNetVersion != "nan" && supportedDotNetVersions.Contains(x.DotNetVersion) == false)) { supportedDotNetVersions.Add(currentFile.DotNetVersion); } content.SetValue("dotNetVersion", string.Join(",", supportedDotNetVersions)); var supportedUmbracoVersions = new List <string>(); foreach (var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.UmbVersion.ToVersionString()) == false && x.UmbVersion.ToVersionString() != "nan" && supportedUmbracoVersions.Contains(x.UmbVersion.ToVersionString()) == false)) { supportedUmbracoVersions.Add(currentFile.UmbVersion.ToVersionString()); } content.SetValue("compatibleVersions", string.Join(",", supportedUmbracoVersions)); } //set the files content.SetValue("defaultScreenshotPath", listingItem.DefaultScreenshot); if (listingItem.Tags != null && listingItem.Tags.Any()) { var tags = new List <string>(); foreach (var projectTag in listingItem.Tags.Where(projectTag => tags.Any(x => string.Compare(x, projectTag.Text, StringComparison.InvariantCultureIgnoreCase) == 0))) { tags.Add(projectTag.Text); } content.SetTags("tags", tags, true, "project"); } if (listingItem.DocumentationFile != null) { if (listingItem.DocumentationFile.Any()) { content.SetValue("documentation", listingItem.DocumentationFile.OrderBy(x => x.Current).First().Path); } } if (listingItem.IsRetired) { listingItem.Live = false; } contentService.SaveAndPublishWithStatus(content); listingItem.Id = content.Id; listingItem.NiceUrl = library.NiceUrl(listingItem.Id); var indexer = ExamineManager.Instance.IndexProviderCollection["projectIndexer"]; if (indexer != null) { indexer.DeleteFromIndex(listingItem.Id.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { Project = projectProvider.GetCurrentListing(); if (!IsPostBack) { projectProvider.IncrementProjectViews(Project); SetSecurables(); SetupProject(); } SetupAnalytics(); }
protected override void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); _vendor = ((IVendorProvider)MarketplaceProviderManager.Providers["VendorProvider"]).GetVendorById(Member.GetCurrentMember().Id); if (_projectId != null) { _project = ((IListingProvider)MarketplaceProviderManager.Providers["ListingProvider"]).GetListing((int)_projectId); //check security to make sure the project belongs to the vendor if (!((_project.Vendor.Member.Id == _vendor.Member.Id) || Utils.IsProjectContributor(_vendor.Member.Id, (int)_projectId))) { //this project does not belong to this member so kick them back to the project list in their profile. Response.Redirect("~/member/profile/projects/"); } } _currentStep = umbraco.helper.Request("editorStep"); ListingCreatorStep _s; if (string.IsNullOrEmpty(_currentStep)) _s = ListingSteps()["details"]; else _s = ListingSteps()[_currentStep]; loadContent(_s); }
/// <summary> /// Persists the listing object to the database /// </summary> /// <param name="listingItem"></param> public void SaveOrUpdate(IListingItem listingItem) { var contentService = UmbracoContext.Current.Application.Services.ContentService; //check if this is a new listing or an existing one. var isUpdate = listingItem.Id != 0; var content = (isUpdate) ? contentService.GetById(listingItem.Id) : contentService.CreateContent(listingItem.Name, listingItem.CategoryId, "Project"); Guid packageGuid; var packageGuidValue = content.GetValue<string>("packageGuid"); var packageGuidString = Guid.TryParse(packageGuidValue, out packageGuid) ? packageGuid.ToString() : Guid.NewGuid().ToString(); //set all the document properties content.SetValue("description", listingItem.Description); content.SetValue("version", listingItem.CurrentVersion); content.SetValue("file", listingItem.CurrentReleaseFile); content.SetValue("status", listingItem.DevelopmentStatus); content.SetValue("stable", (listingItem.Stable) ? "1" : "0"); content.SetValue("projectLive", (listingItem.Live) ? "1" : "0"); content.SetValue("listingType", listingItem.ListingType.GetListingTypeAsString()); content.SetValue("gaCode", listingItem.GACode); content.SetValue("category", listingItem.CategoryId); content.SetValue("licenseName", listingItem.LicenseName); content.SetValue("licenseUrl", listingItem.LicenseUrl); content.SetValue("supportUrl", listingItem.SupportUrl); content.SetValue("sourceUrl", listingItem.SourceCodeUrl); content.SetValue("demoUrl", listingItem.DemonstrationUrl); content.SetValue("openForCollab", listingItem.OpenForCollab); content.SetValue("notAPackage", listingItem.NotAPackage); content.SetValue("packageGuid", packageGuidString); content.SetValue("approved", (listingItem.Approved) ? "1" : "0"); content.SetValue("termsAgreementDate", listingItem.TermsAgreementDate); content.SetValue("owner", listingItem.VendorId); content.SetValue("websiteUrl", listingItem.ProjectUrl); content.SetValue("licenseKey", listingItem.LicenseKey); if (listingItem.PackageFile != null) { var currentFiles = listingItem.PackageFile.Where(x => x.Current && x.Archived == false).ToList(); var supportedDotNetVersions = new List<string>(); foreach ( var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.DotNetVersion) == false && x.DotNetVersion != "nan" && supportedDotNetVersions.Contains(x.DotNetVersion) == false)) { supportedDotNetVersions.Add(currentFile.DotNetVersion); } content.SetValue("dotNetVersion", string.Join(",", supportedDotNetVersions)); var supportedUmbracoVersions = new List<string>(); foreach (var currentFile in currentFiles.Where(x => string.IsNullOrWhiteSpace(x.UmbVersion.ToVersionString()) == false && x.UmbVersion.ToVersionString() != "nan" && supportedUmbracoVersions.Contains(x.UmbVersion.ToVersionString()) == false)) { supportedUmbracoVersions.Add(currentFile.UmbVersion.ToVersionString()); } content.SetValue("compatibleVersions", string.Join(",", supportedUmbracoVersions)); } //set the files content.SetValue("defaultScreenshotPath", listingItem.DefaultScreenshot); if (listingItem.Tags != null && listingItem.Tags.Any()) { var tags = new List<string>(); foreach (var projectTag in listingItem.Tags.Where(projectTag => tags.Any(x => string.Compare(x, projectTag.Text, StringComparison.InvariantCultureIgnoreCase) == 0))) { tags.Add(projectTag.Text); } content.SetTags("tags", tags, true, "project"); } if (listingItem.DocumentationFile != null) { if (listingItem.DocumentationFile.Any()) { content.SetValue("documentation", listingItem.DocumentationFile.OrderBy(x => x.Current).First().Path); } } contentService.SaveAndPublishWithStatus(content); listingItem.Id = content.Id; listingItem.NiceUrl = library.NiceUrl(listingItem.Id); }
protected override void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); if (_projectId != null) { var nodeListingProvider = new NodeListingProvider(); _project = nodeListingProvider.GetListing((int)_projectId); //check security to make sure the project belongs to the vendor var currentMemberId = Members.GetCurrentMemberId(); var vendorIsCurrentMember = (_project.VendorId == currentMemberId); var isProjectContributor = Utils.IsProjectContributor(currentMemberId, (int)_projectId); if ((vendorIsCurrentMember || isProjectContributor) == false) { //this project does not belong to this member so kick them back to the project list in their profile. Response.Redirect("~/member/profile/projects/"); } } _currentStep = umbraco.helper.Request("editorStep"); ListingCreatorStep _s; if (string.IsNullOrEmpty(_currentStep)) _s = ListingSteps()["details"]; else _s = ListingSteps()[_currentStep]; loadContent(_s); }
public static string GetCategoryName(this IListingItem project) { var node = new Node(project.Id); return(node.Parent.Name); }