Ejemplo n.º 1
0
 public int Update(RedirectGroup query)
 {
     try
     {
         return _RdGroupdao.Update(query);
     }
     catch (Exception ex)
     {
         throw new Exception("RedirectGroupMgr.Update-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 2
0
 public List<RedirectGroupQuery> QueryAll(RedirectGroup query, out int totalCount)
 {
     try
     {
         return _RdGroupdao.QueryAll(query, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("RedirectGroupMgr.QueryAll-->" + ex.Message, ex);
     }
 }
Ejemplo n.º 3
0
 public string Save(RedirectGroup query)
 {
     StringBuilder sql = new StringBuilder("");
     try
     {
         query.Replace4MySQL();
         sql.Append(" INSERT INTO redirect_group(group_id,group_name,group_createdate,group_updatedate,group_ipfrom,group_type) ");
         sql.AppendFormat(" VALUES ('{0}','{1}','{2}','{3}','{4}','{5}')", query.group_id, query.group_name, query.group_createdate, query.group_updatedate, query.group_ipfrom,query.group_type);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("RedirectGroupDao-->Save-->" + ex.Message + sql.ToString(), ex);
     }
 }
Ejemplo n.º 4
0
 public int Update(RedirectGroup query)
 {
     StringBuilder sql = new StringBuilder("");
     try
     {
         query.Replace4MySQL();
         sql.AppendFormat("UPDATE redirect_group  set ");
         sql.AppendFormat(" group_name='{0}',group_updatedate='{1}',group_ipfrom='{2}',group_type='{3}' ", query.group_name, query.group_updatedate, query.group_ipfrom,query.group_type);
         sql.AppendFormat(" WHERE group_id='{0}' ;", query.group_id);
         return _access.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("RedirectGroupDao-->Update-->" + ex.Message + sql.ToString(), ex);
     }
 }
Ejemplo n.º 5
0
        public List<RedirectGroupQuery> QueryAll(RedirectGroup query, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                query.Replace4MySQL();
                StringBuilder sqlConi = new StringBuilder();
                sqlConi.Append(" SELECT group_id,group_name,group_createdate, FROM_UNIXTIME(group_createdate) createdate,group_updatedate,FROM_UNIXTIME(group_updatedate) updatedate,group_ipfrom,group_type,t.parameterName ");
                sql.Append(" FROM redirect_group left join t_parametersrc t on group_type = t.parameterCode AND t.parameterType='group_type' WHERE 1=1 ");
                if (query.group_id != 0)
                {
                    sql.AppendFormat(" AND  group_id={0}", query.group_id);
                }
                if(!string.IsNullOrEmpty(query.group_name))
                {
                    sql.AppendFormat(" AND group_name LIKE '%{0}%' ", query.group_name);
                }
                if (!string.IsNullOrEmpty(query.group_type))
                {
                    sql.AppendFormat(" AND group_type ='{0}' ", query.group_type);
                }
                sql.Append(" ORDER BY group_name ");

                totalCount = 0;

                if (query.IsPage)
                {
                    StringBuilder consql = new StringBuilder("SELECT count(group_id) ");
                    DataTable dt = _access.getDataTable(consql.ToString() + sql.ToString());
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(dt.Rows[0][0].ToString());
                    }
                    sql.AppendFormat(" LIMIT {0},{1};", query.Start, query.Limit);

                }
                return _access.getDataTableForObj<RedirectGroupQuery>(sqlConi.ToString() + sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("RedirectGroupDao-->QueryAll-->" + ex.Message + sql.ToString(), ex);
            }
        }
Ejemplo n.º 6
0
 public int Save(RedirectGroup query)
 {
     MySqlCommand mySqlCmd = new MySqlCommand();
     MySqlConnection mySqlConn = new MySqlConnection(connectionStr);
     StringBuilder sbExSql = new StringBuilder();
     SerialDao _serialDao = new SerialDao(connectionStr);
     int id = 0;
     try
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
         {
             mySqlConn.Open();
         }
         mySqlCmd.Connection = mySqlConn;
         //開啟事物
         mySqlCmd.Transaction = mySqlConn.BeginTransaction();
         mySqlCmd.CommandType = System.Data.CommandType.Text;
         StringBuilder Sql = new StringBuilder();
         //修改表serial
         Serial serial = new Serial();
         serial.Serial_id = 3;
         mySqlCmd.CommandText = _serialDao.Update(serial.Serial_id);//獲取鏈接管理在serial裡面的值
         sbExSql.Append(mySqlCmd.CommandText);
         query.group_id = Convert.ToUInt32(mySqlCmd.ExecuteScalar());
         sbExSql.Append(_RdGroupdao.Save(query));
         id = _access.execCommand(_RdGroupdao.Save(query));
         mySqlCmd.Transaction.Commit();
     }
     catch (Exception ex)
     {
         mySqlCmd.Transaction.Rollback();
         throw new Exception("RedirectGroupMgr-->Save-->" + ex.Message + sbExSql.ToString(), ex);
     }
     finally
     {
         if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
         {
             mySqlConn.Close();
         }
     }
     return id;
 }
Ejemplo n.º 7
0
        public HttpResponseBase RedirectGroupList()
        {
            List<RedirectGroupQuery> rgli = new List<RedirectGroupQuery>();
            string json = string.Empty;
            try
            {
                RedirectGroup RGModel = new RedirectGroup();
                RGModel.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                RGModel.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量
                _rdGroupMgr = new RedirectGroupMgr(mySqlConnectionString);
                RGModel.group_name = Request.Params["search_content"];
                int totalCount = 0;
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                rgli = _rdGroupMgr.QueryAll(RGModel, out totalCount);
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(rgli, 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:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 8
0
        public HttpResponseBase SaveGroup()
        {
            string json = string.Empty;
            try
            {
                RedirectGroup rgModel = new RedirectGroup();
                _rdGroupMgr = new RedirectGroupMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["group_id"]))
                {
                    rgModel.group_id = Convert.ToUInt32(Request.Params["group_id"].ToString());
                    rgModel.group_name = Request.Params["group_name"].ToString();
                    rgModel.group_updatedate = Convert.ToUInt32(CommonFunction.GetPHPTime());
                    if (!string.IsNullOrEmpty(Request.Params["group_type"].ToString()))
                    {
                        rgModel.group_type = Request.Params["group_type"].ToString();
                    }
                    rgModel.group_ipfrom = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault().ToString();
                    if (_rdGroupMgr.Update(rgModel) > 0)
                    {
                        json = "{success:true}";
                    }
                }
                else
                {
                    rgModel.group_name = Request.Params["group_name"].ToString();
                    if (!string.IsNullOrEmpty(Request.Params["group_type"].ToString()))
                    {
                        rgModel.group_type = Request.Params["group_type"].ToString();
                    }
                    rgModel.group_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime());
                    rgModel.group_updatedate = rgModel.group_createdate;
                    rgModel.group_ipfrom = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList.FirstOrDefault().ToString();
                    if (_rdGroupMgr.Save(rgModel) > 0)
                    {
                        json = "{success:true}";
                    }
                }

            }
            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;
        }