示例#1
0
        public static void      fUrlRequestComplete(LaunchTool _oTool)
        {
            ParamHttp _oParam = (ParamHttp)_oTool.oCustom;

            //Console.WriteLine("------------------ Finish :\n"  +_oParam.sURL );

            //Console.WriteLine( _oParam.sResult );
            //Console.WriteLine("" );
            //Console.WriteLine("------------------" );
            if (_oParam.bDownloadFile)
            {
                if (_oParam.nTotalBytes > 0)
                {
                    _oParam.nBytes = _oParam.nTotalBytes;
                }
                else
                {
                    _oParam.nBytes *= 1.5;             //Boost gain
                }
                fUrlProgress(_oParam);                 //100%
                Output.TraceGood("Downloaded: " + _oParam.sToFile);
            }

            ///if(!_oParam.bDownloadFile) {
            _oParam.dComplete(_oParam);
            //}
        }
示例#2
0
        public void fCompressionExit(LaunchTool _oTool)
        {
            //Output.TraceWarning("--!!!fCompressionExit!-----: " );
            bExtracting = false;
            fGetLastVersions();
            //   Output.TraceWarning("-#1: " );

            if (oForm != null)
            {
                oForm.fExtractProgress(100, "");
            }

            // Debug.fTrace("----------------------fCompressionExit : " );

            try {
                //Debug.fTrace("-Trydelete : " +  _oTool.sSourceFile);
                if (File.Exists(_oTool.sSourceFile))
                {
                    File.Delete(_oTool.sSourceFile);
                    // Debug.fTrace("-Deleted : " +  _oTool.sSourceFile);
                }
            }catch (Exception Ex) {
                Output.TraceError("--Error: " + Ex.Message);
            }


            if (!fCheckForAutoExtractFiles(_oTool))
            {
                bExtact_InProgress = false;

                // Output.TraceGood("----- Complete All Sub Extraction ------ " );
                bSubExtract = false;

                if (oForm != null)
                {
                    oForm.fModuleFinish();
                }
            }
            else
            {
                Output.TraceGood("----- Complete " + _oTool.sSourceFile);
            }


            if (sName == "Cwc")
            {
                //Cwc update now!
                if (oForm != null)
                {
                    oForm.fExecuteUpdater(this);
                }
            }
        }
示例#3
0
 internal static void fUpdated(string _sArg)
 {
     if (_sArg == Data.sVersion)
     {
         Output.TraceGood("UPDATED TO: " + _sArg);
         //CleanFolder
         Thread.Sleep(500);                 //Wait for update close //TODO add retry ??
         FileUtils.DeleteDirectory(PathHelper.GetExeDirectory() + "Upd_Cwc", true);
     }
     else
     {
         Output.TraceError("UPDATE FAIL TO: " + _sArg);
         Output.TraceWarning("Current " + Data.sVersion);
     }
 }
示例#4
0
文件: Output.cs 项目: VLiance/Cwc-src
        public static void     fPrjOut(string _sLetter, string _sOut)
        {
            if (_sOut == null)
            {
                return;
            }

            string _sPrefix = _sLetter + "> ";

            if (_sOut.Length > 4) //ex T[1]:xxxx
            {
                if (_sOut[1] == '[')
                {
                    switch (_sOut[0])
                    {
                    case 'P':
                        Output.TraceGood(_sPrefix + _sOut);
                        break;

                    case 'E':
                        Output.TraceError(_sPrefix + _sOut);
                        break;

                    case 'W':
                        Output.TraceWarning(_sPrefix + _sOut);
                        break;

                    case 'A':
                        Output.TraceAction(_sPrefix + _sOut);
                        break;

                    case 'T':
                        Output.TraceStd(_sPrefix + _sOut);
                        break;

                    default:
                        Output.Trace(_sPrefix + _sOut);
                        break;
                    }
                    return;
                }
            }
            Output.Trace(_sPrefix + _sOut);
            return;
        }
示例#5
0
        public void fRecewiveMsg(string _sMsg)
        {
            Debug.fTrace(_sMsg);

            if (_sMsg.Length <= 2)
            {
                return;
            }                              //Invalid
            // try {
            if (_sMsg[1] == ':')
            {
                switch (_sMsg[0])
                {
                case 'P':    //Print Good
                    Output.Trace(_sMsg.Substring(2));
                    break;


                case 'G':
                    Output.TraceGood(_sMsg);
                    break;

                case 'E':

                    break;


                case 'C':   //Print Good
                    fPerformCommand(_sMsg.Substring(2));
                    break;

                case 'A':

                    break;

                default:
                    break;
                }
            }
        }
示例#6
0
        public void fExtractOut(LaunchTool _oThis, string _sMsg)
        {
            //Debug.fTrace(_sOut);
            if (!FileUtils.IsEmpty(_sMsg))
            {
                string[] _aResult = _sMsg.Split('\n');
                bool     _bError  = false;
                bool     _bGood   = false;
                if (_sMsg.IndexOf("Can not") >= 0 || _sMsg.IndexOf("Can't") >= 0 || _sMsg.IndexOf("Unexpected") >= 0 || _sMsg.IndexOf("ERROR") >= 0 || _sMsg.IndexOf("Error ") >= 0 || _sMsg.IndexOf("Error:") >= 0)
                {
                    _bError = true;
                    //  Output.TraceError( "--- [" + _oThis.sArg + "] ---"   );
                }
                else if (_sMsg.IndexOf("Everything is Ok") >= 0)
                {
                    _bGood = true;
                }

                foreach (string _sOutput in _aResult)
                {
                    string _sOut = _sOutput.Trim();
                    if (_sOut == "")
                    {
                        continue;
                    }

                    Debug.fRPrint("Extract: " + _sOut + "                                                                                             ");

                    if (_bGood)
                    {
                        Output.TraceGood(_sOut);
                    }
                    else if (_bError)
                    {
                        Output.TraceError(_sOut);
                    }
                    else
                    {
                        Output.TraceWarning("\rExtract[" + _oThis.oModule.sName + "]: " + _sOut);
                    }

                    if (_sOut.IndexOf("Extracting") != -1)
                    {
                        bExtracting = true;
                    }
                    else if (bExtracting)
                    {
                        string [] _aExtInfo = _sOut.Split('%');
                        if (_aExtInfo.Length >= 2)
                        {
                            string _sNumber = _aExtInfo[0].Trim();
                            int    _nValue  = 0;
                            //Debug.fTrace("TryParce: " + _sNumber);
                            if (Int32.TryParse(_sNumber, out _nValue))
                            {
                                if (oForm != null)
                                {
                                    oForm.fExtractProgress(_nValue, _aExtInfo[1]);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#7
0
        public static bool  fLoadModules(bool _bAutoStart = true)
        {
            bool _bFound = true;

            if (Data.oGuiConsole != null)
            {
                Data.bIWantGoToEnd  = true;
                GuiConsole.sFormCmd = "GoEnd";
                //fctbConsole.GoEnd();
            }

            nLoadModuleIndex = 0;
            foreach (string _sModule in Data.aRequiredModule)
            {
                ModuleData _oModule = ModuleData.fFindModule(_sModule);
                _oModule.fGetLocalVersions();

                //  Http.fGetHttp(  _oModule.sUrl_Project , fGetProjectData);//Get readme
                _oModule.fReadHttpModuleTags();
            }

            //Wait to finish
            while (ModuleData.nRequestTag > 0)
            {
                Thread.CurrentThread.Join(1);
            }

            List <ModuleLink> _aLink = new List <ModuleLink>();


            foreach (string _sModule in Data.aRequiredModule)
            {
                ModuleData _oModule = ModuleData.fFindModule(_sModule);
                if (_oModule.aLinkList.Count > 0)
                {
                    foreach (string _sKeyLink  in _oModule.aLinkList)
                    {
                        // Output.TraceWarning( "Recommended version:");
                        Output.TraceAction("Recommended version:" + _oModule.sName + " : " + _sKeyLink);
                        _aLink.Add(_oModule.aLink[_sKeyLink]);
                        break;
                    }
                }
                else
                {
                    Output.TraceError("Not found:" + _sModule);
                    _bFound = false;
                }
            }


            if (_aLink.Count > 0)
            {
                //   Output.TraceWarning( "Download? (yes / no)");
                Output.TraceWarning("Starting Download ... (press 'n' to cancel)");
                foreach (ModuleLink _oLink in _aLink)
                {
                    _oLink.fDownload();
                    while (_oLink.bDl_InProgress)
                    {
                        Thread.CurrentThread.Join(1);
                    }
                    _oLink.fExtract();
                    while (_oLink.oModule.bExtact_InProgress)
                    {
                        Thread.CurrentThread.Join(1);
                    }
                }
                Output.Trace("");
                Output.TraceGood("---------------- All Required Module Completed ------------------");
                foreach (ModuleLink _oLink in _aLink)
                {
                    Output.TraceAction(_oLink.oModule.sCurrFolder);
                }


                Output.TraceGood("-----------------------------------------------------------------");
                if (_bAutoStart)
                {
                    Data.sCmd = "StartBuild";
                }
            }

            return(_bFound);

            /*
             * foreach(ModuleLink _oLink in _aLink) {
             *     _oLink.fExtract();
             * }
             */

            //  Data.oMsgForm.fLoadNextModule();
        }
示例#8
0
        public static void fUpdateFiles(string _sSource)
        {
            Base.bAlive = true;
//Thread.Sleep(10000);

            Output.TraceGood("Update Cwc to ver: " + Data.sUpdateVer);

            string _sBaseSrc  = PathHelper.GetExeDirectory();
            string _sBaseDest = _sSource;


            // Output.TraceGood("Copy Tools: " +_sBaseSrc  + "Tools/"+   "    "+_sBaseDest + "Tools/");

            try {
                FileUtils.CopyFolderContents(_sBaseSrc + "Utils/", _sBaseDest + "Utils/");                 //TODO on run pass only?
            }catch (Exception e) {
                Output.TraceError(e.Message);
            }

            Output.Trace("--- Copy Cwc ----");
            //Thread.Sleep(10);

            //Use Retry
            int    _nCount      = 16;
            int    _nRetryCount = _nCount;
            string _sErrror     = "";

            while (_nRetryCount > 0)
            {
                try {
                    _sErrror = "";
                    File.Copy(_sBaseSrc + "cwc.exe", _sBaseDest + "cwc.exe", true);
                    //_nRetryCount  =0;
                    break;
                }catch (Exception e) {
                    if (_nRetryCount == _nCount - 1)
                    {
                        Output.TraceWarning(e.Message);
                        Output.TraceWarning("Retrying...");
                    }
                    else
                    {
                        if (_nRetryCount != _nCount)
                        {
                            Output.TraceWarning(_nRetryCount.ToString());
                        }
                    }
                    _nRetryCount--;
                    Thread.Sleep(1000);
                    //Output.TraceError(e.GetType().Name);//IOException


                    _sErrror = e.Message;
                }
            }
            if (_sErrror != "")
            {
                Output.TraceError("Can't update cwc, please retry later...");
                Thread.Sleep(3000);
            }
            else
            {
                Output.TraceGood("--- Done ----");
//				Thread.Sleep(3000);
            }



            fRestart(_sBaseDest);
            //Cwc copy
            SysAPI.fQuit();


            //Console.WriteLine("--- Done ----");
        }