Ejemplo n.º 1
0
        public bool Save(ScheduleRelation sr)
        {
            try
            {
                if (Query(sr).Count > 0)
                {
                    if (sr.schedule_id == 0)
                    {
                        return Delete(sr.relation_table, sr.relation_id);
                    }
                    else
                    {
                        return _scheduleRelationDao.Update(sr) > 0;
                    }
                }
                else 
                {
                    if (sr.schedule_id != 0)
                        return _scheduleRelationDao.Save(sr) > 0;
                    else
                        return true;
                }

            }
            catch (Exception ex)
            {
                throw new Exception("ScheduleRelationMgr-->Save" + ex.Message,ex);
            }
        }
Ejemplo n.º 2
0
        public List<ScheduleRelation> Query(ScheduleRelation sr)
        {
            try 
	        {
                return _scheduleRelationDao.Query(sr);
	        }
	        catch (Exception ex)
	        {
                throw new Exception("ScheduleRelationMgr-->Query" + ex.Message,ex);
	        }
        }
Ejemplo n.º 3
0
 public int Save(ScheduleRelation sr)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"INSERT INTO schedule_relation(`schedule_id`,`relation_table`,`relation_id`)VALUES({0},'{1}',{2});",sr.schedule_id,sr.relation_table,sr.relation_id);
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleRelationDao-->Save" + ex.Message,ex);
     }
 }
Ejemplo n.º 4
0
        public List<ScheduleRelation> Query(ScheduleRelation sr)
        {
            try
            {

                var scheRel = _access.getDataTableForObj<ScheduleRelation>(string.Format("SELECT  rowid,schedule_id,relation_table,relation_id  FROM schedule_relation WHERE relation_id={0} AND relation_table='{1}';", sr.relation_id, sr.relation_table));
                foreach (var item in scheRel)
                {
                    item.schedule = new ScheduleDao(connectionString).Query(new Model.Query.ScheduleQuery { schedule_id = item.schedule_id }).FirstOrDefault();
                }
                return scheRel;
            }
            catch (Exception ex)
            {
                throw new Exception("ScheduleRelationDao-->Query" + ex.Message, ex);
            }
        }
Ejemplo n.º 5
0
 public int Update(ScheduleRelation sr)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         sb.AppendFormat(@"set sql_safe_updates=0;update schedule_relation set`schedule_id`={0} where `relation_table`='{1}' AND `relation_id`={2};set sql_safe_updates=1;", sr.schedule_id, sr.relation_table, sr.relation_id); ///add by wwei0216w 2015/3/30 修改原因 代碼執行至該處出現異常 在'{1}'后將','改為'AND'
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("ScheduleRelationDao-->Save" + ex.Message, ex);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 獲取關係表數據by schedule_id
        /// </summary>
        /// <param name="sr"></param>
        /// <returns></returns>
        public ActionResult GetRelationTiers(ScheduleRelation sr)
        {
            try
            {
                List<ScheduleRelation> list = new List<ScheduleRelation>();
                IScheduleRelationImplMgr _srMgr = new ScheduleRelationMgr(connectionString);
                list = _srMgr.Query(sr.schedule_id);
                return Content(JsonConvert.SerializeObject(list));
            }
            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);
                return new EmptyResult();
            }

        }