Exemplo n.º 1
0
        public void WriteLicense()
        {
            BinaryReader reader = new BinaryReader(new FileStream(@"D:\binary1.bin", FileMode.Open, FileAccess.Read));

            byte[]        signature = null;
            ConfigSection cs        = new ConfigSection();
            ConfigItem    _item     = new ConfigItem(reader, -1);

            cs.Add(_item);
            cs.Id = 0;
            if (cs.Id == 0)
            {
                foreach (ConfigItem item in cs)
                {
                    switch (item.Tag)
                    {
                    case 0:
                    {
                        signature = item.RawValue;
                        break;
                    }

                    case 1:
                    {
                        this.timeStamp = DateTime.Now;
                        continue;
                    }

                    case 2:
                    {
                        this.CustomerId = 1;
                        continue;
                    }

                    case 3:
                    {
                        this.SystemId = 2797;
                        continue;
                    }

                    case 4:
                    {
                        this.DeviceId = "A7E8C86F-51A957BD-CD123C19-CA3E15D3-B97035C7";
                        continue;
                    }

                    case 5:
                    {
                        this.Comment = "Pocket";
                        continue;
                    }
                    }
                }
            }
            else if (cs.Id == 1)
            {
            }
        }
Exemplo n.º 2
0
        protected override IEnumerable <ConfigSection> SaveToList()
        {
            List <ConfigSection> section    = new List <ConfigSection>();
            ConfigSection        SectionAdd = new ConfigSection(0);
            ConfigItem           ItemInsert = new ConfigItem(0, true);

            section.Add(SectionAdd);
            SectionAdd.Add(ItemInsert);

            foreach (ConfigSection sec in section)
            {
                if (sec.Id == 0)
                {
                    foreach (ConfigItem itemsave in sec)
                    {
                        switch (itemsave.Tag)
                        {
                        case 0:
                        {
                            timeStamp = DateTime.Now;
                            continue;
                        }

                        case 1:
                        {
                            this.comment = "IMEI";
                            continue;
                        }

                        case 2:
                        {
                            this.customerId = 1;
                            continue;
                        }

                        case 3:
                        {
                            //-----------Set unique id ----------- //
                            this.deviceId = "";
                            continue;
                        }

                        case 4:
                        {
                            this.systemId = 2797;
                            continue;
                        }

                        case 5:
                        {
                            //---------- RSA need to sign data --------//

                            continue;
                        }
                        }
                    }
                }
                else
                {
                    LicenseOption option = new LicenseOption((LicenseOptionName)sec.Id);

                    foreach (ConfigItem ItemName in sec)
                    {
                        switch (ItemName.Tag)
                        {
                        case 0:
                        {
                            option.StartDate = DateTime.Now;
                            continue;
                        }

                        case 1:
                        {
                            option.EndDate = DateTime.MaxValue;
                            continue;
                        }
                        }
                    }
                    addOption(option);
                    section.Add(sec);
                }
            }
            return(SaveToList());
            // throw new Exception("generate license not support");
        }