Exemplo n.º 1
0
 private void BlockUnauthorizedViews()
 {
     btnAdd.Enabled = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.addSchedule);
     dgvSchedules.Columns["Edit"].Visible   = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editSchedule);
     dgvSchedules.Columns["Delete"].Visible = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.delSchedule);
 }
 private void BlockUnauthorizedViews()
 {
     btnDelete.Enabled = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editCustomer);
     btnEdit.Enabled   = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editCustomer);
     btnAdd.Enabled    = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editCustomer);
 }
Exemplo n.º 3
0
        private static string ProcessOperation(string input)
        {
            try
            {
                var operationRequest = OperationRequest.ParseFromString(input);
                if (string.IsNullOrEmpty(operationRequest.OperationName))
                {
                    throw new ArgumentException("OperationName not set.");
                }

                if (string.IsNullOrEmpty(operationRequest.CompanyName))
                {
                    throw new ArgumentException("CompanyName not set.");
                }

                if (string.IsNullOrEmpty(operationRequest.SerialNo))
                {
                    throw new ArgumentException("SerialNo not set.");
                }

                if (string.IsNullOrEmpty(operationRequest.Script))
                {
                    throw new ArgumentException("Script not set.");
                }

                LogHelper.WriteLog(string.Format(Properties.Resources.ExecutingOperation, operationRequest.OperationName));

                if (!PermissionHelper.CheckPermission(operationRequest))
                {
                    LogHelper.WriteLog(string.Format(Properties.Resources.ExecutionDenied, operationRequest.OperationName));
                    return((new ErrorResponse("Execution denied.")).ToString());
                }

                var tempPath = Path.Combine(Path.GetTempPath(), "ACC");
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                tempPath = Path.Combine(tempPath, Guid.NewGuid().ToString());
                Directory.CreateDirectory(tempPath);
                operationRequest.SaveAllFiles(tempPath);

                var lua = new Lua();
                lua.State.Encoding = Encoding.UTF8;
                lua.LoadCLRPackage();

                foreach (var parameter in operationRequest.Parameters ?? Enumerable.Empty <Parameter>())
                {
                    lua[parameter.Name] = parameter.Value;
                }

                lua["WorkspaceFolder"] = tempPath;

                var operationResponse = new OperationResponse();
                lua.RegisterFunction("AddFile", operationResponse, operationResponse.GetType().GetMethod("AddFile"));
                lua.RegisterFunction("AddVariable", operationResponse, operationResponse.GetType().GetMethod("AddVariable"));

                lua.DoString(operationRequest.Script);

                LogHelper.WriteLog(string.Format(Properties.Resources.OperationExecuted, operationRequest.OperationName));
                return(operationResponse.ToString());
            }
            catch (Exception e)
            {
                LogHelper.WriteLog(string.Format(Properties.Resources.ErrorOccured, e.Message));
                var errorResponse = new ErrorResponse(e.Message);
                return(errorResponse.ToString());
            }
        }
Exemplo n.º 4
0
 private void BlockUnauthorizedViews()
 {
     btnAdd.Enabled  = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.addSchedule);
     btnEdit.Enabled = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editSchedule);
     btnDel.Enabled  = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.delSchedule);
 }
Exemplo n.º 5
0
 private void BlockUnauthorizedViews()
 {
     btnAdd.Enabled = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.addCustomer);
     dgvCustomers.Columns["Edit"].Visible   = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editCustomer);
     dgvCustomers.Columns["Delete"].Visible = PermissionHelper.CheckPermission(Session.currentUser, PermissionHelper.editCustomer);
 }
Exemplo n.º 6
0
 protected virtual bool AuthorizeCore(HttpContextBase httpContext)
 {
     return(PermissionHelper.CheckPermission(_roleId, _namespace, _controllerName, _actionName));
 }
Exemplo n.º 7
0
        public async void Init()
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                var status = await PermissionHelper.CheckPermission(Plugin.Permissions.Abstractions.Permission.Location, "Truy cập vị trí", "Sundihome cần quyền truy cập ví trị, để lấy vị trí và tìm bất động sản xung quanh cho bạn.");

                if (status != Plugin.Permissions.Abstractions.PermissionStatus.Granted)
                {
                    await Navigation.PopAsync();

                    return;
                }
            }

            await viewModel.LoadData();

            var first = viewModel.Data.Where(x => x.Lat.HasValue && x.Long.HasValue).FirstOrDefault();

            if (first == null)
            {
                await DisplayAlert("", "Không tìm thấy bất động sản nào.", Language.dong);

                await Navigation.PopAsync();

                return;
            }

            MapSpan mapSpan = MapSpan.FromCenterAndRadius(
                new Position(first.Lat.Value, first.Long.Value), Distance.FromMiles(3));

            map = new CustomMap()
            {
                IsShowingUser     = true,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                MoveToLastRegionOnLayoutChange = true,
                CustomPins = new List <CustomPin>(),
            };

            var webClient = new WebClient();

            foreach (var item in viewModel.Data.Where(x => x.Lat.HasValue && x.PriceFormatText != null))
            {
                var pin = new CustomPin
                {
                    Url       = $"{Configuration.ApiConfig.IP}api/post/priceimage?text={item.PriceFormatText}",
                    Type      = PinType.Place,
                    Position  = new Position(item.Lat.Value, item.Long.Value),
                    Label     = item.Title,
                    Address   = item.Address,
                    PriceText = item.PriceFromText ?? item.PriceFormatText,
                    PostId    = item.Id
                };

                pin.PinBytes = webClient.DownloadData(pin.Url);
                pin.Clicked += async(object o, EventArgs e) =>
                {
                    Pin pinClicked = (Pin)o;
                    await Navigation.PushAsync(new PostDetailPage(item.Id));
                };

                map.Pins.Add(pin);
                map.CustomPins.Add(pin);
            }
            webClient.Dispose();
            map.MoveToRegion(mapSpan);
            grid.Children.Insert(0, map);



            loadingPopup.IsVisible = false;
        }