Пример #1
0
        private static void startWithArgs(string[] args)
        {
            string uploadFilePath, filename, backupName, parentID;
            int    user, compressing = 0, onlyNew = 0;

            try
            {
                if (loadUsers() && args.Length > 5)
                {
                    loadFileList(args[0]);
                    backupName = args[1];
                    parentID   = (args[2] != "0") ? args[2] : null;
                    int.TryParse(args[3], out user);
                    int.TryParse(args[4], out onlyNew);
                    int.TryParse(args[5], out compressing);


                    if (GoogleDriveAPIV3.GoogleDriveConnection(
                            UserList[user].clientSecretPath,
                            UserList[user].userName))
                    {
                        parentID = GoogleDriveAPIV3.createFolderToDrive(
                            Gtools.getTimeStamp() + "_" + backupName,
                            parentID);
                        foreach (IOFile file in IOFileList)
                        {
                            uploadFilePath = (compressing == 0) ? file.path : Gtools.compressFile(file.path);
                            filename       = (compressing == 0) ? file.name : file.name.Split('.').First() + ".zip";
                            GoogleDriveAPIV3.uploadToDrive(uploadFilePath, filename, parentID, (onlyNew != 0), new frmMain());
                        }
                    }
                    else
                    {
                        throw new Exception("Connection Error");
                    }
                }
                else
                {
                    throw new Exception("Arguments Error");
                }
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine(exc.Message + " Start with Args Error.\n");
                Gtools.writeToFile(frmMain.errorLog, Environment.NewLine + DateTime.Now.ToString() +
                                   Environment.NewLine + exc.Message + " Start with Args Error.\n");
            }
        }
Пример #2
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if (cbUser.SelectedIndex == -1)
     {
         MessageBox.Show("You have to Select A User in order to connect", "Attention!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         if (GoogleDriveAPIV3.GoogleDriveConnection(
                 UserList[cbUser.SelectedIndex].clientSecretPath,
                 UserList[cbUser.SelectedIndex].userName))
         {
             btnConnect.BackColor = Color.Green;
             Task.Run(() => { updateDataGridView(); });
         }
         else
         {
             btnConnect.BackColor = Color.Red;
             MessageBox.Show("Connection Error", "Attention!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }