Exemplo n.º 1
0
        internal static void fLaunchUpdate(string sCurrFolder, string _sVersion)
        {
            LaunchTool _oUpd = new LaunchTool();

            _oUpd.bOutput         = false;
            _oUpd.UseShellExecute = true;
            _oUpd.fLaunchExe(sCurrFolder + "cwc.exe", " -wCwcUpd " + PathHelper.GetExeDirectory() + " -wCwcVer " + _sVersion, "", "", true);
            //		Console.WriteLine("Update to ver "  +_sVersion );
            while (!_oUpd.bExeLaunched && Base.bAlive)
            {
                Thread.Sleep(1);
            }
            SysAPI.fQuit(true);
        }
Exemplo n.º 2
0
        internal static void fRestart(string sCurrFolder)
        {
            LaunchTool _oUpd = new LaunchTool();

            _oUpd.bOutput         = false;
            _oUpd.UseShellExecute = true;
            //	_oUpd.fLaunchExe( sCurrFolder + "cwc.exe", "Updated ", "","",true);
            _oUpd.fLaunchExe(sCurrFolder + "cwc.exe", "-wCwcUpdated " + Data.sUpdateVer, "", "", true);
            //				_process.StartInfo.Arguments = "Updated " + _sVersion + " " + Data.sWorkDir + " " + Data.sResendArg;
            while (!_oUpd.bExeLaunched && Base.bAlive)
            {
                Thread.Sleep(1);
            }
            SysAPI.fQuit(true);
        }
Exemplo n.º 3
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 ----");
        }
Exemplo n.º 4
0
        public static string fExpand(string _sFullArg, int _nIndex)
        {
//	Debug.fTrace("---fExpand!!!!! " + _sFullArg);
            //List<string> _sList = new List<string> ();

            string _sResult    = "";
            int    _nSartIndex = 0;
            int    _nEndIndex  = 0;
            int    _nIndexOfA  = _nIndex;

            ///////////////////////////////// Begin with @
            while (_nIndexOfA != -1)
            {
                _sResult  += _sFullArg.Substring(_nSartIndex, _nIndexOfA - _nSartIndex);
                _nEndIndex = fGetEndFile(_sFullArg, _nIndexOfA + 1);


                string _sFile = _sFullArg.Substring(_nIndexOfA + 1, _nEndIndex - (_nIndexOfA + 1));

                //Debug.fTrace("-****************************!!!fExpand  " + _sFile);
                if (_sFile == "wDeloc")                  //Special deloc command to quit
                //Debug.fTrace("!!!---DELOCATISE!!!!!");
                {
                    _sFullArg = _sFullArg.Replace("@wDeloc", "");                     //remove all wDeloc
                    Console.Error.WriteLine("wOut|" + _sFullArg);                     //Use special stream to resend args
                    SysAPI.fQuit(true);
                }


                string _sPath;
                if (_sFile.Length > 2 && _sFile[1] == ':')                 //Absolute path
                {
                    _sPath = _sFile;
                }
                else
                {
                    _sPath = PathHelper.ExeWorkDir + _sFile;                     //Relative path
                }

                string _sText = "";

                string _sExt = Path.GetExtension(_sPath).ToLower();



                try {
                    switch (_sExt)
                    {
                    case ".bat":
                    case ".exe":
                        _sText = Delocalise.fDelocalise(_sPath);
                        break;

                    default:
                        _sText = File.ReadAllText(_sPath);

                        break;
                    }
                }catch (Exception Ex) {
                    Output.TraceError("Error Expand File: " + Ex.Message + " : " + _sPath);
                };

                _sResult   += _sText;
                _nSartIndex = _nEndIndex;

                //   _nSartIndex = _nEndIndex;
                _nIndexOfA = _sFullArg.IndexOf('@', _nEndIndex);
            }

            _sResult += _sFullArg.Substring(_nEndIndex, _sFullArg.Length - _nEndIndex);



            /*
             * string[] _aFiles =   _sFullArg.Split('@');
             * foreach(string _sFileArg in _aFiles) {
             *
             *  int _nIndex = _sFileArg.IndexOf(' ');
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('\t');  //TODO make "OR" combinaison
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('\n');
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('|');
             *  }
             *  if(_nIndex == -1) {
             *      _nIndex = _sFileArg.IndexOf('>');
             *  }
             *   if(_nIndex == -1) {
             *      _nIndex = _sFileArg.Length;
             *  }
             *
             *   string _sFile = _sFileArg.Substring(0, _nIndex);
             *
             *   string _sPath = PathHelper.GetCurrentDirectory() + _sFile;
             *   string _sText = "";
             *  try {
             *      _sText = File.ReadAllText(_sPath);
             *  }catch(Exception Ex) {};
             *
             *   string _sArg =  _sFileArg.Substring(_nIndex);
             *  _sResult += _sText + _sArg;
             *
             *
             * }     */

            //   return _sResult.Replace('\n', ' ');
            //  return _sResult.Replace('\n', ' ').Replace('\r', ' ');
            return(_sResult);
        }