Example #1
0
        public static Person AddPerson(PersonMamut personMamut)
        {
            var person = GetPersonByName(personMamut.FirstName, personMamut.LastName);

            if (person != null)
            {
                Person newperson = new Person(person.PersonId, personMamut.FirstName, personMamut.LastName, personMamut.Mobile, personMamut.Email, true, person.Active);

                DataLayer.UpdatePerson(newperson, sqlConnection);

                return(newperson);
            }
            else
            {
                Person newperson = new Person(Guid.NewGuid(), personMamut.FirstName, personMamut.LastName, personMamut.Mobile, personMamut.Email, true, true);
                DataLayer.CreatePerson(newperson, sqlConnection);

                return(newperson);
            }
        }
Example #2
0
        public static Person AddPerson(PersonMamut personMamut)
        {
            var person = GetPersonByName(personMamut.FirstName, personMamut.LastName);

            if (person != null)
            {
                Person newperson = new Person(person.PersonId, personMamut.FirstName, personMamut.LastName, personMamut.Mobile, personMamut.Email, true, person.Active);

                DataLayer.UpdatePerson(newperson, sqlConnection);

                return newperson;
            }
            else
            {
                Person newperson = new Person(Guid.NewGuid(), personMamut.FirstName, personMamut.LastName, personMamut.Mobile, personMamut.Email, true, true);
                DataLayer.CreatePerson(newperson, sqlConnection);

                return newperson;
            }
        }
Example #3
0
        public static List<Person> GetPersonsFromMamut(List<Person> persons, HttpRequest request)
        {
            string mamutID = "";
            int mamutStartValue = 0;
            int mamutMaxValue = 0;
            System.Configuration.Configuration rootWebConfig1 =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(request.ApplicationPath);

            if (rootWebConfig1.AppSettings.Settings.Count > 0)
            {
                KeyValueConfigurationElement mamutIDSetting =
                    rootWebConfig1.AppSettings.Settings["MAMUT_ID"];
                KeyValueConfigurationElement mamutStartNumber =
                    rootWebConfig1.AppSettings.Settings["MAMUT_START_VALUE"];
                KeyValueConfigurationElement mamutmaxNumber =
                    rootWebConfig1.AppSettings.Settings["MAMUT_MAX_VALUE"];

                mamutID = mamutIDSetting.Value;
                mamutStartValue = Convert.ToInt32(mamutStartNumber.Value);
                mamutMaxValue = Convert.ToInt32(mamutmaxNumber.Value);

            }

            // Get All Employees from Mamut
            dynamic gba2 = Activator.CreateInstance(Type.GetTypeFromProgID("GBAAPI.Gba"));
            dynamic connectinfo2 = Activator.CreateInstance(Type.GetTypeFromProgID("GBAAPI.Connectinfo"));
            connectinfo2.SetConnectBasicInfo(".", "mamut", 1, mamutID);
            gba2.openConnection(connectinfo2);
            dynamic Employee = Activator.CreateInstance(Type.GetTypeFromProgID("GBAAPI.CEmployee"));
            Employee.NewInit(gba2);
            List<PersonMamut> emp = new List<PersonMamut>();

            if (Employee.NewInit(gba2) == true)
            {
                int id = 0;
                for (int j = mamutStartValue; j < mamutMaxValue; j++)
                {
                    try
                    {
                        Employee.Get(j);

                        Iemployee employee = Employee;

                        if (employee.Firstname.Trim() != "" && id != employee.Empid)
                        {

                            // Check if employee is "Anställd"
                            if (employee.Data15.ToString() == "3")
                            {
                                string firstname = employee.Firstname.Trim();
                                string lastname = employee.Surname.Trim();
                                string email = employee.Email1.Trim();
                                string mobile = employee.Mobilephone1.Trim();
                                id = employee.Empid;
                                PersonMamut personMamut = new PersonMamut(firstname, lastname, email, mobile, id);
                                emp.Add(personMamut);
                            }
                            // Check if employee is "Ingen" (Set person to inactive)
                            if (employee.Data15.ToString() == "1")
                            {
                                var person = SiteUtilities.GetPersonByName(employee.Firstname.Trim(), employee.Surname.Trim());

                                if (person != null)
                                {
                                    SiteUtilities.SetPersonInactive(person);
                                }
                            }
                        }
                        else
                        {
                            j = 100;
                        }
                    }
                    catch
                    {
                        mamutMaxValue = j;
                    }

                }

                persons = AddOrUpdatePerson(emp);
            }

            return persons;
        }