/// <summary> /// 数据项绑定 /// </summary> private void DataItemBind(TemplateDB XmlDB) { String ContentHTML = String.Empty; TemplateFormat xf = new TemplateFormat(this); xf.TemplateName = XmlDB.Name; Hashtable Puts = new Hashtable(); if (DataItem != null && DataItem.ID > 0) { if (DataItem.Status == (Int32)EnumStatus.Published && IsPublishTime(DataItem) || (Preview && DataItem.Status == (Int32)EnumStatus.Draft)) { //判断角色权限及区域权限 if (IsPreRoleView(DataItem.Per_AllUsers, DataItem.Per_Roles) && IsPreJurisdictionView(DataItem.Per_AllJurisdictions, DataItem.Per_Jurisdictions)) { //数据项 Puts.Add("DataItem", DataItem); //当前文档关联的文件集 Puts.Add("DownloadFiles", GetDownloadFiles(DataItem)); //详情模板调用 ContentHTML = ViewTemplate(XmlDB, "View_Template_Detail.html", Puts, xf); //动态模块的配置 if (!String.IsNullOrEmpty(ContentHTML) && ContentHTML.IndexOf("[DynamicModules]", StringComparison.CurrentCultureIgnoreCase) >= 0) { //获取动态模块和动态项 Puts = GetDynamics(Puts); ContentHTML = Common.ReplaceNoCase(ContentHTML, "[DynamicModules]", ViewTemplate(GetTemplateDB("DynamicModules"), "View_Template.html", Puts, xf)); } } else { //无权限访问 ContentHTML = "你无当前数据的访问权限"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } } else { //无法访问 ContentHTML = "无法访问内容或未到开始时间"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } } else { ContentHTML = "内容没有找到"; Response.Redirect(new TemplateFormat(this).GoUiUrl(UIToken)); } liContentHTML.Text = ContentHTML; }
public void Execute(BasePage Context) { TemplateFormat xf = new TemplateFormat(Context); QueryParam qp = new QueryParam(); qp.ReturnFields = "ID,Title"; qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Context.Request, "PageSize", xf.ViewSettingT <Int32>("General.Search.Size", 10)); //排序的规则 qp.OrderType = WebHelper.GetIntParam(Context.Request, "OrderType", 1); qp.Orderfld = "ID"; //WebHelper.GetStringParam(Context.Request, "Orderfld", "ID"); //查询语句 qp = CreateQueryParam(qp, Context); //权限筛选 qp = CreateQueryByRoles(qp, Context); //区域筛选 qp = CreateQueryByJurisdictions(qp, Context); int RecordCount = 0; List <Playngo_ClientZone_DownloadFile> EventList = Playngo_ClientZone_DownloadFile.FindAll(qp, out RecordCount); Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); List <Dictionary <String, Object> > DictFiles = new List <Dictionary <string, object> >(); foreach (var EventItem in EventList) { int index = EventList.IndexOf(EventItem); //index 为索引值 Dictionary <String, Object> jsonDict = new Dictionary <String, Object>(); jsonDict.Add("ID", EventItem.ID); jsonDict.Add("Title", EventItem.Title); DictFiles.Add(jsonDict); } jsonPictures.Add("data", DictFiles); jsonPictures.Add("Pages", qp.Pages); jsonPictures.Add("RecordCount", RecordCount); //转换数据为json ResponseString = jsSerializer.Serialize(jsonPictures); }
/// <summary> /// 列表行绑定 /// </summary> protected void gvEventList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //还原出数据 Playngo_ClientZone_Jurisdiction Categorie = e.Row.DataItem as Playngo_ClientZone_Jurisdiction; //移动分类按钮 LinkButton lbSortUp = e.Row.FindControl("lbSortUp") as LinkButton; LinkButton lbSortDown = e.Row.FindControl("lbSortDown") as LinkButton; LinkButton lbMobileSortUp = e.Row.FindControl("lbMobileSortUp") as LinkButton; LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton; lbSortUp.CommandArgument = lbSortDown.CommandArgument = lbMobileSortUp.CommandArgument = lbMobileSortDown.CommandArgument = Categorie.ID.ToString(); //编辑按钮 HyperLink hlMobileEdit = e.Row.FindControl("hlMobileEdit") as HyperLink; HyperLink hlEdit = e.Row.FindControl("hlEdit") as HyperLink; hlMobileEdit.NavigateUrl = hlEdit.NavigateUrl = xUrl("CategoryID", Categorie.ID.ToString(), "Jurisdictions"); //删除按钮 LinkButton btnRemove = e.Row.FindControl("btnRemove") as LinkButton; LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton; btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Categorie.ID.ToString(); btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); //分类名称 HyperLink hlCategorie = e.Row.FindControl("hlCategorie") as HyperLink; hlCategorie.Text = Categorie.Name; //hlCategorie.NavigateUrl = new TemplateFormat(this).GoUrl(Categorie); if (!String.IsNullOrEmpty(Categorie.Picture)) { TemplateFormat xf = new TemplateFormat(this); HyperLink hlPicture = e.Row.FindControl("hlPicture") as HyperLink; var PictureUrl = xf.ViewLinkUrl(Categorie.Picture); hlPicture.NavigateUrl = PictureUrl; String FileName = Path.GetFileName(HttpUtility.UrlDecode(PictureUrl)); String Extension = Path.GetExtension(FileName); if ((".jpg,.gif,.jpeg,.png,.bmp").IndexOf(Extension, StringComparison.CurrentCultureIgnoreCase) >= 0) { hlPicture.ImageUrl = PictureUrl; hlPicture.ImageHeight = 50; } else { hlPicture.Text = FileName; } } } }
public void Execute(BasePage Context) { Int32 FileId = WebHelper.GetIntParam(Context.Request, "FileId", 0); if (FileId > 0) { var FileItem = Playngo_ClientZone_DownloadFile.FindByKeyForEdit(FileId); if (FileItem != null && FileItem.ID > 0 && !String.IsNullOrEmpty(FileItem.Options)) { if (Context.IsPreRoleView(FileItem.Per_AllUsers, FileItem.Per_Roles) && Context.IsPreJurisdictionView(FileItem.Per_AllJurisdictions, FileItem.Per_Jurisdictions)) { var FileItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(FileItem.Options); if (FileItemOptions != null) { TemplateFormat xf = new TemplateFormat(Context); Playngo_ClientZone_Files Multimedia = new Playngo_ClientZone_Files(); String UploadFile = xf.GetFilePath(xf.ViewItemSettingT <String>(FileItem.Options, "UploadFile", ""), Context, out Multimedia); if (!String.IsNullOrEmpty(UploadFile)) { UploadFile = Context.Server.MapPath(UploadFile); if (File.Exists(UploadFile)) { String FileName = String.Format("{0}.{1}", Multimedia.Name, Multimedia.FileExtension); //FileSystemUtils.DownloadFile(UploadFile,String.Format("{0}_{1}{2}", FileItem.Title, FileItem.Version, Path.GetExtension(UploadFile))); //FileSystemUtils.DownloadFile(UploadFile); FileManager file = new FileManager(); file.WriteFileToResponse(new System.IO.FileInfo(UploadFile), ContentDisposition.Attachment); IsResponseWrite = false; } } else { //当前文件找不到 } } else { //没有添加文件 } } else { //没有权限下载 } } else { ResponseString = "没找到数据怎么搞"; } } else { ResponseString = "传过来的文件编号都不对"; } }
/// <summary> /// 推送图片列表数据 /// </summary> public void PushPictureList() { QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_PowerForms_Files._.ID; qp.PageIndex = WebHelper.GetIntParam(Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Request, "PageSize", Int32.MaxValue); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Files._.Status, (Int32)EnumStatus.Activation, SearchType.Equal)); int RecordCount = 0; List <DNNGo_PowerForms_Files> fileList = DNNGo_PowerForms_Files.FindAll(qp, out RecordCount); Dictionary <String, Object> jsonLayers = new Dictionary <string, Object>(); TemplateFormat xf = new TemplateFormat(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); foreach (var fileItem in fileList) { int index = fileList.IndexOf(fileItem); //index 为索引值 Dictionary <String, Object> jsonLayer = new Dictionary <String, Object>(); jsonLayer.Add("Pages", qp.Pages); jsonLayer.Add("ID", fileItem.ID); jsonLayer.Add("CreateTime", fileItem.LastTime); jsonLayer.Add("Name", WebHelper.leftx(fileItem.Name, 20, "...")); jsonLayer.Add("Extension", fileItem.FileExtension); String ThumbnailUrl = ViewLinkUrl(String.Format("MediaID={0}", fileItem.ID)); jsonLayer.Add("ThumbnailUrl", ThumbnailUrl); jsonLayer.Add("FileUrl", GetPhotoPath(fileItem.FilePath)); jsonLayer.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\" src=\"{0}\" /> ", ThumbnailUrl)); jsonLayer.Add("Json", jsSerializer.Serialize(jsonLayer)); jsonLayers.Add(index.ToString(), jsonLayer); } //转换数据为json Response.Clear(); Response.Write(jsSerializer.Serialize(jsonLayers)); Response.End(); }
/// <summary> /// 列表行绑定 /// </summary> protected void gvEventList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //还原出数据 Playngo_ClientZone_DownloadFile Media = e.Row.DataItem as Playngo_ClientZone_DownloadFile; if (Media != null && Media.ID > 0) { TemplateFormat xf = new TemplateFormat(this); HyperLink hlFileName = e.Row.FindControl("hlFileName") as HyperLink; hlFileName.Text = Media.Title; Image imgFileName = e.Row.FindControl("imgFileName") as Image; //imgFileName.ImageUrl = xf.ViewLinkUrl(Media.) //Label lblFileExtension = e.Row.FindControl("lblFileExtension") as Label; //lblFileExtension.Text = Media.FileExtension; //Image imgFileName = e.Row.FindControl("imgFileName") as Image; //HyperLink hlFileName = e.Row.FindControl("hlFileName") as HyperLink; //hlFileName.Text = Media.FileName.Replace("." + Media.FileExtension, ""); //imgFileName.ImageUrl = GetPhotoExtension(Media.FileExtension, Media.FilePath); //hlFileName.NavigateUrl = GetPhotoPath(Media.FilePath); //发布者信息 e.Row.Cells[2].Text = "--"; if (Media.LastUser > 0) { UserInfo uInfo = UserController.GetUserById(PortalId, Media.LastUser); if (uInfo != null && uInfo.UserID > 0) { e.Row.Cells[2].Text = String.Format("{0}<br />{1}", uInfo.Username, uInfo.DisplayName); } } //发布时间 e.Row.Cells[3].Text = Media.LastTime.ToShortDateString(); //状态 e.Row.Cells[4].Text = EnumHelper.GetEnumTextVal(Media.Status, typeof(EnumStatus)); } } }
/// <summary> /// 数据绑定 /// </summary> private void DataListBind(TemplateDB XmlDB) { TemplateFormat xf = new TemplateFormat(this); xf.TemplateName = XmlDB.Name; Hashtable Puts = new Hashtable(); liContentHTML.Text = ViewTemplate(XmlDB, "View_Template.html", Puts, xf); }
public void Execute(BasePage Context) { TemplateFormat xf = new TemplateFormat(Context); QueryParam qp = new QueryParam(); qp.ReturnFields = "ID,Title"; qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Context.Request, "PageSize", xf.ViewSettingT <Int32>("General.Search.Size", 10)); var RoleGroupList = RoleController.GetRoleGroups(Context.PortalId); var RoleGroups = Common.Split <RoleGroupInfo>(RoleGroupList, 1, 999); String SearchText = WebHelper.GetStringParam(Context.Request, "search", ""); if (!String.IsNullOrEmpty(SearchText)) { RoleGroups = RoleGroups.FindAll(r => r.RoleGroupName.IndexOf(SearchText, StringComparison.CurrentCultureIgnoreCase) >= 0); } RoleGroups = Common.Split <RoleGroupInfo>(RoleGroups, qp.PageIndex, qp.PageSize); Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); List <Dictionary <String, Object> > DictItems = new List <Dictionary <string, object> >(); foreach (var RoleGroupItem in RoleGroups) { int index = RoleGroups.IndexOf(RoleGroupItem); //index 为索引值 Dictionary <String, Object> jsonDict = new Dictionary <String, Object>(); jsonDict.Add("id", RoleGroupItem.RoleGroupID); jsonDict.Add("text", RoleGroupItem.RoleGroupName); jsonDict.Add("roles", Playngo_ClientZone_RoleGroup.FindRolesByGroup(Context.PortalId, RoleGroupItem.RoleGroupID)); DictItems.Add(jsonDict); } jsonPictures.Add("Items", DictItems); jsonPictures.Add("Pages", qp.Pages); jsonPictures.Add("RecordCount", RoleGroupList.Count); //转换数据为json ResponseString = jsSerializer.Serialize(jsonPictures); }
public void Execute(BasePage Context) { Dictionary <String, Object> jsonDatas = new Dictionary <string, Object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); TemplateFormat xf = new TemplateFormat(Context); if (Context.UserId > 0) { //jsonDatas.Add("SelectJurisdictions", new List<string>()); var UserItem = Context.UserInfo; String SelectJurisdictions = WebHelper.GetStringParam(Context.Request, "SelectGameCategories", ""); if (!String.IsNullOrEmpty(SelectJurisdictions)) { UserItem.Profile.SetProfileProperty("SelectGameCategories", SelectJurisdictions); } else { UserItem.Profile.SetProfileProperty("SelectGameCategories", "-"); } DataCache.ClearPortalCache(Context.PortalId, true); DataCache.ClearCache(); DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(UserItem); DotNetNuke.Entities.Users.UserController.UpdateUser(Context.PortalId, UserItem); jsonDatas.Add("Result", "Success"); jsonDatas.Add("SelectGameCategories", SelectJurisdictions); } else { //没有登录怎么搞 jsonDatas.Add("Result", "NoLogin"); } //jsonPictures.Add("data", DictFiles); //jsonPictures.Add("Pages", qp.Pages); //jsonPictures.Add("RecordCount", RecordCount); //转换数据为json ResponseString = jsSerializer.Serialize(jsonDatas); }
public static ITextTemplate NewTextTemplate(this IEntitySession session, string name, string template, TemplateFormat format, string culture = "EN-US", string engine = "Simple", Guid? ownerId = null) { var templ = session.NewEntity<ITextTemplate>(); templ.Name = name; templ.Template = template; templ.Format = format; templ.Culture = culture; templ.Engine = engine; templ.OwnerId = ownerId; return templ; }
private string GetTemplate(TemplateFormat format) { var resource = string.Format("{0}.{1}.{2}", this.GetType().Namespace, _name, format.ToString().ToLower()); var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream(resource)) { using (var reader = new StreamReader(stream, Encoding.UTF8)) { var template = reader.ReadToEnd(); return(template); } } }
private string GetTemplate(TemplateFormat format) { var resource = $"{this.GetType().Namespace}.{_name}.{format.ToString().ToLower()}"; var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream(resource)) { using (var reader = new StreamReader(stream ?? throw new InvalidOperationException($"resource not found: {resource}"), Encoding.UTF8)) { var template = reader.ReadToEnd(); return(template); } } }
/// <summary> /// 绑定顶部菜单 /// </summary> private void BindTopMenus() { var XMLDB = GetTemplateDB("TopTabs"); TemplateFormat xf = new TemplateFormat(this); Hashtable Puts = new Hashtable(); //当前激活的菜单 Puts.Add("UIToken", UIToken); //所有菜单的列表 Puts.Add("AllTabList", MenuTabCollection); Puts.Add("TopTabList", MenuTabCollection.FindAll(r => String.IsNullOrEmpty(r.Parent))); liTopMenus.Text = ViewTemplate(XMLDB, "View_Template.html", Puts, xf); }
private void SaveTemplate(byte[] template, TemplateFormat format) { if (template != null) { if (format == TemplateFormat.PK_FVP) { SaveFVPTemplate(template, format); } else { SaveFPTemplate(template, format); } } }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDB EffectDB) { Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); //读取需要载入的参数 Puts.Add("EffectName", Settings_ResultName); Puts.Add("ThemeName", Settings_ResultThemeName); //读取当前Form的结果 DNNGo_PowerForms_Content DataItem = DNNGo_PowerForms_Content.FindByKeyForEdit(FormID); Puts.Add("DataItem", DataItem); if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.ContentValue)) { List <DNNGo_PowerForms_ContentItem> ContentList = Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(DataItem.ContentValue); Puts.Add("ContentList", ContentList); } //查看是否是结果列表页 if (!EffectDB.IsDetail) { Int32 RecordCount = 0; QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_PowerForms_Content._.ID; qp.OrderType = 1; qp.PageSize = 10; qp.PageIndex = PageIndex; qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Content> Results = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount); Puts.Add("ResultList", Results); if (RecordCount > qp.PageSize) { Puts.Add("Pager", new Pager(qp.PageIndex, qp.PageSize, ModuleId, RecordCount, EnumPageType.DnnURL, false).CreateHtml());//分页 } else { Puts.Add("Pager", ""); } } liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf, "Result")); }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDB EffectDB, String ErrorMessage) { //防止重复提交之用 //SubmitButton.Attributes["onclick"] = Page.GetPostBackEventReference(this.SubmitButton) ; Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.CtlButton = SubmitButton; //读取需要载入的参数 Puts.Add("FieldList", FieldList); //读取需要载入的分组 List <DNNGo_PowerForms_Group> GroupList = new List <DNNGo_PowerForms_Group>(); if (Setting_EffectDB.Group) { GroupList = DNNGo_PowerForms_Group.FindAllByView(ModuleId); if (GroupList.Count == 0) { DNNGo_PowerForms_Group defultGroup = new DNNGo_PowerForms_Group(); defultGroup.ID = 0; defultGroup.Name = "Default Group"; GroupList.Add(defultGroup); } } Puts.Add("GroupList", GroupList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("ErrorMessage", ErrorMessage); Puts.Add("captchaErrorMessage", ErrorMessage); //判断表单版本,用来判断是否控制每个人只能填写一次 Puts.Add("DisplayForm", DisplayForm()); if (!String.IsNullOrEmpty(iFrame) && iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0) { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "iFrame.html", Puts, xf)); } else { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf)); } }
public string Transform(string template, TemplateFormat format, IDictionary<string, object> data) { var result = template; var entries = data.ToList(); foreach(var kv in entries) { //Quick check without braces/tags if(!result.Contains(kv.Key)) continue; var tag = OpenTag + kv.Key + EndTag; var strValue = kv.Value + string.Empty; //safe ToString() if(!string.IsNullOrWhiteSpace(strValue) && format == TemplateFormat.Html) strValue = StringHelper.EscapeForHtml(strValue); result = result.Replace(tag, strValue); } if(result.Contains(EscapedOpenTag)) result = result.Replace(EscapedOpenTag, OpenTag); return result; }
protected void gvItemList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DNNGo_PowerForms_ContentItem ContentItem = e.Row.DataItem as DNNGo_PowerForms_ContentItem; if (ContentItem.Extra && !Settings_ExtraTracking) { e.Row.Visible = false; //如果是关闭了追踪,就停止显示 } else { Literal LiContentValue = e.Row.FindControl("LiContentValue") as Literal; TemplateFormat xf = new TemplateFormat(this); xf.FieldList = FieldList; LiContentValue.Text = xf.ViewContentValue(ContentItem); } } }
public QueryParam SqlQueryTable(TemplateFormat xf, BasePage Context) { //4组数据的角标(根据Cookie传过来的时间计算) QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam("Status", (Int32)EnumStatus.Published, SearchType.Equal)); qp.Where.Add(new SearchParam("PortalId", Context.PortalId, SearchType.Equal)); qp.Where.Add(new SearchParam("NotifyInclude", 1, SearchType.Equal)); //qp.Where.Add(new SearchParam("StartTime", xUserTime.UtcTime().AddDays(-xf.ViewSettingT<Int32>("General.ExpiryTimeNotification", 7)), SearchType.GtEqual)); //未到开始时间的不显示数据 qp.Where.Add(new SearchParam("StartTime", xUserTime.UtcTime(), SearchType.LtEqual)); //权限筛选 qp = CreateQueryByRoles(qp, Context); return(qp); }
public void Execute(BasePage Context) { Int32 ItemId = WebHelper.GetIntParam(Context.Request, "ID", 0); if (ItemId > 0) { Int32 ItemType = WebHelper.GetIntParam(Context.Request, "Type", (Int32)EnumDisplayModuleType.GameSheets); TemplateFormat xf = new TemplateFormat(Context); if (ItemType == (Int32)EnumDisplayModuleType.Events) { var Item = Playngo_ClientZone_Event.FindByKeyForEdit(ItemId); Context.Response.Redirect(xf.GoUrl(Item)); } else if (ItemType == (Int32)EnumDisplayModuleType.Campaigns) { var Item = Playngo_ClientZone_Campaign.FindByKeyForEdit(ItemId); Context.Response.Redirect(xf.GoUrl(Item)); } else if (ItemType == (Int32)EnumDisplayModuleType.Downloads) { Context.Response.Redirect(xf.GoUiUrl("Downloads")); } else { var Item = Playngo_ClientZone_GameSheet.FindByKeyForEdit(ItemId); Context.Response.Redirect(xf.GoUrl(Item)); } } else { IsResponseWrite = true; ResponseString = "传过来的文件编号都不对"; } }
/// <summary> /// 绑定区域数据 /// </summary> private void BindNavJurisdictions() { var XMLDB = GetTemplateDB("NavJurisdictions"); TemplateFormat xf = new TemplateFormat(this); Hashtable Puts = new Hashtable(); Int32 RecordCount = 0; QueryParam qp = new QueryParam(); qp.Orderfld = Playngo_ClientZone_Jurisdiction._.Sort; qp.OrderType = 0; qp.Where.Add(new SearchParam(Playngo_ClientZone_Jurisdiction._.PortalId, PortalId, SearchType.Equal)); //权限筛选 qp = CreateQueryByRoles(qp); var Jurisdictions = new List <Playngo_ClientZone_Jurisdiction>(); Jurisdictions.Add(new Playngo_ClientZone_Jurisdiction() { ID = 0, Name = "All" }); var items = Playngo_ClientZone_Jurisdiction.FindAll(qp, out RecordCount); if (items != null && items.Count > 0) { Jurisdictions.AddRange(items); } Puts.Add("Jurisdictions", Jurisdictions); liNavJurisdictions.Text = ViewTemplate(XMLDB, "View_Template.html", Puts, xf); }
public void Execute(BasePage Context) { TemplateFormat xf = new TemplateFormat(Context); QueryParam qp = new QueryParam(); qp.ReturnFields = "ID,Title"; qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Context.Request, "PageSize", xf.ViewSettingT <Int32>("General.Search.Size", 10)); //排序的规则 qp.OrderType = WebHelper.GetIntParam(Context.Request, "OrderType", 1); qp.Orderfld = "ID"; //WebHelper.GetStringParam(Context.Request, "Orderfld", "ID"); //查询语句 qp = CreateQueryParam(qp, Context); //权限筛选 qp = CreateQueryByRoles(qp, Context); //区域筛选 qp = CreateQueryByJurisdictions(qp, Context); int RecordCount = 0; var UserList = new List <UserInfo>(); String SearchText = WebHelper.GetStringParam(Context.Request, "search", ""); if (!String.IsNullOrEmpty(SearchText)) { //UserList = UserController.Instance.GetUsersAdvancedSearch(Context.PortalId, 0, -1, -1, -1, false, 0, 10, "USERID", false, "Username,DisplayName", "%" + SearchText ).ToList<UserInfo>(); UserList = Common.Split <UserInfo>(UserController.GetUsersByUserName(Context.PortalId, "%" + SearchText + "%", 0, 10, ref RecordCount, false, false), 1, 100); // "USERID", false, "Username", ).ToList<UserInfo>(); } else { UserList = Common.Split <UserInfo>(UserController.GetUsers(Context.PortalId, 0, 10, ref RecordCount), 1, 100); //.GetUsersBasicSearch(Context.PortalId, 1, 10, "USERID", false, "", "").ToList<UserInfo>(); } Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); List <Dictionary <String, Object> > DictItems = new List <Dictionary <string, object> >(); foreach (var UserItem in UserList) { int index = UserList.IndexOf(UserItem); //index 为索引值 Dictionary <String, Object> jsonDict = new Dictionary <String, Object>(); jsonDict.Add("id", UserItem.UserID); jsonDict.Add("text", String.Format("{0} - {1}", UserItem.Username, UserItem.DisplayName)); jsonDict.Add("roles", Common.GetStringByList(UserItem.Roles)); DictItems.Add(jsonDict); } jsonPictures.Add("Items", DictItems); jsonPictures.Add("Pages", qp.Pages); jsonPictures.Add("RecordCount", RecordCount); //转换数据为json ResponseString = jsSerializer.Serialize(jsonPictures); }
private void SaveFPTemplate(byte[] template, TemplateFormat format) { if (this.comboBoxFPFormat.SelectedItem.ToString() != DeviceLayoutConfig.NoneItemString) { SaveFileDialog dlg = new SaveFileDialog(); dlg.AddExtension = false; dlg.FileName = "fingerprint"; dlg.Title = "Save fingerprint template"; dlg.AddExtension = true; string l_s_Filter; switch (format) { case TemplateFormat.CFV: l_s_Filter = "Morpho CFV Fingerprint Template (*.cfv)|*.cfv|"; dlg.DefaultExt = "cfv"; break; case TemplateFormat.PKMAT: l_s_Filter = "Morpho PkMat Fingerprint Template (*.pkmat)|*.pkmat|"; dlg.DefaultExt = "pkmat"; break; case TemplateFormat.PKCOMPV2: l_s_Filter = "Morpho PkComp V2 Fingerprint Template (*.pkc)|*.pkc|"; dlg.DefaultExt = "pkc"; break; case TemplateFormat.PKLITE: l_s_Filter = "Morpho PkLite Fingerprint Template (*.pklite)|*.pklite|"; dlg.DefaultExt = "pklite"; break; case TemplateFormat.ANSI_378: l_s_Filter = "ANSI INCITS 378-2004 Finger Minutiae Record (*.ansi-fmr)|*.ansi-fmr|"; dlg.DefaultExt = "ansi-fmr"; break; case TemplateFormat.ISO_19794_2_FMR: l_s_Filter = "ISO/IEC 19794-2:2005 Finger Minutiae Record (*.iso-fmr)|*.iso-fmr|"; dlg.DefaultExt = "iso-fmr"; break; case TemplateFormat.ISO_19794_2_Card_Format_Normal_Size: l_s_Filter = "ISO/IEC 19794-2:2005 Finger Minutiae Card Format Normal Size (*.iso-fmc-ns)|*.iso-fmc-ns|"; dlg.DefaultExt = "iso-fmc-ns"; break; case TemplateFormat.ISO_19794_2_Card_Format_Compact_Size: l_s_Filter = "ISO/IEC 19794-2:2005 Finger Minutiae Card Format Compact Size (*.iso-fmc-cs)|*.iso-fmc-cs|"; dlg.DefaultExt = "iso-fmc-cs"; break; case TemplateFormat.PKMAT_NORM: l_s_Filter = "Morpho PkMat Norm Fingerprint Template (*.pkmn)|*.pkmn|"; dlg.DefaultExt = "pkmn"; break; case TemplateFormat.PKCOMPV2_NORM: l_s_Filter = "Morpho PkComp V2 Norm Fingerprint Template (*.pkcn)|*.pkcn|"; dlg.DefaultExt = "pkcn"; break; default: l_s_Filter = string.Empty; break; } dlg.Filter = l_s_Filter + "All Files (*.*)|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { System.IO.FileStream fs = new System.IO.FileStream(dlg.FileName, FileMode.Create, FileAccess.Write); fs.Write(template, 0, template.Length); fs.Close(); } } }
private static void AddTemplateFormat(ref AssociativeTuple <string, TemplateFormat> io_x_TemplateFormatMap, TemplateFormat i_e_TemplateFormat) { switch (i_e_TemplateFormat) { case TemplateFormat.CFV: io_x_TemplateFormatMap["Morpho CFV Fingerprint Template"] = TemplateFormat.CFV; break; case TemplateFormat.PKMAT: io_x_TemplateFormatMap["Morpho PkMat Fingerprint Template"] = TemplateFormat.PKMAT; break; case TemplateFormat.PKCOMPV2: io_x_TemplateFormatMap["Morpho PkComp V2 Fingerprint Template"] = TemplateFormat.PKCOMPV2; break; case TemplateFormat.PKLITE: io_x_TemplateFormatMap["Morpho PkLite Fingerprint Template"] = TemplateFormat.PKLITE; break; case TemplateFormat.PK_FVP: io_x_TemplateFormatMap["Morpho PkFVP Finger Vein/Fingerprint Template"] = TemplateFormat.PK_FVP; break; case TemplateFormat.ANSI_378: io_x_TemplateFormatMap["ANSI INCITS 378-2004 Finger Minutiae Record"] = TemplateFormat.ANSI_378; break; case TemplateFormat.ISO_19794_2_FMR: io_x_TemplateFormatMap["ISO/IEC 19794-2:2005 Finger Minutiae Record"] = TemplateFormat.ISO_19794_2_FMR; break; case TemplateFormat.ISO_19794_2_Card_Format_Normal_Size: io_x_TemplateFormatMap["ISO/IEC 19794-2:2005 Finger Minutiae Card Format Normal Size"] = TemplateFormat.ISO_19794_2_Card_Format_Normal_Size; break; case TemplateFormat.ISO_19794_2_Card_Format_Compact_Size: io_x_TemplateFormatMap["ISO/IEC 19794-2:2005 Finger Minutiae Card Format Compact Size"] = TemplateFormat.ISO_19794_2_Card_Format_Compact_Size; break; case TemplateFormat.PKMAT_NORM: io_x_TemplateFormatMap["Morpho PkMat Norm Fingerprint Template"] = TemplateFormat.PKMAT_NORM; break; case TemplateFormat.PKCOMPV2_NORM: io_x_TemplateFormatMap["Morpho PkComp V2 Norm Fingerprint Template"] = TemplateFormat.PKCOMPV2_NORM; break; default: throw new InvalidParameterException("Unknown template format value", ErrorCodes.IED_ERR_INTERNAL); } }
private void buttonVerify_Click(object sender, EventArgs e) { try { //Select File OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = false; dlg.Title = "Select reference template"; Dictionary <TemplateFormat, string> l_x_TemplateFormatFilterMap = new Dictionary <TemplateFormat, string>(); l_x_TemplateFormatFilterMap[TemplateFormat.CFV] = "Morpho CFV Fingerprint Template (*.cfv)|*.cfv"; l_x_TemplateFormatFilterMap[TemplateFormat.PKMAT] = "Morpho PkMat Fingerprint Template (*.pkmat)|*.pkmat"; l_x_TemplateFormatFilterMap[TemplateFormat.PKCOMPV2] = "Morpho PkComp V2 Fingerprint Template (*.pkc)|*.pkc"; l_x_TemplateFormatFilterMap[TemplateFormat.PKLITE] = "Morpho PkLite Fingerprint Template (*.pklite)|*.pklite"; l_x_TemplateFormatFilterMap[TemplateFormat.PK_FVP] = "Morpho PkFVP Finger Vein/Fingerprint Template (*.fvp)|*.fvp"; l_x_TemplateFormatFilterMap[TemplateFormat.ANSI_378] = "ANSI INCITS 378-2004 Finger Minutiae Record (*.ansi-fmr)|*.ansi-fmr"; l_x_TemplateFormatFilterMap[TemplateFormat.ISO_19794_2_FMR] = "ISO/IEC 19794-2:2005 Finger Minutiae Record (*.iso-fmr)|*.iso-fmr"; l_x_TemplateFormatFilterMap[TemplateFormat.ISO_19794_2_Card_Format_Normal_Size] = "ISO/IEC 19794-2:2005 Finger Minutiae Card Format Normal Size (*.iso-fmc-ns)|*.iso-fmc-ns"; l_x_TemplateFormatFilterMap[TemplateFormat.ISO_19794_2_Card_Format_Compact_Size] = "ISO/IEC 19794-2:2005 Finger Minutiae Card Format Compact Size (*.iso-fmc-cs)|*.iso-fmc-cs"; l_x_TemplateFormatFilterMap[TemplateFormat.PKMAT_NORM] = "Morpho PkMat Norm Fingerprint Template (*.pkmn)|*.pkmn"; l_x_TemplateFormatFilterMap[TemplateFormat.PKCOMPV2_NORM] = "Morpho PkComp V2 Norm Fingerprint Template (*.pkcn)|*.pkcn"; AssociativeTuple <int, TemplateFormat> l_x_FilterTemplates = new AssociativeTuple <int, TemplateFormat>(); string l_x_Filter = string.Empty; int l_i_FilterIndex = -1; int l_i_FilterCount = 1; foreach (TemplateFormat l_x_TemplateFormat in CurrentDeviceLayoutConfig.VerifyTemplateFormats.Seconds) { l_x_FilterTemplates[l_i_FilterCount] = l_x_TemplateFormat; l_x_Filter += l_x_TemplateFormatFilterMap[l_x_TemplateFormat] + "|"; if (l_x_TemplateFormat == CurrentDeviceLayoutConfig.FPTemplateFormats[this.comboBoxFPFormat.SelectedItem.ToString()] || (CurrentDeviceLayoutConfig.FVPTemplatesSupported && (l_x_TemplateFormat == CurrentDeviceLayoutConfig.FVPTemplateFormats[this.comboBoxFVPFormat.SelectedItem.ToString()]))) { l_i_FilterIndex = l_i_FilterCount; } l_i_FilterCount++; } if (CurrentDeviceLayoutConfig.FVPTemplatesSupported) { l_x_FilterTemplates[l_i_FilterCount] = CurrentDeviceLayoutConfig.FVPTemplateFormats[CurrentDeviceLayoutConfig.FVPTemplateDefaultValue]; if (l_i_FilterIndex == -1) { l_i_FilterIndex = l_x_FilterTemplates[CurrentDeviceLayoutConfig.FVPTemplateFormats[CurrentDeviceLayoutConfig.FVPTemplateDefaultValue]]; } } else { l_x_FilterTemplates[l_i_FilterCount] = CurrentDeviceLayoutConfig.FPTemplateFormats[CurrentDeviceLayoutConfig.FPTemplateDefaultValue]; if (l_i_FilterIndex == -1) { l_i_FilterIndex = l_x_FilterTemplates[CurrentDeviceLayoutConfig.FPTemplateFormats[CurrentDeviceLayoutConfig.FPTemplateDefaultValue]]; } } l_x_Filter += "All Files (*.*)|*.*"; dlg.Filter = l_x_Filter; dlg.FilterIndex = l_i_FilterIndex; if (dlg.ShowDialog() != DialogResult.OK) { //Cancel by User return; } //Open Template FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read); Byte[] reference_template = new Byte[(int)fs.Length]; fs.Read(reference_template as Byte[], 0, (int)fs.Length); fs.Close(); //Init Acquisition Component InitAcquisition(ref GenericAcqComponent); // Retrieve the template format selected by user for the reference template TemplateFormat l_e_ReferenceTemplateFormat = l_x_FilterTemplates[dlg.FilterIndex]; // Backup the previous template format value TemplateFormat l_e_PreviousTemplateFormat = GenericAcqComponent.TemplateFormat; // Set MorphoAcquisition template format to the reference template format GenericAcqComponent.TemplateFormat = l_e_ReferenceTemplateFormat; //Run Acquisition VerifyResult result = GenericAcqComponent.RunCaptureVerify(reference_template); // Restore MorphoAcquisition previous template format GenericAcqComponent.TemplateFormat = l_e_PreviousTemplateFormat; if ((result.Status != ErrorCodes.IED_NO_ERROR) && (result.Status != ErrorCodes.IED_ERR_NO_HIT)) { // Error happened (matching not done) MessageBox.Show(String.Format("Verification failed with error {0}.", result.Status), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (result.Status == ErrorCodes.IED_ERR_NO_HIT) { // Sensor returned NO_HIT MessageBox.Show("Authentication failed.", "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (this.CurrentComponentType == DeviceType.ACTIVE_MACI) { // MorphoAccess does not indicate the matching score so it is not pertinent to check it MessageBox.Show("Authentication succeeded.", "Authentication succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result.AuthenticationScore >= Convert.ToInt16(textBoxAuthent.Text)) { // Other wise, we check the matching score MessageBox.Show(String.Format("Authentication succeeded, score : {0}", result.AuthenticationScore), "Authentication succeeded", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // This should never happen MessageBox.Show(String.Format("Authentication failed, score : {0}", result.AuthenticationScore), "Authentication failed", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception exc) { MessageBox.Show(exc.Message, exc.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Execute(BasePage Context) { TemplateFormat xf = new TemplateFormat(Context); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Dictionary <String, Object> DictFiles = new Dictionary <string, object>(); //创建 DownloadFile 查询的浅度拷贝 var DownloadFileQP = SqlQueryTable(xf, Context); //Cookie中保存的最后点击事件 var ClickTime = GetCookieClickTime(EnumDisplayModuleType.Downloads.ToString()); if (ClickTime != DateTime.MinValue) { DownloadFileQP.Where.Add(new SearchParam("StartTime", ClickTime, SearchType.GtEqual)); } DictFiles.Add("DownloadFileCount", Playngo_ClientZone_DownloadFile.FindCount(DownloadFileQP)); //创建 Campaign 查询的浅度拷贝 var CampaignQP = SqlQueryTable(xf, Context); //Cookie中保存的最后点击事件 ClickTime = GetCookieClickTime(EnumDisplayModuleType.Campaigns.ToString()); if (ClickTime != DateTime.MinValue) { CampaignQP.Where.Add(new SearchParam("StartTime", ClickTime, SearchType.GtEqual)); } DictFiles.Add("CampaignCount", Playngo_ClientZone_Campaign.FindCount(CampaignQP)); //创建 Event 查询的浅度拷贝 var EventQP = SqlQueryTable(xf, Context); //Cookie中保存的最后点击事件 ClickTime = GetCookieClickTime(EnumDisplayModuleType.Events.ToString()); if (ClickTime != DateTime.MinValue) { EventQP.Where.Add(new SearchParam("StartTime", ClickTime, SearchType.GtEqual)); } DictFiles.Add("EventCount", Playngo_ClientZone_Event.FindCount(EventQP)); //创建 GameSheet 查询的浅度拷贝 var GameSheetQP = SqlQueryTable(xf, Context); //Cookie中保存的最后点击事件 ClickTime = GetCookieClickTime(EnumDisplayModuleType.GameSheets.ToString()); if (ClickTime != DateTime.MinValue) { GameSheetQP.Where.Add(new SearchParam("StartTime", ClickTime, SearchType.GtEqual)); } DictFiles.Add("GameSheetCount", Playngo_ClientZone_GameSheet.FindCount(GameSheetQP)); ResponseString = jsSerializer.Serialize(DictFiles); }
public void Execute(BasePage Context) { var FileList = new List <Playngo_ClientZone_DownloadFile>(); //将文件列表取出 String FileIds = WebHelper.GetStringParam(Context.Request, "FileIds", ""); if (!String.IsNullOrEmpty(FileIds)) { FileIds = FileIds.Trim(','); if (!String.IsNullOrEmpty(FileIds)) { FileList = Playngo_ClientZone_DownloadFile.FindAllByIds(FileIds); } } //待打包的文件路径 var FilePathList = new List <String>(); if (FileList != null && FileList.Count > 0) { //将文件的路径收集着 foreach (var FileItem in FileList) { if (FileItem != null && FileItem.ID > 0 && !String.IsNullOrEmpty(FileItem.Options)) { if (Context.IsPreRoleView(FileItem.Per_AllUsers, FileItem.Per_Roles) && Context.IsPreJurisdictionView(FileItem.Per_AllJurisdictions, FileItem.Per_Jurisdictions)) { var FileItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(FileItem.Options); if (FileItemOptions != null) { TemplateFormat xf = new TemplateFormat(Context); String UploadFile = xf.GetFilePath(xf.ViewItemSettingT <String>(FileItem.Options, "UploadFile", ""), Context); if (!String.IsNullOrEmpty(UploadFile)) { UploadFile = Context.Server.MapPath(UploadFile); if (File.Exists(UploadFile) && !FilePathList.Exists(r => r.ToLower() == UploadFile.ToLower())) { FilePathList.Add(UploadFile); } } } } else { //没有权限下载 } } } if (FilePathList != null && FilePathList.Count > 0) { //整理压缩包文件路径等信息 String ZipPath = Context.Server.MapPath(String.Format("{0}ClientZone/temporary/download-{1}files-{2}.zip", Context.PortalSettings.HomeDirectory, FilePathList.Count, DateTime.Now.ToString("yyyyMMdd-Hms"))); FileInfo ZipFile = new FileInfo(ZipPath); if (!ZipFile.Directory.Exists) { ZipFile.Directory.Create(); } else { //清楚很多天前的文件 FileSystemUtils.ClearFiles(ZipFile.Directory, 1); } //创建压缩包 FileSystemUtils.CreateZipFiles(FilePathList, ZipPath); //将压缩好的文件列表下载 FileSystemUtils.DownloadFile(ZipPath, Path.GetFileName(ZipPath)); } else { IsResponseWrite = true; ResponseString = "No files found."; } } }
public void Execute(BasePage Context) { JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>(); String ImageIds = WebHelper.GetStringParam(Context.Request, "Images", ""); if (!String.IsNullOrEmpty(ImageIds)) { QueryParam qp = new QueryParam(); qp.Orderfld = Playngo_ClientZone_Files._.ID; qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1); qp.PageSize = WebHelper.GetIntParam(Context.Request, "PageSize", Int32.MaxValue); qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.Status, (Int32)EnumFileStatus.Approved, SearchType.Equal)); qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.PortalId, Context.PortalId, SearchType.Equal)); qp.Where.Add(new SearchParam(Playngo_ClientZone_Files._.ID, ImageIds.Trim(','), SearchType.In)); int RecordCount = 0; List <Playngo_ClientZone_Files> fileList = Playngo_ClientZone_Files.FindAll(qp, out RecordCount); TemplateFormat xf = new TemplateFormat(); foreach (var fileItem in fileList) { int index = fileList.IndexOf(fileItem); //index 为索引值 Dictionary <String, Object> jsonPicture = new Dictionary <String, Object>(); jsonPicture.Add("Pages", qp.Pages); jsonPicture.Add("ID", fileItem.ID); jsonPicture.Add("CreateTime", fileItem.LastTime); jsonPicture.Add("Name", WebHelper.leftx(fileItem.Name, 20, "...")); jsonPicture.Add("Extension", fileItem.FileExtension); String ThumbnailUrl = Context.ViewLinkUrl(String.Format("MediaID={0}", fileItem.ID)); jsonPicture.Add("ThumbnailUrl", ThumbnailUrl); jsonPicture.Add("FileUrl", Context.GetPhotoPath(fileItem.FilePath)); jsonPicture.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\" src=\"{0}\" /> ", ThumbnailUrl)); //判断当前文件是否为图片 if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("gif,jpg,jpeg,bmp,png").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsVideo", false); jsonPicture.Add("IsPicture", true); } else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("mp4,mkv,avi,ogv,webm,m4v").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsVideo", true); jsonPicture.Add("IsPicture", false); switch (fileItem.FileExtension) { case "mp4": jsonPicture.Add("IsMp4", true); break; case "m4v": jsonPicture.Add("IsM4v", true); break; case "ogv": jsonPicture.Add("IsOgv", true); break; case "webm": jsonPicture.Add("IsWebm", true); break; default: break; } } else if (!String.IsNullOrEmpty(fileItem.FileExtension) && ("flv,swf").IndexOf(fileItem.FileExtension, StringComparison.CurrentCultureIgnoreCase) >= 0) { jsonPicture.Add("IsFlash", true); jsonPicture.Add("IsPicture", false); jsonPicture.Add("Guid", Guid.NewGuid().ToString()); } else { jsonPicture.Add("IsVideo", false); jsonPicture.Add("IsPicture", false); } jsonPicture.Add("Json", jsSerializer.Serialize(jsonPicture)); jsonPictures.Add(index.ToString(), jsonPicture); } jsonPictures.Add("ResultCount", jsonPictures.Count); jsonPictures.Add("Result", "success"); } else { jsonPictures.Add("ResultCount", 0); jsonPictures.Add("Result", "error"); } //转换数据为json ResponseString = jsSerializer.Serialize(jsonPictures); }
/// <summary> /// 获取Form传值 /// </summary> /// <param name="fieldItem"></param> /// <returns></returns> public String GetWebFormValue(DNNGo_PowerForms_Field fieldItem) { String WebFormValue = String.Empty; //创建控件的Name和ID TemplateFormat xf = new TemplateFormat(this); String ControlName = xf.ViewControlName(fieldItem); String ControlID = xf.ViewControlID(fieldItem); if (fieldItem.FieldType == (Int32)EnumViewControlType.CheckBox) { WebFormValue = WebHelper.GetStringParam(Request, ControlName, ""); WebFormValue = !String.IsNullOrEmpty(WebFormValue) && WebFormValue == "on" ? "true" : "false"; } else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload) { if (Request.Files != null && Request.Files.Count > 0) { HttpPostedFile hpFile = Request.Files.Get(ControlName); if (hpFile != null && hpFile.ContentLength > 0) { //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements Boolean retValue = FileSystemUtils.CheckValidFileName(hpFile.FileName); if (retValue) { WebFormValue = String.Format("Url://{0}", FileSystemUtils.UploadFile(hpFile, this));//存放到目录中,并返回 } } } } else if (fieldItem.FieldType == (Int32)EnumViewControlType.MultipleFilesUpload) { String WebUploads = WebHelper.GetStringParam(Request, ControlName, ""); if (!String.IsNullOrEmpty(WebUploads) && WebUploads != "[]") { List <Resource_FilesStatus> Uploads = jsSerializer.Deserialize <List <Resource_FilesStatus> >(WebUploads); if (Uploads != null && Uploads.Count > 0) { List <String> fileurls = new List <string>(); foreach (var UploadFile in Uploads) { fileurls.Add(String.Format("Url://{0}", FileSystemUtils.CopyFile(UploadFile, this))); } WebFormValue = Common.GetStringByList(fileurls, "<|>"); } } } else if (fieldItem.FieldType == (Int32)EnumViewControlType.DropDownList_Country) { var tempWebFormValue = WebHelper.GetStringParam(HttpContext.Current.Request, ControlName, ""); var Countrys = new ListController().GetListEntryInfoItems("Country"); foreach (var Country in Countrys) { if (Country.Value == tempWebFormValue) { WebFormValue = Country.Text; break; } } } else { WebFormValue = WebHelper.GetStringParam(Request, ControlName, ""); if (!(fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox)) { //非富文本框时,需要过滤掉XSS特殊字符 WebFormValue = Common.LostXSS(WebFormValue); } //如果提示的值和输入的值一样的情况,就过滤掉该值 *** 有点争议的地方 if (WebFormValue == fieldItem.ToolTip && fieldItem.DefaultValue != WebFormValue) { WebFormValue = string.Empty; } } return(WebFormValue); }
/// <summary> /// 格式化内容模版 /// </summary> /// <param name="SubmitContent">提交的内容实体</param> /// <param name="Template">模版</param> /// <returns></returns> public String FormatContent(DNNGo_PowerForms_Content SubmitContent, String Template, List <DNNGo_PowerForms_ContentItem> ContentList) { TemplateFormat xf = new TemplateFormat(this); xf.FieldList = FieldList; if (!String.IsNullOrEmpty(Template)) { //为了节约效率,需要先判断模版内有无需要替换的标签 if (Template.IndexOf("[UserName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserName]", SubmitContent.UserName); } if (Template.IndexOf("[CultureInfo]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[CultureInfo]", SubmitContent.CultureInfo); } if (Template.IndexOf("[SubmitTime]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitTime]", SubmitContent.LastTime.ToString()); } if (Template.IndexOf("[SubmitIP]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitIP]", SubmitContent.LastIP); } if (Template.IndexOf("[Email]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[Email]", SubmitContent.Email); } //if (Template.IndexOf("[]", StringComparison.CurrentCultureIgnoreCase) >= 0) Template = Common.ReplaceNoCase(Template, "[]", ""); //2014.4.30 新增更多用户的Token,但需要是用户登陆时提交的才行. if (SubmitContent.LastUser > 0) { DotNetNuke.Entities.Users.UserInfo uInfo = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, SubmitContent.LastUser); if (uInfo != null && uInfo.UserID > 0) { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", uInfo.DisplayName); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", uInfo.LastName); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", uInfo.FirstName); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", Common.GetStringByList(uInfo.Roles)); } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } //循环打印所有的字段值 foreach (DNNGo_PowerForms_ContentItem item in ContentList) { String item_key = String.Format("[{0}]", item.FieldName); if (Template.IndexOf(item_key, StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, item_key, xf.ViewContentValue(item)); } } if (Template.IndexOf("[Content]", StringComparison.CurrentCultureIgnoreCase) >= 0) { EffectDB EffectDB = Setting_EffectDB; Hashtable Puts = new Hashtable(); String FormUrl = Globals.NavigateURL(TabId); if (FormUrl.ToLower().IndexOf("http://") < 0 && FormUrl.ToLower().IndexOf("https://") < 0) { FormUrl = string.Format("{2}://{0}{1}", WebHelper.GetHomeUrl(), FormUrl, PortalSettings.SSLEnabled ? "https" : "http"); } Puts.Add("ContentList", ContentList); Puts.Add("FieldList", FieldList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("Group", EffectDB.Group);//有分组的时候才会显示分组 Puts.Add("FormUrl", FormUrl); Puts.Add("FormTitle", ModuleConfiguration.ModuleTitle); Puts.Add("ExtraTracking", Settings_ExtraTracking);//是否启用跟踪 Template = Common.ReplaceNoCase(Template, "[Content]", ViewTemplate(EffectDB, "EmailTable.html", Puts, xf)); } } return(Template); }
/// <Description> /// 绑定页面项 /// </Description> private void BindPageItem() { //链接 String Element_UrlLink = FieldItem != null ? FieldItem.DefaultValue : String.Empty; //imgUrlLink.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/1-1.png'", ModulePath)); WebHelper.BindList <TabInfo>(ddlUrlLink, TabController.GetPortalTabs(PortalId, Null.NullInteger, true, true, false, false), "IndentedTabName", "TabId"); List <EnumEntity> EnumList = EnumHelper.GetEnumList(typeof(EnumUrlControls)); //设置和选择哪些类型可以显示出来 if (!String.IsNullOrEmpty(FieldItem.ListContent)) { if (!FindUrlType(FieldItem.ListContent, "U")) { EnumList.RemoveAll(r => r.Value == 1); } if (!FindUrlType(FieldItem.ListContent, "P")) { EnumList.RemoveAll(r => r.Value == 2); } if (!FindUrlType(FieldItem.ListContent, "F")) { EnumList.RemoveAll(r => r.Value == 3); } if (EnumList.Count == 1) { rblUrlLink.Visible = false; } WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value"); String defaultType = WebHelper.leftx(FieldItem.ListContent, 1).ToUpper(); if (!String.IsNullOrEmpty(defaultType)) { ShowHideControl(defaultType); } } else { WebHelper.BindList <EnumEntity>(rblUrlLink, EnumList, "Text", "Value"); ShowHideControl("U"); } if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("TabID=", StringComparison.CurrentCultureIgnoreCase) == 0) { WebHelper.SelectedListByValue(ddlUrlLink, Element_UrlLink.Replace("TabID=", "")); //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Page); //txtUrlLink.Attributes.Add("style", "display:none"); //panUrlLink.Attributes.Add("style", "display:none"); ShowHideControl("P"); } else if (!String.IsNullOrEmpty(Element_UrlLink) && Element_UrlLink.IndexOf("MediaID=", StringComparison.CurrentCultureIgnoreCase) == 0) { TemplateFormat xf = new TemplateFormat(this); hfUrlLink.Value = Element_UrlLink; //imgUrlLink.ImageUrl = xf.ViewLinkUrl(Element_UrlLink); div_Image.Attributes.Add("data-MediaID", Element_UrlLink); ShowHideControl("F"); //hlRemoveUrlLink.Attributes.Add("style", "display:;"); //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Files); //txtUrlLink.Attributes.Add("style", "display:none"); //ddlUrlLink.Attributes.Add("style", "display:none"); } else { if (!String.IsNullOrEmpty(Element_UrlLink)) { if (Element_UrlLink.IndexOf("FileID=", StringComparison.CurrentCultureIgnoreCase) == 0) { int FileID = 0; if (int.TryParse(Element_UrlLink.Replace("FileID=", ""), out FileID) && FileID > 0) { var fi = DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(FileID); if (fi != null && fi.FileId > 0) { txtUrlLink.Text = string.Format("{0}{1}{2}", PortalSettings.HomeDirectory, fi.Folder, Server.UrlPathEncode(fi.FileName)); } } } else { txtUrlLink.Text = Element_UrlLink; } ShowHideControl("U"); } //WebHelper.SelectedListByValue(rblUrlLink, (Int32)EnumUrlControls.Url); //ddlUrlLink.Attributes.Add("style", "display:none"); //panUrlLink.Attributes.Add("style", "display:none"); } }
public void Execute(BasePage Context) { Int32 RecordCount = 0; Dictionary <String, Object> jsonData = new Dictionary <string, Object>(); List <Dictionary <String, Object> > DictDataList = new List <Dictionary <string, object> >(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); TemplateFormat xf = new TemplateFormat(Context); //创建数据查询类 var dal = DAL.Create(Playngo_ClientZone_Event.Meta.ConnName); System.Text.StringBuilder SQLQuery = new System.Text.StringBuilder(); var StrIncludedSections = xf.ViewSettingT <String>("Roadmap_IncludedSections", "0,2,3"); if (!String.IsNullOrEmpty(StrIncludedSections)) { var IncludedSections = Common.GetList(StrIncludedSections); if (IncludedSections != null && IncludedSections.Count > 0) { //开始拼接联合查询的SQL if (IncludedSections.Exists(r => r == ((Int32)EnumIncludedSections.Events).ToString())) { SQLQuery.Append(SqlQueryTable("Events", Playngo_ClientZone_Event.Meta.TableName, false, Context)); } if (IncludedSections.Exists(r => r == ((Int32)EnumIncludedSections.Downloads).ToString())) { if (SQLQuery.Length > 0) { SQLQuery.Append(" UNION "); } SQLQuery.Append(SqlQueryTable("Downloads", Playngo_ClientZone_DownloadFile.Meta.TableName, true, Context)); } if (IncludedSections.Exists(r => r == ((Int32)EnumIncludedSections.Campaigns).ToString())) { if (SQLQuery.Length > 0) { SQLQuery.Append(" UNION "); } SQLQuery.Append(SqlQueryTable("Campaigns", Playngo_ClientZone_Campaign.Meta.TableName, true, Context)); } if (IncludedSections.Exists(r => r == ((Int32)EnumIncludedSections.GameSheets).ToString())) { if (SQLQuery.Length > 0) { SQLQuery.Append(" UNION "); } SQLQuery.Append(SqlQueryTable("GameSheets", Playngo_ClientZone_GameSheet.Meta.TableName, true, Context)); } SQLQuery.Append(" ORDER BY ReleaseDate ASC "); //将拼接的SQL获取数据集 String SQLString = SQLQuery.ToString(); var DataSets = dal.Select(dal.PageSplit(SQLString, 0, xf.ViewSettingT <Int32>("General.ProductRoadmap.Pagings", 10), "ID"), "ProductRoadmap"); RecordCount = dal.SelectCount(SQLString, "ProductRoadmap"); //开始解析数据集 if (DataSets != null && DataSets.Tables != null && DataSets.Tables.Count > 0 && DataSets.Tables[0].Rows != null) { var Rows = DataSets.Tables[0].Rows; var Columns = DataSets.Tables[0].Columns; if (Rows.Count > 0) { foreach (DataRow Row in Rows) { Dictionary <String, Object> DictDataItem = new Dictionary <string, object>(); Int32 ItemId = 0; if (Int32.TryParse(Row["ID"].ToString(), out ItemId)) { var TableName = Convert.ToString(Row["TableName"]); DictDataItem.Add("TableName", TableName); //调用不同的数据读取程序 if (TableName == "Events") { DictDataItem = GetDictDataItemsByEvents(DictDataItem, ItemId, Context); } else if (TableName == "Downloads") { DictDataItem = GetDictDataItemsByDownloadFiles(DictDataItem, ItemId, Context); } else if (TableName == "Campaigns") { DictDataItem = GetDictDataItemsByCampaigns(DictDataItem, ItemId, Context); } else if (TableName == "GameSheets") { DictDataItem = GetDictDataItemsByGameSheets(DictDataItem, ItemId, Context); } } DictDataList.Add(DictDataItem); } } } } } jsonData.Add("RecordCount", RecordCount); jsonData.Add("DataCount", DictDataList.Count); jsonData.Add("data", DictDataList); //转换数据为json ResponseString = jsSerializer.Serialize(jsonData); }