Exemplo n.º 1
0
        private void WorkDownload_DoWork(object sender, DoWorkEventArgs e)
        {
            using (DriveService service = GoogleDrive.AbrirServico(credential))
            {
                Dictionary <string, string[]> dicioFields = new Dictionary <string, string[]>();
                foreach (string s in listFields)
                {
                    dicioFields.Add(s, GoogleDrive.ProcurarArquivoId(service, s));
                }

                int i = 0;

                if (!Directory.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\update\\"))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\update\\");
                }

                foreach (var field in dicioFields)
                {
                    MemoryStream ms = GoogleDrive.DownloadFile(service, field.Value[0]);
                    using (FileStream fs = new FileStream(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\update\\" + field.Key,
                                                          FileMode.Create, FileAccess.Write)) ms.WriteTo(fs);
                    i++;
                    (sender as BackgroundWorker).ReportProgress(i);
                }
            }
        }
Exemplo n.º 2
0
        private static bool VerifyExistUpdates()
        {
            string gbackupFolder = ConfigurationManager.AppSettings["UpdatePathNameGDrive"];
            string jsonUpdate    = ConfigurationManager.AppSettings["jsonFileUpdate"];

            using (DriveService service = GoogleDrive.AbrirServico(credential))
            {
                string[] capdeUpdate = GoogleDrive.ProcurarArquivoId(service, gbackupFolder);

                if (capdeUpdate.Length == 0)
                {
                    GoogleDrive.CreateFolder(service, gbackupFolder);
                }

                string[] fileJsonUpdate = GoogleDrive.ProcurarArquivoId(service, jsonUpdate);
                if (fileJsonUpdate.Length != 0)
                {
                    string ss = Encoding.ASCII.GetString(GoogleDrive.DownloadFile(service, fileJsonUpdate[0]).ToArray());
                    serverVersion = JsonConvert.DeserializeObject <AppVersion>(ss);

                    if (Convert.ToDouble(thisAssemblyVersion.FileVersion.Replace(".", "")) < Convert.ToDouble(serverVersion.versao.Replace(".", "")))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        private void Work_DoWork(object sender, DoWorkEventArgs e)
        {
            string gbackupFolder = ConfigurationManager.AppSettings["UpdatePathNameGDrive"];

            using (DriveService service = GoogleDrive.AbrirServico(credential))
            {
                string[] capdeUpdate = GoogleDrive.ProcurarArquivoId(service, gbackupFolder);
                if (capdeUpdate.Length == 0)
                {
                    GoogleDrive.CreateFolder(service, gbackupFolder);
                }

                for (int i = 0; i < listDirectories.Count; i++)
                {
                    GoogleDrive.Upload(service, listDirectories[i], capdeUpdate[0]);
                    (sender as BackgroundWorker).ReportProgress(i);
                }
            }
        }