Example #1
0
        async void BtnSubmit_ClickAsync(object sender, EventArgs e)
        {
            if (SpnTest.GetSelectedItem() != null)
            {
                inf_userinfo fabUser = (inf_userinfo)SpnTest.GetSelectedItem().Item;


                string url = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/assignfabricator";

                inf_assignment objAssignment = new inf_assignment();
                objAssignment.iAssignmentId   = _spl.iAssignmentId;
                objAssignment.cFabricatorUser = fabUser.cUsername;

                int assignRes = await npcc_services.inf_CallWebServiceAsync <int, inf_assignment>(inf_method.Post, url, objAssignment);

                if (assignRes == 1)
                {
                    DBRepository dBRepository = new DBRepository();
                    _spl.cStatus = "F";
                    dBRepository.UpdateSpool(_spl);

                    common_functions.DisplayToast("Task assigned successfully!!", Context);
                }
                else if (assignRes == 2)
                {
                    DBRepository dBRepository = new DBRepository();
                    _spl.cStatus = "F";
                    dBRepository.UpdateSpool(_spl);

                    _ins._lsObjs.RemoveAt(_position);
                    _ins.NotifyItemRemoved(_position);
                    _ins.NotifyItemRangeChanged(_position, _ins._lsObjs.Count);

                    common_functions.DisplayToast("Task assigned successfully!!", Context);
                }
                else
                {
                    common_functions.DisplayToast("Error occurred while assigning the task, contact system admin!!", Context);
                }


                Assign _exportFragment = (Assign)FragmentManager.FindFragmentByTag("Assign");
                if (_exportFragment != null)
                {
                    _exportFragment.Dismiss();
                }
            }
            else
            {
                common_functions.DisplayToast("You have to select a user!!", Context);
            }
        }
        void BtnAssign_Click(object sender, EventArgs e)
        {
            DBRepository dBRepository = new DBRepository();
            UserInfo     user         = dBRepository.GetUserInfo();

            switch (user.group)
            {
            case "Foreman":
                _spl = _lsObjs[(int)((Button)sender).Tag];
                var dialog = new Assign(_spl, _ins, (int)((Button)sender).Tag);
                dialog.Show(_currentContext.FragmentManager, "Assign");

                break;

            case "Fabricator":
                _spl = _lsObjs[(int)((Button)sender).Tag];
                //set alert for executing the task
                Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(_currentContext);
                alert.SetTitle("Confirm Complete");
                alert.SetMessage("Are you sure you want to complete this task.");
                alert.SetPositiveButton("Yes", (senderAlert, args) => {
                    string url = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/FabricatorComplete";

                    inf_assignment objAssignment = new inf_assignment();
                    objAssignment.iAssignmentId  = _spl.iAssignmentId;

                    Task.Run(async() => {
                        assignRes = await npcc_services.inf_CallWebServiceAsync <int, inf_assignment>(inf_method.Post, url, objAssignment);
                    }).ContinueWith(fn => {
                        if (assignRes == 1)
                        {
                            _spl.cStatus = "W";
                            dBRepository.UpdateSpool(_spl);
                            _currentContext.RunOnUiThread(() =>
                            {
                                _ins._lsObjs.RemoveAt((int)((Button)sender).Tag);
                                _ins.NotifyItemRemoved((int)((Button)sender).Tag);
                                _ins.NotifyItemRangeChanged((int)((Button)sender).Tag, _ins._lsObjs.Count);
                            });
                            common_functions.DisplayToast("Task assigned successfully!!", _currentContext);
                        }
                        else
                        {
                            common_functions.DisplayToast("Error occurred while assigning the task, contact system admin!!", _currentContext);
                        }
                    });
                });

                alert.SetNegativeButton("No", (senderAlert, args) => {
                });

                Dialog d = alert.Create();
                d.Show();

                break;

            case "Welder":
                _spl = _lsObjs[(int)((Button)sender).Tag];
                FillWeldLog mFillWeldLog = new FillWeldLog(_spl);
                common_functions.npcc_show_fragment(_currentContext, mFragmentContainer, mFillWeldLog, _fragment);
                break;
            }
        }