Beispiel #1
0
 public ImageUploadHandler(IMangaWriteRepo repo, IImageRepo imageRepo,
                           IFileHandler fileHandler)
 {
     this._mangaRepo   = repo;
     this._imageRepo   = imageRepo;
     this._fileHandler = fileHandler;
 }
Beispiel #2
0
 public ImageController(IImageRepo imageRepo, IUserRepo userRepo, ILikeImageRepo likeImageRepo, IHostingEnvironment env)
 {
     _env           = env;
     _imageRepo     = imageRepo;
     _userRepo      = userRepo;
     _likeImageRepo = likeImageRepo;
 }
Beispiel #3
0
 public ImagesController(IHostingEnvironment host, IImageRepo imageRepo, IOrderRepository repository, IUnitOfWork uow, IMapper mapper, IOptionsSnapshot <ImageSettings> options)
 {
     imageSettings = options.Value;
     _host         = host;
     _repository   = repository;
     _uow          = uow;
     _mapper       = mapper;
     _imageRepo    = imageRepo;
 }
 public ImageBLL(IImageRepo repo)
 {
     this.repo = repo;
 }
 public ImageBLL()
 {
     repo = new ImageRepo();
 }
 public ImageController(IImageRepo imgRepo)
 {
     _imgRepo = imgRepo;
 }
 public ImageController(IImageRepo repo)
 {
     this.bl = repo;
 }
Beispiel #8
0
 public ImageController(IImageRepo repo, IMapper mapper)
 {
     _mapper = mapper;
     _repo   = repo;
 }
Beispiel #9
0
        /// <summary>
        /// 检查并上传乐谱图片
        /// </summary>
        /// <param name="dbPath"></param>
        /// <param name="threadCount"></param>
        private static void CheckSheetPreviewImg(string dbPath, int threadCount)
        {
            Console.WriteLine("执行上传乐谱首页任务, dbPath=" + dbPath + ", 线程数 = " + threadCount);
            InitDB(dbPath);
            var ypHomePath = ConfigUtil.Instance.Load().PianoScorePath;

            if (string.IsNullOrEmpty(ypHomePath))
            {
                Console.WriteLine("无法获取乐谱路径, 先检查一下配置文件");
                return;
            }
            ConcurrentQueue <PianoScore> sheetDirQueue = new ConcurrentQueue <PianoScore>();
            var dataSet = SQLite.SqlTable("SELECT ypid, name, yp_count FROM tan8_music WHERE ypid NOT IN (SELECT ypid FROM tan8_music_img)", null);
            var total   = dataSet.Rows.Count;

            Console.WriteLine("正在添加任务队列...");
            foreach (DataRow dataRow in dataSet.Rows)
            {
                if (Directory.Exists(Path.Combine(ypHomePath, Convert.ToString(dataRow["ypid"]))))
                {
                    sheetDirQueue.Enqueue(new PianoScore()
                    {
                        id      = Convert.ToInt32(dataRow["ypid"]),
                        Name    = dataRow["name"].ToString(),
                        YpCount = Convert.ToByte(dataRow["yp_count"])
                    });
                }
            }
            Console.WriteLine("共添加" + total + "项任务");

            List <ManualResetEvent> manualEvents = new List <ManualResetEvent>();

            for (int i = 0; i < threadCount; i++)
            {
                ManualResetEvent mre = new ManualResetEvent(false);
                manualEvents.Add(mre);
                ThreadPool.QueueUserWorkItem((object obj) =>
                {
                    while (sheetDirQueue.Count > 0)
                    {
                        PianoScore pianoScore = new PianoScore();
                        var isOk = sheetDirQueue.TryDequeue(out pianoScore);
                        if (isOk)
                        {
                            var sheetDir       = Path.Combine(ypHomePath, pianoScore.id.GetValueOrDefault().ToString());
                            var previewPicName = "public.png";
                            //检查目标文件夹是否已经存在已处理的图片
                            if (File.Exists(Path.Combine(ypHomePath, sheetDir, previewPicName)))
                            {
                                IImageRepo imageAPI = ImageRepoFactory.GetRandomApi();
                                //IImageRepo imageAPI = new PrntImageRepo();
                                ImageRepoUploadArg uploadArg = new ImageRepoUploadArg()
                                {
                                    FullFilePath = Path.Combine(ypHomePath, sheetDir, previewPicName),
                                    ExtraArgs    = new JObject
                                    {
                                        { "uploadFileFormName", "sheet_" + pianoScore.id + ".png" }
                                    }
                                };
                                InvokeResult <ImageRepoUploadResult> invokeResult;
                                try
                                {
                                    invokeResult = imageAPI.Upload(uploadArg);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("api {0}, 引发异常, {1}", imageAPI.GetApiCode(), e.Message);
                                    continue;
                                }
                                if (!invokeResult.success)
                                {
                                    Console.WriteLine(pianoScore.Name + "上传失败, msg=" + invokeResult.message);
                                    continue;
                                }
                                SQLite.ExecuteNonQuery("INSERT INTO tan8_music_img(ypid, yp_name, img_url, api, api_channel, create_time) VALUES (@ypid, @ypName, @imgUrl, @api, @apiChannel, datetime('now', 'localtime'))",
                                                       new List <SQLiteParameter>()
                                {
                                    new SQLiteParameter("@ypid", pianoScore.id.GetValueOrDefault()),
                                    new SQLiteParameter("@ypName", pianoScore.Name),
                                    new SQLiteParameter("@imgUrl", invokeResult.data.ImgUrl),
                                    new SQLiteParameter("@api", invokeResult.data.Api),
                                    new SQLiteParameter("@apiChannel", invokeResult.data.ApiChannel)
                                });
                                Console.WriteLine("剩余 : " + sheetDirQueue.Count);
                            }
                        }
                    }
                    ManualResetEvent localMre = (ManualResetEvent)obj;
                    localMre.Set();
                }, mre);
            }
            WaitHandle.WaitAll(manualEvents.ToArray());
            Console.WriteLine("乐谱图片上传完毕");
        }
Beispiel #10
0
 public ChapterRepo(ISQLClient client, IImageRepo images)
 {
     this._client     = client;
     this._imagesRepo = images;
 }