public ActionResult Edit(int id = -1) { SpecialInfo specialInfo = Special.AdminGetModelById(id); if (specialInfo == null) { return(PromptView("专题信息不存在")); } SpecialModel model = new SpecialModel { SpecialID = specialInfo.SpecialID, Name = specialInfo.Name, Title = specialInfo.Title, ImgUrl = specialInfo.ImgUrl, LogoUrl = specialInfo.LogoUrl, IsOut = specialInfo.IsOut, OutUrl = specialInfo.OutUrl, Body = specialInfo.Body, DisplayOrder = specialInfo.DisplayOrder }; Load(); return(View(model)); }
protected void EBtnModify_Click(object sender, EventArgs e) { if (this.Page.IsValid) { SpecialInfo specialInfo = this.GetSpecialInfo(); specialInfo.SpecialId = this.specialId; specialInfo.OrderId = DataConverter.CLng(this.HdnOrderId.Value); specialInfo.NeedCreateHtml = true; string specialName = specialInfo.SpecialName; if ((specialName != this.HdnSpecialName.Value) && Special.ExistsSpecialName(specialName)) { AdminPage.WriteErrMsg("<li>此专题名已经存在,请输入其它的专题名!</li>", "Special.aspx"); } if (Special.UpdateSpecial(specialInfo)) { this.InputPermissions(specialInfo.SpecialId); this.InputRolePermission(specialInfo.SpecialId); IncludeFile.CreateIncludeFileByAssociateType(AssociateType.Special); AdminPage.WriteSuccessMsg("<li>专题信息保存成功!</li>", "SpecialManage.aspx"); } else { AdminPage.WriteErrMsg("<li>专题信息保存失败!</li>", "SpecialManage.aspx"); } } }
private bool BatchAddSpecial(SpecialInfo specialInfo, StringBuilder information) { bool flag = false; if (IsDir(specialInfo.SpecialDir)) { information.Append("<li>" + specialInfo.SpecialName + "目录名只能是字母、数字、下划线组成,首字符不能是数字!</li>"); return(flag); } if (Special.ExistsSpecialName(specialInfo.SpecialName)) { information.Append("<li>" + specialInfo.SpecialName + "专题名已经存在,请输入其它的专题名!</li>"); return(flag); } if (Special.ExistsSpecialDir(specialInfo.SpecialDir)) { information.Append("<li>" + specialInfo.SpecialDir + "专题目录已经存在,请输入其它的目录名!</li>"); return(flag); } if (Special.AddSpecial(specialInfo)) { this.InputPermissions(specialInfo.SpecialId); this.InputRolePermission(specialInfo.SpecialId); IncludeFile.CreateIncludeFileByAssociateType(AssociateType.Special); return(true); } information.Append("<li>" + specialInfo.SpecialName + "专题信息保存失败!</li>"); return(flag); }
public static int GetSpecialByIdCopySpecial(int specialId) { if (specialId > 0) { SpecialInfo specialInfoById = GetSpecialInfoById(specialId); specialInfoById.SpecialName = StringHelper.CopyString(specialInfoById.SpecialName); specialInfoById.SpecialIdentifier = StringHelper.CopyStringNum(specialInfoById.SpecialIdentifier); specialInfoById.SpecialDir = StringHelper.CopyStringNum(specialInfoById.SpecialDir); while (ExistsSpecialName(specialInfoById.SpecialName)) { specialInfoById.SpecialName = StringHelper.CopyString(specialInfoById.SpecialName); } while (ExistsSpecialDir(specialInfoById.SpecialDir)) { specialInfoById.SpecialDir = StringHelper.CopyStringNum(specialInfoById.SpecialDir); specialInfoById.SpecialIdentifier = StringHelper.CopyStringNum(specialInfoById.SpecialIdentifier); } if (!AddSpecial(specialInfoById)) { return(0); } int maxSpecialId = dal.GetMaxSpecialId(); if (maxSpecialId > 0) { return(maxSpecialId); } } return(0); }
public bool SpecialBatchSet(SpecialInfo specialInfo, string specialIds, Dictionary <string, bool> checkItem) { StringBuilder builder = new StringBuilder(); Parameters cmdParams = new Parameters(); builder.Append("UPDATE PE_Specials SET "); if (checkItem["OpenType"]) { builder.Append("OpenType = @OpenType,"); cmdParams.AddInParameter("@OpenType", DbType.Int32, specialInfo.OpenType); } if (checkItem["IsElite"]) { builder.Append("IsElite = @IsElite,"); cmdParams.AddInParameter("@IsElite", DbType.Boolean, specialInfo.IsElite); } if (checkItem["SpecialTemplatePath"]) { builder.Append("SpecialTemplatePath = @SpecialTemplatePath,"); cmdParams.AddInParameter("@SpecialTemplatePath", DbType.String, specialInfo.SpecialTemplatePath); } builder.Remove(builder.Length - 1, 1); builder.Append(" WHERE SpecialID IN ( "); builder.Append(specialIds); builder.Append(" )"); return(DBHelper.ExecuteSql(builder.ToString(), cmdParams)); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); var specialId = AuthRequest.GetQueryInt("specialId"); if (specialId > 0) { _specialInfo = SpecialManager.GetSpecialInfo(SiteId, specialId); } if (IsPostBack) { return; } VerifySitePermissions(ConfigManager.WebSitePermissions.Template); if (_specialInfo != null) { TbTitle.Text = _specialInfo.Title; TbUrl.Text = _specialInfo.Url; PhUpload.Visible = false; } else { TbUrl.Text = $"@/special/{DateTime.Now:yyyy/MM/dd}/"; } }
public IHttpActionResult GetConfig() { try { var request = new AuthenticatedRequest(); var siteId = request.GetQueryInt("siteId"); var specialId = request.GetQueryInt("specialId"); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSitePermissions(siteId, ConfigManager.SitePermissions.Specials)) { return(Unauthorized()); } SpecialInfo specialInfo = null; if (specialId > 0) { specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId); } return(Ok(new { Value = specialInfo, Guid = StringUtils.GetShortGuid(false), })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public void Insert(SpecialInfo specialInfo) { var sqlString = $@"INSERT INTO {TableName} ({nameof(SpecialInfo.SiteId)}, {nameof(SpecialInfo.Title)}, {nameof(SpecialInfo.Url)}, {nameof(SpecialInfo.AddDate)}) VALUES (@{nameof(SpecialInfo.SiteId)}, @{nameof(SpecialInfo.Title)}, @{nameof(SpecialInfo.Url)}, @{nameof(SpecialInfo.AddDate)})"; IDataParameter[] parameters = { GetParameter(nameof(specialInfo.SiteId), DataType.Integer, specialInfo.SiteId), GetParameter(nameof(specialInfo.Title), DataType.VarChar, 200,specialInfo.Title), GetParameter(nameof(specialInfo.Url), DataType.VarChar, 200,specialInfo.Url), GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate) }; ExecuteNonQuery(sqlString, parameters); SpecialManager.RemoveCache(specialInfo.SiteId); }
public void RaiseCallbackEvent(string eventArgument) { SpecialInfo specialInfoById = Special.GetSpecialInfoById(DataConverter.CLng(eventArgument)); SpecialCategoryInfo specialCategoryInfoById = Special.GetSpecialCategoryInfoById(specialInfoById.SpecialCategoryId); this.result = specialCategoryInfoById.SpecialCategoryName + ">>" + specialInfoById.SpecialName; }
protected void EgvSpecial_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int specialCategoryId = BasePage.RequestInt32("SpecialCategoryID"); SpecialInfo dataItem = e.Row.DataItem as SpecialInfo; if (dataItem != null) { HyperLink link = e.Row.FindControl("HypTitle") as HyperLink; if (link != null) { link.Text = StringHelper.SubString(dataItem.SpecialName, 20, "..."); link.NavigateUrl = "Special.aspx?Action=Modify&SpecialID=" + dataItem.SpecialId; } if (specialCategoryId == 0) { specialCategoryId = dataItem.SpecialCategoryId; SpecialCategoryInfo specialCategoryInfoById = Special.GetSpecialCategoryInfoById(specialCategoryId); ExtendedHyperLink link2 = e.Row.FindControl("LblSpecialCategoryLink") as ExtendedHyperLink; link2.BeginTag = "<strong>["; link2.Text = specialCategoryInfoById.SpecialCategoryName; link2.EndTag = "]</strong>"; link2.NavigateUrl = "SpecialManage.aspx?SpecialCategoryID=" + specialCategoryId.ToString(); } } } }
public ActionResult Edit(SpecialModel model, int id = -1) { SpecialInfo specialInfo = Special.AdminGetModelById(id); if (specialInfo == null) { return(PromptView("专题不存在")); } if (ModelState.IsValid) { specialInfo.Name = model.Name; specialInfo.Title = model.Title; specialInfo.ImgUrl = model.ImgUrl; specialInfo.LogoUrl = model.LogoUrl; specialInfo.IsOut = model.IsOut; specialInfo.OutUrl = model.OutUrl; specialInfo.Body = model.Body; specialInfo.DisplayOrder = model.DisplayOrder; Special.Update(specialInfo); return(PromptView("专题编辑成功")); } Load(); return(View(model)); }
public void InitFrom(Stream templateStream) { if (templateStream == null) { throw new ArgumentNullException("templateStream"); } this.file = null; this.name = "Unknown"; this.specialTag = SpecialInfo.None; using (ZipFile templateZip = ZipFile.Read(templateStream)) { ZipEntry entryInfo = templateZip.FirstOrDefault(z => !z.IsDirectory && z.FileName == "TemplateInfo.xml"); ZipEntry entryIcon = templateZip.FirstOrDefault(z => !z.IsDirectory && z.FileName == "TemplateIcon.png"); if (entryIcon != null) { using (MemoryStream str = new MemoryStream()) { entryIcon.Extract(str); str.Seek(0, SeekOrigin.Begin); this.icon = new Bitmap(str); } } if (entryInfo != null) { string xmlSource = null; using (MemoryStream str = new MemoryStream()) { entryInfo.Extract(str); str.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(str)) { xmlSource = reader.ReadToEnd(); } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlSource); XmlElement elemName = xmlDoc.DocumentElement["name"]; if (elemName != null) { this.name = elemName.InnerText; } XmlElement elemDesc = xmlDoc.DocumentElement["description"]; if (elemDesc != null) { this.desc = elemDesc.InnerText; } } } return; }
public void InitFrom(Stream templateStream) { if (templateStream == null) { throw new ArgumentNullException("templateStream"); } this.file = null; this.name = "Unknown"; this.specialTag = SpecialInfo.None; using (ZipArchive templateZip = new ZipArchive(templateStream)) { ZipArchiveEntry entryInfo = templateZip.Entries.FirstOrDefault(z => z.Name == "TemplateInfo.xml"); ZipArchiveEntry entryIcon = templateZip.Entries.FirstOrDefault(z => z.Name == "TemplateIcon.png"); if (entryIcon != null) { using (MemoryStream str = new MemoryStream()) { entryIcon.Extract(str); str.Seek(0, SeekOrigin.Begin); this.icon = new Bitmap(str); } } if (entryInfo != null) { string xmlSource = null; using (MemoryStream str = new MemoryStream()) { entryInfo.Extract(str); str.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(str)) { xmlSource = reader.ReadToEnd(); } } XDocument xmlDoc = XDocument.Parse(xmlSource); XElement elemName = xmlDoc.Element("name"); if (elemName != null) { this.name = elemName.Value; } XElement elemDesc = xmlDoc.Element("description"); if (elemDesc != null) { this.desc = elemDesc.Value; } } } return; }
public void CreateSpecialsHtml(SpecialInfo specialInfo) { TemplateInfo templateInfo = new TemplateInfo(); NameValueCollection values = new NameValueCollection(); values.Add("id", specialInfo.SpecialId.ToString()); values.Add("page", "1"); templateInfo.QueryList = values; templateInfo.CurrentPage = 1; templateInfo.RootPath = this.PhysicalApplicationPath; templateInfo.SiteUrl = this.SiteUrl; templateInfo.IsDynamicPage = false; templateInfo.PageType = 1; templateInfo.PageName = SiteConfig.SiteInfo.VirtualPath + SiteConfig.SiteOption.CreateHtmlPath + specialInfo.ListHtmlPagePath("{$pageid/}"); templateInfo.TemplateContent = Template.GetTemplateContent(specialInfo.SpecialTemplatePath, this.PhysicalApplicationPath); try { TemplateTransform.GetHtml(templateInfo); HtmlAbstract.AddHeardRunatServer(templateInfo, templateInfo.PageName); string str = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + specialInfo.ListHtmlPagePath(""); FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str, templateInfo.TemplateContent); string str2 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str).Replace("//", "/"); this.CreateMessage = string.Concat(new object[] { "<li>成功生成第", this.CreateCompleted + 1, "个专题的专题首页,专题名:<a target=_blank href=", str2, ">", specialInfo.SpecialName, "</a></li>", this.CreateMessage }); } catch { this.CreateMessage = string.Concat(new object[] { "<li>第<font color='red'><b>", this.CreateCompleted + 1, "</b>专题的专题列表页生成失败</font> 专题名:", specialInfo.SpecialName, " 标签解析出现异常,跳过生成</li>", this.CreateMessage }); } int pageNum = templateInfo.PageNum; if (pageNum > 1) { for (int i = 1; i <= pageNum; i++) { templateInfo.TemplateContent = Template.GetTemplateContent(specialInfo.SpecialTemplatePath, this.PhysicalApplicationPath); values = new NameValueCollection(); values.Add("id", specialInfo.SpecialId.ToString()); values.Add("page", i.ToString()); templateInfo.QueryList = values; templateInfo.CurrentPage = i; templateInfo.SiteUrl = this.SiteUrl; templateInfo.PageName = SiteConfig.SiteInfo.VirtualPath + SiteConfig.SiteOption.CreateHtmlPath + specialInfo.ListHtmlPagePath("{$pageid/}"); try { TemplateTransform.GetHtml(templateInfo); HtmlAbstract.AddHeardRunatServer(templateInfo, templateInfo.PageName); string str3 = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + specialInfo.ListHtmlPagePath(i.ToString()); FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + str3, templateInfo.TemplateContent); string str4 = (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteInfo.VirtualPath) + str3).Replace("//", "/"); this.CreateMessage = string.Concat(new object[] { "<li>成功生成第", this.CreateCompleted + 1, "个专题的专题列表页的第", i, "个分页,专题名:<a target=_blank href=", str4, ">", specialInfo.SpecialName, "</a></li>", this.CreateMessage }); } catch { this.CreateMessage = string.Concat(new object[] { "<li>第<font color='red'><b>", this.CreateCompleted + 1, "</b>个专题的专题列表页的第", i, "个分页生成失败</font> 专题名:", specialInfo.SpecialName, " 标签解析出现异常,跳过生成</li>", this.CreateMessage }); } } } }
private SpecialInfo GetSpecialInfo() { SpecialInfo info = new SpecialInfo(); info.OpenType = DataConverter.CLng(this.RadlOpenType.SelectedValue); info.IsElite = DataConverter.CBoolean(this.RadlIsElite.SelectedValue); info.SpecialTemplatePath = this.FileCSpecialTemplatePath.Text; return(info); }
public ActionResult IndexPc(int type = 0) { List <SpecialInfo> a = BonSite.Services.Special.GetList(); SpecialInfo info = BonSite.Services.Special.GetModelById(a[0].SpecialID); WorkContext.Type = type; WorkContext.NavList = ArticleClass.GetNavList(type); return(View()); }
public bool UpdateSpecial(SpecialInfo specialInfo) { Parameters parms = new Parameters(); GetSpecialParameters(specialInfo, parms); string strSql = "UPDATE PE_Specials SET SpecialName = @SpecialName, SpecialCategoryID = @SpecialCategoryId,SpecialDir = @SpecialDir, SpecialIdentifier = @SpecialIdentifier, SpecialPic = @SpecialPic,SpecialTips = @SpecialTips, SpecialTemplatePath = @SpecialTemplatePath, SearchTemplatePath = @SearchTemplatePath, IsElite = @IsElite,OrderId = @OrderId, OpenType = @OpenType, Description = @Description, IsCreateListPage = @IsCreateListPage,ListPageSavePathType = @ListPageSavePathType, ListPagePostfix = @ListPagePostfix, Custom_Content = @CustomContent, NeedCreateHtml = @NeedCreateHtml WHERE SpecialID = @SpecialId"; return(DBHelper.ExecuteSql(strSql, parms)); }
public static SpecialInfo GetSpecialInfo(int siteId, int specialId) { SpecialInfo specialInfo = null; var specialInfoDictionary = GetSpecialInfoDictionaryBySiteId(siteId); if (specialInfoDictionary != null && specialInfoDictionary.ContainsKey(specialId)) { specialInfo = specialInfoDictionary[specialId]; } return(specialInfo); }
public bool AddSpecial(SpecialInfo specialInfo) { Parameters parms = new Parameters(); specialInfo.SpecialId = this.GetMaxSpecialId() + 1; specialInfo.OrderId = GetMaxSpecialOrderId(specialInfo.SpecialCategoryId) + 1; GetSpecialParameters(specialInfo, parms); string strSql = "INSERT INTO PE_Specials(SpecialID, SpecialName, SpecialCategoryID, SpecialDir, SpecialIdentifier, SpecialPic, SpecialTips, SpecialTemplatePath, SearchTemplatePath, IsElite, OrderId, OpenType, Description, IsCreateListPage, ListPageSavePathType, ListPagePostfix, Custom_Content, NeedCreateHtml) VALUES (@SpecialID, @SpecialName, @SpecialCategoryId, @SpecialDir, @SpecialIdentifier, @SpecialPic, @SpecialTips, @SpecialTemplatePath, @SearchTemplatePath, @IsElite, @OrderId, @OpenType, @Description, @IsCreateListPage, @ListPageSavePathType, @ListPagePostfix, @CustomContent, @NeedCreateHtml)"; return(DBHelper.ExecuteSql(strSql, parms)); }
private static void DeleteFolder(int specialId) { SpecialInfo specialInfoById = GetSpecialInfoById(specialId); SpecialCategoryInfo specialCategoryInfoById = GetSpecialCategoryInfoById(specialInfoById.SpecialCategoryId); string str = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + VirtualPathUtility.AppendTrailingSlash(specialCategoryInfoById.SpecialCategoryDir) + specialInfoById.SpecialDir; string file = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, str); if (FileSystemObject.IsExist(file, FsoMethod.Folder)) { FileSystemObject.Delete(file, FsoMethod.Folder); } }
public static bool SpecialBatchSet(SpecialInfo specialInfo, string specialIds, Dictionary <string, bool> checkItem) { if (!DataValidator.IsValidId(specialIds)) { return(false); } if (!checkItem.ContainsValue(true)) { throw new CustomException("没有选择需要批量设置的选项!"); } return(dal.SpecialBatchSet(specialInfo, specialIds, checkItem)); }
/// <summary> /// 获取专题列表 /// </summary> /// <returns></returns> public static List <SpecialInfo> GetTopSpecialList(int count) { List <SpecialInfo> list = new List <SpecialInfo>(); IDataReader reader = BonSite.Core.BSData.RDBS.GetTopSpecialList(count); while (reader.Read()) { SpecialInfo model = BuildFromReader(reader); list.Add(model); } reader.Close(); return(list); }
private void BindSpecial() { SpecialInfo specialInfoById = Special.GetSpecialInfoById(this.specialId); if (specialInfoById.IsNull) { AdminPage.WriteErrMsg("发生错误,请传入正确的专题ID!"); } BasePage.SetSelectedIndexByValue(this.DropSpecialCategory, specialInfoById.SpecialCategoryId.ToString()); this.TxtSpecialName.Text = specialInfoById.SpecialName; this.TxtSpecialIdentifier.Text = specialInfoById.SpecialIdentifier; this.TxtSpecialDir.Enabled = false; string[] strArray = specialInfoById.SpecialDir.Split(new char[] { '/' }); if (strArray.Length > 1) { this.TxtSpecialDir.Text = strArray[1]; } else { this.TxtSpecialDir.Text = strArray[0]; } this.TxtSpecialPic.Text = specialInfoById.SpecialPic; this.TxtSpecialTips.Text = specialInfoById.SpecialTips; this.TxtDescription.Text = specialInfoById.Description; BasePage.SetSelectedIndexByValue(this.RadlIsElite, specialInfoById.IsElite.ToString()); BasePage.SetSelectedIndexByValue(this.RadOpenType, specialInfoById.OpenType.ToString()); this.FileCSpecialTemplatePath.Text = specialInfoById.SpecialTemplatePath; this.FileCSearchTemplatePath.Text = specialInfoById.SearchTemplatePath; BasePage.SetSelectedIndexByValue(this.RadlCreatHtml, specialInfoById.IsCreateListPage.ToString()); this.PagePostfix.Value = specialInfoById.ListPagePostfix; BasePage.SetSelectedIndexByValue(this.RadlListPageHtmlDirType, specialInfoById.ListPageSavePathType.ToString()); int num = 1; if (!string.IsNullOrEmpty(specialInfoById.CustomContent)) { string[] strArray2 = specialInfoById.CustomContent.Split(new string[] { "{#$$$#}" }, StringSplitOptions.None); int num2 = 1; foreach (string str in strArray2) { num = num2; ((TextBox)this.PnlCustomFileds.FindControl("Custom_Content" + num2)).Text = str; ((HtmlTableRow)this.PnlCustomFileds.FindControl("objFiles" + num2)).Attributes.Add("style", "display: ''"); num2++; } } ((DropDownList)this.PnlCustomFileds.FindControl("DropCustomNum")).SelectedValue = num.ToString(); this.HdnSpecialName.Value = specialInfoById.SpecialName; this.HdnSpecialDir.Value = specialInfoById.SpecialDir; this.HdnOrderId.Value = specialInfoById.OrderId.ToString(); }
public override void OnInitTemplatePage(EventArgs e) { int specialId = BasePage.RequestInt32("id"); switch (BasePage.RequestStringToLower("action")) { case "special": this.specialInfo = Special.GetSpecialInfoById(specialId); break; case "specialcategory": this.specialCategoryInfo = Special.GetSpecialCategoryInfoById(specialId); break; } }
/// <summary> /// 通过IDataReader创建ArticleInfo /// </summary> public static SpecialInfo BuildFromReader(IDataReader reader) { SpecialInfo model = new SpecialInfo(); model.SpecialID = TypeHelper.ObjectToInt(reader["SpecialID"]); model.Name = reader["Name"].ToString(); model.Title = reader["Title"].ToString(); model.Body = reader["Body"].ToString(); model.ImgUrl = reader["ImgUrl"].ToString(); model.LogoUrl = reader["LogoUrl"].ToString(); model.OutUrl = reader["OutUrl"].ToString(); model.IsOut = TypeHelper.ObjectToInt(reader["IsOut"]); model.DisplayOrder = TypeHelper.ObjectToInt(reader["DisplayOrder"]); return(model); }
private void InitSpecial() { StringBuilder builder = new StringBuilder(); string specialInfoIds = ""; switch (this.m_SpecialInfoType) { case 1: { int generalId = DataConverter.CLng(HttpContext.Current.Request["GeneralId"]); if (generalId > 0) { specialInfoIds = Special.GetSpecialInfoIds(generalId); } break; } case 2: { int id = DataConverter.CLng(HttpContext.Current.Request["ItemId"]); if (id > 0) { specialInfoIds = CollectionItem.GetInfoById(id).SpecialId; } break; } } if (!string.IsNullOrEmpty(specialInfoIds)) { this.HdnSpecial.Value = specialInfoIds; string[] strArray = specialInfoIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray.Length; i++) { SpecialInfo specialInfoById = Special.GetSpecialInfoById(DataConverter.CLng(strArray[i])); SpecialCategoryInfo specialCategoryInfoById = Special.GetSpecialCategoryInfoById(specialInfoById.SpecialCategoryId); builder.Append("\n<span id='SpecialSpanId" + specialInfoById.SpecialId + "'>"); builder.Append(specialCategoryInfoById.SpecialCategoryName + ">>" + specialInfoById.SpecialName); builder.Append(" <input type='button' class='button' onclick=\"javascript:DelSpecial('" + specialInfoById.SpecialId + "')\" value='删除此专题' /><br /></span>"); } } if (builder.Length <= 0) { builder.Append("<span id='SpecialSpanId0'>无专题<br /></span>"); } this.UlSpecial.InnerHtml = builder.ToString(); }
private static SpecialInfo GetSpecialInfo(IDataRecord rdr) { if (rdr == null) return null; var specialInfo = new SpecialInfo(); var i = 0; specialInfo.Id = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; specialInfo.SiteId = rdr.IsDBNull(i) ? 0 : rdr.GetInt32(i); i++; specialInfo.Title = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; specialInfo.Url = rdr.IsDBNull(i) ? string.Empty : rdr.GetString(i); i++; specialInfo.AddDate = rdr.IsDBNull(i) ? DateTime.Now : rdr.GetDateTime(i); return specialInfo; }
private bool CreateAndCheckFolderPermission(SpecialInfo specialInfo) { string file = VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + specialInfo.SpecialDir; if (!FileSystemObject.IsExist(file, FsoMethod.Folder)) { try { FileSystemObject.Create(file, FsoMethod.Folder); } catch { string errMsg = "专题ID:" + specialInfo.SpecialId.ToString() + " " + specialInfo.SpecialName + " 生成失败! 失败原因:请检查服务器是否给网站" + SiteConfig.SiteOption.CreateHtmlPath + "文件夹写入权限!"; this.ErrorLog(errMsg); return(false); } } return(true); }
private static void GetSpecialParameters(SpecialInfo specialInfo, Parameters parms) { parms.AddInParameter("@SpecialId", DbType.Int32, specialInfo.SpecialId); parms.AddInParameter("@SpecialName", DbType.String, specialInfo.SpecialName); parms.AddInParameter("@SpecialCategoryId", DbType.Int32, specialInfo.SpecialCategoryId); parms.AddInParameter("@SpecialDir", DbType.String, specialInfo.SpecialDir); parms.AddInParameter("@SpecialIdentifier", DbType.String, specialInfo.SpecialIdentifier); parms.AddInParameter("@SpecialPic", DbType.String, specialInfo.SpecialPic); parms.AddInParameter("@SpecialTips", DbType.String, specialInfo.SpecialTips); parms.AddInParameter("@SpecialTemplatePath", DbType.String, specialInfo.SpecialTemplatePath); parms.AddInParameter("@SearchTemplatePath", DbType.String, specialInfo.SearchTemplatePath); parms.AddInParameter("@IsElite", DbType.Boolean, specialInfo.IsElite); parms.AddInParameter("@OrderId", DbType.Int32, specialInfo.OrderId); parms.AddInParameter("@OpenType", DbType.Int32, specialInfo.OpenType); parms.AddInParameter("@Description", DbType.String, specialInfo.Description); parms.AddInParameter("@IsCreateListPage", DbType.Boolean, specialInfo.IsCreateListPage); parms.AddInParameter("@ListPageSavePathType", DbType.Int32, specialInfo.ListPageSavePathType); parms.AddInParameter("@ListPagePostfix", DbType.String, specialInfo.ListPagePostfix); parms.AddInParameter("@CustomContent", DbType.String, specialInfo.CustomContent); parms.AddInParameter("@NeedCreateHtml", DbType.Boolean, specialInfo.NeedCreateHtml); }
public void Update(SpecialInfo specialInfo) { var sqlString = $@"UPDATE {TableName} SET {nameof(SpecialInfo.SiteId)} = @{nameof(SpecialInfo.SiteId)}, {nameof(SpecialInfo.Title)} = @{nameof(SpecialInfo.Title)}, {nameof(SpecialInfo.Url)} = @{nameof(SpecialInfo.Url)}, {nameof(SpecialInfo.AddDate)} = @{nameof(SpecialInfo.AddDate)} WHERE {nameof(SpecialInfo.Id)} = @{nameof(SpecialInfo.Id)}"; IDataParameter[] parameters = { GetParameter(nameof(specialInfo.SiteId), DataType.Integer, specialInfo.SiteId), GetParameter(nameof(specialInfo.Title), DataType.VarChar, 200,specialInfo.Title), GetParameter(nameof(specialInfo.Url), DataType.VarChar, 200,specialInfo.Url), GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate), GetParameter(nameof(specialInfo.Id), DataType.Integer, specialInfo.Id) }; ExecuteNonQuery(sqlString, parameters); SpecialManager.RemoveCache(specialInfo.SiteId); }
public void UseSpecialPressed(ButtonUseSpecial buttonUseSpecial) { specialToUse = buttonUseSpecial.special; SendLocalEvent("OnUseSpecialPressed"); }
public void UseSpecial() { //Debug.Log("UseSpecial()"); if (specialToUse != null) { // Debug.Log("Use " + specialToUse.name); specialToUse.Use(); specialToUse = null; } }
public void InitFrom(Stream templateStream) { if (templateStream == null) throw new ArgumentNullException("templateStream"); this.file = null; this.name = "Unknown"; this.specialTag = SpecialInfo.None; using (ZipArchive templateZip = new ZipArchive(templateStream)) { ZipArchiveEntry entryInfo = templateZip.Entries.FirstOrDefault(z => z.Name == "TemplateInfo.xml"); ZipArchiveEntry entryIcon = templateZip.Entries.FirstOrDefault(z => z.Name == "TemplateIcon.png"); if (entryIcon != null) { using (MemoryStream str = new MemoryStream()) { entryIcon.Extract(str); str.Seek(0, SeekOrigin.Begin); this.icon = new Bitmap(str); } } if (entryInfo != null) { string xmlSource = null; using (MemoryStream str = new MemoryStream()) { entryInfo.Extract(str); str.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(str)) { xmlSource = reader.ReadToEnd(); } } XDocument xmlDoc = XDocument.Parse(xmlSource); XElement elemName = xmlDoc.Element("name"); if (elemName != null) this.name = elemName.Value; XElement elemDesc = xmlDoc.Element("description"); if (elemDesc != null) this.desc = elemDesc.Value; } } return; }
private GameLogic CreateGameLogic(SpecialInfo info, object[] args) { infos.Remove(info); return (GameLogic)Activator.CreateInstance(info.type, args); }
public void InitFrom(Stream templateStream) { if (templateStream == null) throw new ArgumentNullException("templateStream"); this.file = null; this.name = "Unknown"; this.specialTag = SpecialInfo.None; using (ZipFile templateZip = ZipFile.Read(templateStream)) { ZipEntry entryInfo = templateZip.FirstOrDefault(z => !z.IsDirectory && z.FileName == "TemplateInfo.xml"); ZipEntry entryIcon = templateZip.FirstOrDefault(z => !z.IsDirectory && z.FileName == "TemplateIcon.png"); if (entryIcon != null) { using (MemoryStream str = new MemoryStream()) { entryIcon.Extract(str); str.Seek(0, SeekOrigin.Begin); this.icon = new Bitmap(str); } } if (entryInfo != null) { string xmlSource = null; using (MemoryStream str = new MemoryStream()) { entryInfo.Extract(str); str.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(str)) { xmlSource = reader.ReadToEnd(); } } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlSource); XmlElement elemName = xmlDoc.DocumentElement["name"]; if (elemName != null) this.name = elemName.InnerText; XmlElement elemDesc = xmlDoc.DocumentElement["description"]; if (elemDesc != null) this.desc = elemDesc.InnerText; } } return; }