Ejemplo n.º 1
0
        /// <summary>
        /// 开始处理任务
        /// </summary>
        /// <returns></returns>
        public async Task StartJob(JsonFile jsonFile, string tempFilePath)
        {
            if (jsonFile.Values.Count > 0)
            {
                StorageOperation       storage     = new StorageOperation();
                TempStorageOperation   tempStorage = new TempStorageOperation();
                Queue <JsonFileValues> queues      = new Queue <JsonFileValues>();
                for (int i = 0; i < jsonFile.Values.Count; i++)
                {
                    queues.Enqueue(jsonFile.Values[i]);
                }

                jsonFile.Values.Clear();
                if (queues.Count > 0)
                {
                    JsonFileValues job = null;
                    while (queues.TryDequeue(out job))
                    {
                        //预览图处理
                        if (job.Key == "Medium")
                        {
                            jsonFile.Values.Add(new Jobs.ToMediumJob().Run(tempFilePath, job));
                        }
                        //缩略图处理
                        if (job.Key == "Small")
                        {
                            jsonFile.Values.Add(new Jobs.CreateSmallJob().Run(tempFilePath, job));
                        }
                    }
                }
                //保存Json文件
                await jsonFile.SaveAs(tempStorage.GetJsonFilePath(jsonFile.Id));
            }
        }
Ejemplo n.º 2
0
        public JsonFileValues Run(string tempFilePath, JsonFileValues job)
        {
            FileInfo fileInfo = new FileInfo(tempFilePath);
            var      fileName = fileInfo.Name.Replace(fileInfo.Extension, "");

            string thumbnailName = string.Format("{0}_{1}{2}", fileName, "Small", fileInfo.Extension);
            string thumbnailPath = fileInfo.DirectoryName + "\\" + thumbnailName;

            ThumbnailClass.MakeThumbnail(tempFilePath, thumbnailPath, 100, 100, "Cut");
            job.Param      = "100x100";
            job.Status     = "1";
            job.Value      = Core.StorageOperation.GetUrl(thumbnailName);
            job.CreateTime = DateTime.Now;

            return(job);
        }
Ejemplo n.º 3
0
 public JsonFileValues Run(string tempFilePath, JsonFileValues job)
 {
     return(null);
 }