예제 #1
0
        public void IdentityCacheCleanup()
        {
            NorthwindEntityContainer ec = new NorthwindEntityContainer();

            ec.LoadEntities(new Entity[] { new Product {
                                               ProductID = 1
                                           }, new Product {
                                               ProductID = 2
                                           }, new Product {
                                               ProductID = 3
                                           } });
            EntitySet <Product> productSet = ec.GetEntitySet <Product>();

            // Delete an entity
            Product prod = productSet.First();
            int     key  = prod.ProductID;

            productSet.Remove(prod);
            ((IChangeTracking)ec).AcceptChanges();
            // After the delete, the entity is moved back into the default state
            Assert.AreEqual(EntityState.Detached, prod.EntityState);

            // After it has been deleted, we should be able to add
            // a new entity with the same key
            Product newProduct = new Product
            {
                ProductID = key
            };

            productSet.Add(newProduct);
            Assert.AreEqual(EntityState.New, newProduct.EntityState);
            ((IChangeTracking)ec).AcceptChanges();
            Product requeriedProduct = productSet.Single(p => p.ProductID == key);

            Assert.AreSame(newProduct, requeriedProduct);  // make sure instances are same

            // Bug 526544 repro case - delete and submit, then attempt
            // to re-add
            prod = productSet.First();
            key  = prod.ProductID;
            productSet.Remove(prod);
            ((IChangeTracking)ec).AcceptChanges();
            productSet.Add(prod);
            Assert.AreEqual(EntityState.New, prod.EntityState);
            ((IChangeTracking)ec).AcceptChanges();

            // verify that when an entity is Detached, it is removed from ID cache
            // after the detach, attaching an entity with the same key should succeed
            prod = productSet.First();
            key  = prod.ProductID;
            productSet.Detach(prod);
            newProduct = new Product
            {
                ProductID = key
            };
            productSet.Attach(newProduct);
            requeriedProduct = productSet.Single(p => p.ProductID == key);
            Assert.AreSame(newProduct, requeriedProduct);  // make sure instances are same
        }
예제 #2
0
 public void Add_IgnoreRepeats()
 {
     var people = new EntitySet<Person>();
     var p = new Person { FirstName = "A", LastName = "B" };
     people.Add(p);
     people.Add(p);
     Assert.AreEqual(1, people.Count);
 }
예제 #3
0
        public void Setup()
        {
            _entities = new EntitySet();
            _entities.Add().AddComponent <Component1>();
            _entities.Add().AddComponent <Component2>();
            _entities.Add().AddComponent <Component1>();
            var lastEntity = _entities.Add();

            lastEntity.AddComponent <Component1>();
            lastEntity.AddComponent <Component2>();
        }
예제 #4
0
        public void Add_IgnoreRepeats()
        {
            var people = new EntitySet <Person>();
            var p      = new Person {
                FirstName = "A", LastName = "B"
            };

            people.Add(p);
            people.Add(p);
            Assert.AreEqual(1, people.Count);
        }
예제 #5
0
        public void AddRemove()
        {
            var entitySet = new EntitySet(e => true);
            var entity    = new StubEntity();

            entitySet.Add(entity);
            Assert.AreEqual(1, entitySet.Count);
            entitySet.Remove(entity);
            Assert.AreEqual(0, entitySet.Count);
            entitySet.Add(entity);
            Assert.AreEqual(1, entitySet.Count);
        }
예제 #6
0
        public void ICVF_RemoveAt()
        {
            EntitySet <City>        entitySet = this.CreateEntitySet <City>();
            IEditableCollectionView view      = this.GetIECV(entitySet);

            entitySet.Add(this.CreateLocalCity("Renton"));
            entitySet.Add(this.CreateLocalCity("Kent"));
            entitySet.Add(this.CreateLocalCity("Auburn"));

            City city = entitySet.ElementAt(1);

            view.RemoveAt(1);
            Assert.IsFalse(entitySet.Contains(city),
                           "EntitySet should no longer contain the entity at index 1.");
        }
예제 #7
0
        /// <summary>
        /// 提交处理
        /// </summary>
        /// <param name="RoletId">角色Id</param>
        /// <param name="Name">角色名</param>
        /// <param name="Remark">备注</param>
        /// <param name="Right">权利Id的数组</param>
        /// <returns></returns>
        public ActionResult  CreateEdit(string RoleId, string Name, string Remark, int[] Right)
        {
            Role role;

            EntitySet <RoleRight> rights = new EntitySet <RoleRight>();

            if (Right != null)
            {
                foreach (int code in Right)
                {
                    RoleRight rr = new RoleRight();
                    rr.RightCode = code;
                    rights.Add(rr);
                }
            }

            if (string.IsNullOrEmpty(RoleId))
            {
                role = new Role();
            }
            else
            {
                role = db.GetOneRole(int.Parse(RoleId));
            }
            db.DeleteAllOnSubmit(role.RoleRight);
            role.RoleRight = rights;
            role.Name      = Name;
            role.Remark    = Remark;
            db.Save(role);
            return(Json("OK"));
        }
예제 #8
0
        void LoadQuestion()
        {
            var    question = view.QuestionList[currentQuestionIndex];
            string content  = $"Câu {currentQuestionIndex + 1}: {question.Content}";

            EntitySet <Answer> answerList = new EntitySet <Answer>();

            foreach (var item in question.Answers)
            {
                Answer answer = new Answer()
                {
                    AnswerId   = item.AnswerId,
                    QuestionId = item.QuestionId,
                    Content    = item.Content,
                    IsCorrect  = item.IsCorrect
                };

                answerList.Add(answer);
            }

            //copy object
            view.Question = new Question()
            {
                QuestionId     = question.QuestionId,
                Content        = content,
                Hint           = question.Hint,
                SubjectId      = question.SubjectId,
                GradeId        = question.GradeId,
                DifficultLevel = question.DifficultLevel,
                Answers        = answerList
            };
            view.AnswerList = context.Answers.Where(w => w.QuestionId == question.QuestionId).ToList();
        }
예제 #9
0
        protected AggregationServiceTestBase()
        {
            _metadata = new EntityMetadata(1, 3);

            _property0 = _metadata.Properties[0];
            _property1 = _metadata.Properties[1];
            _property2 = _metadata.Properties[2];

            _aggregatorConfig0 = new WgtAvgPropertyAggregatorConfig(0, _property0, _property1);
            _aggregatorConfig1 = new WgtAvgPropertyAggregatorConfig(1, _property1, _property2);
            _aggregatorConfig2 = new WgtAvgPropertyAggregatorConfig(2, _property0, _property2);

            _entity0 = CreateEntity(0, 10, 20, 30);
            _entity1 = CreateEntity(1, 11, 21, 31);
            _entity2 = CreateEntity(2, 12, 22, 32);

            _set = new EntitySet {
                _entity0, _entity1
            };

            var config  = new AggregationConfig(_metadata, new[] { _aggregatorConfig0, _aggregatorConfig1, _aggregatorConfig2 });
            var service = new TAggregationService();

            _root = service.Aggregate(_set, config, _metadata);
            _root.Start();

            _set.Add(_entity2);

            _rootResult = _root.Result;
        }
예제 #10
0
        public TEntity Add(TEntity entity)
        {
            var ret = EntitySet.Add(entity);

            DbContext.SaveChanges();
            return(ret);
        }
예제 #11
0
        public override EntitySet LoadWithId(string type, string[] id, string[] attributes)
        {
            EntitySet result = new EntitySet();

            foreach (string itemId in id)
            {
                string strQuote = itemId.IndexOf("'") > 0 ? "\"" : "'"; // if id contains ' limiter is " else '

                ArrayList subQueries = new ArrayList();

                // Creates a query for each sub-type, and concatenates them using and OR expression
                foreach (string subtype in Factory.Model.GetTreeAsArray(type))
                    subQueries.Add(String.Concat("id(", strQuote, _CommandProcessor.GetKey(subtype, itemId), strQuote, ")"));

                if (subQueries.Count == 0)
                    throw new ModelElementNotFoundException("No such types in metadata: " + type);

                EntitySet es = LoadWithXPath(String.Join(" | ", (string[])subQueries.ToArray(typeof(string))));

                if (es.Count > 0)
                    result.Add(es[0]);
            }

            if (result.Count > 0)
                LoadAttribute(result, attributes);

            return result;
        }
예제 #12
0
        private void AddEntity <T1>(EntitySet <T1> entitySet, IEnumerator <T1> toAddEntities,
                                    Action <SubmitOperation> onSubmittedEachChange, Action onSubmittedAllChanges) where T1 : Entity
        {
            if (toAddEntities.MoveNext())
            {
                T1 addingEntity = toAddEntities.Current;

                _DelayTaskQueue.RunSingleTask(() =>
                {
                    entitySet.Add(addingEntity);

                    _DomainContext.SubmitChanges(op =>
                    {
                        if (onSubmittedEachChange != null)
                        {
                            onSubmittedEachChange(op);
                        }

                        AddEntity(entitySet, toAddEntities, onSubmittedEachChange, onSubmittedAllChanges);
                    }, addingEntity);
                }, _SubmitInterval, () => entitySet.HasChanges, 1);
            }
            else
            if (onSubmittedAllChanges != null)
            {
                onSubmittedAllChanges();
            }
        }
예제 #13
0
        public void Handle(TCommand command)
        {
            var entity = Mapper.Map <TEntity>(command);

            EntitySet.Add(entity);
            UnitOfWork.Save();
            RedisCache.Remove(RedisHelper.ComposeRedisKey(typeof(TEntity).Name, "*"));
        }
예제 #14
0
 public void Add(TEntity entity)
 {
     if (entity != null)
     {
         throw new ArgumentNullException("entity");
     }
     EntitySet.Add(entity);
 }
예제 #15
0
        Entities.Context.Order ConvertToOrder(StudentInGroup sig)
        {
            if (sig == null)
            {
                return(null);
            }
            var email = sig.Student.StudentEmails.OrderByDescending(x => x.StudentEmail_ID).FirstOrDefault()
                        .GetOrDefault(x => x.Email.Trim());

            if (email.IsEmpty() || email.Contains(" ") || !email.Contains("@"))
            {
                email = null;
            }
            var orderDetails = new EntitySet <OrderDetail>();
            var orderExams   = new EntitySet <OrderExam>();

            GroupService.LoadWith(x => x.Course);
            var group = GroupService.GetByPK(sig.Group_ID);

            if (sig.Exam_ID > 0)
            {
                orderExams.Add(new OrderExam {
                    Exam_ID = sig.Exam_ID.Value
                });
            }
            else
            {
                orderDetails.Add(new OrderDetail {
                    Group = group, Course_TC = group.Course_TC, Course = group.Course, Track_TC = sig.Track_TC
                });
            }
            var order = new Entities.Context.Order {
                User = new User {
                    FirstName  = sig.Student.FirstName,
                    LastName   = sig.Student.LastName,
                    SecondName = sig.Student.MiddleName,
                    Email      = email
                },
                IsSig     = true,
                OrderID   = sig.StudentInGroup_ID,
                IsSigPaid = sig.BerthType_TC == BerthTypes.Paid,
                TotalPriceWithDescount = sig.PartialPayment > 0
                                        ? sig.PartialPayment.Value
                                        : sig.Charge.GetValueOrDefault(),
                OrderDetails = orderDetails,
                OrderExams   = orderExams,
                OurOrg_TC    = null,
                Description  = "Оплата спец заказа №" + sig.StudentInGroup_ID
            };
            var context = new PioneerDataContext();

//		    if (PriceService.DopUslCourses().Contains(group.Course_TC)) {
//			    order.OurOrg_TC = OurOrgs.Bt;
//		    }

            order.OurOrg_TC = context.fnGetDefaultOurOrgTC(sig.StudentInGroup_ID, null);
            return(order);
        }
예제 #16
0
        /*
         * view-source:http://armory.twinstar.cz/guild-info.xml?r=Artemis&gn=Exalted
         */
        public static IEnumerable <Guild> GuildCharactersParser(WebPage wp)
        {
            XDocument             xdoc;
            List <Guild>          parsed     = new List <Guild>();
            EntitySet <Character> characters = new EntitySet <Character>();

            if (wp.OK)
            {
                try
                {
                    xdoc = XDocument.Parse(wp.content);

                    IEnumerable <XElement> elems2 = from el in xdoc.Descendants("guildHeader")
                                                    select el;

                    XElement header = elems2.First();

                    Guild g = new Guild();
                    g.Name         = (string)header.Attribute("name");
                    g.Level        = int.Parse((string)header.Attribute("level"));
                    g.FactionId    = int.Parse((string)header.Attribute("faction"));
                    g.AP           = 0;
                    g.ForceRefresh = true;
                    g.LastRefresh  = DateTime.Now;

                    IEnumerable <XElement> elems = from el in xdoc.Descendants("character")
                                                   select el;

                    foreach (XElement character in elems)
                    {
                        Character c = new Character();

                        c.Name         = (string)character.Attribute("name");
                        c.Level        = int.Parse((string)character.Attribute("level"));
                        c.ClassId      = int.Parse((string)character.Attribute("classId"));
                        c.RaceId       = int.Parse((string)character.Attribute("raceId"));
                        c.GenderId     = int.Parse((string)character.Attribute("genderId"));
                        c.FactionId    = g.FactionId;
                        c.AP           = int.Parse((string)character.Attribute("achPoints"));
                        c.HK           = 0;
                        c.ForceRefresh = true;
                        c.LastRefresh  = DateTime.Now;

                        c.Guild = g;

                        characters.Add(c);
                    }
                    g.Characters = characters;
                    parsed.Add(g);
                }
                catch
                {
                    Logger.Log("Erorr in GuildCharactersParser, URL " + wp.URL);
                }
            }

            return(parsed);
        }
