public static bool CheckUserRight(TimeTrackingBlock ttb, string rightName) { if (rightName == null) throw new ArgumentNullException("rightName"); if (ttb == null) throw new ArgumentNullException("ttb"); bool bRetVal = false; if (Mediachase.Ibn.License.TimeTrackingModule) { string key = string.Format(CultureInfo.InvariantCulture, "_ttb_{0}_right_{1}", ttb.PrimaryKeyId.ToString(), rightName); if (HttpContext.Current == null || HttpContext.Current.Items[key] == null) { SecurityService ss = ttb.GetService<SecurityService>(); if (ss != null) bRetVal = ss.CheckUserRight(rightName); if (HttpContext.Current != null) HttpContext.Current.Items[key] = bRetVal; } else { bRetVal = (bool)HttpContext.Current.Items[key]; } } return bRetVal; }
public static bool CheckUserRight(TimeTrackingBlock ttb, string rightName) { if (rightName == null) { throw new ArgumentNullException("rightName"); } if (ttb == null) { throw new ArgumentNullException("ttb"); } bool bRetVal = false; if (Mediachase.Ibn.License.TimeTrackingModule) { string key = string.Format(CultureInfo.InvariantCulture, "_ttb_{0}_right_{1}", ttb.PrimaryKeyId.ToString(), rightName); if (HttpContext.Current == null || HttpContext.Current.Items[key] == null) { SecurityService ss = ttb.GetService <SecurityService>(); if (ss != null) { bRetVal = ss.CheckUserRight(rightName); } if (HttpContext.Current != null) { HttpContext.Current.Items[key] = bRetVal; } } else { bRetVal = (bool)HttpContext.Current.Items[key]; } } return(bRetVal); }
protected void Page_Load(object sender, EventArgs e) { if (BlockId <= 0) throw new ArgumentException("BlockId is wrong or not specified"); block = MetaObjectActivator.CreateInstance<TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), BlockId); // block = new TimeTrackingBlock(BlockId); SecurityService ss = block.GetService<SecurityService>(); if (ss == null || !ss.CheckUserRight(TimeTrackingManager.Right_RegFinances)) throw new AccessDeniedException(); btnApprove.Text = LocRM.GetString("tApprove"); btnCancel.Text = LocRM.GetString("tCancel"); if (!Page.IsPostBack) { BindAccounts(); dtcDate.SelectedDate = Mediachase.IBN.Business.User.GetLocalDate(DateTime.UtcNow).Date; } btnApprove.CustomImage = CHelper.GetAbsolutePath("/layouts/images/accept.gif"); btnCancel.CustomImage = CHelper.GetAbsolutePath("/layouts/images/cancel.gif"); }
public static bool CheckUserRight(int timeTrackingBlockId, string rightName) { if (rightName == null) { throw new ArgumentNullException("rightName"); } bool bRetVal = false; if (Mediachase.Ibn.License.TimeTrackingModule) { string key = string.Format(CultureInfo.InvariantCulture, "_ttb_{0}_right_{1}", timeTrackingBlockId, rightName); if (HttpContext.Current == null || HttpContext.Current.Items[key] == null) { TimeTrackingBlock ttb = MetaObjectActivator.CreateInstance <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), timeTrackingBlockId); SecurityService ss = ttb.GetService <SecurityService>(); if (ss != null) { bRetVal = ss.CheckUserRight(rightName); } if (HttpContext.Current != null) { HttpContext.Current.Items[key] = bRetVal; } } else { bRetVal = (bool)HttpContext.Current.Items[key]; } } return(bRetVal); }
private static int GetFinalStateIdByTimeTrackingBlock(TimeTrackingBlock block) { StateMachineService stateMachine = block.GetService<StateMachineService>(); if (stateMachine == null || stateMachine.StateMachine.States.Count == 0) return -1; State finalState = stateMachine.StateMachine.States[stateMachine.StateMachine.States.Count - 1]; MetaObject stateObject = StateMachineManager.GetState(TimeTrackingBlock.GetAssignedMetaClass(), finalState.Name); return stateObject.PrimaryKeyId.Value; }
private static void GetCurrentAndPrevStateIdByTimeTrackingBlock(TimeTrackingBlock block, out int curStateId, out int prevStateId) { curStateId = -1; prevStateId = -1; StateMachineService stateMachine = block.GetService<StateMachineService>(); if (stateMachine == null || stateMachine.StateMachine.States.Count == 0 || stateMachine.CurrentState == null) return; EventService eventService = block.GetService<EventService>(); if (eventService != null) { // Detects that state is changed, find moFromStateName, toStateName MetaObject[] events = eventService.LoadEvents(TriggerContext.Current.TransactionId); StateMachineEventServiceArgs args = StateMachine.GetStateChangedEventArgs(events); if (args != null) { curStateId = StateMachineManager.GetState(TimeTrackingBlock.GetAssignedMetaClass(), args.CurrentState.Name).PrimaryKeyId.Value; prevStateId = StateMachineManager.GetState(TimeTrackingBlock.GetAssignedMetaClass(), args.PrevState.Name).PrimaryKeyId.Value; } } }