コード例 #1
0
ファイル: ResourceEntities.cs プロジェクト: wtf-boy/Framework
 public void AddTosys_resourcedata(Sys_ResourceData sys_ResourceData)
 {
     base.AddObject("sys_resourcedata", sys_ResourceData);
 }
コード例 #2
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));
        }