Пример #1
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;
        }
Пример #2
0
 public HttpResponseBase GetAreaCount()
 {
     string json = string.Empty;
     try
     {
         int areaId = Convert.ToInt32(Request.Params["AreaId"].ToString());
         _elementMapMgr = new ElementMapMgr(mySqlConnectionString);
         if (_elementMapMgr.GetAreaCount(areaId))
         {
             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;
 }
Пример #3
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;
        }