/// <summary>
        /// Get expected system properties for the entered IC/BootCamper
        /// </summary>
        /// <returns></returns>
        private IEnumerable <OutputProperties> GetExpectedSystemProperties()
        {
            var enteredIcProjectDetails = GetICsProjectList().Where(e => e.IcEmail == _icEmail).ToList();

            if (enteredIcProjectDetails.Count <= 0)
            {
                return(null);
            }
            {
                var spreadSheetId = _configuration["SpreadSheetID"];
                var range         = _configuration["ExpectedSystemPropertiesSheet"];
                var response      = GoogleDriveHelper.GetValuesFromGoogleDrive(spreadSheetId, range,
                                                                               SpreadsheetsResource.ValuesResource.GetRequest.MajorDimensionEnum.COLUMNS);
                return((from value in response.Values
                        let projectName = value[0].ToString()
                                          where enteredIcProjectDetails.Exists(e => e.Projects.Exists(d => d == projectName))
                                          select new OutputProperties
                {
                    OperatingSystem = value[1]?.ToString(),
                    MinimalCpuBenchmarkScore = Convert.ToInt32(value[2]),
                    Memory = Convert.ToDouble(value[3]),
                    Storage = Convert.ToInt64(value[4]),
                    FreeDiskSpace = Convert.ToInt64(value[5]),
                    Architecture = value[6]?.ToString()
                }).ToList());
            }
        }
Exemplo n.º 2
0
        public string[] ReadDriveFolderForFiles(string folder = "In")
        {
            DriveService service = Authentication.AuthenticateOauth(GoogleClientId, GoogleClientSecret, GoogleUserName);
            string       q       = "title = '" + folder + "' and mimeType = 'application/vnd.google-apps.folder'";
            var          dir     = GoogleDriveHelper.GetFiles(service, q);

            if (dir == null || dir.Count == 0)
            {
                return(null);
            }

            q = "'" + dir[0].Id + "' in parents";
            var _filesInsideDir = GoogleDriveHelper.GetFiles(service, q);
            var retList         = new List <string>();

            foreach (var f in _filesInsideDir)
            {
                string downloadedFile = Path.Combine(DownloadLocation, f.OriginalFilename);
                GoogleDriveHelper.downloadFile(service, f.DownloadUrl, downloadedFile);

                if (System.IO.File.Exists(downloadedFile))
                {
                    retList.Add(downloadedFile);
                    GoogleDriveHelper.removeFileFromFolder(service, dir[0].Id, f.Id);
                }
            }

            return(retList.ToArray());
        }
Exemplo n.º 3
0
        public static string Push(int timeToWait)
        {
            string result = "";

            DateTime synchronizationStartTime = DateTime.Now;

            Thread.Sleep(timeToWait);

            foreach (var directory in settings.synchronizedDirectories)
            {
                FileHelper fh         = new FileHelper(settings.lastUpdateTime, directory.path, directory.name);
                int        filesCount = fh.GetFiles(synchronizationStartTime);
                if (filesCount > 0)
                {
                    string package = fh.CreatePackage();
                    GoogleDriveHelper.UploadAndDeleteFile(package);
                    settings.uploadedPackages.Add(package);

                    result += "Pushed: " + filesCount + " files from " + directory.name + " directory. ";
                }
                else
                {
                    result += NoChangesFound;
                }
            }

            settings.lastUpdateTime = synchronizationStartTime;

            Serializer.SerializeObject(settings, "settings.mr");

            return(result);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var options = new CommandLineOptions();

            if (Parser.Default.ParseArguments(args, options))
            {
                if (!File.Exists(options.DatabasePath))
                {
                    Console.WriteLine($"Database File ${options.DatabasePath} not found!");
                    return;
                }
                _silent   = options.Quiet;
                _dbHelper = new DatabaseHelper(options.DatabasePath);
                _upload   = options.Upload;
                UpdateDatabase();

                if (_upload)
                {
                    Console.Write($"Uploading Database File to Google Drive...");
                    var gdHelper = new GoogleDriveHelper();
                    gdHelper.UpdateStoredFile(options.DatabasePath, "5DFileData");
                    Console.WriteLine($"Done");
                }
            }
        }
        private ValueRange GetIcsFromGoogleDrive()
        {
            var range         = _configuration["IcsSheet"];
            var spreadSheetId = _configuration["SpreadSheetID"];
            var response      = GoogleDriveHelper.GetValuesFromGoogleDrive(spreadSheetId, range);

            return(response);
        }
Exemplo n.º 6
0
        private void uploadToGoogleDriveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            PrintInfo($"Uploading {_dbPath} to Google Drive...");
            var gdh = new GoogleDriveHelper();

            gdh.UpdateStoredFile(_dbPath, "5DFileData");
            PrintInfo("Done.");
        }