예제 #17
0
 public EntitySet<Territory> GetTerritories()
 {
     var entities = new EntitySet<Territory>();
     foreach (var territory in this.Territories)
     {
         entities.Add(territory);
     }
     return entities;
 }
예제 #18
0
        public async Task <int> AddUserAsync(User user)
        {
            if (user.UserId == 0)
            {
                EntitySet.Add(user);
            }

            return(await SaveChanges());
        }
        public void Create(TimeInquiryEntity entity)
        {
            var newTimeInquiryEntry = entity.Adapt <TimeInquiryEntity, TimeInquiry>();

            EntitySet.Add(newTimeInquiryEntry);
            Context.SaveChanges();

            newTimeInquiryEntry.Adapt(entity);
        }
예제 #20
0
        public async Task HandleAsync(TCommand command)
        {
            var entity = Mapper.Map <TEntity>(command);

            EntitySet.Add(entity);
            await UnitOfWork.SaveAsync();

            await RedisCache.RemoveAsync(RedisHelper.ComposeRedisKey(typeof(TEntity).Name, "*"));
        }
예제 #21
0
        public void Add()
        {
            Setup();

            foreach (var city in GetCities())
            {
                _entitySet.Add(city);
            }
        }
예제 #22
0
        public void ListChanged_NoSource()
        {
            // When is ListChanged emitted?
            // It's not always when you think it would be.
            // It depends on whether there's a Source present.
            var people = new EntitySet <Person>();
            var events = new List <ListChangedEventArgs> ();

            people.ListChanged += (o, e) => events.Add(e);

            people.Add(new Person {
                FirstName = "A", LastName = "B"
            });
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1));

            events.Clear();
            people.Clear();
            AssertEqual(events,
                        new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                        new ListChangedEventArgs(ListChangedType.Reset, 0, -1));

            events.Clear();
            people.AddRange(new[] {
                new Person {
                    FirstName = "1", LastName = "2"
                },
                new Person {
                    FirstName = "<", LastName = ">"
                },
            });
            AssertEqual(events,
                        new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1),
                        new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1));

            events.Clear();
            var p = new Person {
                FirstName = "{", LastName = "}"
            };

            people.Insert(1, p);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemAdded, 1, -1));

            events.Clear();
            Assert.IsTrue(people.Remove(p));
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 1, -1));

            events.Clear();
            people.RemoveAt(0);
            AssertEqual(events, new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1));

            events.Clear();
            people[0] = p;
            AssertEqual(events,
                        new ListChangedEventArgs(ListChangedType.ItemDeleted, 0, -1),
                        new ListChangedEventArgs(ListChangedType.ItemAdded, 0, -1));
        }
예제 #23
0
 public void Add_ThenSetSourceIsInvalid()
 {
     var people = new EntitySet<Person>();
     Assert.IsFalse(people.HasLoadedOrAssignedValues);
     people.Add(new Person { FirstName = "A", LastName = "B" });
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.SetSource(new[]{
         new Person { FirstName = "1", LastName = "2" }
     });
 }
예제 #24
0
        public void Insert_RepeatValue()
        {
            var people = new EntitySet <Person>();
            var p      = new Person {
                FirstName = "A", LastName = "B"
            };

            people.Add(p);
            people.Insert(0, p);
        }
예제 #25
0
        private TestTable GetTestTable()
        {
            var person = new EntitySet <Person>();

            person.Add(new Person()
            {
                Person1 = "test"
            });
            person.Add(new Person()
            {
                Person1 = "test2"
            });

            var table = new TestTable()
            {
                Name = "Complex", Description = "Record Insert.", Person = person
            };

            return(table);
        }
예제 #26
0
        public void ModifiedEnumerable()
        {
            var entitySet = new EntitySet(e => true);
            var entity    = new StubEntity();

            entitySet.Add(entity);

            // Contains
            Assert.IsTrue(entitySet.Contains(entity));

            // GetEnumerator
            Assert.AreSame(entity, entitySet.First());
            var enumerable = (IEnumerable)entitySet;
            var enumerator = enumerable.GetEnumerator();

            entitySet.Add(new StubEntity());             // modify collection
            Assert.IsTrue(enumerator.MoveNext(), "shouldn't crash, should have original list of entities");
            Assert.AreSame(entity, enumerator.Current);
            Assert.IsFalse(enumerator.MoveNext(), "should be end of original 1 entity list");
        }
예제 #27
0
        private void BeginSubmitCityData(Action <SubmitOperation> callback)
        {
            EntitySet entitySet = this.CityDomainContext.EntityContainer.GetEntitySet <City>();

            entitySet.Add(new City()
            {
                Name = "NewCity", StateName = "NN", CountyName = "NewCounty"
            });

            this.SubmitOperation = this.CityDomainContext.SubmitChanges(callback, this.CityDomainContext);
        }
예제 #28
0
        public void IList_Add_DuplicateItem()
        {
            var people = new EntitySet <Person>();
            var p      = new Person {
                FirstName = "A", LastName = "B"
            };

            people.Add(p);
            System.Collections.IList list = people;
            list.Add(p);
        }
예제 #29
0
    public static EntitySet <T> ToEntitySetFromInterface <T, U>(this IList <U> source) where T : class, U
    {
        var             es = new EntitySet <T>();
        IEnumerator <U> ie = source.GetEnumerator();

        while (ie.MoveNext())
        {
            es.Add((T)ie.Current);
        }
        return(es);
    }
예제 #30
0
 public void Add(T entity)
 {
     if (EntitySet.Count > 0)
     {
         entity.Id = EntitySet.Max(x => x.Value.Id) + 1;
     }
     else
     {
         entity.Id = 1;
     }
     EntitySet.Add(entity.Id, entity);
 }
        public void GetPointsList(Action<Microsoft.Windows.Data.DomainServices.EntityList<Point>> getPointsCallback, int pageSize)
        {
            EntitySet<Point> es = new EntitySet<Point>();
            DesignPoints designPoints = new DesignPoints();
            foreach (var dp in designPoints)
            {
                es.Add(dp);
            }

            var pointsEntityList = new EntityList<Point>(es);
            getPointsCallback(pointsEntityList);
        }
예제 #32
0
 public void Clear_DoesNotResetSource()
 {
     var people = new EntitySet<Person>();
     Assert.IsFalse(people.HasLoadedOrAssignedValues);
     people.Add(new Person { FirstName = "A", LastName = "B" });
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.Clear();
     Assert.IsTrue(people.HasLoadedOrAssignedValues);
     people.SetSource(new[]{
         new Person { FirstName = "1", LastName = "2" },
     });
 }
예제 #33
0
        /// <summary>
        /// 获取实体集
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="elements"></param>
        /// <returns></returns>
        public EntitySet <TEntity> GetEntitySet <TEntity>(IEnumerable <XElement> elements = null) where TEntity : class
        {
            EntitySet <TEntity> entitySet = new EntitySet <TEntity>();
            Type      entityType          = typeof(TEntity);
            ArrayList entities            = this._GetEntitySet(entityType);

            foreach (object entity in entities)
            {
                entitySet.Add(Convert.ChangeType(entity, entityType) as TEntity);
            }
            return(entitySet);
        }
        public void SanityChecking()
        {
            var  people  = new EntitySet <Person>();
            bool changed = false;

            people.ListChanged += (o, e) =>
            {
                changed = true;
            };

            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(0, people.Count);
            Assert.IsFalse(people.IsDeferred);

            people.Add(new Person {
                FirstName = "A", LastName = "B"
            });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            // WTF?!
            Assert.IsFalse(changed);

            changed = false;
            people.Add(new Person {
                FirstName = "1", LastName = "2"
            });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(2, people.Count);
            // WTF?!
            Assert.IsFalse(changed);


            changed = false;
            people.RemoveAt(0);
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            Assert.IsTrue(changed);
        }
예제 #35
0
        protected virtual void Add(TEntity entity)
        {
            DbEntityEntry entry = Context.Entry(entity);

            if (entry.State != EntityState.Detached)
            {
                entry.State = EntityState.Added;
            }
            else
            {
                EntitySet.Add(entity);
            }
        }
예제 #36
0
 public virtual T Insert(T entity)
 {
     try
     {
         var ent = EntitySet.Add(entity);
         return(ent);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         throw;
     }
 }
        public void AllowModifications_Set()
        {
            posts = new EntitySet<Post>(
                delegate(Post p)
                {
                    using (posts.AllowModifications)
                    {
                        posts.Add(new Post("Duplicate"));
                    }
                }, null);

            posts.Add(new Post("Original"));

            Assert.AreEqual(2, posts.Count);
        }
예제 #38
0
        public EntitySet<countrycostofeducation> getCountryCostOfEducation()
        {
            EntitySet<countrycostofeducation> cced = new EntitySet<countrycostofeducation>();

            try
            {
                dbDataContext ct = new dbDataContext();
                var queryCountry = from sg in ct.countrycostofeducations
                                   select sg;

                foreach (countrycostofeducation cc in queryCountry)
                {
                    cced.Add(cc);
                }

            }
            catch (Exception e)
            {
                string str = e.Message;
            }

            return cced;
        }
        public void modificarGrupo(int IdGrupo, string Nombre, string Descripcion, bool activo, List<string> usuarios, Dictionary<int, List<int>> ListaIdPantallas_Controles)
        {
            try
            {
                GRuPOs grupo = database.GRuPOs.Where(g => g.IDGrupo == IdGrupo).Single();
                grupo.Nombre = Nombre;
                grupo.Descripcion = Descripcion;
                if (activo)
                    grupo.Activo = 1;
                else
                    grupo.Activo = 0;
                UsUarIoSGRuPOs ug;
                EntitySet<UsUarIoSGRuPOs> lista = new EntitySet<UsUarIoSGRuPOs>();
                foreach (string username in usuarios)
                {
                    ug = new UsUarIoSGRuPOs();
                    int iduser = database.UsUarIoS.Where(u => u.UserName == username).Select(u=>u.IDUsuario).Single();
                    ug.IDUsuario = iduser;
                    ug.GRuPOs = grupo;
                    lista.Add(ug);
                }
                
                grupo.UsUarIoSGRuPOs = lista;

                List<PerMisOs> listaPermisos = new List<PerMisOs>();
                PerMisOs permiso;
                PerMisOs control;
                foreach (int idpantalla in ListaIdPantallas_Controles.Keys)
                {
                    permiso = new PerMisOs();
                    permiso.Activo = 1;
                    permiso.IDPermiso = IdGrupo;
                    permiso.IDControl = idpantalla;
                    permiso.UsuarioOrgRupo = "G";
                    permiso.WinFormOrcOntrol = "W";
                    listaPermisos.Add(permiso);
                    foreach (int idcontrol in ListaIdPantallas_Controles[idpantalla])
                    {
                        control = new PerMisOs();
                        control.Activo = 1;
                        control.IDPermiso = IdGrupo;
                        control.IDControl = idcontrol;
                        control.UsuarioOrgRupo = "G";
                        control.WinFormOrcOntrol = "C";
                        listaPermisos.Add(control);
                    }
                }
                List<PerMisOs> permsViejos = (from reg in database.PerMisOs
                                              where reg.IDPermiso == IdGrupo && reg.UsuarioOrgRupo=="G"
                                              select reg).ToList();
                //List<UsUarIoSGRuPOs> usugroupsViejos = (from reg in database.UsUarIoSGRuPOs
                //                                        where reg.IDGrupo == IdGrupo
                //                                        select reg).ToList();
                //database.UsUarIoSGRuPOs.DeleteAllOnSubmit(usugroupsViejos);
                database.SubmitChanges();
                database.PerMisOs.DeleteAllOnSubmit(permsViejos);
                database.SubmitChanges();
                database.PerMisOs.InsertAllOnSubmit(listaPermisos);
                database.SubmitChanges();
            }
            catch
            {
                ControladorDatos.createContext();
                throw;
            }
        }
예제 #40
0
        private EntitySet<OrderItem> GetOrderItems()
        {
            var items = new EntitySet<OrderItem>();

            foreach (var orderItem in ShoppingCart.Select(cartProduct => new OrderItem
                                                                             {
                                                                                 ProductId = cartProduct.ProductId,
                                                                                 Price = cartProduct.Price,
                                                                                 Quantity = cartProduct.Quantity
                                                                             }))
            {
                items.Add(orderItem);
            }

            return items;
        }
예제 #41
0
 public void Add_EntityNull()
 {
     var people = new EntitySet<Person>();
     people.Add(null);
 }
