示例#1
0
        /// <summary> </summary>
        public static Boolean clearTmps <t>()
        {
            t[] items = ActiveRecordBase <t> .FindAll();

            bool result = false;

            foreach (dynamic item in items)
            {
                if (item.tmp == true && item.baseid > 0)
                {
                    if (userService.isActive(item.editing) && item.editing == userService.getUser())
                    {
                        //NOTE THIS IS NEEDING TO BE CORRECTED>> item.editing is null
                        //For some resaon when we try to access it it's like we have one layer deep
                        //and this item uses the :publish_base:_base model inheritence
                        //LogService.writelog("Releasing editor from item ", item.editing.nid, item.baseid);
                        logger.writelog("Deleting tmp item ", item.baseid);
                        ActiveRecordMediator <dynamic> .Delete(item);

                        result = true;
                    }
                }
            }
            return(result);
        }
示例#2
0
        /// <summary> </summary>
        public void list_users(int page, int searchId, string target, string filter, Boolean ajax)
        {
            userService.clearConnections <posting>();

            var pageing = new Dictionary <string, int>();

            switch (target)
            {
            case "admin": {
                pageing.Add("adminPaging", page); break;
            }

            case "feu": {
                pageing.Add("feuPaging", page); break;
            }
            }

            PropertyBag["groups"] = ActiveRecordBase <user_group> .FindAll();


            var userpool = ActiveRecordBase <appuser> .FindAll();

            int pag = 0;

            PropertyBag["admin_users"] = PaginationHelper.CreatePagination((IList)userpool.Where(x => x.groups.isAdmin == true).ToList(), 15, (pageing.TryGetValue("adminPaging", out pag) ? pag : 0));

            pag = 0;
            PropertyBag["FEusers"] = PaginationHelper.CreatePagination((IList)userpool.Where(x => x.groups.isAdmin == false).ToList(), 15, (pageing.TryGetValue("feuPaging", out pag) ? pag : 0));
            //PropertyBag["user_groups"] = ActiveRecordBase<user_groups>.FindAll();
            RenderView("list");
        }
        public void Edit(int id)
        {
            advertisement advertisement = ActiveRecordBase <advertisement> .Find(id);

            PropertyBag["advertisementimages"] = advertisement.Images;
            PropertyBag["tags"] = ActiveRecordBase <tags> .FindAll();

            PropertyBag["advertisement"] = ActiveRecordBase <advertisement> .Find(id);

            media_types imgtype = ActiveRecordBase <media_types> .Find(2);

            PropertyBag["images"] = imgtype.media_typed;
            //PropertyBag["images"] = ActiveRecordBase<media_repo>.FindAll();
            PropertyBag["authors"] = ActiveRecordBase <users> .FindAll();

            //PropertyBag["classifiedtype"] = ActiveRecordBase<ClassifiedType>.FindAll();
            //PropertyBag["location"] = ActiveRecordBase<LocationType>.FindAll();
            List <tags> tags = new List <tags>();

            tags.AddRange(ActiveRecordBase <advertisement> .Find(id).Tags);
            int tagscounts = 0;

            if (ActiveRecordBase <advertisement> .Find(id).Tags != null)
            {
                tagscounts = ActiveRecordBase <advertisement> .Find(id).Tags.Count;
            }

            for (int i = tagscounts; i < 2; i++)
            {
                tags.Add(new tags());
            }
            PropertyBag["advertisementtags"] = tags;
            RenderView("new");
        }
示例#4
0
 public static Asda2ItemRecord[] LoadItemsContainersFirst(uint lowChrId)
 {
     return(ActiveRecordBase <Asda2ItemRecord> .FindAll(Asda2ItemRecord.ContOrder, new ICriterion[1]
     {
         (ICriterion)Restrictions.Eq("OwnerId", (object)lowChrId)
     }));
 }
示例#5
0
        /// <summary> </summary>
        public void edit_field(int id)
        {
            field_types field = ActiveRecordBase <field_types> .Find(id);

            PropertyBag["field"] = field;

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

            string ele_str = fieldsService.getfieldmodel_dynamic(field);

            PropertyBag["nat_html_ele"] = ele_str;


            //string json = "{\"Items\":[{ \"Name\":\"Apple\", \"Price\":12.3 },{ \"Name\":\"Grape\", \"Price\":3.21 }],\"Date\":\"21/11/2010\"}";
            var jss = new JavaScriptSerializer();
            var ele = jss.Deserialize <Dictionary <string, dynamic> >(field.attr.ToString());

            //elementSet ele = (elementSet)JsonConvert.DeserializeObject(field.attr.ToString(), typeof(elementSet));
            //string ele_str = FieldsService.getfieldmodel(ele);
            PropertyBag["groups"] = ActiveRecordBase <user_group> .FindAll();

            PropertyBag["users"] = ActiveRecordBase <appuser> .FindAll();

            PropertyBag["html_ele"] = ele_str;
            PropertyBag["ele"]      = ele;

            RenderView("../admin/fields/new");
        }
