Esempio n. 1
0
        private object SupervisorDashboard()
        {
            this.LoggedIn(true);

            GroupBundle groupBundle = new GroupBundle();

            return(new object[]
            {
                new object[]                 // zantei
                {
                    groupBundle.GetTotalFileNum(),
                    groupBundle.GetTotalFileSize(),
                    groupBundle.LiteGroups.Count,
                },

                groupBundle.LiteGroups.Select(v =>
                {
                    Group group = v.GetGroup();

                    return new object[]
                    {
                        Path.GetFileName(group.Dir),
                        group.AccessKey,
                        group.Name,
                        group.GroupTotalFileSizeMax,
                    };
                }),
            });
        }
Esempio n. 2
0
        private object SupervisorDeleteGroup()
        {
            this.LoggedIn(true);

            string accessKey = this.TPrm.StringValue;

            // チェック・正規化
            {
                accessKey = CodeDefinition.ToFair.AccessKey(accessKey);
            }

            string dir = new GroupBundle().LiteGroups.First(v => v.AccessKey == accessKey).GetGroup().Dir;

            FileTools.Delete(dir);

            return("OK");
        }
Esempio n. 3
0
        private object SupervisorEditGroup()
        {
            this.LoggedIn(true);

            string currAccessKey         = this.TPrm["CurrAccessKey"].StringValue;
            string localDir              = this.TPrm["LocalDir"].StringValue;
            string accessKey             = this.TPrm["AccessKey"].StringValue;
            string name                  = this.TPrm["Name"].StringValue;
            long   groupTotalFileSizeMax = long.Parse(this.TPrm["GroupTotalFileSizeMax"].StringValue);

            // チェック・正規化
            {
                currAccessKey = CodeDefinition.ToFair.AccessKey(currAccessKey);
                localDir      = CodeDefinition.ToFair.GroupLocalDir(localDir);
                accessKey     = CodeDefinition.ToFair.AccessKey(accessKey);
                name          = CodeDefinition.ToFair.GroupName(name);
                Utilities.CheckRange(groupTotalFileSizeMax, 1L, Consts.TOTAL_FILE_SIZE_MAX, "容量");
            }

            GroupBundle groupBundle = new GroupBundle();
            Group       group       = groupBundle.LiteGroups.First(v => v.AccessKey == currAccessKey).GetGroup();

            bool changeLocalDirFlag  = StringTools.CompIgnoreCase(Path.GetFileName(group.Dir), localDir) != 0;
            bool changeAccessKeyFlag = group.AccessKey != accessKey;

            // チェック
            {
                if (changeLocalDirFlag)
                {
                    string dirNew = Path.Combine(Consts.GROUP_BUNDLE_DIR, localDir);

                    if (Directory.Exists(dirNew))
                    {
                        throw new Exception("新しいローカルディレクトリは既に存在します。");
                    }

                    if (File.Exists(dirNew))
                    {
                        throw null;                         // 想定外
                    }
                }
                if (changeAccessKeyFlag)
                {
                    if (
                        groupBundle.LiteGroups.Any(v => v.AccessKey == accessKey) ||
                        accessKey == Consts.SUPERVISOR_ACCESS_KEY
                        )
                    {
                        throw new Exception("新しいアクセスキーは既に存在します。");
                    }
                }
            }

            group.AccessKey             = accessKey;
            group.Name                  = name;
            group.GroupTotalFileSizeMax = groupTotalFileSizeMax;
            group.Save();

            if (changeLocalDirFlag)             // 最後に!
            {
                string dirNew = Path.Combine(Consts.GROUP_BUNDLE_DIR, localDir);

                Directory.Move(group.Dir, dirNew);
            }

            return("OK");
        }