示例#1
0
 public void AddDeal(IDeal deal)
 {
     lock (list)
     {
         Get(deal.Symbol).Value += (int)deal.BuySell * deal.Value;
     }
 }
示例#2
0
 public readonly IList <IDeal> Deals = new List <IDeal>();  // надеюсь менять сделки в результате никто не дадумается :)
 public void AddDeal(IDeal deal)
 {
     lock (Deals)
     {
         Deals.Add(deal);
     }
 }
示例#3
0
 public void AddDeal(IDeal deal)
 {
     lock (list)
     {
         Get(deal.Symbol).Value += (int)deal.BuySell * deal.Value;
     }
 }
示例#4
0
 public MenuWriter(IWriteClass writer, IDeal deal, IPlayersHand playersHand, IShowPlayers showPlayer)
 {
     _writer      = writer;
     _deal        = deal;
     _playersHand = playersHand;
     _showPlayers = showPlayer;
 }
 public static DealEntity Create(IDeal deal)
 {
     return(new DealEntity
     {
         DealId = deal.DealId,
         Created = deal.Created,
         AccountId = deal.AccountId,
         AssetPairId = deal.AssetPairId,
         OpenTradeId = deal.OpenTradeId,
         OpenOrderType = deal.OpenOrderType.ToString(),
         OpenOrderVolume = deal.OpenOrderVolume,
         OpenOrderExpectedPrice = deal.OpenOrderExpectedPrice,
         CloseTradeId = deal.CloseTradeId,
         CloseOrderType = deal.CloseOrderType.ToString(),
         CloseOrderVolume = deal.CloseOrderVolume,
         CloseOrderExpectedPrice = deal.CloseOrderExpectedPrice,
         Direction = deal.Direction.ToString(),
         Volume = deal.Volume,
         Originator = deal.Originator.ToString(),
         OpenPrice = deal.OpenPrice,
         OpenFxPrice = deal.OpenFxPrice,
         ClosePrice = deal.ClosePrice,
         CloseFxPrice = deal.CloseFxPrice,
         Fpl = deal.Fpl,
         AdditionalInfo = deal.AdditionalInfo,
         PnlOfTheLastDay = deal.PnlOfTheLastDay,
         CorrelationId = deal.CorrelationId
     });
 }
示例#6
0
文件: ORPTeam.cs 项目: MyRSG/COAT
 protected override void ApproveDeal(IDeal deal, BaseApprArgs args)
 {
     var orpArgs = (ORPTeamApprArgs)args;
     deal.ORPType = orpArgs.ORPType;
     deal.Switch(deal.ORPType == ORPType.SMB ? WorkFlowStep.ISOAdmin : WorkFlowStep.SalesOperation);
     deal.Save();
 }
示例#7
0
 protected void AssertApproval(IDeal d, IApproval approval, int action)
 {
     Assert.AreEqual(d.Id, approval.DealId);
     Assert.AreEqual(CurrentStep, approval.Step);
     Assert.AreEqual(action, approval.ApprovalAction);
     Assert.AreEqual(Comment, approval.Comment);
 }
示例#8
0
文件: BaseUnit.cs 项目: MyRSG/COAT
        public virtual IApproval AssignWrong(IDeal deal, BaseApprArgs args)
        {
            IApproval lastAppr = WorkFlowManager.WorkFlowFactory.GetLastApproval(deal);
            deal.Switch(lastAppr.Step);
            deal.Save();

            return CreateApproval(deal.Id, args.ActionUser, ApprovalAction.AssignWrong, args.Comment);
        }
示例#9
0
        public IEnumerable <DealsModels.DealViewModel> RelatedDeals(int DealID)
        {
            dealServices = new DealServices(new DealsDB());

            IEnumerable <DealsModels.DealViewModel> DealList = dealServices.AllDeal().Where(x => x.DealId != DealID).OrderBy(x => Guid.NewGuid()).Take(3);

            return(DealList);
        }
示例#10
0
 protected override void ApproveDeal(IDeal deal, BaseApprArgs args)
 {
     var soArgs = (SalesOperationApprArgs)args;
     deal.Industry2 = soArgs.Industry2;
     deal.Province2 = soArgs.Province2;
     deal.CurrentStep = WorkFlowStep.ChannelManager;
     deal.Save();
 }