示例#6
0
        /// <summary> </summary>
        public static IList <posting> get_postings(String type_alias, Boolean usedev, Boolean deleted, posting parent)
        {
            List <AbstractCriterion> filtering = new List <AbstractCriterion>();

            filtering.Add(Expression.IsNull("parent"));    //make it the working post
            filtering.Add(Expression.Eq("deleted", deleted));
            filtering.Add(Expression.Eq("post_type", ActiveRecordBase <posting_type> .FindFirst(
                                            new List <AbstractCriterion>()
            {
                Expression.Eq("alias", type_alias)
            }.ToArray())
                                        ));
            posting[] postlist = ActiveRecordBase <posting> .FindAll(new Order[] { Order.Desc("baseid") }, filtering.ToArray());

            List <posting> outputlist = new List <posting>();

            if (postlist.Count() > 0)
            {
                foreach (posting post in postlist)
                {
                    posting posting = post.get_published();
                    if (posting != null)
                    {
                        outputlist.Add(posting);
                    }
                }
            }
            return(outputlist);
        }
示例#7
0
        /// <summary> </summary>
        public static IList <posting_type> get_post_types(Boolean is_admin)
        {
            List <AbstractCriterion> filtering = new List <AbstractCriterion>();

            filtering.Add(Expression.Eq("is_admin", is_admin));
            return(ActiveRecordBase <posting_type> .FindAll(filtering.ToArray()));
        }
示例#8
0
        /// <summary> </summary>
        public string process_fields(string text, posting place, Hashtable param)
        {
            String result = text;

            if (place.post_type != null)
            {
                List <AbstractCriterion> typeEx = new List <AbstractCriterion>();
                typeEx.Add(Expression.Eq("type", place.post_type.alias));

                field_types[] ft = ActiveRecordBase <field_types> .FindAll(typeEx.ToArray());

                List <string> fields = new List <string>();

                if (ft != null)
                {
                    foreach (field_types ft_ in ft)
                    {
                        string value = "";
                        if (text.Contains("$!{" + ft_.alias + "}"))
                        {
                            //log.Error("on field:" + ft_.alias);
                            value  = get_field_value(ft_, place);
                            result = result.Replace("$!{" + ft_.alias + "}", value);
                            PropertyBag["" + ft_.alias] = value;
                        }
                    }
                }
            }
            return(result);
        }
示例#9
0
 public static AchievementRecord[] Load(uint[] achievementEntryIds)
 {
     return(ActiveRecordBase <AchievementRecord> .FindAll(new ICriterion[1]
     {
         (ICriterion)Restrictions.In("_achievementEntryId", (ICollection)achievementEntryIds)
     }));
 }
        /// <summary> </summary>
        public void sites()
        {
            PropertyBag["buttons"]      = new String[] { "edit", "delete" };
            PropertyBag["default_site"] = ActiveRecordBase <site> .FindAll().Where(x => x.is_default == true);

            PropertyBag["sites"] = ActiveRecordBase <site> .FindAll().Where(x => x.is_default == false);
        }
        /// <summary> </summary>
        public void taxonomy()
        {
            //PropertyBag["campuses"] = ActiveRecordBase<campus>.FindAll(Order.Asc("name"));
            PropertyBag["taxonomy_types"] = ActiveRecordBase <taxonomy_type> .FindAll(Order.Asc("name"));

            RenderView("../admin/taxonomy/list");
        }
        /// <summary> </summary>
        public void configuration(int siteid)
        {
            PropertyBag["frontend_themelist"] = themeService.list_themes();

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

            PropertyBag["posting_type_actions"] = ActiveRecordBase <posting_type_action> .FindAll();

            site site_obj = new site();

            if (siteid > 0)
            {
                site_obj = ActiveRecordBase <site> .Find(siteid);
            }
            else
            {
                List <AbstractCriterion> filtering = new List <AbstractCriterion>();
                filtering.Add(Expression.Eq("is_default", true));
                site_obj = ActiveRecordBase <site> .FindFirst(filtering.ToArray());
            }
            PropertyBag["site"] = site_obj;

            foreach (options option in site_obj.options)
            {
                if (!String.IsNullOrWhiteSpace(option.option_key))
                {
                    PropertyBag[option.option_key.ToUpper()] = option.value;//ie: post.get_meta("title");
                }
            }

            RenderView("../admin/configuration");
        }
