Exemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            string       apppath = System.Reflection.Assembly.GetEntryAssembly().Location;
            string       appdir  = System.IO.Path.GetDirectoryName(apppath);
            string       args    = "";
            bool         ok      = false;
            Drive        drive   = null;
            ReturnBox    rb      = null;
            MountService ms      = new MountService();

            if (e.Args.Length > 0)
            {
                args = string.Join(" ", e.Args);
                Logger.Log($"Starting app: {apppath} {args}");
                // process args
                // golddrive.exe z: \\golddrive\host\path -ouid=-1,gid=-1
                drive = ms.GetDriveFromArgs(args);

                // check ssh auth
                rb = ms.TestSsh(drive, drive.AppKey);
                if (rb.MountStatus == MountStatus.OK)
                {
                    ok = true;
                }
                else
                {
                    rb = ms.TestSsh(drive, drive.UserKey);
                    if (rb.MountStatus == MountStatus.OK)
                    {
                        rb = ms.SetupSshWithUserKey(drive, drive.UserKey);
                        ok = rb.MountStatus == MountStatus.OK;
                    }
                }
            }

            if (ok)
            {
                //string cmd = $"{appdir}\\golddrive.exe";
                //Logger.Log($"Starting cli: {cmd} {args}");
                //Process.Start(cmd, args);
                //Process.Start("net.exe", "use " + args);
                rb = ms.Mount(drive);
                if (rb.MountStatus != MountStatus.OK)
                {
                    ok = false;
                }
            }

            if (!ok)
            {
                new MainWindow(rb).ShowDialog();
            }

            this.Shutdown();
        }
Exemplo n.º 2
0
        public MainWindowViewModel(ReturnBox rb)
        {
            _mountService = new MountService();
            //SelectedDrive = drive;

            //Messenger.Default.Register<string>(this, OnShowView);
            CurrentPage = Page.Main;
            LoadDrivesAsync();
            GetVersions();
        }
Exemplo n.º 3
0
        public MainWindowViewModel(ReturnBox rb)
        {
            _mountService = new MountService();
            //Messenger.Default.Register<string>(this, OnShowView);

            CurrentPage = Page.Main;
            LoadDrivesAsync();
            GetVersionsAsync();
            if (rb != null)
            {
                Message = rb.Error;
            }
        }