public FileBrowserViewModel(SftpDataSource dataSource, CoreDispatcher dispatcher, bool showAds) : base(dispatcher) { this.DataSource = dataSource; this.FileSelectionMode = ListViewSelectionMode.None; this.AreFilesClickable = true; this.Host = "Kleeshee SFTP Client"; if (showAds) { #if DEBUG var fileAd = new AdItem { Id = 0, Serving = false }; var folderAd = new AdItem { Id = 1, Serving = false }; #else var fileAd = new AdItem { Id = 0, Serving = true }; var folderAd = new AdItem { Id = 1, Serving = true }; #endif this.Files.Add(fileAd); this.Folders.Add(folderAd); } }
public override void Layout() { load("topNav", new TopNavController().IndexNew); load("header", new TopNavController().Header); set("statsJs", config.Instance.Site.GetStatsJs()); set("adFooter", AdItem.GetAdById(AdCategory.Footer)); set("adLoadLink", to(new AdLoaderController().Index)); bindCommon(); bindSiteSkin(); set("siteBeiAn", config.Instance.Site.BeiAn); set("copyright", lang("siteCopyright")); set("ramsize", lang("memoryUse") + ": " + (((Environment.WorkingSet / 1024) / 1024)) + " MB"); List <FooterMenu> menus = FooterMenu.GetAll(); bindFooterMenus(menus); set("customSkinLink", to(new Admin.SiteSkinController().CustomBg)); }
private void Bind() { var adId = Guid.Empty; if (!string.IsNullOrWhiteSpace(Request.QueryString["adId"])) { Guid.TryParse(Request.QueryString["adId"], out adId); } if (adId.Equals(Guid.Empty)) { MessageBox.Messager(this.Page, "请先完成基本信息后再进行此操作", MessageContent.AlertTitle_Error, "error"); return; } hAdId.Value = adId.ToString(); //查询条件 GetSearchItem(); int totalRecords = 0; AdItem bll = new AdItem(); rpData.DataSource = bll.GetDsByJoinForAdmin(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataBind(); myDataAppend.Append("<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"); }
private void Bind() { Guid adItemId = Guid.Empty; if (!string.IsNullOrWhiteSpace(Request.QueryString["adItemId"])) { Guid.TryParse(Request.QueryString["adItemId"], out adItemId); } if (!adItemId.Equals(Guid.Empty)) { ddlActionType.Enabled = false; AdItem bll = new AdItem(); var model = bll.GetModelByJoin(adItemId); if (model == null) { MessageBox.Messager(this.Page, MessageContent.GetString(MessageContent.Submit_Data_NotExists, "广告项ID【" + adItemId + "】"), MessageContent.AlertTitle_Ex_Error, "error"); return; } hAdItemId.Value = model.Id.ToString(); hImgPictureId.Value = model.PictureId.ToString(); imgPicture.Src = PictureUrlHelper.GetMPicture(model.FileDirectory, model.RandomFolder, model.FileExtension); var li = ddlActionType.Items.FindByValue(model.ActionTypeId.ToString()); if (li != null) { li.Selected = true; } txtSort.Value = model.Sort.ToString(); cbIsDisable.Checked = model.IsDisable; ltrMyOldData.Text = "<span id=\"myOldData\" style=\"display:none;\">{\"PictureId\":\"" + model.PictureId + "\",\"ActionTypeId\":\"" + model.ActionTypeId + "\",\"Sort\":\"" + model.Sort + "\",\"IsDisable\":\"" + model.IsDisable + "\"}</span>"; } }
private async void ExcecuteHyperlink(string adId) { int id = int.Parse(adId); AdItem adItem = Ads.First(ad => ad.Id == id); await Launcher.OpenAsync(new Uri(adItem.Link)); }
public ActionResult RemoveAdItem(int id) { AdItem adItem = _context.AdItens.Single(a => a.Id == id); _context.AdItens.Remove(adItem); _context.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> AdItemDetail(int moduleId, int id, AdItem model) { var now = DateTime.Now; var result = new Result(); if (model.Name.IsNullOrEmpty()) { result.Error("请输入名称"); return(Json(result)); } if (model.Title.IsNullOrEmpty()) { result.Error("请输入标题"); return(Json(result)); } if (id > 0) { var old = DefaultStorage.AdItemGet(id); if (old == null) { result.Message = "数据不存在"; return(Json(result)); } var status = await TryUpdateModelAsync(old); if (status) { result.Status = DefaultStorage.AdItemUpdate(old); if (!result.Status) { result.Message = "更新失败"; } } else { result.Message = "参数有误"; } return(Json(result)); } model.ModuleId = moduleId; model.CreatedOn = now; model.ModifiedBy = string.Empty; model.ModifiedOn = now; var newId = DefaultStorage.AdItemCreate(model); if (result.Status = newId > 0) { result.Success(); } return(Json(result)); }
public ActionResult Sell(AdItem adItem) { AdItem adItemMod = _context.AdItens.Single(a => a.Id == adItem.Id); adItemMod.ClosedAt = DateTime.Now; _context.Entry(adItemMod).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AcceptAdItem(int id) { AdItem adItem = _context.AdItens.Single(a => a.Id == id); adItem.PostedAt = DateTime.Now; _context.Entry(adItem).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("VerifyAdItens")); }
public ActionResult CancelSell(int id) { AdItem adItem = _context.AdItens.Single(a => a.Id == id); adItem.Buyer = null; adItem.BuyerId = null; _context.Entry(adItem).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(AdItemFormViewModel viewModel) { Console.WriteLine(viewModel.Category); try { if (!ModelState.IsValid) { viewModel.States = _context.States.ToList(); viewModel.Categories = _context.Categories.ToList(); return(View("Create", viewModel)); } var adItem = new AdItem { OwnerId = User.Identity.GetUserId(), CategoryId = viewModel.Category, Title = viewModel.Title, CityId = viewModel.City, Description = viewModel.Description, flagNew = viewModel.flagNew, StateId = viewModel.State, Price = viewModel.Price, PostedAt = viewModel.PostedAt }; var file = viewModel.ImageUpload[0]; if (!(file == null || file.ContentLength == 0)) { var imagem = new Images { FileName = System.IO.Path.GetFileName(file.FileName), FileType = FileType.ProductImage, ContentType = file.ContentType }; using (var reader = new System.IO.BinaryReader(file.InputStream)) { imagem.Content = reader.ReadBytes(file.ContentLength); } adItem.Images = new List <Images> { imagem }; } _context.AdItens.Add(adItem); _context.SaveChanges(); } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(RedirectToAction("MyAdItens", "AdItem")); }
public void Delete(int id) { AdItem item = AdItem.findById(id); if (item == null) { echoError("广告不存在"); } else { item.delete(); echoRedirectPart(lang("opok")); } }
public ActionResult Buy(AdItem adItem) { string Userid = User.Identity.GetUserId(); ApplicationUser Buyer = _context.Users.Single(u => u.Id == Userid); AdItem adItemMod = _context.AdItens.Single(a => a.Id == adItem.Id); adItemMod.Buyer = Buyer; adItemMod.BuyerId = Buyer.Id; _context.Entry(adItemMod).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); }
public void Start(int id) { AdItem item = AdItem.findById(id); if (item == null) { echoError("广告不存在"); return; } item.IsStopped = 0; item.update(); echoRedirectPart(lang("opok")); }
public void Show(int id) { ContentPost post = this.postService.GetById(id, ctx.owner.Id); if (post == null) { echoRedirect(lang("exDataNotFound")); return; } ctx.SetItem("ContentPost", post); bindDetail(id, post); set("post.AdBody", AdItem.GetAdById(AdCategory.ArticleInner)); }
//------------------------------------------------------------------------------------------------------------- public void Header() { set("site.Name", Site.Instance.Name); set("site.Logo", config.Instance.Site.GetLogoHtml()); set("adBanner", AdItem.GetAdById(AdCategory.Banner)); set("adNavBottom", AdItem.GetAdById(AdCategory.NavBottom)); List <IMenu> list = menuService.GetList(Site.Instance); IMenu currentRootMenu = bindSubMenus(list); bindNavList(list, currentRootMenu); //List<Dictionary<string, string>> langs = wojilu.lang.GetSupportedLang(); //bindList( "langs", "lang", langs, bindLang ); }
private void bindCategories(List <ForumBoard> categories) { IBlock fcategoryBlock = getBlock("forumCategory"); foreach (ForumBoard board in categories) { List <ForumBoard> boards = getTree().GetChildren(board.Id); ctx.SetItem("currentBoard", board); ctx.SetItem("childForumBoards", boards); fcategoryBlock.Set("childrenBoards", loadHtml(new BoardController().List)); fcategoryBlock.Set("adForumBoards", AdItem.GetAdById(AdCategory.ForumBoards)); fcategoryBlock.Next(); } }
public void Create( ) { AdItem item = ctx.PostValue <AdItem>(); validateItem(item); if (ctx.HasErrors) { echoError(); return; } item.Creator = ctx.viewer.obj as User; item.insert(); echoToParentPart(lang("opok")); }
private void validateItem(AdItem item) { if (strUtil.IsNullOrEmpty(ctx.Post("adItem.StartTime"))) { item.StartTime = new DateTime(1900, 1, 1); } if (strUtil.IsNullOrEmpty(ctx.Post("adItem.EndTime"))) { item.EndTime = new DateTime(2999, 1, 1); } item.AdCode = ctx.PostHtmlAll("adItem.AdCode"); if (strUtil.IsNullOrEmpty(item.Name)) { errors.Add("请填写名称"); } }
public void Edit(int id) { target(Update, id); AdItem item = AdItem.findById(id); if (item == null) { echoError("广告不存在"); return; } set("categoryId", item.CategoryId); set("adCode", strUtil.EncodeTextarea(item.AdCode)); dropList("adItem.ScopeId", cdb.findAll <AdScope>(), "Name=Id", item.ScopeId); bind("item", item); }
private void bindTopicOne(IBlock block, ForumPost data, List <Attachment> attachList) { String quoteLink = Link.To(new Users.PostController().QuoteTopic, data.TopicId) + "?boardId=" + data.ForumBoardId; String replyLink = Link.To(new Users.PostController().ReplyTopic, data.TopicId) + "?boardId=" + data.ForumBoardId; String topicUrl = LinkUtil.appendListPageToTopic(Link.To(new TopicController().Show, data.TopicId), ctx); block.Set("post.ReplyQuoteUrl", quoteLink); block.Set("post.ReplyUrl", replyLink); block.Set("post.TitleStyle", string.Empty); block.Set("post.PostUrl", topicUrl); String content = getTopicContent(data, attachList); block.Set("post.Body", content); block.Set("post.PostFullUrl", getFullUrl(topicUrl)); block.Set("post.AdBody", AdItem.GetAdById(AdCategory.ForumTopicInner)); block.Set("nofollow", ""); }
public override void Layout() { ContentApp app = ctx.app.obj as ContentApp; ContentSetting s = app.GetSettingsObj(); List <ContentPost> posts = postService.GetRankPost(ctx.app.Id, s.RankPosts, PostCategory.Post); bindPosts(posts, "list"); List <ContentPost> imgs = postService.GetRankPost(ctx.app.Id, s.RankPics, PostCategory.Img); bindImgs(imgs, "img"); List <ContentPost> videos = postService.GetRankPost(ctx.app.Id, s.RankVideos, PostCategory.Video); bindVideos(videos, "video"); set("adSidebarTop", AdItem.GetAdById(AdCategory.ArticleSidebarTop)); set("adSidebarBottom", AdItem.GetAdById(AdCategory.ArticleSidebarBottom)); }
public void Index() { String ads = ctx.Post("adItems"); if (strUtil.IsNullOrEmpty(ads)) { echoError("无效的ad"); return; } Dictionary <String, String> map = new Dictionary <string, string>(); String[] arr = ads.Split(','); foreach (String item in arr) { map[item] = AdItem.GetAdByName(item); } echoJson(JsonString.ConvertDictionary(map)); }
private void bindPostOne(IBlock block, ForumPost data, List <Attachment> attachList) { String quoteLink = Link.To(new Users.PostController().QuotePost, data.Id) + "?boardId=" + data.ForumBoardId; String replyLink = Link.To(new Users.PostController().ReplyPost, data.Id) + "?boardId=" + data.ForumBoardId; String postUrl = alink.ToAppData(data); block.Set("post.ReplyQuoteUrl", quoteLink); block.Set("post.ReplyUrl", replyLink); block.Set("post.TitleStyle", "font-weight:normal"); block.Set("post.PostUrl", postUrl); String content = getPostContent(data, attachList); block.Set("post.Body", content); block.Set("post.PostFullUrl", getFullUrl(postUrl)); block.Set("post.AdBody", AdItem.GetAdById(AdCategory.ForumTopicInner)); block.Set("nofollow", "rel=\"nofollow\""); }
public override void Layout() { // load( "topNav", new TopNavController().Index ); load("header", new TopNavController().Header); set("statsJs", config.Instance.Site.GetStatsJs()); set("adFooter", AdItem.GetAdById(AdCategory.Footer)); set("adLoadLink", to(new AdLoaderController().Index)); bindCommon(); bindSiteSkin(); set("copyright", lang("siteCopyright")); set("ramsize", lang("memoryUse") + ": " + (((Environment.WorkingSet / 1024) / 1024)) + " MB"); List <FooterMenu> menus = FooterMenu.GetAll(); bindFooterMenus(menus); if (ctx.viewer.IsLogin) { User user = (User)ctx.viewer.obj; //User owner = ctx.owner.obj as User; set("RegLink", Link.T2(user, new UserProfileController().Profile)); set("labUserName", user.Name); set("LoginLink", Link.T2(Site.Instance, new MainController().Logout)); set("logStatus", "×¢Ïú"); } else { set("RegLink", Link.T2(Site.Instance, new RegisterController().Register)); set("labUserName", "×¢²á"); set("LoginLink", Link.T2(Site.Instance, new MainController().Login)); set("logStatus", "µÇ¼"); } set("customSkinLink", to(new Admin.SiteSkinController().CustomBg)); }
public void Update(int id) { AdItem item = AdItem.findById(id); if (item == null) { echoError("广告不存在"); return; } item = ctx.PostValue(item) as AdItem; validateItem(item); if (ctx.HasErrors) { echoError(); return; } item.update(); echoToParentPart(lang("opok")); }
private void validateItem( AdItem item ) { if (strUtil.IsNullOrEmpty( ctx.Post( "adItem.StartTime" ) )) item.StartTime = new DateTime( 1900, 1, 1 ); if (strUtil.IsNullOrEmpty( ctx.Post( "adItem.EndTime" ) )) item.EndTime = new DateTime( 2999, 1, 1 ); item.AdCode = ctx.PostHtmlAll( "adItem.AdCode" ); if (strUtil.IsNullOrEmpty( item.Name )) errors.Add( "请填写名称" ); if (strUtil.IsNullOrEmpty( item.AdCode )) errors.Add( "请填写广告代码" ); }
public ActionResult Sell(int id) { AdItem adItem = _context.AdItens.Single(a => a.Id == id); return(View(adItem)); }
public ActionResult Buy(int id) { AdItem adItem = _context.AdItens.Where(a => a.Id == id).FirstOrDefault(); return(View(adItem)); }
public void PostLoop() { List <ForumPost> posts = ctx.GetItem("posts") as List <ForumPost>; List <Attachment> attachs = ctx.GetItem("attachs") as List <Attachment>; int pageSize = cvt.ToInt(ctx.GetItem("pageSize")); ForumBoard board = ctx.GetItem("forumBoard") as ForumBoard; ForumTopic topic = ctx.GetItem("forumTopic") as ForumTopic; IBlock block = getBlock("posts"); for (int i = 0; i < posts.Count; i++) { ForumPost data = posts[i]; if (data.Creator == null) { continue; } populatePostTopic(data); block.Set("post.Id", data.Id); block.Set("post.TopicId", data.TopicId); block.Set("post.MemberName", data.Creator.Name); block.Set("post.MemberUrl", toUser(data.Creator)); String face = ""; if (strUtil.HasText(data.Creator.Pic)) { face = string.Format("<img src=\"{0}\"/>", data.Creator.PicMedium); } block.Set("post.MemberFace", face); block.Set("post.MemberRank", getRankStr(data)); block.Set("post.StarList", data.Creator.Rank.StarHtml); block.Set("post.IncomeList", data.Creator.IncomeInfo); block.Set("post.MemberTitle", getUserTitle(data)); block.Set("post.MemberGender", data.Creator.GenderString); block.Set("post.MemberPostCount", data.Creator.PostCount); block.Set("post.MemberCreateTime", data.Creator.Created.ToShortDateString()); block.Set("post.UserLastLogin", data.Creator.LastLoginTime.ToShortDateString()); String signature = strUtil.HasText(data.Creator.Signature) ? "<div class=\"posC\">" + data.Creator.Signature + "</div>" : ""; block.Set("post.UserSignature", signature); block.Set("post.OnlyOneMember", to(new TopicController().Show, data.TopicId) + "?userId=" + data.Creator.Id); block.Set("post.FloorNo", getFloorNumber(pageSize, i)); block.Set("post.Title", addRewardInfo(data, data.Title)); block.Set("post.TitleText", data.Title); block.Set("post.Admin", getAdminString(data)); block.Set("post.CreateTime", data.Created); List <Attachment> attachList = getAttachByPost(attachs, data.Id); if (data.ParentId == 0) { bindTopicOne(block, data, board, attachList); } else { bindPostOne(block, data, board, attachList); } block.Set("relativePosts", getRelativePosts(data)); block.Set("adForumPosts", AdItem.GetAdById(AdCategory.ForumPosts)); block.Next(); } }
/// <summary> /// 广告项提交 /// </summary> /// <param name="context"></param> private void SaveAdItem(HttpContext context) { try { Guid adId = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["adId"])) { Guid.TryParse(context.Request.Form["adId"], out adId); } if (adId.Equals(Guid.Empty)) { context.Response.Write("{\"success\": false,\"message\": \"请先完成基本信息\"}"); return; } if (string.IsNullOrWhiteSpace(context.Request.Form["ddlActionType"])) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}"); return; } Guid adItemId = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["hAdItemId"])) { Guid.TryParse(context.Request.Form["hAdItemId"], out adItemId); } Guid pictureId = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["hImgPictureId"])) { Guid.TryParse(context.Request.Form["hImgPictureId"], out pictureId); } Guid actionTypeId = Guid.Empty; if (!string.IsNullOrWhiteSpace(context.Request.Form["ddlActionType"])) { Guid.TryParse(context.Request.Form["ddlActionType"], out actionTypeId); } int sort = 0; if (!string.IsNullOrWhiteSpace(context.Request.Form["txtSort"])) { int.TryParse(context.Request.Form["txtSort"], out sort); } bool isDisable = false; if (!string.IsNullOrWhiteSpace(context.Request.Form["isDisable"])) { bool.TryParse(context.Request.Form["isDisable"], out isDisable); } AdItem bll = new AdItem(); AdItemInfo model = new AdItemInfo(); model.AdvertisementId = adId; model.Id = adItemId; model.PictureId = pictureId; model.ActionTypeId = actionTypeId; model.Sort = sort; model.IsDisable = isDisable; int effect = -1; if (!adItemId.Equals(Guid.Empty)) { var oldModel = bll.GetModel(adItemId); if (oldModel.ActionTypeId != model.ActionTypeId) { AdItemLink adlBll = new AdItemLink(); if (adlBll.Delete(adItemId) < 1) { AdItemContent adcBll = new AdItemContent(); adcBll.Delete(adItemId); } } else { effect = bll.Update(model); } } else { model.Id = Guid.NewGuid(); effect = bll.Insert(model); } if (effect == 110) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}"); return; } if (effect != 1) { context.Response.Write("{\"success\": false,\"message\": \"操作失败,原因:请正确输入并重试,如果再出现此问题请联系管理员\"}"); return; } context.Response.Write("{\"success\": true,\"message\": \"" + MessageContent.Submit_Success + "\",\"data\": \"" + model.Id + "\"}"); } catch (Exception ex) { context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.AlertTitle_Ex_Error + ":" + ex.Message + "\"}"); } }