private NodeServerDataModel SetData(string packageName, ServerStatusType status, string error, string url, ServerType serverType)
        {
            NodeServerDataModel node = null;

            if (_packages.ContainsKey(packageName))
            {
                node = _packages[packageName];
            }
            else
            {
                node = new NodeServerDataModel();
            }
            node.PackageName = packageName;
            node.Status      = status;
            node.Url         = url;
            node.Error       = error;
            node.ServerType  = serverType;
            return(node);
        }
        public void StartNode(string packageName, ServerType serverType = ServerType.Server)
        {
            //如果进程没有关闭,就强行关闭
            string processName       = string.Format("{0}.{1}", Config.MicroService, packageName);
            string destPath          = string.Format(@"{0}\{1}\", serverType == ServerType.Server ? _apiDirectory.TrimEnd('\\') : _timingDirectory.TrimEnd('\\'), packageName).TrimEnd('\\');
            string entrydestfile     = string.Format(@"{0}\{1}.exe", destPath.TrimEnd('\\'), processName);
            string entrydestConfig   = string.Format(@"{0}.config", entrydestfile);
            string entry             = string.Format(@"{0}\{1}", _commonDirectory, _serviceEntry);
            string entryConfig       = string.Format(@"{0}.config", entry);
            string url               = string.Format("{0}/{1}/", _host.TrimEnd('/'), packageName);
            NodeServerDataModel node = null;

            try
            {
                if (!Directory.Exists(destPath))
                {
                    Directory.CreateDirectory(destPath);
                }
                if (!File.Exists(entrydestfile))
                {
                    File.Copy(entry, entrydestfile);
                }
                if (!File.Exists(entrydestConfig))
                {
                    File.Copy(entryConfig, entrydestConfig);
                }

                #region  制dll
                //DirectoryInfo common = new DirectoryInfo(_commonDirectory);
                //if (!common.Exists) common.Create();
                //var commondllfiles = common.GetFiles("*.dll", SearchOption.AllDirectories);
                //DirectoryInfo apidirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);

                //foreach (var f in commondllfiles)
                //{
                //    string destFile = string.Format("{0}\\{1}", destPath, f.Name);
                //    if (!File.Exists(destFile)) f.CopyTo(destFile);
                //    else
                //    {
                //        FileInfo destVersion = new FileInfo(destFile);
                //        if (f.LastWriteTime > destVersion.LastWriteTime) f.CopyTo(destFile, true);
                //    }
                //}
                #endregion

                #region 启动进程
                Process p = Process.GetProcessesByName(processName).FirstOrDefault();
                if (p == null)
                {
                    p = new Process();
                    ProcessStartInfo ps = new ProcessStartInfo();
                    ps.CreateNoWindow  = !DisplayShell;
                    ps.FileName        = entrydestfile;
                    ps.UseShellExecute = false;
                    if (DisplayShell)
                    {
                        ps.WindowStyle = ProcessWindowStyle.Normal;
                    }
                    else
                    {
                        ps.WindowStyle = ProcessWindowStyle.Hidden;
                    }
                    string args = string.Format("-h {0} -c {1} ", url, _commonDirectory);
                    ps.Arguments          = args;
                    p.ErrorDataReceived  += P_ErrorDataReceived;
                    p.Exited             += P_Exited;
                    p.StartInfo           = ps;
                    p.EnableRaisingEvents = true;
                    p.Start();
                }
                //p.BeginErrorReadLine();
                node = SetData(packageName, ServerStatusType.Started, null, url, serverType);

                _processes[packageName] = p;
                #endregion
            }
            catch (Exception ex)
            {
                node = SetData(packageName, ServerStatusType.Error, ex.Message, url, serverType);
            }

            _packages[packageName] = node;
        }