示例#1
0
 public BidEntry(Mobile bidder, int amount, BidType type)
 {
     m_Bidder     = bidder;
     m_Amount     = amount;
     m_BidType    = type;
     m_DatePlaced = DateTime.UtcNow;
 }
示例#2
0
 private void SetHandStrength(Card card, BidType bidType)
 {
     if (card.Type == CardType.Ten)
     {
         announceStrength[bidType] += 3;
     }
     if (card.Type == CardType.Queen || card.Type == CardType.King)
     {
         announceStrength[bidType] += 2;
     }
     if (card.Type == CardType.Ace)
     {
         announceStrength[bidType] += 5;
     }
     if (card.Type == CardType.Nine)
     {
         announceStrength[bidType] += 6;
     }
     if (card.Type == CardType.Jack)
     {
         announceStrength[bidType] += 10;
     }
     if (card.Type == CardType.Seven || card.Type == CardType.Eight)
     {
         announceStrength[bidType] += 1;
     }
 }
示例#3
0
文件: Auction.cs 项目: YkeSmit1/TOSR
        public void AddBid(Bid bid)
        {
            if (!bids.ContainsKey(CurrentBiddingRound))
            {
                bids[CurrentBiddingRound] = new Dictionary <Player, Bid>();
            }
            bids[CurrentBiddingRound][CurrentPlayer] = bid;

            if (CurrentPlayer == Player.South)
            {
                CurrentPlayer = Player.West;
                ++CurrentBiddingRound;
            }
            else
            {
                ++CurrentPlayer;
            }
            if (bid.bidType == BidType.bid)
            {
                currentContract = bid;
            }
            if (bid.bidType != BidType.pass)
            {
                currentBidType = bid.bidType;
            }
        }
示例#4
0
        public BidType AskForBid(Contract currentContract, IList <BidType> allowedBids, IList <BidType> previousBids)
        {
            int     max        = 0;
            BidType currentBid = BidType.Pass;

            foreach (var item in announceStrength)
            {
                if (item.Value > max && allowedBids.Contains(item.Key) && item.Value > 14)
                {
                    max        = item.Value;
                    currentBid = item.Key;
                }
                if (item.Value >= 24 && allowedBids.Contains(BidType.Double))
                {
                    currentBid = BidType.Double;
                    break;
                }
                if (item.Value >= 24 && allowedBids.Contains(BidType.ReDouble))
                {
                    currentBid = BidType.ReDouble;
                    break;
                }
            }
            return(currentBid);
        }
示例#5
0
        protected void Page_Init(object sender, EventArgs e)
        {
            HasEditPermission = Permissions.PermissionsForUser(SessionHelper.UserId()).Contains(Permissions.PermissionKeys.sys_perm);
            if (Request.QueryString["id"] == "all")
            {
                if (Request.QueryString["bool"] == "bidleave")
                {
                    BidLeave = true;
                }

                AllBids = true;
            }
            if (Request.QueryString["Id"] != null && Request.QueryString["Id"] != "all")
            {
                CustomerId = Request.QueryString["Id"].ToString();
            }

            if (Request.QueryString["Type"] != null)
            {
                customerType = (CustomerType)int.Parse(Request.QueryString["Type"]);
            }

            if (Request.QueryString["BidType"] != null)
            {
                bidType = (BidType)int.Parse(Request.QueryString["BidType"]);
            }

            dgMyBids.PageIndexChanged += dgMyBids_PageIndexChanging;
        }
示例#6
0
文件: Bid.cs 项目: marcusber/Cards
        /// <summary>
        /// Initializes a new instance of the <see cref="Bid"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        protected Bid(BidType type)
        {
            if (!type.IsValid())
            {
                throw new ArgumentOutOfRangeException("type");
            }

            this.BidType = type;
        }
示例#7
0
        public BidEntry(GenericReader reader)
        {
            int version = reader.ReadInt();

            m_Bidder     = reader.ReadMobile();
            m_Amount     = reader.ReadInt();
            m_BidType    = (BidType)reader.ReadInt();
            m_DatePlaced = reader.ReadDateTime();
        }
示例#8
0
 /// <summary>
 /// Create a Bid to be commited to a
 /// </summary>
 /// <param name="room">Room that bid will be placed</param>
 /// <param name="buyer">Buyer owner of this bid</param>
 /// <param name="amount">Bid amount to be commited</param>
 public Bid(Room room, Buyer buyer, decimal amount, BidType type)
 {
     Id     = Guid.NewGuid();
     Date   = DateTimeOffset.UtcNow;
     Room   = room;
     Buyer  = buyer;
     Amount = amount;
     Type   = type;
 }
示例#9
0
        private void AddButton(BidType bidType, int buttonLeft, string buttonText, int buttonWidth)
        {
            var button = new BiddingBoxButton(new Bid(bidType))
            {
                Width  = buttonWidth,
                Top    = defaultButtonHeight * 7,
                Left   = buttonLeft,
                Parent = this,
                Text   = buttonText
            };

            button.Click += BiddingBoxClick;
            button.Show();
            buttons.Add(button);
        }
