コード例 #1
0
    public static string DeleteModel(string pid)
    {
        pid = HttpContext.Current.Server.UrlDecode(pid);
        string          response = "0";
        var             factory  = new DataAccessFactory();
        IDataRepository dal      = factory.CreateDataRepositorProxy();
        ContentObject   co       = dal.GetContentObjectById(pid, false);

        if (co != null &&
            HttpContext.Current.User.Identity.IsAuthenticated &&
            (co.SubmitterEmail.Equals(HttpContext.Current.User.Identity.Name, StringComparison.InvariantCultureIgnoreCase) ||
             Website.Security.IsAdministrator()))
        {
            try
            {
                dal.DeleteContentObject(co);
                response = "1";
            }
            catch { }
        }
        else if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            HttpContext.Current.Response.StatusCode = 403;
        }
        dal.Dispose();
        return(response);
    }
コード例 #2
0
    public static void DownloadButton_Click_Impl(string format, string ContentObjectID)
    {
        var             factory = new DataAccessFactory();
        IDataRepository vd      = factory.CreateDataRepositorProxy();
        var             co      = vd.GetContentObjectById(ContentObjectID, false);

        if (LR_3DR_Bridge.LR_Integration_Enabled())
        {
            LR_3DR_Bridge.ModelDownloaded(co);
        }

        vd.IncrementDownloads(ContentObjectID);
        try
        {
            if (String.IsNullOrEmpty(format))
            {
                string clientFileName = (!String.IsNullOrEmpty(co.OriginalFileName)) ? co.OriginalFileName : co.Location;
                var    data           = vd.GetContentFile(co.PID, clientFileName);

                Website.Documents.ServeDocument(data, clientFileName);
            }
            else
            {
                var data = vd.GetContentFile(co.PID, co.Location);
                if (format == ".dae")
                {
                    Website.Documents.ServeDocument(data, co.Location);
                }
                else if (format != ".O3Dtgz")
                {
                    Website.Documents.ServeDocument(data, co.Location, null, format);
                }
                else
                {
                    var displayFile = vd.GetContentFile(co.PID, co.DisplayFile);
                    Website.Documents.ServeDocument(displayFile, co.DisplayFile);
                }
            }
        }
        catch (System.Threading.ThreadAbortException tabexc) { }
        catch (Exception f)
        {
        }
        vd.Dispose();
    }
コード例 #3
0
    public static bool SendAccessRequest(string pid, string message)
    {
        if (Membership.GetUser() == null || !Membership.GetUser().IsApproved)
        {
            return(false);
        }

        var             factory = new DataAccessFactory();
        IDataRepository vd      = factory.CreateDataRepositorProxy();
        var             co      = vd.GetContentObjectById(pid, false);

        MessageManager manager = new MessageManager();

        message = Westwind.Web.Utilities.HtmlSanitizer.SanitizeHtml(message, null);
        manager.SendMessage(Membership.GetUser().UserName, co.SubmitterEmail, "Requesting Access to Model: " + co.Title + " (" + pid + ")", "A request has been sent from " + Membership.GetUser().UserName + " for access to model " + co.Title + " (" + pid + "). Please review this request and decide on the proper action. Click here to access the model: <a href='/public/model.aspx?ContentObjectID=" + pid + "'>" + pid + "</a> The user sent this message in the request: \n\n" + message +
                            "<br/><div class='accessbutton' onclick='GrantOrDenyRequest(\"" + Membership.GetUser().UserName + "\",\"Grant\",\"" + pid + "\");'>Grant Access</div><div class='accessbutton' onclick='GrantOrDenyRequest(\"" + Membership.GetUser().UserName + "\",\"Deny\",\"" + pid + "\");'>Deny Request</div>"

                            , Membership.GetUser().UserName);
        return(true);
    }