Exemplo n.º 7
0
        // GET: /Gallery/
        public ActionResult GalleryIndex()
        {
            string            secretJsonPath      = Path.Combine(Server.MapPath("~/GoogleDrive/client_secret.json"));
            string            credentialsJSONPath = Path.Combine(Server.MapPath("~/GoogleDrive/.credentials/drive-dotnet-quickstart.json"));
            string            applicationName     = "Drive API .NET Quickstart"; //"PhysioFirstAouth";
            GoogleDriveHelper driveHelper         = new GoogleDriveHelper(secretJsonPath, applicationName, credentialsJSONPath);
            var listFiles = driveHelper.GetFilesFromGDrive();

            //var model = _IGallery.GetAllPhoto();
            return(View("Index", listFiles));
        }
Exemplo n.º 8
0
        public async Task <ActionResult> Index()
        {
            var service = await GoogleDriveHelper.AuthenticateServiceAccount("*****@*****.**", HttpRuntime.AppDomainAppPath + "Kia feed-69b23139ac76.p12");

            var filePath = HttpRuntime.AppDomainAppPath + "Kia feeds.xlsx";
            var file     = await GoogleDriveHelper.UploadFile(service, filePath, "");

            var files = await GoogleDriveHelper.GetFiles(service);

            return(View());
        }
Exemplo n.º 9
0
        /// <summary>
        /// https://github.com/LindaLawton/Google-Dotnet-Samples/tree/master/Google-Drive
        /// </summary>
        /// <param name="context"></param>
        public async void Execute(IJobExecutionContext context)
        {
            // connect with a Service Account
            const string serviceAccountEmail   = "*****@*****.**";
            var          serviceAccountkeyFile = Path.Combine(HttpRuntime.AppDomainAppPath, "Temp", "My Project-b1363c7ae5f1.p12");
            var          service = await GoogleDriveHelper.AuthenticateServiceAccount(serviceAccountEmail, serviceAccountkeyFile);

            var uploadFile = Path.Combine(HttpRuntime.AppDomainAppPath, "Temp", "Kia  feed#1.xlsx");

            await GoogleDriveHelper.UploadFile(service, uploadFile, "Kia vehicle feeds");
        }
        private IEnumerable <CpuBenchMarkScoreProperties> GetCpuBenchMarkScores()
        {
            var range         = _configuration["CpuScoresSheet"];
            var spreadSheetId = _configuration["SpreadSheetID"];
            var response      = GoogleDriveHelper.GetValuesFromGoogleDrive(spreadSheetId, range);

            return(response.Values.Select(value => new CpuBenchMarkScoreProperties
            {
                CpuType = value[0].ToString(),
                Score = Convert.ToInt32(value[1])
            }).ToList());
        }
Exemplo n.º 11
0
        static AppManagement()
        {
            var a = GoogleDriveHelper.GetAllProgramFiles();

            settings = Serializer.DeSerializeObject <Settings>("settings.mr");


            if (settings == null)
            {
                settings = new Settings(DateTime.MinValue);
            }

            backgroundProcessing = false;
        }
        public MainWindowViewModel()
        {
            CurrentWindowState = WindowState.Normal;

            ShowBarInCalendarMenuButton    = false;
            ShowBarInEventListMenuButton   = false;
            ShowBarInAddNewEventMenuButton = false;
            ShowLogInButton   = true;
            googleDriveHelper = new GoogleDriveHelper();
            tokenPath         = Path.Combine(tokenPath, ".credentials\\menadzer_zespolow_token.json");
            if (Directory.Exists(tokenPath))
            {
                GoogleDriveService = googleDriveHelper.GetGoogleDriveService();
                LoggedInAccount    = "Zalogowano";
            }
        }
Exemplo n.º 13
0
        private static List <string> DownloadAllPackagesToSynchronize()
        {
            List <string> packages         = new List <string>();
            List <File>   uploadedPackages = GoogleDriveHelper.GetAllProgramFiles();

            foreach (var uploadedPackage in uploadedPackages)
            {
                if (!settings.uploadedPackages.Contains(uploadedPackage.Name))
                {
                    string name = GoogleDriveHelper.DownloadAndUnzipPackage(uploadedPackage.Id, uploadedPackage.Name);
                    packages.Add(name);
                    GoogleDriveHelper.DeleteFile(uploadedPackage.Id);
                }
            }

            return(packages);
        }
