Exemplo n.º 1
0
 public void DeleteResource(string resourceIDString)
 {
     if (resourceIDString.ConvertListString().Count > 0)
     {
         //ObjectQuery<WTF.Resource.Entity.Sys_Resource> query = this.CurrentEntities.sys_resource.Where("it.ResourceID in {" + resourceIDString.ConvertStringID() + "}", new ObjectParameter[0]).Include("Sys_ResourceType").Include("Sys_ResourceVer");
         List <Sys_Resource> query            = this.CurrentEntities.sys_resource.Where("it.ResourceID in {" + resourceIDString.ConvertStringID() + "}", new ObjectParameter[0]).Include("Sys_ResourceType").Include("Sys_ResourceVer").ToList();
         List <string>       resourceFilePath = new List <string>();
         using (IEnumerator <WTF.Resource.Entity.Sys_Resource> enumerator = query.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 WTF.Resource.Entity.Sys_Resource     objResource = enumerator.Current;
                 WTF.Resource.Entity.Sys_ResourcePath path        = this.CurrentEntities.sys_resourcepath.First <WTF.Resource.Entity.Sys_ResourcePath>(s => s.ResourcePathID == objResource.Sys_ResourceType.ResourcePathID);
                 foreach (WTF.Resource.Entity.Sys_ResourceVer ver in objResource.Sys_ResourceVer)
                 {
                     if (string.IsNullOrEmpty(ver.DictionaryPath))
                     {
                         resourceFilePath.Add(this.GetresourceFullFileNamePath(path.StoragePath, (AccessModeCodeType)objResource.Sys_ResourceType.AccessModeCodeType, objResource.Sys_ResourceType.ResourceTypeCode, this.GetResourcePathFormatValue(ver.UpdateDateTime, ver.ResourceVerID, objResource.Sys_ResourceType.PathFormatCodeType), ver.ResourceGUIDFileName, ver.ResourceFileName, false));
                     }
                     else
                     {
                         resourceFilePath.Add(Path.Combine(path.StoragePath, ver.DictionaryPath));
                     }
                 }
             }
         }
         if (resourceFilePath.Count > 0)
         {
             this.DeleteResourceFile(resourceFilePath);
         }
         this.objCurrentEntities = null;
         this.CurrentEntities.sys_resource.DeleteDataPrimaryKey <WTF.Resource.Entity.Sys_Resource>(resourceIDString);
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
 public void AddTosys_resource(Sys_Resource sys_Resource)
 {
     base.AddObject("sys_resource", sys_Resource);
 }
Exemplo n.º 5
0
        public ResourceInfo InsertResourceVer(string resourceID, string resourceFileName, int resourceSize, string contentType, string account, Stream objStream, int verNo, string remark)
        {
            string resourceVerID = Guid.NewGuid().ToString();

            resourceFileName.CheckIsNull("资源文件名为空", LogModuleType.ResourceLog);
            contentType.CheckIsNull("资源文件类型为空", LogModuleType.ResourceLog);
            account.CheckIsNull("帐号为空", LogModuleType.ResourceLog);
            SysAssert.CheckCondition((objStream == null) || (objStream.Length == 0L), "资源流为空", LogModuleType.ResourceLog);
            SysAssert.CheckCondition(verNo <= 0, "版本号小于零", LogModuleType.ResourceLog);
            this.DeleteResource(resourceID, verNo.ToString());
            SysAssert.CheckCondition(resourceID.IsNull(), "资源类型标识不为空", LogModuleType.ResourceLog);
            WTF.Resource.Entity.Sys_Resource objResource = this.CurrentEntities.sys_resource.Where(" it.ResourceID == '" + resourceID.ToString() + "'", new ObjectParameter[0]).Include("Sys_ResourceType").First <WTF.Resource.Entity.Sys_Resource>();
            DateTime now = DateTime.Now;

            WTF.Resource.Entity.Sys_ResourcePath path = this.CurrentEntities.sys_resourcepath.First <WTF.Resource.Entity.Sys_ResourcePath>(s => s.ResourcePathID == objResource.Sys_ResourceType.ResourcePathID);
            string resourceGUIDFileName = Guid.NewGuid() + Path.GetExtension(resourceFileName);
            string pathFormatValue      = this.GetResourcePathFormatValue(now, resourceVerID, objResource.Sys_ResourceType.PathFormatCodeType);
            string resourcePath         = this.GetResourceURL(path.VirtualName, (AccessModeCodeType)objResource.Sys_ResourceType.AccessModeCodeType, objResource.Sys_ResourceType.ResourceTypeCode, pathFormatValue, resourceGUIDFileName, resourceFileName, resourceVerID);
            string fileNamePath         = this.GetresourceFullFileNamePath(path.StoragePath, (AccessModeCodeType)objResource.Sys_ResourceType.AccessModeCodeType, objResource.Sys_ResourceType.ResourceTypeCode, pathFormatValue, resourceGUIDFileName, resourceFileName, true);
            string str6 = this.GetDirectoryPath((AccessModeCodeType)objResource.Sys_ResourceType.AccessModeCodeType, objResource.Sys_ResourceType.ResourceTypeCode, pathFormatValue, resourceGUIDFileName, resourceFileName);

            WTF.Resource.Entity.Sys_ResourceVer entity = new WTF.Resource.Entity.Sys_ResourceVer
            {
                ResourceVerID        = resourceVerID,
                ResourceSize         = resourceSize,
                ResourcePath         = resourcePath,
                DictionaryPath       = str6,
                ResourceGUIDFileName = resourceGUIDFileName,
                ResourceFileName     = resourceFileName,
                VerNo          = verNo,
                CreateDateTime = now,
                ContentType    = contentType,
                UpdateDateTime = now,
                Account        = account,
                RefCount       = 1,
                Remark         = remark
            };
            objResource.VerCount++;
            byte[] fileByteData = new BinaryReader(objStream).ReadBytes((int)objStream.Length);
            if (objResource.Sys_ResourceType.StorageType != 1)
            {
                WTF.Resource.Entity.Sys_ResourceData data = new WTF.Resource.Entity.Sys_ResourceData
                {
                    ResourceVerID = resourceVerID,
                    ResourceData  = fileByteData,
                    FileExtension = Path.GetExtension(resourceFileName)
                };
                entity.Sys_ResourceData = data;
            }
            objResource.Sys_ResourceVer.Add(entity);
            this.CurrentEntities.SaveChanges();
            if (objResource.Sys_ResourceType.StorageType != 2)
            {
                fileByteData.CreateFile(fileNamePath, true);
            }
            if (objStream != null)
            {
                objStream.Close();
            }
            return(new ResourceInfo(resourceID, resourceVerID, verNo, resourcePath, fileNamePath, resourceFileName));
        }