Esempio n. 1
0
        public async Task <IResultModel> QueryBindPages(Guid roleId)
        {
            if (!await _repository.ExistsAsync(roleId))
            {
                return(ResultModel.NotExists);
            }

            var model = new RolePageBindModel
            {
                RoleId = roleId
            };

            var pageCodesTask = _pageRepository.QueryPageCodesByRole(roleId);
            var buttonsTask   = _buttonRepository.QueryButtonCodes(roleId);

            var pageCodes = await pageCodesTask;
            var buttons   = await buttonsTask;

            if (pageCodes.Any())
            {
                foreach (var pageCode in pageCodes)
                {
                    var page = new PageBindModel
                    {
                        Code    = pageCode,
                        Buttons = buttons.Where(m => m.PageCode == pageCode).Select(m => m.ButtonCode).ToList()
                    };

                    model.Pages.Add(page);
                }
            }

            return(ResultModel.Success(model));
        }
Esempio n. 2
0
        public AntdBindModule()
        {
            Get["/bind"] = x => {
                var model             = new PageBindModel();
                var bindConfiguration = new BindConfiguration();
                var bindIsActive      = bindConfiguration.IsActive();
                model.BindIsActive = bindIsActive;
                model.BindOptions  = bindConfiguration.Get() ?? new BindConfigurationModel();
                model.BindZones    = bindConfiguration.Get()?.Zones;
                return(JsonConvert.SerializeObject(model));
            };

            Post["/bind/set"] = x => {
                var bindConfiguration = new BindConfiguration();
                bindConfiguration.Set();
                return(HttpStatusCode.OK);
            };

            Post["/bind/restart"] = x => {
                var bindConfiguration = new BindConfiguration();
                bindConfiguration.Start();
                bindConfiguration.RndcReconfig();
                bindConfiguration.RndcReload();
                return(HttpStatusCode.OK);
            };

            Post["/bind/stop"] = x => {
                var bindConfiguration = new BindConfiguration();
                bindConfiguration.Stop();
                return(HttpStatusCode.OK);
            };

            Post["/bind/enable"] = x => {
                var dhcpdConfiguration = new BindConfiguration();
                dhcpdConfiguration.Enable();
                dhcpdConfiguration.Start();
                return(HttpStatusCode.OK);
            };

            Post["/bind/disable"] = x => {
                var dhcpdConfiguration = new BindConfiguration();
                dhcpdConfiguration.Disable();
                dhcpdConfiguration.Stop();
                return(HttpStatusCode.OK);
            };

            Post["/bind/options"] = x => {
                string notify                = Request.Form.Notify;
                string maxCacheSize          = Request.Form.MaxCacheSize;
                string maxCacheTtl           = Request.Form.MaxCacheTtl;
                string maxNcacheTtl          = Request.Form.MaxNcacheTtl;
                string forwarders            = Request.Form.Forwarders;
                string allowNotify           = Request.Form.AllowNotify;
                string allowTransfer         = Request.Form.AllowTransfer;
                string recursion             = Request.Form.Recursion;
                string transferFormat        = Request.Form.TransferFormat;
                string querySourceAddress    = Request.Form.QuerySourceAddress;
                string querySourcePort       = Request.Form.QuerySourcePort;
                string version               = Request.Form.Version;
                string allowQuery            = Request.Form.AllowQuery;
                string allowRecursion        = Request.Form.AllowRecursion;
                string ixfrFromDifferences   = Request.Form.IxfrFromDifferences;
                string listenOnV6            = Request.Form.ListenOnV6;
                string listenOnPort53        = Request.Form.ListenOnPort53;
                string dnssecEnabled         = Request.Form.DnssecEnabled;
                string dnssecValidation      = Request.Form.DnssecValidation;
                string dnssecLookaside       = Request.Form.DnssecLookaside;
                string authNxdomain          = Request.Form.AuthNxdomain;
                string keyName               = Request.Form.KeyName;
                string keySecret             = Request.Form.KeySecret;
                string controlAcl            = Request.Form.ControlAcl;
                string controlIp             = Request.Form.ControlIp;
                string controlPort           = Request.Form.ControlPort;
                string controlAllow          = Request.Form.ControlAllow;
                string loggingChannel        = Request.Form.LoggingChannel;
                string loggingDaemon         = Request.Form.LoggingDaemon;
                string loggingSeverity       = Request.Form.LoggingSeverity;
                string loggingPrintCategory  = Request.Form.LoggingPrintCategory;
                string loggingPrintSeverity  = Request.Form.LoggingPrintSeverity;
                string loggingPrintTime      = Request.Form.LoggingPrintTime;
                string trustedKeys           = Request.Form.TrustedKey;
                string aclLocalInterfaces    = Request.Form.AclLocalInterfaces;
                string aclInternalInterfaces = Request.Form.AclInternalInterfaces;
                string aclExternalInterfaces = Request.Form.AclExternalInterfaces;
                string aclLocalNetworks      = Request.Form.AclLocalNetworks;
                string aclInternalNetworks   = Request.Form.AclInternalNetworks;
                string aclExternalNetworks   = Request.Form.AclExternalNetworks;
                var    model = new BindConfigurationModel {
                    Notify                = notify,
                    MaxCacheSize          = maxCacheSize,
                    MaxCacheTtl           = maxCacheTtl,
                    MaxNcacheTtl          = maxNcacheTtl,
                    Forwarders            = forwarders.SplitToList().Select(_ => _.Trim()).ToList(),
                    AllowNotify           = allowNotify.SplitToList().Select(_ => _.Trim()).ToList(),
                    AllowTransfer         = allowTransfer.SplitToList().Select(_ => _.Trim()).ToList(),
                    Recursion             = recursion,
                    TransferFormat        = transferFormat,
                    QuerySourceAddress    = querySourceAddress,
                    QuerySourcePort       = querySourcePort,
                    Version               = version,
                    AllowQuery            = allowQuery.SplitToList().Select(_ => _.Trim()).ToList(),
                    AllowRecursion        = allowRecursion.SplitToList().Select(_ => _.Trim()).ToList(),
                    IxfrFromDifferences   = ixfrFromDifferences,
                    ListenOnV6            = listenOnV6.SplitToList().Select(_ => _.Trim()).ToList(),
                    ListenOnPort53        = listenOnPort53.SplitToList().Select(_ => _.Trim()).ToList(),
                    DnssecEnabled         = dnssecEnabled,
                    DnssecValidation      = dnssecValidation,
                    DnssecLookaside       = dnssecLookaside,
                    AuthNxdomain          = authNxdomain,
                    KeyName               = keyName,
                    KeySecret             = keySecret,
                    ControlAcl            = controlAcl,
                    ControlIp             = controlIp,
                    ControlPort           = controlPort,
                    ControlAllow          = controlAllow.SplitToList().Select(_ => _.Trim()).ToList(),
                    LoggingChannel        = loggingChannel,
                    LoggingDaemon         = loggingDaemon,
                    LoggingSeverity       = loggingSeverity,
                    LoggingPrintCategory  = loggingPrintCategory,
                    LoggingPrintSeverity  = loggingPrintSeverity,
                    LoggingPrintTime      = loggingPrintTime,
                    TrustedKeys           = trustedKeys,
                    AclLocalInterfaces    = aclLocalInterfaces.SplitToList().Select(_ => _.Trim()).ToList(),
                    AclInternalInterfaces = aclInternalInterfaces.SplitToList().Select(_ => _.Trim()).ToList(),
                    AclExternalInterfaces = aclExternalInterfaces.SplitToList().Select(_ => _.Trim()).ToList(),
                    AclLocalNetworks      = aclLocalNetworks.SplitToList().Select(_ => _.Trim()).ToList(),
                    AclInternalNetworks   = aclInternalNetworks.SplitToList().Select(_ => _.Trim()).ToList(),
                    AclExternalNetworks   = aclExternalNetworks.SplitToList().Select(_ => _.Trim()).ToList()
                };
                var bindConfiguration = new BindConfiguration();
                bindConfiguration.Save(model);
                return(HttpStatusCode.OK);
            };

            Post["/bind/zone"] = x => {
                string name = Request.Form.Name;
                string type = Request.Form.Type;
                string file = Request.Form.File;
                string serialUpdateMethod = Request.Form.NameSerialUpdateMethod;
                string allowUpdate        = Request.Form.AllowUpdate;
                string allowQuery         = Request.Form.AllowQuery;
                string allowTransfer      = Request.Form.AllowTransfer;
                var    model = new BindConfigurationZoneModel {
                    Name = name,
                    Type = type,
                    File = file,
                    SerialUpdateMethod = serialUpdateMethod,
                    AllowQuery         = allowQuery.SplitToList().Select(_ => _.Trim()).ToList(),
                    AllowUpdate        = allowUpdate.SplitToList().Select(_ => _.Trim()).ToList(),
                    AllowTransfer      = allowTransfer.SplitToList().Select(_ => _.Trim()).ToList()
                };
                var bindConfiguration = new BindConfiguration();
                bindConfiguration.AddZone(model);
                return(HttpStatusCode.OK);
            };

            Post["/bind/zone/del"] = x => {
                string guid = Request.Form.Guid;
                var    bindConfiguration = new BindConfiguration();
                bindConfiguration.RemoveZone(guid);
                return(HttpStatusCode.OK);
            };
        }