Ejemplo n.º 1
0
        /// <summary>
        /// 模板设置
        /// </summary>
        public void Settings_GET()
        {
            string tpl = Request["tpl"];

            if (String.IsNullOrEmpty(tpl))
            {
                tpl = base.CurrentSite.Tpl;
            }

            var tplSetting = new TemplateSetting(tpl);

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Template_Setting), new
            {
                //模板
                tpl_CFG_OutlineLength        = tplSetting.CFG_OutlineLength.ToString(),
                tpl_CFG_allowAmousComment    = tplSetting.CFG_AllowAmousComment ? " checked=\"checked\"" : String.Empty,
                tpl_CFG_CommentEditorHtml    = tplSetting.CFG_CommentEditorHtml,
                tpl_CFG_ArchiveTagsFormat    = tplSetting.CFG_ArchiveTagsFormat,
                tpl_CFG_FriendLinkFormat     = tplSetting.CFG_FriendLinkFormat,
                tpl_CFG_FriendShowNum        = tplSetting.CFG_FriendShowNum,
                tpl_CFG_NavigatorLinkFormat  = tplSetting.CFG_NavigatorLinkFormat,
                tpl_CFG_NavigatorChildFormat = tplSetting.CFG_NavigatorChildFormat,
                tpl_CFG_SitemapSplit         = tplSetting.CFG_SitemapSplit,
                tpl_CFG_TrafficFormat        = tplSetting.CFG_TrafficFormat
            });
        }
