Exemple #1
0
        private async void CheckOut_Clicked(object sender, EventArgs e)
        {
            checkOut.IsEnabled   = false;
            gd.TimeRegisteredOut = await MakeNewTimeReg("Check out");

            var temp = await db.GetJobRecLinesAsync();

            JobRecLine temp2 = new JobRecLine();

            try
            {
                temp2 = temp.Where(i => i.IsRunning).First();
            }
            catch
            {
                temp2 = null;
            }
            if (temp2 != null)
            {
                temp2.IsRunning = false;
                temp2.End_Time  = DateTime.UtcNow;
                await db.UpdateJobRecLineAsync(temp2);
            }
            ThreadManager manager = new ThreadManager();

            manager.Sync();
        }
Exemple #2
0
        private void CreateMenu()
        {
            var moreAction = new MenuItem {
                Text = "Rediger"
            };

            moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            moreAction.Clicked += (sender, e) =>
            {
                var        mi       = ((MenuItem)sender);
                JobRecLine _recLine = (JobRecLine)mi.CommandParameter;
                MessagingCenter.Send <JobRecLine>(_recLine, "hi");
                //(new JobRecLineUpdateForm(_recLine));
            };

            var SendAction = new MenuItem {
                Text = "Send"
            };

            SendAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            SendAction.Clicked += (sender, e) =>
            {
                var mi = ((MenuItem)sender);

                JobRecLine _recLine = (JobRecLine)mi.CommandParameter;
                _recLine.Sent   = true;
                _recLine.Edited = true;
                App.Database.UpdateJobRecLineAsync(_recLine);
            };
            this.ContextActions.Add(moreAction);
            this.ContextActions.Add(SendAction);
        }
