Exemple #1
0
        public Entities.Site GetSite()
        {
            var store = new SiteStore(Context.FileSystem);
            var site  = store.GetSite(Context.Url);

            return(site);
        }
        /// <summary>
        /// MOVIE_SITESTOREのID一致ROWを削除する
        /// </summary>
        /// <param name="myDbCon"></param>
        /// <returns></returns>
        public static void DeleteSiteStore(SiteStore myTargetData, DbConnection myDbCon)
        {
            List<SiteInfo> listSiteInfo = new List<SiteInfo>();

            string cmdUpdate = "DELETE FROM MOVIE_SITESTORE WHERE ID = @pId";

            SqlParameter[] sqlparams = new SqlParameter[1];

            sqlparams[0] = new SqlParameter("@pId", SqlDbType.Int);
            sqlparams[0].Value = myTargetData.Id;

            myDbCon.openConnection();

            myDbCon.SetParameter(sqlparams);
            myDbCon.execSqlCommand(cmdUpdate);

            myDbCon.closeConnection();

            return;
        }
        /// <summary>
        /// MOVIE_SITESTOREに行の更新をする
        /// </summary>
        /// <param name="myDbCon"></param>
        /// <returns></returns>
        public static void UpdateSiteStore(SiteStore myTargetData, DbConnection myDbCon)
        {
            List<SiteInfo> listSiteInfo = new List<SiteInfo>();

            string cmdUpdate = "UPDATE MOVIE_SITESTORE SET NAME = @pName, LABEL = @pLabel, EXPLANATION = @pExplanation, KIND = @pKind WHERE ID = @pId";

            SqlParameter[] sqlparams = new SqlParameter[5];

            sqlparams[0] = new SqlParameter("@pName", SqlDbType.VarChar);
            sqlparams[0].Value = myTargetData.Name;

            sqlparams[1] = new SqlParameter("@pLabel", SqlDbType.VarChar);
            sqlparams[1].Value = myTargetData.Label;

            sqlparams[2] = new SqlParameter("@pExplanation", SqlDbType.VarChar);
            sqlparams[2].Value = myTargetData.Explanation;

            sqlparams[3] = new SqlParameter("@pKind", SqlDbType.Int);
            sqlparams[3].Value = myTargetData.Kind;

            sqlparams[4] = new SqlParameter("@pId", SqlDbType.Int);
            sqlparams[5].Value = myTargetData.Id;

            myDbCon.openConnection();

            myDbCon.SetParameter(sqlparams);
            myDbCon.execSqlCommand(cmdUpdate);

            myDbCon.closeConnection();

            return;
        }
        /// <summary>
        /// MOVIE_SITESTOREに行を作成する
        /// </summary>
        /// <param name="myDbCon"></param>
        /// <returns></returns>
        public static void InsertSiteStore(SiteStore myTargetData, DbConnection myDbCon)
        {
            List<SiteInfo> listSiteInfo = new List<SiteInfo>();

            string cmdUpdate = "INSERT INTO MOVIE_SITESTORE(NAME, LABEL, EXPLANATION, KIND) VALUES (@pName, @pLabel, @pExplanation, @pKind)";

            SqlParameter[] sqlparams = new SqlParameter[4];

            sqlparams[0] = new SqlParameter("@pName", SqlDbType.VarChar);
            sqlparams[0].Value = myTargetData.Name;

            sqlparams[1] = new SqlParameter("@pLabel", SqlDbType.VarChar);
            sqlparams[1].Value = myTargetData.Label;

            sqlparams[2] = new SqlParameter("@pExplanation", SqlDbType.VarChar);
            sqlparams[2].Value = myTargetData.Explanation;

            sqlparams[3] = new SqlParameter("@pKind", SqlDbType.Int);
            sqlparams[3].Value = myTargetData.Kind;

            myDbCon.openConnection();

            myDbCon.SetParameter(sqlparams);
            myDbCon.execSqlCommand(cmdUpdate);

            myDbCon.closeConnection();

            return;
        }
        /// <summary>
        /// 存在するコンテンツ内のパス名をサイト内のパス群から取得する
        /// </summary>
        /// <param name="myDbCon"></param>
        /// <returns></returns>
        public static List<SiteStore> GetSiteStore(DbConnection myDbCon)
        {
            List<SiteStore> listSiteStore = new List<SiteStore>();

            //string queryString = "SELECT ID, NAME, PATH, KIND FROM MOVIE_SITESTORE ORDER BY NAME, PATH";
            string queryString = "SELECT ID, NAME, EXPLANATION, LABEL, KIND FROM MOVIE_GROUP WHERE KIND = 3 ORDER BY NAME, EXPLANATION";

            SqlCommand command = new SqlCommand(queryString, myDbCon.getSqlConnection());

            myDbCon.openConnection();

            SqlDataReader reader = command.ExecuteReader();

            do
            {
                while (reader.Read())
                {
                    SiteStore site = new SiteStore();

                    site.Id = DbExportCommon.GetDbInt(reader, 0);
                    site.Name = DbExportCommon.GetDbString(reader, 1);
                    site.Explanation = DbExportCommon.GetDbString(reader, 2);
                    site.Label = DbExportCommon.GetDbString(reader, 3);
                    site.Kind = DbExportCommon.GetDbInt(reader, 4);

                    listSiteStore.Add(site);
                }
            } while (reader.NextResult());
            reader.Close();

            myDbCon.closeConnection();

            return listSiteStore;
        }
