Esempio n. 1
0
        protected override void AddProcess(Message message)
        {
            if (message != null)
            {
                String[] dataArray = message.Text.Split(';');
                int      processID;

                if (dataArray.Count() >= 2 && Int32.TryParse(dataArray[0], out processID))
                {
                    ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID);

                    if (process == null)
                    {
                        process = new ProcessPrototype(processID, dataArray[1]);

                        Application.Current.Dispatcher.BeginInvoke(
                            DispatcherPriority.Background,
                            new Action(() =>
                        {
                            ProcessCollection.Add(process);
                        }));

                        Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_PROCESS, process.ID.ToString()));
                    }
                }
            }
        }
Esempio n. 2
0
        protected override void RemoveProcess(Message message)
        {
            if (message != null)
            {
                String data = message.Text;
                int    processID;

                if (Int32.TryParse(data, out processID))
                {
                    ProcessPrototype process = ProcessCollection.FirstOrDefault(x => x.ID == processID);

                    if (process != null)
                    {
                        Application.Current.Dispatcher.BeginInvoke(
                            DispatcherPriority.Background,
                            new Action(() =>
                        {
                            ProcessCollection.Remove(process);
                        }));
                    }

                    if (SelectedPrototype != null && SelectedPrototype.ID == processID)
                    {
                        SelectedPrototype = null;
                        RefreshProperties();
                    }
                }
            }
        }
Esempio n. 3
0
 private void CleanAllItems()
 {
     this.CurrentProcessTasks.RemoveElementsNoReturn(d => true, d => d.Remove());
     this.dataManager.CurrentConnectors.Clear();
     this.dataManager.DataCollections.Clear();
     ProcessCollection.RemoveElementsNoReturn(d => true, RemoveOperation);
 }
Esempio n. 4
0
        public IDataProcess GetOneInstance(string name, bool isAddToList = true, bool newOne = false,
                                           bool isAddUI = false)
        {
            if (newOne)
            {
                var process = PluginProvider.GetObjectByType <IDataProcess>(name);
                if (process != null)
                {
                    if (isAddToList)
                    {
                        ProcessCollection.Add(process);
                        process.SysDataManager = dataManager;

                        process.SysProcessManager = this;
                        var rc4 = process as AbstractProcessMethod;
                        if (rc4 != null)
                        {
                            rc4.MainPluginLocation = MainFrmUI.MainPluginLocation;
                            rc4.MainFrm            = MainFrmUI;
                        }
                        XLogSys.Print.Info("已经成功添加" + process.TypeName + "到当前列表");
                    }

                    if (isAddUI)
                    {
                        ControlExtended.UIInvoke(() => LoadProcessView(process));

                        ControlExtended.UIInvoke(() => ShowConfigUI(process));
                    }

                    return(process);
                }
            }
            return(ProcessCollection.Get(name, isAddToList));
        }
Esempio n. 5
0
 public void Release()
 {
     processDispatcher = null;
     serviceDispatcher = null;
     deviceManager     = null;
     processes         = null;
     services          = null;
 }
Esempio n. 6
0
		public NDebugger()
		{
			processes   = new ProcessCollection(this);
			breakpoints = new BreakpointCollection(this);
			
			if (ApartmentState.STA == System.Threading.Thread.CurrentThread.GetApartmentState()) {
				mta2sta.CallMethod = CallMethod.HiddenFormWithTimeout;
			} else {
				mta2sta.CallMethod = CallMethod.DirectCall;
			}
		}
Esempio n. 7
0
        private void SetCurrentTask(ProcessTask task)
        {
            var process = ProcessCollection.FirstOrDefault(d => d.Name == task.Name);

            if (process == null)
            {
                return;
            }
            var configDocument = (process as IDictionarySerializable).DictSerialize();

            task.ProcessToDo = configDocument;
            XLogSys.Print.Info("已经成功覆盖任务");
        }
