private void fillProjects(User u)
        {
            VestnDB vestnDB = new VestnDB();
            Project project = new Project
            {
                name = "Test Project",
                description = "Test Description",
            };

            //Project Elements
            ProjectElement_Information informationElement;
            ProjectElement_Experience experienceElement;
            ProjectElement_Document documentElement;
            ProjectElement_Video videoElement;
            ProjectElement_Picture pictureElement;
            List<ProjectElement> projectElements;

            informationElement = new ProjectElement_Information
            {

                location = "Here",
                email = "*****@*****.**",
                school= "Univeristy of Nebraska- Lincoln",
                phone = "402-402-4111",
                major = "Actuarial Science",
                minor = "Business Administration",
                description = "tetetetetet"
            };
            documentElement = new ProjectElement_Document
            {
                description = "im a document",
                documentLocation = "asdfasdf"
            };
            experienceElement = new ProjectElement_Experience
            {
                jobTitle = "Owner",
                description = "I'm CEO Bitch.",
                startDate = new DateTime(1991, 6, 12),
                endDate = new DateTime(2011, 6, 12)
            };
            pictureElement = new ProjectElement_Picture
            {
                description = "im a picture",
                pictureLocation = "sadfsadfsa"
            };
            videoElement = new ProjectElement_Video
            {
                //put a test id you know in here haun
                videoId = "xxxxx",
                description = "asdfsadfasdf"
            };

            projectElements = new List<ProjectElement>();
            projectElements.Add(informationElement);
            projectElements.Add(experienceElement);
            projectElements.Add(documentElement);
            projectElements.Add(pictureElement);
            projectElements.Add(videoElement);

            //Save elements to project
            project.projectElements = projectElements;

            //Save Changes to DB
            VestnDB db = new VestnDB();
            db.projects.Add(project);
            if (u.projects == null)
            {
                u.projects = new List<Project>();
            }
            u.projects.Add(project);
            db.Entry(u).State = EntityState.Modified;
            db.SaveChanges();
        }
Beispiel #2
0
        public JsonModels.UploadReponse UploadPictureElement(int projectId, Stream pictureStream, string fileName, bool isCoverPicture = false)
        {
            try
            {
                BlobStorageAccessor blobStorageAccessor = new BlobStorageAccessor();
                UploadManager uploadManager = new UploadManager();
                ProjectAccessor projectAccessor = new ProjectAccessor();

                //initiate queue message
                storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("BlobConnectionString"));
                queueClient = storageAccount.CreateCloudQueueClient();
                queue = queueClient.GetQueueReference(messageQueueName);
                queue.CreateIfNotExist();

                string imageURI = blobStorageAccessor.uploadImage(pictureStream, false).ToString();
                Project p = pa.GetProject(projectId);
                if (isCoverPicture)
                {
                    string FileNameThumb1 = Guid.NewGuid().ToString();
                    string artifactURL1 = string.Format("{0}{1}", FileNameThumb1, ".jpeg");
                    CloudQueueMessage message3 = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", imageURI, p.id, "thumbnail", "ProjectPicture", 266, 266, "", artifactURL1));
                    queue.AddMessage(message3);
                    p.coverPictureThumbnail = RoleEnvironment.GetConfigurationSettingValue("storageAccountUrl").ToString() + "thumbnails/" + artifactURL1;
                    p.coverPicture = imageURI;

                    p.dateModified = DateTime.Now;

                    Project newP = projectAccessor.UpdateProject(p);
                    return new JsonModels.UploadReponse { id = p.id, fileURL = imageURI, name = fileName, galeriaURL = "noGalleryURL", artifactURL = artifactURL1, description = "default description" };
                }
                else
                {
                    string FileNameThumb = Guid.NewGuid().ToString();
                    string artifactURL = string.Format("{0}{1}", FileNameThumb, ".jpeg");
                    ProjectElement_Picture pe = new ProjectElement_Picture
                    {
                        title = GetTitle(fileName),
                        pictureLocation = imageURI,
                        pictureThumbnailLocation = RoleEnvironment.GetConfigurationSettingValue("storageAccountUrl").ToString()+"thumbnails/" + artifactURL
                    };
                    int projectElementId = pa.AddProjectElement(p, pe);
                    if (projectElementId == -1)
                    {
                        logAccessor.CreateLog(DateTime.Now, "ProjectManager - UploadPictureElement", "problem saving project element - 165 ProjectManager");
                        return null;
                    }

                    //string FileNameGaleria = Guid.NewGuid().ToString();
                    //string galleryURL = string.Format("{0}{1}", FileNameGaleria, ".jpeg");

                    CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", imageURI, projectElementId, "thumbnail", "PictureElement", 635, 397, "", artifactURL));
                    //CloudQueueMessage message2 = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", imageURI, projectElementId, "thumbnail", "PictureElement_Galleria", 1000, 750, "", galleryURL));
                    queue.AddMessage(message);
                    //queue.AddMessage(message2);
                    return new JsonModels.UploadReponse { id = projectElementId, fileURL = imageURI, name = fileName, galeriaURL = "galleryURL", artifactURL = artifactURL, description = null };
                }
            }
            catch (Exception ex)
            {
                logAccessor.CreateLog(DateTime.Now, "ProjectManager - UploadPictureElement", ex.StackTrace);
                return null;
            }
        }