コード例 #1
0
ファイル: TimeTrackingBlock.cs プロジェクト: 0anion0/IBN
        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;
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: RegisterFinances.ascx.cs プロジェクト: 0anion0/IBN
        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");
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: TimeTracking.cs プロジェクト: 0anion0/IBN
        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;
        }
コード例 #6
0
ファイル: TimeTracking.cs プロジェクト: 0anion0/IBN
        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;
                }
            }
        }