Esempio n. 8
0
        bool Terminated(Process p, ProcessCollection infos, bool wait = false)
        {
            Exception ex = null;

            try {
                if (!p.HasExited && !wait)
                {
                    return(false);
                }
            } catch {
                if (!wait)
                {
                    return(false);
                }
            }

            p.WaitForExit();

            ProcessInfo info;

            lock (infos) {
                if (!infos.Contains(p))
                {
                    return(true);
                }
                info = infos[p];
                infos.Remove(info);
            }

            if (WCF)
            {
            }

            if ((p.ExitCode == 0 || (WCF && (p.ExitCode == 3 || p.ExitCode == 4))) && File.Exists(info.File) && File.GetLastWriteTimeUtc(info.File) > info.StartTime)
            {
                if (Clean)
                {
                    CleanXmlTypeDefinitions(info.File);
                }
                RemovePortInProxyUrl(info.File, info.Url);
                Log.LogMessage(MessageImportance.High, "Generated proxy class for {0}", new Uri(info.Url).AbsolutePath);
            }
            else
            {
                var cmd = p.StandardOutput.ReadToEnd();
                Log.LogError("Error generating proxy for {0}: {1} {2}; {3}", new Uri(info.Url).AbsolutePath, WSE ? "wsewsdl3.exe" : (WCF ? "scvutil.exe" : "wsdl.exe"), info.Args, cmd.Replace("\n", ", ").Replace("\r", ""));
                Log.LogCommandLine(cmd);
            }
            return(true);
        }
Esempio n. 9
0
        private void OnProcessEnum(string rsp)
        {
            var list = JsonConvert.DeserializeObject <List <WinProcessModel> >(rsp);

            if (ProcessCollection != null)
            {
                ProcessCollection.Clear();
                foreach (var obj in list)
                {
                    var process = Tuple.Create <uint, string>(obj.ProcessId, obj.Name);
                    ProcessCollection.Add(process);
                }
            }
        }
Esempio n. 10
0
 private void OnProcessEnum(CommandMessageRsp rsp)
 {
     if (rsp.RspType == CommandMessageRsp.StringDataType)
     {
         var list = JsonConvert.DeserializeObject <List <WinProcessModel> >(rsp.StringCommandRsp);
         if (ProcessCollection != null)
         {
             ProcessCollection.Clear();
             foreach (var obj in list)
             {
                 var process = Tuple.Create <uint, string>(obj.ProcessId, obj.Name);
                 ProcessCollection.Add(process);
             }
         }
     }
 }
Esempio n. 11
0
        public IDataProcess GetOneInstance(string name, bool isAddToList = true, bool newOne = false,
                                           bool isAddUI = false)
        {
            if (newOne)
            {
                var process = PluginProvider.GetObjectByType <IDataProcess>(name);
                if (process != null)
                {
                    if (isAddToList)
                    {
                        ;
                        process.SysDataManager = dataManager;

                        process.SysProcessManager = this;
                        var rc4 = process as AbstractProcessMethod;
                        if (rc4 != null)
                        {
                            rc4.MainPluginLocation = MainFrmUI.MainPluginLocation;
                            rc4.MainFrm            = MainFrmUI;
                        }
                        var names =
                            CurrentProcessCollections.Select(d => d.Name);
                        var count = names.Count(d => d.Contains(process.TypeName));
                        if (count > 0)
                        {
                            process.Name = process.TypeName + (count + 1);
                        }
                        CurrentProcessCollections.Add(process);
                        XLogSys.Print.Info(GlobalHelper.Get("key_319") + process.TypeName + GlobalHelper.Get("key_320"));
                    }

                    if (isAddUI)
                    {
                        ControlExtended.UIInvoke(() => LoadProcessView(process));
                    }

                    return(process);
                }
            }
            return(ProcessCollection.Get(name, isAddToList));
        }
