/**
         * Wraps autofill data in a LoginCredential  Dataset object which can then be sent back to the
         * client View.
         */
        public static Dataset NewDataset(
            Context context,
            AutofillFieldMetadataCollection autofillFields,
            FilledAutofillFieldCollection filledAutofillFieldCollection,
            bool datasetAuth)
        {
            var datasetName = filledAutofillFieldCollection.GetDatasetName();

            if (datasetName != null)
            {
                Dataset.Builder datasetBuilder;
                if (datasetAuth)
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName, Resource.Drawable.ic_lock_black_24dp));
                    var sender = AuthActivity.GetAuthIntentSenderForDataset(context, datasetName);
                    datasetBuilder.SetAuthentication(sender);
                }
                else
                {
                    datasetBuilder = new Dataset.Builder
                                         (NewRemoteViews(context.PackageName, datasetName, Resource.Drawable.ic_person_black_24dp));
                }

                var setValueAtLeastOnce = filledAutofillFieldCollection.ApplyToFields(autofillFields, datasetBuilder);
                if (setValueAtLeastOnce)
                {
                    return(datasetBuilder.Build());
                }
            }

            return(null);
        }
Exemplo n.º 2
0
 public void DeleteActivity(AuthActivity activity, int userId)
 {
     activity.IsDeleted   = true;
     activity.UpdatedBy   = userId;
     activity.DateUpdated = DateTime.UtcNow;
     _currentDbContext.Entry(activity).State = EntityState.Modified;
     _currentDbContext.SaveChanges();
 }
Exemplo n.º 3
0
        public int SaveActivity(AuthActivity activity, int userId, int tenantId)
        {
            activity.DateCreated = DateTime.UtcNow;
            activity.DateUpdated = DateTime.UtcNow;
            activity.CreatedBy   = userId;
            activity.UpdatedBy   = userId;
            activity.TenantId    = tenantId;
            _currentDbContext.Entry(activity).State = EntityState.Added;
            _currentDbContext.SaveChanges();
            int res = activity.ActivityId;

            return(res);
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ActivityName,ActivityController,ActivityAction,IsActive,ExcludePermission,RightNav")] AuthActivity authactivity)
        {
            if (ModelState.IsValid)
            {
                // get properties of tenant
                caTenant tenant = caCurrent.CurrentTenant();

                // get properties of user
                caUser user = caCurrent.CurrentUser();

                _activityServices.SaveActivity(authactivity, user.UserId, tenant.TenantId);
                return(RedirectToAction("Index"));
            }

            return(View(authactivity));
        }
        /**
         * Wraps autofill data in a Response object (essentially a series of Datasets) which can then
         * be sent back to the client View.
         */
        public FillResponse BuildResponse(Dictionary <string, FieldTypeWithHeuristics> fieldTypesByAutofillHint,
                                          List <DatasetWithFilledAutofillFields> datasets, bool datasetAuth)
        {
            FillResponse.Builder responseBuilder = new FillResponse.Builder();
            if (datasets != null)
            {
                foreach (var datasetWithFilledAutofillFields in datasets)
                {
                    if (datasetWithFilledAutofillFields != null)
                    {
                        Dataset dataset;
                        String  datasetName = datasetWithFilledAutofillFields.autofillDataset.GetDatasetName();
                        if (datasetAuth)
                        {
                            IntentSender intentSender = AuthActivity.GetAuthIntentSenderForDataset(
                                mContext, datasetName);
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews, intentSender);
                        }
                        else
                        {
                            RemoteViews remoteViews = RemoteViewsHelper.ViewsWithNoAuth(
                                mPackageName, datasetName);
                            dataset = mDatasetAdapter.BuildDataset(fieldTypesByAutofillHint,
                                                                   datasetWithFilledAutofillFields, remoteViews);
                        }
                        if (dataset != null)
                        {
                            responseBuilder.AddDataset(dataset);
                        }
                    }
                }
            }
            int saveType = 0;

            AutofillId[] autofillIds = mClientViewMetadata.mFocusedIds;
            if (autofillIds != null && autofillIds.Length > 0)
            {
                SaveInfo saveInfo = new SaveInfo.Builder((SaveDataType)saveType, autofillIds).Build();
                responseBuilder.SetSaveInfo(saveInfo);
                return(responseBuilder.Build());
            }
            return(null);
        }
