/// <summary>
        /// Upload the new version on the drive.
        /// </summary>
        /// <param name="force">true if want to delete existing version with same version code.</param>
        public void Push(bool force)
        {
            var configJson = ConfigJson.Load();
            var version    = _project.GetVersion(configJson.CurrentVersionCode);

            //if version exists on drive
            //if force then delete else abort
            if (version != null)
            {
                if (!force)
                {
                    Console.WriteLine("Version aready exists");
                    return;
                }

                _project.DeleteVersionFromDrive(version);
            }

            if (configJson.CurrentVersionCode == 0)
            {
                Console.WriteLine("Run upversion first");
                return;
            }

            CreateZip();
            var name = $"{configJson.CurrentVersionCode}--{configJson.SoftwareName}--{configJson.VersionName}";

            DriveUtils.UploadFileToCloud(name + ".zip", _project.FolderId, FilePath.TempZipFile);

            Console.WriteLine($"Update {version} has been uploaded to drive.");
        }
        public virtual void MoveTargetToTargetIndex()
        {
            Vector3 _targetPos = Vector3Utils.Lerp(-range, range, m_targetIndex);

            DriveUtils.LockFreeAxisPosition(ref _targetPos, axis);
            _targetPos = transform.TransformPoint(_targetPos);

            _targetPos = Vector3.SmoothDamp(
                targetObject.position,
                _targetPos,
                ref targetVelocity,
                1 / speed * Time.deltaTime);

            if (!onlyMoveWithVelocity)
            {
                targetObject.position = _targetPos;
            }
            else
            {
                Vector3 positionDelta      = _targetPos - targetObject.position;
                Vector3 velocityTarget     = positionDelta / Time.deltaTime;
                Vector3 calculatedVelocity = Vector3.MoveTowards(targetRigidbody.velocity, velocityTarget, 10);
                calculatedVelocity      *= 1 / speed;
                targetRigidbody.velocity = calculatedVelocity;
            }
        }
