Преглед на файлове

WIP:loose end, almost done!

shenjian Office PC преди 7 години
родител
ревизия
d84b4119dc
променени са 9 файла, в които са добавени 291 реда и са изтрити 81 реда
  1. 1 0
      Entity/Entity.csproj
  2. 1 0
      Entity/EnumQStatus.cs
  3. 30 0
      Entity/ResultArzon.cs
  4. 13 16
      Entity/SearchItem.cs
  5. 37 24
      PicSo/Form1.Designer.cs
  6. 72 41
      PicSo/Form1.cs
  7. 1 0
      PicSo/PicSo.csproj
  8. 136 0
      PicSo/SearchController.cs
  9. BIN
      PicSo/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache

+ 1 - 0
Entity/Entity.csproj

@@ -56,6 +56,7 @@
       <DesignTime>True</DesignTime>
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
+    <Compile Include="ResultArzon.cs" />
     <Compile Include="SearchItem.cs" />
     <Compile Include="Tools.cs" />
   </ItemGroup>

+ 1 - 0
Entity/EnumQStatus.cs

@@ -9,6 +9,7 @@ namespace AVSORTER
     {
         未开始,//未开始
         查询中,//查询列表
+        查询完成,
         查询完成一个结果,//列表完成
         查询完成无匹配,
         多个结果请选择一个,

+ 30 - 0
Entity/ResultArzon.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AVSORTER
+{
+    public class ResultArzon
+    {
+        public string Code { get; set; }
+        public Movie Movie { get; set; }
+        public string Status { get; set; }
+
+
+        private QStatus _qstatus;
+
+        public QStatus QStatus
+        {
+            get { return _qstatus; }
+            set { _qstatus = value;
+                Console.WriteLine(_qstatus.ToString());
+            }
+        }
+
+
+
+
+
+    }
+}

+ 13 - 16
Entity/SearchItem.cs

@@ -10,7 +10,7 @@ namespace AVSORTER
     {
         #region 构造函数 public FileItem(string codeString,IGetable getor)
 
-        public SearchItem(string codeString,IGetable getor)
+        public SearchItem(string codeString, IGetable getor)
         {
             this._queryString = codeString;
             this.Getor = getor;
@@ -20,9 +20,6 @@ namespace AVSORTER
         #region 属性 查询字符串public string SeedString
 
         private string _queryString;
-        /// <summary>
-        /// 查询的字符串
-        /// </summary>
         public string SeedString
         {
             get { return _queryString; }
@@ -35,9 +32,10 @@ namespace AVSORTER
         public Movie MovieDetail
         {
             get { return _mv; }
+
         }
         #endregion
-        
+
         /// <summary>
         /// 结果列表
         /// </summary>
@@ -66,7 +64,7 @@ namespace AVSORTER
         {
             get
             {
-                if (this.chooseIndex==-1)
+                if (this.chooseIndex == -1)
                 {
                     return false;
                 }
@@ -128,14 +126,13 @@ namespace AVSORTER
             }
             catch (Exception ee)
             {
-                
+
                 throw ee;
             }
         }
         private void _getMovieCallback(IAsyncResult res)
         {
 
-
             try
             {
                 this._mv = (res.AsyncState as Func<MovieBasic, Movie>).EndInvoke(res);
@@ -169,7 +166,7 @@ namespace AVSORTER
                     OnCompletedLoadImage(this, new EventArgs());
                 }
             }
-            
+
         }
 
         private void _startGetCover()
@@ -196,12 +193,12 @@ namespace AVSORTER
 
         }
 
-        virtual protected void RaiseStatusChangeEvent(QStatus b,QStatus aft,string msg)
+        virtual protected void RaiseStatusChangeEvent(QStatus b, QStatus aft, string msg)
         {
             this._status = aft;
-            if (OnStatusChange!=null)
+            if (OnStatusChange != null)
             {
-                OnStatusChange(this,new StatusChangeEventArgs(b,aft,msg));
+                OnStatusChange(this, new StatusChangeEventArgs(b, aft, msg));
             }
         }
 
@@ -217,17 +214,17 @@ namespace AVSORTER
 
         public void StartQuery()
         {
-            if (OnAboutToLoadInfo==null)
+            if (OnAboutToLoadInfo == null)
             {
                 throw new Exception("必须注册这个事件");
             }
             else
             {
-                OnAboutToLoadInfo(this, new EventArgs());
+				OnAboutToLoadInfo(this, new EventArgs());
             }
 
 
-            if (this.Getor!=null)
+            if (this.Getor != null)
             {
                 //this.MovieBasicList = Getor.Query(SeedString);
                 Func<string, List<MovieBasic>> fuc = new Func<string, List<MovieBasic>>(Getor.Query);
@@ -288,7 +285,7 @@ namespace AVSORTER
             public QStatus Before { get; set; }
             public QStatus After { get; set; }
             public string Message { get; set; }
-            public StatusChangeEventArgs(QStatus _before, QStatus _after,string _msg)
+            public StatusChangeEventArgs(QStatus _before, QStatus _after, string _msg)
             {
                 this.Before = _before;
                 this.After = _after;

+ 37 - 24
PicSo/Form1.Designer.cs

@@ -60,14 +60,12 @@
             this.label2 = new System.Windows.Forms.Label();
             this.txt_sub = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
-            this.bc = new AVSORTER.BasicContainer();
             this.tabControl1 = new System.Windows.Forms.TabControl();
             this.tabPage2 = new System.Windows.Forms.TabPage();
             this.listBox1 = new System.Windows.Forms.ListBox();
             this.cb_AutoCorrect = new System.Windows.Forms.CheckBox();
             this.btn_LocalSearch = new System.Windows.Forms.Button();
             this.txt_LocalSearchKeyWord = new System.Windows.Forms.TextBox();
-            this.movieContainer1 = new PicSo.MovieContainer();
             this.tabPage3 = new System.Windows.Forms.TabPage();
             this.label3 = new System.Windows.Forms.Label();
             this.nud_ActorLessThan = new System.Windows.Forms.NumericUpDown();
@@ -87,6 +85,9 @@
             this.btn_p4_Go1 = new System.Windows.Forms.Button();
             this.label4 = new System.Windows.Forms.Label();
             this.txt_p4_keyword = new System.Windows.Forms.TextBox();
+            this.button1 = new System.Windows.Forms.Button();
+            this.bc = new AVSORTER.BasicContainer();
+            this.movieContainer1 = new PicSo.MovieContainer();
             this.contextMenuStrip1.SuspendLayout();
             this.tabPage1.SuspendLayout();
             this.groupBox2.SuspendLayout();
@@ -175,6 +176,7 @@
             // 
             // groupBox2
             // 
+            this.groupBox2.Controls.Add(this.button1);
             this.groupBox2.Controls.Add(this.btn_paste_new);
             this.groupBox2.Controls.Add(this.btn_AddNewEmptyItem);
             this.groupBox2.Controls.Add(this.txt_EmptyItemKeyWord);
@@ -404,18 +406,6 @@
             this.label1.TabIndex = 12;
             this.label1.Text = "目标路径";
             // 
-            // bc
-            // 
-            this.bc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-            this.bc.IsShowPic = false;
-            this.bc.ListMovieBasic = null;
-            this.bc.Location = new System.Drawing.Point(6, 341);
-            this.bc.MovieB = null;
-            this.bc.Name = "bc";
-            this.bc.Size = new System.Drawing.Size(411, 180);
-            this.bc.TabIndex = 7;
-            this.bc.Load += new System.EventHandler(this.bc_Load);
-            // 
             // tabControl1
             // 
             this.tabControl1.Controls.Add(this.tabPage1);
@@ -483,16 +473,6 @@
             this.txt_LocalSearchKeyWord.TabIndex = 0;
             this.txt_LocalSearchKeyWord.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_LocalSearchKeyWord_KeyPress);
             // 
-            // movieContainer1
-            // 
-            this.movieContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-            this.movieContainer1.Location = new System.Drawing.Point(6, 176);
-            this.movieContainer1.Movie = null;
-            this.movieContainer1.MovieList = null;
-            this.movieContainer1.Name = "movieContainer1";
-            this.movieContainer1.Size = new System.Drawing.Size(913, 375);
-            this.movieContainer1.TabIndex = 2;
-            // 
             // tabPage3
             // 
             this.tabPage3.Controls.Add(this.label3);
@@ -672,6 +652,38 @@
             this.txt_p4_keyword.Size = new System.Drawing.Size(100, 21);
             this.txt_p4_keyword.TabIndex = 0;
             // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(648, 20);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(110, 50);
+            this.button1.TabIndex = 21;
+            this.button1.Text = "CPUs";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // bc
+            // 
+            this.bc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.bc.IsShowPic = false;
+            this.bc.ListMovieBasic = null;
+            this.bc.Location = new System.Drawing.Point(6, 341);
+            this.bc.MovieB = null;
+            this.bc.Name = "bc";
+            this.bc.Size = new System.Drawing.Size(411, 180);
+            this.bc.TabIndex = 7;
+            this.bc.Load += new System.EventHandler(this.bc_Load);
+            // 
+            // movieContainer1
+            // 
+            this.movieContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.movieContainer1.Location = new System.Drawing.Point(6, 176);
+            this.movieContainer1.Movie = null;
+            this.movieContainer1.MovieList = null;
+            this.movieContainer1.Name = "movieContainer1";
+            this.movieContainer1.Size = new System.Drawing.Size(913, 375);
+            this.movieContainer1.TabIndex = 2;
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -764,6 +776,7 @@
         private System.Windows.Forms.Button btn_paste_new;
         private System.Windows.Forms.Button btn_p4_Go1_paste;
         private System.Windows.Forms.Label lbl_p4_status;
+        private System.Windows.Forms.Button button1;
     }
 }
 

+ 72 - 41
PicSo/Form1.cs

@@ -9,6 +9,7 @@ using System.Windows.Forms;
 using System.IO;
 using System.Threading;
 using System.Threading.Tasks;
+using AVSORTER;
 
 namespace PicSo
 {
@@ -157,12 +158,11 @@ namespace PicSo
             {
                 i++;
                 AVSORTER.IGetable getor = arzon.Clone() as AVSORTER.IGetable;
-                tasks[i]= new Task<List<AVSORTER.MovieBasic>>(() => {
+                tasks[i] = new Task<List<AVSORTER.MovieBasic>>(() =>
+                {
                     return getor.Query(item.SubItems[1].Text);
                 }, token);
 
-
-
                 tasks[i].ContinueWith<AVSORTER.Movie>((mbasics) =>
                 {
                     if (mbasics.Result.Count == 1)
@@ -180,7 +180,7 @@ namespace PicSo
             }
 
 
-        } 
+        }
 
 
 
@@ -216,21 +216,15 @@ namespace PicSo
 
         private void listView1_SelectedIndexChanged(object sender, EventArgs e)
         {
+            return;
+
             if (listView1.SelectedItems.Count == 1)
             {
                 if (listView1.SelectedItems[0].Tag != null)
                 {
-                    var si = (listView1.SelectedItems[0].Tag as AVSORTER.SearchItem);
+                    var si = (listView1.SelectedItems[0].Tag as ResultArzon);
+
 
-                    this.bc.ListMovieBasic = si.MovieBasicList;
-                    if (si.IsSelected)
-                    {
-                        this.bc.MovieB = si.SelectedMovieBasic;
-                    }
-                    else if (si.MovieBasicList != null && si.MovieBasicList.Count != 0)
-                    {
-                        this.bc.MovieB = si.MovieBasicList[0];
-                    }
                 }
 
             }
@@ -238,6 +232,11 @@ namespace PicSo
 
         private void btn_select_Click(object sender, EventArgs e)
         {
+
+            MessageBox.Show("不需要了");
+            return;
+
+
             if (listView1.SelectedItems.Count == 1)
             {
                 if (listView1.SelectedItems[0].Tag != null)
@@ -256,24 +255,15 @@ namespace PicSo
                 initFileProcessor();
                 foreach (ListViewItem item in listView1.Items)
                 {
-                    if ((item.Tag as AVSORTER.SearchItem).IsSelected == true)
-                    {
-                        if (item.Text != "No File")
-                        {
-                            AVSORTER.FileProcessor.GetInstance().MakeMove((item.Tag as AVSORTER.SearchItem).MovieDetail, item.Text);
-                            item.SubItems[2].Text = "移动成功!";
-                        }
-                        else
-                        {
-                            item.SubItems[2].Text = "未移动";
-                        }
-
-
 
+                    if (item.Text != "No File")
+                    {
+                        AVSORTER.FileProcessor.GetInstance().MakeMove((item.Tag as AVSORTER.ResultArzon).Movie, item.Text);
+                        item.SubItems[2].Text = "移动成功!";
                     }
                     else
                     {
-                        item.SubItems[2].Text = "未指定对应影片信息";
+                        item.SubItems[2].Text = "未移动";
                     }
 
                 }
@@ -366,7 +356,8 @@ namespace PicSo
         {
             if (this.listView1.SelectedItems.Count > 0)
             {
-                var d = (listView1.SelectedItems[0].Tag as AVSORTER.SearchItem).MovieDetail;
+                var d = (listView1.SelectedItems[0].Tag as ResultArzon).Movie;
+
                 if (d != null)
                 {
                     System.Diagnostics.Process.Start(d.CoverFile);
@@ -395,19 +386,34 @@ namespace PicSo
 
         private void listView1_DoubleClick(object sender, EventArgs e)
         {
-            if (this.listView1.SelectedItems.Count > 0)
-            {
-                var d = (listView1.SelectedItems[0].Tag as AVSORTER.SearchItem);
-                if (d.MovieDetail != null && d != null && !string.IsNullOrEmpty(d.MovieDetail.CoverFile))
+            try
+            { 
+
+
+                if (this.listView1.SelectedItems.Count > 0)
                 {
-                    System.Diagnostics.Process.Start(d.MovieDetail.CoverFile);
+                    var d = (listView1.SelectedItems[0].Tag as ResultArzon);
+
+                    Console.WriteLine(d.Movie);
+
+
+                    if (d.Movie != null && d != null && !string.IsNullOrEmpty(d.Movie.CoverFile))
+                    {
+                        System.Diagnostics.Process.Start(d.Movie.CoverFile);
+                    }
                 }
             }
+            catch (Exception ees)
+            {
+                MessageBox.Show(ees.Message);
+            }
         }
 
 
         private void btn_rebuild_Click(object sender, EventArgs e)
         {
+            MessageBox.Show("未实现");
+            return;
             this.btn_MoveFile.Enabled = false;
             initFileProcessor();
             foreach (ListViewItem item in listView1.Items)
@@ -467,10 +473,15 @@ namespace PicSo
         }
         private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
         {
+
+
             if (this.listBox1.SelectedItems.Count > 0)
             {
                 this.movieContainer1.Movie = (this.listBox1.SelectedItem as AVSORTER.Movie);
             }
+
+
+
         }
         #endregion
 
@@ -618,13 +629,13 @@ namespace PicSo
 
         void workerP4_ProgressChanged(object sender, ProgressChangedEventArgs e)
         {
-            
+
         }
         private void cmenu_p4_item_copy_Click(object sender, EventArgs e)
         {
-            if (lv_p4_result.SelectedItems.Count==1)
+            if (lv_p4_result.SelectedItems.Count == 1)
             {
-                var link=  lv_p4_result.SelectedItems[0].SubItems[2].Text;
+                var link = lv_p4_result.SelectedItems[0].SubItems[2].Text;
 
                 Clipboard.SetText(link);
 
@@ -643,17 +654,37 @@ namespace PicSo
             }
         }
         #endregion
+        SearchController currentSearchController;
+        private void button1_Click(object sender, EventArgs e)
+        {
 
+            List<string> l = new List<string>();
 
+            foreach (ListViewItem item in listView1.Items)
+            {
+                l.Add(item.SubItems[1].Text);
+            }
+            SearchController sc = new SearchController(arzon, l);
 
+            currentSearchController = sc;
 
+            sc.OnStatusChange += Sc_OnStatusChange;
 
+            sc.MainDo(1);
 
+        }
 
-
-
-
-
+        private void Sc_OnStatusChange(object sender, SearchController.StatusChangeEventArgs e)
+        {
+            foreach (ListViewItem item in listView1.Items)
+            {
+                if (item.SubItems[1].Text == e.Ra.Code)
+                {
+                    item.SubItems[2].Text = e.Ra.QStatus.ToString();
+                    item.Tag = e.Ra;
+                }
+            }
+        }
     }
 
 

+ 1 - 0
PicSo/PicSo.csproj

@@ -80,6 +80,7 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SearchController.cs" />
     <EmbeddedResource Include="BasicContainer.resx">
       <DependentUpon>BasicContainer.cs</DependentUpon>
     </EmbeddedResource>

+ 136 - 0
PicSo/SearchController.cs

@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using AVSORTER;
+using Gets;
+
+namespace PicSo
+{
+    internal class SearchController
+    {
+        private List<string> list1;
+
+        Arzon arzon;
+
+        public List<ResultArzon> Results = new List<ResultArzon>();
+
+        public SearchController(Arzon a, List<string> list)
+        {
+            list1 = list;
+            arzon = a;
+        }
+
+        public void MainDo(int threadCount)
+        {
+            int minWorker, minIOC;
+
+            ThreadPool.GetMinThreads(out minWorker, out minIOC);
+
+            ThreadPool.SetMaxThreads(minWorker, minIOC);
+
+            foreach (string item in list1)
+            {
+                ResultArzon ra = new ResultArzon { Code = item.ToString(), QStatus= QStatus.未开始 };
+
+                Results.Add(ra);
+                ThreadPool.QueueUserWorkItem(willdo,ra as object);
+            }
+            return;
+        }
+
+        void willdo(object fcode)
+        {
+            Console.WriteLine("start:" + Thread.CurrentThread.ManagedThreadId);
+
+            var ra = fcode as ResultArzon;
+            ra.QStatus = QStatus.查询中;
+            RaiseStatusChangeEvent(ra);
+
+            var mb_list =  code_2_mb_list(ra.Code);
+            ra.QStatus = QStatus.查询完成;
+            RaiseStatusChangeEvent(ra);
+
+            if (mb_list.Count<4)
+            {
+                ra.QStatus = QStatus.获取信息中;
+                RaiseStatusChangeEvent(ra);
+                foreach (MovieBasic item in mb_list)
+                {
+                    var m = mb_2_m(item);
+                    if (m.AVCode == ra.Code)
+                    {
+                        ra.QStatus = QStatus.获取信息完成;
+                        RaiseStatusChangeEvent(ra);
+                        ra.Movie = m;
+                        break;
+                    }
+                }
+                ra.QStatus = QStatus.下载封面中;
+                RaiseStatusChangeEvent(ra);
+                if (m_cover(ra.Movie))
+                {
+                    ra.QStatus = QStatus.封面下载完成;
+                    RaiseStatusChangeEvent(ra);
+                }
+                else
+                {
+                    ra.QStatus = QStatus.出错;
+                    RaiseStatusChangeEvent(ra);
+                }  
+            }
+            else
+            {
+                ra.QStatus = QStatus.查询完成无匹配;
+                RaiseStatusChangeEvent(ra);
+                throw new ArgumentException("code可能不对,有过多的查询结果");
+            }
+            ra.QStatus = QStatus.准备好移动文件;
+            RaiseStatusChangeEvent(ra);
+            Console.WriteLine("end:" + Thread.CurrentThread.ManagedThreadId);
+        }
+
+        List<MovieBasic> code_2_mb_list(string fcode)
+        {
+            var new_a = this.arzon.Clone() as Arzon;
+            return new_a.Query(fcode);
+        }
+
+        Movie mb_2_m(MovieBasic mb)
+        {
+            var new_a = this.arzon.Clone() as Arzon;
+            return new_a.GetMovie(mb);
+        }
+        bool m_cover(Movie m)
+        {
+            var new_a = this.arzon.Clone() as Arzon;
+            return new_a.GetCover(m);
+        }
+
+
+        public class StatusChangeEventArgs : EventArgs
+        {
+ 
+            public ResultArzon Ra { get; set; }
+            public StatusChangeEventArgs(ResultArzon ra)
+            {
+                this.Ra = ra;
+            }
+        }
+        public delegate void StatusChangeHandler(object sender, StatusChangeEventArgs e);
+
+        public event StatusChangeHandler OnStatusChange;
+
+        private void RaiseStatusChangeEvent(ResultArzon ra)
+        {
+            if (OnStatusChange!=null)
+            {
+                OnStatusChange(this, new StatusChangeEventArgs(ra));
+            }
+
+        }
+    }
+
+
+}

BIN
PicSo/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache