private static void ListFiles(DriveService service, ref string pageToken) { // Define parameters of request. FilesResource.ListRequest listRequest = service.Files.List(); listRequest.Fields = "nextPageToken, files(id, name)"; listRequest.PageToken = pageToken; listRequest.Spaces = "drive"; listRequest.Q = "'10TVA8fya_XoPa0nwg7m2WPsqh_scfyK4' in parents"; //listRequest.Q = "'root' in parents"; request = listRequest.Execute(); if (request.Files != null && request.Files.Count > 0) { foreach (var file in request.Files) { GoogleDriveFilesRepository.DownloadFile(service, file); test.Add(new FileDetails() { FileID = file.Id, FileName = file.Name }); } pageToken = request.NextPageToken; } else { MessageBox.Show("No Files Found"); } }
public async Task <IHttpActionResult> UploadFileInFolder_SharingPermissonAsync(string folderId) { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var fileName = httpRequest.Files.Keys[0]; //foreach (string fileName in httpRequest.Files.Keys) //{ var file = httpRequest.Files[fileName]; var result = await GoogleDriveFilesRepository.FileUploadInFolder(folderId, file); if (result != null) { var x = GoogleDriveFilesRepository.FileSharingPermission(result); if (x) { return(Ok(result)); } return(null); } // } return(Ok(result)); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError()); } }
public ActionResult Checked(HttpPostedFileBase file) { string signature = GoogleDriveFilesRepository.checkWatermark(file); ViewBag.Message = signature; return(View()); }
public ActionResult UploadFile(String tenbaihat, String tentacgia, HttpPostedFileBase file) { string signature = GoogleDriveFilesRepository.FileUpload(tenbaihat, tentacgia, file); ViewBag.Message = signature; return(View()); }
public void UploadFile(FileClass _file, TransactionRepository _transactionRepository, string _memberID) { var FileContract = InitContract(); // Validate the uploaded image(optional) int imageId = _transactionRepository.NextID().FirstOrDefault(); string imagepath = ConfigurationManager.AppSettings["FileImagePath"]; string imageName = imageId.ToString() + '_' + _memberID + '_' + _file.image.FileName.ToString(); // Get the complete file path string fileSavePath = Path.Combine(imagepath + imageName); _file.image.SaveAs(fileSavePath); //BackUp File Google Drive string GoogleItemID = GoogleDriveFilesRepository.UploadImage(fileSavePath, imageName, _file.image.ContentType); //Blockchain var TaskAddFile = FileContract.GetFunction("AddFiles").SendTransactionAsync(HttpContext.Current.Session["Address"].ToString(), imageId, ConvertSavedFileToSha(fileSavePath), GoogleItemID, DateTime.Now.ToString()); TaskAddFile.Wait(); //Database var transaction = new TransactionData() { id = imageId, member_id = Int32.Parse(_memberID.ToString()), filename = imageName, filepath = imagepath, date = DateTime.Now.ToString() }; _transactionRepository.Add(transaction); }
public async Task <IHttpActionResult> UploadFileAsync() { try { var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var fileName = httpRequest.Files.Keys[0]; //foreach (string fileName in httpRequest.Files.Keys) //{ var file = httpRequest.Files[fileName]; var defaultFolderId = Environment.GetEnvironmentVariable("DEFAULT_FOLDER"); var result = await GoogleDriveFilesRepository.FileUploadInFolder(defaultFolderId, file); if (result != null) { var x = GoogleDriveFilesRepository.FileSharingPermission(result.ToString()); if (x) { return(Ok(result)); } return(null); } // } return(Ok(result)); } return(InternalServerError()); } catch (Exception ex) { return(InternalServerError()); } }
public FormChat(IClient client, ChatDataModel.Account account, IAudioCall phoneCall) { InitializeComponent(); _client = client; _user = account; Stream imageMe, imageFriend; string myName = ""; lock (this) { imageMe = GoogleDriveFilesRepository.DownloadFile(Util.Instance.CurrentUser.AvatarDriveID); myName = Util.Instance.CurrentUser.Name; } imageFriend = GoogleDriveFilesRepository.DownloadFile(_user.AvatarDriveID); _ptbFriendsAvatar.Image = Image.FromStream(imageFriend); _ptbFriendsAvatar.SizeMode = PictureBoxSizeMode.StretchImage; _lbFriendsName.Text = _user.Name; authorMe = new Author(Image.FromStream(imageMe), myName); authorFriend = new Author(Image.FromStream(imageFriend), _user.Name); _rcChatlog.Author = authorMe; //gửi yêu cầu lấy lịch sử chat _client.RequestGetHistory(Util.Instance.CurrentUser.Email, _user.Email); _rcChatlog.ChatElement.ShowToolbarButtonElement.Click += ShowToolbarButtonElement_Click; _rcChatlog.ChatElement.SendButtonElement.Click += SendButtonElement_Click; _rcChatlog.CardActionClicked += _rcChatlog_CardActionClicked; _rcChatlog.ChatElement.MessagesViewElement.BackColor = Color.White; _rcChatlog.AutoScroll = false; _phoneCall = phoneCall; _phoneCall.CallStateChange += _phoneCall_CallStateChange; }
public ActionResult LayDuLieu() { db.sp_LayDuLieu(); List <GoogleDriveFiles> lstDataMaster = GoogleDriveFilesRepository.GetDriveFiles(); foreach (var item in lstDataMaster) { if (!item.Name.Contains("MUCLUC") && !item.Name.Contains("MUC LUC") && !item.Name.Contains("BOSUNG") && !item.Name.Contains("TAILIEUHUONGDAN") && !item.Name.Contains("PHIEUKIEMTRA")) { List <GoogleDriveFiles> lstDataDetail = GoogleDriveFilesRepository.GetSubDriveFiles(item.Id); foreach (var item1 in lstDataDetail) { Guid soid = Guid.NewGuid(); db.sp_CapNhapMaster(soid, item1.Name, item.Name, "Linh", DateTime.Now); List <GoogleDriveFiles> lstDataDetailDoc = GoogleDriveFilesRepository.GetSubDriveFiles(item1.Id); foreach (var item2 in lstDataDetailDoc) { Guid id = Guid.NewGuid(); db.sp_CapNhapDetail(id, soid, item2.Name, item2.Id, item2.Num); } } } //db.sp_CapNhapMaster(soid,item.Name,item.); } return(RedirectToAction("GetGoogleDriveFiles", "QuanLyDuLieu")); }
public ActionResult Create(ViewModel VN, HttpPostedFileBase ImageeExPrincipale, string[] Outildata, string[] ConseilData, IEnumerable <HttpPostedFileBase> UploadImage, List <string> UploadTitle, IEnumerable <HttpPostedFileBase> UploadDrive, List <string> UploadTitleDrive) { if (ModelState.IsValid) { //Ajouter Expiriment---------------------------------------------- var ImageExprirmentPath = Path.Combine(Server.MapPath("~/Images/ImageExpiriment"), ImageeExPrincipale.FileName); ImageeExPrincipale.SaveAs(ImageExprirmentPath); VN.Expiriment.ApplicationUserId = User.Identity.GetUserId(); VN.Expiriment.DateTime = DateTime.Now; VN.Expiriment.Image = ImageeExPrincipale.FileName; VN.Expiriment.IdFilliere = string.Join(",", VN.Expiriment.SelectedArrayFilliere); db.Expiriments.Add(VN.Expiriment); db.SaveChanges(); //------------------------------Ajouter Outils-------------------------------------- OutilConseilImage.SaveOutil(Outildata, VN.Expiriment.Id); //------------------------------Ajouter Conseil-------------------------------------- OutilConseilImage.SaveConseil(ConseilData, VN.Expiriment.Id); //Ajouter Image---------------------------------------------------------------------- OutilConseilImage.saveImage(UploadImage, UploadTitle, VN.Expiriment.Id); //Ajouter Fichier pour telecharger GoogleDriveFilesRepository.FileUpload(UploadDrive, UploadTitleDrive, VN.Expiriment.Id); return(RedirectToAction("Index")); } return(View()); }
public JsonResult Render_GetGoogleDriveFilesView() { Dictionary <string, object> jsonResult = new Dictionary <string, object>(); var result = GoogleDriveFilesRepository.GetDriveFiles(); jsonResult.Add("Html", RenderRazorViewToString("~/Views/Home/GetGoogleDriveFiles1.cshtml", result)); return(Json(jsonResult, JsonRequestBehavior.AllowGet)); }
public ActionResult UploadFile(String tenbaihat, String tentacgia, HttpPostedFileBase file) { string signature = GoogleDriveFilesRepository.FileUpload(tenbaihat, tentacgia, file); ViewBag.Message = signature; ViewBag.ses = (UserLogin)Session[CommonConstants.User_Session]; return(View()); }
public ActionResult GetGoogleDriveFiles() { if (Session["TaiKhoan"] != null) { return(View(GoogleDriveFilesRepository.GetDriveFiles(Session["Drive"].ToString()))); } return(RedirectToAction("DangNhap", "TaiKhoan")); }
public ActionResult GetSubGoogleDriveFiles(string folderId) { if (Session["TaiKhoan"] != null) { return(View(GoogleDriveFilesRepository.GetSubDriveFiles(folderId))); } return(RedirectToAction("DangNhap", "TaiKhoan")); }
public void ReceiveMediaMessage(ChatDataModel.ChatMessage message) { var stream = GoogleDriveFilesRepository.DownloadFile(message.ImageMessageDriveID); var img = Image.FromStream(stream); var displayImage = ResizeImagePercentage(img); ChatMediaMessage mess = new ChatMediaMessage(displayImage, displayImage.Size, null, authorFriend, message.TimeSend); _rcChatlog.AddMessage(mess); }
public void UploadFile(HttpPostedFileBase file) { String id = GoogleDriveFilesRepository.FileUploadInFolder("1ErWnUiDbV_hmEVcYYojELOje6LsNnBtP", file); if (id != null) { Response.Redirect("http://127.0.0.1:8080/songs/Create?id=" + id); } }
public void LoadHistory() { foreach (var item in messages) { if (item.ImageMessageDriveId != "") { var download = GoogleDriveFilesRepository.DownloadFile(item.ImageMessageDriveId); var img = ResizeImagePercentage(Image.FromStream(download)); if (item.Sender == _me.Email) { ChatMediaMessage mess = new ChatMediaMessage(img, img.Size, "", _authorMe, item.TimeSend); _radchatChatGroup.AddMessage(mess); } else if (item.Sender != _me.Email) { Author auth; if (_authorFriends.TryGetValue(item.Sender, out auth)) { ChatMediaMessage mess = new ChatMediaMessage(img, img.Size, "", auth, item.TimeSend); _radchatChatGroup.AddMessage(mess); } else { Author author = new Author(null, item.Sender); ChatMediaMessage mess = new ChatMediaMessage(img, img.Size, "", author, item.TimeSend); _radchatChatGroup.AddMessage(mess); } } } else if (item.Message != "") { if (item.Sender == _me.Email) { ChatTextMessage mess = new ChatTextMessage(item.Message, _authorMe, item.TimeSend); _radchatChatGroup.AddMessage(mess); } else if (item.Sender != _me.Email) { Author auth; if (_authorFriends.TryGetValue(item.Sender, out auth)) { ChatTextMessage mess = new ChatTextMessage(item.Message, auth, item.TimeSend); _radchatChatGroup.AddMessage(mess); } else { Author author = new Author(null, item.Sender); ChatTextMessage mess = new ChatTextMessage(item.Message, author, item.TimeSend); _radchatChatGroup.AddMessage(mess); } } } } _isLoadHistory = true; }
public void DownloadFile(string id) { string FilePath = GoogleDriveFilesRepository.DownloadGoogleFile(id); Response.ContentType = "application/zip"; Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(FilePath)); Response.WriteFile(System.Web.HttpContext.Current.Server.MapPath("~/GoogleDriveFiles/" + Path.GetFileName(FilePath))); Response.End(); Response.Flush(); }
// GET: GoogleDrive public ActionResult Index() { // Get file name string uploadedFileName = System.Web.HttpContext.Current.Session["uploadedFileName"] as String; // Upload file to Google Drive GoogleDriveFilesRepository.UploadFileToGoogleDrive(uploadedFileName); return(RedirectToAction("GetGoogleDriveFiles")); }
public void UpdateAvatar(string driveFileId) { Thread thread = new Thread(delegate() { var file = GoogleDriveFilesRepository.DownloadFile(driveFileId); _ptbAvatar.SizeMode = PictureBoxSizeMode.StretchImage; _ptbAvatar.Image = Image.FromStream(file); }); thread.Start(); }
public IActionResult DownloadImage(string CPF) { if (GoogleDriveFilesRepository.VerifyImage("admin_" + CPF) == "404") { return(StatusCode(404, "Image not found!")); } else { return(StatusCode(200, "https://drive.google.com/uc?id=" + GoogleDriveFilesRepository.LoadImage("admin_" + CPF))); } }
static void Main() { Console.WriteLine("Running"); GoogleDriveFilesRepository.FileUpload("Output2020_09_03.csv"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); //Application.Run(new Form1()); }
private void LoadMyAvatar(string fileId) { Stream result = null; Thread thread = new Thread(delegate() { result = GoogleDriveFilesRepository.DownloadFile(fileId); _authorMe.Avatar = Image.FromStream(result); }); thread.Start(); }
public JsonResult FolderLists() { List <GoogleDriveFile> AllFolders = GoogleDriveFilesRepository.GetDriveFolders(); List <DDLOptions> obj = new List <DDLOptions>(); foreach (GoogleDriveFile EachFolder in AllFolders) { obj.Add(new DDLOptions { Id = EachFolder.Id, Name = EachFolder.Name }); } return(Json(obj, JsonRequestBehavior.AllowGet)); }
private void _radLVFriendRequest_ItemDataBound(object sender, ListViewItemEventArgs e) { Thread thread = new Thread(delegate() { var image = Image.FromStream(GoogleDriveFilesRepository.DownloadFile(((ChatDataModel.Account)e.Item.DataBoundItem).AvatarDriveID)); _radlvFriendList.Invoke(new MethodInvoker(delegate() { e.Item.Image = ImageConverter.ImageResize.ResizeImageCircle(image, 42); })); }); thread.Start(); }
private void _ptbChinhSua_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Choose Image"; dialog.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"; if (dialog.ShowDialog() == DialogResult.OK) { string path = dialog.InitialDirectory + @"\" + dialog.FileName; var fileID = GoogleDriveFilesRepository.UploadFile(path.Substring(1)); _client.RequestUpdateAvatar(_account.Email, fileID); } }
private void btnUploadtoGGDrive_Click(object sender, RoutedEventArgs e) { string id = GoogleDriveFilesRepository.CreateFolder("1, Demo"); foreach (FileDesignDTO dgr in dgvImageInfo.ItemsSource) { Thread thread = new Thread(() => { UploadTOGGDrive(dgr, id); }); thread.IsBackground = true; thread.Start(); } }
//author:Vamsi //date: 23/03/2020 //To generate latest invoice pdf public void GenerateInvoicePDF(string vc_invoice_number, string invoice_date, long?invoiceId, long?userId) { if (invoiceId != null && invoiceId != 0) { invoiceMethods.DeleteInvoicePdfFromGDrive(invoiceId); } var actionPDF = GenerateInvoicePDFinByteArray(vc_invoice_number, invoice_date, invoiceId, userId); var UserDetails = adminMethods.GetAllIBWUsers().Where(x => x.int_user_id == userId).FirstOrDefault(); string invoicefilename = UserDetails != null ? vc_invoice_number + "-" + UserDetails.vc_user_name + " " + UserDetails.vc_alias_name + "-" + invoice_date + " - " + DateTime.Now.ToString("hh:mm tt") : vc_invoice_number + "-" + invoice_date + " - " + DateTime.Now.ToString("hh:mm tt"); string FileId = GoogleDriveFilesRepository.UploadInvoiceFiletoGoogleDrivefolder("", invoicefilename, actionPDF); string invoiceaccesslink = GoogleDriveFilesRepository.GetSharableLink(FileId); invoiceMethods.UpdateInvoiceGoogleDriveDetails(invoiceId, FileId, invoiceaccesslink); }
//https://console.developers.google.com/apis/dashboard?project=aspdotnetcsharp-221915&duration=PT1H //public IGoogleDriveApiConnection googleDriveApiConnection; //public FileUploadController(IGoogleDriveApiConnection googleDriveApiConnection) //{ // this.googleDriveApiConnection = googleDriveApiConnection; //} // GET: FileUpload public ActionResult Upload() { List <GoogleDriveFiles> result = null; try { result = GoogleDriveFilesRepository.GetDriveFiles(); } catch (Exception ex) { return(RedirectToAction("GoogleDriveConnectionError")); } return(View(result)); }
public void DownloadFile(string id) { string FilePath = GoogleDriveFilesRepository.DownloadGoogleFile(id); Response.ContentType = "application/zip"; Response.Headers.Add("content-disposition", "attachment; filename=" + Path.GetFileName(FilePath)); string path = Path.Combine(_env.ContentRootPath, "~/GoogleDriveFiles/", Path.GetFileName(FilePath)); byte[] data = Encoding.ASCII.GetBytes(path); Response.Body.Write(data, 0, data.Length); //Response.StatusCode = StatusCodes.Status200OK; Response.Body.FlushAsync(); }
private void Init() { //_ptbChinhSua.BackColor = Color.FromArgb(200, 255, 255, 255); _lbUserName.Text = _account.Name; Thread thread = new Thread(delegate() { var file = GoogleDriveFilesRepository.DownloadFile(_account.AvatarDriveID); _ptbAvatar.SizeMode = PictureBoxSizeMode.StretchImage; _ptbAvatar.Image = Image.FromStream(file); }); thread.Start(); _radlvFriendList.AllowEdit = false; _radlvFriendList.AllowRemove = false; _radlvFriendList.VisualItemCreating += VisualItemCreating; _radlvFriendList.ItemDataBound += _radlvFriendList_ItemDataBound; _radlvFriendList.ItemSize = new Size(_radlvFriendList.ItemSize.Width, 50); _radlvFriendList.ItemMouseClick += _radlvFriendList_ItemMouseClick; _radlvFriendList.ItemMouseDown += _radlvFriendList_ItemMouseDown; _btnCreateGroupChat.AutoSizeMode = AutoSizeMode.GrowAndShrink; _btnCreateGroupChat.Click += _btnCreateGroupChat_Click; _btnAddFriend.Click += _btnAddFriend_Click; _radLVFriendRequest.ItemMouseClick += _radLVFriendRequest_ItemMouseClick; InitGroupsChat(); InitListFriendRequest(); if (!_client.IsSending) { SendRequestGetListGroup(); } if (!_client.IsSending) { _client.RequestGetListFriendRequest(_account.Email); } if (!_client.IsSending) { _client.RequsetGetListFriend(_account.Email); } _client.RequestGetListFriendIRequest(_account.Email); }