Exemple #3
0
        public virtual void LimitChildrenVeloctiy()
        {
            foreach (var child in children)
            {
                Rigidbody childRb = child.GetComponent <Rigidbody>();
                if (childRb == null)
                {
                    continue;
                }

                Vector3 velocityProject = childRb.velocity * Time.deltaTime + child.transform.position;
                Vector3 localPos        = transform.InverseTransformPoint(velocityProject);

                if (DriveUtils.IsInBounds(localPos, axis, range))
                {
                    continue;
                }

                DriveUtils.LimitPos(ref localPos, axis, range);
                if (lockInactiveAxis)
                {
                    DriveUtils.LockFreeAxisPosition(ref localPos, axis);
                }

                childRb.velocity = transform.TransformPoint(localPos) - child.transform.position;
            }
        }
        public void Publish(string googleSheetId, string notes)
        {
            var workItem = dbContext.Set <SpreadsheetWorkItem>()
                           .FirstOrDefault(w => w.GoogleSheetId == googleSheetId);

            var authEmail = ConfigurationManager.AppSettings["Drive.AuthEmail"];
            var authKey   = ConfigurationManager.AppSettings["Drive.AuthKey"];
            var parentDir = ConfigurationManager.AppSettings["Drive.ParentDir"];

            DriveUtils utils = new DriveUtils(authEmail, authKey, parentDir);

            var fileStream = utils.GetFileStream(googleSheetId);

            if (fileStream == null)
            {
                return;
            }

            var documentUploadType = (DocumentUploadType)workItem.Type;
            var context            = new AdapterContext(dbContext, (DocumentUploadType)workItem.Type, workItem.fkRegionId, workItem.ApbnKey);

            using (var tx = dbContext.Database.BeginTransaction())
            {
                adapters[documentUploadType].Publish(fileStream, context, notes);
                tx.Commit();
            }
        }
        private static void Main(string[] args)
        {
            var docopt  = new DocoptWrapper(Usage, args);
            var service = new Service(FilePath.SecretJsonFile, FilePath.CredentialsJsonFile);

            DriveUtils.SetService(service);

            var updater = new Updater.Updater();

            if (docopt.Get("install").IsTrue)
            {
                updater.Install(docopt.GetInt("--code"), docopt.GetString("--name"));
            }
            else if (docopt.Get("checkupdate").IsTrue)
            {
                updater.Checkupdate();
            }
            else if (docopt.Get("showversions").IsTrue)
            {
                //show all versions in the project
                updater.ShowVersions();
            }



#if DEBUG
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
#endif
        }
        protected VideoDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> extractedMIATypeIds) : base(driveInfo)
        {
            IMediaAccessor    mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
            ResourcePath      rp            = LocalFsResourceProviderBase.ToResourcePath(driveInfo.Name);
            IResourceAccessor ra;

            if (!rp.TryCreateLocalResourceAccessor(out ra))
            {
                throw new ArgumentException(string.Format("Unable to access drive '{0}'", driveInfo.Name));
            }
            using (ra)
                _mediaItem = mediaAccessor.CreateLocalMediaItem(ra, mediaAccessor.GetMetadataExtractorsForMIATypes(extractedMIATypeIds));
            if (_mediaItem == null)
            {
                throw new Exception(string.Format("Could not create media item for drive '{0}'", driveInfo.Name));
            }

            MatchWithStubs(driveInfo, new MediaItem[] { _mediaItem });
            IEnumerable <MediaItem> processedItems = CertificationHelper.ProcessMediaItems(new MediaItem[] { _mediaItem });

            if (processedItems.Count() == 0)
            {
                _mediaItem = null;
                return;
            }
            _mediaItem = processedItems.First();
            SingleMediaItemAspect mia = null;

            MediaItemAspect.TryGetAspect(_mediaItem.Aspects, MediaAspect.Metadata, out mia);
            mia.SetAttribute(MediaAspect.ATTR_TITLE, mia.GetAttributeValue(MediaAspect.ATTR_TITLE) +
                             " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")");
        }
Exemple #7
0
        static void Main(string[] args)
        {
            // Variablen für die Aufnahme der Größeninformationen
            ulong totalSize = 0, totalSpace = 0, userSpace = 0;

            try
            {
                // Größe und freien Speicherplatz des Laufwerks C: ermitteln
                DriveUtils.GetDriveSpace("c:", ref totalSize, ref totalSpace, ref userSpace);

                // Ergebnis ausgeben
                Console.WriteLine("Größe: {0} Byte", totalSize);
                Console.WriteLine("Gesamter freier Platz: {0} Byte", totalSpace);
                Console.WriteLine("Benutzerspezifischer freier Platz: {0} Byte", userSpace);
            }
            catch (IOException ex)
            {
                // Fehlerauswertung
                Console.WriteLine("Fehler beim Lesen der Greninformationen " +
                                  "von Laufwerk c: {0}.", ex.Message);
            }

            Console.WriteLine("Beenden mit Return");
            Console.ReadLine();
        }
Exemple #8
0
        private static void Main(string[] args)
        {
            DocoptWrapper docopt  = new DocoptWrapper(Usage, args);
            var           service = new Service(FilePath.SecretJsonFile, FilePath.CredentialsJsonFile);

            DriveUtils.SetService(service);


            if (docopt.Get("init").IsTrue)
            {
                //initialize publisher
                var name = docopt.Get("SOFTWARENAME").ToString();
                Publisher.New(name).Init();
            }

            Publisher publisher = Publisher.Load();

            if (docopt.Get("push").IsTrue)
            {
                //upload files on drive
                publisher.Push(docopt.Get("--force").IsTrue);
            }
            else if (docopt.Get("getupdater").IsTrue)
            {
                //get updater
                publisher.GetUpdater(
                    docopt.Get("--win").IsTrue?"win":"linux"
                    );
            }
            else if (docopt.Get("upversion").IsTrue)
            {
                //increase version
                publisher.UpVersion(docopt.Get("VERSIONNAME").ToString());
            }
            else if (docopt.Get("pushnow").IsTrue)
            {
                //increase version and push
                publisher.PushNow(docopt.GetString("VERSIONNAME"));
            }
            else if (docopt.Get("drop").IsTrue)
            {
                //delete version
                publisher.Drop(docopt.GetInt("--code"), docopt.GetString("--name"));
            }
            else if (docopt.Get("setversion").IsTrue)
            {
                //set version to a specific code/name
                publisher.SetVersion(docopt.Get("VERSIONCODE").AsInt, docopt.GetString("VERSIONNAME"), docopt.Get("--force").IsTrue);
            }
            else if (docopt.Get("showversions").IsTrue)
            {
                //show all versions in the project
                publisher.ShowVersions();
            }

#if DEBUG
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
#endif
        }