Esempio n. 12
0
        public void doIt(int idx)
        {
            ConsoleSpinner load = new ConsoleSpinner();

            load.Delay = 350;

            try
            {
                string file2open = path + names[idx - 1];
                for (int i = 0; i < 8; i++)
                {
                    load.Turn("Loadin ", 6);
                }
                Console.WriteLine();

                ProcessCollection processes = null;
                string            xmlPath   = file2open;

                XmlSerializer serializer = new XmlSerializer(typeof(ProcessCollection));

                StreamReader reader = new StreamReader(xmlPath);
                processes = (ProcessCollection)serializer.Deserialize(reader);
                reader.Close();
                Diplay.PrintLine();
                for (int i = 0; i < processes.Process.Length; i++)
                {
                    Diplay.PrintRow(new string[] { processes.Process[i].Name, processes.Process[i].ID, processes.Process[i].Memory });
                    Diplay.PrintLine();
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                for (int i = 0; i < 8; i++)
                {
                    load.Turn("Loadin ", 7);
                }
                Console.WriteLine("Reason: No Id like that");
            }
        }
Esempio n. 13
0
        private void _connection_ConnectionStateChangedEventHandler(ConnectionStatuses status)
        {
            if (status == ConnectionStatuses.DISCONNECTED)
            {
                SelectedPrototype      = null;
                SelectedProcessToStart = null;

                Application.Current.Dispatcher.BeginInvoke(
                    DispatcherPriority.Background,
                    new Action(() =>
                {
                    ProcessCollection.Clear();
                    ProcessToStartCollection.Clear();
                    ProcessToStart      = "";
                    ProcessImage        = null;
                    _isImageTransfering = false;
                }));
            }

            ConnectionStatus = status;
            RefreshProperties();
        }
Esempio n. 14
0
        protected override void AddProcessIcon(Message message)
        {
            if (message != null)
            {
                int processID;

                if (Int32.TryParse(Utils.GetTextBetween(message.Text, ConnectionService.PROCESS_START_DELIMITER, ConnectionService.PROCESS_END_DELIMITER), out processID))
                {
                    String imageText = message.Text.Substring(0, message.Text.IndexOf(ConnectionService.PROCESS_START_DELIMITER));

                    Bitmap bitmap = Utils.Base64StringToBitmap(imageText);

                    if (bitmap != null)
                    {
                        ProcessPrototype prototype = null;

                        prototype = ProcessCollection.FirstOrDefault(x => x.ID == processID);

                        if (prototype == null)
                        {
                            prototype = ProcessToStartCollection.FirstOrDefault(x => x.ID == processID);
                        }

                        if (prototype != null)
                        {
                            ImageSource imageSource = Utils.BitmapToImageSource(bitmap);
                            bitmap.Dispose();

                            prototype.AddIcon(imageSource);
                        }

                        Connection.Send(Connection.Socket, new Message(MessageTypes.REQUEST_NEXT_ICON, prototype.ID.ToString()));
                    }
                }
            }
        }
Esempio n. 15
0
        public void Analysis_Abutment()
        {
            string ana_file = Path.Combine(Get_Project_Folder(), "Abutment_Analysis_Input.txt");

            string        kStr = "";
            List <string> list = new List <string>();
            int           i    = 0;


            list.Add("ASTRA FLOOR RCC T GIRDER BRIDGE DECK ANALYSIS");
            list.Add("UNIT METER MTON");
            list.Add("JOINT COORDINATES");

            List <JointNode> Joints   = new List <JointNode>();
            List <Member>    MemColls = new List <Member>();

            double L   = MyList.StringToDouble(txt_Ana_L.Text, 0.0);
            double og  = MyList.StringToDouble(txt_Ana_og.Text, 0.0);
            double inc = (L - og * 2) / 4.0;

            double ws = 2.0 - og;



            JointNode jn = new JointNode();

            jn.NodeNo = 1;
            jn.X      = 0.0;

            Joints.Add(jn);

            jn = new JointNode();

            jn.NodeNo = 2;
            jn.X      = og + og;

            Joints.Add(jn);

            jn        = new JointNode();
            jn.NodeNo = 3;
            jn.X      = og + ws;

            Joints.Add(jn);

            jn        = new JointNode();
            jn.NodeNo = 4;
            jn.X      = og + inc;

            Joints.Add(jn);

            jn        = new JointNode();
            jn.NodeNo = 5;
            jn.X      = og + 2 * inc;

            Joints.Add(jn);


            jn        = new JointNode();
            jn.NodeNo = 6;
            jn.X      = og + 3 * inc;

            Joints.Add(jn);


            jn        = new JointNode();
            jn.NodeNo = 7;
            jn.X      = L - (og + ws);

            Joints.Add(jn);

            jn        = new JointNode();
            jn.NodeNo = 8;
            jn.X      = og + 4 * inc;

            Joints.Add(jn);

            jn        = new JointNode();
            jn.NodeNo = 9;
            jn.X      = L;

            Joints.Add(jn);



            Member mbr = new Member();

            mbr.MemberNo  = 1;
            mbr.StartNode = Joints[0];
            mbr.EndNode   = Joints[1];

            MemColls.Add(mbr);
            for (i = 2; i < Joints.Count; i++)
            {
                mbr           = new Member();
                mbr.MemberNo  = i;
                mbr.StartNode = Joints[i - 1];
                mbr.EndNode   = Joints[i];
                MemColls.Add(mbr);
            }



            for (i = 0; i < Joints.Count; i++)
            {
                list.Add(Joints[i].ToString());
            }
            list.Add("MEMBER INCIDENCES");
            for (i = 0; i < MemColls.Count; i++)
            {
                list.Add(MemColls[i].ToString());
            }
            list.Add("SECTION PROPERTIES");

            ////list.Add("1 2 5 6 AX");
            ////list.Add(string.Format("1 2 6 7 PRIS AX 0.036212 IX 0.00001 IY 0.000697 IZ 0.001",
            //list.Add(string.Format("1 2 7 8 PRIS AX {0} IX 0.00001 IY {1} IZ 0.001",
            //    txt_smp_i_a_sup.Text,
            //    txt_smp_i_Ix_sup.Text
            //    ));

            //list.Add(string.Format("3 TO 6 PRIS AX {0} IX 0.00001 IY {1} IZ 0.001",
            //     txt_smp_i_a_mid.Text,
            //     txt_smp_i_ix_mid.Text
            //     ));


            list.Add(string.Format("MATERIAL CONSTANT"));
            list.Add(string.Format("E 2.85E6 ALL"));
            list.Add(string.Format("DENSITY CONCRETE ALL"));
            list.Add(string.Format("POISSON CONCRETE ALL"));
            list.Add(string.Format("SUPPORT"));
            //list.Add(string.Format("2 6   PINNED"));
            list.Add(string.Format("2 8 FIXED BUT FX MZ"));
            //list.Add(string.Format("99 100 101 102   FIXED BUT FX MZ"));



            //list.Add(string.Format("LOAD 1 DEAD LOAD"));
            //list.Add(string.Format("MEMBER LOAD"));
            //list.Add(string.Format("1 2 7 8 UNI GY -{0:f4}", MyList.StringToDouble(txt_Ana_DL_supp.Text, 0.0)/10.0));
            //list.Add(string.Format("3 TO 6 UNI GY -{0}", MyList.StringToDouble(txt_Ana_DL_mid.Text, 0.0)/10.0));

            //list.Add(string.Format("LOAD 2 SIDL"));
            //list.Add(string.Format("MEMBER LOAD"));
            //list.Add(string.Format("1 TO 8 UNI GY -{0}", MyList.StringToDouble(txt_Ana_SIDL.Text, 0.0) / 10.0));

            //list.Add(string.Format("LOAD 3 FPLL"));
            //list.Add(string.Format("MEMBER LOAD"));
            //list.Add(string.Format("1 TO 8 UNI GY -{0}", MyList.StringToDouble(txt_Ana_FPLL.Text, 0.0)/10.0));

            //list.Add(string.Format("PRINT SUPPORT REACTIONS"));
            //list.Add(string.Format("PERFORM ANALYSIS"));
            //list.Add(string.Format("FINISH"));


            File.WriteAllLines(ana_file, list.ToArray());

            MessageBox.Show("Input Data Created as " + ana_file, "ASTRA");

            #region Process
            try
            {
                #region Process
                //int i = 0;


                ProcessCollection pcol = new ProcessCollection();

                ProcessData pd = new ProcessData();

                string flPath = ana_file;
                iapp.Progress_Works.Clear();

                if (File.Exists(flPath))
                {
                    pd = new ProcessData();
                    pd.Process_File_Name = flPath;
                    pd.Process_Text      = "PROCESS ANALYSIS FOR " + Path.GetFileNameWithoutExtension(flPath).ToUpper();
                    pcol.Add(pd);
                    iapp.Progress_Works.Add("Reading Analysis Data from " + Path.GetFileNameWithoutExtension(flPath).ToUpper() + " (ANALYSIS_REP.TXT)");
                }


                i++;
                string ana_rep_file = Path.Combine(Path.GetDirectoryName(flPath), "ANALYSIS_REP");
                if (iapp.Show_and_Run_Process_List(pcol))
                {
                    BridgeMemberAnalysis DeadLoad_Analysis = new BridgeMemberAnalysis(iapp, ana_rep_file);
                }

                #endregion Process
            }
            catch (Exception ex) { }
            #endregion Process
        }
Esempio n. 16
0
 public frm_Process_List(ProcessCollection All_ProcessList, IApplication app)
 {
     InitializeComponent();
     ProcessList = All_ProcessList;
     iapp        = app;
 }
Esempio n. 17
0
 public frm_LS_Process(ProcessCollection All_ProcessList)
 {
     InitializeComponent();
     ProcessList = All_ProcessList;
 }
Esempio n. 18
0
        public override bool Execute()
        {
            if (System.Type.GetType("Mono.Runtime") != null)               // Don't execute under Mono.
            {
                Log.LogMessage(MessageImportance.High, "The GenerateWebProxies task doesn't run under Mono.");
                return(true);
            }
            if ((Files == null || (Urls == null && Sources == null)) && SourceProject == null)
            {
                return(true);
            }

            var tool = ToolExe;

            if (tool == null)
            {
                Log.LogError("GenerateWebProxies: Cannot find " + (WCF ? "svcutil.exe" : "wsdl.exe") + ", please install Windows SDK.");
            }


            var projTime = string.IsNullOrEmpty(Project) ? DateTime.MinValue : File.GetLastWriteTimeUtc(Project);

            DateTime[] sourceTimes = null;

            IisExpress.SSL = SSL;
            var iisport       = IisExpress.RandomPort;
            var useIisExpress = Urls == null;
            var newiis        = false;

            if (Urls == null || AutoRest || Swagger)
            {
                var site = Path.GetFullPath(SourceProject).Trim('\\');
                newiis = IisExpress.SiteFolder != site || !IisExpress.IsStarted;
                if (newiis)
                {
                    IisExpress.SiteFolder = site;
                }
            }

            if (!newiis)
            {
                iisport = IisExpress.Port.Value;
            }

            var ServerUrl = (SSL ? "https" : "http") + "://localhost:" + iisport.ToString() + "/";

            if (Urls == null)
            {
                if (!AutoRest && !Swagger)
                {
                    Sources = Sources ?? Directory.EnumerateFiles(SourceProject, WCF ? "*.svc" : "*.asmx", SearchOption.AllDirectories)
                              .Where(p => !(Exclude?.Any(x => x.ItemSpec == p) ?? false))
                              .Select(path => new TaskItem(path)).ToArray();

                    Urls = Sources.Select(src => new TaskItem(ServerUrl + src.ItemSpec.Substring(SourceProject.Length).Trim('\\', '/', ' ').Replace('\\', '/') /*+ (WCF ? "?wsdl" : "") */))
                           .ToArray();
                    var files = Sources.Select(src => new TaskItem(Path.ChangeExtension(src.ItemSpec.Substring(SourceProject.Length), (FileSuffix ?? Type.ToString()) + "." + Language.ToLower())))
                                .ToDictionary(src => src.ItemSpec);
                    if (Files == null)
                    {
                        Files = files.Values.ToArray();
                    }
                    else
                    {
                        var items = Files.ToDictionary(f => f.ItemSpec);
                        Files = files.Values.Select(f => items.ContainsKey(f.ItemSpec) ? items[f.ItemSpec] : f).ToArray();
                    }
                    var regex = new Regex(@"<%@ (?:WebService|ServiceHost).*?(?:CodeBehind|CodeFile)\s*=\s*(?:(?:""(?<code>[^""]*)"")|(?:'(?<code>[^']*)')).*?%>");
                    sourceTimes = Sources.Select(src => {                     // get times of svc or asmx C# source files
                        var sourceInfo = new FileInfo(src.ItemSpec);
                        if (sourceInfo.Exists)
                        {
                            var m = regex.Match(File.ReadAllText(src.ItemSpec));
                            var t = sourceInfo.LastWriteTimeUtc;
                            if (m.Success)
                            {
                                var codeInfo = new FileInfo(Path.Combine(Path.GetDirectoryName(src.ItemSpec), m.Groups["code"].Value));
                                var codet    = codeInfo.Exists ? codeInfo.LastWriteTimeUtc : DateTime.MinValue;
                                return(codet > t ? codet : t);
                            }
                        }
                        return(DateTime.MinValue);
                    }).ToArray();
                }
            }
            var output    = new List <TaskItem>();
            var processes = new ProcessCollection();
            var startTime = DateTime.UtcNow;

            var wait = new ManualResetEvent(false);

            var iisstarted   = false;
            var anyprocesses = false;

            System.Net.ServicePointManager.DefaultConnectionLimit = 9999;

            var serverError = false;

            if (!AutoRest && !Swagger)
            {
                System.Threading.Tasks.Parallel.For(0, Urls.Length, i => {
                    //for (int i = 0; i < Urls.Length; i++) {
                    try {
                        var meta = Files[i].GetMetadata(Meta);
                        if (!string.IsNullOrEmpty(Meta) && !string.IsNullOrEmpty(meta) && meta != "false")
                        {
                            return;
                        }

                        var url  = Urls[i].ItemSpec;
                        var file = Files[i].ItemSpec;
                        var src  = Sources?[i].ItemSpec;
                        var ns   = Files[i].GetMetadata("Namespace");
                        if (string.IsNullOrEmpty(ns))
                        {
                            ns = Namespace;
                        }
                        var config                 = Config != null ? $"/config:{Config} /mergeConfig " : "";
                        var serializer             = Serializer != null ? $"/serializer:{Serializer} " : "";
                        var useSerializerForFaults = Serializer != null && UseSerializerForFaults ? $"/useSerializerForFaults " : "";
                        var async        = Async ? "/async " : "/syncOnly ";
                        string reference = "";
                        if (Reference != null)
                        {
                            var refs = Reference.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());
                            var str  = new StringBuilder();
                            foreach (var r in refs)
                            {
                                str.Append("\"/r:");
                                str.Append(Path.GetFullPath(r));
                                str.Append("\" ");
                            }
                            reference = str.ToString();
                        }
                        var targetVersion     = TargetClientVersion != null ? $"/targetClientVersion:{TargetClientVersion} " : "";
                        var importXmlTypes    = ImportXmlTypes ? "/importXmlTypes " : "";
                        var dataContractOnly  = DataContractOnly ? "/dataContractOnly " : "";
                        var serviceContract   = ServiceContract ? "/serviceContract " : "";
                        var enableDataBinding = EnableDataBinding ? "/enableDataBinding " : "";
                        string excludeType    = "";
                        if (ExcludeType != null)
                        {
                            var types = ExcludeType.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim());
                            var str   = new StringBuilder();
                            foreach (var t in types)
                            {
                                str.Append("\"/et:");
                                str.Append(Path.GetFullPath(t));
                                str.Append("\" ");
                            }
                            excludeType = str.ToString();
                        }
                        var _internal   = Internal ? "/internal " : "";
                        var mergeConfig = MergeConfig ? "/mergeConfig " : "";
                        var noConfig    = NoConfig ? "/noConfig " : "";
                        var noStdLib    = NoStdLib ? "/noStdLib " : "";

                        var arg = WCF ? $"/t:code /out:{file} /namespace:{ns} /language:{Language} {config}{serializer}{useSerializerForFaults}{async}{targetVersion}{importXmlTypes}{reference}{dataContractOnly}{serviceContract}{enableDataBinding}{excludeType}{_internal}{mergeConfig}{noConfig}{noStdLib}{url}" :
                                  $"/out:{file} /namespace:{ns} /language:{Language} /protocol:{Protocol}" + (WSE ? " /type:" + (type == Types.WseSoapClient ? "soapClient" : "webClient") : (type == Types.Client ? "" : (type == Types.Server ? " /server" : " /serverInterface"))) + (Sharetypes ? " /sharetypes" : "") + " " + url;
                        var fileInfo   = new FileInfo(file);
                        var fileTime   = fileInfo.LastWriteTimeUtc;
                        var sourceTime = sourceTimes[i];

                        if (src == null || !fileInfo.Exists || fileTime < projTime || fileTime < sourceTime)
                        {
                            lock (this) {
                                if (useIisExpress && !iisstarted)
                                {
                                    iisstarted = true;
                                    if (newiis)
                                    {
                                        IisExpress.Stop();
                                        IisExpress.Start(iisport);
                                        var web = new WebClient();
                                        try {
                                            serverError = (web.DownloadString(url) == null);
                                        } catch (Exception ex) {
                                            serverError = true;
                                        }
                                    }
                                }
                            }

                            if (serverError)
                            {
                                Log.LogError("Server still has errors.");
                                return;
                            }

                            var wsdlstart = new ProcessStartInfo(tool)
                            {
                                UseShellExecute        = false,
                                WorkingDirectory       = Environment.CurrentDirectory,
                                CreateNoWindow         = true,
                                WindowStyle            = ProcessWindowStyle.Hidden,
                                RedirectStandardOutput = true,
                                Arguments = arg
                            };
                            var p                 = new Process();
                            p.StartInfo           = wsdlstart;
                            p.EnableRaisingEvents = true;
                            p.Exited             += (sender, a) => {
                                var any = !Terminated(p, processes, false);
                                ProcessInfo[] infos;
                                lock (processes) infos = processes.ToArray();
                                foreach (var info in infos)
                                {
                                    any |= !Terminated(info.Process, processes, false);
                                }
                                if (!any)
                                {
                                    wait.Set();
                                }
                            };
                            lock (processes) processes.Add(new ProcessInfo {
                                    Process = p, File = file, Url = url, Args = arg
                                });
                            lock (output) output.Add(new TaskItem(Files[i]));
                            anyprocesses = true;
                            p.Start();
                        }
                    } catch (Exception ex) {
                        Log.LogErrorFromException(ex);
                    }
                });

                //foreach (var p in processes.ToArray()) p.Start();

                if (anyprocesses && !wait.WaitOne(Timeout * 1000))
                {
                    ProcessInfo[] infos;
                    lock (processes) infos = processes.ToArray();
                    foreach (var info in infos)
                    {
                        if (!info.Process.HasExited)
                        {
                            info.Process.Kill();
                        }
                        Terminated(info.Process, processes, true);
                    }
                }
            }
            else
            {
                var swaggerdocsurl = SwaggerUrl ?? (ServerUrl + "/swagger/docs/" + (ApiVersion ?? "v1"));
                serverError = false;
                if (AutoRest || SwaggerUrl == null)
                {
                    if (newiis)
                    {
                        IisExpress.Stop();
                        IisExpress.Start(iisport);
                        iisstarted = true;
                        var web = new WebClient();
                        try {
                            serverError = (web.DownloadString(ServerUrl) == null);
                        } catch {
                            serverError = true;
                        }
                        if (serverError)
                        {
                            Log.LogError($"Server still has errors: {ServerUrl}.");
                            return(false);
                        }
                    }
                }
                var swaggerjson = new WebClient().DownloadString(swaggerdocsurl);
                var jsonfile    = Path.Combine(OutputDirectory, "swagger.json");
                if (!File.Exists(jsonfile) || File.ReadAllText(jsonfile) != swaggerjson)
                {
                    if (Directory.Exists(OutputDirectory))
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    Directory.CreateDirectory(OutputDirectory);
                    File.WriteAllText(jsonfile, swaggerjson);
                    if (AutoRest)
                    {
                        // AutoRest
                        var outdir      = OutputDirectory != null ? $"-OutputDirectory \"{OutputDirectory}\" " : "";
                        var codegen     = CodeGenerator != null ? $"-CodeGenerator {CodeGenerator} " : "";
                        var modeler     = Modeler != null ? $"-Modeler {Modeler} " : "";
                        var clientname  = ClientName != null ? $"-ClientName {ClientName} " : "";
                        var payloadthrs = PayloadFlatteningTreshold != null ? $"-PayloadFlatteningThreshold {PayloadFlatteningTreshold} " : "";
                        var header      = Header != null ? $"-Header \"{Header}\" " : "";
                        var credentials = AddCredentials != null ? $"-AddCredentials {AddCredentials} " : "";
                        var outfile     = OutputFileName != null ? $"-OutputFileName \"{OutputFileName}\" " : "";
                        var verbose     = Verbose ? $"-Verbose " : "";
                        var settings    = CodeGenSettings != null ? $"-CodeGenSettings \"{CodeGenSettings}\"" : "";

                        var args = $"{outdir}{codegen}{modeler}{clientname}{payloadthrs}{header}{credentials}{outfile}{verbose}{settings}".Trim();
                        Process.Start(ToolExe, args);
                    }
                    else if (Swagger)
                    {
                        try {
                            var codegenurl = "http://generator.swagger.io/api/gen/clients/" + (Language ?? "typescript-angular2");
                            var body       = new StringWriter();
                            body.Write("{\"spec\": ");
                            body.Write(swaggerjson);
                            body.Write(",\"swaggerUrl\":null");
                            if (Options != null)
                            {
                                body.Write($",\"options\":{Options}");
                            }
                            if (Authorization != null)
                            {
                                body.Write($",\"authorizationValue\":{Authorization}");
                            }
                            if (Security != null)
                            {
                                body.Write($",\"securityDefinition\": {Security}");
                            }
                            body.Write("}");
                            var gen = (HttpWebRequest)WebRequest.Create(codegenurl);
                            gen.Method          = "POST";
                            gen.ContentType     = "application/json";
                            gen.Accept          = "application/json";
                            gen.ProtocolVersion = HttpVersion.Version11;
                            var buf = Encoding.UTF8.GetBytes(body.ToString());
                            gen.ContentLength = buf.Length;
                            var w = gen.GetRequestStream();
                            w.Write(buf, 0, buf.Length);
                            w.Close();
                            var     res     = (HttpWebResponse)gen.GetResponse();
                            var     r       = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
                            dynamic result  = SimpleJson.DeserializeObject(r.ReadToEnd());
                            var     rawzip  = new WebClient().DownloadData(result.link);
                            var     zipfile = Path.Combine(OutputDirectory, "swagger.zip");
                            File.WriteAllBytes(zipfile, rawzip);
                            var zip = new Ionic.Zip.ZipFile(zipfile);
                            zip.ExtractAll(OutputDirectory);
                        } catch (Exception ex) {
                            Log.LogErrorFromException(ex);
                            return(false);
                        }
                    }

                    var odir = Path.Combine(Environment.CurrentDirectory, OutputDirectory);
                    output.AddRange(
                        Directory.EnumerateFiles(OutputDirectory)
                        .Select(file => new TaskItem {
                        ItemSpec = file.StartsWith(odir) ? file.Substring(odir.Length).Trim('\\') : file
                    }));
                }
            }

            //if (iisstarted) IisExpress.Stop();

            Output = output.ToArray();
            return(!Log.HasLoggedErrors);
        }