/// <summary>
        /// get all continents
        /// </summary>
        /// <param name="LangId">Insert LangId</param>
        /// <returns>List of anonymous objects</returns>
        public List <dynamic> GetContinents(int LangId)
        {
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                var r = (from C in db.SW_SearchWarContinent
                         join cd in db.SW_SearchWarContinentData
                         on C.SearchWarContinentId equals cd.SearchWarContinentId
                         where cd.LangId == LangId
                         orderby cd.SearchWarContinentName
                         select new
                {
                    SearchWarContinentId = C.SearchWarContinentId,
                    SearchWarContinentAddedDate = C.SearchWarContinentAddedDate,
                    SearchWarContinentEditDate = C.SearchWarContinentEditDate,
                    SearchWarContinentAddedUserId = C.SearchWarContinentAddedUserId,
                    SearchWarContinentEditUserId = C.SearchWarContinentEditUserId,
                    SearchWarContinentName = cd.SearchWarContinentName,
                    LangId = cd.LangId
                });


                return(r.ConvertListAnoToExpa());
            }
        }
        public void CreateBolig(string title,
                                string text,
                                int langid,
                                Guid UserID)
        {
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_Blog createblog = new SW_Blog();
                createblog.BlogAddedByUserId = UserID;
                createblog.BlogEditByUserId  = UserID;
                createblog.BlogAddedDate     = TimeZoneManager.DateTimeNow;
                createblog.BlogEditDate      = TimeZoneManager.DateTimeNow;

                db.SaveChanges();

                SW_BlogData createBlogData = new SW_BlogData();
                createBlogData.BlogId    = createblog.BlogId;
                createBlogData.BlogText  = text;
                createBlogData.LangId    = langid;
                createBlogData.BlogTitle = title;

                db.SW_Blog.AddObject(createblog);
            }
        }
        /// <summary>
        /// Get all countries by ContinentId
        /// </summary>
        /// <param name="LangId">Insert Langid</param>
        /// <param name="ContinentId">Insert ContinentId</param>
        /// <returns>List of anonymous objects</returns>
        public List <dynamic> GetCountries(int LangId, int ContinentId)
        {
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                var r = (from C in db.SW_SearchWarCountry
                         join cd in db.SW_SearchWarCountryData
                         on C.SearchWarCountryId equals cd.SearchWarCountrytId
                         where LangId == cd.LangId && C.SearchWarContinentId == ContinentId
                         orderby cd.SearchWarCountryName
                         select new
                {
                    SearchWarCountryId = C.SearchWarCountryId,
                    SearchWarCountryAddedDate = C.SearchWarCountryAddedDate,
                    SearchWarCountryEditdate = C.SearchWarCountryEditDate,
                    SearchWarCountryAddedUserId = C.SearchWarCountryAddedUserId,
                    SearchWarCountryEditUserId = C.SearchWarCountryEditUserId,
                    SearchWarContinentId = C.SearchWarContinentId,
                    SearchWarCountryName = cd.SearchWarCountryName,
                    SearchWarCountryTLD = cd.SearchWarCountryTLD
                });

                return(r.ConvertListAnoToExpa());
            }
        }