Exemple #9
0
 public void TestNormalizeHitDistance()
 {
     Assert.IsTrue(DriveUtils.NormalizeHitDistance(200, 250) == 0.5f);
     Assert.IsTrue(DriveUtils.NormalizeHitDistance(200, 200) == 0.5f);
     Assert.IsTrue(DriveUtils.NormalizeHitDistance(200, 100) == 0.5f);
     Assert.IsTrue(DriveUtils.NormalizeHitDistance(200, 50) == 1);
     Assert.IsTrue(DriveUtils.NormalizeHitDistance(200, 0) == 1);
 }
Exemple #10
0
 public void TestHitDistance()
 {
     Assert.AreEqual(DriveUtils.NormalizeHitDistance(200, 200), 0.5f);
     Assert.AreEqual(DriveUtils.NormalizeHitDistance(200, 100), 0.5f);
     Assert.AreEqual(DriveUtils.NormalizeHitDistance(200, 0), 1);
     Assert.AreEqual(DriveUtils.NormalizeHitDistance(200, 50), 1);
     Assert.AreEqual(DriveUtils.NormalizeHitDistance(200, 150), 0.5f);
 }
Exemple #11
0
        public void TestRound()
        {
            Assert.IsTrue(DriveUtils.Round(0) == 0);
            Assert.IsTrue(DriveUtils.Round(0.25f) == 0);

            Assert.IsTrue(DriveUtils.Round(0.3f) == 0f);
            Assert.IsTrue(DriveUtils.Round(0.5f) == 0.5f);
            Assert.IsTrue(DriveUtils.Round(0.75f) == 0.5f);
            Assert.IsTrue(DriveUtils.Round(1) == 0.5f);
        }
Exemple #12
0
 protected MultimediaDriveHandler(DriveInfo driveInfo, IEnumerable <MediaItem> mediaItems, MultiMediaType mediaType) : base(driveInfo)
 {
     _mediaType = mediaType;
     _mediaItemsSubViewSpecification = new StaticViewSpecification(
         driveInfo.VolumeLabel + " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")", new Guid[] {}, new Guid[] {});
     foreach (MediaItem item in mediaItems)
     {
         _mediaItemsSubViewSpecification.AddMediaItem(item);
     }
 }
        public virtual Vector3 GetLimitedPositon(Transform _target)
        {
            Vector3 localPos = transform.InverseTransformPoint(_target.transform.position);

            DriveUtils.LimitPos(ref localPos, axis, range);
            if (lockInactiveAxis)
            {
                DriveUtils.LockFreeAxisPosition(ref localPos, axis);
            }

            return(transform.TransformPoint(localPos));
        }
 public override Task <AsyncResult <ContentDirectoryMessaging.MediaItemChangeType> > ProcessAsync(MediaItem mediaItem)
 {
     // If the MediaItem was not loaded from ML
     if (!IsManagedByMediaLibrary(mediaItem))
     {
         string path = GetRemovableMediaItemPath(mediaItem);
         if (!string.IsNullOrEmpty(path))
         {
             DriveUtils.EjectDrive(path);
         }
     }
     return(Task.FromResult(new AsyncResult <ContentDirectoryMessaging.MediaItemChangeType>(false, ContentDirectoryMessaging.MediaItemChangeType.None)));
 }
