Beispiel #1
0
        public int Insert(SearchNavigationInfo searchNavigationInfo)
        {
            var searchNavigationId = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(searchNavigationInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        searchNavigationId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(searchNavigationId);
        }
Beispiel #2
0
        public void Update(SearchNavigationInfo searchNavigationInfo)
        {
            IDataParameter[] parms = null;
            var sqlUpdate          = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(searchNavigationInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            ExecuteNonQuery(sqlUpdate, parms);
        }
Beispiel #3
0
        public int Insert(SearchNavigationInfo searchNavigationInfo)
        {
            var searchNavigationID = 0;

            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(searchNavigationInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, SQL_INSERT, parms);

                        searchNavigationID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(searchNavigationID);
        }
Beispiel #4
0
        public SearchNavigationInfo GetSearchNavigationInfo(int searchNavigationId)
        {
            SearchNavigationInfo searchNavigationInfo = null;

            string sqlWhere  = $"WHERE ID = {searchNavigationId}";
            var    sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                if (rdr.Read())
                {
                    searchNavigationInfo = new SearchNavigationInfo(rdr);
                }
                rdr.Close();
            }

            return(searchNavigationInfo);
        }
Beispiel #5
0
        public SearchNavigationInfo GetSearchNavigationInfo(int SearchNavigationID)
        {
            SearchNavigationInfo searchNavigationInfo = null;

            string SQL_WHERE  = $"WHERE ID = {SearchNavigationID}";
            var    SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                if (rdr.Read())
                {
                    searchNavigationInfo = new SearchNavigationInfo(rdr);
                }
                rdr.Close();
            }

            return(searchNavigationInfo);
        }
Beispiel #6
0
        public List <SearchNavigationInfo> GetSearchNavigationInfoList(int publishmentSystemId)
        {
            var searchNavigationInfoList = new List <SearchNavigationInfo>();

            string sqlWhere  = $"WHERE {SearchNavigationAttribute.PublishmentSystemId} = {publishmentSystemId}";
            var    sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var searchNavigationInfo = new SearchNavigationInfo(rdr);
                    searchNavigationInfoList.Add(searchNavigationInfo);
                }
                rdr.Close();
            }

            return(searchNavigationInfoList);
        }
Beispiel #7
0
        public List <SearchNavigationInfo> GetSearchNavigationInfoList(int publishmentSystemID)
        {
            var searchNavigationInfoList = new List <SearchNavigationInfo>();

            string SQL_WHERE  = $"WHERE {SearchNavigationAttribute.PublishmentSystemID} = {publishmentSystemID}";
            var    SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var searchNavigationInfo = new SearchNavigationInfo(rdr);
                    searchNavigationInfoList.Add(searchNavigationInfo);
                }
                rdr.Close();
            }

            return(searchNavigationInfoList);
        }