示例#10
0
        public async Task <IHttpActionResult> Post([FromBody] BidType model)
        {
            if (!ModelState.IsValid)
            {
                Validate(model);
                return(BadRequest(ModelState));
            }

            var result = await _sql.CreateAsync(model);

            if (result < 1)
            {
                return(BadRequest());
            }

            return(Ok(model));
        }
示例#11
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] BidType model)
        {
            if (!ModelState.IsValid)
            {
                Validate(model);
                return(BadRequest(ModelState));
            }

            // Set ID because Ember doesn't send it
            model.Id = id;

            var result = await _sql.UpdateAsync(model);

            if (!result)
            {
                return(BadRequest());
            }

            return(Ok(model));
        }
示例#12
0
		public BidEntry(Mobile bidder, int amount, BidType type)
		{
			m_Bidder = bidder;
			m_Amount = amount;
			m_BidType = type;
			m_DatePlaced = DateTime.UtcNow;
		}
示例#13
0
 public BidEventArgs(PlayerPosition position, BidType bid)
 {
     this.Position = position;
     this.Bid = bid;
 }
示例#14
0
 public Bid(BidType bidType)
 {
     this.bidType = bidType;
     suit         = default;
     rank         = default;
 }
示例#15
0
        public OpportunityWrapper CreateDeal(
            int contactid,
            IEnumerable <int> members,
            String title,
            String description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            String bidCurrencyAbbr,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable <ItemKeyValuePair <int, String> > customFieldList,
            bool isPrivate,
            IEnumerable <Guid> accessList)
        {
            if (String.IsNullOrEmpty(title) || responsibleid == Guid.Empty)
            {
                throw new ArgumentException();
            }

            var deal = new Deal
            {
                Title                    = title,
                Description              = description,
                ResponsibleID            = responsibleid,
                BidType                  = bidType,
                BidValue                 = bidValue,
                PerPeriodValue           = perPeriodValue,
                DealMilestoneID          = stageid,
                DealMilestoneProbability = successProbability,
                ContactID                = contactid,
                ActualCloseDate          = actualCloseDate,
                ExpectedCloseDate        = expectedCloseDate,
                BidCurrency              = bidCurrencyAbbr,
            };

            if (String.IsNullOrEmpty(deal.BidCurrency))
            {
                deal.BidCurrency = Global.TenantSettings.DefaultCurrency.Abbreviation;
            }

            deal.ID = DaoFactory.GetDealDao().CreateNewDeal(deal);

            deal.CreateBy = ASC.Core.SecurityContext.CurrentAccount.ID;
            deal.CreateOn = DateTime.UtcNow;

            var accessListLocal = accessList.ToList();

            if (isPrivate && accessListLocal.Count > 0)
            {
                CRMSecurity.SetAccessTo(deal, accessListLocal);
            }
            else
            {
                CRMSecurity.MakePublic(deal);
            }

            if (members != null && members.Count() > 0)
            {
                DaoFactory.GetDealDao().SetMembers(deal.ID, members.ToArray());
            }

            foreach (var field in customFieldList)
            {
                if (String.IsNullOrEmpty(field.Value))
                {
                    continue;
                }

                DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
            }

            return(ToOpportunityWrapper(deal));
        }
示例#16
0
 public Bid(int rank, Suit suit)
 {
     bidType   = BidType.bid;
     this.suit = suit;
     this.rank = rank;
 }
示例#17
0
        public OpportunityWrapper UpdateDeal(
                                      int opportunityid,
                                      int contactid,
                                      IEnumerable<int> members,
                                      String title,
                                      String description,
                                      Guid responsibleid,
                                      BidType bidType,
                                      decimal bidValue,
                                      String bidCurrencyAbbr,
                                      int perPeriodValue,
                                      int stageid,
                                      int successProbability,
                                      ApiDateTime actualCloseDate,
                                      ApiDateTime expectedCloseDate,
                                      IEnumerable<ItemKeyValuePair<int, String>> customFieldList,
                                      bool isPrivate,
                                      IEnumerable<Guid> accessList)
        {

            if (String.IsNullOrEmpty(title) || responsibleid == Guid.Empty)
                throw new ArgumentException();

            var deal = new Deal
            {
                ID = opportunityid,
                Title = title,
                Description = description,
                ResponsibleID = responsibleid,
                BidType = bidType,
                BidValue = bidValue,
                PerPeriodValue = perPeriodValue,
                DealMilestoneID = stageid,
                DealMilestoneProbability = successProbability,
                ContactID = contactid,
                ActualCloseDate = actualCloseDate,
                ExpectedCloseDate = expectedCloseDate
            };

            if (String.IsNullOrEmpty(deal.BidCurrency))
                deal.BidCurrency = Global.TenantSettings.DefaultCurrency.Abbreviation;
            
            DaoFactory.GetDealDao().EditDeal(deal);

            deal = DaoFactory.GetDealDao().GetByID(opportunityid);

            if (members != null && members.Count() > 0)
                DaoFactory.GetDealDao().SetMembers(deal.ID, members.ToArray());

            var accessListLocal = accessList.ToList();

            if (isPrivate && accessListLocal.Count > 0)
                CRMSecurity.SetAccessTo(deal, accessListLocal);
            else
                CRMSecurity.MakePublic(deal);

            foreach (var field in customFieldList)
            {
                if (String.IsNullOrEmpty(field.Value)) continue;

                DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
            }

            return ToOpportunityWrapper(deal);

        }