示例#13
0
        /// <summary> </summary>
        virtual public String get_processed()
        {
            if (this.process)
            {
                List <AbstractCriterion> typeEx = new List <AbstractCriterion>();
                typeEx.Add(Expression.Eq("model", "placeController"));
                //typeEx.Add(Expression.Eq("set", this.model.baseid));

                field_types[] ft = ActiveRecordBase <field_types> .FindAll(typeEx.ToArray());

                List <string> fields    = new List <string>();
                Hashtable     hashtable = new Hashtable();
                hashtable["item"] = this;

                if (ft != null)
                {
                    foreach (field_types ft_ in ft)
                    {
                        //string value = "";
                        //value = FieldsService.getFieldVal(ft_, this);
                        //hashtable["" + ft_.alias] = value;
                        //log.Info("hashtable[" + ft_.alias+"]" + value);
                    }
                }
                return(renderService.proccessText(hashtable, this.content));
            }
            return("false");
        }
示例#14
0
        /// <summary> </summary>
        public static Boolean loginUser()
        {
            String username = System.Web.HttpContext.Current.Response.Cookies["unldap"].Value; //Authentication.authenticate();

            HttpContext.Current.Request.Cookies["unldap"].Value = username;                    //Maybe this should be md5'd?
            // save user in database
            appuser[] user_list = ActiveRecordBase <appuser> .FindAll();

            appuser temp = null;

            foreach (appuser user in user_list)
            {
                if (!string.IsNullOrEmpty(user.nid) && user.nid.ToUpper() == username.ToUpper())
                {
                    temp = user;
                }
            }
            if (temp != null)
            {
                temp.logedin = true;
                ActiveRecordMediator <appuser> .Save(temp);

                return(temp.logedin);
            }
            return(false);
        }
示例#15
0
 /// <summary>Retrieves the list of character relations</summary>
 /// <returns>The list of all characters relations.</returns>
 public static BaseRelation[] GetAll()
 {
     return(((IEnumerable <CharacterRelationRecord>)ActiveRecordBase <CharacterRelationRecord> .FindAll())
            .Select <CharacterRelationRecord, BaseRelation>(
                (Func <CharacterRelationRecord, BaseRelation>)(crr => RelationMgr.CreateRelation(crr)))
            .ToArray <BaseRelation>());
 }
示例#16
0
 /// <summary>Retrieves the list of character relations</summary>
 /// <returns>The list of all characters relations.</returns>
 public static BaseRelation[] GetAll()
 {
     return(ActiveRecordBase <CharacterRelationRecord> .FindAll()
            .Select(
                crr => RelationMgr.CreateRelation(crr))
            .ToArray());
 }
示例#17
0
        public static void Init()
        {
            foreach (Asda2ItemAuctionCategory key1 in Enum.GetValues(typeof(Asda2ItemAuctionCategory))
                     .Cast <Asda2ItemAuctionCategory>())
            {
                Dictionary <AuctionLevelCriterion, SortedSet <Asda2ItemRecord> > dictionary =
                    new Dictionary <AuctionLevelCriterion, SortedSet <Asda2ItemRecord> >();
                foreach (AuctionLevelCriterion key2 in Enum.GetValues(typeof(AuctionLevelCriterion))
                         .Cast <AuctionLevelCriterion>())
                {
                    dictionary.Add(key2,
                                   new SortedSet <Asda2ItemRecord>((IComparer <Asda2ItemRecord>)Asda2AuctionMgr.ItemsComparer));
                }
                Asda2AuctionMgr.CategorizedItemsById.Add(key1, dictionary);
            }

            foreach (Asda2ItemRecord loadAuctionedItem in Asda2ItemRecord.LoadAuctionedItems())
            {
                Asda2AuctionMgr.RegisterItem(loadAuctionedItem);
            }
            foreach (AuctionSelledRecord auctionSelledRecord in ActiveRecordBase <AuctionSelledRecord> .FindAll())
            {
                if (!Asda2AuctionMgr.SelledRecords.ContainsKey(auctionSelledRecord.ReciverCharacterId))
                {
                    Asda2AuctionMgr.SelledRecords.Add(auctionSelledRecord.ReciverCharacterId,
                                                      new List <AuctionSelledRecord>());
                }
                Asda2AuctionMgr.SelledRecords[auctionSelledRecord.ReciverCharacterId].Add(auctionSelledRecord);
            }
        }