Пример #4
0
        public dynamic GetSkill(string skillName,
                                int langId)
        {
            skillName = HttpContext.Current.Server.HtmlDecode(skillName);

            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                var r = (from s in db.SW_SearchWarSkill
                         join sd in db.SW_SearchWarSkillData on s.SearchWarSkillId equals sd.SearchWarSkillId
                         where sd.LangId == langId && sd.SearchWarSkillName == skillName
                         select new
                {
                    sd.SearchWarSkillId,
                    sd.SearchWarSkillName,
                    s.SearchWarSkillAddedDatetime,
                    s.SearchWarSkillAddedUserId,
                    s.SearchWarSkillEditDatetime,
                    s.SearchWarSkillEditUserId,
                    s.SearchWarSkillSort
                }).SingleOrDefault();

                return(r.ConvertAnoToExpa());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            // Set defaults values
            string            data          = null;
            string            currentUserIp = "62.107.21.129";
            HttpRequest       currentR      = context.Request;
            HttpServerUtility currentS      = context.Server;
            int      currentLangId;
            bool     isValid      = true;
            string   errorMessage = "succes";
            ANO_User getUser      = ANOProfile.GetCookieValues(currentUserIp, context);



            string userAction = context.Request.QueryString["a"];

            if (string.IsNullOrEmpty(userAction))
            {
                isValid      = false;
                errorMessage = "You forgot action (querystring a)";
            }


            // Create documet and root element called "c" for "chat"
            XDocument createXml = new XDocument(
                new XDeclaration("1.0", "iso-8859-1", "true"),
                new XElement("chat"));

            // Get root element "c"
            XElement getRootElement = createXml.Descendants("chat").Single();

            if (userAction == ChatCmds.SendMessage.ToString())
            {
                string userText = context.Request["t"];
                if (string.IsNullOrEmpty(userText))
                {
                    isValid      = false;
                    errorMessage = "You forgot the message (post/querystring t)";
                }

                string chatIdQuery = context.Request["c"];
                Guid?  chatId      = null;
                if (string.IsNullOrEmpty(chatIdQuery))
                {
                    isValid      = false;
                    errorMessage = "You forgot the chat window id (post/querystring c";
                }

                // Convert chatid querystring to Guid
                try
                {
                    chatId = new Guid(chatIdQuery);
                }
                catch
                {
                    isValid      = false;
                    errorMessage = "Problem with converting chat window id (querystring c)";
                }

                if (isValid == true && chatId.HasValue)
                {
                    string getUsername = null;
                    if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        getUsername = Membership.GetUser(getUser.UserID).UserName;
                    }

                    if (string.IsNullOrEmpty(getUsername))
                    {
                        Searchwar_netEntities db          = new Searchwar_netEntities();
                        SW_SearchWar          matchSearch = db.SW_SearchWar.SingleOrDefault(w => w.SearchWarId == getUser.SearchMatchID);

                        if (matchSearch != null)
                        {
                            getUsername = matchSearch.SearchWarClanName;
                        }
                    }

                    if (!string.IsNullOrEmpty(getUsername))
                    {
                        ChatSystem mngChat = new ChatSystem(context, currentUserIp);
                        mngChat.CreateMsg(userText, chatId, getUser.UserID, getUsername);
                    }
                    else
                    {
                        isValid      = false;
                        errorMessage = "You muct be logged in or searching for a match";
                    }
                }
            }

            // write status for result
            getRootElement.Add(new XElement("status", new XAttribute("bool", isValid.ToString()), errorMessage));

            // Write/save data
            StringWriter sw = new StringWriter();
            XmlWriter    xw = XmlWriter.Create(sw);

            createXml.Save(xw);

            xw.Close();

            data = sw.ToString();

            context.Response.ContentType     = "text/xml";
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.Write(XmlWhiteSpaceModule.RemoveWhitespace(data));
        }
