public async Task CheckRaisedChainInfoUpdatedAsync() { var wallet = new Wallet(); await wallet.StartAsync(); Assert.True(wallet.IsConnected); Assert.IsTrue(wallet.Load("dev_wallet")); ChainInfo test = null; void OnChainInfoUpdated(object sender, ChainInfo chainInfo) { test = chainInfo; } wallet.ChainInfoUpdated += OnChainInfoUpdated; Thread.Sleep(5000); Assert.IsNotNull(test); Assert.AreEqual("DOTMog Node", test.Name); wallet.ChainInfoUpdated -= OnChainInfoUpdated; }
public Container2(SolveAndStoreOD_2T solveAndStoreOD, ChainInfo chainInfo, TickerInfo tickerInfo) { SolveAndStoreOD = solveAndStoreOD; ChainInfo = chainInfo; TickerInfo = tickerInfo; //FT[] _FTColl = { _fT_CN, _fT_CU }; }
public PurchaseListPage(BuyPurchasePage purchasePage, ChainInfo chainInfo) : base("PurchaseListPage") { _purchasePage = purchasePage; AddTitleRow("Title"); AddHeaderRow("Purchases"); var list = new List <PurchaseInfo>(); foreach (var purchase in chainInfo.GetChainPurchases()) { if (!purchase.IsRevoked) { list.Add(purchase.Item); } } if (list.Count > 0) { list.Sort((a, b) => a.PurchaseItemId.CompareTo(b.PurchaseItemId)); foreach (var item in list) { var view = new PurchaseInfoView(item); AddButtonViewRow(view, SetPurchase).Tag = item; } } else { AddTextRow("NoPurchases"); } AddFooterRow(); }
private void AddChainMailsToCrmHistory(DbManager db, ChainInfo chainInfo, int tenant, string user, List <CrmContactEntity> contactIds) { var searchFolders = new List <int> { MailFolder.Ids.inbox, MailFolder.Ids.sent }; var selectChainedMails = GetQueryForChainMessagesSelection(chainInfo.mailbox, chainInfo.id, searchFolders); var crmDal = new CrmHistoryDal(tenant, user); var linkingMessages = db.ExecuteList(selectChainedMails) .ConvertAll(record => { var item = GetMailInfo(db, tenant, user, Convert.ToInt32(record[0]), true, true); item.LinkedCrmEntityIds = contactIds; return(item); }); foreach (var message in linkingMessages) { try { crmDal.AddRelationshipEvents(message); } catch (ApiHelperException ex) { if (!ex.Message.Equals("Already exists")) { throw; } } } }
private ActionChain BuildChain(ChainInfo chainInfo) { if (chainInfo == null) { return(null); } return(BuildChain(chainInfo.entry, chainInfo.actions, new Dictionary <string, Workflows.ActionChain>())); }
public ArrayList CalcColorChain(EPoint a_pntLoc) { m_aCurrentChainInfo = new ChainInfo(); Ball ball = GetBallOnLoc(a_pntLoc); RecursiveCalcColorChain(ball); return m_aCurrentChainInfo.Balls; // return duplicate(currentChain) }
public async Task <bool> SetTargetChain(int chainId) { if (ChainInfo != null && ChainInfo.ChainId != chainId) { ChainInfo = null; } if (ChainInfo == null) { ChainInfo = (await DownloadChainInfo(chainId)).Data; } var endPoints = ChainInfo?.GetPublicEndpoints() ?? new List <string>(); if (!(_forceDefaults && chainId == _defaultChainId)) { if (endPoints == null || endPoints.Count == 0) { Log.Trace("Chain has no valid public endpoints.", this); return(false); } } ChainId = chainId; var alreadyConnected = false; foreach (var endpoint in endPoints) { var uri = new Uri(endpoint); if (ChainEndPoint == uri) { alreadyConnected = true; break; } } if (!alreadyConnected && _forceDefaults && ChainId == _defaultChainId) { alreadyConnected = ChainEndPoint == _defaultEndPoint; } if (!alreadyConnected) { if (_forceDefaults && ChainId == _defaultChainId) { ChainEndPoint = _defaultEndPoint; } else { ChainEndPoint = new Uri(endPoints[Rand.NextInt(endPoints.Count)]); } await EndpointChanged(); } return(true); }
public ArrayList CalcColorChain(EPoint a_pntLoc) { m_aCurrentChainInfo = new ChainInfo(); Ball ball = GetBallOnLoc(a_pntLoc); RecursiveCalcColorChain(ball); return(m_aCurrentChainInfo.Balls); // return duplicate(currentChain) }
public ChainInfoView(ChainInfo chainInfo = null) : base("ChainInfoView") { (_, _name) = AddRow("Name", ""); (_, _website) = AddRow("Website", ""); (_, _revenue) = AddRow("Revenue", ""); (_, _account) = AddLastRow("Account", ""); Update(chainInfo); }
// 체인리스트 관련 함수. // 새로운 체인 정보 추가. 들어가는 정보는 시전자, 적용범위, 스킬인덱스. public static void AddChains(GameObject unit, List <GameObject> targetArea, int skillIndex) { List <ChainInfo> chainList = FindObjectOfType <BattleManager>().GetChainList(); ChainInfo newChainInfo = new ChainInfo(unit, targetArea, skillIndex); chainList.Add(newChainInfo); SetChargeEffectToUnit(unit, "darkCharge"); }
public static void AdvancedChain() { //The generic chain takes a vertex factory, edge factory and identity provider. //Pass the default implementation of any parameters you want default behaviour for //The factory and identity provider implementations must match the identity type of the chain (eg Guid) Chain <Guid> chainHelper = new Chain <Guid>(new StatefulVertexFactory <VertexState>(new EnumState(VertexState.HEALTHY)), new DefaultEdgeFactory(), new DefaultIdentityProvider()); //The chain helper can then be used as normal ChainInfo <Guid> chain = chainHelper.Create(10, false); }
public void ActiveChain(int range, ChainInfo info = new ChainInfo()) { var chainTiles = GetChain(range, info.Cost, info.IgnoreCond); foreach (var tile in chainTiles) { if (tile != null) { tile.ChangeState <State_Active>(info.ActiveTileImage); } } }
public ServiceBlockGenerator(CoreChain coreChain, ServiceChain serviceChain, MaintainChain maintainChain, ServiceBlock lastBlock) { ChainId = serviceChain.ChainId; _blockInfo = new ServiceBlockInfo(serviceChain); _coreChain = coreChain; _serviceChain = serviceChain; _maintainChain = maintainChain; _lastBlock = lastBlock; _chainInfo = coreChain.GetChainInfo(ChainId); _blockState = _chainInfo.LastState; }
public bool TryDoReorganisations(int blockNumber, out ChainInfo last) { if (Reorganisations.TryGetValue(blockNumber, out var chainInfo)) { _last = last = Current; Current = chainInfo; Reorganisations.Remove(blockNumber); return(true); } last = null; return(false); }
public void Verify_Chain_MutantAtSecond_p0Fixation() { ChainInfo <Guid> chainInfo = (new Chain <Guid>(new StatefulVertexFactory <VertexState>(new EnumState(VertexState.HEALTHY)), new DefaultEdgeFactory(), new DefaultIdentityProvider())) .Create(50, true); ((StatefulVertex <Guid, VertexState>)chainInfo.StartOfChain.NextVertex.Vertex).State.ChangeStateValue(VertexState.MUTANT); MoranProcessResult result = runner.RunOn(chainInfo.Graph, Repetitions, Iterations, 3.0d); Assert.AreEqual(result.FixationProbability, 0.0d); Assert.AreEqual(result.ExtinctionProbability, 1.0d); }
private static ChainInfo FindClosestPolarNeighbor(ChainInfo baseInfo, IEnumerable <ChainInfo> possibleNeighbors) { var closestDot = -2f; ChainInfo closestNeighbor = null; foreach (var possibleNeighbor in possibleNeighbors) { var currentDot = Vector2.Dot(baseInfo.baseVector, possibleNeighbor.baseVector); if (currentDot >= closestDot) { closestDot = currentDot; closestNeighbor = possibleNeighbor; } } return(closestNeighbor); }
public static void Show(Unit unit) { BattleManager battleManager = GameObject.FindObjectOfType <BattleManager>(); BattleData battleData = battleManager.battleData; ChainInfo chainInfo = battleData.GetChainInfo(unit); if (chainInfo == null) { return; } List <GameObject> targetArea = chainInfo.GetTargetArea(); battleData.tileManager.PaintTiles(targetArea, TileColor.Yellow); }
public async Task <Download <ChainInfo> > DownloadChainInfo(int chainId) { try { var data = await DownloadBinary($"dynamic/{GetChainTypeName(ChainType.Core)}/chaininfo/{chainId}/result.data"); using (var unpacker = new Unpacker(data)) { var chainInfo = new ChainInfo(unpacker); return(new Download <ChainInfo>(chainInfo)); } } catch (Exception exception) { return(Download <ChainInfo> .HandleException(exception)); } }
// 자신이 건 체인 삭제. public static void RemoveChainsFromUnit(GameObject unit) { List <ChainInfo> chainList = FindObjectOfType <BattleManager>().GetChainList(); ChainInfo deleteChainInfo = chainList.Find(x => x.GetUnit() == unit); if (deleteChainInfo == null) { Debug.LogWarning(unit.GetComponent <Unit>().GetName() + "'s chainInfo is null"); } else { chainList.Remove(deleteChainInfo); } RemoveChargeEffectToUnit(unit); }
private void AddChainMailsToCrmHistory(DbManager db, ChainInfo chainInfo, int tenant, string user, List <CrmContactEntity> contactIds) { var searchFolders = new List <int> { MailFolder.Ids.inbox, MailFolder.Ids.sent }; var selectChainedMails = GetQueryForChainMessagesSelection(chainInfo.mailbox, chainInfo.id, searchFolders); var crmDal = new CrmHistoryDal(tenant, user); db.ExecuteList(selectChainedMails) .ConvertAll(record => { var item = GetMailInfo(db, tenant, user, Convert.ToInt32(record[0]), true, true); item.LinkedCrmEntityIds = contactIds; return(item); }) .ForEach(crmDal.AddRelationshipEvents); }
public static async Task RegisterChain(string chainName, string chainWebsite, WalletClient.ChainKey[] chainKeys, Uri[] endPoints, PurchaseInfo[] purchases) { if (CurrentCoreAccount == null) { return; } HeleusClientResponse result = null; ChainInfo chainInfo = null; if (_busy) { result = new HeleusClientResponse(HeleusClientResultTypes.Busy); goto end; } _busy = true; try { if (!await Client.SetTargetChain(Protocol.CoreChainId)) { result = new HeleusClientResponse(HeleusClientResultTypes.EndpointConnectionError); goto end; } result = await Client.RegisterChain(chainName, chainWebsite, chainKeys, endPoints, purchases); if (result.TransactionResult == TransactionResultTypes.Ok) { chainInfo = (await Client.DownloadChainInfo((result.Transaction as ChainInfoOperation).ChainId)).Data; } } catch (Exception ex) { Log.IgnoreException(ex); } end: await UIApp.PubSub.PublishAsync(new ChainRegistrationEvent(result, chainInfo)); if (result.ResultType != HeleusClientResultTypes.Busy) { _busy = false; } }
protected override void QueryDone(int chainId, ChainInfo chainInfo) { _export.Edit.Text = null; _keyView.Update(null); UIApp.Run(async() => { var coreAccount = WalletApp.CurrentCoreAccount; if (WalletApp.IsCoreAccountUnlocked) { var secretKey = await PassphraseSecretKeyInfo.NewPassphraseSecretKey(chainId, $"{Hex.ToString(coreAccount.RawData)}.{coreAccount.AccountId}"); var key = await Task.Run(() => Key.GenerateEd25519(secretKey.SecretHash)); var encryption = await Task.Run(() => Encryption.GenerateAes256(key.Data, _derivedPassword)); _keyView.Update(key); } }); }
public static void BaiscChain() { //The non-generic chain is an implementation of Chain<Guid> //which uses DefaultVertexFactory, DefaultEdgeFactory and DefaultIdentityProvider Chain chainHelper = new Chain(); //The identity type must be specified because type inference can't help here ChainInfo <Guid> chain = chainHelper.Create(10, false); //Can get the vertex at the start of the chain from the chain info ChainPart <Guid> start = chain.StartOfChain; //Can navigate through the chain using NextVertex property //The vertex itself is the Vertex property Vertex <Guid> nextVertex = start.NextVertex.Vertex; //Can get the graph representing the chain from the Graph property Graph <Guid> chainGraph = chain.Graph; }
protected override async Task QueryDoneAsync(int chainId, ChainInfo chainInfo) { _revenueInfo = null; if (chainInfo != null) { var endPoints = chainInfo.GetPublicEndpoints(); if (endPoints.Count > 0) { var client = new ClientBase(new Uri(endPoints[0]), chainId); var download = (await client.DownloadRevenueInfo(chainId, WalletApp.CurrentAccountId)); var data = download.Data; _revenueInfo = data?.Item; if (_revenueInfo == null) { await ErrorAsync("QueryRevenueFailed"); } } } _revenueView.Update(_revenueInfo); }
public void InitChain(string dbpath, ChainInfo info) { if (this.db != null) { throw new Exception("already had inited."); } db = new db.simple.DB(); db.Open(dbpath, true); var blockcount = db.GetUInt64Direct(TableID_SystemInfo, Key_SystemInfo_BlockCount); if (blockcount == 0) { //insert first block //first block 会有几笔特殊交易 //设置magicinfo //设置初始见证人 //发行默认货币PET var block = new block.Block(); db.PutDirect(TableID_Blocks, BitConverter.GetBytes(blockcount), block.ToBytes()); } }
public void Update(ChainInfo chainInfo) { if (chainInfo != null) { _account.Text = chainInfo.AccountId.ToString(); _name.Text = chainInfo.Name; _website.Text = !string.IsNullOrEmpty(chainInfo.Website) ? chainInfo.Website : "-"; var revenue = 0; var revenueInfo = chainInfo.CurrentRevenueInfo; if (revenueInfo != null) { revenue = revenueInfo.AccountRevenueFactor * revenueInfo.Revenue; } _revenue.Text = Currency.ToString(revenue); } else { Reset(); } }
TransactionResultTypes CheckChainKey(ChainInfo chain, short keyIndex, bool adminRequired, ref Key key) { if (chain == null) { return(TransactionResultTypes.ChainNotFound); } var chainKey = chain.GetChainKey(keyIndex); if (chainKey == null) { return(TransactionResultTypes.ChainKeyNotFound); } if (chainKey.IsExpired()) { return(TransactionResultTypes.ChainKeyExpired); } if (adminRequired && (chainKey.Flags & PublicChainKeyFlags.ChainAdminKey) == 0) { return(TransactionResultTypes.ChainKeyNotFound); } key = chainKey.PublicKey; return(TransactionResultTypes.Ok); }
public bool CanPurchaseItem(PurchaseServiceTransaction transaction, ChainInfo chainInfo) { var purchase = chainInfo.GetPurchase(transaction.PurchaseGroupId, transaction.PurchaseItemId); if (purchase == null) { return(false); } lock (this) { if (_accountFeatures.TryGetValue(transaction.PurchaseGroupId, out var featurePurchase)) { return(featurePurchase.CanPurchase(transaction, purchase)); } if (_accountSubscriptions.TryGetValue(transaction.PurchaseGroupId, out var subscriptionPurchase)) { return(subscriptionPurchase.CanPurchase(transaction, purchase)); } } return(true); }
private List <MailMessage> GetFilteredConversations(IDbManager db, int tenant, string user, MailFilter filter, DateTime?utcChainFromDate, int fromMessageId, bool?prevFlag, out bool hasMore) { var res = new List <MailMessage>(); var chainsToSkip = new List <ChainInfo>(); var skipFlag = false; var chunkIndex = 0; var sortOrder = filter.SortOrder == "ascending"; if (prevFlag.GetValueOrDefault(false)) { sortOrder = !sortOrder; } const string mm_alias = "ch"; const string mtm_alias = "tm"; var queryMessages = new SqlQuery(MailTable.Name.Alias(mm_alias)) .Select(GetMailMessagesColumns(mm_alias)); if (filter.CustomLabels != null && filter.CustomLabels.Count > 0) { queryMessages = queryMessages .InnerJoin(TagMailTable.Name.Alias(mtm_alias), Exp.EqColumns(MailTable.Columns.Id.Prefix(mm_alias), TagMailTable.Columns.MailId.Prefix(mtm_alias))) .Where(Exp.In(TagMailTable.Columns.TagId.Prefix(mtm_alias), filter.CustomLabels)); } queryMessages = queryMessages .ApplyFilter(filter, mm_alias); if (queryMessages == null) { hasMore = false; return(res); } queryMessages .Where(TagMailTable.Columns.Tenant.Prefix(mm_alias), tenant) .Where(TagMailTable.Columns.User.Prefix(mm_alias), user) .Where(MailTable.Columns.IsRemoved.Prefix(mm_alias), false); if (filter.CustomLabels != null && filter.CustomLabels.Count > 0) { queryMessages = queryMessages .GroupBy(1) .Having(Exp.Eq(string.Format("count({0})", MailTable.Columns.Id.Prefix(mm_alias)), filter.CustomLabels.Count())); } queryMessages = queryMessages.OrderBy(MailTable.Columns.ChainDate, sortOrder); if (null != utcChainFromDate) { queryMessages = queryMessages.Where(sortOrder ? Exp.Ge(MailTable.Columns.ChainDate, utcChainFromDate) : Exp.Le(MailTable.Columns.ChainDate, utcChainFromDate)); skipFlag = true; } List <int> ids; if (TryGetFullTextSearchIds(filter, out ids)) { if (!ids.Any()) { hasMore = false; return(res); } } var tenantInfo = CoreContext.TenantManager.GetTenant(tenant); var utcNow = DateTime.UtcNow; var pageSize = filter.PageSize; // We are increasing the size of the page to check whether it is necessary to show the Next button. while (res.Count < pageSize + 1) { queryMessages .SetFirstResult(chunkIndex * CHUNK_SIZE * pageSize) .SetMaxResults(CHUNK_SIZE * pageSize); chunkIndex++; var list = db .ExecuteList(queryMessages) .ConvertAll(r => ConvertToMailMessage(r, tenantInfo, utcNow)); if (0 == list.Count) { break; } if (ids.Any()) { list = list.Where(m => ids.Exists(id => id == m.Id)).ToList(); } foreach (var item in list) { var chainInfo = new ChainInfo { id = item.ChainId, mailbox = item.MailboxId }; // Skip chains that was stored before and within from_message's chain. if (skipFlag) { if (item.ChainDate != TenantUtil.DateTimeFromUtc(tenantInfo.TimeZone, utcChainFromDate.GetValueOrDefault())) { skipFlag = false; } else { if (item.Id == fromMessageId) { skipFlag = false; } chainsToSkip.Add(chainInfo); continue; } } if (chainsToSkip.Contains(chainInfo)) { continue; } var alreadyContains = false; foreach (var chain in res) { if (chain.ChainId == item.ChainId && chain.MailboxId == item.MailboxId) { alreadyContains = true; if (chain.Date < item.Date) { res[res.IndexOf(chain)] = item; } break; } } if (!alreadyContains) { res.Add(item); } if (pageSize + 1 == res.Count) { break; } } if (pageSize + 1 == res.Count) { break; } } hasMore = res.Count > pageSize; if (hasMore) { res.RemoveAt(pageSize); } return(res); }
private List<MailMessageItem> GetFilteredChains( IDbManager db, int id_tenant, string id_user, MailFilter filter, DateTime? utc_chain_from_date, int from_message, bool? prev_flag, out bool has_more) { var res = new List<MailMessageItem>(); var chains_to_skip = new List<ChainInfo>(); var skip_flag = false; var chunck_index = 0; var sort_order = filter.SortOrder == "ascending"; if (prev_flag.GetValueOrDefault(false)) sort_order = !sort_order; var query_messages = new SqlQuery(MailTable.name) .Select( MailTable.Columns.id, MailTable.Columns.from, MailTable.Columns.to, MailTable.Columns.reply, MailTable.Columns.subject, MailTable.Columns.importance, MailTable.Columns.date_sent, MailTable.Columns.size, MailTable.Columns.attach_count, MailTable.Columns.unread, MailTable.Columns.is_answered, MailTable.Columns.is_forwarded, MailTable.Columns.is_from_crm, MailTable.Columns.is_from_tl, MailTable.Columns.folder_restore, MailTable.Columns.folder, MailTable.Columns.chain_id, MailTable.Columns.id_mailbox, MailTable.Columns.chain_date) .Where(GetUserWhere(id_user, id_tenant)) .Where(MailTable.Columns.is_removed, false) .ApplyFilter(filter) .OrderBy(MailTable.Columns.chain_date, sort_order); if (null != utc_chain_from_date) { query_messages = query_messages.Where(sort_order ? Exp.Ge(MailTable.Columns.chain_date, utc_chain_from_date) : Exp.Le(MailTable.Columns.chain_date, utc_chain_from_date)); skip_flag = true; } // We are increasing the size of the page to check whether it is necessary to show the Next button. while (res.Count < filter.PageSize + 1) { query_messages.SetFirstResult(chunck_index * chunk_size * filter.PageSize).SetMaxResults(chunk_size * filter.PageSize); chunck_index++; var tenant_obj = CoreContext.TenantManager.GetTenant(id_tenant); var list = db .ExecuteList(query_messages) .ConvertAll(r => ConvertToConversation(r, tenant_obj)); if (0 == list.Count) break; foreach (var item in list) { var chain_info = new ChainInfo {id = item.ChainId, mailbox = item.MailboxId}; // Skip chains that was stored before and within from_message's chain. if (skip_flag) { var tenant = CoreContext.TenantManager.GetTenant(id_tenant); if (item.ChainDate != TenantUtil.DateTimeFromUtc(tenant, utc_chain_from_date.GetValueOrDefault())) skip_flag = false; else { if (item.Id == from_message) skip_flag = false; chains_to_skip.Add(chain_info); continue; } } if (chains_to_skip.Contains(chain_info)) continue; var already_contains = false; foreach(var chain in res){ if(chain.ChainId == item.ChainId && chain.MailboxId == item.MailboxId){ already_contains = true; if(chain.Date < item.Date) res[res.IndexOf(chain)] = item; break; } } if(!already_contains) res.Add(item); if (filter.PageSize + 1 == res.Count) break; } var is_all_needed_conversation_gathered = filter.PageSize + 1 == res.Count; if (is_all_needed_conversation_gathered) break; var is_enough_messages_for_page = chunk_size*filter.PageSize <= list.Count; if (!is_enough_messages_for_page) break; } has_more = res.Count > filter.PageSize; if (has_more) res.RemoveAt(filter.PageSize); return res; }
private void AddChainMailsToCrmHistory(DbManager db, ChainInfo chain_info, int id_tenant, string id_user, List<CrmContactEntity> contact_ids) { var search_folders = new List<int> {MailFolder.Ids.inbox, MailFolder.Ids.sent}; var select_chained_mails = GetQueryForChainMessagesSelection(chain_info.mailbox, chain_info.id, search_folders); var crm_dal = new CrmHistoryDal(this, id_tenant, id_user); db.ExecuteList(select_chained_mails) .ConvertAll(record => { var item = GetMailInfo(db, id_tenant, id_user, Convert.ToInt32(record[0]), true, true); item.LinkedCrmEntityIds = contact_ids; return item; }) .ForEach(crm_dal.AddRelationshipEvents); }
private static void Wallet_ChainInfoUpdated(object sender, ChainInfo chainInfo) { Console.WriteLine($"CallBack[ChainInfo]: {chainInfo}"); }
private List <MailMessage> GetFilteredChains(IDbManager db, int tenant, string user, MailFilter filter, DateTime?utcChainFromDate, int fromMessageId, bool?prevFlag, out bool hasMore) { var res = new List <MailMessage>(); var chainsToSkip = new List <ChainInfo>(); var skipFlag = false; var chunkIndex = 0; var sortOrder = filter.SortOrder == "ascending"; if (prevFlag.GetValueOrDefault(false)) { sortOrder = !sortOrder; } const string mm_alias = "ch"; const string mtm_alias = "tm"; var queryMessages = new SqlQuery(MailTable.name.Alias(mm_alias)) .Select( MailTable.Columns.id.Prefix(mm_alias), MailTable.Columns.from.Prefix(mm_alias), MailTable.Columns.to.Prefix(mm_alias), MailTable.Columns.reply.Prefix(mm_alias), MailTable.Columns.subject.Prefix(mm_alias), MailTable.Columns.importance.Prefix(mm_alias), MailTable.Columns.date_sent.Prefix(mm_alias), MailTable.Columns.size.Prefix(mm_alias), MailTable.Columns.attach_count.Prefix(mm_alias), MailTable.Columns.unread.Prefix(mm_alias), MailTable.Columns.is_answered.Prefix(mm_alias), MailTable.Columns.is_forwarded.Prefix(mm_alias), MailTable.Columns.is_from_crm.Prefix(mm_alias), MailTable.Columns.is_from_tl.Prefix(mm_alias), MailTable.Columns.folder_restore.Prefix(mm_alias), MailTable.Columns.folder.Prefix(mm_alias), MailTable.Columns.chain_id.Prefix(mm_alias), MailTable.Columns.id_mailbox.Prefix(mm_alias), MailTable.Columns.chain_date.Prefix(mm_alias)); if (filter.CustomLabels != null && filter.CustomLabels.Count > 0) { queryMessages = queryMessages .InnerJoin(TagMailTable.name + " " + mtm_alias, Exp.EqColumns(MailTable.Columns.id.Prefix(mm_alias), TagMailTable.Columns.id_mail.Prefix(mtm_alias))) .Where(Exp.In(TagMailTable.Columns.id_tag.Prefix(mtm_alias), filter.CustomLabels)); } queryMessages = queryMessages .ApplyFilter(filter, mm_alias) .Where(TagMailTable.Columns.id_tenant.Prefix(mm_alias), tenant) .Where(TagMailTable.Columns.id_user.Prefix(mm_alias), user) .Where(MailTable.Columns.is_removed.Prefix(mm_alias), false); if (filter.CustomLabels != null && filter.CustomLabels.Count > 0) { queryMessages = queryMessages .GroupBy(1) .Having(Exp.Eq(string.Format("count({0})", MailTable.Columns.id.Prefix(mm_alias)), filter.CustomLabels.Count())); } queryMessages = queryMessages.OrderBy(MailTable.Columns.chain_date, sortOrder); if (null != utcChainFromDate) { queryMessages = queryMessages.Where(sortOrder ? Exp.Ge(MailTable.Columns.chain_date, utcChainFromDate) : Exp.Le(MailTable.Columns.chain_date, utcChainFromDate)); skipFlag = true; } // We are increasing the size of the page to check whether it is necessary to show the Next button. while (res.Count < filter.PageSize + 1) { queryMessages.SetFirstResult(chunkIndex * CHUNK_SIZE * filter.PageSize).SetMaxResults(CHUNK_SIZE * filter.PageSize); chunkIndex++; var tenantInfo = CoreContext.TenantManager.GetTenant(tenant); var list = db .ExecuteList(queryMessages) .ConvertAll(r => ConvertToConversation(r, tenantInfo)); if (0 == list.Count) { break; } foreach (var item in list) { var chainInfo = new ChainInfo { id = item.ChainId, mailbox = item.MailboxId }; // Skip chains that was stored before and within from_message's chain. if (skipFlag) { if (item.ChainDate != TenantUtil.DateTimeFromUtc(tenantInfo.TimeZone, utcChainFromDate.GetValueOrDefault())) { skipFlag = false; } else { if (item.Id == fromMessageId) { skipFlag = false; } chainsToSkip.Add(chainInfo); continue; } } if (chainsToSkip.Contains(chainInfo)) { continue; } var alreadyContains = false; foreach (var chain in res) { if (chain.ChainId == item.ChainId && chain.MailboxId == item.MailboxId) { alreadyContains = true; if (chain.Date < item.Date) { res[res.IndexOf(chain)] = item; } break; } } if (!alreadyContains) { res.Add(item); } if (filter.PageSize + 1 == res.Count) { break; } } var isAllNeededConversationGathered = filter.PageSize + 1 == res.Count; if (isAllNeededConversationGathered) { break; } var isEnoughMessagesForPage = CHUNK_SIZE * filter.PageSize <= list.Count; if (!isEnoughMessagesForPage) { break; } } hasMore = res.Count > filter.PageSize; if (hasMore) { res.RemoveAt(filter.PageSize); } return(res); }
public void SetBallOnLoc(EPoint a_pnt, Ball a_ball) { if (a_pnt.X < 0 || a_pnt.X >= GridSize.Width || a_pnt.Y < 0) return; m_aGrid[a_pnt.X, a_pnt.Y] = a_ball; a_ball.GridLoc = a_pnt; a_ball.Loc = GetGfxLocFromGridLoc(a_pnt); ResetChainNums(); m_nCurrentChainNum = 0; ArrayList aSameColor = CalcColorChain(a_pnt); if (aSameColor.Count > 2) { ArrayList aAllRemove = new ArrayList(); //remove balls in color chain, and then all balls that are no longer connected to ceiling! //first color chain, and also find all neighbours to the color chain ArrayList aAllNeighbours = new ArrayList(); //make a list of all neighbours: foreach (Ball removeball in aSameColor) { ArrayList aNeighbours = GetNeighbours(removeball); foreach (Ball neighbour in aNeighbours) { if (aAllNeighbours.Contains(neighbour) == false && aSameColor.Contains(neighbour) == false) aAllNeighbours.Add(neighbour); } RemoveBallAtLoc(removeball.GridLoc); removeball.Burst(); //aAllRemove.Add(removeball); } ResetChainNums(); m_nCurrentChainNum = 0; //now for each neighbour, add to remove list if not connected to ceiling: foreach (Ball ball in aAllNeighbours) { //if one of these balls is connected to another, the recursive function will already have added it to its remove list if (ball.ChainNum < 0) { EndogineHub.Put("New chain"); m_aCurrentChainInfo = new ChainInfo(); if (RecursiveCalcConnection(ball) == false) //the chain is not connected to ceiling { foreach (Ball removeball in m_aCurrentChainInfo.Balls) { aAllRemove.Add(removeball); RemoveBallAtLoc(removeball.GridLoc); } } } } foreach (Ball removeball in aAllRemove) { removeball.Fall(); //Dispose(); //.Color = Color.FromArgb(100,100,100); } m_playArea.RemovedBalls(aSameColor.Count, aAllRemove.Count); } }