예제 #1
0
 /// <summary>
 /// 修改文件宽高
 /// </summary>
 /// <param name="file">文件对象</param>
 public void UpdateFileWH(R_File file)
 {
     using (var db = new fz_resourceEntities()) {
         r_files rfile = db.r_files.Where(w => w.Id == file.Id).FirstOrDefault();
         rfile.Width  = file.Width;
         rfile.Height = file.Height;
         db.SaveChanges();
     }
 }
예제 #2
0
        /// <summary>
        /// 智慧教室上传文件
        /// </summary>
        /// <param name="Filedata">文件数据</param>
        /// <returns></returns>
        public bool UploadFileFromClassRoom(string Filedata)
        {
            using (var db = new fz_resourceEntities())
            {
                List <R_FileResource> fileresList = JsonHelper.JosnDeserializer <R_FileResource>(Filedata);
                foreach (R_FileResource fr in fileresList)
                {
                    r_files file = db.r_files.Find(fr.FileID);
                    if (file == null)
                    {
                        file                 = new r_files();
                        file.Id              = fr.FileID;
                        file.FileName        = fr.FileName;
                        file.FilePath        = fr.FilePath;
                        file.FileSize        = Convert.ToInt32(fr.FileSize);
                        file.FileDescription = fr.FileDescription;
                        file.FileExtension   = fr.FileExtension;
                        file.FileType        = fr.FileType;
                        file.UploadTime      = DateTime.Now;
                        db.r_files.Add(file);
                    }
                    r_resource resource = db.r_resource.Where(w => w.FileID == file.Id).FirstOrDefault();
                    if (resource == null)
                    {
                        resource                     = new r_resource();
                        resource.ResourceID          = System.Guid.NewGuid().ToString();
                        resource.SubjectID           = fr.SubjectID;
                        resource.FileID              = file.Id;
                        resource.GradeID             = fr.GradeID;
                        resource.EditionID           = fr.EditionID;
                        resource.Catalog             = fr.Catalog;
                        resource.ResourceName        = fr.FileName;
                        resource.ResourceSize        = fr.FileSize;
                        resource.Description         = fr.FileDescription;
                        resource.ResourceStyle       = fr.ResourceStyle;
                        resource.FileType            = file.FileExtension;
                        resource.ShareStauts         = 0;
                        resource.Copyright           = 4;
                        resource.ResourceCreaterID   = fr.UserID;
                        resource.ResourceCreaterName = fr.UserName;
                        resource.ResourceCreateDate  = DateTime.Now;
                    }
                    else
                    {
                        resource.ResourceStyle = fr.ResourceStyle;
                    }

                    db.r_resource.Add(resource);
                }
                return(db.SaveChanges() > 0);
            }
        }
예제 #3
0
 // GET api/<controller>/5
 public string Get(string id)
 {
     using (var db = new fz_resourceEntities())
     {
         r_files file = db.r_files.Find(id);
         if (file == null)
         {
             return("该文件不存在");
         }
         string url = string.Format("{0}/KingsunFiles/{1}/{2}.{3}", GetFileServerHttp(), file.FilePath, file.Id, file.FileExtension);
         return(url);
     }
 }
예제 #4
0
 /// <summary>
 /// 导入mod资源
 /// </summary>
 /// <param name="files"></param>
 /// <param name="resources"></param>
 /// <returns></returns>
 public string ImportModResource(string files, string resources)
 {
     try
     {
         List <R_ResourceExport_File>     filelist     = JsonHelper.JosnDeserializer <R_ResourceExport_File>(files);
         List <R_ResourceExport_Resource> resourcelist = JsonHelper.JosnDeserializer <R_ResourceExport_Resource>(resources);
         using (var dbcontext = new fz_resourceEntities())
         {
             /////////////先增加文件信息//////////////
             foreach (R_ResourceExport_File file in filelist)
             {
                 r_files tempfile = dbcontext.r_files.Find(file.ID);
                 if (tempfile == null)
                 {
                     dbcontext.r_files.Add(new r_files {
                         Id              = file.ID,
                         FileName        = file.FileName,
                         ConvertStatus   = file.ConvertStatus == null ? 0 : (int)file.ConvertStatus,
                         EncryptStatus   = file.EncryptStatus == null ? 0 : (int)file.EncryptStatus,
                         FileDescription = file.FileDescription,
                         FileExtension   = file.FileExtension,
                         FilePath        = file.FilePath,
                         FileSize        = file.FileSize == null ? 0 : (int)file.FileSize,
                         FileType        = file.FileType == null ? 0 : (int)file.FileType,
                         FinishStatus    = (bool)file.FinishStatus,
                         Height          = file.Height == null ? 0 : (int)file.Height,
                         UploadTime      = file.UploadTime,
                         Width           = file.Width == null ? 0 : (int)file.Width
                     });
                 }
             }
             ////////////后增加资源信息//////////////////
             foreach (R_ResourceExport_Resource resource in resourcelist)
             {
                 r_resource tempresource = dbcontext.r_resource.Find(resource.ID);
                 if (tempresource == null)
                 {
                     dbcontext.r_resource.Add(new r_resource {
                         ResourceID          = resource.ID,
                         Applicable          = resource.Applicable,
                         AppraisedCounts     = resource.AppraisedCounts,
                         BookReelID          = resource.BookReel,
                         BreviaryImgUrl      = resource.BreviaryImgUrl,
                         Catalog             = resource.Catalog,
                         CollectCounts       = resource.CollectCounts,
                         ComeFrom            = resource.ComeFrom,
                         Copyright           = resource.Copyrigh,
                         CopyrightName       = resource.CopyrighName,
                         Description         = resource.Description,
                         EditionID           = resource.Edition,
                         FileID              = resource.FileID,
                         FileType            = resource.FileType,
                         GradeID             = resource.Grade,
                         IsDelete            = resource.IsDelete,
                         IsRecommend         = resource.IsRecommend,
                         IsVerify            = resource.IsVerify,
                         KeyWords            = resource.KeyWords,
                         MaterialID          = resource.MaterialID == null ? null : resource.MaterialID,
                         ModifyDate          = resource.ModifyDate,
                         Number              = resource.Number,
                         Purview             = resource.Purview,
                         Sort                = (int)resource.Sort,
                         SubjectID           = resource.Subject,
                         ResourceClass       = resource.ResourceClass,
                         ResourceLevel       = resource.ResourceLevel,
                         ResourceName        = resource.Title,
                         ResourceScanNum     = resource.ScanCounts,
                         ResourceSize        = resource.ResourceSize,
                         ResourceStyle       = resource.ResourceStyle,
                         ResourceType        = resource.ResourceType,
                         SchoolStage         = resource.SchoolStage,
                         TeachingModules     = resource.TeachingModules,
                         TeachingStep        = resource.TeachingStep,
                         TeachingStyle       = resource.TeachingStyle,
                         TimeSpan            = resource.TimeSpan,
                         ResourceDowLoadNum  = resource.DownCounts,
                         ResourceCreateDate  = System.DateTime.Now,
                         ResourceCollectNum  = 0,
                         ResourceCreaterID   = "",
                         ResourceCreaterName = "方直",
                         ShareStauts         = null
                     });
                 }
             }
             try {
                 dbcontext.SaveChanges();
                 return("ok");
             } catch (Exception ex) {
                 return(ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }