Beispiel #1
0
        /// <summary>
        /// Gets the status of the update
        /// </summary>
        /// <returns>Status Update</returns>
        private dc_EnumConstJBC.dc_UpdateState GetUpdateState()
        {
            string sFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "JBC\\JBC Updater Service", System.Convert.ToString(My.Settings.Default.UpdateStateFile));

            dc_EnumConstJBC.dc_UpdateState state = dc_EnumConstJBC.dc_UpdateState.Finished;

            if (File.Exists(sFile))
            {
                StreamReader objReader = new StreamReader(sFile);
                string       sTextLine;

                //Leemos el documento line by line
                while (objReader.Peek() != -1)
                {
                    sTextLine = objReader.ReadLine().Trim();

                    if (sTextLine == dc_EnumConstJBC.dc_UpdateState.Updating.ToString())
                    {
                        state = dc_EnumConstJBC.dc_UpdateState.Updating;
                    }
                    else if (sTextLine == dc_EnumConstJBC.dc_UpdateState.Finished.ToString())
                    {
                        state = dc_EnumConstJBC.dc_UpdateState.Finished;
                    }
                    else //Failed
                    {
                        state = dc_EnumConstJBC.dc_UpdateState.Failed;
                    }
                }
                objReader.Close();
            }

            return(state);
        }
Beispiel #2
0
        /// <summary>
        /// Save the update status
        /// </summary>
        /// <param name="state">New update status</param>
        private void SetUpdateState(dc_EnumConstJBC.dc_UpdateState state)
        {
            string sState = "";

            if (state == dc_EnumConstJBC.dc_UpdateState.Failed)
            {
                sState = dc_EnumConstJBC.dc_UpdateState.Failed.ToString();
            }
            else if (state == dc_EnumConstJBC.dc_UpdateState.Finished)
            {
                sState = dc_EnumConstJBC.dc_UpdateState.Finished.ToString();
            }
            else
            {
                sState = dc_EnumConstJBC.dc_UpdateState.Updating.ToString();
            }

            //El estado de actualización se guarda en un fichero para permitir la concurrencia
            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "JBC\\JBC Updater Service", System.Convert.ToString(My.Settings.Default.UpdateStateFile)), sState, false);
        }