예제 #1
0
        public bool Save(LogoFile file, string userId)
        {
            string filePath = getFilePath(file.ClientNumber, userId);

            if (File.Exists(filePath))
            {
                try
                {
                    File.Delete(filePath);
                }
                catch (Exception e)
                {
                    _log.Log(e.Message);
                    return(false);
                }
            }

            try
            {
                FileStream FileStream = new FileStream(filePath, FileMode.Create);
                FileStream.Write(file.File, 0, file.File.Length);
                FileStream.Close();
                FileStream.Dispose();
            }
            catch (Exception e)
            {
                _log.Log(e.Message);
                return(false);
            }


            return(true);
        }
예제 #2
0
 // ロゴを使い終わったら必ず呼ぶこと
 public void ClearLogo()
 {
     if (Logo != null)
     {
         File.Delete(logopath);
         logopath = null;
         Logo.Dispose();
         Logo = null;
     }
 }
예제 #3
0
 public void Close()
 {
     if (mediafile != null)
     {
         mediafile.Dispose();
         mediafile = null;
     }
     if (_Logo != null)
     {
         _Logo.Dispose();
         _Logo = null;
     }
 }
예제 #4
0
        // 失敗するとIOExceptionが飛ぶ
        public async Task Analyze(string filepath, int serviceid, string workpath, Point pt, Size sz, int thy, int maxFrames)
        {
            int    pid      = System.Diagnostics.Process.GetCurrentProcess().Id;
            string workfile = workpath + "\\logotmp" + pid + ".dat";
            string tmppath  = workpath + "\\logotmp" + pid + ".lgd";

            // 2の倍数にする
            int imgx = (int)Math.Floor(pt.X / 2) * 2;
            int imgy = (int)Math.Floor(pt.Y / 2) * 2;
            int w    = (int)Math.Ceiling(sz.Width / 2) * 2;
            int h    = (int)Math.Ceiling(sz.Height / 2) * 2;

            NowScanning    = true;
            CancelScanning = false;

            ClearLogo();

            try
            {
                await Task.Run(() => LogoFile.ScanLogo(
                                   context, filepath, serviceid, workfile, tmppath, imgx, imgy, w, h, thy, maxFrames, LogoScanCallback));

                // TsInfoでサービス名を取得する
                using (var info = new TsInfo(context))
                {
                    if (info.ReadFile(filepath) == false)
                    {
                        MessageBox.Show("TS情報取得に失敗: " + context.GetError());
                    }
                    else
                    {
                        // 名前を修正して保存し直す
                        using (var logo = new LogoFile(context, tmppath))
                        {
                            if (info.HasServiceInfo)
                            {
                                int    serviceId   = logo.ServiceId;
                                string serviceName = info.GetServiceList().First(s => s.ServiceId == serviceId).ServiceName;
                                string date        = info.GetTime().ToString("yyyy-MM-dd");
                                logo.Name = serviceName + "(" + date + ")";
                            }
                            else
                            {
                                logo.Name = "情報なし";
                            }

                            logopath = workpath + "\\logo" + pid + ".lgd";
                            logo.Save(logopath);
                        }

                        Logo = new LogoFile(context, logopath);
                        UpdateLogoImage();
                    }
                }
            }
            finally
            {
                if (File.Exists(workfile))
                {
                    File.Delete(workfile);
                }
                if (File.Exists(tmppath))
                {
                    File.Delete(tmppath);
                }
                NowScanning = false;
            }
        }
예제 #5
0
 public bool Save(LogoFile file, string userId)
 {
     return(_logoManager.Save(file, userId));
 }