コード例 #1
0
        public void SendSuccess(string extraData1, string extraData2, bool ed2IsRtf)
        {
            UpdateHelperData uh = new UpdateHelperData(Response.Succeeded, UpdateStep.CheckForUpdate, extraData1, extraData2);

            uh.ExtraDataIsRTF[1] = ed2IsRtf;

            pipeServer.SendMessage(uh.GetByteArray());
        }
コード例 #2
0
ファイル: UpdateHelper.cs プロジェクト: chances/Animatum
        public void SendSuccess(string extraData1, string extraData2, bool ed2IsRtf)
        {
            UpdateHelperData uh = new UpdateHelperData(Response.Succeeded, UpdateStep.CheckForUpdate, extraData1, extraData2);

            uh.ExtraDataIsRTF[1] = ed2IsRtf;

            pipeServer.SendMessage(uh.GetByteArray());
        }
コード例 #3
0
ファイル: UpdateHelper.cs プロジェクト: chances/Animatum
        public void SendNewWyUpdate(string pipeName, int processID)
        {
            UpdateHelperData uh = new UpdateHelperData(UpdateAction.NewWyUpdateProcess) { ProcessID = processID };

            uh.ExtraData.Add(pipeName);
            uh.ExtraDataIsRTF.Add(false);

            pipeServer.SendMessage(uh.GetByteArray());
        }
コード例 #4
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);
            }
        }
コード例 #5
0
ファイル: UpdateHelperData.cs プロジェクト: chances/Animatum
        public static UpdateHelperData FromByteArray(byte[] data)
        {
            UpdateHelperData uhData = new UpdateHelperData();

            using (MemoryStream ms = new MemoryStream(data))
            {
                byte bType = (byte)ms.ReadByte();

                //read until the end byte is detected
                while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
                {
                    switch (bType)
                    {
                        case 0x01:
                            uhData.Action = (UpdateAction)ReadFiles.ReadInt(ms);
                            break;
                        case 0x02: // update step we're on
                            uhData.UpdateStep = (UpdateStep)ReadFiles.ReadInt(ms);
                            break;
                        case 0x80:
                            uhData.ExtraDataIsRTF.Add(true);
                            break;
                        case 0x03: // extra data

                            uhData.ExtraData.Add(ReadFiles.ReadString(ms));

                            // keep the 'ExtraDataIsRTF' same length as ExtraData
                            if (uhData.ExtraDataIsRTF.Count != uhData.ExtraData.Count)
                                uhData.ExtraDataIsRTF.Add(false);

                            break;
                        case 0x04:
                            uhData.ProcessID = ReadFiles.ReadInt(ms);
                            break;
                        case 0x05:
                            uhData.Progress = ReadFiles.ReadInt(ms);
                            break;
                        case 0x06:
                            uhData.ResponseType = (Response)ReadFiles.ReadInt(ms);
                            break;

                        // 0x07, 0x08, and 0x09 used to be links data - obsolete

                        default:
                            ReadFiles.SkipField(ms, bType);
                            break;
                    }

                    bType = (byte)ms.ReadByte();
                }
            }

            return uhData;
        }
コード例 #6
0
        public void SendNewWyUpdate(string pipeName, int processID)
        {
            UpdateHelperData uh = new UpdateHelperData(UpdateAction.NewWyUpdateProcess)
            {
                ProcessID = processID
            };

            uh.ExtraData.Add(pipeName);
            uh.ExtraDataIsRTF.Add(false);

            pipeServer.SendMessage(uh.GetByteArray());
        }
コード例 #7
0
        public void StartPipeServer(Control OwnerHandle)
        {
            //Note: this function can only be called once. Explosions otherwise.

            owner = OwnerHandle;

            pipeServer = new PipeServer();

            pipeServer.MessageReceived    += pipeServer_MessageReceived;
            pipeServer.ClientDisconnected += pipeServer_ClientDisconnected;

            pipeServer.Start(UpdateHelperData.PipenameFromFilename(VersionTools.SelfLocation));
        }
コード例 #8
0
        public static UpdateHelperData FromByteArray(byte[] data)
        {
            UpdateHelperData uhData = new UpdateHelperData();

            using (MemoryStream ms = new MemoryStream(data))
            {
                byte bType = (byte)ms.ReadByte();

                //read until the end byte is detected
                while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:
                        uhData.Action = (UpdateAction)ReadFiles.ReadInt(ms);
                        break;

                    case 0x02:     // update step we're on
                        uhData.UpdateStep = (UpdateStep)ReadFiles.ReadInt(ms);
                        break;

                    case 0x80:
                        uhData.ExtraDataIsRTF.Add(true);
                        break;

                    case 0x03:     // extra data

                        uhData.ExtraData.Add(ReadFiles.ReadString(ms));

                        // keep the 'ExtraDataIsRTF' same length as ExtraData
                        if (uhData.ExtraDataIsRTF.Count != uhData.ExtraData.Count)
                        {
                            uhData.ExtraDataIsRTF.Add(false);
                        }

                        break;

                    case 0x04:
                        uhData.ProcessID = ReadFiles.ReadInt(ms);
                        break;

                    case 0x05:
                        uhData.Progress = ReadFiles.ReadInt(ms);
                        break;

                    case 0x06:
                        uhData.ResponseType = (Response)ReadFiles.ReadInt(ms);
                        break;

                    // 0x07, 0x08, and 0x09 used to be links data - obsolete

                    default:
                        ReadFiles.SkipField(ms, bType);
                        break;
                    }

                    bType = (byte)ms.ReadByte();
                }
            }

            return(uhData);
        }