示例#18
0
        public OpportunityWrapper CreateDeal(
            int contactid,
            IEnumerable<int> members,
            string title,
            string description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            string bidCurrencyAbbr,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable<ItemKeyValuePair<int, string>> customFieldList,
            bool isPrivate,
            IEnumerable<Guid> accessList)
        {
            var deal = new Deal
                {
                    Title = title,
                    Description = description,
                    ResponsibleID = responsibleid,
                    BidType = bidType,
                    BidValue = bidValue,
                    PerPeriodValue = perPeriodValue,
                    DealMilestoneID = stageid,
                    DealMilestoneProbability = successProbability < 0 ? 0 : (successProbability > 100 ? 100 : successProbability),
                    ContactID = contactid,
                    ActualCloseDate = actualCloseDate,
                    ExpectedCloseDate = expectedCloseDate,
                    BidCurrency = !String.IsNullOrEmpty(bidCurrencyAbbr) ? bidCurrencyAbbr.ToUpper() : null,
                };

            CRMSecurity.DemandCreateOrUpdate(deal);

            deal.ID = DaoFactory.GetDealDao().CreateNewDeal(deal);

            deal.CreateBy = SecurityContext.CurrentAccount.ID;
            deal.CreateOn = DateTime.UtcNow;

            var accessListLocal = accessList.ToList();

            if (isPrivate && accessListLocal.Count > 0)
            {
                CRMSecurity.SetAccessTo(deal, accessListLocal);
            }
            else
            {
                CRMSecurity.MakePublic(deal);
            }

            var membersList = members.ToList();
            if (members != null && membersList.Any())
            {
                var contacts = DaoFactory.GetContactDao().GetContacts(membersList.ToArray()).Where(CRMSecurity.CanAccessTo).ToList();
                membersList = contacts.Select(m => m.ID).ToList();

                DaoFactory.GetDealDao().SetMembers(deal.ID, membersList.ToArray());
            }

            var existingCustomFieldList = DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Opportunity).Select(fd => fd.ID).ToList();

            foreach (var field in customFieldList)
            {
                if (string.IsNullOrEmpty(field.Value) || !existingCustomFieldList.Contains(field.Key)) continue;
                DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
            }

            return ToOpportunityWrapper(deal);
        }
