Ejemplo n.º 1
0
 public bool SelectInfoMap(InfoMapQuery query)
 {
     try
     {
         return _infoMapDao.SelectInfoMap(query);
     }
     catch (Exception ex)
     {
         throw new Exception("InfoMapMgr-->SelectInfoMap-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 2
0
 public InfoMapQuery GetOldModel(InfoMapQuery query)
 {
     try
     {
         return _infoMapDao.GetOldModel(query);
     }
     catch (Exception ex)
     {
         throw new Exception("InfoMapMgr-->GetOldModel-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 3
0
 public List<InfoMapQuery> GetInfoMapList(InfoMapQuery query, out int totalCount)
 {
     try
     {
         return _infoMapDao.GetInfoMapList(query, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("InfoMapMgr-->GetInfoMapList-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 4
0
 public int UpdateInfoMap(InfoMapQuery query)
 {
     try
     {
         return _infoMapDao.UpdateInfoMap(query);
     }
     catch (Exception ex)
     {
         throw new Exception("InfoMapMgr-->UpdateInfoMap-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 5
0
        public HttpResponseBase GetInfoMapList()
        {
            List<InfoMapQuery> store = new List<InfoMapQuery>();
            string json = string.Empty;
            InfoMapQuery query = new InfoMapQuery();
            try
            {
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                if (!string.IsNullOrEmpty(Request.Params["siteName"]))
                {
                    query.site_name = Request.Params["siteName"];
                }
                if (!string.IsNullOrEmpty(Request.Params["searchType"]))
                {
                    query.type = Convert.ToInt32(Request.Params["searchType"]);
                }
                _infoMapMgr = new InfoMapMgr(mySqlConnectionString);
                int totalCount = 0;

                store = _infoMapMgr.GetInfoMapList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 元素關係保存
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SaveInfoMap()
        {
            string json = string.Empty;
            int isTranInt = 0;
            try
            {
                _infoMapMgr = new InfoMapMgr(mySqlConnectionString);
                InfoMapQuery emQuery = new InfoMapQuery();
                if (!string.IsNullOrEmpty(Request.Params["map_id"]))//修改
                {
                    emQuery.map_id = Convert.ToInt32(Request.Params["map_id"]);
                    InfoMapQuery oldQuery = _infoMapMgr.GetOldModel(emQuery);

                    if (!string.IsNullOrEmpty(Request.Params["site_id"]))
                    {
                        emQuery.site_id = Convert.ToInt32(Request.Params["site_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["page_id"]))
                    {
                        emQuery.page_id = Convert.ToInt32(Request.Params["page_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["area_id"]))
                    {
                        emQuery.area_id = Convert.ToInt32(Request.Params["area_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["type"]))
                    {
                        emQuery.type = Convert.ToInt32(Request.Params["type"]);
                    }
                    switch (emQuery.type)
                    {
                        case 1:
                            if (int.TryParse(Request.Params["info_id1"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id1"]);
                            }
                            else
                            {
                                emQuery.info_id = oldQuery.info_id;
                            }
                            break;
                        case 2:
                            if (int.TryParse(Request.Params["info_id2"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id2"]);
                            }
                            else
                            {
                                emQuery.info_id = oldQuery.info_id;
                            }
                            break;
                        case 3:
                            if (int.TryParse(Request.Params["info_id3"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id3"]);
                            }
                            else
                            {
                                emQuery.info_id = oldQuery.info_id;
                            }
                            break;
                        case 4:
                            if (int.TryParse(Request.Params["info_id4"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id4"]);
                            }
                            else
                            {
                                emQuery.info_id = oldQuery.info_id;
                            }
                            break;

                    }

                    if (!string.IsNullOrEmpty(Request.Params["sort"]))
                    {
                        emQuery.sort = Convert.ToInt32(Request.Params["sort"]);
                    }
                    emQuery.update_date = DateTime.Now;
                    emQuery.update_user_id = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());

                    if (_infoMapMgr.SelectInfoMap(emQuery))
                    {
                        _infoMapMgr.UpdateInfoMap(emQuery);
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }

                }
                else //新增
                {
                    if (!string.IsNullOrEmpty(Request.Params["site_id"]))
                    {
                        emQuery.site_id = Convert.ToInt32(Request.Params["site_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["page_id"]))
                    {
                        emQuery.page_id = Convert.ToInt32(Request.Params["page_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["area_id"]))
                    {
                        emQuery.area_id = Convert.ToInt32(Request.Params["area_id"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["type"]))
                    {
                        emQuery.type = Convert.ToInt32(Request.Params["type"]);
                    }
                    switch (emQuery.type)
                    {
                        case 1:
                            if (int.TryParse(Request.Params["info_id1"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id1"]);
                            }

                            break;
                        case 2:
                            if (int.TryParse(Request.Params["info_id2"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id2"]);
                            }

                            break;
                        case 3:
                            if (int.TryParse(Request.Params["info_id3"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id3"]);
                            }

                            break;
                        case 4:
                            if (int.TryParse(Request.Params["info_id4"], out isTranInt))
                            {
                                emQuery.info_id = Convert.ToInt32(Request.Params["info_id4"]);
                            }

                            break;

                    }


                    if (!string.IsNullOrEmpty(Request.Params["sort"]))
                    {
                        emQuery.sort = Convert.ToInt32(Request.Params["sort"]);
                    }
                    emQuery.create_date = DateTime.Now;
                    emQuery.update_date = emQuery.create_date;
                    emQuery.create_user_id = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    emQuery.update_user_id = emQuery.create_user_id;

                    if (_infoMapMgr.SelectInfoMap(emQuery))
                    {
                        _infoMapMgr.SaveInfoMap(emQuery);
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }

                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 查詢元素關係列表
 /// </summary>
 /// <param name="query">實體</param>
 /// <param name="totalCount">分頁</param>
 /// <returns>List<InfoMapQuery>集合</returns>
 public List<InfoMapQuery> GetInfoMapList(InfoMapQuery query, out int totalCount)
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder sb = new StringBuilder();
     StringBuilder sbCondi = new StringBuilder();
     StringBuilder sbCount = new StringBuilder();
     List<InfoMapQuery> store = new List<InfoMapQuery>();
     try
     {
         sb.Append(@" select im.map_id,im.site_id,s.site_name,im.page_id,sp.page_name,im.area_id,pa.area_name,im.info_id,im.type,im.sort,create_date,update_date,mu.user_username as update_user_name");
         sbCondi.Append("  from info_map im ");
         sbCondi.Append(" left join site s on s.site_id=im.site_id ");
         sbCondi.Append(" left join site_page sp on sp.page_id=im.page_id ");
         sbCondi.Append(" left join page_area pa on im.area_id=pa.area_id ");
         sbCondi.Append(" left join manage_user mu on im.update_user_id=mu.user_id where 1=1 ");
         sbCount.Append(" select count(im.map_id) as totalCount  ");
         if (!string.IsNullOrEmpty(query.site_name))
         {
             sbCondi.AppendFormat(" and s.site_name like  N'%{0}%'  ", query.site_name);
         }
         if (query.type != 0)
         {
             sbCondi.AppendFormat(" and im.type='{0}'  ", query.type);
         }
         sbCondi.Append(" order by map_id desc");
         totalCount = 0;
         if (query.IsPage)
         {
             sbCount.Append(sbCondi.ToString());
             DataTable dtcount = new DataTable();
             dtcount = _access.getDataTable(sbCount.ToString());
             if (dtcount != null && dtcount.Rows.Count > 0)
             {
                 totalCount =Convert.ToInt32(dtcount.Rows[0]["totalCount"]);
             }
         }
         sbCondi.AppendFormat("  limit {0},{1}", query.Start, query.Limit);
         sb.Append(sbCondi.ToString());
         store = _access.getDataTableForObj<InfoMapQuery>(sb.ToString());
         foreach (var item in store)
         {
             sql.Clear();
             switch (item.type)//類型 1:活動頁面 2:最新消息 3:訊息公告 4:電子報',
             {
                 case 1:
                     sql.AppendFormat("select tb.epaper_title as info_name from epaper_content tb where tb.epaper_id='{0}'", item.info_id);
                     break;
                 case 2:
                     sql.AppendFormat("select tb.news_title as info_name from news_content tb where tb.news_id='{0}'", item.info_id);
                     break;
                 case 3:
                     sql.AppendFormat("select tb.title as info_name from announce tb where tb.announce_id='{0}'", item.info_id);
                     break;
                 case 4:
                     sql.AppendFormat("select tb.content_title as info_name from edm_content tb where tb.content_id='{0}'", item.info_id);
                     break;
             }
             System.Data.DataTable _dt = _access.getDataTable(sql.ToString());
             if (_dt != null && _dt.Rows.Count > 0)
             {
                 item.info_name = _dt.Rows[0]["info_name"].ToString();
             }
         }
         return store;
     }
     catch (Exception ex)
     {
         throw new Exception("InfoMapDao-->GetInfoMapList-->" + ex.Message + sb.ToString() + sbCount.ToString()+sql.ToString(), ex);
     }
 }
Ejemplo n.º 8
0
        public InfoMapQuery GetOldModel(InfoMapQuery query)
        {
            StringBuilder sql = new StringBuilder();


            try
            {
                sql.AppendFormat("select map_id, site_id,page_id,area_id,type,info_id,sort,create_date,create_user_id,update_date,update_user_id from info_map where map_id='{0}'", query.map_id);

                return _access.getSinggleObj<InfoMapQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("InfoMapDao-->GetOldModel-->" + ex.Message + sql.ToString(), ex);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 判斷是否重複添加
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public bool SelectInfoMap(InfoMapQuery query)
        {
            string strSql = string.Empty;
            try
            {
                strSql = string.Format("select * from info_map where site_id='{0}' and page_id='{1}' and area_id='{2}' and type='{3}' and info_id='{4}'", query.site_id, query.page_id, query.area_id, query.type, query.info_id);
                InfoMapQuery model = _access.getSinggleObj<InfoMapQuery>(strSql);
                if (model == null)
                {
                    return true;//代表沒有重複添加
                }
                else if (model.map_id == query.map_id && query.map_id != 0)
                {
                    return true;
                }
                else
                {
                    return false;//代表有重複添加
                }

            }
            catch (Exception ex)
            {

                throw new Exception("InfoMapDao-->SelectInfoMap-->" + ex.Message + strSql.ToString(), ex);
            }
        }
Ejemplo n.º 10
0
        public int UpdateInfoMap(InfoMapQuery query)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@" update info_map set site_id='{0}',page_id='{1}',area_id='{2}',type='{3}',sort='{4}',info_id='{5}', ", query.site_id, query.page_id, query.area_id, query.type, query.sort, query.info_id);
                sb.AppendFormat(" update_date='{0}',update_user_id='{1}'  where map_id='{2}'", query.update_date.ToString("yyyy-MM-dd HH:mm:ss"), query.update_user_id, query.map_id);
                return _access.execCommand(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("InfoMapDao-->UpdateInfoMap-->" + ex.Message + sb.ToString(), ex);
            }

        }
Ejemplo n.º 11
0
        public int SaveInfoMap(InfoMapQuery query)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@" insert into info_map(site_id,page_id,area_id,type,info_id,sort,create_date,create_user_id,update_date,update_user_id)VALUES('{0}','{1}','{2}','{3}','{4}','{5}',", query.site_id, query.page_id, query.area_id, query.type, query.info_id, query.sort);
                sb.AppendFormat(" '{0}','{1}','{2}','{3}')", query.create_date.ToString("yyyy-MM-dd HH:mm:ss"), query.create_user_id, query.update_date.ToString("yyyy-MM-dd HH:mm:ss"), query.update_user_id);
                return _access.execCommand(sb.ToString());

            }
            catch (Exception ex)
            {
                throw new Exception("InfoMapDao-->SaveInfoMap-->" + ex.Message + sb.ToString(), ex);
            }

        }