コード例 #4
0
        private void DoSubmitAll()
        {
            vwarDAL.DataAccessFactory   df      = new DataAccessFactory();
            vwarDAL.IDataRepository     dal     = df.CreateDataRepositorProxy();
            IEnumerable <ContentObject> objects = dal.GetAllContentObjects();

            int total   = 0;
            int current = 0;

            foreach (ContentObject co in objects)
            {
                total++;
            }


            progressBar1.Maximum = total;
            progressBar2.Maximum = 4;

            foreach (ContentObject co in objects)
            {
                current++;
                progressBar1.Value = current;
                progressBar2.Value = 0;
                AllowUIToUpdate();
                textBlock1.Text    = LR_3DR_Bridge.ModelDownloadedInternal(co);
                progressBar2.Value = 1;
                AllowUIToUpdate();
                ContentObject co2 = dal.GetContentObjectById(co.PID, false, true);
                textBlock1.Text    = LR_3DR_Bridge.ModelRatedInternal(co2);
                progressBar2.Value = 2;
                AllowUIToUpdate();
                textBlock1.Text    = LR_3DR_Bridge.ModelUploadedInternal(co);
                progressBar2.Value = 3;
                AllowUIToUpdate();
                textBlock1.Text    = LR_3DR_Bridge.ModelViewedInternal(co);
                progressBar2.Value = 4;
                AllowUIToUpdate();
            }
        }
