public async Task <IActionResult> EditShares(Shares Shares) { db.Shares.Update(Shares); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
protected virtual void SetupAdminNotifications() { if (clusterConfig.Notifications?.Admin?.Enabled == true) { if (clusterConfig.Notifications?.Admin?.NotifyBlockFound == true) { var adminEmail = clusterConfig.Notifications.Admin.EmailAddress; var emailSender = notificationSenders .Where(x => x.Metadata.NotificationType == NotificationType.Email) .Select(x => x.Value) .First(); disposables.Add(Shares .ObserveOn(TaskPoolScheduler.Default) .Where(x => x.IsBlockCandidate) .Subscribe(async share => { try { await emailSender.NotifyAsync(adminEmail, "Block Notification", $"Pool {share.PoolId} found block candidate {share.BlockHeight}"); } catch (Exception ex) { logger.Error(ex); } })); } } }
public IList <Shares> GetAll(int plannerId) { try { Logger.LogInfo("Get: Shares process start"); IList <Shares> lstSharesOption = new List <Shares>(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL, plannerId)); foreach (DataRow dr in dtAppConfig.Rows) { Shares mf = convertToShares(dr); lstSharesOption.Add(mf); } Logger.LogInfo("Get: Shares process completed."); return(lstSharesOption); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public void Update(Share entity) { var modified = Shares.First(m => m.ShareId == entity.ShareId); modified.ShareName = entity.ShareName; modified.ShareCost = entity.ShareCost; }
protected override void SetupStats() { base.SetupStats(); // Pool Hashrate var poolHashRateSampleIntervalSeconds = 60 * 10; disposables.Add(Shares .Buffer(TimeSpan.FromSeconds(poolHashRateSampleIntervalSeconds)) .Do(shares => UpdateMinerHashrates(shares, poolHashRateSampleIntervalSeconds)) .Select(shares => { if (!shares.Any()) { return(0ul); } try { return(HashrateFromShares(shares, poolHashRateSampleIntervalSeconds)); } catch (Exception ex) { logger.Error(ex); return(0ul); } }) .Subscribe(hashRate => poolStats.PoolHashRate = hashRate)); }
public override bool IsVisible(User user) { var userId = user.Id.ToString("N"); return(Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)) || string.Equals(OwnerUserId, userId, StringComparison.OrdinalIgnoreCase)); }
public override int GetHashCode() { var hashCode = 926796717; hashCode = hashCode * -1521134295 + OrderId.GetHashCode(); hashCode = hashCode * -1521134295 + ClientId.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ExecId); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Time); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(AcctNumber); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Exchange); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Side); hashCode = hashCode * -1521134295 + Shares.GetHashCode(); hashCode = hashCode * -1521134295 + Price.GetHashCode(); hashCode = hashCode * -1521134295 + PermId.GetHashCode(); hashCode = hashCode * -1521134295 + Liquidation.GetHashCode(); hashCode = hashCode * -1521134295 + CumQty.GetHashCode(); hashCode = hashCode * -1521134295 + AvgPrice.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(OrderRef); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(EvRule); hashCode = hashCode * -1521134295 + EvMultiplier.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ModelCode); hashCode = hashCode * -1521134295 + EqualityComparer <Liquidity> .Default.GetHashCode(LastLiquidity); return(hashCode); }
public void Update(Shares Shares) { try { string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(SELECT_ID, Shares.Id)); DataBase.DBService.BeginTransaction(); DataBase.DBService.ExecuteCommandString(string.Format(UPDATE_SHARES, Shares.InvesterName, Shares.CompanyName, Shares.FaceValue, Shares.NoOfShares, Shares.MarketPrice, Shares.CurrentValue, (Shares.GoalID == null) ? null : Shares.GoalID.Value.ToString(), Shares.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), Shares.UpdatedBy, Shares.FirstHolder, Shares.SecondHolder, Shares.Nominee, Shares.InvestmentReturnRate, Shares.Id), true); Activity.ActivitiesService.Add(ActivityType.UpdateShares, EntryStatus.Success, Source.Server, Shares.UpdatedByUserName, "Shares", Shares.MachineName); DataBase.DBService.CommitTransaction(); } catch (Exception ex) { DataBase.DBService.RollbackTransaction(); StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); throw ex; } }
public IList <Share> CollectActiveShares(string _fromAddress, double _amountTransaction) { IList <Share> Shares; IList <Share> UsableShares = new List <Share>(); Share LocalShare; double amountFree = 0; IEnumerator <Share> ShareEnumerator; Shares = GetOwnerShares(_fromAddress); ShareEnumerator = Shares.GetEnumerator(); while (ShareEnumerator.MoveNext()) { LocalShare = ShareEnumerator.Current; if (!IsShareSpend(LocalShare)) { amountFree += LocalShare.Amount; UsableShares.Add(LocalShare); if (amountFree >= _amountTransaction) //If we found enough shares value to send from, break { return(UsableShares); } } } return(null); }
protected virtual void SetupStats() { LoadStats(); // Periodically persist pool- and blockchain-stats to persistent storage disposables.Add(Observable.Interval(TimeSpan.FromSeconds(60)) .Select(_ => Observable.FromAsync(async() => { try { await UpdateBlockChainStatsAsync(); } catch (Exception) { // ignored } })) .Concat() .Subscribe(_ => PersistStats())); // For external stratums, miner counts are derived from submitted shares if (poolConfig.ExternalStratum) { disposables.Add(Shares .Buffer(TimeSpan.FromMinutes(1)) .Do(shares => { var sharesByMiner = shares.GroupBy(x => x.Share.Miner).ToArray(); poolStats.ConnectedMiners = sharesByMiner.Length; }) .Subscribe()); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 23 + PositionLongShort.GetHashCode(); hash = hash * 23 + Symbol.GetHashCode(); hash = hash * 23 + Shares.GetHashCode(); if (this.EntryFilledBarIndex == -1) { return(hash); } hash = hash * 23 + EntryMarketLimitStop.GetHashCode(); hash = hash * 23 + EntryFilledBarIndex.GetHashCode(); hash = hash * 23 + EntryFilledPrice.GetHashCode(); hash = hash * 23 + EntrySignal.GetHashCode(); if (this.ExitFilledBarIndex == -1) { return(hash); } hash = hash * 23 + ExitMarketLimitStop.GetHashCode(); hash = hash * 23 + ExitFilledBarIndex.GetHashCode(); hash = hash * 23 + ExitFilledPrice.GetHashCode(); hash = hash * 23 + ExitSignal.GetHashCode(); return(hash); } }
public void TestSharesToString() { var text = string.Join(Environment.NewLine, TestData.GetPredefinedShares()) + Environment.NewLine; Shares <BigInteger> shares = text; Assert.Equal(text, shares.ToString()); }
public static void LoadShares() { if (!File.Exists("shares.json")) { return; } using (var fs = File.Open("shares.json", FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(fs)) { Shares = (ConcurrentDictionary <string, FileShare>)JsonSerializer.CreateDefault() .Deserialize(sr, typeof(ConcurrentDictionary <string, FileShare>)); } } if (Shares == null) { Shares = new ConcurrentDictionary <string, FileShare>(); } var now = DateTime.Now; foreach (var kv in Shares) { if (kv.Value.IsExpired(now)) { Shares.TryRemove(kv.Key, out _); } } }
static void Main(string[] args) { NatMgr.Init(); SimpleUdpServce simple = new SimpleUdpServce(); Console.WriteLine($"client start ip = {simple.local}"); Shares.GetShare <IEnv>().value = EnvEnum.Client; simple.Start(); Console.WriteLine("nat start"); var remote = new IPEndPoint(IPAddress.Parse("123.118.106.73"), 25410); //using (Socket natSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) //{ // natSocket.Bind(new IPEndPoint(IPAddress.Any, 25410)); // natSocket.SendTo(ResNat.SUCCESS.ToByteArray(), remote); //} simple.Send(new ReqNat() { address = remote.ValueAddress() }, new IPEndPoint(IPAddress.Parse("47.105.195.93"), 12000)); //for (int i = 1; i < ushort.MaxValue; i++) //{ // simple.Send(ResNat.SUCCESS, new IPEndPoint(IPAddress.Parse("123.118.106.73"), i)); //} Console.WriteLine("nat end"); for (int i = 0; i < 10; i++) { Thread.Sleep(500); simple.Send(ResNat.NO_SERVER_FOUND, new IPEndPoint(IPAddress.Parse("123.118.106.73"), 25410)); } Thread.Sleep(-1); }
public void Load() { lock (downloadQueue) { try { if (File.Exists(DATA_FOLDER + saveLocation)) { var saved = SafeLoad <Model>(saveLocation); Shares.Clear(); Shares.AddRange(saved.Shares.OrderBy(s => s.Name).ToList()); Avatar = saved.Avatar; Description = saved.Description; Nickname = saved.Nickname; DownloadFolder = saved.DownloadFolder; MaxDownloads = saved.MaxDownloads; MaxDownloadsPerUser = saved.MaxDownloadsPerUser; MaxUploads = saved.MaxUploads; MaxUploadsPerUser = saved.MaxUploadsPerUser; DisableComparision = saved.DisableComparision; LocalNode = saved.LocalNode; AlwaysNoCacheBrowsing = saved.AlwaysNoCacheBrowsing; OverlordPriority = saved.OverlordPriority; DisplayedHelp = saved.DisplayedHelp; } else if (File.Exists(Legacy.Model.saveLocation)) { //New config doesnt exist but an older version does, try to import. var oldmodel = new Legacy.Model(); oldmodel.Load(); Shares.Clear(); Shares.AddRange(oldmodel.Shares.OrderBy(s => s.Name).ToList()); Avatar = oldmodel.Avatar; Description = oldmodel.Description; Nickname = oldmodel.Nickname; DownloadFolder = oldmodel.DownloadFolder; MaxDownloads = oldmodel.MaxDownloads; MaxDownloadsPerUser = oldmodel.MaxDownloadsPerUser; MaxUploads = oldmodel.MaxUploads; MaxUploadsPerUser = oldmodel.MaxUploadsPerUser; DisableComparision = oldmodel.DisableComparision; LocalNode = new Node(); foreach (var data in oldmodel.Node.Data) { LocalNode.SetData(data.Key, data.Value); } AlwaysNoCacheBrowsing = oldmodel.AlwaysNoCacheBrowsing; OverlordPriority = OverlordPriority.Normal; Save(); } } catch (Exception e) { LogManager.GetLogger("faplog").Warn("Failed to read config", e); } } }
public void ToString_InvokeNonZero_ReturnsSummary() { var shares = new Shares() { Count = 10 }; Assert.Equal("10", shares.ToString()); }
public void CreateShares() { string [] shares = _algorithm.Share(Phrase, Threshold, NumberOfShares); Shares.Clear(); foreach (var sh in shares) { ShareName shareName = new ShareName(sh); Shares.Add(shareName); } }
public void Sell(string stock, int quantity) { if (!Shares.ContainsKey(stock)) { return; } Shares[stock] = Shares[stock] - quantity; Orders[stock] = quantity; }
public void Buy(string stock, int quantity) { if (Shares.ContainsKey(stock)) { Shares[stock] = Shares[stock] + quantity; } else { Shares[stock] = quantity; } }
public static string AddShare(FileShare share) { var key = ""; do { key = CryptoHelper.ToSafe64String(Guid.NewGuid().ToByteArray()); } while (Shares.ContainsKey(key)); return(Shares.TryAdd(key, share) ? key : null); }
public override int GetHashCode() { unchecked { var hashCode = StringComparer.InvariantCultureIgnoreCase.GetHashCode(Ticker); hashCode = (hashCode * 397) ^ Shares.GetHashCode(); hashCode = (hashCode * 397) ^ PurchasePrice.GetHashCode(); hashCode = (hashCode * 397) ^ StringComparer.InvariantCultureIgnoreCase.GetHashCode(PurchaseDate); return(hashCode); } }
public void Sell(Person seller, double summ) { if (seller.Balance >= summ) { for (int i = 0; i < summ / DefaultPrice; i++) { seller.PersonalShares.RemoveAt(0); Shares.Add(new Share(DefaultPrice)); } seller.Balance += summ; } }
public void AddShares(IDictionary <string, double> shares) { foreach (var pair in shares) { Shares.Add(pair.Key, pair.Value); } if (Block.Status == BlockStatus.Confirmed) { CalculatePayouts(); } }
public async Task <IActionResult> ConfirmDeleteShares(int?id) { if (id != null) { Shares Shares = await db.Shares.Include(p => p.Groups).FirstOrDefaultAsync(p => p.ShareId == id); if (Shares != null) { return(View(Shares)); } } return(NotFound()); }
public Task BuyAsync(string stock, int quantity) { if (Shares.ContainsKey(stock)) { Shares[stock] = Shares[stock] + quantity; } else { Shares[stock] = quantity; } return(Task.CompletedTask); }
public ActionResult ShareAPage(Shares share) { Shares sh = new Shares(); ViewBag.PageId = new SelectList(db.PostPages.Where(c => c.CreatedBy == User.Identity.Name).ToList(), "Id", "Title"); sh.Message = share.Message; sh.SharedBy = User.Identity.Name; sh.SharedTo = share.SharedTo; sh.PageId = share.PageId; db.Shares.Add(sh); db.SaveChanges(); return(RedirectToAction("Index")); }
private void CalculatePayouts() { var totalShares = Shares.Sum(pair => pair.Value); // total shares. // calculate per worker amounts. foreach (var pair in Shares) { var percent = pair.Value / totalShares; var workerRewardInSatoshis = (decimal)percent * Block.Reward; Payouts.Add(pair.Key, workerRewardInSatoshis); } }
public void Buy(Person buyer, double summ) { if ((buyer.Balance >= summ)) { for (int j = 0; j < summ / DefaultPrice; j++) { buyer.PersonalShares.Add(new Share(DefaultPrice)); Shares.RemoveAt(Shares.Count - 1); } buyer.Balance -= summ; CountShares -= summ / DefaultPrice; } }
/// <summary> /// Wire interval based vardiff updates for client /// WARNING: Assumes to be invoked with lock held on context.VarDiff /// </summary> private void StartVarDiffIdleUpdate(StratumClient client, PoolEndpoint poolEndpoint) { // Check Every Target Time as we adjust the diff to meet target // Diff may not be changed , only be changed when avg is out of the range. // Diff must be dropped once changed. Will not affect reject rate. var interval = poolEndpoint.VarDiff.TargetTime; Observable .Timer(TimeSpan.FromSeconds(interval)) .TakeUntil(Shares.Where(x => x.Client == client)) .Take(1) .Where(x => client.IsAlive) .Subscribe(_ => UpdateVarDiff(client, true)); }
public void SaveChanges(Share share) { SaveChanges <Share>(share); for (int i = 0; i < Shares.Count; i++) { if (Shares[i].Identifier == share.Identifier) { Shares.RemoveAt(i); Shares.Insert(i, share); return; } } Shares.Add(share); }