Переглянути джерело

jxing 更改id為string類型

garrett 4 роки тому
батько
коміт
3a59a9dad9

+ 1 - 1
Config/test/Client.exe.config

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <appSettings>
-    <add key="IP" value="192.168.20.225"/>
+    <add key="IP" value="192.168.0.3"/>
     <add key="Port" value="6666"/>
     <add key="DownloadFileDir" value="E:\\"/>
     <add key="MaxTaskCount" value="3"/>

+ 4 - 2
Dispatcher/Client/Client.csproj

@@ -91,7 +91,7 @@
     <Reference Include="System.IO.Compression.FileSystem" />
     <Reference Include="System.Management" />
     <Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
+      <HintPath>..\..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath>
     </Reference>
     <Reference Include="System.Numerics" />
     <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -124,7 +124,9 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
-    <None Include="packages.config" />
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Content Include="Readme.txt" />

+ 1 - 1
Dispatcher/Client/ClientApp.cs

@@ -61,12 +61,12 @@ namespace Client
         {
             while (true)
             {
+                Thread.Sleep(interval * 1000);
                 if (!TaskNettyClient.isConnected)
                 {
                     Console.WriteLine(DateTime.Now + ": reconnecting....");
                     Restart();
                 }
-                Thread.Sleep(interval * 1000);
             }
         }
 

+ 1 - 1
Dispatcher/Client/MessageHandler.cs

@@ -1,5 +1,5 @@
 using NettyClient;
-using Message = Google.Protobuf.WellKnownTypes.Message;
+using Message = Cn.Sagacloud.Proto.Message;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;

+ 1 - 1
Dispatcher/Client/TaskHandler.cs

@@ -109,7 +109,7 @@ namespace Client
                 catch (Exception ex){
                     Console.WriteLine(ex.StackTrace);
                 }
-                Thread.Sleep(1000);
+                Thread.Sleep(3*1000);
                 
             }
         }

+ 2 - 2
Dispatcher/Client/app.config

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <appSettings>
-    <!--add key="IP" value="192.168.20.225" /-->
-    <add key="IP" value="47.94.89.44" />
+    <add key="IP" value="192.168.0.3" />
+    <!--<add key="IP" value="47.94.89.44" />-->
     <add key="Port" value="6666" />
     <add key="DownloadFileDir" value="E:\\" />
     <add key="MaxTaskCount" value="3" />

+ 1 - 1
Dispatcher/Client/packages.config

@@ -36,7 +36,7 @@
   <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
   <package id="System.Linq" version="4.3.0" targetFramework="net461" />
   <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
-  <package id="System.Memory" version="4.5.1" targetFramework="net461" />
+  <package id="System.Memory" version="4.5.2" targetFramework="net461" />
   <package id="System.Net.Http" version="4.3.0" targetFramework="net461" />
   <package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
   <package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />

+ 10 - 5
Dispatcher/NettyClient/NettyClient.csproj

@@ -49,8 +49,8 @@
     <Reference Include="DotNetty.Transport, Version=0.6.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
       <HintPath>..\packages\DotNetty.Transport.0.6.0\lib\net45\DotNetty.Transport.dll</HintPath>
     </Reference>
-    <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
-      <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
+    <Reference Include="Google.Protobuf, Version=3.8.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll</HintPath>
     </Reference>
     <Reference Include="Microsoft.Extensions.Configuration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll</HintPath>
@@ -79,6 +79,9 @@
     <Reference Include="Microsoft.Extensions.Primitives, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.Extensions.Primitives.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll</HintPath>
     </Reference>
+    <Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
@@ -97,7 +100,7 @@
     </Reference>
     <Reference Include="System.IO.Compression.FileSystem" />
     <Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
+      <HintPath>..\..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath>
     </Reference>
     <Reference Include="System.Numerics" />
     <Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -118,7 +121,6 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ClientWrapper.cs" />
-    <None Include="proto\MessageProto.cs-bak" />
     <Compile Include="proto\MessageProto.cs" />
     <Compile Include="proto\MessageUtil.cs" />
     <Compile Include="TaskNettyClient.cs" />
@@ -126,8 +128,11 @@
     <Compile Include="SimpleMessageHandler.cs" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="app.config" />
+    <None Include="app.config">
+      <SubType>Designer</SubType>
+    </None>
     <None Include="packages.config" />
+    <None Include="proto\MessageProto.cs-bak" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 1 - 1
Dispatcher/NettyClient/SimpleMessageHandler.cs