예제 #42
0
        public retirementgoal updateRetirementGoals(retirementgoal goals)
        {
            retirementgoal retrievedGoal = null;

            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing retirement goal
                var queryRetirementGoals = from sg in ct.retirementgoals
                                       where sg.caseid == goals.caseid
                                       && sg.selforspouse == goals.selforspouse
                                       select sg;
                foreach (retirementgoal sgoals in queryRetirementGoals)
                {
                    retrievedGoal = sgoals;
                }

                //update retirement goal attributes
                retrievedGoal.durationretirement = goals.durationretirement;
                retrievedGoal.futureincome = goals.futureincome;
                retrievedGoal.incomerequired = goals.incomerequired;
                retrievedGoal.intendedretirementage = goals.intendedretirementage;
                retrievedGoal.lumpsumrequired = goals.lumpsumrequired;
                retrievedGoal.maturityvalue = goals.maturityvalue;
                retrievedGoal.sourcesofincome = goals.sourcesofincome;
                retrievedGoal.total = goals.total;
                retrievedGoal.totalfirstyrincome = goals.totalfirstyrincome;
                retrievedGoal.yrstoretirement = goals.yrstoretirement;
                retrievedGoal.existingassetstotal = goals.existingassetstotal;
                retrievedGoal.inflationreturnrate = goals.inflationreturnrate;
                retrievedGoal.inflationrate = goals.inflationrate;
                retrievedGoal.retirementGoalNeeded = goals.retirementGoalNeeded;

                //delete existing assets for the retirement goal
                var queryExistingAssets = from easg in ct.existingassetrgs
                                          where easg.retirementgoalsid == retrievedGoal.id
                                       select easg;
                foreach (existingassetrg easgoals in queryExistingAssets)
                {
                    ct.existingassetrgs.DeleteOnSubmit(easgoals);
                    //ct.SubmitChanges();
                }

                //update existing assets list for the retirement goal
                if (goals.existingassetrgs != null && goals.existingassetrgs.Count > 0)
                {
                    EntitySet<existingassetrg> easgList = new EntitySet<existingassetrg>();
                    foreach (existingassetrg sgea in goals.existingassetrgs)
                    {
                        easgList.Add(sgea);
                    }
                    retrievedGoal.existingassetrgs = easgList;
                }

                ct.SubmitChanges();

            }
            catch (Exception e)
            {
                string str = e.Message;
            }

            return retrievedGoal;
        }
예제 #43
0
        protected void submitSavingGoals(object sender, EventArgs e)
        {
            savinggoal goals = new savinggoal();

            goals.savingGoalNeeded = Convert.ToInt16(savingGoalNeeded.SelectedValue);

            if (goals.savingGoalNeeded == 2)
            {
                goals.goal = goal.Text;
                goals.yrstoaccumulate = yrstoAccumulate.Text;
                goals.amtneededfv = futureValue.Text;
                goals.maturityvalue = maturityValue.Text;

                if (totalShortfallSurplus.Text != null && totalShortfallSurplus.Text != "")
                {
                    double ttl = double.Parse(totalShortfallSurplus.Text);
                    if (ttl < 0)
                    {
                        totalShortfallSurplus.Text = Math.Abs(ttl).ToString();
                    }
                }
                goals.total = totalShortfallSurplus.Text;

                goals.existingassetstotal = existingAssets.Text;
            }
            else if (goals.savingGoalNeeded == 1 || goals.savingGoalNeeded == 0)
            {
                goals.goal = "";
                goals.yrstoaccumulate = "0";
                goals.amtneededfv = "0";
                goals.maturityvalue = "0";
                goals.total = "0";
                goals.existingassetstotal = "0";
            }

            goals.deleted = false;

            string caseid = "";
            if (ViewState["caseid"] != null)
            {
                caseid = ViewState["caseid"].ToString();
                goals.caseid = caseid;
            }

            int noofea = 0;
            if (goals.savingGoalNeeded == 2)
            {
                if (noofmembers.Value != "")
                {
                    noofea = Int16.Parse(noofmembers.Value);
                }
            }

            EntitySet<existingassetsg> easgList = new EntitySet<existingassetsg>();
            if (noofea > 0)
            {
                for (int i = 1; i <= noofea; i++)
                {
                    existingassetsg easg = new existingassetsg();
                    easg.asset = Request.Form["pridesc-" + i];
                    easg.presentvalue = Request.Form["pri_" + i];
                    easg.percentpa = Request.Form["sec_" + i];

                    if ((Request.Form["pridesc-" + i] != null) && (Request.Form["pri_" + i] != null) && (Request.Form["sec_" + i]!=null))
                    {
                        easgList.Add(easg);
                    }

                }
                goals.existingassetsgs = easgList;
            }

            int sgid = 0;
            if (ViewState["sgid"] != null)
            {
                sgid = Int32.Parse(ViewState["sgid"].ToString());
            }

            if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "new")
            {
                goals = savingGoalsDao.saveSavingGoals(goals);
            }
            else if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "update")
            {
                goals = savingGoalsDao.updateSavingGoals(goals, sgid);
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            string status = activityStatusCheck.getSavingGoalStatus(caseid);
            activityStatusDao.saveOrUpdateActivityStatus(caseid, actv, status);

            markStatusOnTab(caseid);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseid);

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseid, caseStatus, url, sendPdf);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (goals != null)
            {
                lblSavingGoalSuccess.Visible = true;

                savingGoal = savingGoalsDao.getSavingGoal(caseid);

                savinggoal displaysg = null;
                if (savingGoal != null && savingGoal.Count > 0)
                {
                    if (addandsave.Value == "1")
                    {
                        displaysg = savingGoal[savingGoal.Count-1];
                    }
                    else
                    {
                        bool found = false;
                        int count = 0;
                        foreach (savinggoal sgl in savingGoal)
                        {
                            if (sgid == sgl.id)
                            {
                                found = true;
                                break;
                            }
                            count++;
                        }

                        if (found)
                        {
                            displaysg = savingGoal[count];
                        }
                        else
                        {
                            displaysg = savingGoal[0];
                        }
                    }

                    savinggoalid.Value = displaysg.id.ToString();
                    addandsave.Value = "";
                }
                populateSavingGoal(displaysg, assmptn, caseid);

                List<savinggoal> gridgoal = savingGoal;
                foreach (savinggoal s in gridgoal)
                {
                    double damtfv = 0;
                    double dmaturityval = 0;
                    double deattl = 0;

                    if (s.amtneededfv != null && s.amtneededfv != "")
                    {
                        damtfv = double.Parse(s.amtneededfv);
                    }
                    if (s.maturityvalue != null && s.maturityvalue != "")
                    {
                        dmaturityval = double.Parse(s.maturityvalue);
                    }
                    if (s.existingassetstotal != null && s.existingassetstotal != "")
                    {
                        deattl = double.Parse(s.existingassetstotal);
                    }

                    if (((dmaturityval + deattl) - damtfv) < 0)
                    {
                        s.total = "-" + s.total;
                    }
                }

                //existingsggrid.DataSource = savingGoal;
                existingsggrid.DataSource = gridgoal;
                existingsggrid.DataBind();

                //refreshSavingGoal();
            }
            else
            {
                lblSavingGoalFailed.Visible = true;
            }
        }
        public int altaGrupo(string Nombre, string Descripcion,bool activo,List<string> usuarios, Dictionary<int,List<int>> ListaIdPantallas_Controles)
        {
            GRuPOs grupo;
            try
            {
                grupo = new GRuPOs();
                grupo.Nombre = Nombre;
                grupo.Descripcion = Descripcion;
                if (activo)
                    grupo.Activo = 1;
                else
                    grupo.Activo = 0;
                UsUarIoSGRuPOs ug;
                EntitySet<UsUarIoSGRuPOs> listaUsuariosGrupos = new EntitySet<UsUarIoSGRuPOs>();
                foreach(string username in usuarios)
                {
                    ug = new UsUarIoSGRuPOs();
                    UsUarIoS user = database.UsUarIoS.Where(u => u.UserName ==username).Single();
                    ug.UsUarIoS = user;
                    ug.GRuPOs = grupo;
                    listaUsuariosGrupos.Add(ug);
                }
                grupo.UsUarIoSGRuPOs = listaUsuariosGrupos;

                database.GRuPOs.InsertOnSubmit(grupo);
                database.SubmitChanges();
                return grupo.IDGrupo;
            }
            catch
            {
                throw;
            }
        }
예제 #45
0
        public myNeed updateMyNeeds(myNeed needs)
        {
            myNeed retrievedNeed = null;

            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing my need
                var queryMyNeeds = from myneed in ct.myNeeds
                                       where myneed.caseId == needs.caseId
                                       select myneed;
                foreach (myNeed myNeeds in queryMyNeeds)
                {
                    retrievedNeed = myNeeds;
                }

                //update my need attributes
                retrievedNeed.lumpSumRequiredForTreatment = needs.lumpSumRequiredForTreatment;
                retrievedNeed.totalRequired = needs.totalRequired;
                retrievedNeed.criticalIllnessInsurance = needs.criticalIllnessInsurance;
                retrievedNeed.existingAssetsMyneeds = needs.existingAssetsMyneeds;
                retrievedNeed.totalShortfallSurplusMyNeeds = needs.totalShortfallSurplusMyNeeds;
                retrievedNeed.lumpSumMyNeeds = needs.lumpSumMyNeeds;
                retrievedNeed.existingSumMyNeeds = needs.existingSumMyNeeds;
                retrievedNeed.shortfallSumMyNeeds = needs.shortfallSumMyNeeds;
                retrievedNeed.monthlyIncomeDisabilityIncome = needs.monthlyIncomeDisabilityIncome;
                retrievedNeed.percentOfIncomeCoverageRequired = needs.percentOfIncomeCoverageRequired;
                retrievedNeed.monthlyCoverageRequired = needs.monthlyCoverageRequired;
                retrievedNeed.disabilityInsuranceMyNeeds = needs.disabilityInsuranceMyNeeds;
                retrievedNeed.existingAssetsMyneedsDisability = needs.existingAssetsMyneedsDisability;
                retrievedNeed.shortfallSurplusMyNeeds = needs.shortfallSurplusMyNeeds;
                retrievedNeed.monthlyAmountMyNeeds = needs.monthlyAmountMyNeeds;
                retrievedNeed.existingMyNeeds = needs.existingMyNeeds;
                retrievedNeed.shortfallMyNeeds = needs.shortfallMyNeeds;
                retrievedNeed.typeOfHospitalCoverage = needs.typeOfHospitalCoverage;
                retrievedNeed.anyExistingPlans = needs.anyExistingPlans;
                retrievedNeed.typeOfRoomCoverage = needs.typeOfRoomCoverage;
                retrievedNeed.coverageOldageYesNo = needs.coverageOldageYesNo;
                retrievedNeed.epOldageYesNo = needs.epOldageYesNo;
                retrievedNeed.coverageIncomeYesNo = needs.coverageIncomeYesNo;
                retrievedNeed.epIncomeYesNo = needs.epIncomeYesNo;
                retrievedNeed.coverageOutpatientYesNo = needs.coverageOutpatientYesNo;
                retrievedNeed.epOutpatientYesNo = needs.epOutpatientYesNo;
                retrievedNeed.coverageDentalYesNo = needs.coverageDentalYesNo;
                retrievedNeed.epDentalYesNo = needs.epDentalYesNo;
                retrievedNeed.coveragePersonalYesNo = needs.coveragePersonalYesNo;
                retrievedNeed.epPersonalYesNo = needs.epPersonalYesNo;
                retrievedNeed.criticalIllnessPrNeeded = needs.criticalIllnessPrNeeded;
                retrievedNeed.disabilityPrNeeded = needs.disabilityPrNeeded;
                retrievedNeed.hospitalmedCoverNeeded = needs.hospitalmedCoverNeeded;
                retrievedNeed.accidentalhealthCoverNeeded = needs.accidentalhealthCoverNeeded;
                retrievedNeed.coverageOutpatientMedExp = needs.coverageOutpatientMedExp;
                retrievedNeed.epOutpatientMedExp = needs.epOutpatientMedExp;
                retrievedNeed.coverageLossOfIncome = needs.coverageLossOfIncome;
                retrievedNeed.epLossOfIncome = needs.epLossOfIncome;
                retrievedNeed.coverageOldageDisabilities = needs.coverageOldageDisabilities;
                retrievedNeed.epOldageDisabilities = needs.epOldageDisabilities;
                retrievedNeed.coverageDentalExp = needs.coverageDentalExp;
                retrievedNeed.epDentalExp = needs.epDentalExp;

                if ((needs.anyExistingPlans == true) || (needs.epOldageYesNo == true) || (needs.epPersonalYesNo == true) || (needs.epOutpatientMedExp == true) || (needs.epLossOfIncome == true) || (needs.epOldageDisabilities == true) || (needs.epDentalExp == true))
                {
                    retrievedNeed.existingPlansDetail = needs.existingPlansDetail;
                }
                else
                    retrievedNeed.existingPlansDetail = "";

               // retrievedNeed.existingPlansDetail = needs.existingPlansDetail;

                retrievedNeed.disabilityProtectionReplacementIncomeRequired = needs.disabilityProtectionReplacementIncomeRequired;
                retrievedNeed.disabilityProtectionReplacementIncomeRequiredPercentage =needs.disabilityProtectionReplacementIncomeRequiredPercentage;
                retrievedNeed.replacementIncomeRequired = needs.replacementIncomeRequired;
                retrievedNeed.yearsOfSupportRequired = needs.yearsOfSupportRequired;
                retrievedNeed.disabilityYearsOfSupport = needs.disabilityYearsOfSupport;
                retrievedNeed.inflatedAdjustedReturns = needs.inflatedAdjustedReturns;
                retrievedNeed.replacementAmountRequired = needs.replacementAmountRequired;
                retrievedNeed.disabilityReplacementAmountRequired = needs.disabilityReplacementAmountRequired;
                retrievedNeed.disabilityInsurance = needs.disabilityInsurance;
                retrievedNeed.inflationAdjustedReturns = needs.inflationAdjustedReturns;

                //delete existing assets for my needs critical illness
                var queryExistingCriticalAssets = from eamyneed in ct.myNeedsCriticalAssets
                                          where eamyneed.myNeedId == retrievedNeed.id
                                          select eamyneed;
                foreach (myNeedsCriticalAsset eamyneeds in queryExistingCriticalAssets)
                {
                    ct.myNeedsCriticalAssets.DeleteOnSubmit(eamyneeds);
                    //ct.SubmitChanges();
                }

                //update existing assets list for my needs critical illness
                if (needs.myNeedsCriticalAssets != null && needs.myNeedsCriticalAssets.Count > 0)
                {
                    EntitySet<myNeedsCriticalAsset> eaMNCriticalList = new EntitySet<myNeedsCriticalAsset>();
                    foreach (myNeedsCriticalAsset mnea in needs.myNeedsCriticalAssets)
                    {
                        eaMNCriticalList.Add(mnea);
                    }
                    retrievedNeed.myNeedsCriticalAssets = eaMNCriticalList;
                }

                //delete existing assets for my needs disability income
                var queryExistingDisablityAssets = from eamyneed in ct.myNeedsDisabilityAssets
                                                  where eamyneed.myNeedId == retrievedNeed.id
                                                  select eamyneed;
                foreach (myNeedsDisabilityAsset eamyneeds in queryExistingDisablityAssets)
                {
                    ct.myNeedsDisabilityAssets.DeleteOnSubmit(eamyneeds);
                    //ct.SubmitChanges();
                }

                //update existing assets list for disability income
                if (needs.myNeedsDisabilityAssets != null && needs.myNeedsDisabilityAssets.Count > 0)
                {
                    EntitySet<myNeedsDisabilityAsset> eaMNDisabilityList = new EntitySet<myNeedsDisabilityAsset>();
                    foreach (myNeedsDisabilityAsset mnea in needs.myNeedsDisabilityAssets)
                    {
                        eaMNDisabilityList.Add(mnea);
                    }
                    retrievedNeed.myNeedsDisabilityAssets = eaMNDisabilityList;
                }

                ct.SubmitChanges();

            }
            catch (Exception ex)
            {
                logException(ex);
                throw ex;
            }

            return retrievedNeed;
        }
