예제 #1
0
        public bool Delete(RegistrationRecord record)
        {
            try
            {
                Delete(record.RecordGuid);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        public void AddCapsule(RegistrationCapsule capsule, Network network)
        {
            RegistrationToken token = new RegistrationToken();

            token.ParseTransaction(capsule.RegistrationTransaction, network);
            RegistrationRecord record = new RegistrationRecord(DateTime.Now,
                                                               Guid.NewGuid(),
                                                               capsule.RegistrationTransaction.GetHash().ToString(),
                                                               capsule.RegistrationTransaction.ToHex(),
                                                               token,
                                                               capsule.RegistrationTransactionProof);

            Add(record);
        }
예제 #3
0
        /// <summary>
        /// Checks if the server ID in the supplied record already exists in the store,
        /// and removes all other records before adding.
        /// </summary>
        /// <param name="regRecord"></param>
        /// <returns></returns>
        public bool AddWithReplace(RegistrationRecord regRecord)
        {
            foreach (RegistrationRecord record in GetByServerId(regRecord.Record.ServerId))
            {
                Delete(record.RecordGuid);
            }

            lock (RegistrationStore.lock_object)
            {
                List <RegistrationRecord> registrations = GetRecordsOrCreateFile();

                registrations.Add(regRecord);

                string regJson = JsonConvert.SerializeObject(registrations);
                File.WriteAllText(StorePath, regJson);

                return(true);
            }
        }
예제 #4
0
        public bool Add(RegistrationRecord regRecord)
        {
            lock (RegistrationStore.lock_object)
            {
                List <RegistrationRecord> registrations = GetRecordsOrCreateFile();

                registrations.Add(regRecord);

                //JsonSerializerSettings settings = new JsonSerializerSettings();
                //settings.Converters.Add(new IPAddressConverter());
                //settings.Formatting = Formatting.Indented;

                //JsonSerializerSettings isoDateFormatSettings = new JsonSerializerSettings
                //{
                //    DateFormatHandling = DateFormatHandling.IsoDateFormat
                //};

                string regJson = JsonConvert.SerializeObject(registrations);
                File.WriteAllText(StorePath, regJson);

                return(true);
            }
        }