@@ -2,7 +2,7 @@
 using System;
 using System.Collections.Concurrent;
 using System.Windows.Forms;
-using Message = Google.Protobuf.WellKnownTypes.Message;
+using Message = Cn.Sagacloud.Proto.Message;
 
 namespace NettyClient
 {

+ 1 - 1
Dispatcher/NettyClient/TaskNettyClient.cs

@@ -7,7 +7,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using DotNetty.Codecs.Protobuf;
-using Message = Google.Protobuf.WellKnownTypes.Message;
+using Message = Cn.Sagacloud.Proto.Message;
 
 namespace NettyClient
 {

+ 1 - 1
Dispatcher/NettyClient/app.config

@@ -20,7 +20,7 @@
       </dependentAssembly>
       <dependentAssembly>
         <assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-3.4.0.0" newVersion="3.4.0.0" />
+        <bindingRedirect oldVersion="0.0.0.0-3.8.0.0" newVersion="3.8.0.0" />
       </dependentAssembly>
       <dependentAssembly>
         <assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />

+ 2 - 2
Dispatcher/NettyClient/packages.config

@@ -5,7 +5,7 @@
   <package id="DotNetty.Codecs.Protobuf" version="0.6.0" targetFramework="net461" />
   <package id="DotNetty.Common" version="0.6.0" targetFramework="net461" />
   <package id="DotNetty.Transport" version="0.6.0" targetFramework="net461" />
-  <package id="Google.Protobuf" version="3.2.0" targetFramework="net461" />
+  <package id="Google.Protobuf" version="3.8.0" targetFramework="net461" />
   <package id="Microsoft.Extensions.Configuration" version="2.2.0" targetFramework="net461" />
   <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.2.0" targetFramework="net461" />
   <package id="Microsoft.Extensions.Configuration.Binder" version="2.2.0" targetFramework="net461" />
@@ -39,7 +39,7 @@
   <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
   <package id="System.Linq" version="4.3.0" targetFramework="net461" />
   <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
-  <package id="System.Memory" version="4.5.1" targetFramework="net461" />
+  <package id="System.Memory" version="4.5.2" targetFramework="net461" />
   <package id="System.Net.Http" version="4.3.0" targetFramework="net461" />
   <package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
   <package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />

+ 0 - 224
Dispatcher/NettyClient/proto/MessageProto - 复制.cs

@@ -1,224 +0,0 @@
-// <auto-generated>
-//     Generated by the protocol buffer compiler.  DO NOT EDIT!
-//     source: MessageProto.proto
-// </auto-generated>
-#pragma warning disable 1591, 0612, 3021
-#region Designer generated code
-using pb = Google.Protobuf;
-using pbr = Google.Protobuf.Reflection;
-namespace Cn.Sagacloud.Proto
-{
-
-    /// <summary>Holder for reflection information generated from MessageProto.proto</summary>
-    public static partial class MessageProtoReflection {
-
-    #region Descriptor
-    /// <summary>File descriptor for MessageProto.proto</summary>
-    public static pbr.FileDescriptor Descriptor {
-      get { return descriptor; }
-    }
-    private static pbr.FileDescriptor descriptor;
-
-    static MessageProtoReflection() {
-      byte[] descriptorData = System.Convert.FromBase64String(
-          string.Concat(
-            "ChJNZXNzYWdlUHJvdG8ucHJvdG8SEmNuLnNhZ2FjbG91ZC5wcm90byI3CgdN",
-            "ZXNzYWdlEgsKA2NtZBgBIAEoCRIOCgZ0YXNrSWQYAiABKAUSDwoHY29udGVu",
-            "dBgDIAEoCUIQQgxNZXNzYWdlUHJvdG9IAWIGcHJvdG8z"));
-      descriptor = pbr.FileDescriptor.FromGeneratedCode(descriptorData,
-          new pbr.FileDescriptor[] { },
-          new pbr.GeneratedClrTypeInfo(null, new pbr.GeneratedClrTypeInfo[] {
-            new pbr.GeneratedClrTypeInfo(typeof(Cn.Sagacloud.Proto.Message), Cn.Sagacloud.Proto.Message.Parser, new[]{ "Cmd", "TaskId", "Content" }, null, null, null)
-          }));
-    }
-    #endregion
-
-  }
-  #region Messages
-  public sealed partial class Message : pb.IMessage<Message> {
-    private static readonly pb.MessageParser<Message> _parser = new pb.MessageParser<Message>(() => new Message());
-     private pb.UnknownFieldSet _unknownFields;
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public static pb.MessageParser<Message> Parser { get { return _parser; } }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public static pbr.MessageDescriptor Descriptor {
-      get { return Cn.Sagacloud.Proto.MessageProtoReflection.Descriptor.MessageTypes[0]; }
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    pbr.MessageDescriptor pb.IMessage.Descriptor {
-      get { return Descriptor; }
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public Message() {
-      OnConstruction();
-    }
-
-    partial void OnConstruction();
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public Message(Message other) : this() {
-      cmd_ = other.cmd_;
-      taskId_ = other.taskId_;
-      content_ = other.content_;
-         _unknownFields = pb.UnknownFieldSet.Clone(other._unknownFields);
-        }
-
-        [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public Message Clone() {
-      return new Message(this);
-    }
-
-    /// <summary>Field number for the "cmd" field.</summary>
-    public const int CmdFieldNumber = 1;
-    private string cmd_ = "";
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public string Cmd {
-      get { return cmd_; }
-      set {
-        cmd_ = pb.ProtoPreconditions.CheckNotNull(value, "value");
-      }
-    }
-
-    /// <summary>Field number for the "taskId" field.</summary>
-    public const int TaskIdFieldNumber = 2;
-    private int taskId_;
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public int TaskId {
-      get { return taskId_; }
-      set {
-        taskId_ = value;
-      }
-    }
-
-    /// <summary>Field number for the "content" field.</summary>
-    public const int ContentFieldNumber = 3;
-    private string content_ = "";
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public string Content {
-      get { return content_; }
-      set {
-        content_ = pb.ProtoPreconditions.CheckNotNull(value, "value");
-      }
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public override bool Equals(object other) {
-      return Equals(other as Message);
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public bool Equals(Message other) {
-      if (ReferenceEquals(other, null)) {
-        return false;
-      }
-      if (ReferenceEquals(other, this)) {
-        return true;
-      }
-      if (Cmd != other.Cmd) return false;
-      if (TaskId != other.TaskId) return false;
-      if (Content != other.Content) return false;
-        return Equals(_unknownFields, other._unknownFields);
-            return true;
-    }
-
-        [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public override int GetHashCode() {
-      int hash = 1;
-      if (Cmd.Length != 0) hash ^= Cmd.GetHashCode();
-      if (TaskId != 0) hash ^= TaskId.GetHashCode();
-      if (Content.Length != 0) hash ^= Content.GetHashCode();
-            if (_unknownFields != null) {hash ^= _unknownFields.GetHashCode();}
-            return hash;
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public override string ToString() {
-      return pb.JsonFormatter.ToDiagnosticString(this);
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public void WriteTo(pb.CodedOutputStream output) {
-      if (Cmd.Length != 0) {
-        output.WriteRawTag(10);
-        output.WriteString(Cmd);
-      }
-      if (TaskId != 0) {
-        output.WriteRawTag(16);
-        output.WriteInt32(TaskId);
-      }
-      if (Content.Length != 0) {
-        output.WriteRawTag(26);
-        output.WriteString(Content);
-      }
-
-            if (_unknownFields != null){_unknownFields.WriteTo(output);}
-        }
-
-        [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public int CalculateSize() {
-      int size = 0;
-      if (Cmd.Length != 0) {
-        size += 1 + pb.CodedOutputStream.ComputeStringSize(Cmd);
-      }
-      if (TaskId != 0) {
-        size += 1 + pb.CodedOutputStream.ComputeInt32Size(TaskId);
-      }
-      if (Content.Length != 0) {
-        size += 1 + pb.CodedOutputStream.ComputeStringSize(Content);
-      }
-
-             if (_unknownFields != null){size += _unknownFields.CalculateSize();}
-            return size;
-    }
-
-    [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public void MergeFrom(Message other) {
-      if (other == null) {
-        return;
-      }
-      if (other.Cmd.Length != 0) {
-        Cmd = other.Cmd;
-      }
-      if (other.TaskId != 0) {
-        TaskId = other.TaskId;
-      }
-      if (other.Content.Length != 0) {
-        Content = other.Content;
-      }
-        _unknownFields = pb.UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
-        }
-
-        [System.Diagnostics.DebuggerNonUserCodeAttribute]
-    public void MergeFrom(pb.CodedInputStream input) {
-      uint tag;
-      while ((tag = input.ReadTag()) != 0) {
-        switch(tag) {
-          default:
-_unknownFields = Google.Protobuf.UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
-                        break;
-          case 10: {
-            Cmd = input.ReadString();
-            break;
-          }
-          case 16: {
-            TaskId = input.ReadInt32();
-            break;
-          }
-          case 26: {
-            Content = input.ReadString();
-            break;
-          }
-        }
-      }
-    }
-
-  }
-
-  #endregion
-
-}
-
-#endregion Designer generated code

+ 12 - 12
Dispatcher/NettyClient/proto/MessageProto.cs

@@ -1,6 +1,6 @@
 // <auto-generated>
 //     Generated by the protocol buffer compiler.  DO NOT EDIT!
-//     source: MessageProto-cs.proto
+//     source: MessageProto.proto
 // </auto-generated>
 #pragma warning disable 1591, 0612, 3021
 #region Designer generated code
@@ -9,28 +9,28 @@ using pb = global::Google.Protobuf;
 using pbc = global::Google.Protobuf.Collections;
 using pbr = global::Google.Protobuf.Reflection;
 using scg = global::System.Collections.Generic;
-namespace NettyClient.Proto {
+namespace Cn.Sagacloud.Proto {
 
-  /// <summary>Holder for reflection information generated from MessageProto-cs.proto</summary>
-  public static partial class MessageProtoCsReflection {
+  /// <summary>Holder for reflection information generated from MessageProto.proto</summary>
+  public static partial class MessageProtoReflection {
 
     #region Descriptor
-    /// <summary>File descriptor for MessageProto-cs.proto</summary>
+    /// <summary>File descriptor for MessageProto.proto</summary>
     public static pbr::FileDescriptor Descriptor {
       get { return descriptor; }
     }
     private static pbr::FileDescriptor descriptor;
 
-    static MessageProtoCsReflection() {
+    static MessageProtoReflection() {
       byte[] descriptorData = global::System.Convert.FromBase64String(
           string.Concat(
-            "ChVNZXNzYWdlUHJvdG8tY3MucHJvdG8SEU5ldHR5Q2xpZW50LnByb3RvIjcK",
-            "B01lc3NhZ2USCwoDY21kGAEgASgJEg4KBnRhc2tJZBgCIAEoCRIPCgdjb250",
-            "ZW50GAMgASgJQhNCD01lc3NhZ2VQcm90b1N0ckgBYgZwcm90bzM="));
+            "ChJNZXNzYWdlUHJvdG8ucHJvdG8SEmNuLnNhZ2FjbG91ZC5wcm90byI3CgdN",
+            "ZXNzYWdlEgsKA2NtZBgBIAEoCRIOCgZ0YXNrSWQYAiABKAkSDwoHY29udGVu",
+            "dBgDIAEoCUITQg9NZXNzYWdlUHJvdG9TdHJIAWIGcHJvdG8z"));
       descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
           new pbr::FileDescriptor[] { },
-          new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
-            new pbr::GeneratedClrTypeInfo(typeof(global::NettyClient.Proto.Message), global::NettyClient.Proto.Message.Parser, new[]{ "Cmd", "TaskId", "Content" }, null, null, null, null)
+          new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
+            new pbr::GeneratedClrTypeInfo(typeof(global::Cn.Sagacloud.Proto.Message), global::Cn.Sagacloud.Proto.Message.Parser, new[]{ "Cmd", "TaskId", "Content" }, null, null, null)
           }));
     }
     #endregion
@@ -45,7 +45,7 @@ namespace NettyClient.Proto {
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
     public static pbr::MessageDescriptor Descriptor {
-      get { return global::NettyClient.Proto.MessageProtoCsReflection.Descriptor.MessageTypes[0]; }
+      get { return global::Cn.Sagacloud.Proto.MessageProtoReflection.Descriptor.MessageTypes[0]; }
     }
 
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute]

+ 3 - 2
Dispatcher/NettyClient/proto/MessageUtil.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Message = Cn.Sagacloud.Proto.Message;
 
 namespace NettyClient.proto
 {
@@ -16,9 +17,9 @@ namespace NettyClient.proto
         //    return msg;
         //}
 
-        public static Google.Protobuf.WellKnownTypes.Message generateMessageStr(string cmd, string taskId, string content)
+        public static Message generateMessageStr(string cmd, string taskId, string content)
         {
-            Google.Protobuf.WellKnownTypes.Message msg = new Google.Protobuf.WellKnownTypes.Message();
+            Message msg = new Message();
             msg.Cmd = cmd;
             msg.TaskId = taskId;
             msg.Content = content;

+ 5 - 8
Dispatcher/TaskDatabase/Mappings/TaskModel.hbm.xml

@@ -7,10 +7,10 @@
   <class name="TaskModel" table="task" entity-name="TaskModel">
     <id name="Tid">
       <!--<generator class="guid" />-->
-      <generator class="native" />
+      <generator class="identity" />
       <!--  <generator class="native" />主键自增。使用数据库自带的生成器 -->
     </id>
-    <property name="Id" />
+    <property name="Id" column="id" type="string"/>
     <property name="Task_name"/>
     <property name="Task_cmd" update="false" />
     <property name="Task_param" update="false"/>
@@ -25,15 +25,12 @@
   </class>
 
   <class name="DownloadTaskModel" table="download">
-    <id name="Tid">
+    <id name="Id" column="id">
       <!--<generator class="guid" />-->
-      <generator class="native" />
+      <generator class="identity" />
       <!--  <generator class="native" />主键自增。使用数据库自带的生成器 -->
     </id>
-    <property name="Id" />
-    <property name="Task_id" >
-      <!--<many-to-one class="DownloadTaskModel" column="Task_Id"/>-->
-    </property>
+    <property name="Task_id" />
     <property name="Task_url" />
     <property name="Task_md5" />
     <property name="Local_dir" />

+ 1 - 1
Dispatcher/TaskDatabase/Model/DownloadTaskModel.cs

@@ -7,7 +7,7 @@ namespace TaskDatabase.Model
     {
         //public virtual int Tid { get; set; }
         //[JsonProperty(PropertyName = "id")]
-        //public virtual int Id { get; set; }
+        public virtual int Id { get; set; }
         [JsonProperty(PropertyName = "taskId")]
         public virtual string Task_id { get; set; }
         [JsonProperty(PropertyName = "httpUrl")]

+ 1 - 1
Dispatcher/TaskDatabase/Model/TaskModel.cs

@@ -9,7 +9,7 @@ namespace TaskDatabase.Model
 {
     public class TaskModel
     {
-        //public virtual int Tid { get; set; }
+        public virtual int Tid { get; set; }
         [JsonProperty(PropertyName = "id")]
         public virtual string Id { get; set; }
         [JsonProperty(PropertyName = "name")]

+ 2 - 1
Dispatcher/TaskDatabase/TaskDatabase.csproj

@@ -41,7 +41,7 @@
       <HintPath>..\..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
-      <HintPath>..\packages\NHibernate.5.2.0\lib\net461\NHibernate.dll</HintPath>
+      <HintPath>..\..\packages\NHibernate.5.2.7\lib\net461\NHibernate.dll</HintPath>
     </Reference>
     <Reference Include="Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
       <HintPath>..\packages\Remotion.Linq.2.2.0\lib\net45\Remotion.Linq.dll</HintPath>
@@ -85,6 +85,7 @@
   <ItemGroup>
     <Content Include="hibernate.cfg.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+      <SubType>Designer</SubType>
     </Content>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 3 - 2
Dispatcher/TaskDatabase/TaskService.cs

@@ -25,7 +25,7 @@ namespace TaskDatabase
                         try
                         {
                             session.Save(task);
-                            if(task.DownloadTaskModelList != null)
+                            if (task.DownloadTaskModelList != null)
                             {
                                 foreach(var download in task.DownloadTaskModelList)
                                 {
@@ -34,7 +34,8 @@ namespace TaskDatabase
                             }
                             transaction.Commit();
                         }
-                        catch {
+                        catch (Exception ex){
+                            Console.WriteLine("write:" + ex.Message);
                             if (transaction != null && transaction.IsActive)
                             {
                                 transaction.Rollback();

+ 1 - 1
Dispatcher/TaskDatabase/hibernate.cfg.xml

@@ -4,7 +4,7 @@
     <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
     <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
     <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
-    <property name="connection.connection_string">Server=localhost;Database=worker;User ID=root;Password=123456</property>
+    <property name="connection.connection_string">Server=127.0.0.1;Database=worker_str;User ID=root;Password=123456</property>
     <property name="show_sql">false</property>
     <mapping assembly="TaskDatabase"/>
   </session-factory>

+ 1 - 1
Dispatcher/TaskDatabase/packages.config

@@ -3,7 +3,7 @@
   <package id="Antlr3.Runtime" version="3.5.1" targetFramework="net461" />
   <package id="Iesi.Collections" version="4.0.4" targetFramework="net461" />
   <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
-  <package id="NHibernate" version="5.2.0" targetFramework="net461" />
+  <package id="NHibernate" version="5.2.7" targetFramework="net461" />
   <package id="Remotion.Linq" version="2.2.0" targetFramework="net461" />
   <package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net461" />
 </packages>