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); }
/// <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(); }
private void SetTemplate() { if (ddlTemplates.Visible && ddlTemplates.SelectedValue != "-1") { int templateId = Int32.Parse(ddlTemplates.SelectedValue); ActiveNode.Template = (Template)CoreRepository.GetObjectById(typeof(Template), templateId); } }
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"; }
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(); } }
public string RoomGetAvaiable(int roomClassId, int roomTypeId, int cruiseId, string startDate, int tripId) { 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); var roomClass = RoomServiceBLL.RoomClassGetById(roomClassId); var roomType = RoomServiceBLL.RoomTypeGetById(roomTypeId); var cruise = RoomServiceBLL.CruiseGetById(cruiseId); var trip = RoomServiceBLL.TripGetById(tripId); if (startDate == null) { return("Start date is required!"); } var startDateDT = DateTime.ParseExact(startDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); return(module.RoomCount(roomClass, roomType, cruise, startDateDT, trip.NumberOfDay, trip.HalfDay).ToString()); }
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; }
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 SetRoles() { ActiveNode.NodePermissions.Clear(); foreach (RepeaterItem ri in rptRoles.Items) { // HACK: RoleId is stored in the ViewState because the repeater doesn't have a DataKeys property. CheckBox chkView = (CheckBox)ri.FindControl("chkViewAllowed"); CheckBox chkEdit = (CheckBox)ri.FindControl("chkEditAllowed"); if (chkView.Checked || chkEdit.Checked) { NodePermission np = new NodePermission(); np.Node = ActiveNode; np.Role = (Role)CoreRepository.GetObjectById(typeof(Role), (int)ViewState[ri.ClientID]); np.ViewAllowed = chkView.Checked; np.EditAllowed = chkEdit.Checked; ActiveNode.NodePermissions.Add(np); } } }
/// <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); }
private void MoveSections() { int sectionId = Int32.Parse(Context.Request.QueryString["SectionId"]); Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); section.Node = ActiveNode; if (Context.Request.QueryString["Action"] == "MoveUp") { section.MoveUp(); CoreRepository.FlushSession(); // reset sections, so they will be refreshed from the database when required. ActiveNode.ResetSections(); } else if (Context.Request.QueryString["Action"] == "MoveDown") { section.MoveDown(); CoreRepository.FlushSession(); // reset sections, so they will be refreshed from the database when required. ActiveNode.ResetSections(); } // Redirect to the same page without the section movement parameters Context.Response.Redirect(Context.Request.Path + String.Format("?NodeId={0}", ActiveNode.Id)); }
public string GetAvaiableRoom(string ci, string sd, string ti, string SectionId, string NodeId) { CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository; int nodeId = Int32.Parse(NodeId); Node node = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId); int sectionId = Int32.Parse(SectionId); Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); SailsModule module = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section); DateTime?startDate = null; try { startDate = DateTime.ParseExact(sd, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } var tripId = -1; try { tripId = Convert.ToInt32(ti); } catch { } var trip = AddSeriesBookingsBLL.TripGetById(tripId); var cruiseId = -1; try { cruiseId = Convert.ToInt32(ci); } catch { } var cruise = AddSeriesBookingsBLL.CruiseGetById(cruiseId); var listRoomClass = AddSeriesBookingsBLL.RoomClassGetAll(); var listRoomType = AddSeriesBookingsBLL.RoomTypeGetAll(); var listAvaiableRoomDTO = new List <AvaiableRoomDTO>(); foreach (var roomClass in listRoomClass) { foreach (var roomType in listRoomType) { if (trip == null) { break; } if (!startDate.HasValue) { break; } var roomCount = module.RoomCount(roomClass, roomType, cruise, startDate.Value, trip.NumberOfDay, true, trip.HalfDay); var avaiableRoomDTO = new AvaiableRoomDTO(); if (roomCount > -1) { avaiableRoomDTO.KindOfRoom = roomClass.Name + " " + roomType.Name; avaiableRoomDTO.RoomClass = new AvaiableRoomDTO.RoomClassDTO() { Id = roomClass.Id, Name = roomClass.Name }; avaiableRoomDTO.RoomType = new AvaiableRoomDTO.RoomTypeDTO() { Id = roomType.Id, Name = roomType.Name, }; var NoOfAdult = roomCount; avaiableRoomDTO.NoOfAdult = NoOfAdult; var NoOfChild = roomCount; avaiableRoomDTO.NoOfChild = NoOfChild; var NoOfBaby = roomCount; avaiableRoomDTO.NoOfBaby = NoOfBaby; listAvaiableRoomDTO.Add(avaiableRoomDTO); } } } Dispose(); return(JsonConvert.SerializeObject(listAvaiableRoomDTO)); }
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 = "A3EFDFABA8653DF2342E8DAC29B51AF0"; if (Request.QueryString["module"] == "noidia") { SECURE_SECRET = "" + SECURE_SECRET; } if (Request.QueryString["module"] == "quocte") { 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); var checkingTransaction = NSession.QueryOver <CheckingTransaction>().Where(x => x.MerchTxnRef == merchTxnRef).SingleOrDefault(); if (checkingTransaction != null) { if (checkingTransaction.Processed) { Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=15&status=1&tid=" + transactionNo + "&oi=" + orderInfo + "&ta=" + amount + "&bid=" + merchTxnRef + "&trc=" + txnResponseCode); } } if (hashvalidateResult == "CORRECTED" && txnResponseCode.Trim() == "0") { SendSuccessEmail(); NSession.Save(new CheckingTransaction() { MerchTxnRef = merchTxnRef, Processed = true }); Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=15&status=1&tid=" + transactionNo + "&oi=" + orderInfo + "&ta=" + amount + "&bid=" + merchTxnRef + "&trc=" + txnResponseCode); } else if (hashvalidateResult == "INVALIDATED" && txnResponseCode.Trim() == "0") { Page.Response.Redirect("./Pending.aspx"); } else { SendFailedEmail(); DeleteBooking(pBookingId); NSession.Save(new CheckingTransaction() { MerchTxnRef = merchTxnRef, Processed = true }); Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=157status=2&b=" + bookingId + "&responsecode=" + txnResponseCode); } }
/// <summary> /// In the OnInit method the Node and Section of every ModuleAdminPage is set. /// An exception is thrown when one of them cannot be set. /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { if ((!Page.Request.ContentType.Contains("json") && !Page.Request.ContentType.Contains("multipart/form-data")) || IsPostBack) { try { if (!string.IsNullOrEmpty(Context.Request.QueryString["NodeId"])) { int nodeId = Int32.Parse(Context.Request.QueryString["NodeId"]); _node = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId); int sectionId = Int32.Parse(Context.Request.QueryString["SectionId"]); _section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); _module = _moduleLoader.GetModuleFromSection(_section); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(_node.Culture); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(_node.Culture); _currentUICulture = Thread.CurrentThread.CurrentUICulture; } } catch (Exception ex) { throw new Exception( "Unable to initialize the Module Admin page because a Node or a Section could not be created.", ex); } // Check permissions if (!Context.User.Identity.IsAuthenticated) { Response.Redirect(string.Format("/Login.aspx?ReturnUrl={0}", Request.RawUrl.Replace("&", "%26"))); throw new AccessForbiddenException("You are not logged in."); } User user = Context.User.Identity as User; if (user == null) { return; } if (!CanByPassCanEditCheck() && !user.CanEdit(_section)) { Response.Redirect("/Error.aspx"); throw new ActionForbiddenException("You are not allowed to edit the section."); } // Optional indexing event handlers if (_module is ISearchable && Boolean.Parse(Config.GetConfiguration()["InstantIndexing"])) { ISearchable searchableModule = (ISearchable)_module; searchableModule.ContentCreated += searchableModule_ContentCreated; searchableModule.ContentUpdated += searchableModule_ContentUpdated; searchableModule.ContentDeleted += searchableModule_ContentDeleted; } // Set FCKEditor context (used by some module admin pages) // It would be nicer if we could do this in the Global.asax, but there the // ultra-convenient ~/Path (ResolveUrl) isn't available :). string userFilesPath = Config.GetConfiguration()["FCKeditor:UserFilesPath"]; if (userFilesPath != null && HttpContext.Current.Application["FCKeditor:UserFilesPath"] == null) { HttpContext.Current.Application.Lock(); HttpContext.Current.Application["FCKeditor:UserFilesPath"] = ResolveUrl(userFilesPath); HttpContext.Current.Application.UnLock(); } } base.OnInit(e); }
private void Page_Load(object sender, EventArgs e) { Title = "Sửa nút"; labelExtension.Text = UrlHelper.EXTENSION; // Note: ActiveNode is handled primarily by the AdminBasePage because other pages use it. // ActiveNode is always freshly retrieved (also after postbacks), so it will be tracked by NHibernate. if (Context.Request.QueryString["NodeId"] != null && Int32.Parse(Context.Request.QueryString["NodeId"]) == -1) { // Create an empty new node if NodeId is set to -1 ActiveNode = new Node(); if (Context.Request.QueryString["ParentNodeId"] != null) { int parentNodeId = Int32.Parse(Context.Request.QueryString["ParentNodeId"]); ActiveNode.ParentNode = (Node)CoreRepository.GetObjectById(typeof(Node), parentNodeId); // Copy Site property from parent. ActiveNode.Site = ActiveNode.ParentNode.Site; if (!IsPostBack) { // Set defaults. ActiveNode.Template = ActiveNode.ParentNode.Template; ActiveNode.Culture = ActiveNode.ParentNode.Culture; // Copy security from parent. ActiveNode.CopyRolesFromParent(); } } else if (Context.Request.QueryString["SiteId"] != null) { int siteId = Int32.Parse(Context.Request.QueryString["SiteId"]); ActiveNode.Site = (Site)CoreRepository.GetObjectById(typeof(Site), siteId); // Set defaults inheriting from site ActiveNode.Culture = ActiveNode.Site.DefaultCulture; ActiveNode.Template = ActiveNode.Site.DefaultTemplate; } // Short description is auto-generated, so we don't need the controls with new nodes. txtShortDescription.Visible = false; rfvShortDescription.Enabled = false; revShortDescription.Enabled = false; } if (!IsPostBack) { // There could be a section movement in the request. Check this and move sections if necessary. if (Context.Request.QueryString["SectionId"] != null && Context.Request.QueryString["Action"] != null) { MoveSections(); } else { if (ActiveNode != null) { BindNodeControls(); BindSections(); if (ActiveNode.IsRootNode) { BindMenus(); } } BindCultures(); BindTemplates(); BindRoles(); } } if (ActiveNode != null) { BindPositionButtonsVisibility(); } }
private void btnSave_Click(object sender, EventArgs e) { if (IsValid) { // Remember the previous PlaceholderId and Position to detect changes string oldPlaceholderId = _activeSection.PlaceholderId; int oldPosition = _activeSection.Position; try { _activeSection.Title = txtTitle.Text; _activeSection.ShowTitle = chkShowTitle.Checked; _activeSection.Node = ActiveNode; if (ActiveNode != null) { _activeSection.Node.Sections.Add(_activeSection); } if (ddlModule.Visible) { _activeSection.ModuleType = (ModuleType)CoreRepository.GetObjectById( typeof(ModuleType), Int32.Parse(ddlModule.SelectedValue)); } _activeSection.PlaceholderId = ddlPlaceholder.SelectedValue; _activeSection.CacheDuration = Int32.Parse(txtCacheDuration.Text); // Calculate new position if the section is new or when the PlaceholderId has changed if (_activeSection.Id == -1 || _activeSection.PlaceholderId != oldPlaceholderId) { _activeSection.CalculateNewPosition(); } // Custom settings SetCustomSettings(); // Validate settings ValidateSettings(); // Roles SetRoles(); // Detect a placeholderId change and change positions of adjacent sections if necessary. if (oldPosition != -1 && oldPlaceholderId != _activeSection.PlaceholderId) { _activeSection.ChangeAndUpdatePositionsAfterPlaceholderChange(oldPlaceholderId, oldPosition, true); } // Save the active section SaveSection(); // Clear cached sections. base.CoreRepository.ClearCollectionCache("CMS.Core.Domain.Node.Sections"); ShowMessage("Vùng phân hệ đã được lưu."); } catch (Exception ex) { ShowError(ex.Message); } } }
public static string CheckAvaiable(string sd, string tid, string sid) { try { int sectionId = Int32.Parse(sid); Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); DateTime pStartDate = DateTime.ParseExact(sd, "MM/dd/yyyy", CultureInfo.InvariantCulture); int tripId = Int32.Parse(tid); var trip = Module.TripGetById(tripId); var cruises = Module.CruiseGetAll(); var involvedCruises = new List <domain.Cruise>(); foreach (domain.Cruise cruise in cruises) { if (cruise.Trips.Contains(trip)) { involvedCruises.Add(cruise); } } var ljRoomInCruise = new List <json.RoomInCruise>(); IList <json.GroupedRoom> ljAvaiableGroupedRoom = null; IList <json.GroupedRoom> ljPendingGroupedRoom = null; foreach (domain.Cruise cruise in involvedCruises) { var lRoomInCruise = NSession.QueryOver <domain.Room>(). Where(x => x.Cruise == cruise). Fetch(x => x.RoomClass).Eager. Fetch(x => x.RoomType).Eager. List(); var lgrInCruise = lRoomInCruise.GroupBy(x => new { x.RoomClass, x.RoomType }).OrderBy(x => x.Key.RoomClass.Id).ThenBy(x => x.Key.RoomType.Id).ToList(); var tripDuration = trip.NumberOfDay - 1; for (var i = 0; i < tripDuration; i++) { var firstDay = false; if (i == 0) { firstDay = true; } var dayToCheck = pStartDate.AddDays(i); var lBookingOnDayToCheck = NSession.QueryOver <BookingRoom>(). JoinQueryOver <Booking>(x => x.Book). Where(x => x.StartDate <= dayToCheck && x.EndDate > dayToCheck). Where(x => x.Cruise.Id == cruise.Id && x.Deleted == false). Where(x => x.Status == StatusType.Approved || x.Status == StatusType.Pending). Fetch(x => x.RoomClass).Eager. Fetch(x => x.RoomType).Eager. List(); var glBookingOnDayToCheck = lBookingOnDayToCheck.GroupBy(x => new { x.RoomClass, x.RoomType }).ToList(); var ljGroupedRoom = new List <json.GroupedRoom>(); for (int j = 0; j < lgrInCruise.Count(); j++) { var legrIncruise = lgrInCruise[j].ToList(); for (int k = 0; k < glBookingOnDayToCheck.Count(); k++) { if (lgrInCruise[j].Key.RoomClass == glBookingOnDayToCheck[k].Key.RoomClass && lgrInCruise[j].Key.RoomType == glBookingOnDayToCheck[k].Key.RoomType) { legrIncruise.RemoveRange(0, glBookingOnDayToCheck[k].Count()); break; } } var ljRoom = new List <json.Room>(); foreach (var egrInCruise in legrIncruise) { var jRoom = new json.Room() { RoomId = egrInCruise.Id }; ljRoom.Add(jRoom); } var jgroupedRoom = new json.GroupedRoom() { JRoomType = new json.RoomType() { RoomTypeId = lgrInCruise[j].Key.RoomType.Id, Name = lgrInCruise[j].Key.RoomType.Name }, JRoomClass = new json.RoomClass() { RoomClassId = lgrInCruise[j].Key.RoomClass.Id, Name = lgrInCruise[j].Key.RoomClass.Name }, LJRoom = ljRoom, }; ljGroupedRoom.Add(jgroupedRoom); } if (firstDay) { ljAvaiableGroupedRoom = ljGroupedRoom; continue; } for (int k = 0; k < ljGroupedRoom.Count(); k++) { for (int l = 0; l < ljAvaiableGroupedRoom.Count(); l++) { if (ljAvaiableGroupedRoom[l].JRoomClass == ljGroupedRoom[k].JRoomClass && ljAvaiableGroupedRoom[l].JRoomType == ljGroupedRoom[k].JRoomType) { if (ljGroupedRoom[k].LJRoom.Count() < ljAvaiableGroupedRoom[l].LJRoom.Count()) { ljAvaiableGroupedRoom[l].LJRoom = ljGroupedRoom[k].LJRoom; break; } } } } } for (var i = 0; i < tripDuration; i++) { var firstDay = false; if (i == 0) { firstDay = true; } var dayToCheck = pStartDate.AddDays(i); var lBookingOnDayToCheck = NSession.QueryOver <BookingRoom>(). JoinQueryOver <Booking>(x => x.Book). Where(x => x.StartDate <= dayToCheck && x.EndDate > dayToCheck). Where(x => x.Cruise.Id == cruise.Id && x.Deleted == false). Where(x => x.Status == StatusType.Pending). Fetch(x => x.RoomClass).Eager. Fetch(x => x.RoomType).Eager. List(); var glBookingPendingOnDayToCheck = lBookingOnDayToCheck.GroupBy(x => new { x.RoomClass, x.RoomType }).OrderBy(x => x.Key.RoomClass.Id).ThenBy(x => x.Key.RoomType.Id).ToList(); var ljGroupedRoom = new List <json.GroupedRoom>(); for (int k = 0; k < glBookingPendingOnDayToCheck.Count(); k++) { var gBookingPendingOnDayToCheck = glBookingPendingOnDayToCheck[k].ToList(); var ljRoom = new List <json.Room>(); for (int j = 0; j < gBookingPendingOnDayToCheck.Count(); j++) { var jRoom = new json.Room(); ljRoom.Add(jRoom); } var jgroupedRoom = new json.GroupedRoom() { JRoomType = new json.RoomType() { RoomTypeId = glBookingPendingOnDayToCheck[k].Key.RoomType.Id, Name = glBookingPendingOnDayToCheck[k].Key.RoomType.Name }, JRoomClass = new json.RoomClass() { RoomClassId = glBookingPendingOnDayToCheck[k].Key.RoomClass.Id, Name = glBookingPendingOnDayToCheck[k].Key.RoomClass.Name }, LJRoom = ljRoom, }; ljGroupedRoom.Add(jgroupedRoom); } if (firstDay) { ljPendingGroupedRoom = ljGroupedRoom; continue; } for (int k = 0; k < ljGroupedRoom.Count(); k++) { for (int l = 0; l < ljPendingGroupedRoom.Count(); l++) { if (ljPendingGroupedRoom[l].JRoomClass == ljGroupedRoom[k].JRoomClass && ljPendingGroupedRoom[l].JRoomType == ljGroupedRoom[k].JRoomType) { if (ljGroupedRoom[k].LJRoom.Count() > ljPendingGroupedRoom[l].LJRoom.Count()) { ljPendingGroupedRoom[l].LJRoom = ljGroupedRoom[k].LJRoom; break; } } } } } var avaiableRoomQuantity = 0; var avaiableRoomDetail = ""; foreach (var jAvaiableGroupedRoom in ljAvaiableGroupedRoom) { avaiableRoomQuantity = avaiableRoomQuantity + jAvaiableGroupedRoom.LJRoom.Count(); avaiableRoomDetail = avaiableRoomDetail + jAvaiableGroupedRoom.LJRoom.Count() + " " + jAvaiableGroupedRoom.JRoomClass.Name + jAvaiableGroupedRoom.JRoomType.Name + " "; } var pendingRoomQuantity = 0; var pendingRoomDetail = ""; foreach (var jPendingGroupedRoom in ljPendingGroupedRoom) { pendingRoomQuantity = pendingRoomQuantity + jPendingGroupedRoom.LJRoom.Count(); pendingRoomDetail = pendingRoomDetail + jPendingGroupedRoom.LJRoom.Count() + " " + jPendingGroupedRoom.JRoomClass.Name + jPendingGroupedRoom.JRoomType.Name + " "; } var roomInCruise = new json.RoomInCruise() { JCruise = new json.Cruise() { CruiseId = cruise.Id, Name = cruise.Name }, LJAvaiableRoom = ljAvaiableGroupedRoom, LJPendingRoom = ljPendingGroupedRoom, AvaiableRoomQuantity = avaiableRoomQuantity.ToString(), AvaiableRoomDetail = avaiableRoomDetail, PendingRoomQuantity = pendingRoomQuantity.ToString(), PendingRoomDetail = pendingRoomDetail, }; ljRoomInCruise.Add(roomInCruise); } return(JsonConvert.SerializeObject(ljRoomInCruise)); } catch (Exception ex) { return("not working"); } }
public string CheckRoom(string sd, string ti, string SectionId, string NodeId) { CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository; int nodeId = Int32.Parse(NodeId); Node node = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId); int sectionId = Int32.Parse(SectionId); Section section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId); SailsModule module = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section); DateTime?startDate = null; try { startDate = DateTime.ParseExact(sd, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } var tripId = -1; try { tripId = Convert.ToInt32(ti); } catch { } var trip = AddSeriesBookingsBLL.TripGetById(tripId); var listRoomClass = AddSeriesBookingsBLL.RoomClassGetAll(); var listRoomType = AddSeriesBookingsBLL.RoomTypeGetAll(); var listCruise = AddSeriesBookingsBLL.CruiseGetAllByTrip(trip); var listCheckRoomResultDTO = new List <CheckRoomResultDTO>(); foreach (var cruise in listCruise) { var checkRoomResultDTO = new CheckRoomResultDTO(); checkRoomResultDTO.Cruise = new CheckRoomResultDTO.CruiseDTO() { Id = cruise.Id, Name = cruise.Name }; int total = 0; string detail = ""; foreach (var roomClass in listRoomClass) { foreach (var roomType in listRoomType) { if (trip == null) { break; } if (!startDate.HasValue) { break; } int avail = module.RoomCount(roomClass, roomType, cruise, startDate.Value, trip.NumberOfDay, trip.HalfDay); if (avail > 0) { total += avail; detail += string.Format("{0} {2} {1} ", avail, roomType.Name, roomClass.Name); } } } checkRoomResultDTO.NoOfRoomAvaiable = total; checkRoomResultDTO.DetailRooms = detail; listCheckRoomResultDTO.Add(checkRoomResultDTO); } Dispose(); return(JsonConvert.SerializeObject(listCheckRoomResultDTO)); }