示例#1
0
 public int AddElementMap(ElementMapQuery query) 
 {
     try
     {
         return _ielementmap.AddElementMap(query);
     }
     catch (Exception ex)
     {
         throw new Exception("ElementMapMgr-->AddElementMap-->" + ex.Message, ex);
     }
 }
示例#2
0
   public List<ElementMapQuery> GetElementMapList(ElementMapQuery query, out int totalCount)
 {
     try
     {
         return _ielementmap.GetElementMapList(query, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("ElementMapMgr-->GetElementMapList-->" + ex.Message, ex);
     }
 }
示例#3
0
        public int AddElementMap(ElementMapQuery query)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@" insert into element_map(site_id,page_id,area_id,packet_id,sort,create_date,create_user_id,update_date,update_user_id)VALUES('{0}','{1}','{2}','{3}','{4}',", query.site_id, query.page_id, query.area_id, query.packet_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("ElementMapDao-->AddElementMap-->" + ex.Message + sb.ToString(), ex);
            }

        }
示例#4
0
        /// <summary>
        /// 查詢元素關係列表
        /// </summary>
        /// <param name="query">實體</param>
        /// <param name="totalCount">分頁</param>
        /// <returns>List<ElementMapQuery>集合</returns>
        public List<ElementMapQuery> GetElementMapList(ElementMapQuery query, out int totalCount)
        {
            query.Replace4MySQL();
            StringBuilder sb = new StringBuilder();
            StringBuilder sqlWhere = new StringBuilder();
            sb.Append(@" select map_id,em.site_id,s.site_name,em.page_id,sp.page_name,em.area_id,pa.area_name,ap.packet_id,ap.packet_name,em.sort,create_date,update_date,mu.user_username as create_user_name");
            sb.Append("  from element_map em left join site s on s.site_id=em.site_id left join site_page sp on sp.page_id=em.page_id left join page_area pa on em.area_id=pa.area_id ");
            sb.Append(" left join area_packet ap on em.packet_id=ap.packet_id left join manage_user mu on em.update_user_id=mu.user_id  ");

            if (!string.IsNullOrEmpty(query.site_name))
            {
                sqlWhere.AppendFormat(" and s.site_name like  N'%{0}%'  ", query.site_name);
            }
            if (query.element_type != 0)
            {
                sqlWhere.AppendFormat(" and ap.element_type='{0}'  ", query.element_type);
            }
            if (sqlWhere.Length != 0)
            {
                sb.Append(" WHERE ");
                sb.Append(sqlWhere.ToString().TrimStart().Remove(0, 3));
            }

            try
            {
                totalCount = 0;
                if (query.IsPage)
                {

                    System.Data.DataTable _dt = _access.getDataTable(sb.ToString());
                    if (_dt != null && _dt.Rows.Count > 0)
                    {
                        totalCount = _dt.Rows.Count;
                    }

                    sb.Append(" order by map_id desc");
                    sb.AppendFormat("  limit {0},{1}", query.Start, query.Limit);
                }
                return _access.getDataTableForObj<ElementMapQuery>(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("ElementMapDao-->GetElementMapList-->" + ex.Message + sb.ToString(), ex);
            }
        }
示例#5
0
        public int upElementMap(ElementMapQuery query)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                sb.AppendFormat(@" update element_map set site_id='{0}',page_id='{1}',area_id='{2}',packet_id='{3}',sort='{4}', ", query.site_id, query.page_id, query.area_id, query.packet_id, query.sort);
                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("ElementMapDao-->upElementMap-->" + ex.Message + sb.ToString(), ex);
            }

        }
示例#6
0
        /// <summary>
        /// 判斷是否重複添加
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public bool SelectElementMap(ElementMapQuery query)
        {
            StringBuilder strSql = new StringBuilder();
            try
            {
                strSql.Append("select map_id,site_id,page_id,area_id,packet_id,sort,create_date,create_user_id,update_date,update_user_id from element_map ");
                strSql.AppendFormat(" where site_id='{0}' and page_id='{1}' and area_id='{2}' and packet_id='{3}'", query.site_id, query.page_id, query.area_id, query.packet_id);
                ElementMapQuery model = _access.getSinggleObj<ElementMapQuery>(strSql.ToString());
                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("ElementMapDao-->SelectElementMap-->" + ex.Message + strSql.ToString(), ex);
            }
        }
示例#7
0
        /// <summary>
        /// 元素關係保存
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SaveElementMap()
        {
            string json = string.Empty;
            try
            {
                ElementMapQuery emQuery = new ElementMapQuery();
                if (!string.IsNullOrEmpty(Request.Params["map_id"]))//修改
                {
                    emQuery.map_id = Convert.ToInt32(Request.Params["map_id"]);
                    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["packet_id"]))
                    {
                        emQuery.packet_id = Convert.ToInt32(Request.Params["packet_id"]);
                    }
                    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());
                    _elementMapMgr = new ElementMapMgr(mySqlConnectionString);
                    if (_elementMapMgr.SelectElementMap(emQuery))
                    {
                        _elementMapMgr.upElementMap(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["packet_id"]))
                    {
                        emQuery.packet_id = Convert.ToInt32(Request.Params["packet_id"]);
                    }
                    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;
                    _elementMapMgr = new ElementMapMgr(mySqlConnectionString);
                    if (_elementMapMgr.SelectElementMap(emQuery))
                    {
                        _elementMapMgr.AddElementMap(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;
        }
示例#8
0
        public HttpResponseBase ElementMapList()
        {
            List<ElementMapQuery> store = new List<ElementMapQuery>();
            string json = string.Empty;
            ElementMapQuery query = new ElementMapQuery();
            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.element_type = Convert.ToInt32(Request.Params["searchType"]);
                }
                _elementMapMgr = new ElementMapMgr(mySqlConnectionString);
                int totalCount = 0;

                store = _elementMapMgr.GetElementMapList(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;
        }
示例#9
0
 public bool SelectElementMap(ElementMapQuery query)
 {
     return _ielementmap.SelectElementMap(query);
 }