protected void Page_Load(object sender, EventArgs e) { this.CheckFlags(); //update the flag links to point to the current page with a new language setting lnkLangEnglish.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=en"; lnkLangSpanish.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=es"; lnkLangPortuguese.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=pt"; lnkLangJapanese.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=ja"; if (((WebPage)this.Page).Locale == Locales.Japan) { //turn on sans-serif for japanese divMaster.Attributes["class"] = "Master Japanese"; } else { divMaster.Attributes["class"] = "Master"; } //TODO: show warning if cookies not enabled //(Must be done via reload) //Show editing info if admin is logged in if (AdminUtil.IsAdminLoggedIn()) { plhAdmin.Visible = true; } }
public ReplyController( IOptions <AppSettingsModel> appSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, BlogUtil blogUtil, ExpUtil expUtil, MessageUtil msgUtil, RatingUtil ratingUtil, IWebHostEnvironment env, IMemoryCache cache, ICompositeViewEngine viewEngine, IActionContextAccessor actionAccessor, HtmlSanitizerService sanitizerService) { _appSettings = appSettings.Value; _db = db; _udb = udb; _adminUtil = adminUtil; _blogUtil = blogUtil; _cache = cache; _env = env; _expUtil = expUtil; _ratingUtil = ratingUtil; _msgUtil = msgUtil; _viewEngine = viewEngine; _actionAccessor = actionAccessor; _sanitizerService = sanitizerService; }
protected void Page_Load(object sender, EventArgs e) { //toggle admin panel if logged in if (AdminUtil.IsAdminLoggedIn()) { plhAdmin.Visible = true; } //toggle link buttons if they aren't used switch (((TradingWebPage)this.Page).PageName) { case TradingPages.Contact: divLnkContact.Attributes["class"] = divLnkContact.Attributes["class"] + " Deactive"; lnkContact.NavigateUrl = ""; break; case TradingPages.Home: divLnkHome.Attributes["class"] = divLnkHome.Attributes["class"] + " Deactive"; lnkHome.NavigateUrl = ""; break; } //handle any flag clicks this.CheckFlags(); //update the flag links to point to the current page with a new language setting lnkLangEnglish.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=en"; lnkLangPortuguese.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=pt"; lnkLangJapanese.NavigateUrl = this.Request.Url.AbsolutePath + "?lang=ja"; }
public AdminController( IOptions <AppSettingsModel> appSettings, IOptionsSnapshot <RegisterSettingsModel> regSettings, IOptionsSnapshot <BackgroundSetting> bgSettings, IOptionsSnapshot <DataSettingsModel> dataSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, CategoryUtil catUtil, ExpUtil expUtil, MessageUtil msgUtil, UserManager <UserProfile> userManager, IMemoryCache cache, IWebHostEnvironment env, IServiceProvider serviceProvider) { _db = db; _udb = udb; _adminUtil = adminUtil; _catUtil = catUtil; _expUtil = expUtil; _msgUtil = msgUtil; _appSettings = appSettings.Value; _regSettings = regSettings.Value; _bgSettings = bgSettings.Value; _dataSettings = dataSettings.Value; _userManager = userManager; _cache = cache; _env = env; _serviceProvider = serviceProvider; }
public ListWindow() { InitializeComponent(); Instance = this; if (AdminUtil.IsRunAsAdmin()) { RegUtil.SelfRunning(); } WindowStartupLocation = WindowStartupLocation.CenterScreen; string appPath = System.Windows.Forms.Application.StartupPath; FileInfo[] files = new DirectoryInfo(appPath).GetFiles(); foreach (FileInfo file in files) { string fileName = file.Name.ToLower(); if (fileName.StartsWith("content-") && fileName.EndsWith(".txt")) { string time = fileName.Substring(8, 13); Trip trip = new Trip(time); MainWindow mainWindow = new MainWindow(trip); mainWindows.Add(mainWindow); listView.Items.Add(trip); mainWindow.Show(); } } InitialTray(); //一启动就最小化至托盘 }
public BlogController( IOptions <AppSettingsModel> appSettings, IOptionsSnapshot <DataSettingsModel> dataSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, BlogUtil blogUtil, CategoryUtil catUtil, MessageUtil msgUtil, TagUtil tagUtil, UserManager <UserProfile> userManager, UploadUtil uploadUtil, RatingUtil ratingUtil, IRecommendationProvider recommendationProvider, CacheService cacheService, IMemoryCache cache) { _db = db; _udb = udb; _adminUtil = adminUtil; _catUtil = catUtil; _blogUtil = blogUtil; _msgUtil = msgUtil; _appSettings = appSettings.Value; _dataSettings = dataSettings.Value; _userManager = userManager; _cache = cache; _uploadUtil = uploadUtil; _tagUtil = tagUtil; _ratingUtil = ratingUtil; _recommendationProvider = recommendationProvider; _cacheService = cacheService; }
protected void Page_Load(object sender, EventArgs e) { string id = Request["id"]; UserInfo user = AdminUtil.GetLoginUser(this); string html = MenuMessageDal.GetPreviewMenuMsgHtml(user, id); Response.Write(html); Response.End(); }
private static void VendorManuallyCreatesTransaction(Action <RemoteWebDriver> vendorActionBeforeCreatingTransaction, Action <RemoteWebDriver> transactionSubmitHandler) { var vendorScenario = new WithAVendorDBScenario(); var vendorEmail = "*****@*****.**"; var vendorPassword = "******"; using (var site = new KeyHubWebDriver()) { string editVendorUserUrl = null; SiteUtil.CreateLocalAccount(site, vendorEmail, vendorPassword, firstBrowser => { firstBrowser.FindElementByCssSelector("a[href='/Account/LogOff']"); firstBrowser.Navigate().GoToUrl(site.UrlFor("/Account")); editVendorUserUrl = firstBrowser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href"); }); // Log in as admin to give the new vendor account vendor permissions using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor(editVendorUserUrl)); SiteUtil.SubmitLoginForm(browser, "admin", "password"); AdminUtil.CreateAccountRightsFor(browser, vendorEmail, ObjectTypes.Vendor, vendorScenario.VendorName); } using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, vendorEmail, vendorPassword); vendorActionBeforeCreatingTransaction(browser); browser.Navigate().GoToUrl(site.UrlFor("/")); browser.FindElementByCssSelector("a[href='/Transaction/Create']").Click(); SiteUtil.SetValueForChosenJQueryControlMulti(browser, "div#Transaction_SelectedSKUGuids_chzn", vendorScenario.SkuCode); browser.FindElementByCssSelector("form[action^='/Transaction/Create'] input[type='submit']").Click(); transactionSubmitHandler(browser); var appKeyValue = GetAppKeyFromTransactionCompletePage(browser); LicenseValidatorTests.AssertRemoteValidationCheckPasses( site, "example.com", appKeyValue, vendorScenario.FeatureCode, vendorScenario.PublicKeyXml); } } }
public void CanManageVendorCredentials() { using (var site = new KeyHubWebDriver()) { using (var browser = BrowserUtil.GetBrowser()) { // Log in as pre-created admin user browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, "admin", "password"); // Create a vendor AdminUtil.CreateVendor(browser); // Create a VendorCredential for the vendor browser.FindElementByCssSelector("a[href^='/VendorCredential/Create']").Click(); var firstVendorCredentialName = "first vendor secret name"; var firstVendorCredentialValue = "vendor secret shared secret"; FillVendorCredentialForm(browser, firstVendorCredentialName, firstVendorCredentialValue); browser.FindElementByCssSelector("form[action^='/VendorCredential/Create'] input[type=submit]").Click(); // Make sure the VendorCredential was created, and edit it. var editButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Edit']"); Assert.Contains(firstVendorCredentialName, browser.PageSource); editButton.Click(); AssertVendorCredentialFormValues(browser, firstVendorCredentialName, firstVendorCredentialValue); var secondVendorCredentialName = "second vendor secret name"; var secondVendorCredentialValue = "second vendor secret"; FillVendorCredentialForm(browser, secondVendorCredentialName, secondVendorCredentialValue); browser.FindElementByCssSelector("form[action^='/VendorCredential/Edit'] input[type=submit]").Click(); // Check the VendorCredential edit page to ensure the edit saved editButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Edit']"); Assert.DoesNotContain(firstVendorCredentialName, browser.PageSource); Assert.Contains(secondVendorCredentialValue, browser.PageSource); editButton.Click(); AssertVendorCredentialFormValues(browser, secondVendorCredentialName, secondVendorCredentialValue); // Return to the Vendor edit page browser.FindElementByCssSelector("a[href^='/Vendor/Details']").Click(); // Remove the VendorCredential var removeButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Remove']"); removeButton.Click(); browser.FindElementByCssSelector("form[action^='/VendorCredential/Remove'] input[type=submit]").Click(); browser.FindElementByCssSelector(".success"); Assert.DoesNotContain(firstVendorCredentialName, browser.PageSource); Assert.DoesNotContain(secondVendorCredentialValue, browser.PageSource); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["lx"] == "1") { //do logout AdminUtil.Logout(); Response.Redirect("~", true); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); //验证代码 if (!AdminUtil.IsLogin(this)) { Response.Redirect("Login.aspx"); } }
/// <summary> /// 分页控件状态设置 /// </summary> protected void InitAspNetPager() { UserInfo user = AdminUtil.GetLoginUser(this); StringBuilder sb = new StringBuilder(); sb.AppendFormat("select count(1) from SWX_GroupPicture where OrgID='{0}'", user.OrgID); int count = int.Parse(MSSQLHelper.GetSingle(sb.ToString()).ToString()); this.AspNetPager.RecordCount = count; this.AspNetPager.PageSize = pageSize; }
public void btnSubmit_Click(object sender, EventArgs e) { if (AdminUtil.CheckLoginCredentials(txtUsername.Text, txtPassword.Text)) { //redirect to the home page Response.Redirect("~/", true); } else { //show error if invalid login this.lblError.Text = "Invalid username/password. <br>"; } }
public ReplyController( BlogContext db, AdminUtil adminUtil, BlogUtil blogUtil, RatingUtil ratingUtil, HtmlSanitizerService sanitizerService) { _db = db; _adminUtil = adminUtil; _blogUtil = blogUtil; _ratingUtil = ratingUtil; _sanitizerService = sanitizerService; }
protected void Page_Load(object sender, EventArgs e) { #region 判断是不是超级管理员 if (!AdminUtil.IsAdmin(this)) //不是超级管理员 { Response.Redirect("Login.aspx"); } #endregion string action = Request["action"]; if (!string.IsNullOrWhiteSpace(action)) { action = action.ToLower(); } string json = string.Empty; switch (action) { case "load": int pageSize = Convert.ToInt32(Request["rows"]); int pageNum = Convert.ToInt32(Request["page"]); string userName = Session["WebUser"].ToString(); DataTable dt = UserDal.GetAllUserList(); int count = dt.Rows.Count; Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("total", count); dic.Add("rows", dt); json = JsonConvert.SerializeObject(dic); break; case "qy": UserDal.UpdateUser(int.Parse(Request["id"]), 1); json = "1"; break; case "ty": UserDal.UpdateUser(int.Parse(Request["id"]), 0); json = "1"; break; default: break; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
private void OnDataLoad() { UserInfo user = AdminUtil.GetLoginUser(this); InitAspNetPager(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("SELECT Top {0} * FROM (SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) AS RowID,* FROM SWX_GroupPicture where OrgID='{1}') T WHERE T.RowID BETWEEN {2} AND {3} ", pageSize, user.OrgID, ((pageSize * (AspNetPager.CurrentPageIndex - 1)) + 1), pageSize * AspNetPager.CurrentPageIndex); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; this.repeaterList1.DataSource = dt; this.repeaterList1.DataBind(); }
public HttpRequestMessage UpdateWX() { string json = ""; UserInfo user = AdminUtil.GetLoginUser(""); string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(""), user.OrgID); if (Tools.GetJsonValue(result, "errcode") == "0") { json = "{\"code\":1,\"msg\":\"\"}"; } else { json = "{\"code\":0,\"msg\":\"errcode:" + Tools.GetJsonValue(result, "errcode") + ", errmsg:" + Tools.GetJsonValue(result, "errmsg") + "\"}"; } return(null); }
private void OnDataLoad() { UserInfo user = AdminUtil.GetLoginUser(this); InitAspNetPager(); StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT Top {0} * FROM (SELECT ROW_NUMBER() OVER(ORDER BY tm.Id DESC) AS RowID,", pageSize); sb.AppendFormat(" tm.* FROM SWX_TextMessage tm "); //sb.AppendFormat(" left join SWX_ImgItem ii on tm.Id = ii.TextMessageId"); sb.AppendFormat(" where OrgID='{0}'", user.OrgID); sb.AppendFormat(" ) T WHERE T.RowID BETWEEN {0} AND {1}", ((pageSize * (AspNetPager.CurrentPageIndex - 1)) + 1), pageSize * AspNetPager.CurrentPageIndex); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; this.repeaterList1.DataSource = dt; this.repeaterList1.DataBind(); }
public void AdminShouldBeAbleToAddAndRemoveUserRights() { using (var site = new KeyHubWebDriver()) { string userEmail = "*****@*****.**"; using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); browser.FindElementByCssSelector("a[href^='/Account/Register']").Click(); SiteUtil.SubmitRegistrationForm(browser, userEmail, "password"); SiteUtil.WaitUntilUserIsLoggedIn(browser); browser.FindElementByCssSelector("a[href^='/Account']").Click(); browser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href"); } using (var browser = BrowserUtil.GetBrowser()) { browser.Navigate().GoToUrl(site.UrlFor("/")); SiteUtil.SubmitLoginForm(browser, "admin", "password"); var customerName = VendorUtil.CreateCustomer(browser); AdminUtil.CreateAccountRightsFor(browser, userEmail, ObjectTypes.Customer, customerName); browser.FindElementByCssSelector(".account-rights-table"); var accountRights = browser.FindElementsByCssSelector(".account-rights-table tbody tr"); Assert.Equal(1, accountRights.Count()); Assert.Contains(customerName, accountRights.First().Text); accountRights.First().FindElement(By.CssSelector("a[href^='/AccountRights/Delete']")).Click(); browser.FindElementByCssSelector("input[value='Confirm Delete']").Click(); new WebDriverWait(browser, TimeSpan.FromSeconds(2)).Until(waitBrowser => { return(browser.FindElementByCssSelector(".account-rights-table") != null && browser.FindElementsByCssSelector(".account-rights-table tbody tr").Count() == 0); }); } } }
protected void Button1_Click(object sender, EventArgs e) { //WXApi.DownloadMedia("http://localhost:2454/UploadFile/aa.png"); //Response.Write(WXApi.UploadMedia(Session["token"].ToString(), "image", "d:\\_临时文件\\aa.png")); //获取天气预报 //string result = HttpRequestUtil.RequestUrl("http://www.weather.com.cn/data/sk/101220101.html", "GET"); //Response.Write(result); //result = Weixin.Mp.Util.Tools.GetJosnValue(result, "WSE"); //Response.Write(result); //Response.Write(AdminUtil.GetRootUrl()); //string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(this), AdminUtil.GetLoginUser(this).OrgID); //Response.Write(AdminUtil.GetRootUrl()); //string path = MapPath("UploadFile/aa.png"); //string id = WXApi.UploadMedia(AdminUtil.GetAccessToken(this), "image", path); //Response.Write(id); Response.Write(WXMsgUtil.CreateTextJson("abc", WXApi.GetOpenIDs(AdminUtil.GetAccessToken(this)))); }
public AuditController( IOptions <AppSettingsModel> appSettings, IOptionsSnapshot <DataSettingsModel> dataSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, BlogUtil blogUtil, MessageUtil msgUtil, UserManager <UserProfile> userManager, IMemoryCache cache) { _db = db; _udb = udb; _adminUtil = adminUtil; _blogUtil = blogUtil; _msgUtil = msgUtil; _appSettings = appSettings.Value; _dataSettings = dataSettings.Value; _userManager = userManager; _cache = cache; }
public ReplyController( IOptions <AppSettingsModel> appSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, BlogUtil blogUtil, ExpUtil expUtil, MessageUtil msgUtil, RatingUtil ratingUtil, HtmlSanitizerService sanitizerService) { _appSettings = appSettings.Value; _db = db; _udb = udb; _adminUtil = adminUtil; _blogUtil = blogUtil; _expUtil = expUtil; _ratingUtil = ratingUtil; _msgUtil = msgUtil; _sanitizerService = sanitizerService; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OnDataLoad(); } string json = string.Empty; try { string action = Request["action"]; if (action == "addPicture") { UserInfo user = AdminUtil.GetLoginUser(this); string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_GroupPicture(OrgID,ImgUrl,ImgName) "); sb.AppendFormat("values('{0}','{1}','{2}') ", user.OrgID, ImgUrl, response.Split(',')[1]); MSSQLHelper.Exists(sb.ToString()); json = "1"; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); //NOTE: the following is too tightly bound to be generic //--> probably should occur as an extension or something //the solution would be to have some delegate be called in the base //webpage that does some action in this initialise //bind this event to the base page event handler this.OnSubmit += new EventHandler(((WebPage)this.Page).DynamicEdit_Submit); this.EditingActive = AdminUtil.IsAdminLoggedIn(); //this is required for a UserControl (handled by custom control though) if (!_hasFirst) { //set this as the first instance of the control in the page _isFirst = true; _hasFirst = true; } }
public HomeController( IOptions <AppSettingsModel> appSettings, IOptionsSnapshot <DataSettingsModel> dataSettings, BlogContext db, UsersContext udb, AdminUtil adminUtil, BlogUtil blogUtil, CategoryUtil catUtil, ExpUtil expUtil, MessageUtil msgUtil, TagUtil tagUtil, UserManager <UserProfile> userManager, UploadUtil uploadUtil, RatingUtil ratingUtil, CacheService cacheService, IMemoryCache cache, IWebHostEnvironment env, ISearchProvider searchProvider) { _db = db; _udb = udb; _adminUtil = adminUtil; _catUtil = catUtil; _blogUtil = blogUtil; _expUtil = expUtil; _msgUtil = msgUtil; _appSettings = appSettings.Value; _dataSettings = dataSettings.Value; _userManager = userManager; _cache = cache; _uploadUtil = uploadUtil; _tagUtil = tagUtil; _ratingUtil = ratingUtil; _cacheService = cacheService; _env = env; _searchProvider = searchProvider; }
public string GetFile() { string jdUrl = AdminUtil.GetRootUrl(); return(jdUrl); }
/// <summary> /// 群发 /// </summary> public string Send() { string type = Request["type"]; string data = Request["data"]; string access_token = AdminUtil.GetAccessToken(this); //获取access_token List <string> openidList = WXApi.GetOpenIDs(access_token); //获取关注者OpenID列表 UserInfo loginUser = AdminUtil.GetLoginUser(this); //当前登录用户 string resultMsg = null; //发送文本 if (type == "1") { resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateTextJson(data, openidList)); } //发送图片 if (type == "2") { string path = MapPath(data); if (!File.Exists(path)) { return("{\"code\":0,\"msg\":\"要发送的图片不存在\"}"); } string msg = WXApi.UploadMedia(access_token, "image", path); string media_id = Tools.GetJsonValue(msg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateImageJson(media_id, openidList)); } //发送图文消息 if (type == "3") { DataTable dt = ImgItemDal.GetImgItemTable(loginUser.OrgID, data); string articlesJson = ImgItemDal.GetArticlesJsonStr(this, access_token, dt); string newsMsg = WXApi.UploadNews(access_token, articlesJson); string newsid = Tools.GetJsonValue(newsMsg, "media_id"); resultMsg = WXApi.Send(access_token, WXMsgUtil.CreateNewsJson(newsid, openidList)); } //结果处理 if (!string.IsNullOrWhiteSpace(resultMsg)) { string errcode = Tools.GetJsonValue(resultMsg, "errcode"); string errmsg = Tools.GetJsonValue(resultMsg, "errmsg"); if (errcode == "0") { return("{\"code\":1,\"msg\":\"\"}"); } else { return("{\"code\":0,\"msg\":\"errcode:" + errcode + ", errmsg:" + errmsg + "\"}"); } } else { return("{\"code\":0,\"msg\":\"type参数错误\"}"); } }
protected void Page_Load(object sender, EventArgs e) { string json = string.Empty; try { string action = Request["action"]; if (action == "Load") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_ImgItem where TextMessageId = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string list = JsonConvert.SerializeObject(dt); loadtext.Value = list; hiddenid.Value = id; } if (action == "addPicture") { string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); json = ImgUrl; } if (action == "saveText") { UserInfo user = AdminUtil.GetLoginUser(this); List <ImgItem> IISS = new List <ImgItem>(); ArrayList arrayList = new ArrayList(); StringBuilder maxsb = new StringBuilder(); string editid = Request["editid"]; string savevalue = Request["savecontent"]; savevalue = savevalue.Substring(0, savevalue.Length - 1); string[] strs = savevalue.Split('|'); for (int i = 0; i < strs.Count(); i++) { string str = ""; if (i != 0) { str = strs[i].Substring(1, strs[i].Length - 1); } else { str = strs[i]; } if (str == "") { continue; } List <ImgItem> IIS = JsonConvert.DeserializeAnonymousType(str, new List <ImgItem>()); IISS.AddRange(IIS); } bool istrue = false; //id为空新建 if (string.IsNullOrWhiteSpace(editid)) { maxsb.AppendFormat("select max(Id) from SWX_TextMessage"); int maxid = MSSQLHelper.GetSingle(maxsb.ToString()) == null ? 0 : int.Parse(MSSQLHelper.GetSingle(maxsb.ToString()).ToString());; int insertid = maxid + 1; StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_TextMessage(Id,OrgID,Status,CreateTime) "); sb.AppendFormat("values({0},'{1}','{2}','{3}') ", insertid, user.OrgID, true, DateTime.Now); arrayList.Add(sb.ToString()); for (int j = 0; j < IISS.Count(); j++) { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("insert into SWX_ImgItem(TextMessageId,Title,Author,ImgUrl,Content,TextUrl) "); sbitem.AppendFormat("values({0},'{1}','{2}','{3}','{4}','{5}') ", insertid, IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); arrayList.Add(sbitem.ToString()); } if (arrayList.Count != 1) { istrue = MSSQLHelper.ExecuteSqlTran(arrayList); } } else { for (int j = 0; j < IISS.Count(); j++) { if (string.IsNullOrWhiteSpace(IISS[j].Id)) { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("insert into SWX_ImgItem(TextMessageId,Title,Author,ImgUrl,Content,TextUrl) "); sbitem.AppendFormat("values({0},'{1}','{2}','{3}','{4}','{5}') ", editid, IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); arrayList.Add(sbitem.ToString()); } else { StringBuilder sbitem = new StringBuilder(); sbitem.AppendFormat("update SWX_ImgItem set Title = '{0}',Author = '{1}',ImgUrl = '{2}',Content = '{3}',TextUrl = '{4}' ", IISS[j].Title, IISS[j].Author, IISS[j].ImgUrl, IISS[j].Content, IISS[j].TextUrl); sbitem.AppendFormat(" WHERE ID= {0} ", IISS[j].Id); arrayList.Add(sbitem.ToString()); } } if (arrayList.Count != 0) { istrue = MSSQLHelper.ExecuteSqlTran(arrayList); } } if (istrue) { json = "1"; } } if (action == "deleteText") { string deleteid = Request["deleteid"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete from SWX_ImgItem where Id = {0}", deleteid); bool istrue = MSSQLHelper.Exists(sb.ToString()); json = "1"; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { OnDataLoad(); } string json = string.Empty; try { UserInfo user = AdminUtil.GetLoginUser(this); string action = Request["action"]; if (action == "addPicture") { string response = Request["response"]; string ImgUrl = System.IO.Path.Combine(UPLOAD_PATH, DateTime.Now.ToString("yyyyMMdd"), response.Split(',')[0] + response.Split(',')[1]).Replace("\\", "/"); StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert into SWX_GroupPicture(OrgID,ImgUrl,ImgName) "); sb.AppendFormat("values('{0}','{1}','{2}') ", user.OrgID, ImgUrl, response.Split(',')[1]); MSSQLHelper.Exists(sb.ToString()); json = "1"; } if (action == "deletePic") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_GroupPicture where Id = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string ImgUrl = dt.Rows[0]["ImgUrl"].ToString(); StringBuilder sb1 = new StringBuilder(); sb1.AppendFormat("delete from SWX_GroupPicture where Id = {0}", id); MSSQLHelper.Exists(sb1.ToString()); File.Delete(Server.MapPath(ImgUrl)); json = "1"; } if (action == "copyPic") { string id = Request["Id"]; StringBuilder sb = new StringBuilder(); sb.AppendFormat(" select * from SWX_GroupPicture where Id = {0} ", id); DataTable dt = MSSQLHelper.Query(sb.ToString()).Tables[0]; string ImgUrl = dt.Rows[0]["ImgUrl"].ToString(); string ImgPa = AdminUtil.GetRootUrl() + ImgUrl; json = ImgPa; } } catch (Exception ex) { string err = ex.Message; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }
public string GetMenusKey() { UserInfo user = AdminUtil.GetLoginUser(this); return(MenuDal.GetMenusLevel3(user)); }