Ejemplo n.º 1
0
 public static void entityInsert(Entity entity, Account account)
 {
     var _esc = new EntityServiceClient();
     var _parentEntity = _esc.LoadEntity2(entity.ParentID)[0];
     entity.ExchangeRate = _parentEntity.ExchangeRate;
     entity.Currency.CurrencyID = _parentEntity.Currency.CurrencyID;
         _esc.NewEntity3(entity, account);
 }
Ejemplo n.º 2
0
 private bool checkSameTransaction(int entityID,string entityName)
 {
     var esc = new EntityServiceClient();
     EntityCollection _ec = new EntityCollection();
     EntityCollection _ecs = new EntityCollection(esc.LoadEntity2(entityID));
     var _newTallyCollection = EntitiesFunc.entityCollectioin(_ec, _ecs);
     if (_newTallyCollection.Where(x => (x.SumType == SumType.Transaction && x.EntityName == entityName) || (x.SumType == SumType.Subtotal && x.EntityName == entityName)).Count() > 0)
         return true;
     else
         return false;
 }
Ejemplo n.º 3
0
        private void insertNodeEntity(string jsonEntityString)
        {
            JsonEntities _jsonEntity = JsonConvert.DeserializeObject<JsonEntities>(jsonEntityString);
            if (checkSameTransaction(_jsonEntity.ParentID,_jsonEntity.EntityName) && (_jsonEntity.SumType==1 || _jsonEntity.SumType==2))
            {
                Response.Write(string.Format("There are two {0} {1} Entities!", _jsonEntity.EntityName,EntitiesFunc.sumTypeFunc(_jsonEntity.SumType)));
            }
            else
            {
                var _epsr = new EndPeriodServiceClient();
                var _esr = new EntityServiceClient();
                decimal _exchangeRate;
                Currency _currency;
                if(_jsonEntity.SumType==1)
                {
                    _currency = new Currency{CurrencyID =_jsonEntity.EntityName};
                    _exchangeRate = _epsr.GetEndPeriodRate(new Currency { CurrencyID = _jsonEntity.EntityName })[0].ExchangeRate;

                }
                else if (_jsonEntity.SumType == 2)
                {
                    _currency = _esr.LoadEntity2(_jsonEntity.ParentID)[0].Currency;
                    _exchangeRate = decimal.Parse(_jsonEntity.EntityName);
                }
                else if (_jsonEntity.ParentID == 0)
                {
                    _currency = null;
                    _exchangeRate = 1;
                }
                else
                {
                    var _parentSubTotalEntity= _esr.QueryParentSubTotalEntity(_jsonEntity.ParentID)[0];
                    _exchangeRate = _parentSubTotalEntity.ExchangeRate;
                    _currency = _parentSubTotalEntity.Currency;
                }

                #region "Entity"
                Entity _entity = new Entity
                {
                    EntityName = _jsonEntity.EntityName,
                    EntityType = EntitiesFunc.entityTypeFunc(_jsonEntity.EntityType),
                    IsAccount = _jsonEntity.IsAccount ? 1 : 0,
                    IsLastLevel = _jsonEntity.IsLastLevel ? 1 : 0,
                    ParentID = _jsonEntity.ParentID,
                    ExchangeRate = _exchangeRate,
                    Currency = _currency,
                    SumType = EntitiesFunc.sumTypeFunc(_jsonEntity.SumType)
                };
                #endregion
                try
                {
                    if (!_jsonEntity.IsAccount)
                    {//no account
                        EntitiesFunc.entityInsert(_entity);
                    }
                    else
                    {//has account
                        #region "Account"
                        Account _account = new Account
                        {
                            AccountName = _jsonEntity.Account.AccountName,
                            Company = _jsonEntity.Account.Company,
                            Password = _jsonEntity.Account.Password,
                            AccountType = EntitiesFunc.accoutnTypeFunc(_jsonEntity.Account.AccountType),
                            BettingLimit = _jsonEntity.Account.BettingLimit,
                            DateOpen = _jsonEntity.Account.DateOpen,
                            Factor = _jsonEntity.Account.Factor,
                            Personnel = _jsonEntity.Account.Personnel,
                            IP = _jsonEntity.Account.IP,
                            Odds = _jsonEntity.Account.Odds,
                            IssuesConditions = _jsonEntity.Account.IssuesConditions,
                            RemarksAcc = _jsonEntity.Account.RemarksAcc,
                            Perbet = _jsonEntity.Account.Perbet
                        };
                        #endregion
                        EntitiesFunc.entityInsert(_entity, _account);
                    }
                    Response.Write("Success!");
                }
                catch
                {
                    Response.Write("Fail!");
                }
            }
        }