/// <summary> /// 添加一个资源 /// </summary> /// <param name="resrc">待添加的资源实例</param> public void AddResource(Resource resrc) { if (resrc != null && resrc.ResourceName != null && !resrc.ResourceName.Equals("") && resrc.ResourceType != null && !resrc.ResourceType.Equals("") && resrc.ResourcePath != null && !resrc.ResourcePath.Equals("")) { CreateResourceQuery(resrc.ResourceName, resrc.ResourceType, resrc.ResourcePath); MoonDataSet.ResourcesDataTable dt = ResrcTableAdapter.GetDataByResourcePath(resrc.ResourcePath); if (dt.Rows.Count > 0) { MoonDataSet.ResourcesRow r = dt[0] as MoonDataSet.ResourcesRow; resrc.ResourceID = r.ResourceId.ToString(); } } }
/// <summary> /// 由资源路径获取资源实例 /// </summary> /// <param name="resourcePath"></param> /// <returns></returns> private Resource GetDataByResourcePath(string resourcePath) { try { MoonDataSet.ResourcesDataTable dt = ResrcTableAdapter.GetDataByResourcePath(resourcePath); if (dt.Rows.Count > 0) { MoonDataSet.ResourcesRow r = dt.Rows[0] as MoonDataSet.ResourcesRow; return(new Resource(r.ResourceId.ToString(), r.ResourceName, r.ResourceType, r.ResourcePath)); } } catch (Exception e) { } return(null); }