Exemplo n.º 1
0
 public void SetMinerProfileProperty(Guid workId, string propertyName, object value)
 {
     if (!MinerProfileProperties.ContainsKey(propertyName))
     {
         return;
     }
     using (var database = CreateDatabase(workId)) {
         var  col   = database.GetCollection <MinerProfileData>();
         var  data  = col.FindAll().FirstOrDefault();
         bool exist = true;
         if (data == null)
         {
             exist = false;
             data  = MinerProfileData.CreateDefaultData();
         }
         PropertyInfo propertyInfo = MinerProfileProperties[propertyName];
         if (propertyInfo.PropertyType == typeof(Guid))
         {
             value = DictionaryExtensions.ConvertToGuid(value);
         }
         propertyInfo.SetValue(data, value, null);
         if (exist)
         {
             data.ModifiedOn = DateTime.Now;
             col.Update(data);
         }
         else
         {
             col.Insert(data);
         }
     }
 }
Exemplo n.º 2
0
        public void UpdateClients(string propertyName, Dictionary <string, object> values)
        {
            InitOnece();
            PropertyInfo propertyInfo = typeof(ClientData).GetProperty(propertyName);

            if (propertyInfo != null)
            {
                if (propertyInfo.PropertyType == typeof(Guid))
                {
                    foreach (var kv in values)
                    {
                        values[kv.Key] = DictionaryExtensions.ConvertToGuid(kv.Value);
                    }
                }
                foreach (var kv in values)
                {
                    string objectId = kv.Key;
                    object value    = kv.Value;
                    if (_dicByObjectId.TryGetValue(objectId, out ClientData clientData))
                    {
                        propertyInfo.SetValue(clientData, value, null);
                        clientData.ModifiedOn = DateTime.Now;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void SetPoolProfileProperty(Guid workId, Guid poolId, string propertyName, object value)
 {
     if (!PoolProfileProperties.ContainsKey(propertyName))
     {
         return;
     }
     using (var database = CreateDatabase(workId)) {
         var  col   = database.GetCollection <PoolProfileData>();
         var  data  = col.FindById(poolId);
         bool exist = true;
         if (data == null)
         {
             exist = false;
             data  = PoolProfileData.CreateDefaultData(poolId);
         }
         PropertyInfo propertyInfo = PoolProfileProperties[propertyName];
         if (propertyInfo.PropertyType == typeof(Guid))
         {
             value = DictionaryExtensions.ConvertToGuid(value);
         }
         propertyInfo.SetValue(data, value, null);
         if (exist)
         {
             col.Update(data);
         }
         else
         {
             col.Insert(data);
         }
     }
 }
Exemplo n.º 4
0
 public void UpdateClient(string objectId, string propertyName, object value)
 {
     InitOnece();
     if (_dicByObjectId.TryGetValue(objectId, out ClientData clientData))
     {
         PropertyInfo propertyInfo = typeof(ClientData).GetProperty(propertyName);
         if (propertyInfo != null)
         {
             if (propertyInfo.PropertyType == typeof(Guid))
             {
                 value = DictionaryExtensions.ConvertToGuid(value);
             }
             propertyInfo.SetValue(clientData, value, null);
             clientData.ModifiedOn = DateTime.Now;
         }
     }
 }