FromByteArray() public static method

public static FromByteArray ( byte data ) : UpdateHelperData
data byte
return UpdateHelperData
Esempio n. 1
0
        void ServerReceivedData(byte[] message)
        {
            UpdateHelperData data = UpdateHelperData.FromByteArray(message);

            if (data.Action == UpdateAction.GetwyUpdateProcessID)
            {
                // send ProcessID
                pipeServer.SendMessage(new UpdateHelperData(UpdateAction.GetwyUpdateProcessID)
                {
                    ProcessID = Process.GetCurrentProcess().Id
                }.GetByteArray());
                return;
            }

            UpdateStep step = data.UpdateStep;

            if (step == UpdateStep.RestartInfo)
            {
                RestartInfoSent = true;

                // load the pre-install info
                if (data.ExtraData.Count > 0)
                {
                    FileOrServiceToExecuteAfterUpdate = data.ExtraData[0];
                    IsAService = data.ExtraDataIsRTF[0];
                }

                // load the AutoUpdateID (for writing to file whether the update failed or Succeeded)
                if (data.ExtraData.Count > 1)
                {
                    AutoUpdateID = data.ExtraData[1];
                }

                if (data.ExtraData.Count > 2)
                {
                    ExecutionArguments = data.ExtraData[2];
                }
            }
            else if (step == UpdateStep.Install)
            {
                // if we're already installing, don't bother to process the message again
                if (Installing)
                {
                    return;
                }

                Installing = true;
            }

            if (RequestReceived != null)
            {
                RequestReceived(this, data.Action, step);
            }
        }
Esempio n. 2
0
        private void ServerReceivedData(byte[] message)
        {
            UpdateHelperData updateHelperData = UpdateHelperData.FromByteArray(message);

            if (updateHelperData.Action == UpdateAction.GetwyUpdateProcessID)
            {
                pipeServer.SendMessage(new UpdateHelperData(UpdateAction.GetwyUpdateProcessID)
                {
                    ProcessID = Process.GetCurrentProcess().Id
                }.GetByteArray());
                return;
            }
            UpdateStep updateStep = updateHelperData.UpdateStep;

            switch (updateStep)
            {
            case UpdateStep.RestartInfo:
                RestartInfoSent = true;
                if (updateHelperData.ExtraData.Count > 0)
                {
                    FileOrServiceToExecuteAfterUpdate = updateHelperData.ExtraData[0];
                    IsAService = updateHelperData.ExtraDataIsRTF[0];
                }
                if (updateHelperData.ExtraData.Count > 1)
                {
                    AutoUpdateID = updateHelperData.ExtraData[1];
                }
                if (updateHelperData.ExtraData.Count > 2)
                {
                    ExecutionArguments = updateHelperData.ExtraData[2];
                }
                break;

            case UpdateStep.Install:
                if (Installing)
                {
                    return;
                }
                Installing = true;
                break;
            }
            if (this.RequestReceived != null)
            {
                this.RequestReceived(this, updateHelperData.Action, updateStep);
            }
        }