コード例 #5
0
ファイル: Upload.aspx.cs プロジェクト: llaxton/3D-Repository
    public static string SubmitUpload(string DeveloperName, string ArtistName, string DeveloperUrl,
                                      string SponsorName, string LicenseType,
                                      bool RequireResubmit)
    {
        HttpServerUtility server = HttpContext.Current.Server;
        ContentObject     tempCO = (ContentObject)HttpContext.Current.Session["contentObject"];

        try
        {
            FileStatus status = (FileStatus)HttpContext.Current.Session["fileStatus"];

            var             factory = new DataAccessFactory();
            IDataRepository dal     = factory.CreateDataRepositorProxy();
            dal.InsertContentObject(tempCO);
            tempCO.DeveloperName      = server.HtmlEncode(DeveloperName);
            tempCO.ArtistName         = server.HtmlEncode(ArtistName);
            tempCO.MoreInformationURL = server.HtmlEncode(DeveloperUrl);
            tempCO.RequireResubmit    = RequireResubmit;
            tempCO.SponsorName        = server.HtmlEncode(SponsorName);
            vwarDAL.PermissionsManager perMgr = new PermissionsManager();
            var groupSetReturnCode            = perMgr.SetModelToGroupLevel(HttpContext.Current.User.Identity.Name, tempCO.PID, vwarDAL.DefaultGroups.AllUsers, ModelPermissionLevel.Fetchable);
            groupSetReturnCode = perMgr.SetModelToGroupLevel(HttpContext.Current.User.Identity.Name, tempCO.PID, vwarDAL.DefaultGroups.AnonymousUsers, ModelPermissionLevel.Searchable);

            string pid = tempCO.PID;
            //tempCO.SponsorURL = SponsorUrl; !missing SponsorUrl metadata in ContentObject

            if (LicenseType == "publicdomain")
            {
                tempCO.CreativeCommonsLicenseURL = "http://creativecommons.org/publicdomain/mark/1.0/";
            }
            else
            {
                tempCO.CreativeCommonsLicenseURL = String.Format(ConfigurationManager.AppSettings["CCBaseUrl"], LicenseType);
            }


            //Upload the thumbnail and logos
            string filename = status.hashname;
            string basehash = filename.Substring(0, filename.LastIndexOf(".") - 1);
            foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/App_Data/imageTemp")).GetFiles("*" + basehash + "*"))
            {
                using (FileStream fstream = f.OpenRead())
                {
                    string type = f.Name.Substring(0, f.Name.IndexOf('_'));
                    switch (type)
                    {
                    case ImagePrefix.DEVELOPER_LOGO:
                        tempCO.DeveloperLogoImageFileName   = "developer_logo" + f.Extension;
                        tempCO.DeveloperLogoImageFileNameId = dal.SetContentFile(fstream, tempCO.PID, tempCO.DeveloperLogoImageFileName);
                        break;

                    case ImagePrefix.SPONSOR_LOGO:
                        tempCO.SponsorLogoImageFileName   = "sponsor_logo" + f.Extension;
                        tempCO.SponsorLogoImageFileNameId = dal.SetContentFile(fstream, tempCO.PID, tempCO.SponsorLogoImageFileName);
                        break;

                    case ImagePrefix.SCREENSHOT:
                        tempCO.ScreenShot   = "screenshot" + f.Extension;
                        tempCO.ScreenShotId = dal.SetContentFile(fstream, tempCO.PID, tempCO.ScreenShot);

                        System.Drawing.Imaging.ImageFormat fmt = System.Drawing.Imaging.ImageFormat.Png;
                        if (f.Extension == ".png")
                        {
                            fmt = System.Drawing.Imaging.ImageFormat.Png;
                        }
                        else if (f.Extension == ".jpg")
                        {
                            fmt = System.Drawing.Imaging.ImageFormat.Jpeg;
                        }
                        else if (f.Extension == ".gif")
                        {
                            fmt = System.Drawing.Imaging.ImageFormat.Gif;
                        }
                        else
                        {
                            throw new Exception("Invalid screenshot format");
                        }

                        tempCO.ThumbnailId = Website.Common.GetFileSHA1AndSalt(fstream) + f.Extension;
                        using (FileStream outFile = new FileStream(HttpContext.Current.Server.MapPath("~/thumbnails/" + tempCO.ThumbnailId), FileMode.Create))
                            Website.Common.GenerateThumbnail(fstream, outFile, fmt);

                        break;

                    default:
                        break;
                    }
                }
            }
            string dataPath = HttpContext.Current.Server.MapPath("~/App_Data/");
            if (status.type == FormatType.VIEWABLE)
            {
                //Upload the original file
                using (FileStream s = new FileStream(dataPath + status.hashname, FileMode.Open))
                {
                    tempCO.OriginalFileId   = dal.SetContentFile(s, pid, "original_" + status.filename);
                    tempCO.OriginalFileName = "original_" + status.filename;
                }
                using (FileStream s = new FileStream(Path.Combine(dataPath, "converterTemp/" + status.hashname.ToLower().Replace("skp", "zip")), FileMode.Open, FileAccess.Read))
                {
                    tempCO.DisplayFileId = dal.SetContentFile(s, pid, status.filename.ToLower().Replace("skp", "zip"));
                }
                using (FileStream s = new FileStream(Path.Combine(dataPath, "viewerTemp/" + status.hashname.ToLower().Replace("skp", "o3d").Replace("zip", "o3d")), FileMode.Open))
                {
                    dal.SetContentFile(s, pid, status.filename.ToLower().Replace("skp", "o3d").Replace("zip", "o3d"));
                }
            }
            else if (status.type == FormatType.RECOGNIZED)
            {
                using (FileStream s = new FileStream(dataPath + status.hashname, FileMode.Open))
                {
                    tempCO.OriginalFileName = "original_" + status.filename;
                    tempCO.OriginalFileId   = dal.SetContentFile(s, pid, tempCO.OriginalFileName);
                }
            }
            tempCO.Enabled      = true;
            tempCO.UploadedDate = DateTime.Now;

            dal.UpdateContentObject(tempCO);
            UploadReset(status.hashname);

            List <string> textureReferences = HttpContext.Current.Session["contentTextures"] as List <string>;

            List <string> textureReferenceMissing = HttpContext.Current.Session["contentMissingTextures"] as List <string>;



            if (textureReferences != null)
            {
                foreach (string tex in textureReferences)
                {
                    tempCO.SetParentRepo(dal);
                    tempCO.AddTextureReference(tex, "unknown", 0);
                }
            }
            if (textureReferenceMissing != null)
            {
                foreach (string tex in textureReferenceMissing)
                {
                    tempCO.SetParentRepo(dal);
                    tempCO.AddMissingTexture(tex, "unknown", 0);
                }
            }

            if (LR_3DR_Bridge.LR_Integration_Enabled())
            {
                LR_3DR_Bridge.ModelUploaded(tempCO);
            }

            Website.Mail.SendModelUploaded(tempCO);
            dal.Dispose();
            perMgr.Dispose();
            return(tempCO.PID);
        }
        catch (Exception e)
        {
            #if DEBUG
            return(String.Format("fedoraError|" + e.Message + "<br /><br />" + e.StackTrace));
            #else
            return("fedoraError|" + ConfigurationManager.AppSettings["UploadPage_FedoraError"]);
            #endif
        }
    }
