Esempio n. 1
0
		// This method is invoked when the application has loaded its UI and its ready to run
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

		dataSource = new EmployeeDataSource(this);
		@delegate = new EmployeeListDelegate(this);
		tableviewEmployee.DataSource = dataSource;
		tableviewEmployee.Delegate = @delegate;
		alertDelegate = new CallAlert (this);

			//System.MissingMethodException: Method not found: 'Default constructor not found...ctor() of CorporateDirectory1.Employee'.
			var e = new Employee();
			e.Firstname = "a"; e.Work=1; e.Mobile=2; e.Lastname="b";e.Department="c";e.Email="@";
			var f = e.Firstname; var g = e.Work; var h=e.Mobile; var i=e.Lastname; var j=e.Department; var k=e.Email;
			
			using (var db = new SQLiteClient.SQLiteConnection("phonebook")) {
				// Perform strongly typed queries
			    var users = db.Query<Employee>("SELECT Firstname, Lastname, Work, Mobile, Department, Email FROM Phonebook ORDER BY Lastname", 1000);
			    
				listData = users.ToList();
			}
			
			
			window.MakeKeyAndVisible ();
			return true;
		}
Esempio n. 2
0
        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            dataSource = new EmployeeDataSource(this);
            @delegate  = new EmployeeListDelegate(this);
            tableviewEmployee.DataSource = dataSource;
            tableviewEmployee.Delegate   = @delegate;
            alertDelegate = new CallAlert(this);

            //System.MissingMethodException: Method not found: 'Default constructor not found...ctor() of CorporateDirectory1.Employee'.
            var e = new Employee();

            e.Firstname = "a"; e.Work = 1; e.Mobile = 2; e.Lastname = "b"; e.Department = "c"; e.Email = "@";
            var f = e.Firstname; var g = e.Work; var h = e.Mobile; var i = e.Lastname; var j = e.Department; var k = e.Email;

            using (var db = new SQLiteClient.SQLiteConnection("phonebook")) {
                // Perform strongly typed queries
                var users = db.Query <Employee>("SELECT Firstname, Lastname, Work, Mobile, Department, Email FROM Phonebook ORDER BY Lastname", 1000);

                listData = users.ToList();
            }


            window.MakeKeyAndVisible();
            return(true);
        }
Esempio n. 3
0
        public ActionResult Index(string sort, string sortdir, int?page = 1)
        {
            var list  = EmployeeDataSource.CreateEmployees();
            var model = new RptViewModel {
                EmployeesList = list
            };

            return(View(model));
        }
Esempio n. 4
0
        static async Task <SimulatorConfiguration> CreateConfiguration(AppSettings appSettings)
        {
            EmployeeDataSource employeeDataSource = new EmployeeDataSource(appSettings.EmployeeApiUri, appSettings.EmployeeApiKey);

            SimulatorConfiguration simConfig = SimulatorConfigManager.GetDefaultConfiguration();

            simConfig.Employees = await GetEmployeesAsync(employeeDataSource, simConfig.FloorPeopleMapping.Sum(f => f.Value));

            // Mark employees who will use break room.
            SimulatorConfigManager.SetEmployeesBreakroomUse(simConfig, .25m);

            // This should always be done last!
            SimulatorConfigManager.AssignEmployeesToOffices(simConfig);

            return(simConfig);
        }
Esempio n. 5
0
        [HttpPost] //for IE-8
        public ActionResult SearchEmployeeInfo(string data)
        {
            if (!Request.IsAjaxRequest())
            {
                return(Content(string.Empty));
            }

            if (string.IsNullOrWhiteSpace(data))
            {
                return(Content(string.Empty));
            }

            var employeesList = EmployeeDataSource.CreateEmployees();
            var list          = employeesList.Where(x => x.Name.Contains(data)).ToList();

            if (list == null || !list.Any())
            {
                return(Content(string.Empty));
            }

            return(PartialView(viewName: "_SearchEmployeeInfo", model: list));
        }
Esempio n. 6
0
        [HttpPost] //for IE-8
        public ActionResult EmployeeInfoData(int?id)
        {
            if (!Request.IsAjaxRequest())
            {
                return(Json(false));
            }

            if (!id.HasValue)
            {
                return(Json(false));
            }

            var list = EmployeeDataSource.CreateEmployees();
            var data = list.Where(x => x.Id == id.Value).FirstOrDefault();

            if (data == null)
            {
                return(Json(false));
            }

            return(Json(data));
        }
Esempio n. 7
0
        [HttpPost] //for IE-8
        public ActionResult EmployeeInfo(int?id)
        {
            if (!Request.IsAjaxRequest())
            {
                return(View("Error"));
            }

            if (!id.HasValue)
            {
                return(View("Error"));
            }

            var list = EmployeeDataSource.CreateEmployees();
            var data = list.Where(x => x.Id == id.Value).FirstOrDefault();

            if (data == null)
            {
                return(View("Error"));
            }

            return(PartialView(viewName: "_EmployeeInfo", model: data));
        }
