Example #1
1
 public Packet()
 {
     this.actionsAfterUpdateField = new ActionsType();
     this.changedFilesField = new List<string>();
     this.actionsBeforeUpdateField = new ActionsType();
     this.previousPacketsField = new List<PacketIdentificationType>();
     this.packetIdentificationField = new PacketIdentificationType();
 }
Example #2
0
        public void SavePacketTest()
        {
            Packet packet = new Packet();
            packet.PacketIdentification = new PacketIdentificationType();
            packet.PacketIdentification.Number = "2";
            packet.PacketIdentification.Date = DateTime.Now;
            packet.PacketIdentification.Guid = Guid.NewGuid().ToString();
            packet.PacketIdentification.ProgramGuid = Guid.NewGuid().ToString();
            packet.PacketIdentification.ProgramVersion = "5.2016.2.2";

            packet.PreviousPackets = new List<PacketIdentificationType>();
            var sss = new PacketIdentificationType
            {
                Number = "1",
                Date = DateTime.Now.AddDays(-1),
                Guid = Guid.NewGuid().ToString(),
                ProgramGuid = Guid.NewGuid().ToString(),
                ProgramVersion = "5.2016.2.2"
            };

            packet.PreviousPackets.Add(sss);

            packet.ActionsBeforeUpdate = new ActionsType();
            packet.ActionsBeforeUpdate.Runs = new List<RunAppType>();

            packet.ActionsBeforeUpdate.Runs.Add(new RunAppType() { RelPath = "asdd", Args = "asddvk", Value = "" });
            packet.ActionsBeforeUpdate.Runs.Add(new RunAppType() { RelPath = "as", Args = "asddvklklfk", Value = "94056" });

            packet.ActionsBeforeUpdate.Scripts = new List<string>();
            packet.ActionsBeforeUpdate.Scripts.Add("dfjhdgfg");
            packet.ActionsBeforeUpdate.Scripts.Add("cxvbvb");

            packet.ChangedFiles = new List<string>() {"asd", "xccc", "aaaaaa"};

            packet.ActionsAfterUpdate = new ActionsType();
            packet.ActionsAfterUpdate.Runs = new List<RunAppType>();
            packet.ActionsAfterUpdate.Runs.Add(new RunAppType() { RelPath = "asdd 2", Args = "asddvklklfk 2 ", Value = "94056" }); 
            packet.ActionsAfterUpdate.Runs.Add(new RunAppType() { RelPath = "asdd" , Args = "asddvklklfk", Value = "94056" });
            packet.UpdateMessage = string.Empty;
            PacketDefinitionsLoader definitionsLoader = new PacketDefinitionsLoader();

            var fileName = Path.GetTempFileName();
            definitionsLoader.SavePacket(packet, fileName);

        }
        public void CreatePacketTest()
        {
            int packetnum = Environment.TickCount / 40;

            Packet packet = new Packet();
            packet.PacketIdentification = new PacketIdentificationType();
            packet.PacketIdentification.Number = packetnum.ToString();
            packet.PacketIdentification.Date = DateTime.Now;
            packet.PacketIdentification.Guid = Guid.NewGuid().ToString();
            packet.PacketIdentification.ProgramGuid = Guid.NewGuid().ToString();
            packet.PacketIdentification.ProgramVersion = "5.2016.2.2";

            packet.PreviousPackets = new List<PacketIdentificationType>();
            var sss = new PacketIdentificationType
            {
                Number = "1",
                Date = DateTime.Now.AddDays(-1),
                Guid = Guid.NewGuid().ToString(),
                ProgramGuid = Guid.NewGuid().ToString(),
                ProgramVersion = "5.2016.2.2"
            };

            packet.PreviousPackets.Add(sss);

            packet.ActionsBeforeUpdate = new ActionsType();
            packet.ActionsBeforeUpdate.Runs = new List<RunAppType>();

            packet.ActionsBeforeUpdate.Runs.Add(new RunAppType() { RelPath = "asdd", Args = "asddvk", Value = "" });
            packet.ActionsBeforeUpdate.Runs.Add(new RunAppType() { RelPath = "as", Args = "asddvklklfk", Value = "94056" });

            packet.ActionsBeforeUpdate.Scripts = new List<string>();
            packet.ActionsBeforeUpdate.Scripts.Add("dfjhdgfg");
            packet.ActionsBeforeUpdate.Scripts.Add("cxvbvb");

            packet.ChangedFiles = new List<string>() { "asd", "xccc", "aaaaaa" };

            packet.ActionsAfterUpdate = new ActionsType();
            packet.ActionsAfterUpdate.Runs = new List<RunAppType>();
            packet.ActionsAfterUpdate.Runs.Add(new RunAppType() { RelPath = "asdd 2", Args = "asddvklklfk 2 ", Value = "94056" });
            packet.ActionsAfterUpdate.Runs.Add(new RunAppType() { RelPath = "asdd", Args = "asddvklklfk", Value = "94056" });
            packet.UpdateMessage = string.Empty;

            FilePacketManager filePacketManager = new FilePacketManager();
            filePacketManager.CreatePacket(packet, new List<string>() { @"F:\20130816_143132.jpg", @"F:\20130816_143305.jpg", @"F:\Новая папка\Открытка к нг 2015 коллеги.png" }, new List<string>(),  @"F:\testUpdate\" + packet.PacketIdentification.Number + ".zip");
        }