예제 #46
0
        protected void submitRetirementGoals(object sender, EventArgs e)
        {
            //File.AppendAllText(@"C:\ZurichLogs\logs.txt", "\n inside submitSavingGoals code behind");

            retirementgoal goalsSelf = new retirementgoal();

            string caseid = "";
            if (ViewState["caseid"] != null)
            {
                caseid = ViewState["caseid"].ToString();
                goalsSelf.caseid = caseid;
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            string caseType = "";
            retirementGoalSelf = retirementGoalsDao.getRetirementGoal(caseid, "self");

            if (retirementGoalSelf != null)
            {
                caseType = "update";
            }
            else
            {
                caseType = "new";
            }

            goalsSelf.retirementGoalNeeded = Convert.ToInt32(retirementGoalNeeded.SelectedValue);

            if (goalsSelf.retirementGoalNeeded == 2)
            {
                goalsSelf.durationretirement = durationOfRetirement.Text;
                goalsSelf.futureincome = futureIncomeNeeded.Text;
                goalsSelf.incomerequired = incomeRequiredUponRetirement.Text;
                goalsSelf.intendedretirementage = intendedRetirementAge.Text;
                goalsSelf.lumpsumrequired = lumpSumRequiredAtRetirement.Text;
                goalsSelf.maturityvalue = maturityValue2.Text;
                goalsSelf.selforspouse = "self";
                goalsSelf.sourcesofincome = sourcesOfIncome.Text;

                if (totalShortfallSurplus2.Text != null && totalShortfallSurplus2.Text != "")
                {
                    double ttl = double.Parse(totalShortfallSurplus2.Text);
                    if (ttl < 0)
                    {
                        totalShortfallSurplus2.Text = Math.Abs(ttl).ToString();
                    }
                }
                goalsSelf.total = totalShortfallSurplus2.Text;

                goalsSelf.totalfirstyrincome = totalFirstYearIncomeNeeded.Text;
                goalsSelf.yrstoretirement = yearsToRetirement.Text;
                goalsSelf.existingassetstotal = existingAssets2.Text;
                goalsSelf.inflationrate = annualInflationRate.Text;
                goalsSelf.inflationreturnrate = inflationAdjustedReturn.Text;
            }
            else if (goalsSelf.retirementGoalNeeded == 1 || goalsSelf.retirementGoalNeeded == 0)
            {
                goalsSelf.durationretirement = "0";
                goalsSelf.futureincome = "0";
                goalsSelf.incomerequired = "0";
                goalsSelf.intendedretirementage = "0";
                goalsSelf.lumpsumrequired = "0";
                goalsSelf.maturityvalue = "0";
                goalsSelf.selforspouse = "self";
                goalsSelf.sourcesofincome = "0";
                goalsSelf.total = "0";
                goalsSelf.totalfirstyrincome = "0";
                goalsSelf.yrstoretirement = "0";
                goalsSelf.existingassetstotal = "0";
                goalsSelf.inflationrate = "0";
                goalsSelf.inflationreturnrate = "0";
            }

            int noofeaself = 0;
            if (goalsSelf.retirementGoalNeeded == 2)
            {
                if (noofmembers.Value != "")
                {
                    noofeaself = Int16.Parse(noofmembers.Value);
                }
            }

            EntitySet<existingassetrg> eargSelfList = new EntitySet<existingassetrg>();
            if (noofeaself > 0)
            {
                for (int i = 1; i <= noofeaself; i++)
                {
                    existingassetrg easg = new existingassetrg();
                    easg.asset = Request.Form["pridesc-" + i];
                    easg.presentvalue = Request.Form["pri_" + i];
                    easg.percentpa = Request.Form["sec_" + i];

                    if ((Request.Form["pridesc-" + i] != null) && (Request.Form["pri_" + i] != null) && (Request.Form["sec_" + i] != null))
                    {
                        eargSelfList.Add(easg);
                    }

                }
                goalsSelf.existingassetrgs = eargSelfList;
            }

            if (caseType == "new")
            {
                goalsSelf = retirementGoalsDao.saveRetirementGoals(goalsSelf);
            }
            else if (caseType == "update")
            {
                goalsSelf = retirementGoalsDao.updateRetirementGoals(goalsSelf);
            }

            string status = activityStatusCheck.getRetirementGoalStatus(goalsSelf);
            activityStatusDao.saveOrUpdateActivityStatus(caseid, actv, status);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseid);

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseid, caseStatus, url, sendPdf);

            markStatusOnTab(caseid);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (goalsSelf != null)
            {
                lblRetirementGoalSuccess.Visible = true;
                populateRetirementGoal(goalsSelf, inflationAdjustedReturnAsmptn, annualInflationReturn, caseid);
            }
            else
            {
                lblRetirementGoalFailed.Visible = true;
            }
        }
예제 #47
0
        static void Main(string[] args)
        {
            if (args.Length < 6) {
                Console.WriteLine("Usage:\tBenchmark.exe <s or p> <key number> <key size> <property number> <entity number> <iteration> <seed>");
                Console.WriteLine("Sample:\tBenchmark.exe s 5 3 10 100000 100 231347");
                return;
            }

            var isParallel = args[0] == "p";
            var keyCount = Int32.Parse(args[1]);
            var keySize = Int32.Parse(args[2]);
            var propertyCount = Int32.Parse(args[3]);
            var entityCount = Int32.Parse(args[4]);
            var iteration = Int32.Parse(args[5]);
            var seed = args.Length < 7 ? DateTime.Now.Millisecond : Int32.Parse(args[6]);

            Console.WriteLine("Parallel: " + isParallel);
            Console.WriteLine("Key number: " + keyCount);
            Console.WriteLine("Key size: " + keySize);
            Console.WriteLine("Property number: " + propertyCount);
            Console.WriteLine("Entity number: " + entityCount);
            Console.WriteLine("Iteration: " + iteration);
            Console.WriteLine("Seed: " + seed);
            Console.WriteLine();

            var random = new Random(seed);

            var metadata = new EntityMetadata(keyCount, propertyCount);
            var config = CreateAggregationConfig(metadata);

            var set = new EntitySet();
            foreach (var keys in InfiniteKeys(keyCount, keySize).Take(entityCount)) {
                set.Add(metadata.CreateEntity(keys));
            }

            Console.Write("Preparing...");

            var watch = new Stopwatch();
            watch.Start();

            var service = isParallel ? (IAggregationService)new ParallelAggregationService() : new SerialAggregationService();
            var root = service.Aggregate(set, config, metadata);
            root.Start();

            Console.WriteLine("Done");

            PrintMessage(iteration, 0);

            for (var i = 0; i < iteration; i++) {
                var num = 0;

                foreach (var entity in set) {
                    foreach (var property in metadata.Properties) {
                        entity.Set(property, (decimal)(random.NextDouble() * 1000000));
                    }

                    if (++num % 1000 == 0) {
                        PrintMessage(iteration, i + num * 1.0 / entityCount);
                    }
                }

                PrintMessage(iteration, i + 1);
            }

            Console.WriteLine();
            Console.WriteLine("Waiting for completion.");

            while (root.Running) {
                Thread.Sleep(100);
            }

            Console.WriteLine("Time: " + watch.Elapsed);

            var postfix = DateTime.Now.ToString("yyyyMMdd-HHmmss");
            Dump(set, metadata, "Source-" + postfix + ".csv");
            Dump(root.Result, metadata, config, "Result-" + postfix + ".csv");
        }
예제 #48
0
        protected void saveAssetLiabilitiesDetails(object sender, EventArgs e)
        {
            string caseId = "";
            if (ViewState["caseId"] != null)
            {
                caseId = ViewState["caseId"].ToString();
            }

            if (Session["fnacaseid"] != null)
            {
                caseId = Session["fnacaseid"].ToString();
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            AssetAndLiabilityDAO assetAndLiabilityDAO = new AssetAndLiabilityDAO();
            assetAndLiability assetAndLiability = assetAndLiabilityDAO.getAssetLiabilityForCase(caseId);

            string status = "new";

            if (assetAndLiability != null)
            {
                copyAssetBaseClass(assetAndLiability);
                status = "update";
            }
            else
            {
                assetAndLiability = new assetAndLiability();
                copyAssetBaseClass(assetAndLiability);
            }

            int noofmemberOfInvestedAssets = 0;
            int noOfLiabilitiesNumber = 0;
            int noPersonalUsedAssetsNumber = 0;

            if (otherInvestedAssetsNumber.Value != "")
            {
                noofmemberOfInvestedAssets = Int16.Parse(otherInvestedAssetsNumber.Value) + 1;
            }

            if (otherPersonalUsedAssetsNumber.Value != "")
            {
                noPersonalUsedAssetsNumber = Int16.Parse(otherPersonalUsedAssetsNumber.Value) + 1;
            }

            if (otherLiabilitiesNumber.Value != "")
            {
                noOfLiabilitiesNumber = Int16.Parse(otherLiabilitiesNumber.Value) + 1;
            }

            EntitySet<personalUseAssetsOther> personalUseAssets = new EntitySet<personalUseAssetsOther>();
            EntitySet<liabilityOther> liabilityOthers = new EntitySet<liabilityOther>();
            EntitySet<investedAssetOther> investedAssetOther = new EntitySet<investedAssetOther>();

            if (noofmemberOfInvestedAssets > 0)
            {
                for (int i = 0; i < noofmemberOfInvestedAssets; i++)
                {

                    if (Request.Form["priothers-" + i] != null)
                    {
                        investedAssetOther asset = new investedAssetOther();
                        asset.cash = Request.Form["priotherscash-" + i];
                        asset.cpf = Request.Form["priotherscpf-" + i];
                        asset.date = DateTime.Today;
                        asset.assetDesc = Request.Form["priothers-" + i];
                        investedAssetOther.Add(asset);
                    }
                }
            }
            assetAndLiability.investedAssetOthers = investedAssetOther;
            if (noPersonalUsedAssetsNumber > 0)
            {
                for (int i = 0; i < noPersonalUsedAssetsNumber; i++)
                {

                    if (Request.Form["priotherspu-" + i] != null)
                    {
                        personalUseAssetsOther asset = new personalUseAssetsOther();
                        asset.cash = Request.Form["priotherspucash-" + i];
                        asset.cpf = Request.Form["priotherspucpf-" + i];
                        asset.date = DateTime.Today;
                        asset.assetDesc = Request.Form["priotherspu-" + i];
                        personalUseAssets.Add(asset);

                    }
                }
            }
            assetAndLiability.personalUseAssetsOthers = personalUseAssets;
            if (noOfLiabilitiesNumber > 0)
            {
                for (int i = 0; i < noOfLiabilitiesNumber; i++)
                {

                    if (Request.Form["priotherslb-" + i] != null)
                    {
                        liabilityOther liability = new liabilityOther();
                        liability.liabilityDesc = Request.Form["priotherslb-" + i];
                        liability.cash = Request.Form["priotherslbamount-" + i];
                        liability.date = DateTime.Today;
                        liabilityOthers.Add(liability);

                    }
                }
            }

            assetAndLiability.liabilityOthers = liabilityOthers;
            AssetAndLiabilityDAO dao = new AssetAndLiabilityDAO();
            if (status.Equals("new"))
            {
                assetAndLiability.caseId = caseId;
                dao.insertNewAssetLiabilityDetails(assetAndLiability);
            }
            else
                dao.updateAssetLiabilityDetails(assetAndLiability);

            this.assetList.DataSource = investedAssetOther;
            this.assetList.DataBind();
            this.liabilitiesOtherRepeater.DataSource = liabilityOthers;
            this.liabilitiesOtherRepeater.DataBind();
            this.otherPersonalAssetsRepeater.DataSource = personalUseAssets;
            this.otherPersonalAssetsRepeater.DataBind();

            string sts = activityStatusCheck.getAssetLiabilityStatus(assetAndLiability);
            activityStatusDao.saveOrUpdateActivityStatus(caseId, actv, sts);

            markStatusOnTab(caseId);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseId);

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseId, caseStatus, url, sendPdf);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (liabilityOthers.Count > 0)
                this.otherInvestedAssetsNumber.Value = (liabilityOthers.Count - 1) + "";
            if (personalUseAssets.Count > 0)
                this.otherPersonalUsedAssetsNumber.Value = (personalUseAssets.Count - 1) + "";
            if (investedAssetOther.Count > 0)
                this.otherInvestedAssetsNumber.Value = (investedAssetOther.Count - 1) + "";
            activityId.Value = caseId;

            lblPdSummarySaveSuccess.Visible = true;

            List<string> errors = printErrorMessages(assetAndLiability);
            this.ErrorRepeater.DataSource = errors;
            this.ErrorRepeater.DataBind();
        }