Exemple #15
0
        public virtual void LimitChildrenPositon()
        {
            foreach (var child in children)
            {
                Vector3 localPos = transform.InverseTransformPoint(child.transform.position);

                DriveUtils.LimitPos(ref localPos, axis, range);
                if (lockInactiveAxis)
                {
                    DriveUtils.LockFreeAxisPosition(ref localPos, axis);
                }

                child.transform.position = transform.TransformPoint(localPos);
            }
        }
        public virtual Quaternion GetLimitedRotation(Transform _target)
        {
            Vector3 localEuler = DriveUtils.LimitRot(targetObject.localEulerAngles,
                                                     rotAxis,
                                                     new Vector2(rotRangeOneMin, rotRangeOneMax),
                                                     new Vector2(rotRangeTwoMin, rotRangeTwoMax));

            if (lockInactiveAxis)
            {
                DriveUtils.LockFreeAxisRotation(ref localEuler, rotAxis);
            }


            return(Quaternion.Euler(localEuler));
        }
    private string GetRemovableMediaItemPath(MediaItem mediaItem)
    {
      if (mediaItem == null)
        return null;

      foreach (var pra in mediaItem.PrimaryResources)
      {
        var resPath = ResourcePath.Deserialize(pra.GetAttributeValue<string>(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH));
        var dosPath = LocalFsResourceProviderBase.ToDosPath(resPath);
        if (string.IsNullOrEmpty(dosPath))
          continue;
        if (DriveUtils.IsDVD(dosPath))
          return dosPath;
      }
      return null;
    }
        public ActionResult TestDrive()
        {
            var authEmail = ConfigurationManager.AppSettings["Drive.AuthEmail"];
            var authKey   = ConfigurationManager.AppSettings["Drive.AuthKey"];
            var parentDir = ConfigurationManager.AppSettings["Drive.ParentDir"];


            var driveUtils = new DriveUtils(authEmail, authKey, parentDir);


            //var fileId = driveUtils.UploadFile(null, @"D:\Work\kawal-desa\Content\sheets\DD 2015p 0 NASIONAL.xlsx", "DD 2015p 0 NASIONAL.xlsx");
            //var fileId = driveUtils.CreateRootDirectory();
            var fileId = "" + driveUtils.IsFileExists("0B5Uy21bYS6k9a1BQdUdoWFBQV3M", "DD 2015p 0 NASIONAL.xlsx A");

            return(Content(fileId));
        }
        public virtual Vector3 GetLimitedVelocity(Rigidbody _targetRb)
        {
            Vector3 velocityProject = _targetRb.velocity * Time.deltaTime + _targetRb.transform.position;
            Vector3 localPos        = transform.InverseTransformPoint(velocityProject);

            if (DriveUtils.IsInBounds(localPos, axis, range))
            {
                return(_targetRb.velocity);
            }

            DriveUtils.LimitPos(ref localPos, axis, range);
            if (lockInactiveAxis)
            {
                DriveUtils.LockFreeAxisPosition(ref localPos, axis);
            }

            return(transform.TransformPoint(localPos) - _targetRb.transform.position);
        }