示例#11
0
文件: IsoAdmin.cs 项目: MyRSG/COAT
 protected override void ApproveDeal(IDeal deal, BaseApprArgs args)
 {
     var isoArgs = (IsoAdminApprArgs)args;
     deal.Industry2 = isoArgs.Industry2;
     deal.Province2 = isoArgs.Province2;
     deal.Switch(WorkFlowStep.InsideSales);
     deal.Save();
 }
示例#12
0
文件: BaseUnit.cs 项目: MyRSG/COAT
        public virtual IApproval Approve(IDeal deal, BaseApprArgs args)
        {
            ApproveDeal(deal, args);
            var rslt = CreateApproval(deal.Id, args.ActionUser, ApprovalAction.Approve, args.Comment);
            AdditionOpeation(deal, rslt, args);
            SendNotifcationMail(deal, args);

            return rslt;
        }
示例#13
0
        public async Task AddAsync(IPositionHistory positionHistory, IDeal deal)
        {
            var entity =
                _convertService.Convert <IPositionHistory, PositionHistoryEntity>(positionHistory,
                                                                                  o => o.ConfigureMap(MemberList.Source));

            entity.Timestamp = DateTimeOffset.UtcNow;

            await _tableStorage.InsertOrReplaceAsync(entity);
        }
示例#14
0
文件: SalesTeam.cs 项目: MyRSG/COAT
        protected override void AdditionOpeation(IDeal deal, IApproval approval, BaseApprArgs args)
        {
            var stArgs = (SalesTeamApprArgs)args;

            var answer = WorkFlowManager.WorkFlowFactory.CreateAnswer();
            answer.DealId = deal.Id;
            answer.ApprovalId = approval.Id;
            answer.QuestionId = stArgs.QuestionId;
            answer.Answer = stArgs.Answer;

            WorkFlowManager.DataFactory.SaveAnswer(answer);
        }
示例#15
0
 public static DealDataModel ToDataModel(this IDeal deal)
 {
     return(new DealDataModel()
     {
         CustomerName = deal.CustomerName,
         DealershipName = deal.DealershipName,
         DealNumber = deal.DealNumber,
         Price = deal.Price,
         SoldDate = deal.SoldDate,
         Vehicle = deal.Vehicle
     });
 }
示例#16
0
        public ActionResult ViewDeal()
        {
            if (RouteData.Values["id"] != null)
            {
                int ID = Convert.ToInt32(RouteData.Values["id"].ToString());
                dealServices = new DealServices(new DealsDB());


                ViewSingleDeal SingleDeal = dealServices.GetSingleDeal(ID);
                ViewBag.Message = " ";
                dealServices.Dispose();
                return(View("Index", SingleDeal));
            }
            return(RedirectToAction("Index", "Home"));
        }
示例#17
0
        public IApproval GetLastApproval(IDeal deal)
        {
            switch (deal.CurrentStep)
            {
                case WorkFlowStep.SalesOperation:
                    return new TestApproval { DealId = deal.Id, Step = WorkFlowStep.ORPTeam };
                case WorkFlowStep.ISOAdmin:
                    return new TestApproval { DealId = deal.Id, Step = WorkFlowStep.ORPTeam };
                case WorkFlowStep.ChannelManager:
                    return new TestApproval { DealId = deal.Id, Step = WorkFlowStep.SalesOperation };
                case WorkFlowStep.InsideSales:
                    return new TestApproval { DealId = deal.Id, Step = WorkFlowStep.ISOAdmin };
                case WorkFlowStep.ChannelDirector:
                    return new TestApproval { DealId = deal.Id, Step = WorkFlowStep.SalesTeam };
            }

            return WorkFlowManager.DataFactory.GetApprovals().Last(a => a.DealId == deal.Id);
        }
示例#18
0
 public void Handle(IDeal d)
 {
     if (ohlc.Open == 0 || d.When < ohlc.WhenInDt)
     {
         ohlc.Open = (double)d.Price;
     }
     if (ohlc.High == 0 || (double)d.Price > ohlc.High)
     {
         ohlc.High = (double)d.Price;
     }
     if (ohlc.Low == 0 || (double)d.Price < ohlc.Low)
     {
         ohlc.Low = (double)d.Price;
     }
     if (ohlc.Close == 0 || d.When >= ohlc.WhenInDt)
     {
         ohlc.Close = (double)d.Price;
     }
     ohlc.Volume += (double)d.DealCount;
 }
