protected void Page_Load(object sender, EventArgs e) { lang = LanguageService.GetInstance().GetModel(CurrentLanguageId); if (lang != null) { configFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", lang.Code)); type = ConfigHelper.GetVal(configFile, "OnlineType", type); x = ConfigHelper.GetVal(configFile, "OnlineX", x); y = ConfigHelper.GetVal(configFile, "OnlineY", y); style = ConfigHelper.GetVal(configFile, "OnlineStyle", style); color = ConfigHelper.GetVal(configFile, "OnlineStyleColor", color); qq = ConfigHelper.GetVal(configFile, "OnlineIconQQ", qq); msn = ConfigHelper.GetVal(configFile, "OnlineIconMSN", msn); tb = ConfigHelper.GetVal(configFile, "OnlineIconTaobao", tb); ali = ConfigHelper.GetVal(configFile, "OnlineIconAli", ali); skype = ConfigHelper.GetVal(configFile, "OnlineIconSkype", skype); onname = ConfigHelper.GetVal(configFile, "OnlineOnName", onname); info = ConfigHelper.GetVal(configFile, "OnlineOtherInfo", info); } if (!IsPostBack && lang != null) { InitData(); } foreach (ListItem item in rblType.Items) { item.Attributes.Add("onclick", "onlineposition(" + item.Value + ", '');"); } }
/// <summary> /// 指定语言 /// </summary> /// <param name="langId"></param> public WebPage(long langId) { currentLanguage = LanguageService.GetInstance().GetModel(langId); CookieHelper.SetCookie("__Language__", langId.ToString()); CookieHelper.SetCookie("__Lanugage__", "Object", SerializeHelper.Serialize <cmsLanguage>(currentLanguage)); currentConfigFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", currentLanguage.Code)); CookieHelper.SetCookie("__Lanugage__", "ConfigFile", string.Format("~/Manage/Config/{0}.config", currentLanguage.Code)); }
public ProductAdd() : base(PagePurviewType.PPT_NEWS) { lang = LanguageService.GetInstance().GetModel(CurrentLanguageId); if (lang != null) { configFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", lang.Code)); } }
protected override void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtOrder.Text.Trim())) { txtOrder.Text = "0"; } if (action.Equals("add")) { lang = new cmsLanguage(); } else { lang = lgs.Get(id); if (lang != null) { lang.Attach(); } else { lang = new cmsLanguage(); } } lang.Name = txtName.Text; lang.ShortName = txtShortName.Text; lang.Code = txtCode.Text; lang.HomeUrl = string.IsNullOrEmpty(txtUrl.Text) ? "/" : txtUrl.Text; lang.OrderNo = Convert.ToInt32(txtOrder.Text); lang.IsDefault = chkDefault.Checked ? 1 : 0; lang.IsEnabled = chkEnabled.Checked ? 1 : 0; lang.Remark = txtRemark.Text; try { long r = lgs.Save(lang); if (action.Equals("edit")) { r = lang.Id; } hidID.Value = r.ToString(); // 创建模板目录下的语言配置文件 CreateLangConfigFile(lang); // if (action.Equals("add")) { ScriptUtil.ConfirmAndRedirect(@"语言添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "LanguageAdd.aspx?node=" + NodeCode, "LanguageList.aspx?node=" + NodeCode); } else { ScriptUtil.ConfirmAndRedirect(@"语言修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "LanguageAdd.aspx?node=" + NodeCode + "&id=" + id, "LanguageList.aspx?node=" + NodeCode); } } catch (Exception ex) { ScriptUtil.Alert(ex.Message); Logger.Error(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { base.InitializePageControls(null, gv); lang = LanguageService.GetInstance().GetModel(CurrentLanguageId); if (!IsPostBack && lang != null) { BindGrid(); } }
protected void Page_Load(object sender, EventArgs e) { lang = LanguageService.GetInstance().GetModel(CurrentLanguageId); if (lang != null) { configFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", lang.Code)); } if (!IsPostBack && lang != null) { InitData(); } }
protected void Page_Load(object sender, EventArgs e) { id = Request["id"]; action = (string.IsNullOrEmpty(Request["action"])) ? "add" : Request["action"]; lang = LanguageService.GetInstance().GetModel(CurrentLanguageId); if (!IsPostBack && lang != null) { InitData(); } }
/// <summary> /// 如果不同语言模板是同一个,则不能执行此方法 /// </summary> /// <param name="lang"></param> private void CreateLangConfigFile(cmsLanguage lang) { /* * string path = Server.MapPath(lang.HomeUrl); * if (!path.EndsWith("\\")) path += "\\"; * if (!Directory.Exists(path)) Directory.CreateDirectory(path); * * string file = path + "lang.config"; * //if (!File.Exists(file)) * //{ * // using (StreamWriter sw = File.CreateText(file)) { sw.Close(); } * //} * ConfigHelper.SetVal(file, "langName", lang.Name); * ConfigHelper.SetVal(file, "langId", lang.Id.ToString()); */ }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request["id"]) || !long.TryParse(Request["id"], out langId)) { throw new ArgumentException("参数不正确。"); } lang = LanguageService.GetInstance().GetModel(langId); if (lang != null) { configFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", lang.Code)); } if (!IsPostBack) { InitData(); } }
private void InitData() { lang = lgs.Get(id); if (lang != null) { hidID.Value = lang.Id.ToString(); txtName.Text = lang.Name; txtShortName.Text = lang.ShortName; txtCode.Text = lang.Code; txtCode.Enabled = false; // 代码不允许修改 txtUrl.Text = lang.HomeUrl; txtOrder.Text = lang.OrderNo.ToString(); chkDefault.Checked = lang.IsDefault.HasValue ? lang.IsDefault.Value == 1 : false; chkEnabled.Checked = lang.IsEnabled.HasValue ? lang.IsEnabled.Value == 1 : false; txtRemark.Text = lang.Remark; } }
/// <summary> /// /// </summary> public WebPage() { long langId = 0; // 1. 从当前配置文件中读取 //if (currentLanguage == null) //{ // string path = HttpContext.Current.Request.PhysicalPath; // path = path.Substring(0, path.LastIndexOf('\\')); // string langfile = path + "\\lang.config"; // if (File.Exists(langfile)) // { // langId = ConfigHelper.GetVal<long>(langfile, "langId"); // currentLanguage = LanguageService.GetInstance().GetModel(langId); // } //} // 1. 从请求参数中获取 if (!string.IsNullOrEmpty(HttpContext.Current.Request["lng"])) { string code = HttpContext.Current.Request["lng"]; currentLanguage = LanguageService.GetInstance().GetModelWithWhere(cmsLanguage._.Code == code); } // 2. 先从cookie读取 if (currentLanguage == null && !string.IsNullOrEmpty(CookieHelper.GetCookieValue("__Language__"))) { if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue("__Language__", "Object"))) { currentLanguage = SerializeHelper.Desrialize <cmsLanguage>(CookieHelper.GetCookieValue("__Language__", "Object")); } else { langId = long.Parse(CookieHelper.GetCookieValue("__Language__")); currentLanguage = LanguageService.GetInstance().GetModel(langId); } if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue("__Language__", "ConfigFile"))) { currentConfigFile = CookieHelper.GetCookieValue("__Language__", "ConfigFile"); } } // 3. 从语言列表中取默认语言 if (currentLanguage == null) { currentLanguage = Languages.Find(x => x.IsDefault == 1); //CookieHelper.SetCookie("__Lanugage__", "Object", SerializeHelper.Serialize<cmsLanguage>(currentLanguage)); } // 4. 抛出异常 if (currentLanguage == null) { throw new Exception("网站语言未设置或者默认语言未指定,请到系统管理->系统设置->语言设置中进行设置。"); } else { CookieHelper.SetCookie("__Language__", currentLanguage.Id.ToString()); CookieHelper.SetCookie("__Lanugage__", "Object", SerializeHelper.Serialize <cmsLanguage>(currentLanguage)); } if (string.IsNullOrEmpty(currentConfigFile)) { currentConfigFile = Server.MapPath(string.Format("~/Manage/Config/{0}.config", currentLanguage.Code)); CookieHelper.SetCookie("__Lanugage__", "ConfigFile", string.Format("~/Manage/Config/{0}.config", currentLanguage.Code)); } }
private void DoServicerActions(string action) { ServicerService ss = ServicerService.GetInstance(); if (action.Equals("ServicerOrder")) { string id = Request["Id"]; string order = Request["Order"]; int r = ss.ChangeOrder(id, int.Parse(order)); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,排序失败!\"}"; } } else if (action.Equals("ServicerEnable")) { string id = Request["Id"]; int r = ss.Enable(id); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,状态改变失败!\"}"; } } else if (action.Equals("ServicerDelete")) { string id = Request["Id"]; int r = ss.DeleteModel(id); if (r > 0) { json = "{\"result\":1}"; } else { json = "{\"result\":0, \"msg\":\"服务器发生错误,删除失败!\"}"; } } else if (action.Equals("ServicerCode")) { string langid = Request["lang"]; string navurl = Request["navurl"]; string formatOnline_1_2 = @" <div id='onlinebox' class='onlinebox onlinebox_{0} onlinebox_{0}_{1}' style='display: none;'> <div class='onlinebox-showbox' title='点击可显示'><span>在线交流</span></div> <div class='onlinebox-conbox' style='display: none;'> <div class='onlinebox-top' title='点击可隐藏'> <a href='javascript:;' onclick='return onlineclose();' class='onlinebox-close' title='关闭'></a> <span>在线交流</span> </div> <div class='onlinebox-center'> <div class='onlinebox-center-box'> {2} </div> </div> <div class='onlinebox-bottom'> <div class='onlinebox-bottom-box'> <div class='online-tbox'> {3} </div> </div> </div> <div class='onlinebox-bottom-bg'></div> </div> <div class='clear'></div> </div>"; string formatOnline_3_4 = @" <div id='onlinebox' class='onlinebox onlinebox_{0} onlinebox_{0}_{1}' style='display: none;'> <div class='onlinebox-top'> <a href='javascript:;' onclick='return onlineclose();' class='onlinebox-close' title='关闭'></a> <span>在线交流</span> </div> <div class='onlinebox-center'> <div class='onlinebox-center-box'> {2} </div> </div> <div class='onlinebox-bottom'> <div class='onlinebox-bottom-box'> <div class='online-tbox'> {3} </div> </div> </div> <div class='onlinebox-bottom-bg'></div> <div class='clear'></div> </div>"; StringBuilder sbOnline = new StringBuilder(); string formatServicer = @"<dl><dt>{0}</dt><dd>{1}</dd></dl><div class='clear'></div>"; StringBuilder sbServicers = new StringBuilder(); StringBuilder sbSkype = new StringBuilder(); StringBuilder sbAli = new StringBuilder(); string formatQQ = "<span class='qq'><a href='tencent://message/?uin={0}&Site=&Menu=yes' title='{1}'><img border='0' src='http://wpa.qq.com/pa?p=1:{0}:{2}'></a></span>"; string formatMSN = "<span class='msn'><a href='msnim:chat?contact={0}' title='{1}'><img border='0' alt='{1}' src='{2}.gif' /></a></span>"; string formatTb = "<span class='taobao'><a target='_blank' href='http://amos.im.alisoft.com/msg.aw?v=2&uid={0}&site=cntaobao&s=2&charset=utf-8' title='{1}'><img border='0' src='http://amos.im.alisoft.com/online.aw?v=2&uid={0}&site=cntaobao&s={2}&charset=utf-8' alt='{1}' /></a></span>"; string formatAli = "<div class='ali'><a target='_blank' href='http://amos1.sh1.china.alibaba.com/msg.atc?v=1&uid={0}' title='{1}'><img src='http://amos1.sh1.china.alibaba.com/online.atc?v=1&uid={0}&s={2}' alt='{1}' border='0'></a></div>"; string formatSkype = "<div class='skype'><a href='callto://{0}' title='{1}'><img src='{2}.gif' border='0' alt='{1}'/></a></div>"; cmsLanguage lang = LanguageService.GetInstance().GetModel(langid); string configFile = ""; if (lang != null) { configFile = Context.Server.MapPath(string.Format("~/Manage/Config/{0}.config", lang.Code)); } string type = ConfigHelper.GetVal(configFile, "OnlineType"); string x = ConfigHelper.GetVal(configFile, "OnlineX"); string y = ConfigHelper.GetVal(configFile, "OnlineY"); string style = ConfigHelper.GetVal(configFile, "OnlineStyle"); string format = ""; if (style.Equals("1") || style.Equals("2")) { format = formatOnline_1_2; } else { format = formatOnline_3_4; } string color = ConfigHelper.GetVal(configFile, "OnlineStyleColor"); string qq = ConfigHelper.GetVal(configFile, "OnlineIconQQ"); string msn = ConfigHelper.GetVal(configFile, "OnlineIconMSN"); string tb = ConfigHelper.GetVal(configFile, "OnlineIconTaobao"); string ali = ConfigHelper.GetVal(configFile, "OnlineIconAli"); string skype = ConfigHelper.GetVal(configFile, "OnlineIconSkype"); string onname = ConfigHelper.GetVal(configFile, "OnlineOnName"); string info = ConfigHelper.GetVal(configFile, "OnlineOtherInfo"); List <cmsServicer> ls = ss.GetListByLang(long.Parse(langid)); foreach (var item in ls) { string name = (onname == "1") ? item.Name : ""; string servicers = ""; if (!string.IsNullOrEmpty(item.QQ)) { servicers += string.Format(formatQQ, item.QQ, item.Name, qq); } if (!string.IsNullOrEmpty(item.MSN)) { servicers += string.Format(formatMSN, item.MSN, item.Name, Request.ApplicationPath + "manage/images/msn/msn_" + msn); } if (!string.IsNullOrEmpty(item.TaobaoWW)) { servicers += string.Format(formatTb, item.TaobaoWW, item.Name, tb); } sbServicers.AppendLine(string.Format(formatServicer, name, servicers)); if (!string.IsNullOrEmpty(item.SKYPE)) { sbSkype.AppendLine(string.Format(formatSkype, item.SKYPE, item.Name, Request.ApplicationPath + "manage/images/skype/skype_" + skype)); } if (!string.IsNullOrEmpty(item.AliWW)) { sbAli.AppendLine(string.Format(formatAli, item.AliWW, item.Name, ali)); } } sbServicers.AppendLine(sbSkype.ToString()); sbServicers.AppendLine(sbAli.ToString()); sbOnline.AppendLine(string.Format(format, style, color, sbServicers.ToString(), info)); json = sbOnline.ToString();//.Replace("\"", """).Replace("\r","").Replace("\n",""); Response.ContentType = "text/html"; } }