public bool IsLockStillAquired() { Store.RedisDB lockDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); bool result = lockDb.DataBase.KeyExists(this.m_MasterAccessionNo); return(result); }
private void Build() { List <AccessionLock> list = new List <AccessionLock>(); Store.RedisDB locksDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); RedisResult[] redisResult = (RedisResult[])locksDb.GetAllHashes(); foreach (RedisValue[] r in redisResult) { HashEntry he1 = new HashEntry(r[0], r[1]); HashEntry he2 = new HashEntry(r[2], r[3]); HashEntry he3 = new HashEntry(r[4], r[5]); AccessionLock item = new AccessionLock(new HashEntry[] { he1, he2, he3 }); list.Add(item); } list.Sort(delegate(AccessionLock x, AccessionLock y) { if (x.TimeAquired > y.TimeAquired) { return(1); } else { return(-1); } }); foreach (AccessionLock item in list) { this.Add(item); } }
private void GetHash() { Store.RedisDB lockDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); HashEntry[] hashFields = lockDb.DataBase.HashGetAll(this.m_MasterAccessionNo); this.m_MasterAccessionNo = hashFields[0].Value; this.m_Address = hashFields[1].Value; this.m_TimeAquired = DateTime.Parse(hashFields[2].Value); this.NotifyPropertyChanged(string.Empty); }
public void TransferLock(string address) { HashEntry[] hashFields = new HashEntry[3]; hashFields[0] = new HashEntry("MasterAccessionNo", this.MasterAccessionNo); hashFields[1] = new HashEntry("Address", address); hashFields[2] = new HashEntry("TimeAquired", DateTime.Now.ToString()); Store.RedisDB lockDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); lockDb.DataBase.HashSet(this.m_MasterAccessionNo, hashFields); this.m_Address = address; this.m_TimeAquired = DateTime.Now; this.NotifyPropertyChanged(string.Empty); }
public void ReleaseLock() { this.m_Address = null; this.m_TimeAquired = null; Store.RedisDB scanDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); var transaction = scanDb.DataBase.CreateTransaction(); transaction.AddCondition(Condition.HashExists(this.m_MasterAccessionNo, "MasterAccessionNo")); transaction.KeyDeleteAsync(this.m_MasterAccessionNo); bool committed = transaction.Execute(); this.NotifyPropertyChanged(string.Empty); }
private void TryHashSet() { HashEntry[] hashFields = new HashEntry[3]; hashFields[0] = new HashEntry("MasterAccessionNo", this.m_MasterAccessionNo); hashFields[1] = new HashEntry("Address", UI.AppMessaging.AccessionLockMessage.GetMyAddress()); hashFields[2] = new HashEntry("TimeAquired", DateTime.Now.ToString()); Store.RedisDB lockDb = Store.AppDataStore.Instance.RedisStore.GetDB(Store.AppDBNameEnum.Lock); var transaction = lockDb.DataBase.CreateTransaction(); transaction.AddCondition(Condition.HashNotExists(this.m_MasterAccessionNo, "MasterAccessionNo")); transaction.HashSetAsync(this.m_MasterAccessionNo, hashFields); bool committed = transaction.Execute(); }
private void HandleJSON(YellowstonePathology.Store.AppDBNameEnum db, string keyField, string path) { JsonSerializerSettings camelCaseFormatter = new JsonSerializerSettings(); camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); Store.RedisDB redisDb = Store.AppDataStore.Instance.RedisStore.GetDB(db); foreach (string jString in (string[])redisDb.GetAllJSONKeys()) { JObject jObject = JsonConvert.DeserializeObject <JObject>(jString); string name = jObject[keyField].ToString().ToLower(); if (string.IsNullOrEmpty(name) == true) { name = "nullId"; } string fileName = name + ".json"; using (StreamWriter sw = new StreamWriter(path + @"\" + fileName, false)) { string formatted = JsonConvert.SerializeObject(jObject, Formatting.Indented, camelCaseFormatter); sw.Write(formatted); } } }