示例#19
0
 public void Handle(IDeal d)
 {
     if (!dic.ContainsKey(d.WhatById))
     {
         if (!dic.ContainsKey(d.WhatById))
         {
             var td = new  Dictionary <OhlcType, OhlcMaker>();
             td.Add(OhlcType.M5, new OhlcMaker(d.WhatById, OhlcType.M5));
             td.Add(OhlcType.M15, new OhlcMaker(d.WhatById, OhlcType.M15));
             td.Add(OhlcType.M30, new OhlcMaker(d.WhatById, OhlcType.M30));
             td.Add(OhlcType.M60, new OhlcMaker(d.WhatById, OhlcType.M60));
             td.Add(OhlcType.M480, new OhlcMaker(d.WhatById, OhlcType.M480));
             td.Add(OhlcType.M1440, new OhlcMaker(d.WhatById, OhlcType.M1440));
             dic.Add(d.WhatById, td);
         }
     }
     foreach (var v in dic[d.WhatById].Values)
     {
         v.Handle(d);
     }
 }
        public async Task AddAsync(IPositionHistory positionHistory, IDeal deal)
        {
            await TransactionWrapperExtensions.RunInTransactionAsync(
                (conn, transaction) => DoAdd(conn, transaction, positionHistory, deal),
                _connectionString,
                RollbackExceptionHandler,
                commitException => CommitExceptionHandler(commitException, positionHistory, deal));

            if (deal != null)
            {
                Task.Run(async() =>
                {
                    using (var conn = new SqlConnection(_connectionString))
                    {
                        try
                        {
                            await conn.ExecuteAsync("[dbo].[UpdateDealCommissionParamsOnDeal]",
                                                    new
                            {
                                deal.DealId,
                                deal.OpenTradeId,
                                deal.OpenOrderVolume,
                                deal.CloseTradeId,
                                deal.CloseOrderVolume,
                                deal.Volume,
                            },
                                                    commandType: CommandType.StoredProcedure);
                        }
                        catch (Exception e)
                        {
                            await _log.WriteErrorAsync(nameof(PositionsHistorySqlRepository),
                                                       nameof(AddAsync),
                                                       $"Failed to calculate commissions for the deal {deal.DealId}, skipping.", e);
                        }
                    }
                });
            }
        }
        private async Task DoAdd(SqlConnection conn, SqlTransaction transaction, IPositionHistory positionHistory, IDeal deal)
        {
            var positionEntity = PositionsHistoryEntity.Create(positionHistory);
            await conn.ExecuteAsync($"insert into {TableName} ({GetColumns}) values ({GetFields})",
                                    positionEntity,
                                    transaction);

            if (deal != null)
            {
                var entity = DealEntity.Create(deal);

                await conn.ExecuteAsync(
                    $@"INSERT INTO [dbo].[Deals] ({string.Join(",", DealsSqlRepository.DealInsertColumns)}) VALUES (@{string.Join(",@", DealsSqlRepository.DealInsertColumns)})",
                    new
                {
                    entity.DealId,
                    entity.Created,
                    entity.AccountId,
                    entity.AssetPairId,
                    entity.OpenTradeId,
                    entity.OpenOrderType,
                    entity.OpenOrderVolume,
                    entity.OpenOrderExpectedPrice,
                    entity.CloseTradeId,
                    entity.CloseOrderType,
                    entity.CloseOrderVolume,
                    entity.CloseOrderExpectedPrice,
                    entity.Direction,
                    entity.Volume,
                    entity.Originator,
                    entity.OpenPrice,
                    entity.OpenFxPrice,
                    entity.ClosePrice,
                    entity.CloseFxPrice,
                    entity.Fpl,
                    entity.PnlOfTheLastDay,
                    entity.AdditionalInfo,
                    entity.CorrelationId
                },
                    transaction);

                await conn.ExecuteAsync("INSERT INTO [dbo].[DealCommissionParams] (DealId) VALUES (@DealId)",
                                        new { deal.DealId },
                                        transaction);
            }
        }
示例#22
0
文件: BaseUnit.cs 项目: MyRSG/COAT
 protected abstract void ApproveDeal(IDeal deal, BaseApprArgs args);
 private DealContract Convert(IDeal deal)
 {
     return(_convertService.Convert <IDeal, DealContract>(deal, opts => opts.ConfigureMap()
                                                          .ForMember(x => x.Direction,
                                                                     o => o.ResolveUsing(z => z.Direction.ToType <PositionDirectionContract>()))));
 }