Пример #6
0
        /// <summary>
        /// Insert a path in cSiteMapNode (Insert RoleIds with AddRoleId)
        /// </summary>
        /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
        /// <param name="userId">Insert UserId</param>
        /// <param name="showSiteMapNode">Show URL in menu or not? (true)Show - (false)Dont show in menu</param>
        /// <param name="siteMapNodeSubId">If you want this URL like a sub for a URL, then insert ID of the URL</param>
        /// <param name="title">Inser title of URL</param>
        /// <param name="langaugeId">Insert ID of that langauge it write in</param>
        /// <param name="metatagsObject">to add metatags to sitemap (just left it null if you dont want metatags with)</param>
        protected void CreateSiteMapNode_Single(string path,
                                                Guid userId,
                                                bool showSiteMapNode,
                                                int?siteMapNodeSubId,
                                                string title,
                                                int langaugeId,
                                                int sort,
                                                SiteMapNodeMetatagsObject m)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;

            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_SiteMapNode createSiteMapNode = new SW_SiteMapNode
                {
                    SiteMapNodePath        = path,
                    SiteMapNodeAddedUserId = userId,
                    SiteMapNodeEditUserId  = userId,
                    SiteMapNodeShow        = showSiteMapNode,
                    SiteMapNodeEditDate    = dateTimeNow,
                    SiteMapNodeAddedDate   = dateTimeNow,
                    SiteMapNodeSort        = sort
                };

                SW_SiteMapNodeData createSiteMapNodeData = new SW_SiteMapNodeData
                {
                    LangId = langaugeId
                };


                // Check title for empty
                if (!string.IsNullOrEmpty(title))
                {
                    createSiteMapNodeData.SiteMapNodeTitle = title;
                }


                // Check SubId for empty
                if (siteMapNodeSubId.HasValue)
                {
                    SW_SiteMapNode siteMapNodeSub = (from s in db.SW_SiteMapNode
                                                     where s.SiteMapNodeId.Equals(siteMapNodeSubId)
                                                     select s).SingleOrDefault();

                    // Check path is in database
                    if (siteMapNodeSub != null)
                    {
                        createSiteMapNode.SiteMapNodeSubId = siteMapNodeSubId;
                    }
                    else
                    {
                        throw (new ArgumentNullException("siteMapNodeSubId", "Cant find SiteMapId '" + siteMapNodeSubId + "' in database"));
                    }
                }

                db.SW_SiteMapNode.AddObject(createSiteMapNode);
                db.SaveChanges();

                // Insert SiteMapId
                createSiteMapNodeData.SiteMapNodeId = createSiteMapNode.SiteMapNodeId;

                db.SW_SiteMapNodeData.AddObject(createSiteMapNodeData);
                db.SaveChanges();


                if (m != null)
                {
                    new SearchWar.SiteMap.MetaTags.SiteMapNodeMetaTags().CreateMetaTags(createSiteMapNode.SiteMapNodeId,
                                                                                        m.MetaTagTitle,
                                                                                        m.MetaTagDescription,
                                                                                        m.MetaTagKeywords,
                                                                                        m.MetaTagLanguage,
                                                                                        m.MetaTagAuthor,
                                                                                        m.MetaTagPublisher,
                                                                                        m.MetaTagCopyright,
                                                                                        m.MetaTagRevisitAfter,
                                                                                        m.MetaTagRobots,
                                                                                        m.MetaTagCache,
                                                                                        m.MetaTagCacheControl,
                                                                                        userId,
                                                                                        langaugeId);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Update a path in cSiteMapNode
        /// (Insert RoleIds with AddRoleId and Remove RoleIds with RemoveRoleId)
        /// </summary>
        /// <param name="siteMapNodeId">Insert SiteMapId</param>
        /// <param name="path">Insert URL (Ex. ~/default.aspx)</param>
        /// <param name="userId">Insert UserId</param>
        /// <param name="showSiteMapNode">Show URL in menu or not? (true)Show - (false)Dont show in menu</param>
        /// <param name="siteMapNodeSubId">If you want this URL like a sub for a URL, then insert ID of the URL</param>
        /// <param name="title">Inser title of URL</param>
        /// <param name="langaugeId">Insert ID of that langauge it write in</param>
        /// <param name="newLangId">Insert newLangId</param>
        protected void UpdateSiteMap(int siteMapNodeId,
                                     int langaugeId,
                                     string path,
                                     Guid userId,
                                     bool showSiteMapNode,
                                     int?siteMapNodeSubId,
                                     string title,
                                     int?newLangId,
                                     int sort,
                                     SiteMapNodeMetatagsObject m)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;

            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_SiteMapNode siteMapNode = (from s in db.SW_SiteMapNode
                                              where s.SiteMapNodeId.Equals(siteMapNodeId)
                                              select s).SingleOrDefault();

                // Check SiteMapId in database
                if (siteMapNode != null)
                {
                    siteMapNode.SiteMapNodePath       = path;
                    siteMapNode.SiteMapNodeShow       = showSiteMapNode;
                    siteMapNode.SiteMapNodeSubId      = siteMapNodeSubId;
                    siteMapNode.SiteMapNodeEditUserId = userId;
                    siteMapNode.SiteMapNodeEditDate   = dateTimeNow;
                    siteMapNode.SiteMapNodeSort       = sort;

                    SW_SiteMapNodeData siteMapNodeData = siteMapNode.SW_SiteMapNodeData.Single <SW_SiteMapNodeData>(d => d.SiteMapNodeId.Equals(siteMapNodeId) && d.LangId.Equals(langaugeId));
                    siteMapNodeData.SiteMapNodeTitle = title;
                    if (newLangId.HasValue)
                    {
                        siteMapNodeData.LangId = newLangId.Value;
                    }

                    db.SaveChanges();

                    object checkMetaTags =
                        db.SW_SiteMapNodeMetaTags.Where(mt => mt.MetaTagsId == siteMapNodeId).SingleOrDefault();

                    if (m != null && checkMetaTags != null)
                    {
                        new SearchWar.SiteMap.MetaTags.SiteMapNodeMetaTags().UpdateMetaTags(siteMapNodeId,
                                                                                            langaugeId,
                                                                                            m.MetaTagTitle,
                                                                                            m.MetaTagDescription,
                                                                                            m.MetaTagKeywords,
                                                                                            m.MetaTagLanguage,
                                                                                            m.MetaTagAuthor,
                                                                                            m.MetaTagPublisher,
                                                                                            m.MetaTagCopyright,
                                                                                            m.MetaTagRevisitAfter,
                                                                                            m.MetaTagRobots,
                                                                                            m.MetaTagCache,
                                                                                            m.MetaTagCacheControl,
                                                                                            null,
                                                                                            userId);
                    }
                }
                else
                {
                    throw (new ArgumentNullException("siteMapNodeId", "Cant find SiteMap '" + siteMapNodeId + "' in database"));
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Delete paths in SiteMapNodes
        /// </summary>
        protected void DeleteSiteMapNodes()
        {
            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities()) {
                // Check RemoveRoleIds for empty
                if (_siteMapNodeIds.Count() > 0)
                {
                    IQueryable <SW_SiteMapNode> deleteSiteMapNodes = (from s in db.SW_SiteMapNode
                                                                      where _siteMapNodeIds.Contains(s.SiteMapNodeId)
                                                                      select s).AsQueryable <SW_SiteMapNode>();

                    IQueryable <SW_SiteMapNodeData> deleteSiteMapNodesData = (from sd in db.SW_SiteMapNodeData
                                                                              where _siteMapNodeIds.Contains(sd.SiteMapNodeId)
                                                                              select sd).AsQueryable <SW_SiteMapNodeData>();

                    IQueryable <SW_SiteMapNodeRole> DeleteSiteMapNodesRoles = (from r in db.SW_SiteMapNodeRoles
                                                                               where _siteMapNodeIds.Contains(r.SiteMapNodeId)
                                                                               select r).AsQueryable <SW_SiteMapNodeRole>();

                    IQueryable <SW_SiteMapNodeMetaTag> deleteSiteMapNodesMetaTags = (from m in db.SW_SiteMapNodeMetaTags
                                                                                     where _siteMapNodeIds.Contains(m.MetaTagsId)
                                                                                     select m).AsQueryable <SW_SiteMapNodeMetaTag>();

                    IQueryable <SW_SiteMapNodeMetaTagsData> deleteSiteMapNodesMetaTagsData = (from md in db.SW_SiteMapNodeMetaTagsData
                                                                                              where _siteMapNodeIds.Contains(md.MetaTagsId)
                                                                                              select md).AsQueryable <SW_SiteMapNodeMetaTagsData>();

                    // Delete all SiteMapNodesMetaTagsData
                    foreach (var item in deleteSiteMapNodesMetaTagsData)
                    {
                        db.SW_SiteMapNodeMetaTagsData.DeleteObject(item);
                    }

                    // Delete all SiteMapNodesMetaTags
                    foreach (var item in deleteSiteMapNodesMetaTags)
                    {
                        db.SW_SiteMapNodeMetaTags.DeleteObject(item);
                    }

                    // Delete all SiteMapNodesRoles
                    foreach (var item in DeleteSiteMapNodesRoles)
                    {
                        db.SW_SiteMapNodeRoles.DeleteObject(item);
                    }

                    // Delete all SiteMapNodesData
                    foreach (var item in deleteSiteMapNodesData)
                    {
                        db.SW_SiteMapNodeData.DeleteObject(item);
                    }

                    // Delete all SiteMapNodes
                    foreach (var item in deleteSiteMapNodes)
                    {
                        db.SW_SiteMapNode.DeleteObject(item);
                    }

                    db.SaveChanges();
                }
            }
        }
Пример #9
0
 public SearchEngine()
 {
     db = new Searchwar_netEntities();
     db.Connection.Open();
     db.ExecuteStoreCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
 }
Пример #10
0
        /// <summary>
        /// Create MetaTags to a cSiteMapNode
        /// </summary>
        /// <param name="siteMapNodeId">Insert SiteMapNodeId</param>
        /// <param name="metaTagTitle">Insert Title</param>
        /// <param name="metaTagDescription">Insert Desc</param>
        /// <param name="metaTagKeywords">Insert keywords like "word, word, word"</param>
        /// <param name="metaTagLanguage">Insert lang like "da" or "en"</param>
        /// <param name="metaTagAuthor">Insert author</param>
        /// <param name="metaTagPublisher">Insert publisher</param>
        /// <param name="metaTagCopyright">Insert Copyright</param>
        /// <param name="metaTagRevisitAfter">Insert Revisitafter like "7 days"</param>
        /// <param name="metaTagRobots">Insert Robots like "index,follow"</param>
        /// <param name="metaTagCache">Insert cache like "no-cache"</param>
        /// <param name="metaTagCacheControl">Insert cachecontrol like "no-cache"</param>
        /// <param name="langaugeId">Insert ID of that langauge this metatags is write in</param>
        /// <param name="userId">Insert UserId</param>
        public void CreateMetaTags(int siteMapNodeId,
                                   string metaTagTitle,
                                   string metaTagDescription,
                                   string metaTagKeywords,
                                   string metaTagLanguage,
                                   string metaTagAuthor,
                                   string metaTagPublisher,
                                   string metaTagCopyright,
                                   string metaTagRevisitAfter,
                                   string metaTagRobots,
                                   string metaTagCache,
                                   string metaTagCacheControl,
                                   Guid userId,
                                   int langaugeId)
        {
            DateTime dateTimeNow = TimeZoneManager.DateTimeNow;


            // using statement free the memory after metode is done
            using (Searchwar_netEntities db = new Searchwar_netEntities())
            {
                SW_SiteMapNode getCurrentSiteMapNode = (from s in db.SW_SiteMapNode
                                                        where s.SiteMapNodeId.Equals(siteMapNodeId)
                                                        select s).SingleOrDefault();

                // Check cSiteMapNode
                if (getCurrentSiteMapNode != null)
                {
                    SW_SiteMapNodeMetaTag createMeta = new SW_SiteMapNodeMetaTag
                    {
                        MetaTagsId          = siteMapNodeId,
                        MetaTagsAddedUserId = userId,
                        MetaTagsEditUserId  = userId,
                        MetaTagsAddedDate   = dateTimeNow,
                        MetaTagsEditDate    = dateTimeNow
                    };

                    SW_SiteMapNodeMetaTagsData createMetaData = new SW_SiteMapNodeMetaTagsData
                    {
                        MetaTagsTitle        = metaTagTitle,
                        MetaTagsDescription  = metaTagDescription,
                        MetaTagsKeywords     = metaTagKeywords,
                        MetaTagsLanguage     = metaTagLanguage,
                        MetaTagsAuthor       = metaTagAuthor,
                        MetaTagsPublisher    = metaTagPublisher,
                        MetaTagsCopyright    = metaTagCopyright,
                        MetaTagsRevisitAfter = metaTagRevisitAfter,
                        MetaTagsRobots       = metaTagRobots,
                        MetaTagsCache        = metaTagCache,
                        MetaTagsCacheControl = metaTagCacheControl,
                        LangId     = langaugeId,
                        MetaTagsId = siteMapNodeId
                    };


                    db.SW_SiteMapNodeMetaTags.AddObject(createMeta);
                    db.SW_SiteMapNodeMetaTagsData.AddObject(createMetaData);
                    db.SaveChanges();
                }
                else
                {
                    throw (new ArgumentNullException("siteMapNodeId", "Cant find siteMapNodeId '" + siteMapNodeId + "' in database"));
                }
            }
        }