示例#18
0
        private bool Start()
        {
            Guild[] guilds = null;

#if DEBUG
            try
            {
#endif
            guilds = ActiveRecordBase <Guild> .FindAll();

#if DEBUG
        }
        catch (Exception e)
        {
            RealmDBMgr.OnDBError(e);
            guilds = ActiveRecordBase <Guild> .FindAll();
        }
#endif

            if (guilds != null)
            {
                foreach (var guild in guilds)
                {
                    guild.InitAfterLoad();
                }
            }

            return(true);
        }
示例#19
0
        /// <summary> </summary>
        public static Hashtable make_all_post_json_table(String type, Boolean dev)
        {
            Hashtable all = new Hashtable();
            Dictionary <string, string> queries   = httpService.get_request_parmas_obj();
            List <AbstractCriterion>    filtering = new List <AbstractCriterion>();

            filtering.Add(Expression.Eq("post_type", ActiveRecordBase <posting_type> .FindFirst(
                                            new List <AbstractCriterion>()
            {
                Expression.Eq("alias", type)
            }.ToArray())
                                        ));
            posting[] posts = ActiveRecordBase <posting> .FindAll(new Order[] { Order.Desc("revision"), Order.Desc("version") }, filtering.ToArray());

            var i = 0;

            foreach (posting post in posts)
            {
                String name = (queries.ContainsKey("format") && queries["format"] == "xml") ? ("post_" + i.ToString()) : i.ToString();
                all.Add(name, make_post_json_table(post.baseid, type, dev));
                i++;
            }

            return(all);
        }
示例#20
0
        virtual public IList <style_option_types> getUnUsed(styles style, geometric_events events)
        {
            IList <style_option_types> unUsed = new List <style_option_types>();

            //IList<style_options> used = getUsed();
            if (style.id > 0)
            {
                style_option_types[] all_op = ActiveRecordBase <style_option_types> .FindAll();

                foreach (style_option_types ops in all_op)
                {
                    if (ops.style_type.Contains(style.type))
                    {
                        if (style._option != null && style._option.Count > 0)
                        {
                            foreach (style_options op in style._option)
                            {
                                if (this.id == op.user_event.id)
                                {
                                    if (op.value == "")
                                    {
                                        unUsed.Add(ops);
                                    }
                                }
                            }
                        }
                        else
                        {
                            unUsed.Add(ops);
                        }
                    }
                }
            }
            return(unUsed);
        }
示例#21
0
 public static Asda2ItemRecord[] LoadItems(uint lowCharId)
 {
     return(ActiveRecordBase <Asda2ItemRecord> .FindAll(new ICriterion[1]
     {
         (ICriterion)Restrictions.Eq("OwnerId", (object)lowCharId)
     }));
 }
示例#22
0
 public static AchievementProgressRecord[] Load(int chrRecordId)
 {
     return(ActiveRecordBase <AchievementProgressRecord> .FindAll(new ICriterion[1]
     {
         (ICriterion)Restrictions.Eq("_characterGuid", (object)chrRecordId)
     }));
 }
示例#23
0
 public static Asda2ItemRecord[] LoadAuctionedItems()
 {
     return(ActiveRecordBase <Asda2ItemRecord> .FindAll(new ICriterion[1]
     {
         (ICriterion)Restrictions.Eq("IsAuctioned", (object)true)
     }));
 }
示例#24
0
        /// <summary> </summary>
        virtual public List <string> get_post_feilds(posting post)
        {
            List <AbstractCriterion> typeEx = new List <AbstractCriterion>();

            typeEx.Add(Expression.Eq("set", post.post_type.baseid));
            field_types[] ft = ActiveRecordBase <field_types> .FindAll(typeEx.ToArray());

            List <string> fields = new List <string>();

            List <string> user_fields = new List <string>();

            if (ft != null)
            {
                foreach (field_types ft_ in ft)
                {
                    if ((ft_.users.Count > 0) || (ft_.users.Count > 0))
                    {
                        if (ft_.users.Contains(userService.getUser()))
                        {
                            user_fields.Add(fieldsService.get_field(ft_, post));
                        }
                        else
                        {
                            fields.Add(fieldsService.get_field(ft_, post));
                        }
                    }
                    else
                    {
                        user_fields.Add(fieldsService.get_field(ft_, post));
                    }
                }
            }
            return(fields);
        }