Esempio n. 8
0
        /// <summary>
        /// Get our random employees from employee source.
        /// </summary>
        /// <param name="simDataStore">The employee data source.</param>
        /// <param name="count">The number of employees to get.</param>
        /// <returns>List of employees.</returns>
        static async Task <IList <SimulatorEmployee> > GetEmployeesAsync(EmployeeDataSource simDataStore, int count)
        {
            string employeesJson = null;

            try
            {
                employeesJson = await simDataStore.GetEmployeesAsync(530);
            }
            catch (HttpRequestException exc)
            {
                LogMessage("ERROR", "HTTP Request exception. Unable to retrieve a list of employees: " + exc.ToString());
                throw;
            }
            catch (Exception exc)
            {
                LogMessage("ERROR", "Unable to retrieve a list of employees: " + exc.ToString());
                throw;
            }

            var results = JsonSerializer.Deserialize <IList <SimulatorEmployee> >(employeesJson);

            return(results);
        }
Esempio n. 9
0
        public void StressTest()
        {
            var organizationDataSource = new OrganizationDataSource();
            var companyDataTarget      = new CompanyDataTarget();
            var stateStorage           = new SyncStateStorage();
            var keyMapStorage          = new SyncKeyMapStorage();

            var pk = 1;

            for (var times = 0; times < 10; times++)
            {
                Log.Debug($"PREPARING CHANGES");
                var random = new Random();
                for (var i = 0; i < 10; i++)
                {
                    var operation = random.Next(0, 5);

                    switch (operation)
                    {
                    case 0:
                    case 1:
                        //INSERT
                        var organization = new Organization
                        {
                            Id   = pk++,
                            Name = Guid.NewGuid().ToString(),
                            RegistrationNumber = Guid.NewGuid().ToString()
                        };
                        OrganizationStorage.Storage.Add(organization);

                        Log.Debug($"Created organization '{organization.Id}'");
                        break;

                    case 2:
                    case 3:
                        //UPDATE
                        if (OrganizationStorage.Storage.Count > 0)
                        {
                            var itemNr = random.Next(0, OrganizationStorage.Storage.Count);
                            var update = OrganizationStorage.Storage[itemNr];
                            update.Name = Guid.NewGuid().ToString();
                            Log.Debug($"Updated organization '{update.Id}'");
                        }
                        break;

                    case 4:
                        //DELETE
                        if (OrganizationStorage.Storage.Count > 0)
                        {
                            var itemNr = random.Next(0, OrganizationStorage.Storage.Count);
                            OrganizationStorage.Storage.RemoveAt(itemNr);
                            Log.Debug($"Deleted organization");
                        }
                        break;
                    }
                }



                if (OrganizationStorage.Storage.Count > 0)
                {
                    var orgNr = random.Next(0, OrganizationStorage.Storage.Count);

                    var organization = OrganizationStorage.Storage[orgNr];

                    for (var i = 0; i < 10; i++)
                    {
                        var operation = random.Next(0, 5);

                        switch (operation)
                        {
                        case 0:
                        case 1:
                            //INSERT
                            var employee = new Employee
                            {
                                Id        = pk++,
                                Firstname = Guid.NewGuid().ToString(),
                                Lastname  = Guid.NewGuid().ToString()
                            };
                            organization.Employees.Add(employee);
                            Log.Debug($"Created employee '{employee.Id}' in organization '{organization.Id}'");

                            break;

                        case 2:
                        case 3:
                            //UPDATE
                            if (organization.Employees.Count > 0)
                            {
                                var itemNr = random.Next(0, organization.Employees.Count);
                                var update = organization.Employees[itemNr];
                                update.Firstname = Guid.NewGuid().ToString();
                            }
                            break;

                        case 4:
                            //DELETE
                            if (organization.Employees.Count > 0)
                            {
                                var itemNr = random.Next(0, organization.Employees.Count);
                                organization.Employees.RemoveAt(itemNr);
                            }
                            break;
                        }
                    }
                }

                Log.Debug($"DONE PREPARING CHANGES");

                Action <string, string, Organization, Company> nestedTasks = (sourceKey, targetKey, sourceItem, targetItem) =>
                {
                    Log.Debug($"Sync for org {sourceKey}, t= '{targetKey}' started");


                    var organizationId  = int.Parse(sourceKey);
                    var employeeStorage = new EmployeeDataSource(organizationId);

                    var companyId          = int.Parse(targetKey);
                    var companyUserStorage = new CompanyUserDataTarget(companyId);

                    var employeeSyncTask = new SyncTask <Employee, CompanyUser>(
                        "EmployeeSyncTask",
                        employeeStorage,
                        companyUserStorage,
                        stateStorage,
                        keyMapStorage,
                        null,
                        sourceKey);

                    employeeSyncTask.Execute();
                };

                var orgSyncTask = new SyncTask <Organization, Company>(
                    "OrganizationSyncTask",
                    organizationDataSource,
                    companyDataTarget,
                    stateStorage,
                    keyMapStorage,
                    nestedTasks,
                    null
                    );

                orgSyncTask.Execute();


                try
                {
                    CheckCurrentSyncState();
                }
                catch (Exception ex)
                {
                    throw new Exception("State not valid!", ex);
                }
            }
        }
Esempio n. 10
0
        public ActionResult Index(string sort, string sortdir, int?page = 1)
        {
            var list = EmployeeDataSource.CreateEmployees();

            return(View(list));
        }