Пример #1
0
        public StorageModule()
        {
            this.RequiresAuthentication();

            Get["/storage"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.VolumesInfo    = Volumes.BlocksFromDd();
                vmod.IsOsRemovable  = InstallCheck.IsOsRemovable;
                vmod.Mounts         = antdlib.MountPoint.MountRepository.Get();
                vmod.CurrentContext = Request.Path;
                vmod.CCTable        = CCTableRepository.GetAllByContext(Request.Path);
                vmod.Count          = CCTableRepository.GetAllByContext(Request.Path).ToArray().Length;
                return(View["_page-storage", vmod]);
            };

            Get["/storage/reload/volumes"] = x => {
                Volumes.PopulateBlocks();
                return(Response.AsJson(true));
            };

            Post["/storage/install"] = x => {
                new InstallOperativeSystem((string)Request.Form.DiskName).SetDiskAndInstall();
                return(Response.AsJson(true));
            };

            Post["/rsync/add"] = x => {
                var source      = (string)Request.Form.Source;
                var destination = (string)Request.Form.Destination;
                var options     = (string)Request.Form.Options;
                var type        = (string)Request.Form.Type.Value;
                Rsync.Create(source, destination, options, type);
                return(Response.AsRedirect("/"));
            };
        }