示例#24
0
 protected void AssertAssignWrongApproval(IDeal d, IApproval approval)
 {
     AssertApproval(d, approval, ApprovalAction.AssignWrong);
 }
示例#25
0
 protected void AssertDeclineApproval(IDeal d, IApproval approval)
 {
     AssertApproval(d, approval, ApprovalAction.Decline);
 }
示例#26
0
 public IDeal SaveDeal(IDeal deal)
 {
     return deal;
 }
示例#27
0
        public ActionResult CouponGenerator(ViewSingleDeal CreateCoupon)
        {
            if (Session[KeyList.SessionKeys.UserID] == null)
            {
                return(RedirectToAction("Index", "Register_Login"));
            }

            //    walleservice = new UserWalletServices(new DealsDB());
            walleservice = new UserWalletServices(new DealsDB());
            Wallet AddTrans = walleservice.GetCreditByUserID(Convert.ToInt32(Session[DealsNZ.Helpers.KeyList.SessionKeys.UserID].ToString()));

            if (CreateCoupon.CouponPrice > AddTrans.WalletCredit)
            {
                walleservice.Dispose();
            }
            else
            {
                AddTrans.UserId           = Convert.ToInt32(Session[DealsNZ.Helpers.KeyList.SessionKeys.UserID].ToString());
                AddTrans.WalletCredit     = Convert.ToDecimal(Convert.ToDecimal(AddTrans.WalletCredit) - Convert.ToDecimal(CreateCoupon.CouponPrice));
                AddTrans.WalletCreditDate = System.DateTime.Now;

                Wallet DealUserWallet = walleservice.GetCreditByDealUserID(CreateCoupon.DealId);
                DealUserWallet.WalletCredit = Convert.ToDecimal(Convert.ToDecimal(DealUserWallet.WalletCredit) + Convert.ToDecimal(CreateCoupon.CouponPrice));

                if (walleservice.WalletUpdate(AddTrans) == true && walleservice.WalletUpdate(DealUserWallet) == true)
                {
                    Coupon InsertCoupon = new Coupon()
                    {
                        CouponUniqueText = CreateCoupon.DealId.ToString() + GenerateCode(),
                        CouponValidTill  = CreateCoupon.ValidTill,
                        CouponQty        = CreateCoupon.CouponQty,
                        CouponPrice      = CreateCoupon.CouponPrice,
                        AddedOn          = System.DateTime.Now.Date,
                        DealId           = CreateCoupon.DealId,
                        UserId           = Convert.ToInt32(Session[KeyList.SessionKeys.UserID]),
                        ReedemNo         = 0
                    };
                    couponservice = new CouponService(new DealsDB());
                    couponservice.Insert(InsertCoupon);
                    couponservice.Dispose();
                    Session[KeyList.SessionKeys.WalletCredit] = walleservice.ShowWalletAmount(Convert.ToInt32(Session[DealsNZ.Helpers.KeyList.SessionKeys.UserID].ToString()));
                    walleservice.Dispose();
                    string       CouponBody         = createEmailBody(CreateCoupon.StoreName, CreateCoupon.Address, CreateCoupon.Title, CreateCoupon.Price.ToString(), CreateCoupon.StrikePrice.ToString(), CreateCoupon.Discount.ToString(), InsertCoupon.CouponQty.ToString(), InsertCoupon.CouponValidTill.ToString(), InsertCoupon.CouponUniqueText);
                    string       Title              = "Coupon For " + CreateCoupon.Title;
                    IUserProfile UserProfileService = new UserProfileServices(new DealsDB());
                    if (UserProfileService.UserMail(CouponBody, Title, Session[KeyList.SessionKeys.UserEmail].ToString()) == true)
                    {
                        dealServices = new DealServices(new DealsDB());
                        ViewSingleDeal SingleDeal = dealServices.GetSingleDeal(CreateCoupon.DealId);
                        dealServices.Dispose();
                        ViewBag.Message = "Check Your Mail To Get Coupon";
                        return(View("Index", SingleDeal));
                    }
                }
                else
                {
                    walleservice.Dispose();
                }
            }

            return(View());
        }
示例#28
0
 protected void AssertApproveApproval(IDeal d, IApproval approval)
 {
     AssertApproval(d, approval, ApprovalAction.Approve);
 }
示例#29
0
 public void AddDeal(IDeal deal)
 {
     lock (Deals)
     {
         Deals.Add(deal);
     }
 }
