Esempio n. 1
0
        //ZiboMod
        public static void ZiboDownload(string DownloadID)
        {
            GDriveAPI ZiboDrive = new GDriveAPI();

            ZiboDrive.DownloadFile(DownloadID, AppData + "\\BoeingDL.zip"); //Downloads file to %Appdata%. Operation is async!
            while (ZiboDrive.DriveClient.IsBusy)
            {
                InstallPage._InstallPage.UpdateProgressbar(ZiboDrive.downloadProgress);
                Thread.Sleep(2);
            }
        }
Esempio n. 2
0
        public static string FindLatestGDriveFile(string FolderID, bool SearchZiboOnly)
        {
            string    DownloadID = "";
            GDriveAPI ZiboDrive  = new GDriveAPI();                                                  //Import the API parser
            Dictionary <string, dynamic> folderContentData = ZiboDrive.GetDriveFolderList(FolderID); //Get list of items in folder
            List <string> folderItemName          = new List <string>();                             //Define lists for item properties
            List <double> folderItemAddedDate     = new List <double>();
            List <string> folderItemDriveID       = new List <string>();
            List <int>    potentialFiles          = new List <int>();                                                              //Define list of zip candidates for installation
            List <double> potentialFilesAddedDate = new List <double>();                                                           // Define list of zip candidates with date to find newest of the few.

            for (int i = 0; i < folderContentData["items"].Count; i++)                                                             //Add a global index of files and directories in drive folder, so that we can search in it.
            {
                folderItemName.Add(folderContentData["items"][i]["title"]);                                                        //Add title to list
                folderItemAddedDate.Add(Convert.ToDouble(Convert.ToDateTime(folderContentData["items"][i]["createdDate"]).Ticks)); //Add the file added date to list
                folderItemDriveID.Add(folderContentData["items"][i]["id"]);

                if (folderItemName[i].Contains(".zip"))
                {
                    if (!folderItemName[i].Contains("B738") && !folderItemName[i].Contains("B737") && !folderItemName[i].Contains("Boeing") && SearchZiboOnly) //In case there are other files in zibo's Google Drive
                    {
                    }
                    else
                    {
                        potentialFiles.Add(i); //Add to list of zip files as ID, so that we don't have to look up later when we're downloading it
                    }
                }
            }
            for (int i = 0; i < potentialFiles.Count; i++)
            {
                potentialFilesAddedDate.Add(folderItemAddedDate[potentialFiles[i]]);                         //Add potentialfiles' last modified date so that they get the same ID.
            }
            int NewestFile = potentialFiles[potentialFilesAddedDate.IndexOf(potentialFilesAddedDate.Max())]; //Find which file ID is the newest file.

            DownloadID = folderItemDriveID[NewestFile];                                                      //Select DriveID for downloading the file
            return(DownloadID);
        }