コード例 #6
0
ファイル: Upload.aspx.cs プロジェクト: llaxton/3D-Repository
    public static JsonWrappers.UploadDetailDefaults Step2_Submit(string ScaleValue, string UpAxis)
    {
        HttpContext       context       = HttpContext.Current;
        HttpServerUtility server        = context.Server;
        FileStatus        currentStatus = (FileStatus)context.Session["fileStatus"];

        var             factory = new DataAccessFactory();
        IDataRepository dal     = factory.CreateDataRepositorProxy();
        ContentObject   tempCO  = (ContentObject)context.Session["contentObject"];

        tempCO.UpAxis    = server.HtmlEncode(UpAxis);
        tempCO.UnitScale = server.HtmlEncode(ScaleValue);
        //dal.UpdateContentObject(tempCO);
        context.Session["contentObject"] = tempCO;


        //Bind the
        JsonWrappers.UploadDetailDefaults jsReturnParams = new JsonWrappers.UploadDetailDefaults();
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            UserProfile p = null;
            try
            {
                p = UserProfileDB.GetUserProfileByUserName(context.User.Identity.Name);
            }
            catch { }

            if (p != null)
            {
                jsReturnParams.HasDefaults   = true;
                jsReturnParams.DeveloperName = p.DeveloperName;
                jsReturnParams.ArtistName    = p.ArtistName;
                jsReturnParams.DeveloperUrl  = p.WebsiteURL;
                jsReturnParams.SponsorName   = p.SponsorName;

                string tempImagePath = context.Server.MapPath("~/App_Data/imageTemp/");
                if (p.DeveloperLogo != null)
                {
                    string extension           = p.DeveloperLogoContentType.Substring(p.DeveloperLogoContentType.LastIndexOf("/") + 1);
                    string tempDevLogoFilename = "devlogo_" + currentStatus.hashname.Replace("zip", extension);
                    using (FileStream stream = new FileStream(tempImagePath + tempDevLogoFilename, FileMode.Create))
                    {
                        stream.Write(p.DeveloperLogo, 0, p.DeveloperLogo.Length);
                    }

                    jsReturnParams.DeveloperLogoFilename = tempDevLogoFilename;
                }

                if (p.SponsorLogo != null)
                {
                    string extension = p.SponsorLogoContentType.Substring(p.SponsorLogoContentType.LastIndexOf("/") + 1);
                    string tempSponsorLogoFilename = "sponsorlogo_" + currentStatus.hashname.Replace("zip", extension);
                    using (FileStream stream = new FileStream(tempImagePath + tempSponsorLogoFilename, FileMode.Create))
                    {
                        stream.Write(p.SponsorLogo, 0, p.SponsorLogo.Length);
                    }

                    jsReturnParams.SponsorLogoFilename = tempSponsorLogoFilename;
                }
            }
        }
        dal.Dispose();
        return(jsReturnParams);
    }