Exemplo n.º 6
0
        public async Task <(bool IsSucessful, string Error)> Login(Urls.OIDCUrls urls)
        {
            var configuration = new AuthorizationServiceConfiguration(
                ToUrl(urls.Authorization),
                ToUrl(urls.Token)
                );

            var authRequestBuilder = new AuthorizationRequest.Builder(
                configuration,
                AuthConstants.ClientId,
                ResponseTypeValues.Code,
                global::Android.Net.Uri.Parse(AuthConstants.RedirectUri)
                ).SetScope(AuthConstants.Scope);

            if (AuthConstants.Scope.Contains("offline_access"))
            {
                authRequestBuilder = authRequestBuilder.SetPrompt("consent");
            }
            var authRequest = authRequestBuilder.Build();

            MicroLogger.LogDebug("Making auth request to " + configuration.AuthorizationEndpoint);
#pragma warning disable IDE0059 // Unnecessary assignment of a value
            var intent = authService.GetAuthorizationRequestIntent(authRequest);
#pragma warning restore IDE0059 // Unnecessary assignment of a value

            taskCompletitionSource = new TaskCompletionSource <AuthState>();

            authService.PerformAuthorizationRequest(
                authRequest,
                AuthActivity.CreatePostAuthorizationIntent(
                    _context,
                    authRequest),
                authService.CreateCustomTabsIntentBuilder().Build()
                );

            var state = await taskCompletitionSource.Task;
            if (state.AuthorizationException != null)
            {
                return(false, state.AuthorizationException.ErrorDescription);
            }
            else
            {
                return(true, null);
            }
        }
Exemplo n.º 7
0
        // GET: /Activity/Details/5
        public ActionResult Details(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AuthActivity authactivity = _activityServices.GetActivityById((int)id);

            if (authactivity == null)
            {
                return(HttpNotFound());
            }
            return(View(authactivity));
        }
Exemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            AuthActivity authactivity = _activityServices.GetActivityById((int)id);

            // get properties of tenant
            caTenant tenant = caCurrent.CurrentTenant();

            // get properties of user
            caUser user = caCurrent.CurrentUser();

            _activityServices.DeleteActivity(authactivity, user.UserId);

            return(RedirectToAction("Index"));
        }
Exemplo n.º 9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view          = inflater.Inflate(Resource.Layout.LayoutLast, container, false);
            var btn_calculate = view.FindViewById <Button>(Resource.Id.btn_cost);

            Button btn_auth1 = view.FindViewById <Button>(Resource.Id.btn_auth2);

            btn_auth1.Click += (s, e) =>
            {
                try
                {
                    Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    AuthActivity content3 = new AuthActivity();
                    transaction1.Replace(Resource.Id.framelayout, content3).AddToBackStack(null);
                    transaction1.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Activity, "" + ex.Message, ToastLength.Long).Show();
                }
            };

            // Переход к форме регистрации.
            btn_calculate.Click += (s, e) =>
            {
                //set alert for executing the task
                try
                {
                    Android.App.FragmentTransaction transaction2 = this.FragmentManager.BeginTransaction();
                    AddOrderActivity content = new AddOrderActivity();
                    transaction2.Replace(Resource.Id.framelayout, content).AddToBackStack(null);
                    transaction2.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Activity, "" + ex.Message, ToastLength.Long).Show();
                }
            };
            return(view);
            // Переход к форме авторизация
        }
Exemplo n.º 10
0
        public ActionResult Edit(AuthActivity authactivity)
        {
            if (ModelState.IsValid)
            {
                caTenant tenant = caCurrent.CurrentTenant();
                caUser   user   = caCurrent.CurrentUser();

                bool status = _activityServices.UpdateActivity(authactivity, user.UserId, tenant.TenantId);

                if (status == false)
                {
                    ViewBag.Error = "Problem updating record. Please contact support";
                    return(View(authactivity));
                }


                return(RedirectToAction("Index"));
            }

            return(View(authactivity));
        }
Exemplo n.º 11
0
        public Boolean PermCheck(string controller, string action, int UserId, int WareHId)
        {
            Boolean Status = false;

            //get the handheld termianl activities
            AuthActivity Activity = _currentDbContext.AuthActivities
                                    .Where(e => e.ActivityController == controller && e.ActivityAction == action &&
                                           e.IsActive == true && e.IsDeleted != true)?.FirstOrDefault();

            if (Activity != null)
            {
                AuthPermission Permission = _currentDbContext.AuthPermissions.Where(e => e.ActivityId == Activity.ActivityId && e.UserId == UserId && e.WarehouseId == WareHId &&
                                                                                    e.IsActive == true && e.IsDeleted != true)?.FirstOrDefault();

                if (Permission != null)
                {
                    Status = true;
                }
            }

            return(Status);
        }