Exemple #20
0
        protected AudioCDDriveHandler(DriveInfo driveInfo, IEnumerable <MediaItem> tracks) : base(driveInfo)
        {
            string volumeLabel;

            try
            {
                volumeLabel = driveInfo.VolumeLabel;
            }
            catch (Exception)
            {
                volumeLabel = "Audio CD";
            }
            _audioCDSubViewSpecification = new StaticViewSpecification(
                volumeLabel + " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")", new Guid[] {}, new Guid[] {});
            foreach (MediaItem track in tracks)
            {
                _audioCDSubViewSpecification.AddMediaItem(track);
            }
        }
        public void LimitPos()
        {
            if (driveType == DriveTypes.Directional)
            {
                scratchPos = -transform.InverseTransformPoint(globalStart);

                DriveUtils.LimitPos(ref scratchPos, axis, range);

                if (lockInactiveAxis)
                {
                    DriveUtils.LockFreeAxisPosition(ref scratchPos, axis);
                }

                transform.position = startMatrix.MultiplyPoint3x4(scratchPos);
            }
            else if (lockInverse)
            {
                transform.localPosition = middlePos;
            }
        }
        protected VideoDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> extractedMIATypeIds) : base(driveInfo)
        {
            IMediaAccessor    mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
            ResourcePath      rp            = LocalFsResourceProviderBase.ToResourcePath(driveInfo.Name);
            IResourceAccessor ra;

            if (!rp.TryCreateLocalResourceAccessor(out ra))
            {
                throw new ArgumentException(string.Format("Unable to access drive '{0}'", driveInfo.Name));
            }
            using (ra)
                _mediaItem = mediaAccessor.CreateLocalMediaItem(ra, mediaAccessor.GetMetadataExtractorsForMIATypes(extractedMIATypeIds));
            if (_mediaItem == null)
            {
                throw new Exception(string.Format("Could not create media item for drive '{0}'", driveInfo.Name));
            }
            MediaItemAspect mia = _mediaItem.Aspects[MediaAspect.ASPECT_ID];

            mia.SetAttribute(MediaAspect.ATTR_TITLE, mia.GetAttributeValue(MediaAspect.ATTR_TITLE) +
                             " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")");
        }
    public void Execute()
    {
      var path = _opticalDrive;

      //Eject the media for the currently playing video
      var currentPlayer = ServiceRegistration.Get<IPlayerContextManager>().CurrentPlayerContext;
      var mediaItem = currentPlayer?.CurrentMediaItem;
      var mediaItemPath = GetRemovableMediaItemPath(mediaItem);
      if (!string.IsNullOrEmpty(mediaItemPath))
      {
        //Stop playback before eject
        currentPlayer?.Stop();
        path = mediaItemPath;
      }

      var error = DriveUtils.EjectDrive(path);
      string driveLetter = path.Length >= 2 ? path.Substring(0, 2) : "?";
      switch (error)
      {
        case DriveUtils.DriveEjectError.InvalidMediaError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} is invalid!", driveLetter);
          break;
        case DriveUtils.DriveEjectError.NotFoundError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} does not exist!", driveLetter);
          break;
        case DriveUtils.DriveEjectError.LockError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} could not be locked!", driveLetter);
          break;
        case DriveUtils.DriveEjectError.DismountError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} could not be dismounted!", driveLetter);
          break;
        case DriveUtils.DriveEjectError.PreventRemovalError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} could not be suspended!", driveLetter);
          break;
        case DriveUtils.DriveEjectError.EjectError:
          ServiceRegistration.Get<ILogger>().Error("Media eject failed. Drive {0} could not be ejected!", driveLetter);
          break;
      }
    }
Exemple #24
0
        /// <summary>
        /// Install the version specified by code or name,
        /// if both are null latest version is installed
        /// </summary>
        /// <param name="code">Target version code to be installed.</param>
        /// <param name="name">Target version name to be installed.</param>
        public void Install(int code, string name)
        {
            Version version = null;

            if (code > 0)
            {
                version = _project.GetVersion(code);
            }
            else if (!string.IsNullOrEmpty(name))
            {
                version = _project.GetVersion(name);
            }
            else
            {
                version = _project.GetLatestVersion();
            }

            if (version == null)
            {
                Console.WriteLine("Version could not be found.");
                return;
            }

            Console.WriteLine("Starting Download...");

            if (!DriveUtils.DownloadFile(FilePath.TempZipFile, version.FileId))
            {
                Console.WriteLine("Downloding updated failed.");
                return;
            }

            UnzipFiles();

            var configJson = new ConfigJson(_project.SoftwareName, version.VersionCode);

            configJson.SaveJson();

            Console.WriteLine($"Updated to version code {version.VersionName}");
        }