示例#30
0
文件: BaseUnit.cs 项目: MyRSG/COAT
 public virtual IApproval Decline(IDeal deal, BaseApprArgs args)
 {
     deal.Switch(WorkFlowStep.Decline);
     deal.Save();
     return CreateApproval(deal.Id, args.ActionUser, ApprovalAction.Decline, args.Comment);
 }
示例#31
0
文件: BaseUnit.cs 项目: MyRSG/COAT
 protected abstract void SendNotifcationMail(IDeal deal, BaseApprArgs args);
示例#32
0
 private void AssertAnswer(IDeal deal, IApproval app, IAnswer answer)
 {
     var actureAnswer = WorkFlowManager.WorkFlowFactory.GetAnswer(deal.Id, app.Id);
     Assert.AreEqual(deal.Id, actureAnswer.DealId);
     Assert.AreEqual(app.Id, actureAnswer.ApprovalId);
     Assert.AreEqual(answer.QuestionId, actureAnswer.QuestionId);
     Assert.AreEqual(answer.Answer, actureAnswer.Answer);
 }
示例#33
0
 protected override void ApproveDeal(IDeal deal, BaseApprArgs args)
 {
     deal.Switch(WorkFlowStep.Approve);
     deal.Save();
 }
示例#34
0
文件: SalesTeam.cs 项目: MyRSG/COAT
 protected override void ApproveDeal(IDeal deal, BaseApprArgs args)
 {
     deal.Switch(deal.Size > DirectorSize ? WorkFlowStep.ChannelDirector : WorkFlowStep.Approve);
     deal.Save();
 }
示例#35
0
 public DealsViewModel(INavigationService navigationService, IDeal service) : base(navigationService)
 {
     this.service = service;
 }
 public Task AddAsync(IDeal obj)
 {
     return(_tableStorage.InsertAsync(_convertService.Convert <IDeal, DealEntity>(obj)));
 }
示例#37
0
 public void RegisterDeal(IDeal deal, int discount)
 {
     _deals.Add(new KeyValuePair <IDeal, int>(deal, discount));
 }
示例#38
0
 public DealEventArgs(IDeal deal)
 {
     this.deal = deal;
 }
示例#39
0
文件: ORPTeam.cs 项目: MyRSG/COAT
 protected override void SendNotifcationMail(IDeal deal, BaseApprArgs args)
 {
 }
        private Task CommitExceptionHandler(Exception exception, IPositionHistory positionHistory, IDeal deal)
        {
            var context = $"Error {exception.Message} \n" +
                          $"Entity <{nameof(IPositionHistory)}>: \n" +
                          positionHistory.ToJson() + " \n" +
                          $"Entity <{nameof(IDeal)}>: \n" +
                          deal?.ToJson();

            return(_log.WriteErrorAsync(nameof(PositionsHistorySqlRepository), nameof(AddAsync), context, exception));
        }
示例#41
0
        public string Save(IDeal deal)
        {
            //if (_dealRepository == null)
            //    throw new ArgumentNullException("DealRepository cannot be null");
            //if (deal.Id == Guid.Empty)
            //{
            //    // new deal
            //    deal.DateCreated = DateTime.Now;
            //    deal.Active = true;
            //    deal.Id = Guid.NewGuid();
            //    deal.DateModified = null;
            //    _dealRepository.Add((DF.Domain.Concrete.Deal)deal);

            //    _dealRepository.UnitOfWork.Commit();

            //}
            //else
            //{
            //    var oDeal = _dealRepository.Where(u => u.Id == deal.Id).SingleOrDefault();

            //    if (oDeal == null)
            //        throw new ArgumentNullException("deal");

            //    deal.DateCreated = oDeal.DateCreated;

            //    Magically.CopyPropertyValues(ref oDeal, (DF.Domain.Concrete.Deal)deal);

            //    _dealRepository.UnitOfWork.Commit();

            //}

            //return string.Format("Successfully saved deal {0} {1}", deal.FirstName, deal.LastName);

            return string.Empty;
        }
 public PokerController(Deal deal)
 {
     this.deal = deal;
 }
示例#43
0
 public DealEventArgs(IDeal deal)
 {
     this.deal = deal;
 }
示例#44
0
文件: BaseUnit.cs 项目: MyRSG/COAT
 protected virtual void AdditionOpeation(IDeal deal, IApproval approval, BaseApprArgs args)
 {
 }