コード例 #1
0
 public bool getUserPermission(int storeid, string permission)
 {
     Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
     if (permission is null)
     {
         Logger.logError(CommonStr.ArgsTypes.None, this, System.Reflection.MethodBase.GetCurrentMethod());
         return(false);
     }
     int[] perms;
     if (!Store_options.TryGetValue(storeid, out perms))
     {
         return(false);
     }
     if (permission.Equals(CommonStr.MangerPermission.Comments))
     {
         return(perms[0] == 1);
     }
     if (permission.Equals(CommonStr.MangerPermission.Purchase))
     {
         return(perms[1] == 1);
     }
     if (permission.Equals(CommonStr.MangerPermission.Product))
     {
         return(perms[2] == 1);
     }
     if (permission.Equals(CommonStr.MangerPermission.DiscountPolicy))
     {
         return(perms[3] == 1);
     }
     if (permission.Equals(CommonStr.MangerPermission.PurachsePolicy))
     {
         return(perms[4] == 1);
     }
     return(false);
 }
コード例 #2
0
        //Set User permission over spesific store
        public Tuple <bool, string> setPermmisions(int store_id, int[] permission_set, bool saveChanges = false)
        {
            Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
            if (store_id < 1)
            {
                return(new Tuple <bool, string>(false, "No such Store id\n"));
            }
            if (permission_set == null)
            {
                return(new Tuple <bool, string>(false, "Null Argument\n"));
            }
            if (!isStorManager(store_id) && !isStoreOwner(store_id))
            {
                return(new Tuple <bool, string>(false, "The user is not Store Manager or owner\n"));
            }

            if (Store_options.ContainsKey(store_id))
            {
                int[] oldp = Store_options[store_id];

                List <UserStorePermissions> perms = DbManager.Instance.GetUserStorePermissionSet(store_id, this.Name);
                Store_options.Remove(store_id);
                try
                {
                    DbManager.Instance.DeletePermission(perms);
                }
                catch (Exception ex)
                {
                    Logger.logError("Delete Permissions error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod());
                    return(new Tuple <bool, string>(false, "Delete Permissions DB Failed cannot proceed"));
                }
            }
            Store_options.Add(store_id, permission_set);
            List <UserStorePermissions> permsN = AdapterUser.CreateNewPermissionSet(Name, store_id, permission_set);

            try
            {
                DbManager.Instance.InsertUserStorePermissionSet(permsN, saveChanges);
            }
            catch (Exception ex)
            {
                Logger.logError("Insert Permissions error : " + ex.Message, this, System.Reflection.MethodBase.GetCurrentMethod());
                return(new Tuple <bool, string>(false, "Insert Permissions DB Failed cannot proceed"));
            }
            return(new Tuple <bool, string>(true, ""));
        }
コード例 #3
0
 public bool RemovePermission(int store_id)
 {
     Logger.logEvent(this, System.Reflection.MethodBase.GetCurrentMethod());
     return(Store_options.Remove(store_id));
 }