Beispiel #8
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (searchID > 0)
                        {
                            var searchInfo = DataProviderWX.SearchDAO.GetSearchInfo(searchID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemID, searchInfo.KeywordID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        phStep1.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    var isItemReady = true;

                    if (isItemReady)
                    {
                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);

                        if (itemCount > 0)
                        {
                            var itemIDList        = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                            var imageCssClassList = TranslateUtils.StringCollectionToStringList(Request.Form["itemImageCssClass"]);
                            var keywordTypeList   = TranslateUtils.StringCollectionToStringList(Request.Form["itemKeywordType"]);
                            var functionIDList    = TranslateUtils.StringCollectionToIntList(Request.Form["itemFunctionID"]);
                            var channelIDList     = TranslateUtils.StringCollectionToIntList(Request.Form["itemChannelID"]);
                            var contentIDList     = TranslateUtils.StringCollectionToIntList(Request.Form["itemContentID"]);

                            var titleList          = TranslateUtils.StringCollectionToStringList(Request.Form["itemTitle"]);
                            var navigationTypeList = TranslateUtils.StringCollectionToStringList(Request.Form["itemNavigationType"]);
                            var urlList            = TranslateUtils.StringCollectionToStringList(Request.Form["itemUrl"]);

                            var navigationInfoList = new List <SearchNavigationInfo>();
                            for (var i = 0; i < itemCount; i++)
                            {
                                var navigationInfo = new SearchNavigationInfo {
                                    ID = itemIDList[i], PublishmentSystemID = PublishmentSystemID, SearchID = searchID, Title = titleList[i], Url = urlList[i], ImageCssClass = imageCssClassList[i], NavigationType = navigationTypeList[i], KeywordType = keywordTypeList[i], FunctionID = functionIDList[i], ChannelID = channelIDList[i], ContentID = contentIDList[i]
                                };

                                if (string.IsNullOrEmpty(navigationInfo.Title))
                                {
                                    FailMessage("保存失败,导航链接名称为必填项");
                                    isItemReady = false;
                                }
                                if (string.IsNullOrEmpty(navigationInfo.ImageCssClass))
                                {
                                    FailMessage("保存失败,导航链接图标为必填项");
                                    isItemReady = false;
                                }
                                if (navigationInfo.NavigationType == ENavigationTypeUtils.GetValue(ENavigationType.Url) && string.IsNullOrEmpty(navigationInfo.Url))
                                {
                                    FailMessage("保存失败,导航链接地址为必填项");
                                    isItemReady = false;
                                }

                                navigationInfoList.Add(navigationInfo);
                            }

                            if (isItemReady)
                            {
                                DataProviderWX.SearchNavigationDAO.DeleteAllNotInIDList(PublishmentSystemID, searchID, itemIDList);

                                foreach (var navigationInfo in navigationInfoList)
                                {
                                    if (navigationInfo.ID > 0)
                                    {
                                        DataProviderWX.SearchNavigationDAO.Update(navigationInfo);
                                    }
                                    else
                                    {
                                        DataProviderWX.SearchNavigationDAO.Insert(navigationInfo);
                                    }
                                }
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep3.Visible = true;
                        btnSubmit.Text  = "确 认";
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 3)
                {
                    var searchInfo = new SearchInfo();
                    if (searchID > 0)
                    {
                        searchInfo = DataProviderWX.SearchDAO.GetSearchInfo(searchID);
                    }
                    searchInfo.PublishmentSystemID = PublishmentSystemID;
                    searchInfo.KeywordID           = DataProviderWX.KeywordDAO.GetKeywordID(PublishmentSystemID, searchID > 0, tbKeywords.Text, EKeywordType.Search, searchInfo.KeywordID);
                    searchInfo.IsDisabled          = !cbIsEnabled.Checked;
                    searchInfo.Title           = PageUtils.FilterXSS(tbTitle.Text);
                    searchInfo.ImageUrl        = imageUrl.Value;;
                    searchInfo.Summary         = tbSummary.Text;
                    searchInfo.ContentImageUrl = contentImageUrl.Value;

                    searchInfo.IsOutsiteSearch = cbIsOutsiteSearch.Checked;
                    searchInfo.IsNavigation    = cbIsNavigation.Checked;
                    searchInfo.NavTitleColor   = tbNavTitleColor.Text;
                    searchInfo.NavImageColor   = tbNavImageColor.Text;

                    searchInfo.ImageAreaTitle     = tbImageAreaTitle.Text;
                    searchInfo.ImageAreaChannelID = TranslateUtils.ToInt(Request.Form["imageChannelID"]);
                    searchInfo.TextAreaTitle      = tbTextAreaTitle.Text;
                    searchInfo.TextAreaChannelID  = TranslateUtils.ToInt(Request.Form["textChannelID"]);

                    try
                    {
                        if (searchID > 0)
                        {
                            DataProviderWX.SearchDAO.Update(searchInfo);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "修改微搜索",
                                            $"微搜索:{tbTitle.Text}");
                            SuccessMessage("修改微搜索成功!");
                        }
                        else
                        {
                            searchID = DataProviderWX.SearchDAO.Insert(searchInfo);

                            DataProviderWX.SearchNavigationDAO.UpdateSearchID(PublishmentSystemID, searchID);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "添加微搜索",
                                            $"微搜索:{tbTitle.Text}");
                            SuccessMessage("添加微搜索成功!");
                        }

                        var redirectUrl = BackgroundSearch.GetRedirectUrl(PublishmentSystemID);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "微搜索设置失败!");
                    }
                }
            }
        }