public void InsertResourceType(WTF.Resource.Entity.Sys_ResourceType objResourceType) { objResourceType.ResourceTypeCode.CheckIsNull("请输入资源类型代码", LogModuleType.ResourceLog); SysAssert.CheckCondition(this.CurrentEntities.sys_resourcetype.Any <WTF.Resource.Entity.Sys_ResourceType>(p => p.ResourceTypeCode == objResourceType.ResourceTypeCode), "输入的资源类型代码已经存在", LogModuleType.ResourceLog); objResourceType.ResourceTypeName.CheckIsNull("请输入资源类型名称", LogModuleType.ResourceLog); this.CurrentEntities.AddTosys_resourcetype(objResourceType); this.CurrentEntities.SaveChanges(); }
public string InsertResource(string resourceName, int resourceTypeID) { resourceName.CheckIsNull("资源类型名称不为空", LogModuleType.ResourceLog); SysAssert.CheckCondition(resourceTypeID <= 0, "资源类型标识不为空", LogModuleType.ResourceLog); WTF.Resource.Entity.Sys_ResourceType type = this.CurrentEntities.sys_resourcetype.FirstOrDefault <WTF.Resource.Entity.Sys_ResourceType>(p => p.ResourceTypeID == resourceTypeID); SysAssert.CheckCondition(type == null, "资源类型不存在,请在资源申请处添加", LogModuleType.ResourceLog); WTF.Resource.Entity.Sys_Resource entity = new WTF.Resource.Entity.Sys_Resource { ResourceID = Guid.NewGuid().ToString(), ResourceName = resourceName, VerCount = 0, CreateDate = DateTime.Now }; type.Sys_Resource.Add(entity); this.CurrentEntities.SaveChanges(); return(entity.ResourceID); }
public void CheckResourceID(string ResourceID, string resourceName, int resourceTypeID) { if (!this.CurrentEntities.sys_resource.Any <WTF.Resource.Entity.Sys_Resource>(s => (s.ResourceID == ResourceID))) { ResourceID.CheckIsNull("资源标识不能为空", LogModuleType.ResourceLog); resourceName.CheckIsNull("资源类型名称不为空", LogModuleType.ResourceLog); SysAssert.CheckCondition(resourceTypeID <= 0, "资源类型标识不为空", LogModuleType.ResourceLog); WTF.Resource.Entity.Sys_ResourceType type = this.CurrentEntities.sys_resourcetype.FirstOrDefault <WTF.Resource.Entity.Sys_ResourceType>(p => p.ResourceTypeID == resourceTypeID); SysAssert.CheckCondition(type == null, "资源类型不存在,请在资源申请处添加", LogModuleType.ResourceLog); WTF.Resource.Entity.Sys_Resource entity = new WTF.Resource.Entity.Sys_Resource { ResourceID = ResourceID, ResourceName = resourceName, VerCount = 0, CreateDate = DateTime.Now }; type.Sys_Resource.Add(entity); this.CurrentEntities.SaveChanges(); } }
public void DeleteResourceType(string resourceTypeIDString) { //ObjectQuery<WTF.Resource.Entity.Sys_ResourceType> query = this.CurrentEntities.sys_resourcetype.Where("it.ResourceTypeID in {" + resourceTypeIDString + "}", new ObjectParameter[0]).Include("Sys_Resource"); List <Sys_ResourceType> query = this.CurrentEntities.sys_resourcetype.Where("it.ResourceTypeID in {" + resourceTypeIDString + "}", new ObjectParameter[0]).Include("Sys_Resource").ToList(); List <string> resourceFilePath = new List <string>(); using (IEnumerator <WTF.Resource.Entity.Sys_ResourceType> enumerator = query.GetEnumerator()) { while (enumerator.MoveNext()) { WTF.Resource.Entity.Sys_ResourceType objResourceType = enumerator.Current; WTF.Resource.Entity.Sys_ResourcePath path = this.CurrentEntities.sys_resourcepath.First <WTF.Resource.Entity.Sys_ResourcePath>(s => s.ResourcePathID == objResourceType.ResourcePathID); foreach (WTF.Resource.Entity.Sys_Resource resource in objResourceType.Sys_Resource) { resource.Sys_ResourceVer.Load(); foreach (WTF.Resource.Entity.Sys_ResourceVer ver in resource.Sys_ResourceVer) { if (string.IsNullOrEmpty(ver.DictionaryPath)) { resourceFilePath.Add(this.GetresourceFullFileNamePath(path.StoragePath, (AccessModeCodeType)objResourceType.AccessModeCodeType, objResourceType.ResourceTypeCode, this.GetResourcePathFormatValue(ver.UpdateDateTime, ver.ResourceVerID, objResourceType.PathFormatCodeType), ver.ResourceGUIDFileName, ver.ResourceFileName, false)); } else { resourceFilePath.Add(Path.Combine(path.StoragePath, ver.DictionaryPath)); } ver.Sys_ResourceDataReference.Load(); } } } } if (resourceFilePath.Count > 0) { this.DeleteResourceFile(resourceFilePath); } this.objCurrentEntities = null; this.CurrentEntities.sys_resourcetype.DeleteDataPrimaryKey <WTF.Resource.Entity.Sys_ResourceType>(resourceTypeIDString); }
public void AddTosys_resourcetype(Sys_ResourceType sys_ResourceType) { base.AddObject("sys_resourcetype", sys_ResourceType); }