Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        public JsonModels.UploadReponse AddDocumentElement(int projectId, string description, Stream fileStream, string fileName, string userName)
        {
            Project p = pa.GetProject(projectId);
            BlobStorageAccessor ba = new BlobStorageAccessor();
            string location = null;
            string[] s2 = fileName.Split('.');
            string extention = s2[s2.Count() - 1].ToLower();

            UserAccessor ua = new UserAccessor();
            User u = ua.GetUser(userName);
            string fullName = u.firstName +" " +  u.lastName;

            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("BlobConnectionString"));
            queueClient = storageAccount.CreateCloudQueueClient();
            queue = queueClient.GetQueueReference(messageQueueName);
            queue.CreateIfNotExist();
            string documentText = "";

            //string PDFLocation = "notset";
            if (extention == "pdf")
            {
                location = ba.uploadPDF(fileStream, false).ToString();
                UploadManager um = new UploadManager();
                //location = um.stampThatShit(location, fullName, null);
                //documentText = um.ExtractText(location);
            }
            else if (extention == "doc" || extention == "docx")
            {
                location = ba.uploadDOC(fileStream, false, "."+extention).ToString();
            }
            else if (extention == "ppt" || extention == "pptx")
            {
                location = ba.uploadUnknown(fileStream, false, extention).ToString();
            }
            else if( extention == "xls" || extention == "xlsx")
            {
                location = ba.uploadUnknown(fileStream,false, extention).ToString();
            }
            else if (extention == "rtf")
            {
                location = ba.uploadUnknown(fileStream, false, extention).ToString();
            }
            else if (extention == "txt")
            {
                location = ba.uploadUnknown(fileStream, false, extention).ToString();
            }
            else
            {
                //upload unknown file type. do this or display message
                Uri result = ba.uploadUnknown(fileStream, false, extention);
                if (result == null)
                {
                    return null;
                }
                else
                {
                    location = result.ToString();
                }
            }
            String FileName = Guid.NewGuid().ToString();
            string uniqueBlobName = string.Format("{0}{1}", FileName, ".pdf");
            string docThumb = "";
            if (extention == "pdf")
            {
                docThumb = location;
            }
            else
            {
                docThumb = RoleEnvironment.GetConfigurationSettingValue("storageAccountUrl").ToString()+"pdfs/" + uniqueBlobName;
            }
            ProjectElement_Document pe = new ProjectElement_Document
            {
                description = description,
                documentLocation = location,
                title = fileName,
                documentText = documentText,
                documentThumbnailLocation = docThumb
            };
            int projectElementId = pa.AddProjectElement(p, pe);
            if (extention == "doc" || extention == "docx")
            {
                CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", location, projectElementId, "documentConversion", @"http://do.convertapi.com/Word2Pdf", 0, 0, fullName, uniqueBlobName));
                queue.AddMessage(message);
            }
            else if (extention == "ppt" || extention == "pptx")
            {
                CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", location, projectElementId, "documentConversion", @"http://do.convertapi.com/PowerPoint2Pdf", 0, 0, "", uniqueBlobName));
                queue.AddMessage(message);
            }
            else if( extention == "xls" || extention == "xlsx")
            {
                CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", location, projectElementId, "documentConversion", @"http://do.convertapi.com/Excel2Pdf", 0, 0, fullName, uniqueBlobName));
                queue.AddMessage(message);
            }
            else if (extention == "rtf")
            {
                CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", location, projectElementId, "documentConversion", @"http://do.convertapi.com/RichText2Pdf", 0, 0, fullName, uniqueBlobName));
                queue.AddMessage(message);
            }
            else if (extention == "txt")
            {
                CloudQueueMessage message = new CloudQueueMessage(String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", location, projectElementId, "documentConversion", @"http://do.convertapi.com/Text2Pdf", 0, 0, fullName, uniqueBlobName));
                queue.AddMessage(message);
            }
            if (extention == "pdf")
            {
                return new JsonModels.UploadReponse { id = projectElementId, fileURL = location, name = fileName, artifactURL = location };
            }
            return new JsonModels.UploadReponse { id = projectElementId, fileURL = location, artifactURL = docThumb, name = fileName };
        }