예제 #1
0
        public async override void StreamThread()
        {
            // 다운로드시 보일 라벨과 프로그래스 바를 설정해준다.
            label.Text       = "0%";
            label.Name       = "label";
            label.AutoSize   = true;
            progress.Value   = 0;
            progress.Maximum = 100;
            progress.Controls.Add(label);
            progress.Size = new System.Drawing.Size(181, 23);
            this.OnControl(this, progress);
            FolderInfo folders = new FolderInfo();

            folders.isfile = false;
            //folder.directory = new List<System.IO.DirectoryInfo>();
            this.maxsize += await CreateDirectory(folders, localfolder, localfolder.FullName);

            // 폴더안에 파일들을 가져오는 함수 시작
            // 업로드를 시작한다.
            CloudFiles file = await folder.CreateFolder(System.IO.Path.GetFileName(localfolder.FullName), this.fileid);

            await UpFolder(folders, file.Item.FileID);

            this.OnProgressChange(this, this.maxsize, this.maxsize, this.progress);
            // 업로드 완료시 이벤트 발생
            this.OnComplete(this, progress, file, this.fileid, group);
        }
예제 #2
0
        public ActionResult UploadPatientReport(CloudFiles cloudfiles, HttpPostedFileBase report)
        {
            string skey = null;

            cloudfiles.DoctorId   = ((CustomPrincipal)HttpContext.User).UserId;
            cloudfiles.Date       = DateTime.Now;
            cloudfiles.DoctorName = ((CustomPrincipal)HttpContext.User).Username;

            var chars  = "ABCDEFGHI1234567890JKLMNOPQRSTUVWXYZabcdefghijklmn#@!*&%opqrstuvwxyz";
            var random = new Random();
            var result = new string(
                Enumerable.Repeat(chars, 5)
                .Select(s => s[random.Next(s.Length)])
                .ToArray());

            skey = result.ToString();
            cloudfiles.SecretKey = skey;

            cloudfiles.Filename    = Path.GetFileName(report.FileName);
            cloudfiles.Contentype  = report.ContentType;
            cloudfiles.PatientName = ReadPatientRegisterationTable(database()).FindAll().FirstOrDefault(s => s.PatientId == cloudfiles.PatientId).PatientName;
            using (Stream fs = report.InputStream)
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] bytes = br.ReadBytes((Int32)fs.Length);
                    var    db    = database();
                    cloudfiles.Data = bytes;
                    CreateCloudFiles(cloudfiles, db);
                }
            }
            this.AddToastMessage("", "Updated Patient Info Sucessfull", ToastType.Info);
            return(RedirectToAction("ListPatientReport", "Doctors"));
        }
예제 #3
0
        private MongoCollection <CloudFiles> CreateCloudFiles(CloudFiles cloudFileRecord, MongoDatabase mongoDatabase)
        {
            MongoCollection <CloudFiles> cloudFiles = mongoDatabase.GetCollection <CloudFiles>("CloudFiles");

            cloudFiles.Insert(cloudFileRecord);
            return(cloudFiles);
        }