示例#25
0
        /// <summary> </summary>
        public string[] get_feild_short_codes(posting cal_events)
        {
            //log.Info("________________________________________________________________________________\nLoading feilds For:" + place.prime_name+"("+place.baseid+")\n");
            List <AbstractCriterion> typeEx = new List <AbstractCriterion>();

            typeEx.Add(Expression.Eq("model", "placeController"));
            // typeEx.Add(Expression.Eq("set", cal_events.model.baseid));

            field_types[] ft = ActiveRecordBase <field_types> .FindAll(typeEx.ToArray());

            List <string> fields = new List <string>();

            string[] codes = new string[ft.Length];
            int      i     = 0;

            if (ft != null)
            {
                foreach (field_types ft_ in ft)
                {
                    codes[i] = "${" + ft_.alias + "}";
                    i++;
                }
            }
            return(codes);
        }
示例#26
0
 /// <summary>
 /// 根据查询条件查询满足条件的实体
 /// </summary>
 public IList <T> Qry(IList <ICriterion> queryConditions)
 {
     return(ActiveRecordBase.FindAll(
                typeof(T)
                , queryConditions.ToArray()
                ) as IList <T>);
 }
示例#27
0
        /// <summary> </summary>
        public void edit_user(int id, int page)
        {
            appuser user = ActiveRecordBase <appuser> .Find(id);

            if (!userService.checkPrivleage("edit_users") && user != userService.getUser())
            {
                Flash["error"] = "Sorry you are not able to edit this user.";
                RedirectToAction("list");
                return;
            }

            PropertyBag["history"] = PaginationHelper.CreatePagination((IList)ActiveRecordBase <logs> .FindAll(Order.Desc("date"),
                                                                                                               new List <AbstractCriterion>()
            {
                Expression.Eq("nid", user.nid)
            }.ToArray()
                                                                                                               ).ToList(), 15, page);
            //media_types imgtype = ActiveRecordBase<media_types>.Find(1); //TODO restore
            //PropertyBag["images"] = imgtype.media_typed; //Flash["images"] != null ? Flash["images"] :
            //PropertyBag["userimages"] = user.media; //TODO restore
            PropertyBag["user"]   = user;
            PropertyBag["groups"] = ActiveRecordBase <user_group> .FindAll();

            RenderView("edit");
        }
示例#28
0
 /// <summary>
 /// 根据条件查询
 /// </summary>
 /// <param name="queryConditions"></param>
 /// <returns></returns>
 public IList <T> Query(IList <ICriterion> queryConditions)
 {
     {
         Array arry = ActiveRecordBase.FindAll(typeof(T), queryConditions.ToArray());
         return(arry as IList <T>);
     }
 }
示例#29
0
 public static GuildEventLogEntry[] LoadAll(uint guildId)
 {
     return(ActiveRecordBase <GuildEventLogEntry> .FindAll(GuildEventLogEntry.CreatedOrder, new ICriterion[1]
     {
         (ICriterion)Restrictions.Eq("m_GuildId", (object)(int)guildId)
     }));
 }
示例#30
0
        //This is a generic set of methods that will first check the object has a property
        //then if it does set it to null if the user is not actively editing it
        /// <summary> </summary>
        public static Boolean clearConnections <t>()
        {
            t[] items = ActiveRecordBase <t> .FindAll();

            bool result = false;

            foreach (dynamic item in items)
            {
                if (item.GetType().GetProperty("editing") != null)
                {
                    if (userService.isActive(item.editing))
                    {
                        //NOTE THIS IS NEEDING TO BE CORRECTED>> item.editing is null
                        //For some resaon when we try to access it it's like we have one layer deep
                        //and this item uses the :publish_base:_base model inheritence
                        //LogService.writelog("Releasing editor from item ", item.editing.nid, item.baseid);
                        logger.writelog("Releasing editor from item ", item.baseid);
                        item.editing = null;
                        ActiveRecordMediator <dynamic> .Save(item);

                        result = true;
                    }
                }
            }
            return(result);
        }