예제 #49
0
        public educationgoal updateEducationGoals(educationgoal goals, int egid)
        {
            educationgoal retrievedGoal = null;

            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing education goal
                var queryEducationGoals = from sg in ct.educationgoals
                                       where sg.caseid == goals.caseid && sg.id == egid
                                       select sg;
                foreach (educationgoal sgoals in queryEducationGoals)
                {
                    retrievedGoal = sgoals;
                }

                //update education goal attributes
                retrievedGoal.agefundsneeded = goals.agefundsneeded;
                retrievedGoal.currentage = goals.currentage;
                retrievedGoal.maturityvalue = goals.maturityvalue;
                retrievedGoal.nameofchild = goals.nameofchild;
                retrievedGoal.noofyrstosave = goals.noofyrstosave;
                retrievedGoal.total = goals.total;
                retrievedGoal.existingassetstotal = goals.existingassetstotal;
                retrievedGoal.futurecost = goals.futurecost;
                retrievedGoal.presentcost = goals.presentcost;
                retrievedGoal.inflationrate = goals.inflationrate;
                retrievedGoal.educationGoalNeeded = goals.educationGoalNeeded;

                retrievedGoal.countryofstudyid = goals.countryofstudyid;

                //delete existing assets for the education goal
                var queryExistingAssets = from easg in ct.existingassetegs
                                          where easg.educationgoalsid == retrievedGoal.id
                                          select easg;
                foreach (existingasseteg easgoals in queryExistingAssets)
                {
                    ct.existingassetegs.DeleteOnSubmit(easgoals);
                    //ct.SubmitChanges();
                }

                //update existing assets list for the education goal
                if (goals.existingassetegs != null && goals.existingassetegs.Count > 0)
                {
                    EntitySet<existingasseteg> easgList = new EntitySet<existingasseteg>();
                    foreach (existingasseteg sgea in goals.existingassetegs)
                    {
                        easgList.Add(sgea);
                    }
                    retrievedGoal.existingassetegs = easgList;
                }

                if (retrievedGoal.educationGoalNeeded == 1 || retrievedGoal.educationGoalNeeded == 0)
                {
                    var eduGoalRecords = from edug in ct.educationgoals
                                         where edug.caseid == goals.caseid
                                         select edug;
                    int[] arrRecordIds = null;

                    if (eduGoalRecords != null)
                    {
                        int size = eduGoalRecords.ToArray().Length;
                        arrRecordIds = new int[size];
                    }
                    int index = 0;
                    foreach (educationgoal egl in eduGoalRecords)
                    {
                        arrRecordIds[index] = egl.id;
                        index++;
                    }

                    var todelExistingAssets = from easg in ct.existingassetegs
                                              where arrRecordIds.Contains(easg.educationgoalsid)
                                              select easg;
                    foreach (existingasseteg easgoals in todelExistingAssets)
                    {
                        ct.existingassetegs.DeleteOnSubmit(easgoals);
                    }

                    var toDelEducationGoals = from sg in ct.educationgoals
                                              where sg.caseid == goals.caseid && sg.id != egid
                                              select sg;
                    foreach (educationgoal s in toDelEducationGoals)
                    {
                        ct.educationgoals.DeleteOnSubmit(s);
                    }
                }

                ct.SubmitChanges();

            }
            catch (Exception e)
            {
                string str = e.Message;
            }

            return retrievedGoal;
        }
예제 #50
0
        protected EntitySet LoadSql(string query, string[] attributes, Hashtable columnAliasMapping, bool referenceloading)
        {
            EntitySet es = new EntitySet();
            Hashtable entities = new Hashtable();

            IDbCommand cmd = _Driver.CreateCommand(query, _Connection, _Transaction);

            if (TraceSqlSwitch.Enabled)
            {
                TraceHelpler.Trace(cmd, _Dialect);
            }

            using (IDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    // the real type of the entity must be returned as the first column
                    string type = reader[SqlMapperTransformer.TYPE_ALIAS].ToString();

                    EntityMapping em = _Mapping.Entities[type];

                    // Creates the id using all the primary key columns
                    string id;
                    int idPosition = 1;
                    if (referenceloading)
                    {
                        idPosition++;
                        while (idPosition < reader.FieldCount && !reader.GetName(idPosition).ToLower().StartsWith(EntityMapping.PREFIX_ID.ToLower()))
                            idPosition++;
                        if (idPosition == reader.FieldCount)
                            idPosition = 2;
                        id = reader[idPosition].ToString().Trim();
                    }
                    else
                        id = reader[1].ToString().Trim();
                    for (int i = 1; i < em.Ids.Count; i++)
                    {
                        //if (em.Ids[i].Generator.Name == GeneratorMapping.GeneratorType.business)
                        //    id += SqlMapperProvider.IDSEP + reader[em.Attributes.FindByField(em.Ids[i].Field).Name].ToString().Trim();
                        //else
                        id += SqlMapperProvider.IDSEP + reader[i + idPosition].ToString().Trim();
                    }

                    Entity e = entities[String.Concat(type, ":", id)] as Entity;

                    if (e == null)
                    {
                        e = new Entity(type);
                        e.Id = id;
                        e.State = State.UpToDate;
                        es.Add(e);
                        entities.Add(String.Concat(type, ":", id), e);
                    }

                    ImportAttributes(reader, attributes, _Mapping.Entities[e.Type], e, columnAliasMapping);
                }
            }

            return es;
        }
