Esempio n. 1
0
        public ActionResult Upload(HttpPostedFileBase uploadedfile, string owner, string description)
        {
            if (uploadedfile != null && uploadedfile.ContentLength > 0)
            {
                #region Blob Storage code
                // Create Blob client
                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                // Get reference to the container and create it if it doesn't exist
                CloudBlobContainer uploadContainer = blobClient.GetContainerReference("uploadcontainer");
                uploadContainer.CreateIfNotExists();

                // Set permissions
                uploadContainer.SetPermissions(new BlobContainerPermissions {
                    PublicAccess = BlobContainerPublicAccessType.Container
                });

                // Get a reference to the blob
                CloudBlockBlob blob = uploadContainer.GetBlockBlobReference(uploadedfile.FileName);

                // Upload the file to the blob
                blob.UploadFromStream(uploadedfile.InputStream);
                #endregion

                #region Table code
                // Create Table client
                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                CloudTable       table       = tableClient.GetTableReference("fileuploads");
                table.CreateIfNotExists();

                // Initialize the FileUploadEntity "row"
                var fileUploadEntity = new FileUploadEntity(owner);
                fileUploadEntity.Description = description;
                fileUploadEntity.Url         = blob.Uri.ToString();

                // Save the row
                TableOperation insertOperation = TableOperation.Insert(fileUploadEntity);
                table.Execute(insertOperation);
                #endregion

                #region Queue code
                // Create Queue cient
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
                CloudQueue       queue       = queueClient.GetQueueReference("fileuploadsqueue");
                queue.CreateIfNotExists();

                // Create a message with the blob URL as content and add it to the queue
                CloudQueueMessage message = new CloudQueueMessage(blob.Uri.ToString());
                queue.AddMessage(message);
                #endregion
            }

            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult savedocuments(FileUploadEntity fileUploadEntity, string SendCompanyName)
        {
            ClientBLL clientBLL = new ClientBLL();
            string    path      = Server.MapPath("~/Documents/");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string DocumentName = Path.GetFileNameWithoutExtension(fileUploadEntity.UploadFile.FileName);
            string Extention    = Path.GetExtension(fileUploadEntity.UploadFile.FileName).Replace(".", "");
            string Ext          = Path.GetExtension(fileUploadEntity.UploadFile.FileName);
            string fileName     = DocumentName + Ext;

            fileUploadEntity.UploadFile.SaveAs(path + fileName);
            fileUploadEntity.DocumentName = DocumentName;
            fileUploadEntity.Extension    = Extention;

            if (fileUploadEntity.Monthly != "")
            {
                fileUploadEntity.Quaterly = "";
            }
            if (fileUploadEntity.Quaterly != "")
            {
                fileUploadEntity.Monthly = "";
            }
            if (fileUploadEntity.DocumentType == "Other")
            {
                fileUploadEntity.DocumentType = fileUploadEntity.OtherDocuments;
            }
            clientBLL.Savedocuments(fileUploadEntity);
            clientBLL.InsertDocumentType(fileUploadEntity.DocumentType);
            //clientBLL.InsertDocumentType(fileUploadEntity.DocumentType);
            tblUser tbluser = pablaAccountsEntities.tblUsers.SingleOrDefault(b => b.UserId == fileUploadEntity.UserId);

            string htmlBody   = "";
            string headerText = "Hi <b> " + tbluser.FirstName + " " + tbluser.LastName + " ,</b>";
            string startTable = "<table>";
            string emailText  = "<tr><td><br/>A document has been uploaded for the person name  <b> " + fileUploadEntity.PersonName + " </b> of the company " + SendCompanyName + " with document type  <b> " + fileUploadEntity.DocumentType + " </b>. Please find an attachment below:-</br></br></td></tr>";

            emailText += "<tr><td>Regards</td></tr>";
            emailText += "<tr><td><b>Pabla Accounting And Tax Services</b></td></tr>";
            string endTable = "<br/></table> </br> </br> Thanks";

            htmlBody = headerText + startTable + emailText + endTable;
            string fullfilepath = path + fileName;

            customMethod.SendEmail(tbluser.Email, "Document Uploaded", htmlBody, fullfilepath);
            TempData["Message"] = "3";
            return(RedirectToAction("client_view", new { ClientId = fileUploadEntity.UserId }));
        }
Esempio n. 3
0
        public ActionResult add_document(FileUploadEntity fileUploadEntity)
        {
            ClientBLL clientBLL = new ClientBLL();
            string    path      = Server.MapPath("~/Documents/");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string DocumentName = Path.GetFileNameWithoutExtension(fileUploadEntity.UploadFile.FileName);
            string Extention    = Path.GetExtension(fileUploadEntity.UploadFile.FileName).Replace(".", "");
            string Ext          = Path.GetExtension(fileUploadEntity.UploadFile.FileName);
            string fileName     = DocumentName + Ext;

            fileUploadEntity.UploadFile.SaveAs(path + fileName);
            fileUploadEntity.DocumentName = DocumentName;
            fileUploadEntity.Extension    = Extention;
            if (fileUploadEntity.DocumentType == "Other")
            {
                fileUploadEntity.DocumentType = fileUploadEntity.Other;
            }
            clientBLL.Savedocuments(fileUploadEntity);
            clientBLL.InsertDocumentType(fileUploadEntity.DocumentType);
            var     result  = pablaAccountsEntities.tbl_RequestedDocument.SingleOrDefault(b => b.RequestDocumentId == fileUploadEntity.RequestedDocumentId);
            tblUser tbluser = new tblUser();

            if (result != null)
            {
                result.IsUploaded = true;
                pablaAccountsEntities.SaveChanges();
                tbluser = pablaAccountsEntities.tblUsers.SingleOrDefault(b => b.UserId == result.RequestedBy);
            }
            string htmlBody   = "";
            string headerText = "Hi <b> " + tbluser.FirstName + " " + tbluser.LastName + " ,</b>";
            string startTable = "<table>";
            string emailText  = "<tr><td><br/>As per Your request for addition of document named as <b> " + result.DocumentName + " </b> of Document Type <b> " + result.DocumentType + " </b> for <b> " + fileUploadEntity.PersonName + " </b> , We have uploaded a document, Please find an attachment below:-</br></br></td></tr>";

            emailText += "<tr><td>Regards</td></tr>";
            emailText += "<tr><td><b>Pabla Accounting And Tax Services</b></td></tr>";
            string endTable = "<br/></table> </br> </br> Thanks";

            htmlBody = headerText + startTable + emailText + endTable;
            string fullfilepath = path + fileName;

            customMethod.SendEmail(tbluser.Email, "Document Uploaded", htmlBody, fullfilepath);
            TempData["Messsage"] = "3";
            return(RedirectToAction("requested_document", "admin"));
        }
Esempio n. 4
0
        public ActionResult add_document(int requestedDocumentId, string clientName)
        {
            FileUploadEntity fileuploadentity = new FileUploadEntity();
            var result = pablaAccountsEntities.tbl_RequestedDocument.SingleOrDefault(b => b.RequestDocumentId == requestedDocumentId);

            if (result != null)
            {
                fileuploadentity.UserId              = (int)result.RequestedBy;
                fileuploadentity.PersonName          = result.PersonName;
                fileuploadentity.year                = result.Year;
                fileuploadentity.DocumentType        = result.DocumentType;
                fileuploadentity.Other               = result.Other;
                fileuploadentity.Monthly             = result.Monthly;
                fileuploadentity.Periodending        = result.Periodending;
                fileuploadentity.RequestedDocumentId = requestedDocumentId;
            }
            ViewBag.ClientName = clientName;
            return(View(fileuploadentity));
        }
Esempio n. 5
0
 public void Savedocuments(FileUploadEntity fileUploadEntity)
 {
     client.Savedocuments(fileUploadEntity);
 }
Esempio n. 6
0
 public void Savedocuments(FileUploadEntity fileUploadEntity)
 {
     pablaAccountsEntities.usp_insertclientdocument(fileUploadEntity.UserId, fileUploadEntity.PersonName, fileUploadEntity.DocumentType, fileUploadEntity.year, fileUploadEntity.DocumentName, fileUploadEntity.Extension, fileUploadEntity.OtherDocuments, fileUploadEntity.Periodending, fileUploadEntity.Monthly, fileUploadEntity.Quaterly);
 }