예제 #4
0
        public async Task <CloudFiles> CreateFolder(string foldername, string parentid)
        {
            string method = "POST";
            string uri    = "https://api.dropbox.com/1/fileops/create_folder";
            Dictionary <string, string> parameter = new Dictionary <string, string>();

            parameter.Add("root", "auto");
            if (parentid == "root")
            {
                parentid = "/";
            }
            parentid += "/" + foldername;
            parameter.Add("path", parentid);
            try
            {
                System.Net.HttpWebResponse rp = await HttpHelper.RequstHttp(method, uri, parameter, driveinfo.token.access_token, null, null, 0, 0, 0);

                Dictionary <string, object> dic = HttpHelper.DerealizeJson(rp.GetResponseStream());
                CloudFiles file = AddFiles(dic);
                return(file);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #5
0
 protected void OnComplete(object sender, Control control, CloudFiles item = null, string fileid = null, ListViewGroup group = null)
 {
     if (this.StreamCompleteCallback != null)
     {
         this.StreamCompleteCallback(sender, control, item, fileid, group);
     }
 }
예제 #6
0
 public CreateFolder(CloudFiles file, NewFileOption option)
 {
     InitializeComponent();
     this.file    = file;
     label1.Text  = "파일 명 : ";
     tb_PATH.Text = file.Item.Path;
     this.option  = option;
 }
예제 #7
0
        private async void AllSerach()
        {
            foreach (var item in Setting.driveinfo)
            {
                CloudFiles files = null;
                if (item.token.Drive == "Google")
                {
                    string query     = "title = " + "'" + serchname + "'";
                    var    parameter = new Dictionary <string, string>
                    {
                        { "q", query }
                    };

                    var result = await HttpHelper.RequstHttp("GET", "https://www.googleapis.com/drive/v2/files", parameter, item.token.access_token);

                    Dictionary <string, object> fileinfo = HttpHelper.DerealizeJson(result.GetResponseStream());
                    object[] items = (object[])fileinfo["items"];
                    googlecloud1.Folder.GoogleFolder folder = new Folder.GoogleFolder(item);
                    foreach (var fi in items)
                    {
                        files = folder.AddFiles((Dictionary <string, object>)fi);
                        file.Add(files);
                    }
                }
                else if (item.token.Drive == "OneDrive")
                {
                    var parameter = new Dictionary <string, string>
                    {
                        { "q", serchname }
                    };
                    var result = await HttpHelper.RequstHttp("GET", "https://api.onedrive.com/v1.0/drive/root/view.search", parameter, item.token.access_token);

                    Dictionary <string, object> fileinfo = HttpHelper.DerealizeJson(result.GetResponseStream());
                    object[] items = (object[])fileinfo["value"];
                    googlecloud1.Folder.OneDriveFolder folder = new Folder.OneDriveFolder(item);
                    foreach (var fi in items)
                    {
                        files = folder.AddFiles((Dictionary <string, object>)fi);
                        file.Add(files);
                    }
                }
                else if (item.token.Drive == "DropBox")
                {
                    var parameter = new HttpParameterCollection()
                    {
                        { "query", serchname },
                        { "access_token", item.token.access_token }
                    };
                    var result = OAuthUtility.Get("https://api.dropboxapi.com/1/search/auto//", parameter);
                    googlecloud1.Folder.DropBoxFolder folder = new Folder.DropBoxFolder(item);
                    foreach (RequestResult re in result)
                    {
                        files = folder.AddFiles(re.ToDictionary());
                        file.Add(files);
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// 드라이브 정보를 받아옴
 /// </summary>
 /// <returns></returns>
 public async Task Signin()
 {
     service = Authentication.AuthenticateOauth("892886432316-smcv78utjgpp1iec18v67amr2gigv24m.apps.googleusercontent.com", "eyOFpG-LFIfp8ad3usTL81LG", "bit12");
     if (service != null)
     {
         item = new GoogleFile(service);
         await LoadFolderFromId("root");
     }
 }
예제 #9
0
        public System.Drawing.Image GetCustomIcon(CloudFiles files)
        {
            SHFILEINFO sfi = new SHFILEINFO();

            if (files.Item.Extention != null)
            {
                SHGetFileInfo("." + files.Item.Extention.ToUpper(), FILE_ATTRIBUTE_NORMAL, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME | SHGFI_SYSICONINDEX);
                if (sfi.szTypeName.ToUpper() == " 프로그램")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186290_gdm_xnest));
                }
                else if (files.Item.Extention.ToUpper() == "PDF")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186074_pdf));
                }
                else if (sfi.szTypeName == "이미지")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186415_photos));
                }
                else if (files.Item.Extention.ToUpper() == "ZIP" || files.Item.Extention.ToUpper() == "ALZ")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186516_1));
                }
                else if (files.Item.Extention.ToUpper() == "DLL")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186520_12));
                }
                else if (files.Item.Extention.ToUpper() == "BAT")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186523_14));
                }
                else if (files.Item.Extention.ToUpper() == "AVI" || files.Item.Extention.ToUpper() == "MP4")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources._1439186533_11));
                }
                else if (files.Item.Extention.ToUpper() == "DOC" || files.Item.Extention.ToUpper() == "DOCX")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources.icon_doc));
                }
                else if (files.Item.Extention.ToUpper() == "PPT" || files.Item.Extention.ToUpper() == "PPTX")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources.icon_ppt));
                }
                else if (files.Item.Extention.ToUpper() == "XLS" || files.Item.Extention.ToUpper() == "XLSX")
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources.icon_xls));
                }
                else
                {
                    return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources.icon_default));
                }
            }
            else
            {
                return(new System.Drawing.Bitmap(global::googlecloud1.Properties.Resources.Folder_Closed_Icon_256));
            }
        }