예제 #51
0
        private bool saveFamilyNeeds()
        {
            familyNeed familyNeeds = new familyNeed();

            familyNeeds.familyIncPrNeeded = Convert.ToInt32(familyIncPrNeeded.SelectedValue);
            familyNeeds.mortgageNeeded = Convert.ToInt32(mortgagePrNeeded.SelectedValue);

            if (familyNeeds.familyIncPrNeeded == 2)
            {
                familyNeeds.replacementIncomeRequired = txtReplacementIncome.Text;
                familyNeeds.yearsOfSupportRequired = txtYrsOfSupport.Text;
                familyNeeds.inflationAdjustedReturns = txtInflationAdjustedReturns.Text;
                familyNeeds.lumpSumRequired = txtLumpSumRequired.Text;
                familyNeeds.otherLiabilities = txtOtherLiabilities.Text;
                familyNeeds.emergencyFundsNeeded = txtEmergencyFundsNeeded.Text;
                familyNeeds.finalExpenses = txtFinalExpenses.Text;
                familyNeeds.otherFundingNeeds = txtOtherFundingNeeds.Text;
                //familyNeeds.otherComments = txtotherComments.Text;
                familyNeeds.totalRequired = txtTotalRequired.Text;
                familyNeeds.existingLifeInsurance = txtExistingLifeInsurance.Text;
                familyNeeds.existingAssetsFamilyneeds = txtExistingAssetsFamilyneeds.Text;
                //familyNeeds.totalShortfallSurplus = txtTotalShortfallSurplus.Text;
                familyNeeds.totalShortfallSurplus = hiddenTotalShortfallSurplus.Value;
            }
            else if (familyNeeds.familyIncPrNeeded == 1 || familyNeeds.familyIncPrNeeded == 0)
            {
                familyNeeds.replacementIncomeRequired = "0";
                familyNeeds.yearsOfSupportRequired = "0";
                familyNeeds.inflationAdjustedReturns = "0";
                familyNeeds.lumpSumRequired = "0";
                familyNeeds.otherLiabilities = "0";
                familyNeeds.emergencyFundsNeeded = "0";
                familyNeeds.finalExpenses = "0";
                familyNeeds.otherFundingNeeds = "0";
                //familyNeeds.otherComments = txtotherComments.Text;
                familyNeeds.totalRequired = "0";
                familyNeeds.existingLifeInsurance = "0";
                familyNeeds.existingAssetsFamilyneeds = "0";
                //familyNeeds.totalShortfallSurplus = txtTotalShortfallSurplus.Text;
                familyNeeds.totalShortfallSurplus = "0";
            }

            if (familyNeeds.mortgageNeeded == 2)
            {
                familyNeeds.mortgageProtectionOutstanding = txtMortgageProtectionOutstanding.Text;
                familyNeeds.mortgageProtectionInsurances = txtMortgageProtectionInsurances.Text;
                familyNeeds.mortgageProtectionTotal = hiddentxtMortgageProtectionTotal.Value;
            }
            else if (familyNeeds.mortgageNeeded == 1 || familyNeeds.mortgageNeeded == 0)
            {
                familyNeeds.mortgageProtectionOutstanding = "0";
                familyNeeds.mortgageProtectionInsurances = "0";
                familyNeeds.mortgageProtectionTotal = "0";
            }

            familyNeeds.caseId = ViewState["caseId"].ToString();

            int noofea = 0;
            if (familyNeeds.familyIncPrNeeded == 2)
            {
                if (noofmembers.Value != "")
                {
                    noofea = Int16.Parse(noofmembers.Value);
                }
            }

            EntitySet<familyNeedsAsset> eaFNeedsList = new EntitySet<familyNeedsAsset>();
            if (noofea > 0)
            {
                for (int i = 1; i <= noofea; i++)
                {
                    familyNeedsAsset eafn = new familyNeedsAsset();
                    eafn.asset = Request.Form["prifamily-" + i];
                    eafn.presentValue = Request.Form["prifamilyneeds_" + i];

                    if ((Request.Form["prifamily-" + i] != null) && (Request.Form["prifamilyneeds_" + i] != null))
                    {
                        eaFNeedsList.Add(eafn);
                    }

                }
                familyNeeds.familyNeedsAssets = eaFNeedsList;
            }

            if (ViewState["casetypefamily"] != null && ViewState["casetypefamily"].ToString() == "new")
            {
                familyNeeds = familyNeedsDAO.saveFamilyNeeds(familyNeeds);
            }
            else if (ViewState["casetypefamily"] != null && ViewState["casetypefamily"].ToString() == "update")
            {
                familyNeeds = familyNeedsDAO.updateFamilyNeeds(familyNeeds);
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            string status = activityStatusCheck.getProtectionGoalFamilyStatus(familyNeeds);
            activityStatusDao.saveOrUpdateActivityStatus(ViewState["caseId"].ToString(), actv, status);

            markStatusOnTab(ViewState["caseId"].ToString());

            string caseStatus = activityStatusCheck.getZPlanStatus(ViewState["caseId"].ToString());

            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");

            pdfData = activityStatusCheck.sendDataToSalesPortal(ViewState["caseId"].ToString(), caseStatus, url, sendPdf);

            if (familyNeeds != null)
            {
                populateFamilyNeed(familyNeeds);
            }
            else
            {
                return false;
            }

            return true;
        }
예제 #52
0
        public void Extract()
        {
            RestClient cli = new RestClient("http://192.168.217.128:81/");

            RestRequest request = new RestRequest("/profile/_temp_view", Method.POST);
            request.RequestFormat = DataFormat.Json;
            CouchJson json = new CouchJson();
            json.map = @"function(doc) {
                                        if(doc.bat['ODIs'] || doc.bowl['ODIs']) emit(doc,null);
                                    }";
            request.AddBody(json);
            cli.ExecuteAsync(request, delegate(RestResponse re)
            {
                CouchResponse docs = JsonConvert.DeserializeObject<CouchResponse>(re.Content);

                foreach (CouchData data in docs.rows)
                {
                    Document doc = data.key;
                    EntitySet<Team> teams = new EntitySet<Team>();
                    foreach (string team in doc.profile.Teams)
                    {
                        teams.Add(new Team { Name = team });
                    }

                    EntitySet<Debut> debuts = new EntitySet<Debut>();
                    if (!doc.debut.odi.Equals("-")) debuts.Add(new Debut { MatchType = 0, Match = doc.debut.odi });
                    if (!doc.debut.test.Equals("-")) debuts.Add(new Debut { MatchType = 1, Match = doc.debut.test });
                    if (!doc.debut.firstClass.Equals("-")) debuts.Add(new Debut { MatchType = 2, Match = doc.debut.firstClass });
                    if (!doc.debut.t20i.Equals("-")) debuts.Add(new Debut { MatchType = 3, Match = doc.debut.t20i });
                    if (!doc.debut.twenty20.Equals("-")) debuts.Add(new Debut { MatchType = 4, Match = doc.debut.twenty20 });

                    EntitySet<BattingStat> battingStats = new EntitySet<BattingStat>();
                    if (!doc.bat.odi.matches.Equals("-"))
                        battingStats.Add(new BattingStat
                        {
                            MatchType = 0,
                            Runs = doc.bat.odi.runs,
                            Fours = doc.bat.odi.fours,
                            Sixes = doc.bat.odi.sixes,
                            Fifties = doc.bat.odi.fifties,
                            Hundreds = doc.bat.odi.hundreds,
                            Innings = doc.bat.odi.innings,
                            HighScore = doc.bat.odi.highScore,
                            Average = doc.bat.odi.average,
                            Catches = doc.bat.odi.catches,
                            Matches = doc.bat.odi.matches,
                            StrikeRate = doc.bat.odi.strikeRate,
                            Stumpings = doc.bat.odi.stumpings
                        });
                    if (!doc.bat.test.matches.Equals("-"))
                        battingStats.Add(new BattingStat
                        {
                            MatchType = 1,
                            Runs = doc.bat.test.runs,
                            Fours = doc.bat.test.fours,
                            Sixes = doc.bat.test.sixes,
                            Fifties = doc.bat.test.fifties,
                            Hundreds = doc.bat.test.hundreds,
                            Innings = doc.bat.test.innings,
                            HighScore = doc.bat.test.highScore,
                            Average = doc.bat.test.average,
                            Catches = doc.bat.test.catches,
                            Matches = doc.bat.test.matches,
                            StrikeRate = doc.bat.test.strikeRate,
                            Stumpings = doc.bat.test.stumpings
                        });
                    if (!doc.bat.firstClass.matches.Equals("-"))
                        battingStats.Add(new BattingStat
                        {
                            MatchType = 2,
                            Runs = doc.bat.firstClass.runs,
                            Fours = doc.bat.firstClass.fours,
                            Sixes = doc.bat.firstClass.sixes,
                            Fifties = doc.bat.firstClass.fifties,
                            Hundreds = doc.bat.firstClass.hundreds,
                            Innings = doc.bat.firstClass.innings,
                            HighScore = doc.bat.firstClass.highScore,
                            Average = doc.bat.firstClass.average,
                            Catches = doc.bat.firstClass.catches,
                            Matches = doc.bat.firstClass.matches,
                            StrikeRate = doc.bat.firstClass.strikeRate,
                            Stumpings = doc.bat.firstClass.stumpings
                        });
                    if (!doc.bat.twenty20.matches.Equals("-"))
                        battingStats.Add(new BattingStat
                        {
                            MatchType = 4,
                            Runs = doc.bat.twenty20.runs,
                            Fours = doc.bat.twenty20.fours,
                            Sixes = doc.bat.twenty20.sixes,
                            Fifties = doc.bat.twenty20.fifties,
                            Hundreds = doc.bat.twenty20.hundreds,
                            Innings = doc.bat.twenty20.innings,
                            HighScore = doc.bat.twenty20.highScore,
                            Average = doc.bat.twenty20.average,
                            Catches = doc.bat.twenty20.catches,
                            Matches = doc.bat.twenty20.matches,
                            StrikeRate = doc.bat.twenty20.strikeRate,
                            Stumpings = doc.bat.twenty20.stumpings
                        });
                    if (!doc.bat.t20i.matches.Equals("-"))
                        battingStats.Add(new BattingStat
                        {
                            MatchType = 3,
                            Runs = doc.bat.t20i.runs,
                            Fours = doc.bat.t20i.fours,
                            Sixes = doc.bat.t20i.sixes,
                            Fifties = doc.bat.t20i.fifties,
                            Hundreds = doc.bat.t20i.hundreds,
                            Innings = doc.bat.t20i.innings,
                            HighScore = doc.bat.t20i.highScore,
                            Average = doc.bat.t20i.average,
                            Catches = doc.bat.t20i.catches,
                            Matches = doc.bat.t20i.matches,
                            StrikeRate = doc.bat.t20i.strikeRate,
                            Stumpings = doc.bat.t20i.stumpings
                        });

                    EntitySet<BowlingStat> bowlingStats = new EntitySet<BowlingStat>();
                    if (!doc.bowl.odi.matches.Equals("-"))
                        bowlingStats.Add(new BowlingStat
                        {
                            MatchType = 0,
                            Matches = doc.bowl.odi.matches,
                            Average = doc.bowl.odi.average,
                            Balls = doc.bowl.odi.balls,
                            Wickets = doc.bowl.odi.wickets,
                            EconomyRate = doc.bowl.odi.economy,
                            StrikeRate = doc.bowl.odi.strikeRate,
                            InningsBest = doc.bowl.odi.inningsBest,
                            MatchBest = doc.bowl.odi.matchBest,
                            Innings = doc.bowl.odi.innings,
                            Fives = doc.bowl.odi.fives,
                            Fours = doc.bowl.odi.fours,
                            Tens = doc.bowl.odi.tens
                        });
                    if (!doc.bowl.test.matches.Equals("-"))
                        bowlingStats.Add(new BowlingStat
                        {
                            MatchType = 1,
                            Matches = doc.bowl.test.matches,
                            Average = doc.bowl.test.average,
                            Balls = doc.bowl.test.balls,
                            Wickets = doc.bowl.test.wickets,
                            EconomyRate = doc.bowl.test.economy,
                            StrikeRate = doc.bowl.test.strikeRate,
                            InningsBest = doc.bowl.test.inningsBest,
                            MatchBest = doc.bowl.test.matchBest,
                            Innings = doc.bowl.test.innings,
                            Fives = doc.bowl.test.fives,
                            Fours = doc.bowl.test.fours,
                            Tens = doc.bowl.test.tens
                        });
                    if (!doc.bowl.firstClass.matches.Equals("-"))
                        bowlingStats.Add(new BowlingStat
                        {
                            MatchType = 2,
                            Matches = doc.bowl.firstClass.matches,
                            Average = doc.bowl.firstClass.average,
                            Balls = doc.bowl.firstClass.balls,
                            Wickets = doc.bowl.firstClass.wickets,
                            EconomyRate = doc.bowl.firstClass.economy,
                            StrikeRate = doc.bowl.firstClass.strikeRate,
                            InningsBest = doc.bowl.firstClass.inningsBest,
                            MatchBest = doc.bowl.firstClass.matchBest,
                            Innings = doc.bowl.firstClass.innings,
                            Fives = doc.bowl.firstClass.fives,
                            Fours = doc.bowl.firstClass.fours,
                            Tens = doc.bowl.firstClass.tens
                        });
                    if (!doc.bowl.t20i.matches.Equals("-"))
                        bowlingStats.Add(new BowlingStat
                        {
                            MatchType = 3,
                            Matches = doc.bowl.t20i.matches,
                            Average = doc.bowl.t20i.average,
                            Balls = doc.bowl.t20i.balls,
                            Wickets = doc.bowl.t20i.wickets,
                            EconomyRate = doc.bowl.t20i.economy,
                            StrikeRate = doc.bowl.t20i.strikeRate,
                            InningsBest = doc.bowl.t20i.inningsBest,
                            MatchBest = doc.bowl.t20i.matchBest,
                            Innings = doc.bowl.t20i.innings,
                            Fives = doc.bowl.t20i.fives,
                            Fours = doc.bowl.t20i.fours,
                            Tens = doc.bowl.t20i.tens
                        });
                    if (!doc.bowl.twenty20.matches.Equals("-"))
                        bowlingStats.Add(new BowlingStat
                        {
                            MatchType = 4,
                            Matches = doc.bowl.twenty20.matches,
                            Average = doc.bowl.twenty20.average,
                            Balls = doc.bowl.twenty20.balls,
                            Wickets = doc.bowl.twenty20.wickets,
                            EconomyRate = doc.bowl.twenty20.economy,
                            StrikeRate = doc.bowl.twenty20.strikeRate,
                            InningsBest = doc.bowl.twenty20.inningsBest,
                            MatchBest = doc.bowl.twenty20.matchBest,
                            Innings = doc.bowl.twenty20.innings,
                            Fives = doc.bowl.twenty20.fives,
                            Fours = doc.bowl.twenty20.fours,
                            Tens = doc.bowl.twenty20.tens
                        });

                    Profile p = new Profile
                    {
                        Country = doc.country,
                        Born = doc.profile.Born,
                        BattingStyle = doc.profile.battingStyle,
                        BowlingStyle = doc.profile.bowlingStyle,
                        FieldingPosition = doc.profile.fieldingPosition,
                        Name = doc.profile.Name,
                        Teams = teams,
                        Debuts = debuts,
                        BattingStats = battingStats,
                        BowlingStats = bowlingStats
                    };

                    App.DB.Profiles.InsertOnSubmit(p);
                }
                App.DB.SubmitChanges();
            });
        }
        // 2010-05-12 - JG: Esta es la primer version de los extrasliquidacion, cuando se usaba una sola tabla.
        //public int agregarExtraLiquidacionEmpleado(int idEmpleado, DateTime fecha, string descripcion, bool signoPositivo, float valor, int cantidadCuotas)
        //{
        //    ExtrasLiquidAcIonEmPleadO exliq;
        //    Table<ExtrasLiquidAcIonEmPleadO> tabla;
        //    try
        //    {
        //        tabla = database.GetTable<ExtrasLiquidAcIonEmPleadO>();

        //        int cuotaActual = 1;
        //        int idExtraARetornar = -1;
        //        DateTime mesCorrespondiente = fecha;

        //        uint proximoIdExtraEmpleado;
              
        //        List<uint> ListExtras = (from reg in tabla
        //                   where reg.IDEmpleado == idEmpleado
        //                   select reg.IDExtrasLiquidacionEmpleado).ToList<uint>();

        //        uint extras=0;
        //        if (ListExtras.Count > 0)
        //            extras = ListExtras.Max();
        //        proximoIdExtraEmpleado = (uint)extras + 1;
                
        //        // Se crea un registro nuevo por cada cuota, aumentando la cuota y el mes
        //        while (cuotaActual <= cantidadCuotas)
        //        {
        //            exliq = new ExtrasLiquidAcIonEmPleadO();

        //            exliq.IDEmpleado = (uint) idEmpleado;
        //            exliq.IDExtrasLiquidacionEmpleado = proximoIdExtraEmpleado;
        //            exliq.Fecha = mesCorrespondiente;
        //            //if (signoPositivo)
        //            //    exliq.Signo = 1;
        //            //else
        //            //    exliq.Signo = -1;
        //            exliq.Valor = valor/cantidadCuotas;
        //            //exliq.CantidadCuotas = (sbyte)cantidadCuotas;
        //            exliq.Descripcion = descripcion;
        //            //exliq.CuotaActual = (sbyte) cuotaActual;
                
        //            tabla.InsertOnSubmit(exliq);
                    
        //            if (cuotaActual == 1)  // Si es la primer cuota, todo el idextra nuevo para retornarlo
        //                idExtraARetornar = (int) exliq.IDExtrasLiquidacionEmpleado;
        //            cuotaActual++; // Aumento en uno la cuota actual
        //            mesCorrespondiente = mesCorrespondiente.AddMonths(1); // Aumento en 1 el mes correspondiente de la cuota.
        //        }

        //        database.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
        //        if (idExtraARetornar != -1)
        //        {
                   
        //            return idExtraARetornar;
                    
        //        }
        //        else
        //            throw new Exception("Error al crear los Extras para el empleado.");


        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        public int agregarExtraLiquidacionEmpleado(int idEmpleado, DateTime fecha, string descripcion, bool signoPositivo, float valor, int cantidadCuotas, string userName, int idTipoExtraLiquidacion, TimeSpan cantHs_LlevaHs, decimal porcentaje)
        {
            Table<ExtrasLiquidAcIon> tablaExtrasLiquidacion =  null;
            Table<CuOtAsExtrasLiquidAcIon> tablaCuotas;
            int idExtraARetornar = -1;
            CuOtAsExtrasLiquidAcIon cuota;
            ExtrasLiquidAcIon el = null;
            int estado = 0;
            try
            {
                int idUsuario = (from user in database.UsUarIoS
                                 where user.UserName == userName
                                 select user.IDUsuario).Single();

                tablaExtrasLiquidacion = database.GetTable<ExtrasLiquidAcIon>();
                tablaCuotas = database.GetTable<CuOtAsExtrasLiquidAcIon>();
                DateTime mesCorrespondiente = fecha;

                el = new ExtrasLiquidAcIon();
                el.IDEmpleado = (uint) idEmpleado;
                el.Descripcion = descripcion;
                el.Signo = (signoPositivo ? (sbyte)1 : (sbyte)0);
                el.CuotaActual = 1;
                el.CantidadCuotas = (byte)cantidadCuotas;
                el.IDUsuario = idUsuario;
                el.IDTipoExtraLiquidacion = (byte)idTipoExtraLiquidacion;
                el.CantHsTipoExtraLlevaHsEnSegs = (int)cantHs_LlevaHs.TotalSeconds;
                el.Porcentaje = porcentaje;

                tablaExtrasLiquidacion.InsertOnSubmit(el);
                 
                database.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);

                idExtraARetornar = (int)el.IDExtraLiquidacion;
                if (idExtraARetornar == -1)
                {
                    throw new Exception("Error al crear los Extras para el empleado.");
                }

                // Primer estado, al confirmar el insert del extra
                estado = 1;
                
                EntitySet<CuOtAsExtrasLiquidAcIon> set = new EntitySet<CuOtAsExtrasLiquidAcIon>();
                int numCuota = 1;
                while (numCuota <= cantidadCuotas)
                {
                    cuota = new CuOtAsExtrasLiquidAcIon();
                    cuota.Fecha = mesCorrespondiente;
                    cuota.Liquidado = 0;
                    cuota.NumeroCuota = (sbyte) numCuota;
                    numCuota++;
                    cuota.ValorCuota = valor / cantidadCuotas;
                    cuota.IDExtraLiquidacion = el.IDExtraLiquidacion;
                    cuota.ExtrasLiquidAcIon = el;
                  
                    set.Add(cuota);
                    mesCorrespondiente = mesCorrespondiente.AddMonths(1);
                }

                el.CuOtAsExtrasLiquidAcIon = set;
                
                database.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
                

                return idExtraARetornar;

            }
            catch (Exception ex)
            {
                if (estado == 1)
                {
                    tablaExtrasLiquidacion.DeleteOnSubmit(el);
                    database.SubmitChanges();

                }
                WriteErrorLog(ex);
                throw new Exception("Error al ingresar los extras. " + ex.Message); 
            }
            
        }
