Beispiel #1
0
        public string Save(string objProperties)
        {
            MessageResponse msg = new MessageResponse();
            try
            {
                Dictionary<string, string> dicProperties = JsonConvert.DeserializeObject<Dictionary<string, string>>(objProperties);

                Visit visit = new Visit();
                visit.Id_Visitor = Convert.ToDecimal(dicProperties["Id_Person"]);

                DateTime InitialDate = Convert.ToDateTime(dicProperties["InitialDate"] + " " + dicProperties["InitialHour"]);
                DateTime FinalDate = Convert.ToDateTime(dicProperties["FinalDate"] + " " + dicProperties["FinalHour"]);

                visit.InitialDate = InitialDate;
                visit.InitialHour = InitialDate;
                visit.FinalDate = FinalDate;
                visit.FinalHour = FinalDate;
                visit.Id_Functionary = (float)Convert.ToInt64(dicProperties["Id_Functionary"]);
                visit.ElementsToGetIn = dicProperties["ElementsToGetIn"];
                visit.VisitDescription = dicProperties["VisitDescription"];
                visit.DateCreateTransaction = System.DateTime.Now;
                visit.DateModifyRegistration = System.DateTime.Now;
                visit.DateCreateRegistration = System.DateTime.Now;
                VisitsDao.save(visit);

                msg.Message = ConfigManager.SaveSuccessMessage;
            }
            catch (Exception exception)
            {
                msg.Message = ConfigManager.SaveErrorMessage;
                msg.Error = exception.ToString();
            }

            return serialize.Serialize(msg);
        }
Beispiel #2
0
        public static void update(Visit visit)
        {
            using (ITransaction transaction = Session.BeginTransaction())
            {
                try
                {
                    Session.Clear();

                    Session.Update(visit);

                    transaction.Commit();

                    Session.Flush();
                }
                catch (Exception exception)
                {
                    transaction.Rollback();
                    throw exception;
                }
            }
        }
Beispiel #3
0
        public static void Test(TypeTest type)
        {
            switch (type)
            {
                case TypeTest.Diary:
                    {
                        Diary diary = DiariesDao.find(1);

                        List<Diary> diaries = DiariesDao.findBy("Id_Visitor", "11");

                        List<Visit> visits = VisitsDao.findBy("Id_Visitor", 11);

                        if (diary == null)
                        {
                            diary = new TMA.MODEL.Entity.Diary()
                            {
                                DateDiary = "0",
                                HourDiary = "0",
                                DateCreateRegistration = DateTime.Now.ToLocalTime(),
                                DateModifyRegistration = DateTime.Now.ToLocalTime(),
                                CenterCost = 1

                            };

                            TMA.DAO.EntityManager.DiariesDao.save(diary);
                        }

                        break;
                    }
                case TypeTest.Person:
                    {
                        Person person = PersonsDao.find(2);

                        if (person == null)
                        {
                            person = new TMA.MODEL.Entity.Person()
                            {
                                Id_BiometricReader = 500003,
                                Name = "Agustín",
                                LastName = "Mejía",
                                DateCreateRegistration = DateTime.Now,

                            };

                            TMA.DAO.EntityManager.PersonsDao.save(person);
                        }
                        else {
                            person.DateModifyRegistration = DateTime.Now;
                            TMA.DAO.EntityManager.PersonsDao.update(person);
                        }

                        break;
                    }

                case TypeTest.Visit:
                    {
                        Visit visit = VisitsDao.find(8);

                        VisitsDao.findFunctionaryBy("Name", "wil");

                        if (visit == null)
                        {
                            visit = new TMA.MODEL.Entity.Visit()
                            {
                                Id_Visit = 0,
                                Id_Visitor = 1,
                                Id_Functionary = 1,
                                VisitDescription = "Capacitación",
                                ElementsToGetIn = "Pc",
                                DateCreateTransaction = DateTime.Now,
                                DateCreateRegistration = DateTime.Now,
                                DateModifyRegistration = DateTime.Now,
                                FinalDate = DateTime.Now,
                                FinalHour = DateTime.Now,
                                InitialDate = DateTime.Now,
                                InitialHour = DateTime.Now,
                                Id_UserCreateRegistration = "1",
                                Id_UserModifyRegistration = "1",
                                Id_Area = 1
                            };

                            TMA.DAO.EntityManager.VisitsDao.save(visit);
                        }

                        break;
                    }

                case TypeTest.User:
                    {
                        Users user = TMA.DAO.EntityManager.UsersDao.find(2);

                        if (user == null)
                        {
                            user = new TMA.MODEL.Entity.Users()
                            {
                                Id_User = 2,
                                IsActive = true,
                                Id_Role = 1,
                                DocumentType = 1,
                                DateCreateRegistration = System.DateTime.Now,
                                DateModifyRegistration = System.DateTime.Now,
                                Name = "Agus",
                                Login = "******"
                            };

                            TMA.DAO.EntityManager.UsersDao.save(user);
                        }
                        break;
                    }
                case TypeTest.Profile: {

                    Profile profile = ProfilesDao.find(8);

                    if (profile == null)
                    {
                        profile = new TMA.MODEL.Entity.Profile() { Id_Profile = 4, Description = "Administrador", DateCreateRegistration = DateTime.Now, Id_User = 1, DateModifyRegistration = DateTime.Now, Id_UserModifyRegistration = 1 };
                        TMA.DAO.EntityManager.ProfilesDao.save(profile);
                    }

                    break;
                }

                case TypeTest.Headquarter:
                    {
                        Headquarter head = HeadquartersDao.find(1);

                        if (head == null)
                        {
                            head = new TMA.MODEL.Entity.Headquarter() { Id_Headquarter = 3, Description = "Este" };
                            TMA.DAO.EntityManager.HeadquartersDao.save(head);
                        }

                        break;
                    }

                case TypeTest.Department:
                    {
                        Department department = DepartmentsDao.find(1);

                        if (department == null)
                        {
                            department = new TMA.MODEL.Entity.Department() { Name = "Valle" };
                            TMA.DAO.EntityManager.DepartmentsDao.save(department);
                        }

                        break;
                    }

                case TypeTest.City:
                    {
                        City city = CitiesDao.find(1);

                        if (city == null)
                        {
                            city = new TMA.MODEL.Entity.City() {  Name = "Cali", Id_Department = 1 };
                            TMA.DAO.EntityManager.CitiesDao.save(city);
                        }

                        break;
                    }

                case TypeTest.Depencency:
                    {
                        Dependency dependency = DependenciesDao.find(10);

                        if (dependency == null)
                        {
                            dependency = new Dependency()
                            {
                                Name = "Sistemas",
                                Id_Company = 1
                            };

                            DependenciesDao.save(dependency);
                        }

                        break;
                    }

                case TypeTest.CostCenter:
                    {
                        CostCenter cost = CostCentersDao.find(10);

                        if( cost == null)
                        {
                            cost = new CostCenter()
                            {
                                Id_Dependency =1,
                                Name = "Sistemas"
                            };

                            CostCentersDao.save(cost);
                        }

                        break;
                    }

                case TypeTest.Company:
                    {
                        Company company = CompaniesDao.find(10);

                        if (company == null)
                        {
                            company = new Company()
                            {
                                Name = "Carvajal Servicios",
                                Address = "Calle 1234",
                                Id_City = 1,
                                Id_Subsidiary = 1
                            };

                            CompaniesDao.save(company);
                        }

                        break;
                    }
            }
        }