Exemple #3
0
        public async Task <bool> CreateJobRecLine(JobRecLine task)
        {
            try
            {
                HttpClient client = ClientGateway.GetHttpClient;

                var data = JsonConvert.SerializeObject(task);

                var content = new StringContent(data, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(endPoint + "create", content);

                if (response.IsSuccessStatusCode)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #4
0
        private void Lv_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var        action = ((ListView)sender).SelectedItem;
            JobRecLine c      = (JobRecLine)action;

            this.Navigation.PushModalAsync(new JobRecLineDetail(c));
        }
Exemple #5
0
        public JobRecLineForm(MaintenanceTask task)
        {
            recLine    = new JobRecLine();
            taskGlobal = task;

            workTypePicker = new Picker()
            {
                VerticalOptions = LayoutOptions.Start
            };
            workTypePicker.Title = "Vælg arbejdstype";
            workTypePicker.SelectedIndexChanged += WorkTypePicker_SelectedIndexChanged;
            resourceMachinePicker = new Picker()
            {
                VerticalOptions = LayoutOptions.Start
            };
            resourceMachinePicker.Title = "Vælg Maskine";
            resourceMachinePicker.SelectedIndexChanged += ResourceMachinePicker_SelectedIndexChanged;
            SetItemssources();
            start = new Button {
                Text = "Start opgave", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White, VerticalOptions = LayoutOptions.Start
            };
            cancel = new Button {
                Text = "Cancel", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White, VerticalOptions = LayoutOptions.Start
            };

            datePicker = new DatePicker()
            {
                Format = "D",
                Date   = DateTime.Today
            };
            start.Clicked  += Start_Clicked;
            cancel.Clicked += Cancel_Clicked;
            layout          = new StackLayout
            {
                Children =
                {
                    //datePicker,
                    workTypePicker,
                    resourceMachinePicker,
                    start,
                    cancel
                }
            };
            layout.VerticalOptions = LayoutOptions.Center;
            if (Device.RuntimePlatform.Equals("iOS"))
            {
                // move layout under the status bar
                layout.Padding = new Thickness(0, 20, 0, 0);
            }
            Content = layout;
        }
        public JobRecLineUpdateForm(JobRecLine jobRecLine)
        {
            recLine = new JobRecLine();
            //taskGlobal = task;
            recLineGlobal = jobRecLine;
            workType      = jobRecLine.Work_Type;

            //descriptionEntry = new Entry { Text = recLineGlobal.Description };
            //amount = new Entry { Text = recLineGlobal.Quantity.ToString(CultureInfo.InvariantCulture), Keyboard = Keyboard.Numeric };

            workTypeButton = new Button {
                Text = "Arbejdstype (" + recLineGlobal.Work_Type + ")", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White
            };
            unitCodeButton = new Button {
                Text = "Enhedskode", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White
            };
            done = new Button {
                Text = "OK", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White
            };
            cancel = new Button {
                Text = "Cancel", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White, VerticalOptions = LayoutOptions.EndAndExpand
            };
            datePicker = new DatePicker()
            {
                Format = "D",
                Date   = recLineGlobal.Start_Time
            };
            workTypeButton.Clicked += WorkTypeButton_Clicked;
            done.Clicked           += Done_Clicked;
            cancel.Clicked         += Cancel_Clicked;
            layout = new StackLayout
            {
                Children =
                {
                    datePicker,
                    workTypeButton,
                    descriptionEntry,
                    amount,
                    done,
                    cancel
                }
            };
            if (Device.RuntimePlatform.Equals("iOS"))
            {
                // move layout under the status bar
                layout.Padding = new Thickness(0, 20, 0, 0);
            }
            Content = layout;
        }
Exemple #7
0
        private async void LogOutButton_Clicked(object sender, EventArgs e)
        {
            var temp = await db.GetJobRecLinesAsync();

            JobRecLine temp2 = new JobRecLine();

            try
            {
                temp2 = temp.Where(i => i.IsRunning).First();
            }
            catch
            {
                temp2 = null;
            }
            if (temp2 != null)
            {
                if (await DisplayAlert("OBS!", "Der er uafsluttede opgaver. Vil du stoppe opgaven inden du logger ud?", "Ja", "Nej"))
                {
                    temp2.IsRunning = false;
                    temp2.End_Time  = DateTime.UtcNow;
                    await db.UpdateJobRecLineAsync(temp2);
                }
            }
            gd.IsLoggedIn = false;
            List <Page> pl = new List <Page>();

            foreach (var item in gd.TabbedPage.Children)
            {
                pl.Add(item);
            }
            foreach (var item in pl)
            {
                gd.TabbedPage.Children.Remove(item);
            }
            ThreadManager manager = new ThreadManager();

            manager.Sync();
            gd.TabbedPage.Children.Add(gd.LoginPage);
        }
Exemple #8
0
        public async Task <JobRecLine> UpdateJobRecLine(JobRecLine task)
        {
            try
            {
                string newendPoint = null;
                newendPoint = endPoint + "update/";
                HttpClient client = ClientGateway.GetHttpClient;

                var data = JsonConvert.SerializeObject(task);

                var content = new StringContent(data, Encoding.UTF8, "application/json");

                var response = await client.PutAsync(newendPoint, content);

                return(JsonConvert.DeserializeObject <JobRecLine>(response.Content.ReadAsStringAsync().Result));
            }
            catch
            {
                JobRecLine jl = null;
                return(jl);
            }
        }
Exemple #9
0
        public JobRecLineDetail(JobRecLine c)
        {
            //if (c.Job_No != null)
            //{
            //    DetailModel jobNoModel = new DetailModel()
            //    {
            //        type = "Sagsnummer",
            //        value = c.Job_No.ToString()
            //    };
            //    list.Add(jobNoModel);
            //}
            //if (c.Journal_Template_Name != null)
            //{
            //    DetailModel journalTemplateNameModel = new DetailModel()
            //    {
            //        type = "Journal Template Name",
            //        value = c.Journal_Template_Name
            //    };
            //    list.Add(journalTemplateNameModel);
            //}
            if (c.Start_Time > new DateTime(1950, 1, 1))
            {
                DetailModel postingDateModel = new DetailModel()
                {
                    type  = "Registreret dato",
                    value = c.Start_Time.ToString("dd/MM/yyyy")
                };
                list.Add(postingDateModel);
            }
            //if (c.Type != null)
            //{
            //    DetailModel typeModel = new DetailModel()
            //    {
            //        type = "Type",
            //        value = c.Type
            //    };
            //    list.Add(typeModel);
            //}
            //if (c.No != null)
            //{
            //    DetailModel noModel = new DetailModel()
            //    {
            //        type = "Nummer",
            //        value = c.No.ToString()
            //    };
            //    list.Add(noModel);
            //}
            //if (c.Description != null)
            //{
            //    DetailModel descriptionModel = new DetailModel()
            //    {
            //        type = "Beskrivelse",
            //        value = c.Description
            //    };
            //    list.Add(descriptionModel);
            //}
            //DetailModel quantityModel = new DetailModel()
            //{
            //    type = "Antal",
            //    value = c.Quantity.ToString()
            //};
            //list.Add(quantityModel);
            //if (c.Unit_of_Measure_Code != null)
            //{
            //    DetailModel unitOfMeasureCodeModel = new DetailModel()
            //    {
            //        type = "Enhedskode",
            //        value = c.Unit_of_Measure_Code
            //    };
            //    list.Add(unitOfMeasureCodeModel);
            //}
            //if (c.Work_Type_Code != null)
            //{
            //    JobRecLineDetailModel workTypeCodeModel = new JobRecLineDetailModel()
            //    {
            //        type = "Arbejdstype",
            //        value = c.Work_Type_Code
            //    };
            //    list.Add(workTypeCodeModel);
            //}
            //if (c.Journal_Batch_Name != null)
            //{
            //    DetailModel journalBatchNameModel = new DetailModel()
            //    {
            //        type = "Batch Name",
            //        value = c.Journal_Batch_Name
            //    };
            //    list.Add(journalBatchNameModel);
            //}
            //if (c.Job_Task_No != null)
            //{
            //    DetailModel jobTaskNoModel = new DetailModel()
            //    {
            //        type = "Opgavenummer",
            //        value = c.Job_Task_No
            //    };
            //    list.Add(jobTaskNoModel);
            //}
            if (c.TaskNo != null)
            {
                DetailModel maintenanceTaskNoModel = new DetailModel()
                {
                    type  = "Vedligeholdsopgavenummer",
                    value = c.TaskNo
                };
                list.Add(maintenanceTaskNoModel);
            }
            if (c.Status != null)
            {
                DetailModel statusModel = new DetailModel()
                {
                    type  = "Status",
                    value = c.Status
                };
                list.Add(statusModel);
            }
            if (c.Work_Type != null)
            {
                DetailModel workTypeModel = new DetailModel()
                {
                    type  = "Arbejdstype",
                    value = c.Work_Type
                };
                list.Add(workTypeModel);
            }

            Application.Current.Properties["gridrowindex"] = 1;

            var temp = new DataTemplate(typeof(CustomTaskDetailCell));

            lv = new ListView()
            {
                HasUnevenRows = true,
                ItemTemplate  = temp
            };

            lv.ItemsSource = list;

            Button button = new Button()
            {
                Text = "Tilbage", BackgroundColor = Color.FromRgb(135, 206, 250), TextColor = Color.White
            };

            button.Clicked += Button_Clicked;
            StackLayout layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        =
                {
                    lv,
                    button
                }
            };

            if (Device.RuntimePlatform.Equals("iOS"))
            {
                // move layout under the status bar
                layout.Padding = new Thickness(0, 20, 0, 0);
            }
            Content = layout;
        }
Exemple #10
0
        protected async override void OnAppearing()
        {
            var temp = await db.GetJobRecLinesAsync();

            JobRecLine temp2 = new JobRecLine();

            MeetLeavePage timepage = new MeetLeavePage();

            timepage.GetData();

            taskList = null;
            int notdone = 0;

            while (taskList == null)
            {
                taskList = await App.Database.GetTasksAsync();
            }
            foreach (var item in taskList)
            {
                if (item.status == "Released" && item.responsible == gd.User.No && item.planned_Date <= gd.SearchDateTimeLast && item.planned_Date >= gd.SearchDateTime)
                {
                    notdone++;
                }
            }
            try
            {
                temp2 = temp.Where(i => i.IsRunning).First();
            }
            catch
            {
                temp2 = null;
            }
            if (temp2 != null)
            {
                MaintenanceTask task = await db.GetTaskAsync(temp2.TaskGUID);

                currentJobRecLabel.Text = "Der er startet en opgave klokken: " + temp2.Start_Time.AddHours(1).ToString("HH:mm") + " på opgave nr.: " + temp2.TaskNo + " - " + task.CustomerName + "\n\nDu arbejder på:  " + temp2.Work_Type_And_Machine;
            }
            else
            {
                currentJobRecLabel.Text = "Der er i øjeblikket ingen påbegyndte opgaver";
            }
            if (notdone == 1)
            {
                tasks.Text = "Du har " + notdone + " frigivet opgave.";
            }
            else
            {
                tasks.Text = "Du har " + notdone + " frigivne opgaver.";
            }
            if (gd.TimeRegisteredIn != null && gd.TimeRegisteredIn.Time.Date == DateTime.Today.Date)
            {
                timeRegisteredIn.Text = "Du er mødt ind: " + gd.TimeRegisteredIn.Time.AddHours(1).ToString("HH:mm");
            }
            if (gd.TimeRegisteredOut != null && gd.TimeRegisteredOut.Time.Date == DateTime.Today.Date)
            {
                timeRegisteredOut.Text = "Du er meldt ud: " + gd.TimeRegisteredOut.Time.AddHours(1).ToString("HH:mm");
            }
            if (gd.SearchDateTime > new DateTime(1950, 1, 1))
            {
                searchTimeFrom.Text = "Fra d.: " + gd.SearchDateTime.ToString("dd/MM/yyyy");
            }
            else
            {
                searchTimeFrom.Text = "Fra dato: Ingen dato sat";
            }
            if (gd.SearchDateTimeLast < new DateTime(2050, 1, 1))
            {
                searchTimeTo.Text = "Til d.: " + gd.SearchDateTimeLast.ToString("dd/MM/yyyy");
            }
            else
            {
                searchTimeTo.Text = "Til dato: Ingen dato sat";
            }
            if (gd.SearchUserName != null)
            {
                searchUser.Text = "Brugernavn: " + gd.SearchUserName;
            }
            else
            {
                searchUser.Text = "Brugernavn: Intet brugernavn";
            }
            SendJobRegLinesButton.Text = await SendButtonText();
        }
Exemple #11
0
 public Task <int> DeleteJobRecLineAsync(JobRecLine task)
 {
     return(database.DeleteAsync(task));
 }
Exemple #12
0
 public Task <int> UpdateJobRecLineAsync(JobRecLine task)
 {
     return(database.UpdateAsync(task));
 }
Exemple #13
0
 public Task <int> SaveJobRecLineAsync(JobRecLine task)
 {
     return(database.InsertAsync(task));
 }