예제 #54
0
        public void SetSource_ThenAddIsFine()
        {
            var people = new EntitySet<Person>();

            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            
            people.SetSource(new[]{
                new Person { FirstName = "1", LastName = "2" }
            });
            Assert.IsTrue(people.IsDeferred);
            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            people.Add(new Person { FirstName = "A", LastName = "B" });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.IsTrue(people.IsDeferred);
            Assert.AreEqual(2, people.Count);
        }
예제 #55
0
        public incomeExpense updateIncomeExpenseDetails(incomeExpense incomeExpenseDetail)
        {
            incomeExpense incomeExpense = null;
            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing saving goal
                var queryIncomeExpenseDetails = from al in ct.incomeExpenses
                                                  where al.caseId == incomeExpenseDetail.caseId
                                                  select al;
                foreach (incomeExpense incomeExpenseDetails in queryIncomeExpenseDetails)
                {
                    incomeExpense = incomeExpenseDetails;
                }

                incomeExpense.emergencyFundsNeeded = incomeExpenseDetail.emergencyFundsNeeded;
                incomeExpense.shortTermGoals = incomeExpenseDetail.shortTermGoals;
                incomeExpense.extraDetails = incomeExpenseDetail.extraDetails;
                incomeExpense.netMonthlyIncomeAfterCpf = incomeExpenseDetail.netMonthlyIncomeAfterCpf;
                incomeExpense.netMonthlyExpenses = incomeExpenseDetail.netMonthlyExpenses;
                incomeExpense.monthlySavings = incomeExpenseDetail.monthlySavings;
                incomeExpense.lifeInsuranceSA = incomeExpenseDetail.lifeInsuranceSA;
                incomeExpense.lifeInsuranceMV = incomeExpenseDetail.lifeInsuranceMV;
                incomeExpense.expiry1 = incomeExpenseDetail.expiry1;
                incomeExpense.lifeInsurancePremium = incomeExpenseDetail.lifeInsurancePremium;
                incomeExpense.lifeInsuranceRemarks = incomeExpenseDetail.lifeInsuranceRemarks;
                incomeExpense.tpdcSA = incomeExpenseDetail.tpdcSA;
                incomeExpense.tpdcMV = incomeExpenseDetail.tpdcMV;
                incomeExpense.expiry2 = incomeExpenseDetail.expiry2;
                incomeExpense.tpdcPremium = incomeExpenseDetail.tpdcPremium;
                incomeExpense.tpdcRemarks = incomeExpenseDetail.tpdcRemarks;
                incomeExpense.criticalIllnessSA = incomeExpenseDetail.criticalIllnessSA;
                incomeExpense.criticalIllnessMV = incomeExpenseDetail.criticalIllnessMV;
                incomeExpense.expiry3 = incomeExpenseDetail.expiry3;
                incomeExpense.criticalIllnessPremium = incomeExpenseDetail.criticalIllnessPremium;
                incomeExpense.criticalIllnessRemarks = incomeExpenseDetail.criticalIllnessRemarks;
                incomeExpense.disabilityIncomeSA = incomeExpenseDetail.disabilityIncomeSA;
                incomeExpense.disabilityIncomeMV = incomeExpenseDetail.disabilityIncomeMV;
                incomeExpense.expiry4 = incomeExpenseDetail.expiry4;
                incomeExpense.disabilityIncomePremium = incomeExpenseDetail.disabilityIncomePremium;
                incomeExpense.disabilityIncomeRemarks = incomeExpenseDetail.disabilityIncomeRemarks;
                incomeExpense.mortgageSA = incomeExpenseDetail.mortgageSA;
                incomeExpense.mortgageMV = incomeExpenseDetail.mortgageMV;
                incomeExpense.expiry5 = incomeExpenseDetail.expiry5;
                incomeExpense.mortgagePremium = incomeExpenseDetail.mortgagePremium;
                incomeExpense.mortgageRemarks = incomeExpenseDetail.mortgageRemarks;
                incomeExpense.others1A = incomeExpenseDetail.others1A;
                incomeExpense.others1V = incomeExpenseDetail.others1V;
                incomeExpense.expiry6 = incomeExpenseDetail.expiry6;
                incomeExpense.others1Premium = incomeExpenseDetail.others1Premium;
                incomeExpense.others1Remarks = incomeExpenseDetail.others1Remarks;

                incomeExpense.DeathTermInsurancePremium = incomeExpenseDetail.DeathTermInsurancePremium;
                incomeExpense.DeathTermInsuranceSA = incomeExpenseDetail.DeathTermInsuranceSA;
                incomeExpense.DeathTermInsuranceTerm = incomeExpenseDetail.DeathTermInsuranceTerm;
                incomeExpense.DeathWholeLifeInsurancePremium = incomeExpenseDetail.DeathWholeLifeInsurancePremium;
                incomeExpense.DeathWholeLifeInsuranceSA = incomeExpenseDetail.DeathWholeLifeInsuranceSA;
                incomeExpense.DeathWholeLifeInsuranceTerm = incomeExpenseDetail.DeathWholeLifeInsuranceTerm;
                incomeExpense.incomeExpenseNeeded = incomeExpenseDetail.incomeExpenseNeeded;
                incomeExpense.incomeExpenseNotNeededReason = incomeExpenseDetail.incomeExpenseNotNeededReason;
                incomeExpense.assecertainingAffordabilityEnable = incomeExpenseDetail.assecertainingAffordabilityEnable;
                incomeExpense.assecertainingAffordabilityReason = incomeExpenseDetail.assecertainingAffordabilityReason;

                incomeExpense.otherSourcesOfIncome = incomeExpenseDetail.otherSourcesOfIncome;

                incomeExpense.caseId=incomeExpenseDetail.caseId;

                var queryIncomeExpenseOthers = from incomeExpenseOther in ct.incomeExpenseOthers
                                               where incomeExpenseOther.incomeExpenseId == incomeExpenseDetail.id
                                               select incomeExpenseOther;
                foreach (incomeExpenseOther incomeExpenseOther in queryIncomeExpenseOthers)
                {
                    ct.incomeExpenseOthers.DeleteOnSubmit(incomeExpenseOther);
                }

                //update income expense others list for the IncomeExpense goal
                if (incomeExpenseDetail.incomeExpenseOthers != null && incomeExpenseDetail.incomeExpenseOthers.Count > 0)
                {
                    EntitySet<incomeExpenseOther> incomeExpenseOtherSet = new EntitySet<incomeExpenseOther>();
                    foreach (incomeExpenseOther incomeExpenseOther in incomeExpenseDetail.incomeExpenseOthers)
                    {
                        incomeExpenseOtherSet.Add(incomeExpenseOther);
                    }
                    incomeExpense.incomeExpenseOthers = incomeExpenseOtherSet;
                }

                var queryIncomeExpenseSaving = from insuranceArrangementSaving in ct.insuranceArrangementSavings
                                               where insuranceArrangementSaving.incomeExpenseId == incomeExpenseDetail.id
                                               select insuranceArrangementSaving;
                foreach (insuranceArrangementSaving insuranceArrangementSaving in queryIncomeExpenseSaving)
                {
                    ct.insuranceArrangementSavings.DeleteOnSubmit(insuranceArrangementSaving);
                }

                //update income expense others list for the IncomeExpense goal
                if (incomeExpenseDetail.insuranceArrangementSavings != null && incomeExpenseDetail.insuranceArrangementSavings.Count > 0)
                {
                    EntitySet<insuranceArrangementSaving> insuranceArrangementSavingSet = new EntitySet<insuranceArrangementSaving>();
                    foreach (insuranceArrangementSaving insuranceArrangementSaving in incomeExpenseDetail.insuranceArrangementSavings)
                    {
                        insuranceArrangementSavingSet.Add(insuranceArrangementSaving);
                    }
                    incomeExpense.insuranceArrangementSavings = insuranceArrangementSavingSet;
                }

                var queryIncomeExpenseRetirement = from insuranceArrangementRetirement in ct.insuranceArrangementRetirements
                                                   where insuranceArrangementRetirement.incomeExpenseId == incomeExpenseDetail.id
                                                   select insuranceArrangementRetirement;
                foreach (insuranceArrangementRetirement insuranceArrangementRetirement in queryIncomeExpenseRetirement)
                {
                    ct.insuranceArrangementRetirements.DeleteOnSubmit(insuranceArrangementRetirement);
                }

                //update income expense others list for the IncomeExpense goal
                if (incomeExpenseDetail.insuranceArrangementRetirements != null && incomeExpenseDetail.insuranceArrangementRetirements.Count > 0)
                {
                    EntitySet<insuranceArrangementRetirement> insuranceArrangementRetirementSet = new EntitySet<insuranceArrangementRetirement>();
                    foreach (insuranceArrangementRetirement insuranceArrangementRetirement in incomeExpenseDetail.insuranceArrangementRetirements)
                    {
                        insuranceArrangementRetirementSet.Add(insuranceArrangementRetirement);
                    }
                    incomeExpense.insuranceArrangementRetirements = insuranceArrangementRetirementSet;
                }

                var queryIncomeExpenseEducation = from insuranceArrangementEducation in ct.insuranceArrangementEducations
                                                  where insuranceArrangementEducation.incomeExpenseId == incomeExpenseDetail.id
                                                  select insuranceArrangementEducation;
                foreach (insuranceArrangementEducation insuranceArrangementEducation in queryIncomeExpenseEducation)
                {
                    ct.insuranceArrangementEducations.DeleteOnSubmit(insuranceArrangementEducation);
                }

                //update income expense others list for the IncomeExpense goal
                if (incomeExpenseDetail.insuranceArrangementEducations != null && incomeExpenseDetail.insuranceArrangementEducations.Count > 0)
                {
                    EntitySet<insuranceArrangementEducation> insuranceArrangementEducationSet = new EntitySet<insuranceArrangementEducation>();
                    foreach (insuranceArrangementEducation insuranceArrangementEducation in incomeExpenseDetail.insuranceArrangementEducations)
                    {
                        insuranceArrangementEducationSet.Add(insuranceArrangementEducation);
                    }
                    incomeExpense.insuranceArrangementEducations = insuranceArrangementEducationSet;
                }

                ct.SubmitChanges();
            }
            catch (Exception e)
            {
                string str = e.Message;
            }
            return incomeExpense;
        }
예제 #56
0
        public savinggoal updateSavingGoals(savinggoal goals, int sgid)
        {
            savinggoal retrievedGoal = null;

            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing saving goal
                var querySavingGoals = from sg in ct.savinggoals
                                       where sg.caseid == goals.caseid && sg.id == sgid
                                       select sg;
                foreach (savinggoal sgoals in querySavingGoals)
                {
                    retrievedGoal = sgoals;
                }

                //retrievedGoal = goals;

                //update saving goal attributes
                retrievedGoal.amtneededfv = goals.amtneededfv;
                retrievedGoal.goal = goals.goal;
                retrievedGoal.maturityvalue = goals.maturityvalue;
                retrievedGoal.regularannualcontrib = goals.regularannualcontrib;
                retrievedGoal.total = goals.total;
                retrievedGoal.yrstoaccumulate = goals.yrstoaccumulate;
                retrievedGoal.existingassetstotal = goals.existingassetstotal;
                retrievedGoal.savingGoalNeeded = goals.savingGoalNeeded;

                //delete existing assets for the saving goal
                var queryExistingAssets = from easg in ct.existingassetsgs
                                          where easg.savinggoalsid == retrievedGoal.id
                                       select easg;
                foreach (existingassetsg easgoals in queryExistingAssets)
                {
                    ct.existingassetsgs.DeleteOnSubmit(easgoals);
                    //ct.SubmitChanges();
                }

                //update existing assets list for the saving goal
                if (goals.existingassetsgs != null && goals.existingassetsgs.Count > 0)
                {
                    EntitySet<existingassetsg> easgList = new EntitySet<existingassetsg>();
                    foreach (existingassetsg sgea in goals.existingassetsgs)
                    {
                        easgList.Add(sgea);
                    }
                    retrievedGoal.existingassetsgs = easgList;
                }

                if (retrievedGoal.savingGoalNeeded == 1 || retrievedGoal.savingGoalNeeded == 0)
                {
                    var sgGoalRecords = from sgids in ct.savinggoals
                                        where sgids.caseid == goals.caseid
                                        select sgids;
                    int[] arrRecordIds = null;

                    if (sgGoalRecords != null)
                    {
                        int size = sgGoalRecords.ToArray().Length;
                        arrRecordIds = new int[size];
                    }

                    int index = 0;
                    foreach (savinggoal sgl in sgGoalRecords)
                    {
                        arrRecordIds[index] = sgl.id;
                        index++;
                    }

                    var todelExistingAssets = from easg in ct.existingassetsgs
                                              where arrRecordIds.Contains(easg.savinggoalsid)
                                              select easg;
                    foreach (existingassetsg easgoals in todelExistingAssets)
                    {
                        ct.existingassetsgs.DeleteOnSubmit(easgoals);
                    }

                    var toDeleteSgGoals = from sg in ct.savinggoals
                                          where sg.caseid == goals.caseid && sg.id != sgid
                                          select sg;
                    foreach (savinggoal s in toDeleteSgGoals)
                    {
                        ct.savinggoals.DeleteOnSubmit(s);
                    }
                }

                ct.SubmitChanges();

            }
            catch (Exception e)
            {
                string str = e.Message;
            }

            return retrievedGoal;
        }