Exemple #6
0
        public BasketballContext(string rootPath,
                                 EditorSelector sectionEditorSelector, EditorSelector unitEditorSelector,
                                 IDataLayer userConnection, IDataLayer fabricConnection,
                                 IDataLayer messageConnection, IDataLayer forumConnection)
        {
            this.rootPath              = rootPath;
            this.imagesPath            = Path.Combine(RootPath, "Images");
            this.userConnection        = userConnection;
            this.fabricConnection      = fabricConnection;
            this.messageConnection     = messageConnection;
            this.forumConnection       = forumConnection;
            this.sectionEditorSelector = sectionEditorSelector;
            this.unitEditorSelector    = unitEditorSelector;

            this.userStorage     = new UserStorage(userConnection);
            this.NewsStorages    = new TopicStorageCache(fabricConnection, messageConnection, NewsType.News);
            this.ArticleStorages = new TopicStorageCache(fabricConnection, messageConnection, ArticleType.Article);
            this.Forum           = new ForumStorageCache(fabricConnection, forumConnection);

            string settingsPath = Path.Combine(rootPath, "SiteSettings.config");

            if (!File.Exists(settingsPath))
            {
                this.siteSettings = new SiteSettings();
            }
            else
            {
                this.siteSettings = XmlSerialization.Load <SiteSettings>(settingsPath);
            }

            this.pull = new TaskPull(
                new ThreadLabel[] { Labels.Service },
                TimeSpan.FromMinutes(15)
                );

            this.newsCache = new Cache <Tuple <ObjectHeadBox, LightHead[]>, long>(
                delegate
            {
                ObjectHeadBox newsBox = new ObjectHeadBox(fabricConnection,
                                                          string.Format("{0} order by act_from desc", DataCondition.ForTypes(NewsType.News))
                                                          );

                int[] allNewsIds = newsBox.AllObjectIds;

                List <LightHead> actualNews = new List <LightHead>();
                for (int i = 0; i < Math.Min(22, allNewsIds.Length); ++i)
                {
                    int newsId = allNewsIds[i];
                    actualNews.Add(new LightHead(newsBox, newsId));
                }

                return(_.Tuple(newsBox, actualNews.ToArray()));
            },
                delegate { return(newsChangeTick); }
                );

            this.articlesCache = new Cache <Tuple <ObjectBox, LightObject[]>, long>(
                delegate
            {
                ObjectBox articleBox = new ObjectBox(fabricConnection,
                                                     string.Format("{0} order by act_from desc", DataCondition.ForTypes(ArticleType.Article))
                                                     );

                int[] allArticleIds = articleBox.AllObjectIds;

                ObjectBox actualBox = new ObjectBox(FabricConnection,
                                                    string.Format("{0} order by act_from desc limit 5", DataCondition.ForTypes(ArticleType.Article))
                                                    );

                List <LightObject> actualArticles = new List <LightObject>();
                foreach (int articleId in actualBox.AllObjectIds)
                {
                    actualArticles.Add(new LightObject(actualBox, articleId));
                }

                return(_.Tuple(articleBox, actualArticles.ToArray()));
            },
                delegate { return(articleChangeTick); }
                );

            this.lightStoreCache = new Cache <IStore, long>(
                delegate
            {
                LightObject contacts = DataBox.LoadOrCreateObject(fabricConnection,
                                                                  ContactsType.Contacts, ContactsType.Kind.CreateXmlIds, "main");

                LightObject seo = DataBox.LoadOrCreateObject(fabricConnection,
                                                             SEOType.SEO, SEOType.Kind.CreateXmlIds, "main");

                SectionStorage sections = SectionStorage.Load(fabricConnection);

                WidgetStorage widgets = WidgetStorage.Load(fabricConnection, siteSettings.DisableScripts);

                RedirectStorage redirects = RedirectStorage.Load(fabricConnection);

                SiteStore store = new SiteStore(sections, null, widgets, redirects, contacts, seo);
                store.Links.AddLink("register", null);
                store.Links.AddLink("passwordreset", null);

                return(store);
            },
                delegate { return(dataChangeTick); }
                );

            this.lastPublicationCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = messageConnection.GetTable("",
                                                             "Select Distinct article_id From message order by create_time desc limit 10"
                                                             );

                List <RowLink> lastComments = new List <RowLink>(10);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    if (News.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = NewsStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                    else if (Articles.ObjectById.Exist(topicId))
                    {
                        TopicStorage topic  = ArticleStorages.ForTopic(topicId);
                        RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                        if (lastMessage != null)
                        {
                            lastComments.Add(lastMessage);
                        }
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(publicationCommentChangeTick); }
                );

            this.lastForumCommentsCache = new Cache <RowLink[], long>(
                delegate
            {
                DataTable table = forumConnection.GetTable("",
                                                           "Select Distinct article_id From message order by create_time desc limit 7"
                                                           );

                List <RowLink> lastComments = new List <RowLink>(7);
                foreach (DataRow row in table.Rows)
                {
                    int topicId = ConvertHlp.ToInt(row[0]) ?? -1;

                    TopicStorage topic  = Forum.TopicsStorages.ForTopic(topicId);
                    RowLink lastMessage = _.Last(topic.MessageLink.AllRows);
                    if (lastMessage != null)
                    {
                        lastComments.Add(lastMessage);
                    }
                }

                return(lastComments.ToArray());
            },
                delegate { return(forumCommentChangeTick); }
                );

            this.tagsCache = new Cache <TagStore, long>(
                delegate
            {
                ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

                return(new TagStore(tagBox));
            },
                delegate { return(tagChangeTick); }
                );

            //this.tagsCache = new Cache<Tuple<ObjectHeadBox, Dictionary<string, int>>, long>(
            //  delegate
            //  {
            //    ObjectHeadBox tagBox = new ObjectHeadBox(fabricConnection, DataCondition.ForTypes(TagType.Tag) + " order by xml_ids asc");

            //    Dictionary<string, int> tagIdByKey = new Dictionary<string, int>();
            //    foreach (int tagId in tagBox.AllObjectIds)
            //    {
            //      string tagName = TagType.DisplayName.Get(tagBox, tagId);
            //      if (StringHlp.IsEmpty(tagName))
            //        continue;

            //      string tagKey = tagName.ToLower();
            //      tagIdByKey[tagKey] = tagId;
            //    }

            //    return _.Tuple(tagBox, tagIdByKey);
            //  },
            //  delegate { return tagChangeTick; }
            //);

            this.unreadDialogCache = new Cache <TableLink, long>(
                delegate
            {
                return(DialogueHlp.LoadUnreadLink(forumConnection));
            },
                delegate { return(unreadChangeTick); }
                );

            Pull.StartTask(Labels.Service,
                           SiteTasks.SitemapXmlChecker(this, rootPath,
                                                       delegate(LinkInfo[] sectionlinks)
            {
                List <LightLink> allLinks = new List <LightLink>();
                allLinks.AddRange(
                    ArrayHlp.Convert(sectionlinks, delegate(LinkInfo link)
                {
                    return(new LightLink(link.Directory, null));
                })
                    );

                foreach (int articleId in Articles.AllObjectIds)
                {
                    LightHead article = new LightHead(Articles, articleId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("article", articleId),
                                      article.Get(ObjectType.ActTill) ?? article.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                foreach (int newsId in News.AllObjectIds)
                {
                    LightHead news = new LightHead(News, newsId);
                    allLinks.Add(
                        new LightLink(UrlHlp.ShopUrl("news", newsId),
                                      news.Get(ObjectType.ActTill) ?? news.Get(ObjectType.ActFrom)
                                      )
                        );
                }

                //foreach (int tagId in Tags.AllObjectIds)
                //{
                //  LightHead tag = new LightHead(Tags, tagId);
                //  allLinks.Add(
                //    new LightLink(string.Format("/tags?tag={0}", tagId)
                //    )
                //  );
                //}

                return(allLinks.ToArray());
            }
                                                       )
                           );
        }
Exemple #7
0
 public Entities.Site GetSite()
 {
     var store = new SiteStore(Context.FileSystem);
     var site = store.GetSite(Context.Url);
     return site;
 }