Beispiel #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);
     }
 }
Beispiel #2
0
 public void DeleteResource(string resourceID, string verNoString)
 {
     WTF.Resource.Entity.Sys_Resource objResource;
     if (verNoString.Length > 0)
     {
         objResource = this.CurrentEntities.sys_resource.Where("it.ResourceID=='" + resourceID + "'", new ObjectParameter[0]).Include("Sys_ResourceType").FirstOrDefault <WTF.Resource.Entity.Sys_Resource>();
         if (objResource != null)
         {
             List <WTF.Resource.Entity.Sys_ResourceVer> list = this.CurrentEntities.sys_resourcever.Where("it.ResourceID=='" + resourceID + "' and  it.VerNo in {" + verNoString + "}", new ObjectParameter[0]).Include("Sys_ResourceData").ToList <WTF.Resource.Entity.Sys_ResourceVer>();
             WTF.Resource.Entity.Sys_ResourcePath       path = this.CurrentEntities.sys_resourcepath.First <WTF.Resource.Entity.Sys_ResourcePath>(s => s.ResourcePathID == objResource.Sys_ResourceType.ResourcePathID);
             List <string> resourceFilePath = new List <string>();
             foreach (WTF.Resource.Entity.Sys_ResourceVer ver in list)
             {
                 objResource.VerCount--;
                 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 (ver.Sys_ResourceData != null)
                 {
                     this.CurrentEntities.DeleteObject(ver.Sys_ResourceData);
                 }
                 this.CurrentEntities.DeleteObject(ver);
             }
             if (resourceFilePath.Count > 0)
             {
                 this.DeleteResourceFile(resourceFilePath);
             }
             this.CurrentEntities.SaveChanges();
         }
     }
 }
Beispiel #3
0
 public void AddTosys_resourcepath(Sys_ResourcePath sys_ResourcePath)
 {
     base.AddObject("sys_resourcepath", sys_ResourcePath);
 }
Beispiel #4
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));
        }