Exemplo n.º 12
0
        public bool UpdateActivity(AuthActivity activity, int userId, int tenantId)
        {
            var act = _currentDbContext.AuthActivities.FirstOrDefault(m => m.ActivityId == activity.ActivityId);

            if (act != null)
            {
                act.ActivityName                   = activity.ActivityName;
                act.ActivityAction                 = activity.ActivityAction;
                act.ActivityController             = activity.ActivityController;
                act.IsActive                       = activity.IsActive;
                act.RightNav                       = activity.RightNav;
                act.DateUpdated                    = DateTime.UtcNow;
                act.UpdatedBy                      = userId;
                _currentDbContext.Entry(act).State = EntityState.Modified;
                _currentDbContext.SaveChanges();
                return(true);
            }

            else
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.activity_order_price, container, false);

            preloader           = view.FindViewById <ProgressBar>(Resource.Id.loader);
            txt_From            = view.FindViewById <TextView>(Resource.Id.OrderPriceTextFrom);
            txt_To              = view.FindViewById <TextView>(Resource.Id.OrderPriceTextTo);
            txt_Distance        = view.FindViewById <TextView>(Resource.Id.OrderPriceTextDistance);
            txt_Insurance_Price = view.FindViewById <TextView>(Resource.Id.OrderPriceTextInsurancePrice);
            txt_Shipping_Cost   = view.FindViewById <TextView>(Resource.Id.OrderPriceTextShippingCost);
            btn_add_order       = view.FindViewById <Button>(Resource.Id.OrderPriceBtnAddOrder);
            btn_add_order_again = view.FindViewById <Button>(Resource.Id.OrderPriceBtnAddOrderAgain);

            txt_Shipping_Cost.Text   = StaticOrder.Amount;
            txt_Insurance_Price.Text = StaticOrder.Insurance_amount + " ₽";
            txt_Distance.Text        = StaticOrder.Distance + " км";
            txt_To.Text   = StaticOrder.Destination_address;
            txt_From.Text = StaticOrder.Inception_address;


            btn_add_order_again.Click += async delegate
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(Activity);
                alert.SetTitle("Внимание!");
                alert.SetMessage("Вы действительно хотите сделать перерасчёт стоимости ?");
                alert.SetPositiveButton("Да", (senderAlert, args) =>
                {
                    FragmentTransaction transaction = FragmentManager.BeginTransaction();
                    AddOrderActivity content        = new AddOrderActivity();
                    transaction.Replace(Resource.Id.framelayout, content).AddToBackStack(null).Commit(); CrossSettings.Current.AddOrUpdateValue("OrderInStageOfBid", "false");
                    base.OnDestroy();
                });
                alert.SetNegativeButton("Отмена", (senderAlert, args) => {});

                Dialog dialog = alert.Create();
                dialog.Show();
            };

            btn_add_order.Click += async delegate
            {
                preloader.Visibility = Android.Views.ViewStates.Visible;

                if (StaticUser.PresenceOnPage != true)
                {
                    Android.App.FragmentTransaction transaction2 = this.FragmentManager.BeginTransaction();
                    AlertDialog.Builder             alert        = new AlertDialog.Builder(Activity);
                    alert.SetTitle("Внимание!");
                    alert.SetMessage("Для оформления заказа необходимо войти или зарегистрироваться.");
                    alert.SetPositiveButton("Регистрация", (senderAlert, args) =>
                    {
                        alert.Dispose();
                        Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                        alert1.SetTitle("Внимание!");
                        alert1.SetMessage("Необходимо выбрать вид регистрации.");
                        alert1.SetPositiveButton("Для физ.лица", (senderAlert1, args1) =>
                        {
                            Activity_Registration_Individual_Person content4 = new Activity_Registration_Individual_Person();
                            transaction2.Replace(Resource.Id.framelayout, content4).AddToBackStack(null).Commit();
                        });
                        alert1.SetNegativeButton("Для юр.лица", (senderAlert1, args1) =>
                        {
                            Activity_Legal_Entity_Registration content3 = new Activity_Legal_Entity_Registration();
                            transaction2.Replace(Resource.Id.framelayout, content3).AddToBackStack(null).Commit();
                        });
                        Dialog dialog1 = alert1.Create();
                        dialog1.Show();
                    });
                    alert.SetNegativeButton("Вход", (senderAlert, args) =>
                    {
                        AuthActivity content3 = new AuthActivity();
                        transaction2.Replace(Resource.Id.framelayout, content3).AddToBackStack(null).Commit();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
                else
                {
                    StaticUser.NeedToCreateOrder = true;
                    Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    UserActivity content = new UserActivity();
                    transaction1.Replace(Resource.Id.framelayout, content);
                    transaction1.Commit();
                }
            };

            return(view);
        }