private void AddNewTimeTableSubject(object sender, RoutedEventArgs e) { var addDialog = new Dialogs.AddNewSubjectToTimeTableDialog(GetDisplatedDays()); addDialog.ShowDialog(); if (!addDialog.Selected) { return; } int pairNumber = -1; Subject selectedSubject = addDialog.SelectedSubject; DaysOfWeek selectedDay = addDialog.SelectedDay; PairType selectedPairType = addDialog.SelectedPairType; foreach (var day in _displayedSchedule.ScheduleDayColumns) { if (day.DayName == addDialog.SelectedDay) { pairNumber = (day.SubjectDayDict.Count > 0) ? day.SubjectDayDict.Keys.Max() + 1 : 1; day.SubjectDayDict.Add(pairNumber, new SubjectScheduleItem() { PairType = selectedPairType, Subject = selectedSubject }); break; } } SubjectControl.LoadSchedule(_displayedSchedule); _subjectRepository.AddModifyOneTimeTableSubject(_displayedSchedule.Year, _displayedSchedule.SemesterNumber, _displayedSchedule.WeekNumber, selectedDay, pairNumber, selectedSubject, selectedPairType); }
public Orders MyOrders(PairType pair) { try { System.Threading.Thread.Sleep(WAIT); string qString = "pair=" + pair.ToString() + "&nonce=" + nonce; var sign = ComputeHash(this.secret, qString); var url = URL + "Order/MyOrders"; if (DIAGNOS) { System.Diagnostics.Debug.WriteLine("nonce={0} qString={1} url={2} Key={3}", nonce, qString, url, Key); } string result = Query(qString, url, Key, sign, "GET"); if (!string.IsNullOrEmpty(result)) { JObject orders = JObject.Parse(result); if (orders["error"] != null) { throw new Exception(orders["error"].ToString()); } if (orders != null) { var pairOrders = orders[pair.ToString()].ToString(); Orders response = Serializer.Deserialize <Orders>(pairOrders); return(response); } } return(null); } catch (Exception ex) { throw; } }
public void ClearMyOrders(PairType pair) { try { System.Threading.Thread.Sleep(WAIT); string qString = "nonce=" + nonce + "&pair=" + pair.ToString(); var sign = ComputeHash(this.secret, qString); var url = URL + "Order/MyOrders"; if (DIAGNOS) { System.Diagnostics.Debug.WriteLine("nonce={0} qString={1} url={2} Key={3}", nonce, qString, url, Key); } string result = Query(qString, url, Key, sign, "POST"); Orders myOrders = Serializer.Deserialize <Orders>(result); foreach (var item in myOrders.ask) { CancelOrder(item.id); } foreach (var item in myOrders.bid) { CancelOrder(item.id); } } catch (Exception ex) { throw; } }
/// <summary> /// Method to record the child Form to List. Calling application handles whatever it needs to do /// with the current Form /// </summary> /// <param name="formChild"></param> public void AddForm(Form formChild) { var newPair = new PairType <IntPtr, string>(formChild.Handle, formChild.Name); if (string.IsNullOrEmpty(this.initialFormName)) { this.initialFormName = formChild.Name; } var iFormCnt = TransitionForms.Count; if (iFormCnt > 1) { var iIdx = TransitionForms.FindIndex(pt => pt.Right == formChild.Name); if (iIdx >= 0) { if (!Control.FromHandle(TransitionForms[iIdx].Left).IsDisposed) { var historyForm = (Form)Control.FromHandle(TransitionForms[iIdx].Left); historyForm.Close(); historyForm.Dispose(); TransitionForms.RemoveAt(iIdx); } } } TransitionForms.Add(newPair); }
private List <PairType <TenderTypePanel.TenderTypeButton, bool> > generateEnableList() { var rt = new List <PairType <TenderTypePanel.TenderTypeButton, bool> >( (int)TenderTypePanel.TenderTypeButton.TTYPELENGTH); for (var j = TenderTypePanel.TenderTypeButton.CASH; j < TenderTypePanel.TenderTypeButton.TTYPELENGTH; ++j) { //Enabled all by default except PayPal var newEntry = new PairType <TenderTypePanel.TenderTypeButton, bool>(j, (j != TenderTypePanel.TenderTypeButton.PAYPAL)); //Check if the customer is looked up //If not enable only cash as MOP if (GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer == null || string.IsNullOrEmpty(GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber) || GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber == "0") { if (newEntry.Left != TenderTypePanel.TenderTypeButton.CASH) { continue; } } if (disableCardTenderType && (newEntry.Left == TenderTypePanel.TenderTypeButton.CREDITORBILLAP || newEntry.Left == TenderTypePanel.TenderTypeButton.DEBIT)) { continue; } //Add to the list rt.Add(newEntry); } return(rt); }
private void AssignUserSelection(ListViewItem assignedLVItem) { string userName = assignedLVItem.Text; if (!string.IsNullOrEmpty(userName) && assignedLVItem.SubItems != null && assignedLVItem.SubItems.Count > 0) { string typeName = assignedLVItem.SubItems[1].Text; if (!string.IsNullOrEmpty(typeName)) { PairType <CashDrawerUserVO, List <CashDrawerUserVO> > cDrawerEntry = this.cashDrawerUserMap[this.cashDrawerSelection]; if (typeName.Equals(PRIMARY, StringComparison.OrdinalIgnoreCase)) { this.assignedUserSelection = cDrawerEntry.Left; return; } if (CollectionUtilities.isNotEmpty(cDrawerEntry.Right)) { foreach (CashDrawerUserVO cdUsr in cDrawerEntry.Right) { if (cdUsr == null) { continue; } if (cdUsr.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)) { this.assignedUserSelection = cdUsr; return; } } } } } }
public IEnumerable <PairType> GetAllPairTypes() { var pairTypes = new List <PairType>(); using (var databaseConnection = new SqlConnection(_connString)) { databaseConnection.Open(); using (var command = new SqlCommand(getAllPairTypes, databaseConnection)) { command.CommandType = System.Data.CommandType.StoredProcedure; using (var reader = command.ExecuteReader()) { while (reader.Read()) { var pairType = new PairType { TypeId = (int)reader["TypeId"], TypeName = (string)reader["TypeName"], TypeStringId = (string)reader["TypeStringId"] }; pairTypes.Add(pairType); } } } } return(pairTypes); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="splitChar"></param> /// <param name="components"></param> /// <returns></returns> public static bool SplitFractionIntoComponents(string data, char splitChar, out PairType <string, string> components) { components = new PairType <string, string>(string.Empty, string.Empty); if (string.IsNullOrEmpty(data)) { return(false); } int splitIdx = data.IndexOf(splitChar); if (splitIdx == -1) { return(false); } string[] splits = data.Split(new[] { splitChar }, 2); if (splits.Length == 2) { components.Left = splits[0]; components.Right = splits[1]; return(true); } return(false); }
public List <ExchangesTrade> GetTrades(PairType Pair = PairType.BtcNis, long since = 0, double date = 0) { using (WebClient client = new WebClient()) { System.Threading.Thread.Sleep(WAIT); string result = client.DownloadString(URL + "Exchanges/" + Pair.ToString() + "/trades.json"); List <ExchangesTrade> response = Serializer.Deserialize <List <ExchangesTrade> >(result); return(response); } }
public Ticker GetTicker(PairType Pair = PairType.BtcNis) { using (WebClient client = new WebClient()) { System.Threading.Thread.Sleep(WAIT); var urlTicker = URL + "Exchanges/" + Pair.ToString() + "/Ticker.json"; string result = client.DownloadString(urlTicker); Ticker response = Serializer.Deserialize <Ticker>(result); return(response); } }
public OrderBook GetOrderBook(PairType Pair = PairType.BtcNis) { using (WebClient client = new WebClient()) { System.Threading.Thread.Sleep(WAIT); string result = client.DownloadString(URL + "Exchanges/" + Pair.ToString() + "/orderbook.json"); if (DIAGNOS) { System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("mm:ss")); } OrderBook response = Serializer.Deserialize <OrderBook>(result); return(response); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addUserButton_Click(object sender, EventArgs e) { if (this.availableUserSelection == null || this.cashDrawerSelection == null) { if (this.availableUserSelection == null && this.cashDrawerSelection != null) { MessageBox.Show("Please select a user from the available user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (this.cashDrawerSelection == null && this.assignedUserSelection != null) { MessageBox.Show("Please select a cash drawer.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Please select a cash drawer and a user from the available user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } //Get the cash drawer user map PairType <CashDrawerUserVO, List <CashDrawerUserVO> > mapping = this.cashDrawerUserMap[this.cashDrawerSelection]; if (mapping.Left == null) { mapping.Left = this.availableUserSelection; } else { mapping.Right.Add(this.availableUserSelection); } updatedCashDrawerId.Add(this.cashDrawerSelection.Id); this.cashDrawerUserMap[this.cashDrawerSelection] = mapping; this.availableUsers.Remove(this.availableUserSelection); this.updateAvailableUserList(); this.updateAssignedUserList(this.cashDrawerSelection); //Clear selection this.availableUserSelection = null; this.assignedUserSelection = null; //Set pending changes this.pendingChanges = true; if (this.submitButton.Enabled == false) { this.submitButton.Enabled = true; this.submitButton.Update(); } }
/// <summary> /// Constructor /// </summary> public DataTypeVOMapper() { this.mapping = new Dictionary <DataTypeConstants.PawnDataType, PairType <TypeCode, SqlDbType> >(); this.keys = new List <DataTypeConstants.PawnDataType>(); foreach (PairType <DataTypeConstants.PawnDataType, PairType <TypeCode, SqlDbType> > p in DataTypeConstants.DATATYPES) { if (p == null) { continue; } DataTypeConstants.PawnDataType curKey = p.Left; PairType <TypeCode, SqlDbType> curVal = p.Right; this.mapping.Add(curKey, curVal); this.keys.Add(curKey); } }
private List <PairType <TenderTypePanel.TenderTypeButton, bool> > generateEnableList() { var rt = new List <PairType <TenderTypePanel.TenderTypeButton, bool> >( (int)TenderTypePanel.TenderTypeButton.TTYPELENGTH); for (var j = TenderTypePanel.TenderTypeButton.CASH; j < TenderTypePanel.TenderTypeButton.TTYPELENGTH; ++j) { //Enabled all by default except PayPal var newEntry = new PairType <TenderTypePanel.TenderTypeButton, bool>(j, (j != TenderTypePanel.TenderTypeButton.PAYPAL)); //Add to the list rt.Add(newEntry); } return(rt); }
private void Pairify(double d) { var testCase = new PairType(); var conversionContext = new Definitions(); var module = testCase.RootScope.Convert(conversionContext).SafeCastTo(out Tac.Backend.Interpreted.Syntaz_Model_Interpeter.Elements.InterpetedRootScope _); var(scope, res) = module.InterpetWithExposedScope(InterpetedContext.Root()); Assert.False(res.IsReturn(out var _, out var value)); var method = scope.GetMember(new NameKey("pairify")); Assert.False(method.Value.Has <IInterpetedMethod>().Invoke(TypeManager.NumberMember(TypeManager.Double(d))).IsReturn(out var _, out var methodResult)); Assert.Equal(d, methodResult !.Value.Has <IInterpetedScope>().GetMember(new NameKey("x")).Value.Has <IBoxedDouble>().Value); Assert.Equal(d, methodResult !.Value.Has <IInterpetedScope>().GetMember(new NameKey("y")).Value.Has <IBoxedDouble>().Value); }
public async Task <IActionResult> PairPost(int tag1, int tag2, [FromQuery] int type) { Tag Tag1 = await _context.Tag.FindAsync(tag1); Tag Tag2 = await _context.Tag.FindAsync(tag2); PairType pairType = (PairType)type; //This is a hack. 99 means "child" from the tag manager, so we're swapping them. //It's a dumb hack, but I'm tired. if (type == 99) { Tag1 = await _context.Tag.FindAsync(tag2); Tag2 = await _context.Tag.FindAsync(tag1); pairType = PairType.Parent; } if (Tag1 == null | Tag2 == null) { return(NotFound()); } TagPair newPair = new TagPair() { Tag1 = Tag1, Tag2 = Tag2, Type = pairType }; if (await _context.TagPair.AnyAsync(tp => (tp.Tag1 == Tag1 && tp.Tag2 == Tag2))) { return(NotFound()); } await _context.TagPair.AddAsync(newPair); await _context.SaveChangesAsync(); return(Ok("{}")); }
/// <summary> /// Begin site method - call prior to getParameters /// </summary> /// <param name="caller">Calling class object</param> /// <param name="siteId">SiteId specifier object</param> /// <param name="ruleIds">List of Business rule strings</param> /// <param name="rules">List of BusinessRuleVO objects - Output param</param> /// <returns>PawnRulesSystemReturnCode</returns> public PawnRulesSystemReturnCode beginSite(object caller, SiteId siteId, List <string> ruleIds, out Dictionary <string, BusinessRuleVO> rules) { rules = new Dictionary <string, BusinessRuleVO>(); //Validate input if (caller == null || CollectionUtilities.isEmpty(ruleIds)) { return (new PawnRulesSystemReturnCode( PawnRulesSystemReturnCode.Code.ERROR, "Input values to beginSite are invalid.")); } //Check if this object is already using the pawn rules system if (this.beginBlockRegistry.ContainsKey(caller)) { PairType <SiteId, bool> curSiteBegin = this.beginBlockRegistry[caller]; if (curSiteBegin.Right) { return (new PawnRulesSystemReturnCode( PawnRulesSystemReturnCode.Code.WARNING, "Already in an active begin block for this site and this caller parent object.")); } curSiteBegin.Right = true; curSiteBegin.Left = siteId; } else { this.beginBlockRegistry.Add(caller, new PairType <SiteId, bool>(siteId, true)); } //Set site id this.currentSite = siteId; //Change last parameter to true if you want to save the rules file to the disk after it is loaded //into the rules engine data structure //rules = RulesHelper.BuildBusinessRules(siteId, true); rules = RulesHelper.BuildBusinessRules(siteId); return(new PawnRulesSystemReturnCode(PawnRulesSystemReturnCode.Code.SUCCESS)); }
/// <summary> /// /// </summary> /// <param name="nm"></param> /// <param name="iFxns"></param> /// <param name="elseFxn"></param> public IfThenElseBlock( string nm, List <PairType <FxnBlock, FxnBlock> > iFxns, FxnBlock elseFxn) { if (string.IsNullOrEmpty(nm) || CollectionUtilities.isEmpty(iFxns)) { throw new ApplicationException("Cannot create IfThenElse block"); } //Set the necessary fields this.ifMap = new Dictionary <string, bool>(); this.setName(nm); this.ifElseBlockPairs = new List <PairType <ConditionBlock, ActionBlock> >(); this.elseBlock = new ActionBlock(nm + "-ElseAction", elseFxn); int cnt = 0; //Create the if blocks foreach (PairType <FxnBlock, FxnBlock> fxn in iFxns) { FxnBlock condFxn = fxn.Left; FxnBlock actFxn = fxn.Right; //Create condition block ConditionBlock cndBlk = new ConditionBlock(nm + "-Condition-" + cnt, fxn.Left); //Create action block ActionBlock actBlk = new ActionBlock(nm + "-Action-" + cnt, fxn.Right); //Create bound pair of condition to action PairType <ConditionBlock, ActionBlock> ifElsBlk = new PairType <ConditionBlock, ActionBlock>(cndBlk, actBlk); //Add this to the if else block pair list this.ifElseBlockPairs.Add(ifElsBlk); //Increase count cnt++; } }
/// <summary> /// End site method - call after done with getParameters /// </summary> /// <param name="caller">Calling class object</param> /// <param name="siteId">SiteId specifier object</param> /// <returns>PawnRulesSystemReturnCode</returns> public PawnRulesSystemReturnCode endSite(object caller, SiteId siteId) { if (caller == null || siteId == null) { return(new PawnRulesSystemReturnCode(PawnRulesSystemReturnCode.Code.ERROR, "Inputs to endSite are invalid")); } if (this.beginBlockRegistry.ContainsKey(caller)) { PairType <SiteId, bool> curBlock = this.beginBlockRegistry[caller]; if (curBlock.Left == siteId) { if (curBlock.Right) { curBlock.Right = false; curBlock.Left = null; } } return(new PawnRulesSystemReturnCode(PawnRulesSystemReturnCode.Code.SUCCESS)); } return(new PawnRulesSystemReturnCode(PawnRulesSystemReturnCode.Code.WARNING, "No block found for given site id / caller pair")); }
/// <summary> /// /// </summary> /// <param name="cdVo"></param> private void updateAssignedUserList(CashDrawerVO cdVo) { if (cdVo == null) { return; } this.assignedUserListView.Items.Clear(); PairType <CashDrawerUserVO, List <CashDrawerUserVO> > mapping = this.cashDrawerUserMap[cdVo]; bool clearExistingList = true; if (mapping != null) { if (mapping.Left != null && mapping.Left.UserId != 0) { this.addUserToAssignedUserListView(mapping.Left, true); } if (CollectionUtilities.isNotEmpty(mapping.Right)) { foreach (CashDrawerUserVO cvo in mapping.Right) { if (cvo == null) { continue; } if (mapping.Left != null && mapping.Left.UserId == 0) { this.addUserToAssignedUserListView(cvo, true); } else { this.addUserToAssignedUserListView(cvo, false); } } } } }
public PairSignal() { this.stkTID = 0; this.etfTID = 0; this.trSignal = PairType.nullType; }
public PairSignal(int _stkID, int _etfID) { this.stkTID = _stkID; this.etfTID = _etfID; this.trSignal = PairType.nullType; }
public ClassificationPostflop(HoldemHand hand, HoldemGamePhase phase, HoldemBoard board) { CardList communityCards = board.GetBoardAt(phase); // Default this.hand = HandType.Unknown; this.kicker = KickerType.Unknown; this.pair = PairType.Irrelevant; this.draw = DrawType.Irrelevant; this.straightDraw = StraightDrawType.None; Trace.Assert(communityCards.Count > 0, "Cannot classificate an empty list of community cards."); // Create a new list including the board cards and the cards from the hand CardList cards = new CardList(communityCards.Count + 2); foreach (Card c in communityCards) { cards.AddCard(c); } cards.AddCard(hand.GetFirstCard()); cards.AddCard(hand.GetSecondCard()); // --- Royal flush if (IsRoyalFlush(cards)) { this.hand = HandType.RoyalFlush; this.kicker = KickerType.Irrelevant; return; } // -- Four of a kind if (cards.HaveIdenticalFaces(4)) { this.hand = HandType.FourOfAKind; this.kicker = KickerType.Irrelevant; return; } // -- Full House // If we have three of a kind and two pair at the same time, we have a full house bool isThreeOfAKind = cards.HaveIdenticalFaces(3); bool isTwoPair = IsTwoPair(cards); if (isThreeOfAKind && isTwoPair) { this.hand = HandType.FullHouse; this.kicker = KickerType.Irrelevant; return; } // -- Flush for (int i = 0; i < cards.Count; i++) { int numCardsSameSuit = 0; for (int j = i + 1; j < cards.Count; j++) { if (cards[i].Suit == cards[j].Suit) { numCardsSameSuit++; } } if (numCardsSameSuit >= 4) { this.hand = HandType.Flush; this.kicker = KickerType.Irrelevant; return; } } // -- Straight if (IsStraight(cards)) { this.hand = HandType.Straight; this.kicker = KickerType.Irrelevant; return; } // Calculate draws (if we got until here, there might be some) // Also, no draws are possible at the river if (phase == HoldemGamePhase.River) { draw = DrawType.None; straightDraw = StraightDrawType.None; } else { draw = GetDrawType(cards); if (IsInsideStraightDraw(cards)) { straightDraw = StraightDrawType.InsideStraightDraw; } if (IsOpenEndedStraightDraw(cards)) { straightDraw = StraightDrawType.OpenEndedStraightDraw; } } // -- Trips if (isThreeOfAKind) { this.hand = HandType.ThreeOfAKind; this.kicker = KickerType.Irrelevant; return; } // -- Two pair if (isTwoPair) { this.hand = HandType.TwoPair; this.kicker = KickerType.Irrelevant; return; } // -- Pair Card matching; if (cards.HaveIdenticalFaces(2, out matching)) { // Sort list by face value (ace high first) cards.Sort(SortUsing.AceHigh); // Find kicker (check from end of the list where face values are higher) Card kicker = cards[0]; for (int i = cards.Count - 1; i >= 0; i--) { if (cards[i].Face != matching.Face) { kicker = cards[i]; break; } } this.hand = HandType.Pair; this.kicker = GetKickerTypeFromCard(kicker); this.pair = GetPairType(communityCards, matching, hand.GetFirstCard(), hand.GetSecondCard()); return; } // -- High card cards.Sort(SortUsing.AceHigh); Card highCard = cards.Last; this.hand = HandType.HighCard; this.kicker = GetKickerTypeFromCard(highCard); }
/// <summary> /// /// </summary> private void buildInitalAssignedUserMap() { //Clear for initial construction this.cashDrawerUserMap.Clear(); bool lookForPrimaryUsers = true; if (assignedPrimaryUsers.Count <= 0) { //Cannot populate the value components of the map now lookForPrimaryUsers = false; } //Iterate through cash drawers foreach (CashDrawerVO curCd in this.cashDrawers) { if (curCd == null) { continue; } PairType <CashDrawerUserVO, List <CashDrawerUserVO> > usrEntry = new PairType <CashDrawerUserVO, List <CashDrawerUserVO> >(null, new List <CashDrawerUserVO>()); List <CashDrawerUserVO> assignedUser = new List <CashDrawerUserVO>(); if (lookForPrimaryUsers) { foreach (CashDrawerUserVO cdUsr in this.assignedPrimaryUsers) { if (cdUsr == null) { continue; } if (curCd.RegisterUserId == cdUsr.Id) { usrEntry.Left = cdUsr; assignedUser.Add(cdUsr); break; } } this.cashDrawerDeleteMap.Add(curCd, assignedUser); foreach (CashDrawerUserVO cdAuxUsr in this.assignedAuxiliaryUsers) { if (cdAuxUsr == null) { continue; } if (cdAuxUsr.RegisterId == curCd.Id) { List <CashDrawerUserVO> usrList = usrEntry.Right; if (usrList == null) { usrList = new List <CashDrawerUserVO>(); } usrList.Add(cdAuxUsr); usrEntry.Right = usrList; } } this.cashDrawerUserMap.Add(curCd, usrEntry); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeUserButton_Click(object sender, EventArgs e) { bool primaryDeleted = false; if (this.assignedUserSelection == null || this.cashDrawerSelection == null) { if (this.assignedUserSelection == null && this.cashDrawerSelection != null) { MessageBox.Show("Please select a user from the assigned user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (this.cashDrawerSelection == null && this.assignedUserSelection != null) { MessageBox.Show("Please select a cash drawer.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Please select a cash drawer and a user from the assigned user list.", "Shop Cash Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } //Get the cash drawer user map PairType <CashDrawerUserVO, List <CashDrawerUserVO> > mapping = this.cashDrawerUserMap[this.cashDrawerSelection]; //Get the cash drawer delete map entry deleteMapping = this.cashDrawerDeleteMap[this.cashDrawerSelection]; //Remove the user in either the primary or auxiliary position if (mapping != null) { if (mapping.Left != null && mapping.Left == this.assignedUserSelection) { if (mapping.Right.Count >= 1) { mapping.Left = mapping.Right[0]; mapping.Right.Remove(mapping.Right[0]); } else { primaryDeleted = true; mapping.Left.RegisterId = null; mapping.Left.UserName = null; mapping.Left.UserId = 0; } } else { mapping.Right.Remove(this.assignedUserSelection); } if (!deleteMapping.Contains(this.assignedUserSelection) && !string.IsNullOrEmpty(this.assignedUserSelection.ConnectedId)) { deleteMapping.Add(this.assignedUserSelection); } //Update available users this.availableUsers.Add(this.assignedUserSelection); //Update user map this.cashDrawerUserMap[this.cashDrawerSelection] = mapping; if (!updatedCashDrawerId.Any(s => s == this.cashDrawerSelection.Id)) { updatedCashDrawerId.Add(this.cashDrawerSelection.Id); } //Update views this.updateAssignedUserList(this.cashDrawerSelection); this.updateAvailableUserList(); //Clear selections this.assignedUserSelection = null; this.availableUserSelection = null; if (primaryDeleted) { if (assignedUserListView.Items.Count == 0) { this.submitButton.Enabled = false; } } //Set pending changes this.pendingChanges = true; if (this.submitButton.Enabled == false) { this.submitButton.Enabled = true; this.submitButton.Update(); } } }
public ClassificationPostflop(HoldemHand hand, HoldemGamePhase phase, HoldemBoard board) { CardList communityCards = board.GetBoardAt(phase); // Default this.hand = HandType.Unknown; this.kicker = KickerType.Unknown; this.pair = PairType.Irrelevant; this.draw = DrawType.Irrelevant; this.straightDraw = StraightDrawType.None; Trace.Assert(communityCards.Count > 0, "Cannot classificate an empty list of community cards."); // Create a new list including the board cards and the cards from the hand CardList cards = new CardList(communityCards.Count + 2); foreach (Card c in communityCards) cards.AddCard(c); cards.AddCard(hand.GetFirstCard()); cards.AddCard(hand.GetSecondCard()); // --- Royal flush if (IsRoyalFlush(cards)) { this.hand = HandType.RoyalFlush; this.kicker = KickerType.Irrelevant; return; } // -- Four of a kind if (cards.HaveIdenticalFaces(4)) { this.hand = HandType.FourOfAKind; this.kicker = KickerType.Irrelevant; return; } // -- Full House // If we have three of a kind and two pair at the same time, we have a full house bool isThreeOfAKind = cards.HaveIdenticalFaces(3); bool isTwoPair = IsTwoPair(cards); if (isThreeOfAKind && isTwoPair) { this.hand = HandType.FullHouse; this.kicker = KickerType.Irrelevant; return; } // -- Flush for (int i = 0; i < cards.Count; i++) { int numCardsSameSuit = 0; for (int j = i + 1; j < cards.Count; j++) { if (cards[i].Suit == cards[j].Suit) { numCardsSameSuit++; } } if (numCardsSameSuit >= 4) { this.hand = HandType.Flush; this.kicker = KickerType.Irrelevant; return; } } // -- Straight if (IsStraight(cards)) { this.hand = HandType.Straight; this.kicker = KickerType.Irrelevant; return; } // Calculate draws (if we got until here, there might be some) // Also, no draws are possible at the river if (phase == HoldemGamePhase.River) { draw = DrawType.None; straightDraw = StraightDrawType.None; } else { draw = GetDrawType(cards); if (IsInsideStraightDraw(cards)) { straightDraw = StraightDrawType.InsideStraightDraw; } if (IsOpenEndedStraightDraw(cards)) { straightDraw = StraightDrawType.OpenEndedStraightDraw; } } // -- Trips if (isThreeOfAKind) { this.hand = HandType.ThreeOfAKind; this.kicker = KickerType.Irrelevant; return; } // -- Two pair if (isTwoPair) { this.hand = HandType.TwoPair; this.kicker = KickerType.Irrelevant; return; } // -- Pair Card matching; if (cards.HaveIdenticalFaces(2, out matching)) { // Sort list by face value (ace high first) cards.Sort(SortUsing.AceHigh); // Find kicker (check from end of the list where face values are higher) Card kicker = cards[0]; for (int i = cards.Count - 1; i >= 0; i--) { if (cards[i].Face != matching.Face) { kicker = cards[i]; break; } } this.hand = HandType.Pair; this.kicker = GetKickerTypeFromCard(kicker); this.pair = GetPairType(communityCards, matching, hand.GetFirstCard(), hand.GetSecondCard()); return; } // -- High card cards.Sort(SortUsing.AceHigh); Card highCard = cards.Last; this.hand = HandType.HighCard; this.kicker = GetKickerTypeFromCard(highCard); }
public void AddModifyOneTimeTableSubject(int year, int semesterNumber, int weekNumber, DaysOfWeek selectedDay, int pairNumber, Subject selectedSubject, PairType selectedPairType) { using (var databaseConnection = new SqlConnection(_connString)) { databaseConnection.Open(); using (var command = new SqlCommand(addModifyCertainSubject, databaseConnection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@year", year); command.Parameters.AddWithValue("@semesterNumber", semesterNumber); command.Parameters.AddWithValue("@weekNumber", weekNumber); command.Parameters.AddWithValue("@dayName", selectedDay.ToString()); command.Parameters.AddWithValue("@pairNumber", pairNumber); command.Parameters.AddWithValue("@selectedSubjectId", selectedSubject.SubjectId); command.Parameters.AddWithValue("@selectedSubjectPairTypeId", selectedPairType.TypeId); command.ExecuteNonQuery(); } } }
public static bool ComputeDescription(PawnLoan pLoan, List <PairType <int, long> > gunItemNumberIndices, out string desc) { desc = string.Empty; if (pLoan == null || gunItemNumberIndices == null || pLoan.Items == null || pLoan.Items.Count <= 0 || gunItemNumberIndices.Count != pLoan.Items.Count) { if (FileLogger.Instance.IsLogError) { FileLogger.Instance.logMessage(LogLevel.ERROR, "LoanTicketLengthCalculator", "Cannot compute loan description - invalid method inputs"); } return(false); } var descBuilder = new StringBuilder(); for (int i = 0; i < pLoan.Items.Count; ++i) { Item p = pLoan.Items[i]; if (p == null) { continue; } PairType <int, long> curGunItemNumber = gunItemNumberIndices[i]; //Are we at a gun indice //Insert gun number into ticket description for the current //pawn item string gunNumberStr = null; string ticketSubNumStr = "[" + (i + 1) + "]"; if (curGunItemNumber.Left == i) { long gunNumber = curGunItemNumber.Right; gunNumberStr = GUN_NUM_SHORT + gunNumber + ";"; } //SR 08/05/2011 Added logic to remove brackets which do not have matching ending pair int begBracketIndex = p.TicketDescription.IndexOf("("); int endBracketIndex = p.TicketDescription.IndexOf(")"); if ((begBracketIndex >= 0 && (endBracketIndex < 0 || endBracketIndex < begBracketIndex)) || endBracketIndex > begBracketIndex) { p.TicketDescription = p.TicketDescription.Replace("(", " "); p.TicketDescription = p.TicketDescription.Replace(")", " "); } if (string.IsNullOrEmpty(gunNumberStr)) { descBuilder.Append(ticketSubNumStr + p.TicketDescription); } else { string fullDesc = ticketSubNumStr + p.TicketDescription; string ticketNumberSubStr = fullDesc.Substring(0, 3); string remainingDescStr = fullDesc.Substring(3); descBuilder.Append(ticketNumberSubStr + gunNumberStr + remainingDescStr); } } if (descBuilder.Length > 0) { desc = descBuilder.ToString(); return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="dA"></param> /// <param name="pwnSec"></param> /// <param name="decryptKey"> </param> /// <returns></returns> public static bool GetAllPawnSecData( ref DataAccessTools dA, ref PawnSecVO pwnSec, out string decryptKey) { decryptKey = string.Empty; if (pwnSec == null) { MessageBox.Show("Data passed into method is invalid", "Alert"); return(false); } //Get global configuration if (!GetGlobalConfig(ref dA, ref pwnSec, out decryptKey)) { MessageBox.Show("Could not acquire global configuration", "Alert"); } //Setup store config as the single parameter needed for the next few queries var ptStoCfg = new PairType <string, string> [1]; ptStoCfg[0] = new PairType <string, string>("STORECONFIGID", "1"); //Load db services and map DataReturnSet dbServices; if (!DataAccessService.ExecuteVariableQuery(false, PawnStoreSetupQueries.SELECT_PAWNSEC_DB, "databaseservice", PAWNSEC, out dbServices, ref dA, ptStoCfg)) { MessageBox.Show("Could not execute query against the database service table", "Alert"); return(false); } if (dbServices == null || dbServices.NumberRows <= 0) { MessageBox.Show("Could not find any database services in the pawnsec database", "Alert"); return(false); } for (int i = 0; i < dbServices.NumberRows; ++i) { DataReturnSetRow dR; if (!dbServices.GetRow(i, out dR)) { continue; } var enabFlag = Utilities.GetStringValue(dR.GetData("ENABLED")); var enabFlagBool = (!string.IsNullOrEmpty(enabFlag) && enabFlag.Equals("1")); var userName = Utilities.GetStringValue(dR.GetData("DBUSER")); var userPwd = Utilities.GetStringValue(dR.GetData("DBUSERPWD")); var dbServiceVo = new DatabaseServiceVO(userName, userPwd, enabFlagBool) { Id = Utilities.GetULongValue(dR.GetData("ID")), Name = Utilities.GetStringValue(dR.GetData("NAME")), Server = Utilities.GetStringValue(dR.GetData("SERVER")), Port = Utilities.GetStringValue(dR.GetData("PORT")), Schema = Utilities.GetStringValue(dR.GetData("SCHEMA")), AuxInfo = Utilities.GetStringValue(dR.GetData("AUXINFO")), ServiceType = Utilities.GetStringValue(dR.GetData("SERVICETYPE")) }; var dbMapVo = new PawnSecVO.DatabaseServiceStoreMapVO { Id = Utilities.GetULongValue(dR.GetData("DATABASEMAPID")), StoreConfigId = Utilities.GetULongValue(dR.GetData("DATABASEMAPSTORECONFIGID")), DatabaseServiceId = dbServiceVo.Id }; //Add vo objects to lists pwnSec.DatabaseServiceList.Add(dbServiceVo); pwnSec.DatabaseServiceMapList.Add(dbMapVo); } return(true); }
public PairPos(Equities etf, Equities stk) { this.EtfLeg = etf; this.StkLeg = stk; this.sScore = new double[4]; this.currHoldingPeriod = -1; this.thisPairStatus = PairType.nullType; }
/*__________________________________________________________________________________________*/ private void IH_ItemHistoryDataGridView_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { bool enableAddItem = true; if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { _ActiveTicketNumber = Utilities.GetIntegerValue(IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[IH_History_TktNo.Name].Value, 0); int docType = int.Parse(((string)IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[0].Value).Substring(12, 1)); string selectedICN = Utilities.GetStringValue(IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[0].Value); string status = IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[ IH_History_ItemStatusColumn.Name].Value.ToString(); if (e.ColumnIndex == 0) { // string docType = // IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[IH_History_DocType.Name]. // Value.ToString(); switch (status) { case "SOLD": if (GlobalDataAccessor.Instance.DesktopSession.CustomerHistorySales != null) { Sale_dialog sd = new Sale_dialog(GlobalDataAccessor.Instance.DesktopSession.CustomerHistorySales.Find (l => l.TicketNumber == _ActiveTicketNumber)); sd.ShowDialog(); } break; case "On Layaway": if (GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLayaways != null) { LayawayVO ly = GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLayaways.Find (l => l.TicketNumber == _ActiveTicketNumber); Receipt r; if (ly.Receipts.Count > 0) { r = ly.Receipts[0]; } else { r = new Receipt(); } Layaway_dialog ld = new Layaway_dialog(ly, r); ld.ShowDialog(); } break; case "REF": SaleRefund_Dialog srd = new SaleRefund_Dialog(GlobalDataAccessor.Instance.DesktopSession.CustomerHistorySales.Find (l => l.TicketNumber == _ActiveTicketNumber)); srd.ShowDialog(); break; default: if (GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases != null && docType == 2) { PurchaseHistory_Dialog d = new PurchaseHistory_Dialog(GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases.Find(l => l.TicketNumber == _ActiveTicketNumber), 0, status); if (d.isSetup) { d.ShowDialog(); } } else if (status.ToUpper() == "VOID") { if (docType == 1) { PawnLoan pawnLoan = Utilities.CloneObject(GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans.Find(l => l.TicketNumber == _ActiveTicketNumber)); ProductHistory_Dialog productHistory = new ProductHistory_Dialog(pawnLoan, 0); productHistory.ShowDialog(); } else if (docType == 2) { PurchaseHistory_Dialog d = new PurchaseHistory_Dialog( GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryPurchases.Find( l => l.TicketNumber == _ActiveTicketNumber), 0, status); d.ShowDialog(); } } else { var pawnLoan = Utilities.CloneObject(GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans.Find(l => l.TicketNumber == _ActiveTicketNumber)); var productHistory = new ProductHistory_Dialog(pawnLoan, 0); productHistory.ShowDialog(); } break; } } if (docType == 1) { PawnLoan pawnLoan = Utilities.CloneObject(GlobalDataAccessor.Instance.DesktopSession.CustomerHistoryLoans.Find(l => l.TicketNumber == _ActiveTicketNumber)); var gunItems = pawnLoan.Items.Find(i => i.GunNumber > 0 && i.Icn == selectedICN); if (gunItems != null) { enableAddItem = false; } } _ActiveICN = Utilities.GetStringValue(IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[IH_History_TransactionNumberColumn.Name].Value, ""); string sLoanStatus = Utilities.GetStringValue(IH_ItemHistoryDataGridView.Rows[e.RowIndex].Cells[IH_History_ItemStatusColumn.Name].Value, ""); PairType <ProductStatus, string> pairType = GlobalDataAccessor.Instance.DesktopSession.LoanStatus .First(pt => pt.Right == sLoanStatus); if (pairType.Left == ProductStatus.PU) { const string resName = "NEWPAWNLOAN"; UserVO currUser = GlobalDataAccessor.Instance.DesktopSession.LoggedInUserSecurityProfile; IH_AddItemToNewPawnLoan.Enabled = SecurityProfileProcedures.CanUserViewResource(resName, currUser, GlobalDataAccessor.Instance.DesktopSession); IH_AddItemToNewPawnLoan.Enabled = enableAddItem; } else { IH_AddItemToNewPawnLoan.Enabled = false; } } }