コード例 #1
0
ファイル: CharacterRecord.cs プロジェクト: 0xFh/Asda2-Project
 /// <summary>
 /// Checks if a character with the given name already exists.
 /// </summary>
 /// <param name="characterName">the name to check for</param>
 /// <returns>true if the character exists; false otherwise</returns>
 public static bool Exists(string characterName)
 {
     try
     {
         return(ActiveRecordBase <CharacterRecord> .Exists((ICriterion)Restrictions.Like("Name", characterName)));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
コード例 #2
0
ファイル: CharacterRecord.cs プロジェクト: 0xFh/Asda2-Project
 /// <summary>
 /// Checks if a character with the given Id already exists.
 /// </summary>
 public static bool Exists(uint entityLowId)
 {
     try
     {
         return(ActiveRecordBase <CharacterRecord> .Exists((ICriterion)Restrictions.Eq("Guid", (long)entityLowId)));
     }
     catch (Exception ex)
     {
         RealmDBMgr.OnDBError(ex);
         return(false);
     }
 }
コード例 #3
0
        /// <summary>Checks to see if an account already exists.</summary>
        /// <returns>true if the account exists; false otherwise</returns>
        public static bool DoesAccountExist(string accName)
        {
            AccountMgr instance = AccountMgr.Instance;

            if (instance.IsCached)
            {
                using (instance.m_lock.EnterReadLock())
                    return(instance.m_cachedAccsByName.ContainsKey(accName));
            }
            else
            {
                return(ActiveRecordBase <Account> .Exists(new ICriterion[1]
                {
                    (ICriterion)Restrictions.InsensitiveLike("Name", accName, MatchMode.Exact)
                }));
            }
        }
コード例 #4
0
        public bool IsPropertyUnique(string property)
        {
            object obj2         = this.GetValue(property);
            object primaryValue = this.GetPrimaryValue();

            if (obj2 == null)
            {
                return(false);
            }
            bool flag = false;

            if (primaryValue == null)
            {
                flag = !ActiveRecordBase <T> .Exists <SimpleExpression>(Restrictions.Eq(property, obj2));
            }
            else
            {
                flag = !ActiveRecordBase <T> .Exists(new ICriterion[] { Restrictions.Eq(property, obj2), Restrictions.Not(Restrictions.Eq(EntityBase <T> .PrimaryKeyName, primaryValue)) });
            }
            return(flag);
        }
コード例 #5
0
 /// <summary>
 /// Check if the <paramref name="id"/> exists in the database.
 /// </summary>
 /// <typeparam name="PkType">The <c>System.Type</c> of the PrimaryKey</typeparam>
 /// <param name="id">The id to check on</param>
 /// <returns><c>true</c> if the ID exists; otherwise <c>false</c>.</returns>
 public bool Exists <PkType>(PkType id)
 {
     return(ActiveRecordBase <T> .Exists(id));
 }
コード例 #6
0
        /// <summary> </summary>
        public bool Perform(ExecuteWhen exec, IEngineContext context, IController controller, IControllerContext controllerContext)
        {
            //this should be removed
            if (!Controllers.BaseController.authenticated())
            {
                System.Web.HttpContext.Current.Response.Redirect("~/center/login.castle");
            }

            controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll();

            controllerContext.PropertyBag["userService"]   = userService;
            controllerContext.PropertyBag["helperService"] = helperService;
            controllerContext.PropertyBag["user"]          = userService.getUserFull();

            //return true;

            if (context.Request.IsLocal)
            {
                if (!controllerContext.Action.Contains("install") && ActiveRecordBase <appuser> .Exists())
                {
                    //controllerContext.PropertyBag["campuses"] = ActiveRecordBase<campus>.FindAll();
                    controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll();

                    controllerContext.PropertyBag["userService"]   = userService;
                    controllerContext.PropertyBag["helperService"] = helperService;
                    controllerContext.PropertyBag["user"]          = userService.getUserFull();
                }
                return(true);
            }
            // Read previous authenticated principal from session
            // (could be from cookie although with more work)
            User user = (User)context.Session["user"];

            // Redirect to dailystellar.wsu.edu because dailystellar.com can't catch the cookie
            //if (context.Request.Uri.ToString().ToLower().Contains("dailystellar.com"))
            //{
            //     context.Response.Redirect("http://dev.stellar.wsu.edu/admin");
            //     return false;
            //}
            // Sets the principal as the current user
            context.CurrentUser = user;
            if (Controllers.BaseController.authenticated())
            {
                return(true);
            }
            // Checks if it is OK
            //if (context.CurrentUser == null ||
            //    !context.CurrentUser.Identity.IsAuthenticated ||
            //    !Authentication.logged_in())
            if (Controllers.BaseController.authenticated())
            {
                // Not authenticated, redirect to login
                String username = userService.getNid();



                appuser[] users = ActiveRecordBase <appuser> .FindAllByProperty("nid", username);

                if (users.Length == 0)
                {
                    //context.Response.RedirectToUrl("~/admin", false);
                    //return false;
                }
                //context.Session["manager"] = true;
                //context.Cookies["unldap"].Value = username;
                user = new User(username, new String[0]);
                context.CurrentUser = user;
                System.Threading.Thread.CurrentPrincipal = user;
            }


            if (userService.isLogedIn())// || Authentication.logged_in()) /* not 100% we can't just strip off the Authentication.*/
            {
                appuser currentUser = userService.getUser();
                if (currentUser != null)
                {
                    appuser you = ActiveRecordBase <appuser> .Find(currentUser.baseid);

                    you.logedin     = true;
                    you.last_active = DateTime.Now;
                    ActiveRecordMediator <appuser> .Update(you);

                    ActiveRecordMediator <appuser> .Save(you);
                }
            }
            if (!controllerContext.Action.Contains("install"))
            {
                // controllerContext.PropertyBag["campuses"] = ActiveRecordBase<campus>.FindAll();
                controllerContext.PropertyBag["post_types"] = ActiveRecordBase <posting_type> .FindAll();

                controllerContext.PropertyBag["userService"]   = userService;
                controllerContext.PropertyBag["helperService"] = helperService;
                controllerContext.PropertyBag["user"]          = userService.getUserFull();
            }
            // Everything is ok
            return(true);
        }
コード例 #7
0
ファイル: PetitionRecord.cs プロジェクト: uvbs/Asda2-Server
 public static bool CanBuyPetition(uint ownerId)
 {
     return(!ActiveRecordBase <PetitionRecord> .Exists <int>((int)ownerId));
 }
コード例 #8
0
ファイル: ManagerBase.cs プロジェクト: 605333616/Match
 public bool Exists(IList <ICriterion> queryConditions)
 {
     return(ActiveRecordBase.Exists(typeof(T), queryConditions.ToArray()));
 }
コード例 #9
0
ファイル: ManagerBase.cs プロジェクト: 605333616/Match
 public bool Exists(int id)
 {
     return(ActiveRecordBase.Exists(typeof(T), id));
 }