/// <summary> /// Loads aan existing Section from the database or creates a new one if the SectionId = -1 /// </summary> private void LoadSection() { // NOTE: Called from OnInit! if (Context.Request.QueryString["SectionId"] != null) { if (Int32.Parse(Context.Request.QueryString["SectionId"]) == -1) { // Create a new section instance _activeSection = new Section(); _activeSection.Node = ActiveNode; if (!IsPostBack) { _activeSection.CopyRolesFromNode(); } } else { // Get section data _activeSection = (Section)CoreRepository.GetObjectById(typeof(Section), Int32.Parse( Context.Request.QueryString[ "SectionId"])); } } // Preload available ModuleTypes because we might need them to display the CustomSettings // of the first ModuleType if none is selected (when adding a brand new Section). _availableModuleTypes = CoreRepository.GetAll(typeof(ModuleType), "Name"); // Create the controls for the ModuleType-specific settings. CreateCustomSettings(); }
public ActionResult DocStatuses_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new CoreRepository(); var p = new DynamicParameters(); p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); var items = rep.GetSQLData <dynamic>("GetDocStatuses", p, CommandType.StoredProcedure) as List <dynamic> ?? new List <dynamic>(); var total = p.Get <int>("total"); var json = JsonConvert.SerializeObject(new { items, total = total }); return(Content(json, "application/json")); }
private void BindMenus() { pnlMenus.Visible = true; rptMenus.DataSource = CoreRepository.GetMenusByRootNode(ActiveNode); rptMenus.DataBind(); hplNewMenu.NavigateUrl = String.Format("~/Admin/MenuEdit.aspx?MenuId=-1&NodeId={0}", ActiveNode.Id); }
//登录时 验证用户时使用 public bool AuthenticateUser(string username, string password, bool persistLogin) { //数据访问类 CoreRepository cr = (CoreRepository)HttpContext.Current.Items["CoreRepository"]; string hashedPassword = Encryption.StringToMD5Hash(password); try { //通过用户名密码得到用户对象 User user = cr.GetUserByUsernameAndPassword(username, hashedPassword); if (user != null) { user.IsAuthenticated = true; //string currentIp = HttpContext.Current.Request.UserHostAddress; //user.LastLogin = DateTime.Now; //user.LastIp = currentIp; // Save login date and IP 记录相关信息 cr.UpdateObject(user); 更新用户授权通过信息 // Create the authentication ticket HttpContext.Current.User = new CuyahogaPrincipal(user); //通过授权 FormsAuthentication.SetAuthCookie(user.Name, persistLogin); return true; } else { //log.Warn(String.Format("Invalid username-password combination: {0}:{1}.", username, password)); return false; } } catch (Exception ex) { throw new Exception(String.Format("Unable to log in user '{0}': " + ex.Message, username), ex); } }
public IActionResult AddLocation(Location location) { var repo = new CoreRepository(); repo.Add(location); return(Index()); }
private void SetTemplate() { if (ddlTemplates.Visible && ddlTemplates.SelectedValue != "-1") { int templateId = Int32.Parse(ddlTemplates.SelectedValue); ActiveNode.Template = (Template)CoreRepository.GetObjectById(typeof(Template), templateId); } }
private void Context_BeginRequest(object sender, EventArgs e) { // Get the adapter for the 1.0 CoreRepository and store it in the HttpContext.Items collection. IWindsorContainer container = ContainerAccessorUtil.GetContainer(); CoreRepository cr = (CoreRepository)container["corerepositoryadapter"]; HttpContext.Current.Items.Add("CoreRepository", cr); }
private void BindRoles() { IList roles = CoreRepository.GetAll(typeof(Role), "PermissionLevel"); rptRoles.ItemDataBound += rptRoles_ItemDataBound; rptRoles.DataSource = roles; rptRoles.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int sectionId = Int32.Parse(Request.QueryString["SectionId"]); Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); var status = Request.QueryString["status"]; if (status == "1") { lblStatus.Text = "Success"; lblStatus.ForeColor = System.Drawing.Color.Green; } if (status == "2") { lblStatus.Text = "Fail"; lblStatus.ForeColor = System.Drawing.Color.Red; } var transactionId = Request.QueryString["tid"]; lblTransactionId.Text = transactionId; var orderInformation = Request.QueryString["oi"]; lblOrderInfomation.Text = orderInformation; var totalAmount = Request.QueryString["ta"]; lblTotalAmount.Text = totalAmount; var bookingId = Request.QueryString["bid"]; lblBookingId.Text = bookingId; var pBookingId = Int32.Parse(bookingId); var booking = NSession.QueryOver <Booking>().Where(x => x.Id == pBookingId).SingleOrDefault(); lblDepartureDate.Text = booking.StartDate.ToLongDateString(); lblItinerary.Text = booking.Trip.Name; lblCruise.Text = booking.Cruise.Name; var clBookingRoom = new List <BookingRoom>(); var lBookingRoom = booking.BookingRooms; foreach (var bookingRoom in lBookingRoom) { clBookingRoom.Add((BookingRoom)bookingRoom); } var glBookingRoom = clBookingRoom.GroupBy(x => new { x.RoomClass, x.RoomType }); foreach (var gBookingRoom in glBookingRoom) { lblRoom.Text = lblRoom.Text + gBookingRoom.Count() + " " + gBookingRoom.Key.RoomClass.Name + gBookingRoom.Key.RoomType.Name + " "; } }
protected void Page_Load(object sender, EventArgs e) { int sectionId = Int32.Parse(Request.QueryString["SectionId"]); Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); DateTime startDate = DateTime.ParseExact(Request.QueryString["sd"], "MM/dd/yyyy", CultureInfo.InvariantCulture); lblStartDate.Text = startDate.ToLongDateString(); int itineraryId = Int32.Parse(Request.QueryString["i"]); var itinerary = NSession.QueryOver <SailsTrip>().Where(x => x.Id == itineraryId).SingleOrDefault(); lblItinerary.Text = itinerary.Name; int cruiseId = Int32.Parse(Request.QueryString["c"]); var cruise = NSession.QueryOver <Cruise>().Where(x => x.Id == cruiseId).SingleOrDefault(); lblCruise.Text = cruise.Name; lblYourName.Text = Request.QueryString["yn"]; lblYourEmail.Text = Request.QueryString["ye"]; lblYourPhone.Text = Request.QueryString["p"]; var lBookedRoom = GetListBookedRoom(); var lSingleRoom = GetListSingleRoom(); var lChildren = GetListChildren(); var lFullRoom = GetListFullRoom(); foreach (var bookedRoom in lBookedRoom) { lblRoom.Text = lblRoom.Text + bookedRoom.Quantity + " " + bookedRoom.RoomClass.Name + bookedRoom.RoomType.Name + " "; foreach (var singleRoom in lSingleRoom) { if (singleRoom.RoomClass == bookedRoom.RoomClass && singleRoom.RoomType == bookedRoom.RoomType) { lblRoom.Text = lblRoom.Text + "(" + " " + singleRoom.Quantity + " " + "Single Room" + " " + ")"; } } foreach (var children in lChildren) { if (children.RoomClass == bookedRoom.RoomClass && children.RoomType == bookedRoom.RoomType) { lblRoom.Text = lblRoom.Text + " " + "+" + " " + children.Quantity + " " + "Children" + "<br/>"; } } } var fullRoomPrice = GetRoomPrice(lFullRoom, cruise, itinerary); var singleRoomPrice = GetSingleRoomPrice(lSingleRoom, cruise, itinerary); var childrenPrice = GetChildrenPrice(lChildren, cruise, itinerary); var exchangeRate = GetExchangeRate(); var totalAmount = fullRoomPrice + singleRoomPrice + childrenPrice; var exchangedTotalAmount = totalAmount * exchangeRate; lblTotalAmount.Text = totalAmount.ToString("N", CultureInfo.GetCultureInfo("en-US")) + " " + "USD x " + "<a href='https://www.vietcombank.com.vn/exchangerates/' data-toggle='tooltip' title='We use Vietcombank 's Exchange Rate. Click to see more' target='_blank'>" + exchangeRate.ToString("N", CultureInfo.GetCultureInfo("en-US")) + "</a>" + " = " + exchangedTotalAmount.ToString("N", CultureInfo.GetCultureInfo("en-US")) + " VND"; }
public async Task <RuntimeResult> ConfigPrefixAsync(string prefix) { var record = await CoreRepository.GetOrCreateGuildSettingsAsync(Context.Guild).ConfigureAwait(false); record.CommandPrefix = prefix; await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false); return(CommandRuntimeResult.FromSuccess($"Successfully changed prefix to {Format.Bold(prefix)}.")); }
public TraceManager() { db = new CoreRepository(); _disposed = false; //SERIALIZE WILL FAIL WITH PROXIED ENTITIES //dbContext.Configuration.ProxyCreationEnabled = false; //ENABLING COULD CAUSE ENDLESS LOOPS AND PERFORMANCE PROBLEMS //dbContext.Configuration.LazyLoadingEnabled = false; }
private void BindCompatibleSections() { string selectedAction = String.Empty; if (ddlAction.SelectedIndex == -1 && ddlAction.Items.Count > 0) { selectedAction = ddlAction.Items[0].Value; } else { selectedAction = ddlAction.SelectedValue; } ArrayList compatibleModuleTypes = new ArrayList(); // Get all ModuleTypes. IList moduleTypes = CoreRepository.GetAll(typeof(ModuleType)); foreach (ModuleType mt in moduleTypes) { string assemblyQualifiedName = mt.ClassName + ", " + mt.AssemblyName; Type moduleTypeType = Type.GetType(assemblyQualifiedName); if (moduleTypeType != null) // throw exception when moduleTypeType == null? { ModuleBase moduleInstance = base.ModuleLoader.GetModuleFromType(mt); if (moduleInstance is IActionConsumer) { IActionConsumer actionConsumer = moduleInstance as IActionConsumer; CMS.Core.Communication.Action currentAction = _activeActionProvider.GetOutboundActions().FindByName(selectedAction); if (actionConsumer.GetInboundActions().Contains(currentAction)) { compatibleModuleTypes.Add(mt); } } } } if (compatibleModuleTypes.Count > 0) { // Retrieve all sections that have the compatible ModuleTypes IList compatibleSections = CoreRepository.GetSectionsByModuleTypes(compatibleModuleTypes); if (compatibleSections.Count > 0) { pnlTo.Visible = true; btnSave.Enabled = true; ddlSectionTo.DataSource = compatibleSections; ddlSectionTo.DataValueField = "Id"; ddlSectionTo.DataTextField = "FullName"; ddlSectionTo.DataBind(); } else { pnlTo.Visible = false; btnSave.Enabled = false; } } }
private void MoveNode(NodePositionMovement npm) { CoreRepository.ClearQueryCache("Nodes"); IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site); ActiveNode.Move(rootNodes, npm); CoreRepository.FlushSession(); Context.Response.Redirect(Context.Request.RawUrl); }
public async Task <RuntimeResult> ModeratorPermsSetAsync([Remainder] GuildPermission guildPermission) { var record = await CoreRepository.GetOrCreateGuildSettingsAsync(Context.Guild).ConfigureAwait(false); record.ModeratorPermission = guildPermission; await CoreRepository.SaveRepositoryAsync().ConfigureAwait(false); return(CommandRuntimeResult.FromSuccess( $"Successfully changed the required moderator permission to {Format.Bold(guildPermission.Humanize(LetterCasing.Title))}.")); }
public IActionResult Index() { var repo = new CoreRepository(); var model = new MapViewModel { Locations = repo.Get(new Rectangle(-34.5, -33, 151, 152)) }; return(View(model)); }
private void rptSections_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Delete" || e.CommandName == "Detach") { int sectionId = Int32.Parse(e.CommandArgument.ToString()); Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); if (e.CommandName == "Delete") { section.Node = ActiveNode; try { // First tell the module to remove its content. ModuleBase module = ModuleLoader.GetModuleFromSection(section); module.DeleteModuleContent(); // Make sure there is no gap in the section indexes. // ABUSE: this method was not designed for this, but works fine. section.ChangeAndUpdatePositionsAfterPlaceholderChange(section.PlaceholderId, section.Position, false); // Now delete the Section. ActiveNode.Sections.Remove(section); CoreRepository.DeleteObject(section); } catch (Exception ex) { ShowError(ex.Message); log.Error(String.Format("Error deleting section : {0}.", section.Id), ex); } } if (e.CommandName == "Detach") { try { // Make sure there is no gap in the section indexes. // ABUSE: this method was not designed for this, but works fine. section.ChangeAndUpdatePositionsAfterPlaceholderChange(section.PlaceholderId, section.Position, false); // Now detach the Section. ActiveNode.Sections.Remove(section); section.Node = null; section.PlaceholderId = null; CoreRepository.UpdateObject(section); // Update search index to make sure the content of detached sections doesn't // show up in a search. SearchHelper.UpdateIndexFromSection(section); } catch (Exception ex) { ShowError(ex.Message); log.Error(String.Format("Error detaching section : {0}.", section.Id), ex); } } BindSections(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (ActiveNode.Sections.Count > 0) { ShowError( "Không thể xóa nút khi có các vùng phân hệ trong nó. Hãy xóa hoặc tạm gỡ toàn bộ các vùng này trước."); } else if (ActiveNode.ChildNodes.Count > 0) { ShowError("Không thể xóa nút khi còn các nút con. Hãy xóa hết các nút con trước."); } else { try { CoreRepository.ClearQueryCache("Nodes"); bool hasParentNode = (ActiveNode.ParentNode != null); if (hasParentNode) { ActiveNode.ParentNode.ChildNodes.Remove(ActiveNode); } else { IList rootNodes = CoreRepository.GetRootNodes(ActiveNode.Site); rootNodes.Remove(ActiveNode); } CoreRepository.DeleteNode(ActiveNode); // Reset the position of the 'neighbour' nodes. if (ActiveNode.Level == 0) { ActiveNode.ReOrderNodePositions(CoreRepository.GetRootNodes(ActiveNode.Site), ActiveNode.Position); } else { ActiveNode.ReOrderNodePositions(ActiveNode.ParentNode.ChildNodes, ActiveNode.Position); } CoreRepository.FlushSession(); if (hasParentNode) { Context.Response.Redirect(String.Format("NodeEdit.aspx?NodeId={0}", ActiveNode.ParentNode.Id)); } else { Context.Response.Redirect("Default.aspx"); } } catch (Exception ex) { ShowError(ex.Message); log.Error(String.Format("Có lỗi khi xóa nút: {0}.", ActiveNode.Id), ex); } } }
public static SailsModule GetInstance() { CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository; int nodeId = 1; Node node = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId); int sectionId = 15; Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); SailsModule module = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section); return(module); }
private void Context_AuthenticateRequest(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; if (app.Context.User != null && app.Context.User.Identity.IsAuthenticated)//若用户已经通过认证 { CoreRepository cr = (CoreRepository)HttpContext.Current.Items["CoreRepository"]; int userId = Int32.Parse(app.Context.User.Identity.Name); User cuyahogaUser = (User)cr.GetObjectById(typeof(User), userId);//得到对应的cuyahogaUser对象 cuyahogaUser.IsAuthenticated = true; app.Context.User = new CuyahogaPrincipal(cuyahogaUser);//将通过标准窗体认证的user替换成CuyahogaUser, cuyahogaUser包含更多的信息 } }
protected void Page_Load(object sender, EventArgs e) { int sectionId = Int32.Parse(Request.QueryString["SectionId"]); Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); string SECURE_SECRET = "6D0870CDE5F24F34F3915FB0045120DB"; string hashvalidateResult = ""; // Khoi tao lop thu vien VPCRequest conn = new VPCRequest("http://onepay.vn"); conn.SetSecureSecret(SECURE_SECRET); // Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa hashvalidateResult = conn.Process3PartyResponse(Page.Request.QueryString); // Lay gia tri tham so tra ve tu cong thanh toan String vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown"); string amount = conn.GetResultField("vpc_Amount", "Unknown"); string localed = conn.GetResultField("vpc_Locale", "Unknown"); string command = conn.GetResultField("vpc_Command", "Unknown"); string version = conn.GetResultField("vpc_Version", "Unknown"); string cardType = conn.GetResultField("vpc_Card", "Unknown"); string orderInfo = conn.GetResultField("vpc_OrderInfo", "Unknown"); string merchantID = conn.GetResultField("vpc_Merchant", "Unknown"); string authorizeID = conn.GetResultField("vpc_AuthorizeId", "Unknown"); string merchTxnRef = conn.GetResultField("vpc_MerchTxnRef", "Unknown"); string transactionNo = conn.GetResultField("vpc_TransactionNo", "Unknown"); string acqResponseCode = conn.GetResultField("vpc_AcqResponseCode", "Unknown"); string txnResponseCode = vpc_TxnResponseCode; string message = conn.GetResultField("vpc_Message", "Unknown"); var bookingId = merchTxnRef; var pBookingId = Int32.Parse(bookingId); if (hashvalidateResult == "CORRECTED" && txnResponseCode.Trim() == "0") { SendSuccessEmail(); NSession.Save(new CheckingTransaction() { MerchTxnRef = merchTxnRef, Processed = true }); Response.Write("responsecode=1&desc=confirm-success"); } else { SendFailedEmail(); NSession.Save(new CheckingTransaction() { MerchTxnRef = merchTxnRef, Processed = true }); Response.Write("responsecode=0&desc=confirm-fail"); } }
private void CreateCustomSettings() { // Find out the ModuleType. Existing Sections have ModuleType property but for new ones // we have to determine which ModuleType is selected. ModuleType mt = null; if (_activeSection.ModuleType != null) { mt = _activeSection.ModuleType; } else if (Context.Request.Form[ddlModule.UniqueID] != null) { // The user has selected a ModuleType. Fetch that one from the database and // create the settings. int moduleTypeId = Int32.Parse(Context.Request.Form[ddlModule.UniqueID]); mt = (ModuleType)CoreRepository.GetObjectById(typeof(ModuleType), moduleTypeId); } else { // Get the Settings of the first ModuleType in the list. if (_availableModuleTypes.Count > 0) { mt = (ModuleType)_availableModuleTypes[0]; } } if (mt != null) { ModuleBase module; if (_activeSection.Id > 0) { module = _moduleLoader.GetModuleFromSection(_activeSection); } else { module = _moduleLoader.GetModuleFromClassName(mt.ClassName); } foreach (ModuleSetting ms in mt.ModuleSettings) { HtmlTableRow settingRow = new HtmlTableRow(); HtmlTableCell labelCell = new HtmlTableCell(); labelCell.InnerText = ms.FriendlyName; HtmlTableCell controlCell = new HtmlTableCell(); controlCell.Controls.Add(SettingControlHelper.CreateSettingControl(ms.Name, ms.GetRealType(), null, module, Page)); settingRow.Cells.Add(labelCell); settingRow.Cells.Add(controlCell); plcCustomSettings.Controls.Add(settingRow); } } pnlCustomSettings.Visible = mt.ModuleSettings.Count > 0; }
public ActionResult DocLogs_getItems() { var parameters = AjaxModel.GetParameters(HttpContext); var isDownload = ""; var createdBy = ""; var name = ""; DateTime createdMin = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; DateTime createdMax = (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue; if (parameters.filter != null && parameters.filter.Count > 0) { isDownload = parameters.filter.ContainsKey("isDownload") ? parameters.filter["isDownload"].ToString() : "0"; createdBy = parameters.filter.ContainsKey("createdBy") ? parameters.filter["createdBy"].ToString() : ""; name = parameters.filter.ContainsKey("name") ? parameters.filter["name"].ToString() : ""; if (parameters.filter.ContainsKey("created") && parameters.filter["created"] != null) { var dates = parameters.filter["created"].ToString() .Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (dates.Length > 0) { createdMin = RDL.Convert.StrToDateTime(dates[0].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue); } if (dates.Length > 1) { createdMax = RDL.Convert.StrToDateTime(dates[1].Trim(), (DateTime)System.Data.SqlTypes.SqlDateTime.MaxValue); createdMax = createdMax.AddDays(1).AddSeconds(-1); } } } var rep = new CoreRepository(); var p = new DynamicParameters(); p.Add("isDownLoad", isDownload); p.Add("createdBy", createdBy); p.Add("name", name); p.Add("createdMin", createdMin); p.Add("createdMax", createdMax); var items = rep.GetSQLData <dynamic>("GetDocLogs", p, CommandType.StoredProcedure); var json = JsonConvert.SerializeObject(new { items }); return(Content(json, "application/json")); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { if (db != null) { db.Dispose(); } } db = null; _disposed = true; } }
private void Context_AuthenticateRequest(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; if (app.Context.User != null && app.Context.User.Identity.IsAuthenticated) { CoreRepository cr = (CoreRepository)HttpContext.Current.Items["CoreRepository"]; // There is a logged-in user with a standard Forms Identity. Replace it with // the cached Cuyahoga identity (the User class implements IIdentity). int userId = Int32.Parse(app.Context.User.Identity.Name); User cuyahogaUser = (User)cr.GetObjectById(typeof(User), userId); cuyahogaUser.IsAuthenticated = true; app.Context.User = new BitPortalPrincipal(cuyahogaUser); } }
private void InitTemplate() { if (Context.Request.QueryString["TemplateId"] != null) { int templateId = Int32.Parse(Context.Request.QueryString["TemplateId"]); CoreRepository cr = (CoreRepository)HttpContext.Current.Items["CoreRepository"]; Template template = (Template)cr.GetObjectById(typeof(Template), templateId); BaseTemplate templateControl = (BaseTemplate)this.LoadControl(UrlHelper.GetApplicationPath() + template.Path); string css = UrlHelper.GetApplicationPath() + template.BasePath + "/Css/" + template.Css; templateControl.RenderCssLinks(new string[1] { css }); templateControl.InsertContainerButtons(); this.Controls.Add(templateControl); } }
private void BindSections() { IList sortedSections = CoreRepository.GetSortedSectionsByNode(ActiveNode); // Synchronize sections, otherwise we'll have two collections with the same Sections ActiveNode.Sections = sortedSections; rptSections.DataSource = sortedSections; rptSections.DataBind(); if (ActiveNode.Id > 0 && ActiveNode.Template != null) { // Also enable add section link hplNewSection.NavigateUrl = String.Format("~/Admin/SectionEdit.aspx?SectionId=-1&NodeId={0}", ActiveNode.Id); hplNewSection.Visible = true; } }
private void BindTemplates() { IList templates = CoreRepository.GetAll(typeof(Template), "Name"); // Bind ddlTemplates.DataSource = templates; ddlTemplates.DataValueField = "Id"; ddlTemplates.DataTextField = "Name"; ddlTemplates.DataBind(); if (ActiveNode != null && ActiveNode.Template != null) { ListItem li = ddlTemplates.Items.FindByValue(ActiveNode.Template.Id.ToString()); if (li != null) { li.Selected = true; } } }
public dynamic GetItems(ASCRUDGetItemsModel parameters, aspnet_Users user, out string msg, out int total) { msg = ""; total = 0; var name = ""; if (!_IsCanUserChange(user)) { msg = "Нет прав для данной операции"; return(null); } try { if (parameters.filter != null && parameters.filter.Count > 0) { name = parameters.filter.ContainsKey("name") ? parameters.filter["name"].ToString() : ""; } var sorts = parameters.sort.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var directions = parameters.direction.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries); var sort1 = sorts.Length > 0 ? sorts[0] : ""; var direction1 = directions.Length > 0 ? directions[0] : ""; var rep = new CoreRepository(); var p = new DynamicParameters(); p.Add("name", name); p.Add("sort1", sort1); p.Add("direction1", direction1); p.Add("page", parameters.page); p.Add("pageSize", parameters.pageSize); p.Add("total", dbType: DbType.Int32, direction: ParameterDirection.Output); dynamic res = rep.GetSQLData <dynamic>("motskin_GetContractors", p, CommandType.StoredProcedure) as List <dynamic> ?? new List <dynamic>(); total = p.Get <int>("total"); return(res); } catch (Exception ex) { _debug(ex, new { userName = user.UserName }); msg = "Сбой при выполнении операции"; return(null); } }
/// <summary> /// A searchresult contains a SectionId propery that indicates to which section the /// result belongs. We need to get a real Section to determine if the current user /// has view access to that Section. /// </summary> /// <param name="nonFilteredResults"></param> /// <returns></returns> private static SearchResultCollection FilterResults(SearchResultCollection nonFilteredResults) { SearchResultCollection filteredResults = new SearchResultCollection(); CoreRepository cr = HttpContext.Current.Items["CoreRepository"] as CoreRepository; if (cr != null) { foreach (SearchResult result in nonFilteredResults) { Section section = (Section)cr.GetObjectById(typeof(Section), result.SectionId); if (section.ViewAllowed(HttpContext.Current.User.Identity)) { filteredResults.Add(result); } } } return(filteredResults); }