Exemple #25
0
        public async Task CreateTable(Table table, string fileName, string sheetName, double scale)
        {
            try
            {
                _scale = scale;
                _table = table;

                using var drive = new DriveUtils();
                var fileId = await drive.CreateSpreadsheetFile(fileName);

                var ws = Worksheet.CreateEndUser(fileId);
                _sheetId = ws.CreateSheet(sheetName);
                var response = await ws.BatchUpdate(GetBatchUpdate(), fileId);

                Utils.ShowSpreadsheetFile(fileId, _sheetId.ToString());
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex, "GoogleTable");
                MessageBox.Show(ex.Message);
            }
        }
Exemple #26
0
        /// <summary>
        /// returns letter + ":"
        /// </summary>
        /// <returns>returns unused drive letter with column unless none is found, in which case it returns null</returns>
        private string MakeSubstPath(string path)
        {
            // Drive letter used for subst
            string substDriveLetter;

            // Drive letter used + colon
            string substDriveLetterColon;

            substDriveLetter = DriveUtils.GetFirstUnusedDriveLetter();

            if (substDriveLetter == null)
            {
                return(null);
            }

            substDriveLetterColon = substDriveLetter + ":";
            XAssert.IsTrue(MakeSubst(substDriveLetterColon, path), "Failed to make subst");

            // Add this to make sure we remove later
            m_createdDrives.Add(substDriveLetterColon);
            return(substDriveLetterColon);
        }
        public String GetCurrentSheetUrl(DocumentUploadType type, string regionId, string apbnKey)
        {
            User user = KawalDesaController.GetCurrentUser();

            var context = new AdapterContext(dbContext, type, regionId, apbnKey);

            var region = dbContext.Set <Region>().Find(regionId);

            String userId    = user != null ? user.Id : null;
            String userEmail = user != null ? user.Email : null;
            String userName  = user != null ? user.Name : "Anonymous";

            var workItem = dbContext.Set <SpreadsheetWorkItem>()
                           .FirstOrDefault(w => w.fkUserId == userId &&
                                           w.fkRegionId == region.Id &&
                                           w.Type == type &&
                                           w.ApbnKey == context.Apbn.Key);

            if (workItem == null)
            {
                using (var tx = dbContext.Database.BeginTransaction())
                {
                    var typeStr = type.ToString();
                    typeStr = typeStr.Replace("National", "");
                    typeStr = typeStr.Replace("Regional", "");
                    typeStr = typeStr.ToUpper();

                    var root = HttpContext.Current.Server.MapPath("~/Content/sheets");
                    Directory.CreateDirectory(root);
                    var safeFileName = typeStr + " " + apbnKey + " " + regionId + " " + region.Name + ".xlsx";
                    var fullPath     = Path.Combine(root, safeFileName);
                    var bytes        = adapters[type].GetBytes(context);
                    File.WriteAllBytes(fullPath, bytes);

                    var authEmail  = ConfigurationManager.AppSettings["Drive.AuthEmail"];
                    var authKey    = ConfigurationManager.AppSettings["Drive.AuthKey"];
                    var parentDir  = ConfigurationManager.AppSettings["Drive.ParentDir"];
                    var driveUtils = new DriveUtils(authEmail, authKey, parentDir);

                    var workDir = dbContext.Set <SpreadsheetWorkDir>().FirstOrDefault(
                        d => d.fkUserId == userId);

                    if (workDir == null)
                    {
                        var dirName = string.Format("KawalDesa Sheets - ({0})", userName);
                        workDir = new SpreadsheetWorkDir()
                        {
                            GoogleSheetId = driveUtils.CreateParentDirectory(userEmail, dirName),
                            fkUserId      = userId
                        };
                        dbContext.Set <SpreadsheetWorkDir>().Add(workDir);
                        dbContext.SaveChanges();
                    }

                    workItem = new SpreadsheetWorkItem()
                    {
                        GoogleSheetId = driveUtils.UploadFile(workDir.GoogleSheetId, fullPath, safeFileName),
                        fkUserId      = userId,
                        fkRegionId    = region.Id,
                        ApbnKey       = apbnKey,
                        Type          = type
                    };
                    dbContext.Set <SpreadsheetWorkItem>().Add(workItem);
                    dbContext.SaveChanges();

                    tx.Commit();
                }
            }

            //string fullyQualifiedUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority);
            //return fullyQualifiedUrl + "/Content/sheets/" + safeFileName;
            return("https://docs.google.com/spreadsheets/d/" + workItem.GoogleSheetId);
        }
