A container for parameters to be passed as defaults for Step 3 Upload form inputs
Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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;
    }