示例#19
0
        private void ImportOpportunityData(DaoFactory _daoFactory)
        {
            var allUsers = ASC.Core.CoreContext.UserManager.GetUsers(EmployeeStatus.All).ToList();

            using (var CSVFileStream = _dataStore.GetReadStream("temp", _CSVFileURI))
                using (CsvReader csv = ImportFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
                {
                    int currentIndex = 0;

                    var customFieldDao   = _daoFactory.CustomFieldDao;
                    var contactDao       = _daoFactory.ContactDao;
                    var tagDao           = _daoFactory.TagDao;
                    var dealDao          = _daoFactory.DealDao;
                    var dealMilestoneDao = _daoFactory.DealMilestoneDao;

                    var findedTags        = new Dictionary <int, List <String> >();
                    var findedCustomField = new List <CustomField>();
                    var findedDeals       = new List <Deal>();
                    var findedDealMembers = new Dictionary <int, List <int> >();

                    var dealMilestones = dealMilestoneDao.GetAll();

                    while (csv.ReadNextRecord())
                    {
                        _columns = csv.GetCurrentRowFields(false);

                        var obj = new Deal();

                        obj.ID = currentIndex;

                        obj.Title = GetPropertyValue("title");

                        if (String.IsNullOrEmpty(obj.Title))
                        {
                            continue;
                        }

                        obj.Description = GetPropertyValue("description");

                        var csvResponsibleValue = GetPropertyValue("responsible");
                        var responsible         = allUsers.Where(n => n.DisplayUserName().Equals(csvResponsibleValue)).FirstOrDefault();

                        if (responsible != null)
                        {
                            obj.ResponsibleID = responsible.ID;
                        }
                        else
                        {
                            obj.ResponsibleID = Constants.LostUser.ID;
                        }

                        DateTime actualCloseDate;

                        DateTime expectedCloseDate;

                        if (DateTime.TryParse(GetPropertyValue("actual_close_date"), out actualCloseDate))
                        {
                            obj.ActualCloseDate = actualCloseDate;
                        }

                        if (DateTime.TryParse(GetPropertyValue("expected_close_date"), out expectedCloseDate))
                        {
                            obj.ExpectedCloseDate = expectedCloseDate;
                        }

                        var currency = CurrencyProvider.Get(GetPropertyValue("bid_currency"));

                        if (currency != null)
                        {
                            obj.BidCurrency = currency.Abbreviation;
                        }
                        else
                        {
                            obj.BidCurrency = Global.TenantSettings.DefaultCurrency.Abbreviation;
                        }

                        decimal bidValue;

                        var bidValueStr = GetPropertyValue("bid_amount");

                        if (Decimal.TryParse(bidValueStr, NumberStyles.Number, CultureInfo.InvariantCulture, out bidValue))
                        {
                            obj.BidValue = bidValue;
                        }
                        else
                        {
                            obj.BidValue = 0;
                        }


                        var bidTypeStr = GetPropertyValue("bid_type");

                        BidType bidType = BidType.FixedBid;

                        if (!String.IsNullOrEmpty(bidTypeStr))
                        {
                            if (String.Compare(CRMDealResource.BidType_FixedBid, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.FixedBid;
                            }
                            else if (String.Compare(CRMDealResource.BidType_PerDay, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.PerDay;
                            }
                            else if (String.Compare(CRMDealResource.BidType_PerHour, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.PerHour;
                            }
                            else if (String.Compare(CRMDealResource.BidType_PerMonth, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.PerMonth;
                            }
                            else if (String.Compare(CRMDealResource.BidType_PerWeek, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.PerWeek;
                            }
                            else if (String.Compare(CRMDealResource.BidType_PerYear, bidTypeStr, true) == 0)
                            {
                                bidType = BidType.PerYear;
                            }
                        }

                        obj.BidType = bidType;

                        if (obj.BidType != BidType.FixedBid)
                        {
                            int perPeriodValue;

                            if (int.TryParse(GetPropertyValue("per_period_value"), out perPeriodValue))
                            {
                                obj.PerPeriodValue = perPeriodValue;
                            }
                        }

                        int probabilityOfWinning;

                        if (int.TryParse(GetPropertyValue("probability_of_winning"), out probabilityOfWinning))
                        {
                            obj.DealMilestoneProbability = probabilityOfWinning;
                        }

                        var dealMilestoneTitle = GetPropertyValue("deal_milestone");

                        var tag = GetPropertyValue("tag");


                        if (!String.IsNullOrEmpty(tag))
                        {
                            var tagList = tag.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                            tagList.AddRange(_importSettings.Tags);
                            tagList = tagList.Distinct().ToList();
                            findedTags.Add(obj.ID, tagList);
                        }
                        else if (_importSettings.Tags.Count != 0)
                        {
                            findedTags.Add(obj.ID, _importSettings.Tags);
                        }


                        if (String.IsNullOrEmpty(dealMilestoneTitle))
                        {
                            obj.DealMilestoneID = dealMilestones[0].ID;
                        }
                        else
                        {
                            var dealMilestone = dealMilestones.Find(item => String.Compare(item.Title, dealMilestoneTitle, true) == 0);

                            if (dealMilestone == null)
                            {
                                obj.DealMilestoneID = dealMilestones[0].ID;
                            }
                            else
                            {
                                obj.DealMilestoneID = dealMilestone.ID;
                            }
                        }

                        var contactName = GetPropertyValue("client");

                        var localMembersDeal = new List <int>();

                        if (!String.IsNullOrEmpty(contactName))
                        {
                            var contacts = contactDao.GetContactsByName(contactName, true);

                            if (contacts.Count > 0)
                            {
                                obj.ContactID = contacts[0].ID;
                                localMembersDeal.Add(obj.ContactID);
                            }
                            else
                            {
                                contacts = contactDao.GetContactsByName(contactName, false);
                                if (contacts.Count > 0)
                                {
                                    obj.ContactID = contacts[0].ID;
                                    localMembersDeal.Add(obj.ContactID);
                                }
                            }
                        }

                        var members = GetPropertyValue("member");

                        if (!String.IsNullOrEmpty(members))
                        {
                            var membersList = members.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                            foreach (var item in membersList)
                            {
                                var findedMember = contactDao.GetContactsByName(item, true);

                                if (findedMember.Count > 0)
                                {
                                    localMembersDeal.Add(findedMember[0].ID);
                                }
                                else
                                {
                                    findedMember = _daoFactory.ContactDao.GetContactsByName(item, false);
                                    if (findedMember.Count > 0)
                                    {
                                        localMembersDeal.Add(findedMember[0].ID);
                                    }
                                }
                            }
                        }

                        if (localMembersDeal.Count > 0)
                        {
                            findedDealMembers.Add(obj.ID, localMembersDeal);
                        }


                        foreach (JProperty jToken in _importSettings.ColumnMapping.Children())
                        {
                            var propertyValue = GetPropertyValue(jToken.Name);

                            if (String.IsNullOrEmpty(propertyValue))
                            {
                                continue;
                            }

                            if (!jToken.Name.StartsWith("customField_"))
                            {
                                continue;
                            }

                            var fieldID = Convert.ToInt32(jToken.Name.Split(new[] { '_' })[1]);
                            var field   = customFieldDao.GetFieldDescription(fieldID);

                            if (field != null)
                            {
                                findedCustomField.Add(new CustomField
                                {
                                    EntityID   = obj.ID,
                                    EntityType = EntityType.Opportunity,
                                    ID         = fieldID,
                                    Value      = field.FieldType == CustomFieldType.CheckBox ? (propertyValue == "on" || propertyValue == "true" ? "true" : "false") : propertyValue
                                });
                            }
                        }

                        Percentage += 1.0 * 100 / (ImportFromCSV.MaxRoxCount * 2);

                        if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                        {
                            ImportDataCache.ResetAll(EntityType.Opportunity);

                            throw new OperationCanceledException();
                        }

                        ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());



                        findedDeals.Add(obj);

                        if (currentIndex + 1 > ImportFromCSV.MaxRoxCount)
                        {
                            break;
                        }

                        currentIndex++;
                    }


                    Percentage = 50;

                    if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                    {
                        ImportDataCache.ResetAll(EntityType.Opportunity);

                        throw new OperationCanceledException();
                    }

                    ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());

                    var newDealIDs = dealDao.SaveDealList(findedDeals);
                    findedDeals.ForEach(d => d.ID = newDealIDs[d.ID]);

                    Percentage += 12.5;

                    if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                    {
                        ImportDataCache.ResetAll(EntityType.Opportunity);

                        throw new OperationCanceledException();
                    }

                    ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());

                    findedCustomField.ForEach(item => item.EntityID = newDealIDs[item.EntityID]);

                    customFieldDao.SaveList(findedCustomField);

                    Percentage += 12.5;

                    if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                    {
                        ImportDataCache.ResetAll(EntityType.Opportunity);

                        throw new OperationCanceledException();
                    }

                    ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());

                    foreach (var findedDealMemberKey in findedDealMembers.Keys)
                    {
                        dealDao.SetMembers(newDealIDs[findedDealMemberKey], findedDealMembers[findedDealMemberKey].ToArray());
                    }

                    Percentage += 12.5;

                    if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                    {
                        ImportDataCache.ResetAll(EntityType.Opportunity);

                        throw new OperationCanceledException();
                    }

                    ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());

                    foreach (var findedTagKey in findedTags.Keys)
                    {
                        tagDao.SetTagToEntity(EntityType.Opportunity, newDealIDs[findedTagKey], findedTags[findedTagKey].ToArray());
                    }

                    if (_importSettings.IsPrivate)
                    {
                        findedDeals.ForEach(dealItem => CRMSecurity.SetAccessTo(dealItem, _importSettings.AccessList));
                    }

                    Percentage += 12.5;

                    if (ImportDataCache.CheckCancelFlag(EntityType.Opportunity))
                    {
                        ImportDataCache.ResetAll(EntityType.Opportunity);

                        throw new OperationCanceledException();
                    }

                    ImportDataCache.Insert(EntityType.Opportunity, (ImportDataOperation)Clone());
                }

            Complete();
        }
示例#20
0
        public OpportunityWrapper UpdateDeal(
            int opportunityid,
            int contactid,
            IEnumerable <int> members,
            String title,
            String description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable <ItemKeyValuePair <int, String> > customFieldList,
            bool isPrivate,
            IEnumerable <Guid> accessList)
        {
            if (contactid == 0 || String.IsNullOrEmpty(title) || responsibleid == Guid.Empty)
            {
                throw new ArgumentException();
            }

            var deal = new Deal
            {
                ID                       = opportunityid,
                Title                    = title,
                Description              = description,
                ResponsibleID            = responsibleid,
                BidType                  = bidType,
                BidValue                 = bidValue,
                PerPeriodValue           = perPeriodValue,
                DealMilestoneID          = stageid,
                DealMilestoneProbability = successProbability,
                ContactID                = contactid,
                ActualCloseDate          = actualCloseDate,
                ExpectedCloseDate        = expectedCloseDate
            };

            DaoFactory.GetDealDao().EditDeal(deal);

            deal = DaoFactory.GetDealDao().GetByID(opportunityid);

            if (members != null && members.Count() > 0)
            {
                DaoFactory.GetDealDao().SetMembers(deal.ID, members.ToArray());
            }

            var accessListLocal = accessList.ToList();

            if (isPrivate && accessListLocal.Count > 0)
            {
                CRMSecurity.SetAccessTo(deal, accessListLocal);
            }
            else
            {
                CRMSecurity.MakePublic(deal);
            }

            foreach (var field in customFieldList)
            {
                if (String.IsNullOrEmpty(field.Value))
                {
                    continue;
                }

                DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
            }

            return(ToOpportunityWrapper(deal));
        }
示例#21
0
		public BidEntry(GenericReader reader)
		{
			int version = reader.ReadInt();
			m_Bidder = reader.ReadMobile();
			m_Amount = reader.ReadInt();
			m_BidType = (BidType)reader.ReadInt();
			m_DatePlaced = reader.ReadDateTime();
		}
示例#22
0
 private Bid(BidType bidType) : this()
 {
     mBidType = bidType;
 }
 private void SetHandStrength(Card card, BidType bidType)
 {
     if (card.Type == CardType.Ten)
     {
         announceStrength[bidType] += 3;
     }
     if (card.Type == CardType.Queen || card.Type == CardType.King)
     {
         announceStrength[bidType] += 2;
     }
     if (card.Type == CardType.Ace)
     {
         announceStrength[bidType] += 5;
     }
     if (card.Type == CardType.Nine)
     {
         announceStrength[bidType] += 6;
     }
     if (card.Type == CardType.Jack)
     {
         announceStrength[bidType] += 10;
     }
     if (card.Type == CardType.Seven || card.Type == CardType.Eight)
     {
         announceStrength[bidType] += 1;
     }
 }
示例#24
0
 public BidEventArgs(PlayerPosition position, BidType bid, Contract currentContract)
 {
     this.Position        = position;
     this.Bid             = bid;
     this.CurrentContract = currentContract;
 }
示例#25
0
        public OpportunityWrapper UpdateDeal(
            int opportunityid,
            int contactid,
            IEnumerable<int> members,
            string title,
            string description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            string bidCurrencyAbbr,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable<ItemKeyValuePair<int, string>> customFieldList,
            bool isPrivate,
            IEnumerable<Guid> accessList,
            bool isNotify)
        {
            var deal = DaoFactory.GetDealDao().GetByID(opportunityid);
            if (deal == null) throw new ItemNotFoundException();

            deal.Title = title;
            deal.Description = description;
            deal.ResponsibleID = responsibleid;
            deal.BidType = bidType;
            deal.BidValue = bidValue;
            deal.PerPeriodValue = perPeriodValue;
            deal.DealMilestoneID = stageid;
            deal.DealMilestoneProbability = successProbability < 0 ? 0 : (successProbability > 100 ? 100 : successProbability);
            deal.ContactID = contactid;
            deal.ActualCloseDate = actualCloseDate;
            deal.ExpectedCloseDate = expectedCloseDate;
            deal.BidCurrency = !String.IsNullOrEmpty(bidCurrencyAbbr) ? bidCurrencyAbbr.ToUpper() : null;

            CRMSecurity.DemandCreateOrUpdate(deal);

            DaoFactory.GetDealDao().EditDeal(deal);

            deal = DaoFactory.GetDealDao().GetByID(opportunityid);

            var membersList = members != null ? members.ToList() : new List<int>();
            if (membersList.Any())
            {
                var contacts = DaoFactory.GetContactDao().GetContacts(membersList.ToArray()).Where(CRMSecurity.CanAccessTo).ToList();
                membersList = contacts.Select(m => m.ID).ToList();

                DaoFactory.GetDealDao().SetMembers(deal.ID, membersList.ToArray());
            }


            if (CRMSecurity.IsAdmin || deal.CreateBy == SecurityContext.CurrentAccount.ID)
            {
                SetAccessToDeal(deal, isPrivate, accessList, isNotify, false);
            }

            if (customFieldList != null)
            {
                var existingCustomFieldList = DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Opportunity).Select(fd => fd.ID).ToList();
                foreach (var field in customFieldList)
                {
                    if (string.IsNullOrEmpty(field.Value) || !existingCustomFieldList.Contains(field.Key)) continue;
                    DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
                }
            }

            return ToOpportunityWrapper(deal);
        }
        public OpportunityWrapper CreateDeal(
            int contactid,
            IEnumerable <int> members,
            string title,
            string description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            string bidCurrencyAbbr,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable <ItemKeyValuePair <int, string> > customFieldList,
            bool isPrivate,
            IEnumerable <Guid> accessList)
        {
            var deal = new Deal
            {
                Title                    = title,
                Description              = description,
                ResponsibleID            = responsibleid,
                BidType                  = bidType,
                BidValue                 = bidValue,
                PerPeriodValue           = perPeriodValue,
                DealMilestoneID          = stageid,
                DealMilestoneProbability = successProbability < 0 ? 0 : (successProbability > 100 ? 100 : successProbability),
                ContactID                = contactid,
                ActualCloseDate          = actualCloseDate,
                ExpectedCloseDate        = expectedCloseDate,
                BidCurrency              = !String.IsNullOrEmpty(bidCurrencyAbbr) ? bidCurrencyAbbr.ToUpper() : null,
            };

            CRMSecurity.DemandCreateOrUpdate(deal);

            deal.ID = DaoFactory.GetDealDao().CreateNewDeal(deal);

            deal.CreateBy = SecurityContext.CurrentAccount.ID;
            deal.CreateOn = DateTime.UtcNow;

            var accessListLocal = accessList != null?accessList.ToList() : new List <Guid>();

            if (isPrivate && accessListLocal.Any())
            {
                CRMSecurity.SetAccessTo(deal, accessListLocal);
            }
            else
            {
                CRMSecurity.MakePublic(deal);
            }

            var membersList = members != null?members.ToList() : new List <int>();

            if (membersList.Any())
            {
                var contacts = DaoFactory.GetContactDao().GetContacts(membersList.ToArray()).Where(CRMSecurity.CanAccessTo).ToList();
                membersList = contacts.Select(m => m.ID).ToList();
                DaoFactory.GetDealDao().SetMembers(deal.ID, membersList.ToArray());
            }

            if (customFieldList != null)
            {
                var existingCustomFieldList = DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Opportunity).Select(fd => fd.ID).ToList();
                foreach (var field in customFieldList)
                {
                    if (string.IsNullOrEmpty(field.Value) || !existingCustomFieldList.Contains(field.Key))
                    {
                        continue;
                    }
                    DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
                }
            }

            return(ToOpportunityWrapper(deal));
        }
 public static Domain.Entities.Types.BidType ToModel(this BidType type)
 {
     return((Domain.Entities.Types.BidType)type);
 }