Exemplo n.º 14
0
        public void Initialize()
        {
            _helper = new GoogleDriveHelper();

            _shapes = new List <Shape>();

            Shape shape = new ShapeFactory().CreateShape(ShapeType.Line);

            shape.SetStartPoint(1, 1);
            shape.SetEndPoint(10, 10);
            _shapes.Add(shape);

            shape = new ShapeFactory().CreateShape(ShapeType.Rectangle);
            shape.SetStartPoint(2, 2);
            shape.SetEndPoint(9, 9);
            _shapes.Add(shape);
        }
Exemplo n.º 15
0
        private async void btnReadFromGoogle_Click(object sender, RoutedEventArgs e)
        {
            GoogleDriveHelper gh = new GoogleDriveHelper();

            if (await gh.LoginToGoogle(GoogleAuthJSON))
            {
                GoogleAuthJSON = gh.GoogleAuthJSON;
                ApplicationDataContainer adc = ApplicationData.Current.LocalSettings.CreateContainer("GoogleDrive", ApplicationDataCreateDisposition.Always);
                if (adc.Values.Keys.Contains("json"))
                {
                    adc.Values["json"] = gh.GoogleAuthJSON;
                }
                else
                {
                    adc.Values.Add("json", gh.GoogleAuthJSON);
                }

                if (gh.CreateService())
                {
                    if (gh.ReadFile("TextEncryptor"))
                    {
                        txtData.Text = gh.fileData;
                        var alert = new MessageDialog("Successfully read file from Google!");
                        await alert.ShowAsync();
                    }
                    else
                    {
                        var alert = new MessageDialog("Error reading file from Google!");
                        await alert.ShowAsync();
                    }
                }
                else
                {
                    var alert = new MessageDialog("Error creating Google Drive Service!");
                    await alert.ShowAsync();
                }
            }
            else
            {
                var alert = new MessageDialog("Error connecting to Google!");
                await alert.ShowAsync();
            }
        }
        /// <summary>
        /// Updating Boot Camper Machine in Google Drive
        /// </summary>
        public void UpdateBootCamperMachineDetails()
        {
            var currentSystemProps = GetSystemProperties();
            var validate           = ValidateSystemProperties(currentSystemProps);

            var icList = GetIcsFromGoogleDrive();
            var index  = (from ic in icList.Values
                          where ic.Any(e => e.ToString() == _icEmail)
                          select icList.Values.IndexOf(ic)).FirstOrDefault();

            // Why index + 3?
            // We started with retrieving data from third row. So +2
            // Retrieved index value starts from 0 so if it is 1 then actual value is 1+1
            // Finally it 2 + index + 1
            index = index + 3;

            //Update Enough Specifications
            var enoughSpecsStoredCell = _configuration["EnoughSpecsStoredCell"];
            var spreadSheetId         = _configuration["SpreadSheetID"];

            GoogleDriveHelper.UpdateValuesInGoogleDrive(spreadSheetId, enoughSpecsStoredCell + index,
                                                        validate ? "Yes" : "No");

            //Update Actual Machine Specs
            var actualMachineSpecs = new StringBuilder();

            actualMachineSpecs.AppendLine(" - CPU:" + currentSystemProps.ProcessorName);
            actualMachineSpecs.AppendLine(" - CPU Score:" + currentSystemProps.CpuBenchMarkScore);
            actualMachineSpecs.AppendLine(" - Memory:" + currentSystemProps.UsableMemory + "G");
            actualMachineSpecs.AppendLine(" - OS:" + currentSystemProps.OperatingSystemEdition);
            actualMachineSpecs.AppendLine(" - Storage:" + currentSystemProps.StorageSpace + "G");
            actualMachineSpecs.AppendLine(" - Free disk space:" + currentSystemProps.FreeDiskSpace + "G");
            actualMachineSpecs.Append(" - Arch:" + currentSystemProps.Architecture);
            var actualMachineSpecsStoredCell = _configuration["ActualMachineSpecsStoredCell"];

            GoogleDriveHelper.UpdateValuesInGoogleDrive(spreadSheetId, actualMachineSpecsStoredCell + index,
                                                        actualMachineSpecs.ToString());
            WriteLine("Machine Configuration Details Updated Successfully in Google Drive in ICs sheets");
        }
 public Resourse Create(Resourse resourse)
 {
     resourse.Link = GoogleDriveHelper.UploadFile(resourse.Base64String, resourse.Title, resourse.Type);
     _resourses.InsertOne(resourse);
     return(resourse);
 }
Exemplo n.º 18
0
 public AppWindowVM()
 {
     // Initiating command with async lambda function that will call Helper class to perform authentication and then fetching files
     OAuth2AuthenticationCommand = new DelegateCommand(async() => { Files = await GoogleDriveHelper.GetFilesAsync(); });
 }