Exemple #28
0
        public void GetDiskOccupiedSpace()
        {
            ulong fSize = DriveUtils.GetDiskOccupiedSpace(2323, "c:\\Temp\\log20200312.txt");

            Assert.IsTrue(fSize > 0);
        }
Exemple #29
0
        protected MultimediaDriveHandler(DriveInfo driveInfo, IEnumerable <Guid> necessaryMIATypeIds, IEnumerable <Guid> optionalMIATypeIds, MultiMediaType mediaType) : base(driveInfo)
        {
            _mediaType = mediaType;
            string drive = driveInfo.Name;

            drive = drive.Substring(0, 2); // Clip potential '\\' at the end
            string directory = "/" + drive + "/";

            _mediaItemsSubViewSpecification = new LocalDirectoryViewSpecification(driveInfo.VolumeLabel + " (" + DriveUtils.GetDriveNameWithoutRootDirectory(driveInfo) + ")",
                                                                                  ResourcePath.BuildBaseProviderPath(LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID, directory),
                                                                                  necessaryMIATypeIds, optionalMIATypeIds);
        }
        /// <summary>
        /// Upload updater to drive and return its link.
        /// </summary>
        public void GetUpdater(string os)
        {
            Console.WriteLine("Creating Updater...");

            string fileId;

            if (DriveUtils.GetUpdaterLink(_project, os, out fileId))
            {
                Console.WriteLine(DriveUtils.IdToDirectDownloadLink(fileId));
                return;
            }


            //copy updater into temp
            var sourcePath = "";

            switch (os)
            {
            case "win":
                sourcePath = FilePath.WinUpdaterDir;
                break;

            case "linux":
                sourcePath = FilePath.LinuxUpdaterDir;
                break;

            default:
                return;
            }

            var destinationPath = FilePath.TempDir;

            Directory.CreateDirectory(destinationPath);
            Utils.Empty(new DirectoryInfo(destinationPath));

            //Now Create all of the directories
            foreach (var dirPath in Directory.GetDirectories(sourcePath, "*",
                                                             SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(sourcePath, destinationPath));
            }

            //Copy all the files & Replaces any files with the same name
            foreach (var newPath in Directory.GetFiles(sourcePath, "*.*",
                                                       SearchOption.AllDirectories))
            {
                File.Copy(newPath, newPath.Replace(sourcePath, destinationPath), true);
            }

            //create json for updater

            var installConfigJson = new InstallConfigJson(
                FilePath.InstallConfigJsonInTemp,
                DriveUtils.GetRootFoderIdFromMyDrive(),
                _project.SoftwareName
                );

            installConfigJson.SaveJson();


            //zip and upload
            File.Delete(FilePath.TempZipFile);
            ZipFile.CreateFromDirectory(FilePath.TempDir, FilePath.TempZipFile);
            Console.WriteLine("Uploading to Drive...");
            var updaterFileId = DriveUtils.UploadFileToCloud($"{_project.SoftwareName}--{os}.zip", _project.FolderId, FilePath.TempZipFile);

            Console.WriteLine("Link for the updater:");
            Console.WriteLine(DriveUtils.IdToDirectDownloadLink(updaterFileId));
        }