示例#28
0
        public void UpdateButtons(Bid bid, Player auctionCurrentPlayer)
        {
            currentBidType = bid.bidType;

            switch (bid.bidType)
            {
            case BidType.bid:
                EnableButtons(new[] { Bid.Dbl });
                DisableButtons(new[] { Bid.Rdbl });
                foreach (var button in buttons)
                {
                    Bid localBid = button.bid;
                    if (localBid.bidType == BidType.bid && button.bid <= bid)
                    {
                        button.Enabled = false;
                    }
                }
                if (currentDeclarer == Player.UnKnown)
                {
                    currentDeclarer = auctionCurrentPlayer;
                }
                break;

            case BidType.pass:
                if (Common.IsSameTeam(auctionCurrentPlayer, currentDeclarer))
                {
                    switch (currentBidType)
                    {
                    case BidType.bid:
                        EnableButtons(new[] { Bid.Dbl });
                        DisableButtons(new[] { Bid.Rdbl });
                        break;

                    case BidType.dbl:
                        DisableButtons(new[] { Bid.Dbl, Bid.Rdbl });
                        break;
                    }
                }
                else
                {
                    switch (currentBidType)
                    {
                    case BidType.bid:
                        DisableButtons(new[] { Bid.Dbl, Bid.Rdbl });
                        break;

                    case BidType.dbl:
                        EnableButtons(new[] { Bid.Rdbl });
                        DisableButtons(new[] { Bid.Dbl });
                        break;
                    }
                }
                break;

            case BidType.dbl:
                EnableButtons(new[] { Bid.Rdbl });
                DisableButtons(new[] { Bid.Dbl });
                break;

            case BidType.rdbl:
                DisableButtons(new[] { Bid.Dbl, Bid.Rdbl });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#29
0
 public Bid CreateBid(Room room, decimal bidAmount, BidType type)
 {
     return(new Bid(room, this, bidAmount, type));
 }
示例#30
0
        public OpportunityWrapper UpdateDeal(
            int opportunityid,
            int contactid,
            IEnumerable <int> members,
            string title,
            string description,
            Guid responsibleid,
            BidType bidType,
            decimal bidValue,
            string bidCurrencyAbbr,
            int perPeriodValue,
            int stageid,
            int successProbability,
            ApiDateTime actualCloseDate,
            ApiDateTime expectedCloseDate,
            IEnumerable <ItemKeyValuePair <int, string> > customFieldList,
            bool isPrivate,
            IEnumerable <Guid> accessList,
            bool isNotify)
        {
            var deal = DaoFactory.GetDealDao().GetByID(opportunityid);

            if (deal == null)
            {
                throw new ItemNotFoundException();
            }

            deal.Title                    = title;
            deal.Description              = description;
            deal.ResponsibleID            = responsibleid;
            deal.BidType                  = bidType;
            deal.BidValue                 = bidValue;
            deal.PerPeriodValue           = perPeriodValue;
            deal.DealMilestoneID          = stageid;
            deal.DealMilestoneProbability = successProbability < 0 ? 0 : (successProbability > 100 ? 100 : successProbability);
            deal.ContactID                = contactid;
            deal.ActualCloseDate          = actualCloseDate;
            deal.ExpectedCloseDate        = expectedCloseDate;
            deal.BidCurrency              = !String.IsNullOrEmpty(bidCurrencyAbbr) ? bidCurrencyAbbr.ToUpper() : null;

            CRMSecurity.DemandCreateOrUpdate(deal);

            DaoFactory.GetDealDao().EditDeal(deal);

            deal = DaoFactory.GetDealDao().GetByID(opportunityid);

            var membersList = members != null?members.ToList() : new List <int>();

            if (membersList.Any())
            {
                var contacts = DaoFactory.GetContactDao().GetContacts(membersList.ToArray()).Where(CRMSecurity.CanAccessTo).ToList();
                membersList = contacts.Select(m => m.ID).ToList();

                DaoFactory.GetDealDao().SetMembers(deal.ID, membersList.ToArray());
            }


            if (CRMSecurity.IsAdmin || deal.CreateBy == SecurityContext.CurrentAccount.ID)
            {
                SetAccessToDeal(deal, isPrivate, accessList, isNotify, false);
            }

            if (customFieldList != null)
            {
                var existingCustomFieldList = DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Opportunity).Select(fd => fd.ID).ToList();
                foreach (var field in customFieldList)
                {
                    if (string.IsNullOrEmpty(field.Value) || !existingCustomFieldList.Contains(field.Key))
                    {
                        continue;
                    }
                    DaoFactory.GetCustomFieldDao().SetFieldValue(EntityType.Opportunity, deal.ID, field.Key, field.Value);
                }
            }

            return(ToOpportunityWrapper(deal));
        }
示例#31
0
 private Bid(BidType bidType)
     : this()
 {
     mBidType = bidType;
 }
示例#32
0
文件: Card.cs 项目: emsto/JustBelot
        public int GetValue(BidType contract)
        {
            if (contract == BidType.Pass || contract == BidType.Double || contract == BidType.ReDouble)
            {
                throw new InvalidEnumArgumentException("contract", (int)contract, typeof(BidType));
            }

            if (contract == BidType.AllTrumps
                || (contract == BidType.Clubs && this.Suit == CardSuit.Clubs)
                || (contract == BidType.Diamonds && this.Suit == CardSuit.Diamonds)
                || (contract == BidType.Hearts && this.Suit == CardSuit.Hearts)
                || (contract == BidType.Spades && this.Suit == CardSuit.Spades))
            {
                if (this.Type == CardType.Seven)
                {
                    return 0;
                }

                if (this.Type == CardType.Eight)
                {
                    return 0;
                }

                if (this.Type == CardType.Nine)
                {
                    return 14;
                }

                if (this.Type == CardType.Ten)
                {
                    return 10;
                }

                if (this.Type == CardType.Jack)
                {
                    return 20;
                }

                if (this.Type == CardType.Queen)
                {
                    return 3;
                }

                if (this.Type == CardType.King)
                {
                    return 4;
                }

                if (this.Type == CardType.Ace)
                {
                    return 11;
                }
            }
            else
            {
                // Non-trump card
                if (this.Type == CardType.Seven)
                {
                    return 0;
                }

                if (this.Type == CardType.Eight)
                {
                    return 0;
                }

                if (this.Type == CardType.Nine)
                {
                    return 0;
                }

                if (this.Type == CardType.Ten)
                {
                    return 10;
                }

                if (this.Type == CardType.Jack)
                {
                    return 2;
                }

                if (this.Type == CardType.Queen)
                {
                    return 3;
                }

                if (this.Type == CardType.King)
                {
                    return 4;
                }

                if (this.Type == CardType.Ace)
                {
                    return 11;
                }
            }

            throw new Exception("Unable to determine card value!");
        }
示例#33
0
        private async void SendAlarm(BidType type)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            if (Device.RuntimePlatform == Device.Android)
            {
                if (!await CheckPermission(Permission.Location, "Для отправки тревоги, необходимо разрешение на использование геоданных."))
                {
                    IsBusy = false;
                    return;
                }
            }

            var          guid    = Guid.NewGuid();
            var          user    = App.User;
            bool         res     = false;
            IBidsService service = new BidsService
            {
                AccessToken = (string)user.UserToken.Token.Clone(),
                TokenType   = (string)user.UserToken.TokenType.Clone()
            };

            try
            {
                res = await service.CreateBid(new Bid
                {
                    Guid     = guid,
                    Client   = user,
                    Location = await Location.GetCurrentGeolocationAsync(GeolocationAccuracy.Best),
                    Status   = BidStatus.PendingAcceptance,
                    Type     = type
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (res)
            {
                if (type == BidType.Call)
                {
                    App.Call("+7 911 447-11-83");
                }
                else if (type == BidType.Alert)
                {
                    await Application.Current.MainPage.DisplayAlert("Внимание", "Тревога отправлена", "OK");
                }

                await Task.Run(() =>
                {
                    DependencyService.Get <ILocationTrackingService>()
                    .StartService(guid);
                });
            }
            else
            {
                if (string.IsNullOrEmpty(service.LastError))
                {
                    await Application.Current.MainPage.DisplayAlert("Внимание", "Ошибка сервера.", "Ок");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Внимание", service.LastError, "Ок");
                }
            }

            IsBusy = false;
        }