Ejemplo n.º 1
0
        public void HasRight_SameRightTypeSameAdministrativeDivisionIdNotSameInitiativeId_False()
        {
            var right = new Right(RightType.AddCities, "locationId", "initiativeId");

            var hasRight = right.HasRight(RightType.AddCities, "locationId", "initiativeId1");

            hasRight.Should().BeFalse();
        }
 public static bool HasRightForPage(UserObject user, string page, Right r)
 {
     if (user != null)
         if (user.PagePermissionList.Keys.Contains(page))
             if (user.PagePermissionList[page].Contains(r))
                 return true;
     return false;
 }
Ejemplo n.º 3
0
        public void HasRight_NotSameRightTypeSameAdministrativeDivisionIdSameInitiativeId_False()
        {
            var right = new Right(RightType.AddCities, "locationId", "initiativeId");

            var hasRight = right.HasRight(RightType.AcceptLikelyThiefSuggestions, "locationId", "initiativeId");

            hasRight.Should().BeFalse();
        }
Ejemplo n.º 4
0
 public Shield()
 {
     Front frontPanel = new Front();
     Rear rearPanel = new Rear();
     Top topPanel = new Top();
     Bottom bottomPanel = new Bottom();
     Right rightPanel = new Right();
     Left leftPanel = new Left();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// New employee right without any link to database
 /// </summary>
 /// <returns>Employee right instance</returns>
 public EmployeeRight NewEmployeeRight(Employee employee, Right right)
 {
     return New<EmployeeRight>((e) =>
     {
         e.Employee = employee;
         e.Right = right;
         employee.Rights.Add(e);
     });
 }
Ejemplo n.º 6
0
 public AddRight(bool isedit, int rightIndex)
 {
     InitializeComponent();
     this.isedit = isedit;
     if (isedit && rightIndex > -1)
     {
         right = UserAdminUtilities.UserAdminUtility.Rights[rightIndex];
         reset();
     }
 }
Ejemplo n.º 7
0
        public void HasRight_SameRightTypePropertyAdministrativeDivisionIdIsLowerInHierarchySameInitiativeId_False()
        {
            var administrativeDivisions = new List<AdministrativeDivision>()
                                              {
                                                  new AdministrativeDivision(null, "tomsk region", "tomskayaoblast", 0, 0) {Id = "id1"},
                                                  new AdministrativeDivision("id1", "tomsk", "tomsk", 0, 0) { Id = "id2" }
                                              };

            var administrativeDivisionProvider = Substitute.For<AdministrativeDivisionProviderBase>();
            administrativeDivisionProvider.AdministrativeDivisions.Returns(administrativeDivisions);

            DependencyResolver.SetResolver(x => administrativeDivisionProvider, x => null);

            var right = new Right(RightType.AddCities, "id2", "initiativeId");

            var hasRight = right.HasRight(RightType.AddCities, "id1", "initiativeId");

            hasRight.Should().BeFalse();
        }
Ejemplo n.º 8
0
        private void InitializeApplication(Application application)
        {
            var securableApplication = new SecurableApplication();
            securableApplication.CopyFrom(application);

            // adding the system securable object type.
            SecurableObjectType systemObjectType = new SecurableObjectType()
            {
                    Id = 0,
                    Application = securableApplication,
                    Name = "system",
                    Description = "System Securable Object Type"
            };

            // adding the systemObjectType as a securable object type.
            GatekeeperFactory.SecurableObjectTypeSvc.Add(systemObjectType);

            securableApplication.SecurableObjectType = systemObjectType;

            // adding the application as a securable object.
            GatekeeperFactory.SecurableObjectSvc.Add(securableApplication as ISecurableObject);

            // defining the system administrator role.
            Role systemAdministerRole = new Role()
            {
                Application = securableApplication,
                Name = "system_admin",
                Description = "Administers the System",
                SecurableObjectType = systemObjectType
            };

            // adding the system administrator and the system user roles.
            IRoleSvc roleSvc = GatekeeperFactory.RoleSvc;
            roleSvc.Add(systemAdministerRole);//adding the systemAdministerRole as a role.

            // defining the Administer_System right.
            Right administerSystemRight = new Right()
            {
                Application = securableApplication,
                Name = "administer_system",
                Description = "Administers the System",
                SecurableObjectType = systemObjectType
            };

            // defining the View_System right.
            Right viewSystemRight = new Right()
            {
                Application = securableApplication,
                Name = "view_system",
                Description = "Views the System",
                SecurableObjectType = systemObjectType
            };

            // adding the Administer_System and the View_System rights.
            IRightSvc rightSvc = GatekeeperFactory.RightSvc;
            rightSvc.Add(administerSystemRight);//adding the administerSystemRight as a right.
            rightSvc.Add(viewSystemRight);//adding the viewSystemRight as a right.

            // adding the role-right assignment (System Admin - Administer_System)
            RoleRightAssignment admin_administer = new RoleRightAssignment()
            {
                Application = securableApplication,
                Role = systemAdministerRole,
                Right = administerSystemRight,
                SecurableObjectType = systemObjectType
            };

            // adding the role-right assignment (System Admin - View_System)
            RoleRightAssignment admin_view = new RoleRightAssignment()
            {
                Application = securableApplication,
                Role = systemAdministerRole,
                Right = viewSystemRight,
                SecurableObjectType = systemObjectType
            };

            IRoleRightAssignmentSvc rraSvc = GatekeeperFactory.RoleRightAssignmentSvc;
            rraSvc.Add(admin_administer);
            rraSvc.Add(admin_view);

            var adminUser = GatekeeperFactory.UserSvc.GetByLoginName("admin");
            IApplicationUserSvc appUserSvc = GatekeeperFactory.ApplicationUserSvc;
            appUserSvc.Save(new ApplicationUser(){Application = securableApplication, User = adminUser, Role = systemAdministerRole});
        }
Ejemplo n.º 9
0
 public bool Authenticate(SecurityToken mySecurityToken, ulong myToBeCheckedVertexID, ulong myCorrespondingVertexTypeID, Right myWantedAction = Right.Traverse)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 public override INotifyExpression <long> ApplyParameters(IDictionary <string, object> parameters)
 {
     return(new ObservableLongBitwiseOr(Left.ApplyParameters(parameters), Right.ApplyParameters(parameters)));
 }
Ejemplo n.º 11
0
        public void WriteAndRead()
        {
            var tempName = Guid.NewGuid().ToString();
            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var rights = from right in databaseSession.Query<Right>()
                                   where right.Name == tempName
                                   select right;

                Assert.IsNotNull(rights);
                Assert.AreEqual(0, rights.Count());

                var toAdd = new Right
                                {
                                    Id = Guid.NewGuid(),
                                    Name = tempName
                                };

                using (var transaction = databaseSession.BeginTransaction())
                {
                    databaseSession.Save(toAdd);
                    transaction.Commit();
                }
            }

            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var rights = from right in databaseSession.Query<Right>()
                             where right.Name == tempName
                             select right;

                Assert.IsNotNull(rights);
                Assert.AreEqual(1, rights.Count());

                using (var transaction = databaseSession.BeginTransaction())
                {
                    databaseSession.Delete(rights.ToArray()[0]);
                    transaction.Commit();
                }
            }

            using (var databaseSession = NHibernateHelper.OpenSession())
            {
                var rights = from right in databaseSession.Query<Right>()
                             where right.Name == tempName
                             select right;

                Assert.IsNotNull(rights);
                Assert.AreEqual(0, rights.Count());
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Updates the specified right.
 /// </summary>
 /// <param name="right">The right.</param>
 public void Update(Right right)
 {
     this.rightDao.Update(right);
 }
Ejemplo n.º 13
0
 internal override Expression BuildExpression(Expression callerExpression = null)
 {
     return(Expression.Modulo(Left.BuildExpression(callerExpression), Right.BuildExpression(callerExpression)));
 }
Ejemplo n.º 14
0
        public override Expression <Func <T, bool> > GetExpression()
        {
            var body = Left.GetExpression().And(Right.GetExpression());

            return(body);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Create a new Right object.
 /// </summary>
 /// <param name="rightID">Initial value of RightID.</param>
 /// <param name="rightName">Initial value of RightName.</param>
 public static Right CreateRight(int rightID, string rightName)
 {
     Right right = new Right();
     right.RightID = rightID;
     right.RightName = rightName;
     return right;
 }
Ejemplo n.º 16
0
 public override INotifyExpression <T> ApplyParameters(IDictionary <string, object> parameters)
 {
     return(new ObservableCoalesceExpression <T>(Left.ApplyParameters(parameters), Right.ApplyParameters(parameters)));
 }
Ejemplo n.º 17
0
 public override string ToString()
 {
     return(string.Format(Format, Left.ToString(), Right.ToString()) + "{" + (Value != null ? Value.ToString() : "(null)") + "}");
 }
Ejemplo n.º 18
0
 public override INotifyExpression <TResult> ApplyParameters(IDictionary <string, object> parameters)
 {
     return(new ObservableReversableBinaryExpression <TLeft, TRight, TResult>(Left.ApplyParameters(parameters), Right.ApplyParameters(parameters), Implementation, rightReverser, leftReverser));
 }
Ejemplo n.º 19
0
 public override Choice copy()
 {
     return(new Nor(Left.copy() as Expression, Right.copy() as Expression));
 }
Ejemplo n.º 20
0
 internal override void Emit(ILGenerator ilg, bool preserve)
 {
     Right.Emit(ilg);
     Left.EmitSet(ilg, preserve);
 }
Ejemplo n.º 21
0
 public override int Interpret(OperationContext context)
 {
     return(Left.Interpret(context) - Right.Interpret(context));
 }
Ejemplo n.º 22
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected override TResult _GetPayload(BinaryBState state)
 => Joiner(Left.GetPayload(state.left), Right.GetPayload(state.right));
Ejemplo n.º 23
0
 protected override object Evaluate(object context, EvaluationContext evalContext)
 {
     return(Convert.ToBoolean(Left.EvaluateInternal(context, evalContext)) ||
            Convert.ToBoolean(Right.EvaluateInternal(context, evalContext)));
 }
Ejemplo n.º 24
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected override long _GetSyncTime(BinaryBState state)
 => Math.Max(Left.GetSyncTime(state.left), Right.GetSyncTime(state.right));
Ejemplo n.º 25
0
        /// <summary>
        /// �������� ������ ���� �� ������� ���������� ��� ��������� �������������� ����
        /// </summary>
        public SortedList<string, Right> GetRightList(int roleID)
        {
            // ���������� ������ ���� ������������ ��� �������������
            RefreshBase();

            Monitor.Enter(baseLock);
            SortedList<string, Right> rightList = new SortedList<string, Right>();

            try
            {
                tblRight.DefaultView.RowFilter = "RoleID = " + roleID;
                int rowCnt = tblRight.DefaultView.Count;

                for (int i = 0; i < rowCnt; i++)
                {
                    DataRowView rowView = tblRight.DefaultView[i];
                    tblInterface.DefaultView.RowFilter = "ItfID = " + rowView["ItfID"];

                    if (tblInterface.DefaultView.Count > 0)
                    {
                        Right right = new Right();
                        right.ViewRight = (bool)rowView["ViewRight"];
                        right.CtrlRight = (bool)rowView["CtrlRight"];

                        string name = (string)tblInterface.DefaultView[0]["Name"];
                        if (!rightList.ContainsKey(name))
                            rightList.Add(name, right);
                    }
                }
            }
            catch (Exception ex)
            {
                AppData.Log.WriteAction((Localization.UseRussian ?
                    "������ ��� ��������� ������ ���� �� ������� ����������: " :
                    "Error getting interface objects rights list: ") + ex.Message, Log.ActTypes.Exception);
            }
            finally
            {
                Monitor.Exit(baseLock);
            }

            return rightList;
        }
Ejemplo n.º 26
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected override long _GetOtherTime(BinaryBState state)
 => Math.Min(Left.GetOtherTime(state.left), Right.GetOtherTime(state.right));
Ejemplo n.º 27
0
 /// <summary>
 /// Deletes the specified right.
 /// </summary>
 /// <param name="right">The right.</param>
 public void Delete(Right right)
 {
     this.rightDao.Delete(right);
 }
Ejemplo n.º 28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 protected override bool _IsDone(BinaryBState state) => Left.IsDone(state.left) || Right.IsDone(state.right);
Ejemplo n.º 29
0
 public bool IsReadonly(Right rt, FLStatus status)
 {
     return false;
 }
Ejemplo n.º 30
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected override BinaryBState _Init() => new BinaryBState(Left.Init(), Right.Init());
Ejemplo n.º 31
0
 protected ClaimBase(string securable, Right right)
 {
     this.Securable = securable;
     this.Right = right;
 }
Ejemplo n.º 32
0
 private bool Overlap(BinaryBState state)
 {
     return(Left.IsReady(state.left) && Right.IsReady(state.right) &&
            (Math.Max(Left.GetSyncTime(state.left), Right.GetSyncTime(state.right)) <
             Math.Min(Left.GetOtherTime(state.left), Right.GetOtherTime(state.right))));
 }
Ejemplo n.º 33
0
        void ImportRight(Application application, XmlNode node)
        {
            var name = node.Attributes["name"].Value;
            var securableObjectTypeName = node.Attributes["securableObjectType"].Value;

            var desc = string.Empty;
            var xAttrDescription = node.Attributes["description"];
            if(xAttrDescription != null)
                desc = xAttrDescription.Value;

            var securableObjectType = GatekeeperFactory.SecurableObjectTypeSvc.Get(application, securableObjectTypeName);

            Right right = new Right()
            {
                Application = application,
                Name = name,
                Description = desc,
                SecurableObjectType = securableObjectType
            };

            Console.WriteLine("Adding Right '{0}'.", name);
            try
            {
                GatekeeperFactory.RightSvc.Add(right);
                Console.WriteLine("Completed adding Right '{0}'.", name);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Error occurred while adding Right '{0}'.", name);
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 34
0
 public override string ToString()
 {
     return($"({Token.Literal} {Right.ToString()})");
 }
Ejemplo n.º 35
0
 private Reader(string securable, Right right)
     : base(securable, right)
 {
 }
Ejemplo n.º 36
0
 private void LeftRightRotation()
 {
     Right.RightRotation();
     LeftRotation();
 }
Ejemplo n.º 37
0
 private Editor(string securable, Right right)
     : base(securable, right)
 {
 }
Ejemplo n.º 38
0
 public override string ToString()
 {
     //return string.Concat(Left.ToString("X").PadLeft(16, '0'), Right.ToString("X").PadLeft(16, '0'));
     return(string.Concat(Name, string.IsNullOrEmpty(Name) ? "" : " ", Left.ToString("X").PadLeft(16, '0'), Right.ToString("X").PadLeft(16, '0')));
 }
Ejemplo n.º 39
0
 static Right()
 {
     obj = new Right();
 }
Ejemplo n.º 40
0
 protected internal override ExcelDxfBorderBase Clone()
 {
     return(new ExcelDxfBorderBase(_styles)
     {
         Bottom = Bottom.Clone(), Top = Top.Clone(), Left = Left.Clone(), Right = Right.Clone()
     });
 }
Ejemplo n.º 41
0
        public static Environment CreateEnvironmentResponse()
        {
            InfrastructureService environmentURL = new InfrastructureService { Name = InfrastructureServiceNames.environment, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/environments/5b72f2d4-7a83-4297-a71f-8b5fb26cbf14" };
            InfrastructureService provisionRequestsURL = new InfrastructureService { Name = InfrastructureServiceNames.provisionRequests, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/provisionRequests" };
            InfrastructureService queuesURL = new InfrastructureService { Name = InfrastructureServiceNames.queues, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/queues" };
            InfrastructureService requestsConnectorURL = new InfrastructureService { Name = InfrastructureServiceNames.requestsConnector, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/requestsConnector" };
            InfrastructureService subscriptionsURL = new InfrastructureService { Name = InfrastructureServiceNames.subscriptions, Value = "http://rest3api.sifassociation.org/api/solutions/auTestSolution/subscriptions" };
            IDictionary<InfrastructureServiceNames, InfrastructureService> infrastructureServices = new Dictionary<InfrastructureServiceNames, InfrastructureService>
            {
                { environmentURL.Name, environmentURL },
                { provisionRequestsURL.Name, provisionRequestsURL },
                { queuesURL.Name, queuesURL },
                { requestsConnectorURL.Name, requestsConnectorURL },
                { subscriptionsURL.Name, subscriptionsURL }
            };

            Right adminRight = new Right { Type = "ADMIN", Value = "APPROVED" };
            Right createRight = new Right { Type = "CREATE", Value = "APPROVED" };
            IDictionary<string, Right> rights = new Dictionary<string, Right> { { adminRight.Type, adminRight } };

            Infrastructure.Service studentPersonalsService = new Infrastructure.Service
            {
                ContextId = "DEFAULT",
                Name = "StudentPersonals",
                Rights = rights,
                Type = "OBJECT"
            };
            Infrastructure.Service schoolInfosService = new Infrastructure.Service
            {
                ContextId = "DEFAULT",
                Name = "SchoolInfos",
                Rights = rights,
                Type = "OBJECT"
            };
            ICollection<Infrastructure.Service> services = new SortedSet<Infrastructure.Service>
            {
                studentPersonalsService, schoolInfosService
            };

            ProvisionedZone schoolZone = new ProvisionedZone { SifId = "auSchoolTestingZone", Services = services };
            ProvisionedZone studentZone = new ProvisionedZone { SifId = "auStudentTestingZone", Services = services };

            IDictionary<string, ProvisionedZone> provisionedZones = new SortedDictionary<string, ProvisionedZone> { { schoolZone.SifId, schoolZone }, { studentZone.SifId, studentZone } };

            Environment environmentResponse = CreateEnvironmentRequest();
            environmentResponse.InfrastructureServices = infrastructureServices;
            environmentResponse.ProvisionedZones = provisionedZones;

            return environmentResponse;
        }
Ejemplo n.º 42
0
 /// <summary>
 /// Tests if the value contained in this instance is equal to the one in the other instance
 /// </summary>
 /// <param name="other">The instance to compare to</param>
 /// <returns>true if both instances wraps the same value, according to object.Equals rules</returns>
 public bool Equals(Right other)
 {
     return(object.Equals(other.Value, this.Value));
 }
Ejemplo n.º 43
0
 /// <summary>
 /// There are no comments for Right in the schema.
 /// </summary>
 public void AddToRight(Right right)
 {
     base.AddObject("Right", right);
 }
Ejemplo n.º 44
0
 public override bool ProcessBinding()
 {
     Right.GetBackingBox().TeleportCentered(Left.GetBackingBox().GetCenterPoint());
     return(false);
 }
Ejemplo n.º 45
0
        public void sessioning1()
        {
            User test = new User();
            test.Email = "*****@*****.**";
            test.Password = "******";
            test.Type = UserType.admin;
            Package p = new Package();
            p.Id = 1001;
            p.Name = "p1001";
            p.OwnerEmail = "*****@*****.**";
            p.FileIds = new int[] {092};
            FileInfo fi = new FileInfo();
            fi.Id = 092;
            fi.Name = "testItem";
            fi.OwnerEmail = "*****@*****.**";
            fi.Type = FileType.text;
            FileInfo fiu = new FileInfo();
            fiu.Id = 092;
            fiu.Name = "UpdatedtestItem";
            fiu.OwnerEmail = "*****@*****.**";
            fiu.Type = FileType.text;
            Right r = new Right();
            r.ItemId = 092;
            r.Type = RightType.edit;
            r.Until = DateTime.Now.AddDays(1);
            r.UserEmail = "*****@*****.**";

            using (ShimsContext.Create())
            {
                ShimServiceClient.AllInstances.GetUserByEmailString = (a, b) => test;
                ShimServiceClient.AllInstances.CreatePackagePackage = (a, b) => {return 1;};
                ShimServiceClient.AllInstances.GetPackageByIdInt32 = (a, b) => {return p;};
                ShimServiceClient.AllInstances.AddToPackageInt32ArrayInt32 = (a, b, c) => {};
                ShimServiceClient.AllInstances.GetFileInfoByIdInt32 = (a, b) => {return fi;};
                ShimServiceClient.AllInstances.AddTagStringInt32 = (a, b, c) => { };
                ShimServiceClient.AllInstances.DeleteFileByIdInt32 = (a, b) => { };
                ShimServiceClient.AllInstances.GetRightStringInt32 = (a, b, c) => {return r;};
                ShimServiceClient.AllInstances.UpdateFileInfoFileInfo = (a, b) => { };

                Controller.LogIn("*****@*****.**", "test");
                Controller.CreatePackage(p);
                Controller.AddToPackage(new int[]{092},1001);
                Controller.AddTag("tag1", 092);
                Controller.DeleteFileById(092);
                try
                {
                    Controller.UpdateFileInfo(fiu);
                } catch(OriginalNotFoundException e){
                    //This should be thrown
                }
            }
        }
Ejemplo n.º 46
0
 private Deleter(string securable, Right right)
     : base(securable, right)
 {
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Adds the specified right,inserts right into the system.
 /// </summary>
 /// <param name="right">The right.</param>
 public void Add(Right right)
 {
     this.rightDao.Add(right);
 }
Ejemplo n.º 48
0
 /// <summary>Клон узла</summary>
 /// <returns>Клон узла</returns>
 public override ExpressionTreeNode Clone() => new ComputedBracketNode(_Bracket)
 {
     Left  = Left?.Clone(),
     Right = Right?.Clone()
 };
Ejemplo n.º 49
0
Archivo: UCIt.cs Proyecto: hkiaipc/fnq
 public bool IsReadonly(Right rt, FLStatus status)
 {
     return !(rt.Value == fnbx.Right.SenderValue &&
         (status == FLStatus.New || status == FLStatus.Created));
 }
Ejemplo n.º 50
0
 public override string ToString()
 {
     return($"{Left.ToString()} and {Right.ToString()}");
 }
Ejemplo n.º 51
0
        private void cmdAddRight(string arg)
        {
            Right r = null;
            if ((editRight.EditValue as Right) == null)
            {
                r = new Right { Name = editRight.EditValue.ToString() };
                r.Save();
            }
            else
                r = editRight.EditValue as Right;

            RoleRight rr = new RoleRight
            {
                RightId = r.Id,
                RoleId = CurrentRole.Id
            };

            rr.Save();
            listEntityRoleRight.BindData();

            editRight.EditValue = null;
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Gets the LINQ expression which represents the current specification.
 /// </summary>
 /// <returns>The LINQ expression.</returns>
 public override Expression <Func <T, bool> > ToExpression()
 {
     return(Left.ToExpression().Or(Right.ToExpression()));
 }
 public override dynamic Get(State state)
 => Left.Get(state) + Right.Get(state);
Ejemplo n.º 54
0
 /// <summary>
 /// Nombres de noeuds dans l'arbre
 /// </summary>
 /// <returns></returns>
 public int NumberOfNodes()
 {
     return(1 + (HasLeft() ? Left.NumberOfNodes() : 0) + (HasRight() ? Right.NumberOfNodes() : 0));
 }
Ejemplo n.º 55
0
    void UpdateRight(HttpContext context)
    {
        string id = context.Request["id"];
        string mvs = context.Request["mvs"];
        string msg = string.Empty;
        try {
            Role obj = new Role {
                Id = new Guid(id) ,
                Rights = new List<Right>()
            };
            string[] arry1 = mvs.Split(',');
            foreach (var item in arry1) {
                string[] arry2 = item.Split('=');
                var newitem = new Right {
                    ModuleId = int.Parse(arry2[0]) ,
                    Permission = int.Parse(arry2[1])
                };
                obj.Rights.Add(newitem);
            }
            RepositoryFactory<RolesRepository>.Get().UpdateRight(obj);
            //log
            AppLog.Write("更新角色权限" , AppLog.LogMessageType.Info , "id=" + id , this.GetType());

            context.Response.End();
        } catch (Exception ex) {
            AppLog.Write("更新角色权限 出错" , AppLog.LogMessageType.Error , "id=" + id , ex , this.GetType());

            msg = ex.Message;
        }
        if (!string.IsNullOrWhiteSpace(msg)) {
            context.Response.Write("{\"msg\":\"" + msg + "\"}");
        }
    }
Ejemplo n.º 56
0
        public override string ToString()
        {
            var right = Right is ExpressionTreeBranch <T>?$"({Right})" : Right.ToString();

            return($"{Left}-{right}");
        }
 public override IExpression?Differentiate(string byVariable)
 {
     return(new SubtractExpression(Left?.Differentiate(byVariable), Right?.Differentiate(byVariable)));
 }
Ejemplo n.º 58
0
        /* TODO - It is noted that it should never be called by other than the controller.
         * Do we even need a public method then?
         * If it should only be used by the controller, it can just use client.GetRight(...) as it already does.
         *
        /// <summary>Looks up a Right by the email of the User and the Id of the Item involved.</summary>
        /// <param name="email">The Email of the User whom the Right concerns.</param>
        /// <param name="itemId">The Id of the Item which the Right concerns.</param>
        /// <returns>The Right with the matching email and itemId.</returns>
        private static Right GetRight(string email, int itemId)
        {
            throw new NotImplementedException();
        }
         */
        /// <summary>Updates the exising right that has matching UserEmail and ItemId fields, with the rest of the fields from the given updatedRight.</summary>
        /// <param name="updatedRight">The updated Right object.</param>
        public static void UpdateRight(Right updatedRight)
        {
            if (_sessionUser == null)
                throw new NotLoggedInException();

            if (updatedRight == null || updatedRight.UserEmail == null)
                throw new InadequateObjectException();

            using (var client = new ServiceClient())
            {
                Right right;

                try
                {
                    right = client.GetRight(updatedRight.UserEmail, updatedRight.ItemId);
                }
                catch (Exception)
                {
                    throw new OriginalNotFoundException();
                }

                if(right == null)
                    throw new OriginalNotFoundException();

                Item item = null;

                if (FileExists(updatedRight.ItemId))
                    item = client.GetFileInfoById(updatedRight.ItemId);

                if (PackageExists(updatedRight.ItemId))
                    item = client.GetPackageById(updatedRight.ItemId);

                if(item == null)
                    throw new ObjectNotFoundException();

                if (_sessionUser.Type != UserType.admin
                    && !_sessionUser.Email.Equals(item.OwnerEmail)
                    && !HasEditRights(updatedRight.ItemId))
                    throw new InsufficientRightsException();

                client.UpdateRight(updatedRight);
            }
        }
Ejemplo n.º 59
0
        public void HasRight_SameRightTypeSameAdministrativeIdPropertyInitiativeIdIsNull_True()
        {
            var right = new Right(RightType.AddCities, "locationId", null);

            var hasRight = right.HasRight(RightType.AddCities, "locationId", "initiativeId1");

            hasRight.Should().BeTrue();
        }
Ejemplo n.º 60
0
Archivo: Add.cs Proyecto: azend/Poly
 public override string ToString()
 {
     return(Left.ToString() + " + " + Right.ToString());
 }