예제 #57
0
        public Boolean updateAssetLiabilityDetails(assetAndLiability assetAndLiability)
        {
            Boolean status = true;
            assetAndLiability assetLiability = null;
            try
            {
                dbDataContext ct = new dbDataContext();

                //retrieve existing saving goal
                var queryAssetAndLiabilityGoals = from al in ct.assetAndLiabilities
                                       where al.caseId == assetAndLiability.caseId
                                       select al;
                foreach (assetAndLiability assetLiabilityGoals in queryAssetAndLiabilityGoals)
                {
                    assetLiability = assetLiabilityGoals;
                }

                assetLiability.bankAcctCash = assetAndLiability.bankAcctCash;
                assetLiability.cashLoan = assetAndLiability.cashLoan;
                assetLiability.cpfoaBal = assetAndLiability.cpfoaBal;
                assetLiability.creditCard = assetAndLiability.creditCard;
                assetLiability.homeMortgage = assetAndLiability.homeMortgage;
                assetLiability.ilpCash = assetAndLiability.ilpCash;
                assetLiability.ilpCpf = assetAndLiability.ilpCpf;
                assetLiability.invPropCash = assetAndLiability.invPropCash;
                assetLiability.invPropCpf = assetAndLiability.invPropCpf;
                assetLiability.lumpSumCash = assetAndLiability.lumpSumCash;
                assetLiability.lumpSumCpf = assetAndLiability.lumpSumCpf;
                assetLiability.netWorth = assetAndLiability.netWorth;
                assetLiability.regularSumCash = assetAndLiability.regularSumCash;
                assetLiability.regularSumCpf = assetAndLiability.regularSumCpf;
                assetLiability.resPropCash = assetAndLiability.resPropCash;
                assetLiability.resPropCpf = assetAndLiability.resPropCpf;
                assetLiability.srsBal = assetAndLiability.srsBal;
                assetLiability.srsInvCash = assetAndLiability.srsInvCash;
                assetLiability.stocksSharesCash = assetAndLiability.stocksSharesCash;
                assetLiability.stocksSharesCpf = assetAndLiability.stocksSharesCpf;
                assetLiability.submissionDate = assetAndLiability.submissionDate;
                assetLiability.unitTrustsCash = assetAndLiability.unitTrustsCash;
                assetLiability.unitTrustsCpf = assetAndLiability.unitTrustsCpf;
                assetLiability.vehicleLoan = assetAndLiability.vehicleLoan;
                assetLiability.cpfsaBal = assetAndLiability.cpfsaBal;
                assetLiability.cpfMediSaveBalance = assetAndLiability.cpfMediSaveBalance;
                assetLiability.assetAndLiabilityNeeded = assetAndLiability.assetAndLiabilityNeeded;
                assetLiability.assetAndLiabilityNotNeededReason = assetAndLiability.assetAndLiabilityNotNeededReason;
                assetLiability.assetIncomePercent = assetAndLiability.assetIncomePercent;
                assetLiability.premiumRecomendedNeeded = assetAndLiability.premiumRecomendedNeeded;

                var queryliabilityOthers = from liabilityOther in ct.liabilityOthers
                                           where liabilityOther.assetLiabilityId == assetAndLiability.id
                                           select liabilityOther;
                foreach (liabilityOther liabilityOthers in queryliabilityOthers)
                {
                    ct.liabilityOthers.DeleteOnSubmit(liabilityOthers);
                }

                var querypersonalUseAssetsOthers = from personalUseAssetsOther in ct.personalUseAssetsOthers
                                                   where personalUseAssetsOther.assetLiabilityId == assetAndLiability.id
                                                   select personalUseAssetsOther;
                foreach (personalUseAssetsOther personalUseAssetsOther  in querypersonalUseAssetsOthers)
                {
                    ct.personalUseAssetsOthers.DeleteOnSubmit(personalUseAssetsOther);
                }

                var queryinvestedAssetOthers = from investedAssetOthers in ct.investedAssetOthers
                                               where investedAssetOthers.assetLiabilityId == assetAndLiability.id
                                               select investedAssetOthers;
                foreach (investedAssetOther investedAssetOther in queryinvestedAssetOthers)
                {
                    ct.investedAssetOthers.DeleteOnSubmit(investedAssetOther);
                }

                //update liability others list for the AssetLiability goal
                if (assetAndLiability.liabilityOthers != null && assetAndLiability.liabilityOthers.Count > 0)
                {
                    EntitySet<liabilityOther> liabilityOtherSet = new EntitySet<liabilityOther>();
                    foreach (liabilityOther liabilityOther in assetAndLiability.liabilityOthers)
                    {
                        liabilityOtherSet.Add(liabilityOther);
                    }
                    assetLiability.liabilityOthers = liabilityOtherSet;
                }

                //update personal UseAssets others list for the AssetLiability
                if (assetAndLiability.personalUseAssetsOthers != null && assetAndLiability.personalUseAssetsOthers.Count > 0)
                {
                    EntitySet<personalUseAssetsOther> personalUseAssetsOtherSet = new EntitySet<personalUseAssetsOther>();
                    foreach (personalUseAssetsOther liabilityOther in assetAndLiability.personalUseAssetsOthers)
                    {
                        personalUseAssetsOtherSet.Add(liabilityOther);
                    }
                    assetLiability.personalUseAssetsOthers = personalUseAssetsOtherSet;
                }

                //update invested others list for the AssetLiability
                if (assetAndLiability.investedAssetOthers != null && assetAndLiability.investedAssetOthers.Count > 0)
                {
                    EntitySet<investedAssetOther> investedAssetOtherSet = new EntitySet<investedAssetOther>();
                    foreach (investedAssetOther investedAssetOther in assetAndLiability.investedAssetOthers)
                    {
                        investedAssetOtherSet.Add(investedAssetOther);
                    }
                    assetLiability.investedAssetOthers = investedAssetOtherSet;
                }

                ct.SubmitChanges();
            }
            catch (Exception e)
            {
                status = false;
                string str = e.Message;
            }

            return status;
        }
예제 #58
0
        public void SanityChecking()
        {
            var people = new EntitySet<Person>();
            bool changed = false;
            people.ListChanged += (o, e) => {
                changed = true;
            };

            Assert.IsFalse(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(0, people.Count);
            Assert.IsFalse(people.IsDeferred);

            people.Add(new Person { FirstName = "A", LastName = "B" });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            // WTF?!
            Assert.IsFalse(changed);

            changed = false;
            people.Add(new Person { FirstName = "1", LastName = "2" });
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(2, people.Count);
            // WTF?!
            Assert.IsFalse(changed);


            changed = false;
            people.RemoveAt(0);
            Assert.IsTrue(people.HasLoadedOrAssignedValues);
            Assert.AreEqual(1, people.Count);
            Assert.IsFalse(people.IsDeferred);
            Assert.IsTrue(changed);
        }
예제 #59
0
        private EntitySet LoadWithXPath(string xPath)
        {
            EntitySet result = new EntitySet();

            foreach (XmlNode n in _Document.SelectNodes(xPath))
            {
                Entity e = CreateEntity(n);
                if (e != null)
                {
                    result.Add(e);
                }
            }

            return result;
        }
예제 #60
0
        protected void submitEducationGoals(object sender, EventArgs e)
        {
            educationgoal goals = new educationgoal();

            goals.educationGoalNeeded = Convert.ToInt16(educationGoalNeeded.SelectedValue);

            if (goals.educationGoalNeeded == 2)
            {
                goals.agefundsneeded = ageWhenFundsNeeded.Text;
                goals.currentage = currentAge.Text;
                goals.maturityvalue = maturityValue.Text;
                goals.nameofchild = nameofChild.Text;
                goals.noofyrstosave = yrsToSave.Text;

                if (totalShortfallSurplus.Text != null && totalShortfallSurplus.Text != "")
                {
                    double ttl = double.Parse(totalShortfallSurplus.Text);
                    if (ttl < 0)
                    {
                        totalShortfallSurplus.Text = Math.Abs(ttl).ToString();
                    }
                }
                goals.total = totalShortfallSurplus.Text;

                goals.existingassetstotal = existingAssetsEducationGoals.Text;
                goals.futurecost = futureValue.Text;
                goals.presentcost = costEducation.Text;
                goals.inflationrate = inflationRate.Text;
            }
            else if (goals.educationGoalNeeded == 1 || goals.educationGoalNeeded == 0)
            {
                goals.agefundsneeded = "0";
                goals.currentage = "0";
                goals.maturityvalue = "0";
                goals.nameofchild = "";
                goals.noofyrstosave = "0";
                goals.total = "0";
                goals.existingassetstotal = "0";
                goals.futurecost = "0";
                goals.presentcost = "0";
                goals.inflationrate = "0";
            }

            goals.deleted = false;

            string caseid = "";
            if (ViewState["caseid"]!=null)
            {
                caseid = ViewState["caseid"].ToString();
                goals.caseid = caseid;
            }

            goals.countryofstudyid = Int16.Parse(countryList.SelectedValue);

            int noofea = 0;
            if (goals.educationGoalNeeded == 2)
            {
                if (noofmembers.Value != "")
                {
                    noofea = Int16.Parse(noofmembers.Value);
                }
            }

            EntitySet<existingasseteg> easgList = new EntitySet<existingasseteg>();
            if (noofea > 0)
            {
                for (int i = 1; i <= noofea; i++)
                {
                    existingasseteg easg = new existingasseteg();
                    easg.asset = Request.Form["pri-" + i];
                    easg.presentvalue = Request.Form["pri_" + i];
                    easg.percentpa = Request.Form["sec_" + i];

                    if ((Request.Form["pri-" + i] != null) && (Request.Form["pri_" + i] != null) && (Request.Form["sec_" + i] != null))
                    {
                        easgList.Add(easg);
                    }

                }
                goals.existingassetegs = easgList;
            }

            int egid = 0;
            if (ViewState["egid"] != null)
            {
                egid = Int32.Parse(ViewState["egid"].ToString());
            }

            if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "new")
            {
                goals = educationGoalsDao.saveEducationGoals(goals);
            }
            else if (ViewState["casetype"] != null && ViewState["casetype"].ToString() == "update")
            {
                goals = educationGoalsDao.updateEducationGoals(goals, egid);
            }

            string actv = "";
            if (ViewState["activity"] != null)
            {
                actv = ViewState["activity"].ToString();
            }

            string status = activityStatusCheck.getEducationGoalStatus(caseid);
            activityStatusDao.saveOrUpdateActivityStatus(caseid, actv, status);

            markStatusOnTab(caseid);

            string caseStatus = activityStatusCheck.getZPlanStatus(caseid);

            /*if (st == 1)
            {
                lblStatusSubmitted.Visible = false;
            }
            else
            {
                lblStatusSubmissionFailed.Visible = true;
            }*/

            if (goals != null)
            {
                lblEducationGoalSuccess.Visible = true;

                educationGoal = educationGoalsDao.getEducationGoal(caseid);

                educationgoal displaysg = null;
                if (educationGoal != null && educationGoal.Count > 0)
                {
                    if (addandsave.Value == "1")
                    {
                        displaysg = educationGoal[educationGoal.Count-1];
                    }
                    else
                    {
                        bool found = false;
                        int count = 0;
                        foreach (educationgoal sgl in educationGoal)
                        {
                            if (egid == sgl.id)
                            {
                                found = true;
                                break;
                            }
                            count++;
                        }

                        if (found)
                        {
                            displaysg = educationGoal[count];
                        }
                        else
                        {
                            displaysg = educationGoal[0];
                        }
                    }

                    educationgoalid.Value = displaysg.id.ToString();
                    addandsave.Value = "";
                }
                populateEducationGoal(displaysg, assmptn, cced, caseid);

                List<educationgoal> gridgoal = educationGoal;
                foreach (educationgoal s in gridgoal)
                {
                    double damtfv = 0;
                    double dmaturityval = 0;
                    double deattl = 0;

                    if (s.futurecost != null && s.futurecost != "")
                    {
                        damtfv = double.Parse(s.futurecost);
                    }
                    if (s.maturityvalue != null && s.maturityvalue != "")
                    {
                        dmaturityval = double.Parse(s.maturityvalue);
                    }
                    if (s.existingassetstotal != null && s.existingassetstotal != "")
                    {
                        deattl = double.Parse(s.existingassetstotal);
                    }

                    if (((dmaturityval + deattl) - damtfv) < 0)
                    {
                        s.total = "-" + s.total;
                    }
                }

                //existingeggrid.DataSource = educationGoal;
                existingeggrid.DataSource = gridgoal;
                existingeggrid.DataBind();

                //refreshEducationGoal(assmptn, cced);
            }
            else
            {
                lblEducationGoalFailed.Visible = true;
            }
            string url = Server.MapPath("~/_layouts/Zurich/Printpages/");
            pdfData = activityStatusCheck.sendDataToSalesPortal(caseid, caseStatus, url, sendPdf);
        }