예제 #10
0
        public List <CloudFiles> GetFiles()
        {
            List <CloudFiles> cloude = new List <CloudFiles>();

            foreach (var item in files)
            {
                CloudFiles cl = item;
                cloude.Add(cl);
            }
            return(cloude);
        }
예제 #11
0
        public override List <CloudFiles> GetFiles()
        {
            List <CloudFiles> cloude = new List <CloudFiles>();

            foreach (var item in GoogleFiles)
            {
                CloudFiles cl = item;
                cloude.Add(cl);
            }
            return(cloude);
        }
예제 #12
0
        private async void Sign()
        {
            connection = await OneDriveLogin.SignInToMicrosoftAccount(this, "baba", @"C:\Save");

            if (null != connection)
            {
                item = new OneDriveFile(connection);
                await LoadFolderFromId("root");
            }
            //UpdateConnectedStateUx();
        }
예제 #13
0
        private async void btn_OK_Click(object sender, EventArgs e)
        {
            if (tb_NAME.Text != "")
            {
                if (NewFileOption.CREATEFOLDER == option)
                {
                    if (MessageBox.Show(tb_NAME.Text + "로 폴더를 생성하시겠습니까?", "폴더 생성", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        try
                        {
                            file = await folder.CreateFolder(tb_NAME.Text, parentid);

                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                            Close();
                        }
                        catch (Exception er)
                        {
                            MessageBox.Show("에러 : " + er.Message);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else if (NewFileOption.RENAME == option)
                {
                    if (MessageBox.Show(tb_NAME.Text + "로 파일명을 변경하시겠습니까?", "파일명 변경", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        try
                        {
                            await file.ChageFileName(tb_NAME.Text);

                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                            Close();
                        }
                        catch (Exception error)
                        {
                            MessageBox.Show("에러 : " + error.Message);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("폴더명을 입력해야 합니다");
                return;
            }
        }
예제 #14
0
 /// <summary>
 /// 파일을 가져오는 함수
 /// </summary>
 /// <param name="file">부모 파일</param>
 /// <param name="folders"></param>
 public void AddFile(CloudFiles file, AllFolder folders)
 {
     // 부모 파일이 폴더가 아니라 파일이면 함수를 빠져나간다. 재귀함수의 탈출 조건
     if (file.Item.IsFile == true)
     {
         return;
     }
     folders.AddFiles(file.Item.FileID);
     file.Item.ChildFile = folders.GetFiles();
     foreach (var item in file.Item.ChildFile)
     {
         //재귀함수로 파일리스트에 파일들을 집어넣어준다.
         AddFile(item, folders);
     }
 }
예제 #15
0
        public static System.Drawing.Bitmap GetIcon(CloudFiles item)
        {
            SHFILEINFO sfi = new SHFILEINFO();

            if (item.Item.Extention != null)
            {
                IntPtr img1 = img1 = SHGetFileInfo("." + item.Item.Extention.ToUpper(), FILE_ATTRIBUTE_NORMAL, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME | SHGFI_SYSICONINDEX);
            }
            else
            {
                IntPtr img1 = img1 = SHGetFileInfo("Doesn't matter", FILE_ATTRIBUTE_DIRECTORY, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_OPENICON | SHGFI_TYPENAME);
            }
            System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(sfi.hIcon).Clone();
            DestroyIcon(sfi.hIcon);
            return(icon.ToBitmap());
        }
예제 #16
0
        public async Task <CloudFiles> CreateFolder(string foldername, string parentid)
        {
            string   method     = "POST";
            string   uri        = string.Format("https://api.onedrive.com/v1.0/drive/items/{0}/children", parentid);
            UniValue properties = UniValue.Create(new { name = foldername, folder = new { } });

            try
            {
                byte[] buf = Encoding.UTF8.GetBytes(properties.ToString());
                System.Net.HttpWebResponse rp = await HttpHelper.RequstHttp(method, uri, null, driveinfo.token.access_token, null, buf, buf.Length, 0, buf.Length);

                Dictionary <string, object> dic = HttpHelper.DerealizeJson(rp.GetResponseStream());
                CloudFiles file = AddFiles(dic);
                return(file);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #17
0
        public CloudFiles CreateFile(Dictionary <string, object> fileinfo)
        {
            CloudFiles files = null;

            if (driveinfo.token.Drive == "Google")
            {
                GoogleFolder folder = new GoogleFolder(driveinfo);
                files = folder.AddFiles(fileinfo);
            }
            else if (driveinfo.token.Drive == "OneDrive")
            {
                OneDriveFolder folder = new OneDriveFolder(driveinfo);
                files = folder.AddFiles(fileinfo);
            }
            else if (driveinfo.token.Drive == "DropBox")
            {
                DropBoxFolder folder = new DropBoxFolder(driveinfo);
                files = folder.AddFiles(fileinfo);
            }
            return(files);
        }
예제 #18
0
        public Cloud(Level level, CloudFiles file, CloudTypes type)
        {
            Level = level;
            Type  = type;
            switch (file)
            {
            case CloudFiles.One:
                base.InitWithTexture(level.PlayerCharacterSheet.Texture, new CCRect(1024, 595, 97, 67));
                break;

            case CloudFiles.Two:
                base.InitWithTexture(level.PlayerCharacterSheet.Texture, new CCRect(1135, 590, 123, 78));
                break;

            case CloudFiles.Three:
                base.InitWithTexture(level.PlayerCharacterSheet.Texture, new CCRect(1270, 588, 112, 87));
                break;
            }
            _velocityPoint = new CCPoint(Level.PlatformVelocity / 2.0f, 0);
            Reset();
        }
예제 #19
0
        private async Task UpFolder(FolderInfo folders, string ID)
        {
            foreach (var item in folders.file)
            {
                await UpLoadFile(folder, ID, startsize, item.FullName, item.Length);
            }
            if (folders.folder.Count <= 0)
            {
                return;
            }
            else
            {
                foreach (var item in folders.folder)
                {
                    string     folderid;
                    CloudFiles file1 = await folder.CreateFolder(System.IO.Path.GetFileName(item.filename), ID);

                    folderid = file1.Item.FileID;
                    await UpFolder(item, folderid);
                }
            }
        }
예제 #20
0
        public async Task <CloudFiles> CreateFolder(string foldername, string parentid)
        {
            string method = "POST";
            string uri    = "https://www.googleapis.com/drive/v2/files";
            object parent;

            parent = new object[] { new { id = parentid } };
            UniValue properties = UniValue.Create(new { title = foldername, parents = parent, mimeType = "application/vnd.google-apps.folder" });

            try
            {
                byte[] buf = Encoding.UTF8.GetBytes(properties.ToString());
                System.Net.HttpWebResponse rp = await HttpHelper.RequstHttp(method, uri, null, driveinfo.token.access_token, null, buf, buf.Length, 0, buf.Length);

                Dictionary <string, object> dic = HttpHelper.DerealizeJson(rp.GetResponseStream());
                CloudFiles file = AddFiles(dic);
                return(file);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #21
0
        private async void NavigateToItem(CloudFiles item)
        {
            flowLayoutPanel_filecontent.Controls.Clear();
            if ((item as GoogleFile) != null)
            {
                GoogleFile file      = (GoogleFile)item;
                AllFolder  newfolder = new GoogleFolder(file.Service);
                await newfolder.AddFiles(file.GetId());

                LoadTile(newfolder);
            }
            else if ((item as OneDriveFile) != null)
            {
                OneDriveFile file      = (OneDriveFile)item;
                AllFolder    newfolder = new OneDriveFolder(file.Connect);
                await newfolder.AddFiles(file.GetId());

                LoadTile(newfolder);
            }
            else
            {
                MessageBox.Show("파일 열기 실패");
            }
        }
예제 #22
0
        public async override void StreamThread()
        {
            int ReadSize = 0;

            label.Text       = "0%";
            label.Name       = "label";
            label.AutoSize   = true;
            progress.Value   = 0;
            progress.Maximum = 100;
            progress.Controls.Add(label);
            progress.Size = new System.Drawing.Size(181, 23);
            this.OnControl(this, progress);
            byteArray = new byte[FileTransfer.StreamBlockSize];
            ReadSize  = 0;
            System.IO.MemoryStream mstream = new System.IO.MemoryStream();
            string uploadurl = null;
            string method    = "PUT";

            presize = 0;
            endsize = 0;
            UpLoadUrl Url = new UpLoadUrl(path, fildid, maxsize, accesstoken);

            if (driveinfo.token.Drive == "Google")
            {
                uploadurl = await Url.GetGoogleUploadUrl();
            }
            else if (driveinfo.token.Drive == "OneDrive")
            {
                uploadurl = await Url.GetOneDriveUrl();
            }
            else if (driveinfo.token.Drive == "DropBox")
            {
                uploadurl = string.Format("https://api-content.dropbox.com/1/chunked_upload?overwrite=true&autorename=true");
            }
            try
            {
                HttpWebResponse respone = null;
                respone = await RequstHttp(method, uploadurl, null, accesstoken, filestream, maxsize, StreamBlockSize);

                if (driveinfo.token.Drive == "DropBox")
                {
                    Dictionary <string, object> text = HttpHelper.DerealizeJson(respone.GetResponseStream());
                    string uploadid = text["upload_id"].ToString();
                    Dictionary <string, string> parameter = new Dictionary <string, string>();
                    parameter.Add("upload_id", uploadid);
                    respone = await HttpHelper.RequstHttp("POST", string.Format("https://api-content.dropbox.com/1/commit_chunked_upload/auto/{0}", System.IO.Path.Combine(fildid, path).Replace("\\", "/")), parameter, accesstoken);
                }
                Dictionary <string, object> file = HttpHelper.DerealizeJson(respone.GetResponseStream());
                CloudFiles item = CreateFile(file);
                this.OnComplete(this, progress, item, fildid, group);
                filestream.Close();
                mstream.Close();
            }
            catch (WebException e)
            {
                MessageBox.Show("전송오류: " + e.Message);
                return;
            }
            catch (Exception e)
            {
                MessageBox.Show("전송오류: " + e.Message);
                return;
            }
        }
예제 #23
0
 private async void Sign()
 {
     connection = await OneDriveLogin.SignInToMicrosoftAccount(this, "baba", @"C:\Save");
     if (null != connection)
     {
         item = new OneDriveFile(connection);
         await LoadFolderFromId("root");
     }
     //UpdateConnectedStateUx();
 }
예제 #24
0
 public FileInfoForm(CloudFiles file)
 {
     InitializeComponent();
     this.file = file;
 }
예제 #25
0
        public void RemoveFile(CloudFiles file)
        {
            int index = this.files.IndexOf(file);

            this.files.RemoveAt(index);
        }
예제 #26
0
 private async void NavigateToItem(CloudFiles item)
 {
     flowLayoutPanel_filecontent.Controls.Clear();
     if((item as GoogleFile) != null)
     {
         GoogleFile file = (GoogleFile)item;
         AllFolder newfolder = new GoogleFolder(file.Service);
         await newfolder.AddFiles(file.GetId());
         LoadTile(newfolder);
     }
     else if((item as OneDriveFile) != null)
     {
         OneDriveFile file = (OneDriveFile)item;
         AllFolder newfolder = new OneDriveFolder(file.Connect);
         await newfolder.AddFiles(file.GetId());
         LoadTile(newfolder);
     }
     else
     {
         MessageBox.Show("파일 열기 실패");
     }
 }
예제 #27
0
 /// <summary>
 /// 드라이브 정보를 받아옴
 /// </summary>
 /// <returns></returns>
 public async Task Signin()
 {
     service = Authentication.AuthenticateOauth("892886432316-smcv78utjgpp1iec18v67amr2gigv24m.apps.googleusercontent.com", "eyOFpG-LFIfp8ad3usTL81LG", "bit12");
     if(service != null)
     {
         item = new GoogleFile(service);
         await LoadFolderFromId("root");
     }
 }
예제 #28
0
        public void RemoveFile(CloudFiles file)
        {
            int index = GoogleFiles.IndexOf(file);

            GoogleFiles.RemoveAt(index);
        }