コード例 #1
0
 public override void OnAuthorization(BaseModule context)
 {
     if (!context.Authorized && context.RequestContainsKey("XX") && context.RequestString("XX").Contains("Anno"))
     {
         context.Authorized = true;
     }
 }
コード例 #2
0
        //public bool Exists(int ModuleId)
        //{
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("select count(1) from BaseModule");
        //    strSql.Append(" where ");
        //    strSql.Append(" ModuleId = @ModuleId  ");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@ModuleId", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = ModuleId;

        //    return DbHelperSQL.Exists(strSql.ToString(), parameters);
        //}



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BaseModule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BaseModule(");
            strSql.Append("Name,Memo,SortId");
            strSql.Append(") values (");
            strSql.Append("@Name,@Memo,@SortId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",   SqlDbType.VarChar, 200),
                new SqlParameter("@Memo",   SqlDbType.VarChar, 254),
                new SqlParameter("@SortId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.Name;
            parameters[1].Value = model.Memo;
            parameters[2].Value = model.SortId;

            object obj = dbc.ExeInfochange(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
        public bool RecoverModuleById(Guid moduleID)
        {
            BaseModule module = BaseObject.GetById <BaseModule>(moduleID);

            if (module != null)
            {
                string content = module.Content;
                module.Content = "Deze module is hersteld. Om de content terug in de module te plaatsen kiest u bewerken en klik op opslaan.<br /><strong>LETOP!! Corrigeer de content voordat u op opslaan klikt.</strong>";
                module.Save();

                module.Content = content;
                module.Save();
                //if (module.IsVisibleOnAllPages || module.IsVisibleOnAllPagesInLayout)
                //{
                //    BitCaching.ClearCache();
                //}
                //else
                //{

                //    BitCaching.RemoveItemFromCache(module.Page.ID.ToString());
                //}

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        public void Open()
        {
            selectedItem   = null;
            selectedModule = null;

            gridItems.Clear();

            foreach (Item item in InventoryUtility.InvArmorEquips(Main.LocalPlayer))
            {
                if (item.IsAir)
                {
                    continue;
                }

                if (item.ModItem is ModularItem modularItem)
                {
                    UIModularItem uiModularItem = new UIModularItem(modularItem)
                    {
                        Width  = { Pixels = 48 },
                        Height = { Pixels = 48 }
                    };
                    uiModularItem.OnClick += args =>
                    {
                        args.Handled = true;

                        OpenItem(modularItem);
                    };

                    gridItems.Add(uiModularItem);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <BaseModule> GetList(string strWhere)
        {
            try
            {
                List <BaseModule> list   = new List <BaseModule>();
                StringBuilder     strSql = new StringBuilder();
                strSql.Append("select ModuleId,Name,Memo,SortId");
                strSql.Append(" FROM BaseModule ");
                if (strWhere.Trim() != "")
                {
                    strSql.Append(" where " + strWhere);
                }
                DataSet ds = dbc.ds(strSql.ToString());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        BaseModule module = new BaseModule();
                        module.ModuleId = Convert.ToInt16(ds.Tables[0].Rows[i]["ModuleId"]);
                        module.Name     = ds.Tables[0].Rows[i]["Name"].ToString();
                        module.SortId   = Convert.ToInt16(ds.Tables[0].Rows[i]["SortId"]);
                        list.Add(module);
                    }
                }
                return(list);
            }
            catch (Exception ee)
            {
                MessageUtil.ShowError(ee.Message);
                return(null);
            }
        }
コード例 #6
0
        public VelocityHelper(BaseModule _bpm, XmlDBEntity _Theme)
        {
            Theme = _Theme;
            bPage = _bpm;

            Init(_bpm);
        }
コード例 #7
0
        public static string MoveModule(string moduleid, string pageid, string containername, int sortorder)
        {
            BaseService.CheckLoginAndLicense();

            string where = String.Format("FK_PAGE = '{0}' And ContainerName='{1}' AND OrderingNumber >= {2}", pageid, containername, sortorder);
            //where = String.Format("FK_PAGE = '{0}' And Container='{1}'", pageid, containername);
            BaseCollection <BaseModule> modules = BaseCollection <BaseModule> .Get(where, "OrderingNumber");

            foreach (BaseModule mod in modules)
            {
                mod.OrderingNumber++;
                mod.Save();
            }

            string returnValue = "";

            //moduleid = moduleid.Replace("bitModule", "");
            moduleid      = moduleid.Replace("bitModule", "").Replace("_", "-");
            containername = containername.Replace("bitContainer", "");

            BaseModule module = (BaseModule)BaseDomainObject.GetById <BaseModule>(new Guid(moduleid));

            module.ContainerName  = containername;
            module.OrderingNumber = sortorder;
            module.Save();
            returnValue = new ModuleService().GetUserControlContent(module);
            //moet naar container
            //updateOrderingNumber
            //alleen degene ophalen met een groter nummer dan sortorder

            PublishDependentPages(module);
            return(returnValue);
        }
コード例 #8
0
        public VelocityHelper(BaseModule _bpm, EffectDBEntity _Theme)
        {
            Theme = _Theme;
            bpm   = _bpm;

            Init(_bpm);
        }
コード例 #9
0
        public static string SaveModuleContent(string id, string content)
        {
            BaseService.CheckLoginAndLicense();
            id = id.Replace("bitModule", "");
            id = id.Replace("bitEditor", "");
            BaseModule module = BaseModule.GetById <BaseModule>(new Guid(id));

            module = module.ConvertToType();
            //module.LoadPropsFromXmlFile();
            content        = content.Replace("?mode=edit", ""); //BUG WORKAROUND. BUG ZIT MOGELIJK NOG IN DE EDITOR.
            module.Content = content;
            module.Save();

            module.Publish();

            //Experimenteel caching reset
            //if (module.Page != null)
            //{
            //    BitCaching.RemoveItemFromCache(module.Page.ID.ToString());
            //}

            if (module.Type == "HtmlModule")
            {
                PublishModule(module);
            }
            return(new ModuleService().GetUserControlContent(module));
        }
コード例 #10
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            VersionData versionData = new VersionData();

            versionData.CurrentVersion = VERSION;

            BaseModule module = ModuleFactory.Get(ModuleFactory.Version);

            try
            {
                Task <bool> processResult = module.Process(versionData);
                bool        result        = await processResult;
                if (result == false)
                {
                    Console.WriteLine("Version Mismatch");
                    loginButton.IsEnabled = false;
                    MessageBox.Show("Version Mismatch");
                }
                else
                {
                    loginButton.IsEnabled = true;
                    Console.WriteLine("Updated Version : " + VERSION);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR : " + ex.Message);
            }
        }
コード例 #11
0
ファイル: OverrideModule.cs プロジェクト: Keswiik/Juicy
        internal override List <IBinding> GetBindings()
        {
            List <IBinding> bindings = new List <IBinding>();

            bindings.AddRange(BaseModule.GetBindings());

            // this will prevent 'silently' overriding bad bindings in the base module
            foreach (var binding in bindings)
            {
                CacheBinding(binding);
            }

            List <IBinding> overriddenBindings = new List <IBinding>();

            overriddenBindings.AddRange(OverriddenModule.GetBindings());

            foreach (var binding in overriddenBindings)
            {
                if (IsCached(binding.BaseType, binding.Name))
                {
                    continue;
                }

                bindings.Add(binding);
                CacheBinding(binding);
            }

            return(bindings);
        }
コード例 #12
0
        private SiteMap GetSiteMap(bool rebuild = false)
        {
            var cacheKey = "Sitemap-Cached";
            Action <SiteMap> cacheSitemap = (sm) =>
            {
                CacheItemPolicy p = new CacheItemPolicy();
                p.AbsoluteExpiration = DateTimeOffset.Now.AddHours(1);
                MemoryCache.Default.Add(cacheKey, sm, p);
            };

            lock (BaseModule.GetLockObject("SiteMap")) // ensures only one thread can build sitemap
            {
                // try from memory (1 hour cache)
                {
                    SiteMap sitemap = MemoryCache.Default[cacheKey] as SiteMap;

                    if (sitemap != null)
                    {
                        return(sitemap);
                    }
                }

                var sitemapPath = Path.Combine(this.RootPath, "Site", "sitemap.json");

                // use cached file if it is less than 1 days old
                if (File.Exists(sitemapPath) &&
                    DateTime.UtcNow.Subtract(File.GetLastWriteTimeUtc(sitemapPath)).TotalDays < 1)
                {
                    using (var sr = File.OpenText(sitemapPath))
                    {
                        JsonTextReader jr      = new JsonTextReader(sr);
                        JsonSerializer ser     = new JsonSerializer();
                        var            sitemap = ser.Deserialize <SiteMap>(jr);

                        cacheSitemap(sitemap);

                        return(sitemap);
                    }
                }

                // rebuild and cache it
                {
                    var sitemap = new SiteMap();
                    SiteMapModule.SiteMapRequested(this.Context, sitemap);

                    using (var fs = File.OpenWrite(sitemapPath))
                        using (var sw = new StreamWriter(fs))
                        {
                            JsonTextWriter jw  = new JsonTextWriter(sw);
                            JsonSerializer ser = new JsonSerializer();

                            ser.Serialize(jw, sitemap);
                        }

                    cacheSitemap(sitemap);

                    return(sitemap);
                }
            }
        }
コード例 #13
0
        public static void DeleteModule(string id)
        {
            BaseService.CheckLoginAndLicense();
            BaseModule module = GetModule(id);

            CmsPage page = module.Page;

            if (page != null)
            {
                //verwijderen drilldown modules
                string where = String.Format("FK_Page='{0}'", module.Page.ID);
                BaseCollection <BaseModule> modulesOnThisPage = BaseCollection <BaseModule> .Get(where);

                //foreach (BaseModule mod in modulesOnThisPage)
                //{
                //    if (mod.DrillDownType == NavigationTypeEnum.ShowDetailsInModules)
                //    {
                //        string modArray = mod.DrillDownModules.ToString().Replace(module.ID + ",", "");
                //        mod.DrillDownModules = modArray.Split(new char[] { ',' });
                //    }
                //}
                //Remove page from caching.
                //BitCaching.RemoveItemFromCache(page.ID.ToString());
            }
            //SetUnpublishedItem(module);
            module.Delete();

            PublishDependentPages(module);
        }
コード例 #14
0
        private void OpenItem(ModularItem item)
        {
            selectedItem = item;

            gridModules.Clear();

            foreach (int type in ModuleLoader.validModulesForItem[item.Type])
            {
                BaseModule module = ModuleLoader.GetModule(type);

                UIModule uiModule = new UIModule(module)
                {
                    Color  = item.IsInstalled(module.Type) ? Color.LimeGreen : Color.Red,
                    Width  = { Percent = 100 },
                    Height = { Pixels = 64 }
                };
                uiModule.OnClick += args =>
                {
                    args.Handled = true;

                    OpenModule(module);
                };
                gridModules.Add(uiModule);
            }
        }
コード例 #15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BaseModule model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BaseModule set ");

            strSql.Append(" Name = @Name , ");
            strSql.Append(" Memo = @Memo , ");
            strSql.Append(" SortId = @SortId , ");
            strSql.Append(" where ModuleId=@ModuleId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ModuleId", SqlDbType.Int,       4),
                new SqlParameter("@Name",     SqlDbType.VarChar, 200),
                new SqlParameter("@Memo",     SqlDbType.VarChar, 254),
                new SqlParameter("@SortId",   SqlDbType.Int,       4),
            };

            parameters[0].Value = model.ModuleId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Memo;
            parameters[3].Value = model.SortId;
            int rows = dbc.ExeInfochange(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #16
0
        /// <summary>
        /// 构建模块
        /// </summary>
        /// <returns></returns>
        protected virtual IModule CreateModule()
        {
            IModule module = new BaseModule(Guid.Parse(SysModuleID));

            CreateButton(module);
            return(module);
        }
コード例 #17
0
        public ServiceResponseData AlterModule()
        {
            int        moduleId = requestData.GetData <int>(0);
            BaseModule module   = NewObject <BaseModule>().getmodel(moduleId) as BaseModule;

            responseData.AddData(module);
            return(responseData);
        }
コード例 #18
0
        public BaseProxy(BaseRouterModule baseRouterModule, ProxyHelper proxyHelper, BaseModule baseModule)
        {
            this.proxyHelper      = proxyHelper;
            this.baseRouterModule = baseRouterModule;
            this.baseModule       = baseModule;

            callIDToResponseHandler = new Dictionary <int, Action <Response> >();
        }
コード例 #19
0
        [NotNull] public static string FormatTransaction([NotNull] BaseModule module, ulong from, ulong to, [CanBeNull] string note, DateTime instant, decimal amount, [NotNull] string unit, bool mention = false)
        {
            var fromName   = module.Name(from, mention);
            var toName     = module.Name(to, mention);
            var noteFormat = string.IsNullOrWhiteSpace(note) ? "" : $"'{note}'";

            return($"[{instant:HH\\:mm UTC dd-MMM-yyyy}] {FormatCurrency(amount, unit)} {fromName} => {toName} {noteFormat}");
        }
コード例 #20
0
ファイル: Power.cs プロジェクト: JonRurka/WarWorldInfServer
 public double GetValue(double x, double y, double z)
 {
     if (BaseModule == null || PowerModule == null)
     {
         throw new NullReferenceException("Base and power modules must be provided.");
     }
     return(System.Math.Pow(BaseModule.GetValue(x, y, z), PowerModule.GetValue(x, y, z)));
 }
コード例 #21
0
        void windowsUIView_QueryControl(object sender, QueryControlEventArgs e)
        {
            Type       moduleType = typeof(EntertainmentNetworkMainForm).Assembly.GetType(e.Document.ControlTypeName);
            BaseModule module     = Activator.CreateInstance(moduleType, this.ViewsManager) as BaseModule;

            //module.Init(barManager);
            e.Control = module;
        }
コード例 #22
0
 public void RemoveAllAdditionalModules()
 {
     for (int i = _additionalModules.Count - 1; i >= 0; i--)
     {
         BaseModule module = _additionalModules[i];
         _additionalModules.RemoveAt(i);
         module.Destroy();
     }
 }
コード例 #23
0
        public static async Task GetHelpMessageAsync(DiscordMessage msg, int id)
        {
            BaseModule          module       = GameManager.Instance.CurrentBomb.Modules.First(m => m.ModuleID == id);
            DiscordEmbedBuilder embedBuilder = new DiscordEmbedBuilder();

            embedBuilder.AddField("Manual", $"https://ktane.timwi.de/HTML/{module.ModuleName}.html".Replace(" ", "%20"));
            embedBuilder.AddField("Help", module.HelpMessage.FormatThis(module.ModuleID));
            await msg.Reply(embed : embedBuilder.WithTitle($"Help for: {module.ModuleName}").WithColor(DiscordColor.Red).Build());
        }
コード例 #24
0
ファイル: RightController.cs プロジェクト: hongfagj/efwplus
        public void SaveModule()
        {
            BaseModule module = frmaddmodule.currModule;

            module.BindDb(this);
            module.save();

            InitMenuData();
        }
コード例 #25
0
ファイル: RightController.cs プロジェクト: hongfagj/efwplus
        public void AlterModule(int moduleId)
        {
            (frmaddmodule as Form).Text = "修改模块";

            BaseModule module = NewObject <BaseModule>().getmodel(moduleId) as BaseModule;

            frmaddmodule.currModule = module;
            (frmaddmodule as Form).ShowDialog();
        }
コード例 #26
0
        [NotNull] public static string FormatBalance([NotNull] BaseModule module, [NotNull] IBalance balance)
        {
            var a = module.Name(balance.UserA);
            var b = module.Name(balance.UserB);

            var(borrower, lender) = balance.Amount < 0 ? (a, b) : (b, a);

            return($"{borrower} owes {FormatCurrency(Math.Abs(balance.Amount), balance.Unit)} to {lender}");
        }
コード例 #27
0
ファイル: MainForm.cs プロジェクト: yzdqk00000/ChannelsOf16
 /// <summary>
 /// 创建模块
 /// </summary>
 /// <param name="ModuleType"></param>
 /// <returns></returns>
 private BaseModule CreateModule(string ModuleType, object obj)
 {
     //添加视图
     _Module = Activator.CreateInstance(typeof(MainForm).Assembly.GetType(ModuleType), obj) as BaseModule;
     panelControl_Modules.Controls.Clear();
     panelControl_Modules.Controls.Add(_Module);
     _Module.Dock = DockStyle.Fill;
     return(_Module);
 }
コード例 #28
0
        /// <summary>
        /// Helper for getting incremental state for a torch.nn.Module.
        /// </summary>
        public static Dictionary <string, torch.Tensor> GetIncrementalState(
            BaseModule module,
            Dictionary <string, Dictionary <string, torch.Tensor> > incrementalState,
            string key)
        {
            var fullKey = GetFullIncrementalStateKey(module, key);

            return(incrementalState.ContainsKey(fullKey) ? incrementalState[fullKey] : null);
        }
コード例 #29
0
        private dynamic ResizeImage(dynamic arg)
        {
            var file = Path.Combine(this.RootPath, (string)arg.path);

            if (File.Exists(file) == false)
            {
                return(404);
            }

            if (this.Request.Url.Query == string.Empty)
            {
                return(400);
            }

            var    parameter    = new ImageResizeModule.ImageFiltrationParameters(this.Context, file);
            var    parameterKey = parameter.GetHashCode().ToString();
            var    key          = file + parameterKey;
            string resizeRelativePath;

            if (_FileList.TryGetValue(key, out resizeRelativePath) == true)
            {
                return(this.Response.AsRedirect(resizeRelativePath, Nancy.Responses.RedirectResponse.RedirectType.Permanent));
            }

            resizeRelativePath = "site/imageresize/" + (string)arg.path + "/" + parameterKey + Path.GetExtension(file);

            var rootPath        = this.RootPath;
            var resizeDirectory = Path.Combine(rootPath, "Site", "imageresize", (string)arg.path);

            Directory.CreateDirectory(resizeDirectory);

            var resizeFile = Path.Combine(rootPath, resizeRelativePath);

            lock (BaseModule.GetLockObject(resizeFile))
            {
                if (File.Exists(resizeFile) == true)
                {
                    _FileList[key] = "/" + resizeRelativePath;
                    return(this.Response.AsRedirect("/" + resizeRelativePath, Nancy.Responses.RedirectResponse.RedirectType.Permanent));
                }

                if (Directory.GetFiles(resizeDirectory).Length + 1 > MAX_PER_FILE)
                {
                    return(400);
                }

                var result = ImageResizeModule.ResizeAndFilterImage(file, parameter);

                using (var resized = File.OpenWrite(resizeFile))
                {
                    result.Output.CopyTo(resized);
                }

                _FileList[key] = "/" + resizeRelativePath;
                return(this.Response.AsRedirect("/" + resizeRelativePath, Nancy.Responses.RedirectResponse.RedirectType.Permanent));
            }
        }
コード例 #30
0
ファイル: Authorization.cs プロジェクト: zxbe/Anno.Core
 public override void OnAuthorization(BaseModule context)
 {
     if (context.RequestString("uname") != "yrm")
     {
         context.Authorized = false;
         return;
     }
     context.Authorized = true;
 }
コード例 #31
0
ファイル: BaseModuleHost.cs プロジェクト: bberak/PokerDotNet
 protected virtual void FocusOnModule(Control window, BaseModule module)
 {
     module.Focus(window);
 }
コード例 #32
0
ファイル: Controls.cs プロジェクト: shine8319/DLS
 public NavBarGroupTagObject(string name, Type moduleType) {
     this.name = name;
     this.moduleType = moduleType;
     module = null;
 }
コード例 #33
0
ファイル: frmMain.cs プロジェクト: shine8319/DLS
 internal void OnModuleShown(BaseModule baseModule) {
     rpgPrint.Visible = CurrentPrintableComponent != null;
 }