예제 #1
0
 public void SetCoinKernelProfileProperty(Guid workId, Guid coinKernelId, string propertyName, object value)
 {
     if (!CoinKernelProfileProperties.ContainsKey(propertyName))
     {
         return;
     }
     using (var database = CreateDatabase(workId)) {
         var  col   = database.GetCollection <CoinKernelProfileData>();
         var  data  = col.FindById(coinKernelId);
         bool exist = true;
         if (data == null)
         {
             exist = false;
             data  = CoinKernelProfileData.CreateDefaultData(coinKernelId);
         }
         PropertyInfo propertyInfo = CoinKernelProfileProperties[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);
         }
     }
 }
예제 #2
0
                public static CoinKernelProfile Create(INTMinerRoot root, Guid coinKernelId)
                {
                    if (root.CoinKernelSet.TryGetCoinKernel(coinKernelId, out ICoinKernel coinKernel))
                    {
                        var data = GetCoinKernelProfileData(coinKernel.GetId());
                        if (data == null)
                        {
                            data = CoinKernelProfileData.CreateDefaultData(coinKernel.GetId());
                        }
                        CoinKernelProfile coinProfile = new CoinKernelProfile(data);

                        var    defaultInputSegments = coinKernel.InputSegments.Where(a => a.IsDefault && a.TargetGpu.IsSupportedGpu(NTMinerRoot.Instance.GpuSet.GpuType)).ToArray();
                        string touchedArgs          = coinProfile.TouchedArgs;
                        if (coinProfile.CustomArgs == null)
                        {
                            coinProfile.CustomArgs = string.Empty;
                        }
                        if (string.IsNullOrEmpty(touchedArgs))
                        {
                            foreach (var defaultInputSegment in defaultInputSegments)
                            {
                                if (!coinProfile.CustomArgs.Contains(defaultInputSegment.Segment))
                                {
                                    if (coinProfile.CustomArgs.Length == 0)
                                    {
                                        coinProfile.CustomArgs += defaultInputSegment.Segment;
                                    }
                                    else
                                    {
                                        coinProfile.CustomArgs += " " + defaultInputSegment.Segment;
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var defaultInputSegment in defaultInputSegments)
                            {
                                if (!touchedArgs.Contains(defaultInputSegment.Segment) && !coinProfile.CustomArgs.Contains(defaultInputSegment.Segment))
                                {
                                    if (coinProfile.CustomArgs.Length == 0)
                                    {
                                        coinProfile.CustomArgs += defaultInputSegment.Segment;
                                    }
                                    else
                                    {
                                        coinProfile.CustomArgs += " " + defaultInputSegment.Segment;
                                    }
                                }
                            }
                        }
                        return(coinProfile);
                    }
                    else
                    {
                        return(Empty);
                    }
                }
예제 #3
0
                private static CoinKernelProfileData GetCoinKernelProfileData(Guid coinKernelId)
                {
                    IRepository <CoinKernelProfileData> repository = NTMinerRoot.CreateLocalRepository <CoinKernelProfileData>();
                    var result = repository.GetByKey(coinKernelId);

                    if (result == null)
                    {
                        result = CoinKernelProfileData.CreateDefaultData(coinKernelId);
                    }
                    return(result);
                }
예제 #4
0
                private static CoinKernelProfileData GetCoinKernelProfileData(MineWorkData mineWorkData, Guid coinKernelId)
                {
                    bool isUseJson = mineWorkData != null;
                    IRepository <CoinKernelProfileData> repository = NTMinerRoot.CreateLocalRepository <CoinKernelProfileData>(isUseJson);
                    var result = repository.GetByKey(coinKernelId);

                    if (result == null)
                    {
                        result = CoinKernelProfileData.CreateDefaultData(coinKernelId);
                    }
                    return(result);
                }
예제 #5
0
 public CoinKernelProfileData GetCoinKernelProfile(Guid workId, Guid coinKernelId)
 {
     using (var database = CreateDatabase(workId)) {
         var col  = database.GetCollection <CoinKernelProfileData>();
         var data = col.FindById(coinKernelId);
         if (data == null)
         {
             data = CoinKernelProfileData.CreateDefaultData(coinKernelId);
             col.Insert(data);
         }
         return(data);
     }
 }
예제 #6
0
 private CoinKernelProfileData GetCoinKernelProfileData(Guid coinKernelId)
 {
     if (CommandLineArgs.IsWorker)
     {
         return(Server.ProfileService.GetCoinKernelProfile(CommandLineArgs.WorkId, coinKernelId));
     }
     else
     {
         IRepository <CoinKernelProfileData> repository = NTMinerRoot.CreateLocalRepository <CoinKernelProfileData>();
         var result = repository.GetByKey(coinKernelId);
         if (result == null)
         {
             result = CoinKernelProfileData.CreateDefaultData(coinKernelId);
         }
         return(result);
     }
 }
예제 #7
0
                public static CoinKernelProfile Create(INTMinerRoot root, MineWorkData mineWorkData, Guid coinKernelId)
                {
                    if (root.CoinKernelSet.TryGetCoinKernel(coinKernelId, out ICoinKernel coinKernel))
                    {
                        var data = GetCoinKernelProfileData(mineWorkData, coinKernel.GetId());
                        if (data == null)
                        {
                            data = CoinKernelProfileData.CreateDefaultData(coinKernel.GetId());
                        }
                        CoinKernelProfile coinProfile = new CoinKernelProfile(mineWorkData, data);

                        return(coinProfile);
                    }
                    else
                    {
                        return(Empty);
                    }
                }
                public static CoinKernelProfile Create(INTMinerRoot root, Guid coinKernelId)
                {
                    if (root.ServerContext.CoinKernelSet.TryGetCoinKernel(coinKernelId, out ICoinKernel coinKernel))
                    {
                        var repository             = NTMinerRoot.CreateLocalRepository <CoinKernelProfileData>();
                        CoinKernelProfileData data = repository.GetByKey(coinKernelId);
                        if (data == null)
                        {
                            double dualCoinWeight = GetDualCoinWeight(root, coinKernel.KernelId);
                            data = CoinKernelProfileData.CreateDefaultData(coinKernel.GetId(), dualCoinWeight);
                        }
                        if (root.ServerContext.GroupSet.TryGetGroup(coinKernel.DualCoinGroupId, out IGroup group))
                        {
                            var coinIds = root.ServerContext.CoinGroupSet.GetGroupCoinIds(coinKernel.DualCoinGroupId);
                            if (!coinIds.Contains(data.DualCoinId))
                            {
                                data.DualCoinId = coinIds.FirstOrDefault();
                            }
                        }
                        CoinKernelProfile coinProfile = new CoinKernelProfile(data);

                        var    defaultInputSegments = coinKernel.InputSegments.Where(a => a.IsDefault && a.TargetGpu.IsSupportedGpu(NTMinerRoot.Instance.GpuSet.GpuType)).ToArray();
                        string touchedArgs          = coinProfile.TouchedArgs;
                        if (coinProfile.CustomArgs == null)
                        {
                            coinProfile.CustomArgs = string.Empty;
                        }
                        if (string.IsNullOrEmpty(touchedArgs))
                        {
                            foreach (var defaultInputSegment in defaultInputSegments)
                            {
                                if (!coinProfile.CustomArgs.Contains(defaultInputSegment.Segment))
                                {
                                    if (coinProfile.CustomArgs.Length == 0)
                                    {
                                        coinProfile.CustomArgs += defaultInputSegment.Segment;
                                    }
                                    else
                                    {
                                        coinProfile.CustomArgs += " " + defaultInputSegment.Segment;
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var defaultInputSegment in defaultInputSegments)
                            {
                                if (!touchedArgs.Contains(defaultInputSegment.Segment) && !coinProfile.CustomArgs.Contains(defaultInputSegment.Segment))
                                {
                                    if (coinProfile.CustomArgs.Length == 0)
                                    {
                                        coinProfile.CustomArgs += defaultInputSegment.Segment;
                                    }
                                    else
                                    {
                                        coinProfile.CustomArgs += " " + defaultInputSegment.Segment;
                                    }
                                }
                            }
                        }
                        return(coinProfile);
                    }
                    else
                    {
                        return(Empty);
                    }
                }