bool Build(string testdriver, List <string> argslist)
        {
            bool          flag      = true;
            List <string> buildList = new List <string>();

            buildList = argslist;
            buildList.Insert(0, testdriver);
            fileMgr.storagePath = childstorage;
            fileMgr.getFiles("*.*");
            string csfile = "";

            foreach (string item in buildList)
            {
                csfile += " " + item;
            }
            Console.Write("\n ============== cs files are:   " + csfile + "==================\n ");
            List <string> storedFile = new List <string>();

            try
            {
                foreach (string file in fileMgr.files)
                {
                    string fileName = Path.GetFileName(file);
                    storedFile.Add(fileName);
                }
                if (buildList.All(b => storedFile.Any(a => a == (b))))
                {
                    Console.Write("\n=================== Start building " + csfile + "==================\n ");
                    Process p = new Process();
                    p.StartInfo.FileName = "cmd.exe";
                    string driverName_ = Path.GetFileNameWithoutExtension(testdriver);
                    p.StartInfo.Arguments              = @"/Ccsc /target:library " + csfile;
                    p.StartInfo.WorkingDirectory       = @childstorage;
                    p.StartInfo.RedirectStandardError  = true;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute        = false;
                    p.Start();
                    p.WaitForExit();
                    string       errors = p.StandardError.ReadToEnd();
                    string       output = p.StandardOutput.ReadToEnd();
                    StreamWriter sW     = new StreamWriter(@childstorage + "/" + driverName_ + "buildlog.txt");
                    sW.WriteLine(string.Concat(output, errors));
                    sW.Close();
                    Console.Write($"\n  Build Errors: {errors}");
                    Console.Write($"\n  Build Outout: {output}");
                    Console.Write("\n =================== Building ends ==================\n");
                }
                else
                {
                    flag = false;
                };
            }
            catch (Exception ex)
            {
                Console.Write("\n\n The error reason  in  build()  is {0}\n\n", ex.Message);
            }
            return(flag);
        }
예제 #2
0
        void initializeDispatcher()
        {
            Func <CommMessage, CommMessage> getTopFiles = (CommMessage msg) =>
            {
                fileMgr.currentPath = "";
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to        = "http://localhost:" + clientport + "/IMessagePassingComm";
                reply.from      = "http://localhost:" + rcvrport + "/IMessagePassingComm";
                reply.command   = "getTopFiles";
                reply.arguments = fileMgr.getFiles().ToList <string>();
                return(reply);
            };

            messageDispatcher["getTopFiles"] = getTopFiles;
            Func <CommMessage, CommMessage> XML = (CommMessage msg) =>
            {
                tempList.Add(msg);
                CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                reply.to      = "http://localhost:" + clientport + "/IMessagePassingComm";
                reply.from    = "http://localhost:" + rcvrport + "/IMessagePassingComm";
                reply.command = "receive";
                reply.driver  = Path.GetFileName(msg.driver);
                return(reply);
            };

            messageDispatcher["XML"] = XML;

            Func <CommMessage, CommMessage> XMLend = (CommMessage msg) =>
            {
                fileMgr.doc     = new XDocument();
                fileMgr.msgList = tempList;
                fileMgr.makeRequest();
                if (fileMgr.saveXml())
                {
                    try{
                        CommMessage reply = new CommMessage(CommMessage.MessageType.reply);
                        reply.to      = "http://localhost:" + clientport + "/IMessagePassingComm";
                        reply.from    = "http://localhost:" + rcvrport + "/IMessagePassingComm";
                        reply.command = "XMLDone";
                        reply.show();
                        sndr.postMessage(reply);
                        if (transfer())
                        {
                            tempXML = fileMgr.tempXML;
                            CommMessage request = new CommMessage(CommMessage.MessageType.build);
                            request.to      = "http://localhost:" + motherport + "/IMessagePassingComm";
                            request.from    = "http://localhost:" + rcvrport + "/IMessagePassingComm";
                            request.command = tempList.Count().ToString();
                            request.XML     = tempXML;
                            tempList        = new List <CommMessage>();
                            return(request);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    catch (Exception ex) {
                        Console.Write("\n\n The error reason in XMLend is {0}\n\n", ex.Message);
                    }
                    return(null);
                }
                else
                {
                    return(null);
                }
            };

            messageDispatcher["XMLend"] = XMLend;
        }