/// <summary> /// 通过Code获取RSID /// </summary> /// <param name="code">资源Code</param> /// <returns>null or RSID</returns> public int CodeToRSID(string code) { ResourceM r = new ResourceM(); return(r.Where(r.RS_Code == code) .SelectValue <int>(r.RSID, 0)); }
/// <summary> /// 通过RSID获取Code /// </summary> /// <param name="rsid">资源ID</param> /// <returns>null or Code</returns> public string RSIDToCode(int rsid) { ResourceM r = new ResourceM(); return(r.Where(r.RSID == rsid) .SelectValue <string>(r.RS_Code, null)); }
/// <summary> /// 修改资源信息 /// </summary> /// <param name="resource">资源实体</param> /// <returns>是否成功</returns> public bool ModifyResource(Resource resource) { ResourceM r = new ResourceM(); r.Bind(resource); r.RSID.IsInc = false; r.Create_Time.IsInc = false; r.Last_Update.Value = DateTime.Now; return(r.NoLock().Where(r.RSID == resource.RSID).Update()); }
/// <summary> /// 移除资源,同时移除资源与其它对象的关联信息 /// </summary> /// <param name="rsids">资源ID组</param> /// <param name="tran">事务</param> public bool RemoveResource(QDbTran tran, params int[] rsids) { Resource_LinkedM rl = new Resource_LinkedM(); ResourceM r = new ResourceM(); //删除关联表数据 // bool temp = true; temp = temp && rl.Where(rl.RSID.In(rsids)).Delete(tran); //删除资源表数据 temp = temp && r.Where(r.RSID.In(rsids)).Delete(tran); return(temp); }
/// <summary> /// 获取指定包里的资源 /// </summary> /// <param name="packageIds">包ID组</param> /// <param name="incDisabled">是否包括忆禁用的部分</param> /// <returns>资源列表</returns> public List <Resource> GetResources(bool incDisabled, params int[] packageIds) { ResourceM r = new ResourceM(); Resource_LinkedM rl = new Resource_LinkedM(); rl.IncludeAll(false); SQuery SQ = NewSQ(); SQ.From(r) .InnerJoin(rl) .On(rl.RSID == r.RSID) .Where(r.RSID != "0") .And(rl.LK_OBJT == Package.LK_OBJT) .And(rl.LK_OBJT_ID.In(packageIds)); if (incDisabled == false) { SQ.And(r.Is_Disabled == false); } if (_OrderColumnName == null) { SQ.OrderBy(r.Order_Index); } else { if (r.Contains(_OrderColumnName)) { SQ.OrderBy(r[_OrderColumnName]); } else if (rl.Contains(_OrderColumnName)) { SQ.OrderBy(r[_OrderColumnName]); } else if (_OrderColumnName.IndexOf(",") > 0) { SQ.OrderBy(r.CN_Name.Exp(_OrderColumnName)); } else { SQ.OrderBy(r.Order_Index); } } return(SQ.Select <Resource>()); }
/// <summary> /// 添加资源 /// </summary> /// <param name="resource">资源实体</param> /// <param name="tran">事务</param> /// <returns>是否成功</returns> public int AppendResource(Resource resource, QDbTran tran) { if (resource == null) { return(0); } if (string.IsNullOrEmpty(resource.Uri_Target)) { resource.Uri_Target = "_self"; } resource.Create_Time = DateTime.Now; resource.Last_Update = resource.Create_Time; ResourceM r = new ResourceM(); r.Bind(resource); r.Insert(true, tran); return(r.INSERTED_ID); }
/// <summary> /// 获取某一资源信息 /// </summary> /// <param name="rsid">资源ID</param> /// <returns>资源实体</returns> public Resource GetResource(int rsid) { ResourceM r = new ResourceM(); return(r.NoLock().Where(r.RSID == rsid).SelectOne <Resource>()); }
/// <summary> /// 是否存在某资源 /// </summary> /// <param name="rsid">资源ID</param> /// <returns>是否存在</returns> public bool Exists(int rsid) { ResourceM r = new ResourceM(); return(r.NoLock().Where(r.RSID == rsid).Exists()); }