Ejemplo n.º 2
0
        private TemplateSetting createSetting()
        {
            var setting        = new TemplateSetting();
            var font_names     = cmb_font_lastname.Text.Split('-');
            var font_companies = cmb_font_company.Text.Split('-');
            var font_positions = cmb_font_position.Text.Split('-');

            setting.isCanDelete = true;
            setting.isFNvisible = cb_firstname.Checked;
            setting.isLNvisible = cb_lasname.Checked;
            setting.isPAvisible = cb_patronim.Checked;
            setting.isCOvisible = cb_company.Checked;
            setting.isPOvisible = cb_position.Checked;

            setting.isFNtoupper = chb_first_name_to_upper.Checked;
            setting.isLNtoupper = chb_last_name_to_upper.Checked;
            setting.isPAtoupper = chb_pathronim_to_upper.Checked;
            setting.isCOtoupper = chb_company_to_upper.Checked;
            setting.isPOtoupper = chb_position_to_upper.Checked;

            setting.FontNameNA  = font_names[0];
            setting.FontNameCO  = font_companies[0];
            setting.FontNamePO  = font_positions[0];
            setting.FontSizeNA  = float.Parse(font_names[1]);
            setting.FontSizeCO  = float.Parse(font_companies[1]);
            setting.FontSizePO  = float.Parse(font_positions[1]);
            setting.FontStyleNA = int.Parse(font_names[2]);
            setting.FontStyleCO = int.Parse(font_companies[2]);
            setting.FontStylePO = int.Parse(font_positions[2]);
            setting.SettingName = cmb_setting_name.Text;

            return(setting);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取当前模板的主题配色
        /// </summary>
        /// <returns></returns>
        private ThemeSetting GetCurrentThemeSetting()
        {
            ThemeSetting currentSetting = new ThemeSetting();
            //内页面跟随首页配置的主题配色方案变化
            string          currentTempdate = System.IO.File.ReadAllText(this.Server.MapPath(_templatesettings));//读取当前应用的模板
            TemplateSetting curTemplateObj  = ParseFormJson <TemplateSetting>(currentTempdate);

            if (curTemplateObj != null)
            {
                if (System.IO.File.Exists(this.Server.MapPath(_themesettings)))
                {
                    string currentTheme = System.IO.File.ReadAllText(this.Server.MapPath(_themesettings));//读取模板应用的主题配色列表
                    List <ThemeSetting> curThemeObjs = ParseFormJson <List <ThemeSetting> >(currentTheme);
                    if (curThemeObjs != null)
                    {
                        var info = curThemeObjs.FirstOrDefault(a => a.templateId == curTemplateObj.Id);//取当前启用的模板对应的主题配色方案
                        if (null != info)
                        {
                            currentSetting = info;
                            //ViewBag.WritingColor = info.writingColor;
                            //ViewBag.SecondaryColor = info.secondaryColor;
                            //ViewBag.MainColor = info.mainColor;
                            //ViewBag.FrameColor = info.frameColor;
                            //ViewBag.ClassifiedsColor = info.classifiedsColor;
                            //ViewBag.TypeId = (CommonModel.ThemeType)info.typeId;
                        }
                    }
                }
            }
            return(currentSetting);
        }
Ejemplo n.º 4
0
        public void TestCreateAnalysisMapping()
        {
            var template = new TemplateSetting("index_1*");
            var type     = new TypeSetting("type88");

            type.AddStringField("name", null, Store.no, IndexType.analyzed, TermVector.no, 1, null, true, true, "keyword", "keyword", "keyword");
            template.AddTypeSetting(type);
            var result = client.CreateTemplate("template_123", template).Success;

            Assert.AreEqual(true, result);
            result = client.CreateIndex("index_1123").Success;
            Assert.AreEqual(true, result);
            var a = client.Index("index_1123", "type88", "key1", "{name:\"张三\"}");

            Assert.AreEqual(true, a.Success);
            a = client.Index("index_1123", "type88", "key2", "{name:\"张三丰\"}");
            Assert.AreEqual(true, a.Success);
            a = client.Index("index_1123", "type88", "key3", "{name:\"大张旗鼓\"}");
            Assert.AreEqual(true, a.Success);
            a = client.Index("index_1123", "type88", "key4", "{name:\"子张怡\"}");
            Assert.AreEqual(true, a.Success);
            Thread.Sleep(2000);
            var count = client.Count("index_1123", "type88", "name:张");

            Assert.AreEqual(0, count);
            count = client.Count("index_1123", "type88", "name:张三");
            Assert.AreEqual(1, count);
            count = client.Count("index_1123", "type88", "name:张三丰");
            Assert.AreEqual(1, count);
            count = client.Count("index_1123", "type88", "name:张三*");
            Assert.AreEqual(2, count);
            count = client.Count("index_1123", "type88", "name:张三*");
            Assert.AreEqual(2, count);
            count = client.Count("index_1123", "type88", "name:张三?");
            Assert.AreEqual(1, count);
            count = client.Count("index_1123", "type88", "name:*张*");
            Assert.AreEqual(4, count);
            count = client.Count("index_1123", "type88", "name:?张*");
            Assert.AreEqual(2, count);

            //test for _all
            //only works after setting default_analysis to keyword(or set against filed: _all )
//			count = client.Count("index_1123", "type88", "_all:张");
//			Assert.AreEqual(0, count);
//			count = client.Count("index_1123", "type88", "_all:张三");
//			Assert.AreEqual(1, count);
//			count = client.Count("index_1123", "type88", "_all:张三丰");
//			Assert.AreEqual(1, count);
//			count = client.Count("index_1123", "type88", "_all:张三*");
//			Assert.AreEqual(2, count);
//			count = client.Count("index_1123", "type88", "_all:张三*");
//			Assert.AreEqual(2, count);
//			count = client.Count("index_1123", "type88", "_all:张三?");
//			Assert.AreEqual(1, count);
//			count = client.Count("index_1123", "type88", "_all:*张*");
//			Assert.AreEqual(4, count);
//			count = client.Count("index_1123", "type88", "_all:?张*");
//			Assert.AreEqual(2, count);
        }
Ejemplo n.º 5
0
        public void TestTemplate()
        {
            var tempkey = "test_template_key1";

            client.DeleteTemplate(tempkey);

            var template = new TemplateSetting(tempkey);

            template.Template     = "business_*";
            template.IndexSetting = new TemplateIndexSetting(3, 2);

            var type1 = new TypeSetting("mytype")
            {
            };

            type1.AddNumField("identity", NumType.Float);
            type1.AddDateField("datetime");

            var type2 = new TypeSetting("mypersontype");

            type2.AddStringField("personid");

            type2.SourceSetting         = new SourceSetting();
            type2.SourceSetting.Enabled = false;

            template.AddTypeSetting(type1);
            template.AddTypeSetting(type2);

            var jsonstr = JsonSerializer.Get(template);

            Console.WriteLine(jsonstr);

            var result = client.CreateTemplate(tempkey, template);

            Console.WriteLine(result.JsonString);
            Assert.AreEqual(true, result.Success);

            result = client.CreateIndex("business_111");
            Assert.AreEqual(true, result.Success);
            result = client.CreateIndex("business_132");
            Assert.AreEqual(true, result.Success);
            result = client.CreateIndex("business_31003");
            Assert.AreEqual(true, result.Success);

            client.Refresh();
            var temp = client.GetTemplate(tempkey);

            TemplateSetting result1;

            Assert.AreEqual(true, temp.TryGetValue(tempkey, out result1));
            Assert.AreEqual(template.Order, result1.Order);
            Assert.AreEqual(template.Template, result1.Template);

            client.DeleteIndex("business_111");
            client.DeleteIndex("business_132");
            client.DeleteIndex("business_31003");
        }
Ejemplo n.º 6
0
        public OperateResult CreateTemplate(string templateName, TemplateSetting template)
        {
            Contract.Assert(template != null);

            string url = "/_template/{0}".Fill(templateName);

            string       json   = JsonSerializer.Get(template);
            RestResponse result = _provider.Post(url, json);

            return(GetOperationResult(result));
        }
Ejemplo n.º 7
0
        public virtual string FormatTemplatePath(string tplPath)
        {
            TemplateSetting ts = Cms.TemplateManager.Get(this._site.Tpl);

            if (ts.CfgEnabledMobiPage && Cms.Context.DeviceType == DeviceType.Mobile)
            {
                String path = String.Format("/{0}/_mobile_/{1}", _site.Tpl, tplPath);
                if (Cms.Template.Exists(path))
                {
                    return(path);
                }
            }
            return(String.Format("/{0}/{1}", _site.Tpl, tplPath));
        }
Ejemplo n.º 8
0
        public void Settings_POST()
        {
            string tpl = Request["tpl"];

            if (String.IsNullOrEmpty(tpl))
            {
                tpl = base.CurrentSite.Tpl;
            }
            else
            {
                if (!UserState.Administrator.Current.IsMaster)
                {
                    base.RenderError("无权执行此操作!");
                    return;
                }
            }

            TemplateSetting tplSetting = Cms.TemplateManager.Get(tpl);
            var             req        = base.Request;
            int             outlineLength;

            int.TryParse(req["tpl_CFG_OutlineLength"], out outlineLength);
            tplSetting.CfgOutlineLength      = outlineLength;
            tplSetting.CFG_AllowAmousComment = req["tpl_CFG_AllowAmousComment"] == "on";
            tplSetting.CFG_CommentEditorHtml = req["tpl_CFG_CommentEditorHtml"];
            tplSetting.CFG_ArchiveTagsFormat = req["tpl_CFG_ArchiveTagsFormat"];
            tplSetting.CFG_FriendLinkFormat  = req["tpl_CFG_FriendLinkFormat"];
            int friendlinkNum;

            int.TryParse(req["tpl_CFG_FriendShowNum"], out friendlinkNum);
            tplSetting.CFG_FriendShowNum        = friendlinkNum;
            tplSetting.CFG_NavigatorLinkFormat  = req["tpl_CFG_NavigatorLinkFormat"];
            tplSetting.CFG_NavigatorChildFormat = req["tpl_CFG_NavigatorChildFormat"];
            tplSetting.CFG_SitemapSplit         = req["tpl_CFG_SitemapSplit"];
            tplSetting.CFG_TrafficFormat        = req["tpl_CFG_TrafficFormat"];
            tplSetting.CfgEnabledMobiPage       = req["tpl_CFG_Enabled_Mobi"] == "1";
            tplSetting.CfgShowError             = req["tpl_CFG_Show_Error"] == "1";
            tplSetting.Save();

            base.RenderSuccess("修改成功!");
        }
Ejemplo n.º 9
0
        public TemplateModel SaveTemplate(TemplateModel model)
        {
            var old = GetTemplate(model.TemplateID);

            if (string.IsNullOrEmpty(model.TemplateID))
            {
                model.TemplateID = Guid.NewGuid().ToString().ToLower();
            }

            var dir = Path.Combine(TemplatesDir, old != null ? old.TemplateID : model.TemplateID);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var settings = new TemplateSetting
            {
                ID              = old != null ? old.TemplateID : model.TemplateID,
                Code            = model.TemplateCode,
                Name            = model.TemplateName,
                CategoryID      = model.CategoryID,
                CreationTimeUtc = old != null ? old.CreationTime : DateTime.UtcNow,
                LastUpdateTime  = old != null ? DateTime.UtcNow : new Nullable <DateTime>()
            };

            var settingsPath = Path.Combine(dir, settings_json);

            File.WriteAllText(settingsPath, JsonConvert.SerializeObject(settings, Newtonsoft.Json.Formatting.Indented));

            if (model.XtraReport != null)
            {
                model.XtraReport.Name        = model.TemplateID;
                model.XtraReport.DisplayName = model.TemplateName;

                var reportPath = Path.Combine(dir, xtrareport_xml);
                File.WriteAllBytes(reportPath, model.XtraReport.GetBuffer());
            }

            return(model);
        }
Ejemplo n.º 10
0
        public void Settings_POST()
        {
            string tpl = Request["tpl"];

            if (String.IsNullOrEmpty(tpl))
            {
                tpl = base.CurrentSite.Tpl;
            }
            else
            {
                if (UserState.Administrator.Current.SiteId > 0)
                {
                    base.RenderError("无权执行此操作!");
                    return;
                }
            }

            TemplateSetting tplSetting = new TemplateSetting(tpl);
            var             req        = base.Request;
            int             outlineLength;

            int.TryParse(req["tpl_cfg_outlinelength"], out outlineLength);
            tplSetting.CFG_OutlineLength     = outlineLength;
            tplSetting.CFG_AllowAmousComment = req["tpl_cfg_allowamouscomment"] == "on";
            tplSetting.CFG_CommentEditorHtml = req["tpl_cfg_commenteditorhtml"];
            tplSetting.CFG_ArchiveTagsFormat = req["tpl_cfg_archivetagsformat"];
            tplSetting.CFG_FriendLinkFormat  = req["tpl_cfg_friendlinkformat"];
            int friendlinkNum;

            int.TryParse(req["tpl_cfg_friendshownum"], out friendlinkNum);
            tplSetting.CFG_FriendShowNum        = friendlinkNum;
            tplSetting.CFG_NavigatorLinkFormat  = req["tpl_cfg_navigatorlinkformat"];
            tplSetting.CFG_NavigatorChildFormat = req["tpl_cfg_navigatorchildformat"];
            tplSetting.CFG_SitemapSplit         = req["tpl_cfg_sitemapsplit"];
            tplSetting.CFG_TrafficFormat        = req["tpl_cfg_trafficformat"];
            tplSetting.Save();

            base.RenderSuccess("修改成功!");
        }
Ejemplo n.º 11
0
        public SettingStorage()
        {
            context = new ExhibitionSettingContext();
            if (context.CurrentSettings.Select(s => s).Count() == 0)
            {
                CurrentSetting ncs = new CurrentSetting("default");
                context.CurrentSettings.Add(ncs);
                context.SaveChanges();
            }

            if (context.TemplateSettings.Select(t => t).Count() == 0)
            {
                TemplateSetting defaultSetting = new TemplateSetting();
                defaultSetting.isCanDelete = false;
                defaultSetting.isFNvisible = true;
                defaultSetting.isLNvisible = true;
                defaultSetting.isPAvisible = true;
                defaultSetting.isCOvisible = true;
                defaultSetting.isPOvisible = true;

                defaultSetting.FontNameNA = "Arial";
                defaultSetting.FontNameCO = "Arial";
                defaultSetting.FontNamePO = "Arial";

                defaultSetting.FontSizeNA = 9.75f;
                defaultSetting.FontSizeCO = 8.25f;
                defaultSetting.FontSizePO = 8.25f;

                defaultSetting.FontStyleNA = 0;
                defaultSetting.FontStyleCO = 0;
                defaultSetting.FontStylePO = 0;
                defaultSetting.SettingName = "default";

                context.TemplateSettings.Add(defaultSetting);
                context.SaveChanges();
            }
            cs  = context.CurrentSettings.Select(c => c).FirstOrDefault();
            lts = context.TemplateSettings.Select(t => t).ToList();
        }
Ejemplo n.º 12
0
        public void TestCreateUser()
        {
            var template_key = "test_user_template";

            client.DeleteTemplate(template_key);

            var template = new TemplateSetting(template_key);

            template.Template     = "test_user*";
            template.IndexSetting = new TemplateIndexSetting(1, 1);
            var type = new TypeSetting("Staff");

            type.AddStringField("Name");
            type.AddStringField("Email");
            type.AddStringField("EnglishName");

            type.AddNumField("UserID", NumType.Integer);
            template.AddTypeSetting(type);

            var jsonstr = JsonSerializer.Get(template);

            Console.WriteLine(jsonstr);

            var result = client.CreateTemplate(template_key, template);

            Console.WriteLine(result.JsonString);
            Assert.AreEqual(true, result.Success);

            var temp2 = client.GetTemplate(template_key);

            Assert.AreEqual("test_user*", temp2[template_key].Template);
            Assert.True(temp2[template_key].Mappings.ContainsKey("Staff"));

            Assert.AreEqual(1, temp2[template_key].IndexSetting.NumberOfReplicas);
            Assert.AreEqual(1, temp2[template_key].IndexSetting.NumberOfShards);

            result = client.DeleteTemplate(template_key);
            Assert.AreEqual(true, result.Success);
        }
Ejemplo n.º 13
0
        public JsonResult GetThemeSettingJson()
        {
            string          currentTempdate = System.IO.File.ReadAllText(IOHelper.GetMapPath(_templatesettings));//读取当前应用的模板
            TemplateSetting curTemplateObj  = ParseFormJson <TemplateSetting>(currentTempdate);

            if (curTemplateObj != null)
            {
                if (System.IO.File.Exists(IOHelper.GetMapPath(_themesettings)))
                {
                    string currentTheme = System.IO.File.ReadAllText(IOHelper.GetMapPath(_themesettings));//读取当前模板应用的主题配色
                    List <ThemeSetting> curThemeObjs = ParseFormJson <List <ThemeSetting> >(currentTheme);
                    if (curThemeObjs != null && curThemeObjs.Count > 0)
                    {
                        var info = curThemeObjs.FirstOrDefault(a => a.templateId == curTemplateObj.Id);
                        if (null != info)
                        {
                            return(Json(info, true));
                        }
                    }
                }
            }
            return(Json(null, true));
        }
Ejemplo n.º 14
0
        public TemplateSetting SetSetting(string templateName, string key, string value)
        {
            var setting = db.TemplateSettings.FirstOrDefault(s => s.TemplateName == templateName && s.Key == key);

            if (setting != null)
            {
                setting.Value = value;
            }
            else
            {
                setting = new TemplateSetting {
                    TemplateName = templateName, Key = key, Value = value
                };
                db.TemplateSettings.Add(setting);
            }

            db.SaveChanges();

            // Update local cache
            _settingsCache.AddOrUpdate(templateName + key, value, (oldKey, oldvalue) => value);

            return(setting);
        }
Ejemplo n.º 15
0
        public ActionResult Verify(LoginModel model, string id)
        {
            var browser = Request.Browser.Type;

            if (browser.Contains("InternetExplorer"))
            {
                return(RedirectToAction("Unsupported_browser", "Account"));
            }
            Session.Clear();
            try
            {
                if (!string.IsNullOrEmpty(model.name) && !string.IsNullOrEmpty(model.templateid))
                {
                    if (System.IO.File.Exists(Server.MapPath("~") + @"\Templates\TemplateSetting.json"))
                    {
                        string privateTemplatesJson = System.IO.File.ReadAllText(Server.MapPath("~") + @"\Templates\TemplateSetting.json");
                        privateTemplates = Newtonsoft.Json.JsonConvert.DeserializeObject <TemplateSetting>(privateTemplatesJson);
                        if (privateTemplates != null)
                        {
                            bool flag = false;
                            foreach (var template in privateTemplates.privateTemplateKeys)
                            {
                                if (template.key != "" && template.value != "")
                                {
                                    if (template.key == model.templateid && template.value.ToLower() == model.name.ToLower())
                                    {
                                        flag = true;
                                        Session["templateName"] = model.name;
                                        Session["templateId"]   = model.templateid;
                                    }
                                }
                            }
                            if (flag == false)
                            {
                                Session["templateName"] = null;
                                Session["templateId"]   = null;
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(model.Event))
                {
                    string eventsTemplate = Server.MapPath("~") + @"\Templates\Events.json";
                    if (System.IO.File.Exists(eventsTemplate))
                    {
                        string eventContent = System.IO.File.ReadAllText(eventsTemplate);
                        var    jItems       = JObject.Parse(eventContent);
                        if (jItems[model.Event] != null)
                        {
                            model.Event = jItems[model.Event].ToString();
                        }
                        else
                        {
                            model.Event = string.Empty;
                        }
                    }
                }
            }
            catch { }
            return(View(model));
        }
Ejemplo n.º 16
0
 public void addSettingToStorage(TemplateSetting ts)
 {
     lts.Add(ts);
     context.TemplateSettings.Add(ts);
     context.SaveChanges();
 }
Ejemplo n.º 17
0
 public ConnectionFactory(IOptionsSnapshot <TemplateSetting> setting)
 {
     _setting = setting.Value;
 }
Ejemplo n.º 18
0
 public void delSettingFromStorage(TemplateSetting ts)
 {
     lts.Remove(ts);
     context.TemplateSettings.Remove(ts);
     context.SaveChanges();
 }
Ejemplo n.º 19
0
        private void btSave_Click(object sender, EventArgs e)
        {
            string spechlder = cmbSpecHldrs.GetSelectedValue();

            if (string.IsNullOrEmpty(spechlder))
            {
                MessageBox.Show(@"Please choise special handling indicator.", @"Template Setting", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }
            string location   = null;
            string entityName = _worker.EntityName;

            try
            {
                location = _worker.Save(spechlder);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error: {0}\r\n{1} Template could not be saved.", ex.Message, entityName), @"Template Setting",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Configuration.Configuration config = null;
            try
            {
                config = ConfigReader.Current.Read() ?? new Configuration.Configuration();
            }
            catch
            {
                config = new Configuration.Configuration();
            }

            bool isUpdated = false;

            Template template = new Template()
            {
                EntityName = _worker.EntityName, Location = location
            };
            TemplateSetting setting = new TemplateSetting()
            {
                SpecialHandlingIndicator = spechlder,
                Templates = new Template[] { template }
            };

            while (!isUpdated)
            {
                if (config.TemplateSettings != null)
                {
                    foreach (TemplateSetting ts in config.TemplateSettings)
                    {
                        if (ts.SpecialHandlingIndicator == spechlder)
                        {
                            foreach (Template t in ts.Templates)
                            {
                                if (t.EntityName == entityName)
                                {
                                    t.Location = location;
                                    isUpdated  = true;
                                    break;
                                }
                            }

                            if (!isUpdated)
                            {
                                ts.Templates = ts.Templates.Concat(new Template[] { template }).ToArray();
                                isUpdated    = true;
                                break;
                            }
                        }
                    }

                    if (!isUpdated)
                    {
                        config.TemplateSettings =
                            config.TemplateSettings.Concat(new TemplateSetting[] { setting }).ToArray();
                        isUpdated = true;
                    }
                }
                else
                {
                    config.TemplateSettings = new TemplateSetting[] { setting };
                    isUpdated = true;
                }
            }

            try
            {
                if (ConfigWriter.Current.Save(config))
                {
                    MessageBox.Show(string.Format("{0} Template is saved.", entityName), @"Template Setting",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (ConfigException ex)
            {
                MessageBox.Show(string.Format("Error: {0}\\r\\n{1} Template could not be saved.", ex.Message, entityName), @"Template Setting",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }