コード例 #1
0
        public override object ConvertTo(object data, string format)
        {
            if (format == typeof(IDateRange).FullName)
            {
                var draggedProjectItem = (DataObjectHelper.GetData(data, typeof(Project), true) as List <object>).First() as Project;
                var task = new GanttTask {
                    Title = draggedProjectItem.Name, Start = draggedProjectItem.Start, End = draggedProjectItem.End
                };

                return(task);
            }
            else if (DataObjectHelper.GetDataPresent(data, typeof(ScheduleViewDragDropPayload), false))
            {
                ScheduleViewDragDropPayload payload = (ScheduleViewDragDropPayload)DataObjectHelper.GetData(data, typeof(ScheduleViewDragDropPayload), false);
                if (payload != null)
                {
                    return(payload.DraggedAppointments);
                }
            }
            else if (format == typeof(ScheduleViewDragDropPayload).FullName)
            {
                var customers = DataObjectHelper.GetData(data, typeof(Project), true) as IEnumerable;
                if (customers != null)
                {
                    return(customers.OfType <Project>().Select(c => new Appointment {
                        Subject = c.Name
                    }).ToList());
                }
            }

            return(null);
        }
コード例 #2
0
        public override IEnumerable <IOccurrence> ConvertDraggedData(object data)
        {
            var payload = DataObjectHelper.GetData(data, typeof(SchedulingDragOperationPayload), true) as SchedulingDragOperationPayload;

            if (payload != null)
            {
                return(payload.DraggedItems.OfType <IGanttTask>().Select(p => new Appointment {
                    Subject = p.Title, Start = p.Start, End = p.End
                }).ToList <IOccurrence>());
            }
            else
            {
                var project = ((List <object>)DataObjectHelper.GetData(data, typeof(Project), true)).FirstOrDefault() as Project;
                if (project != null)
                {
                    return(new List <IOccurrence> {
                        new Appointment {
                            Subject = project.Name, Start = project.Start, End = project.End
                        }
                    });
                }
            }

            return(base.ConvertDraggedData(data));
        }
コード例 #3
0
        public override object ConvertTo(object data)
        {
            var draggedProjectItem = (DataObjectHelper.GetData(data, typeof(Project), true) as List <object>).First() as Project;
            var task = new GanttTask {
                Title = draggedProjectItem.Name, Start = draggedProjectItem.Start, End = draggedProjectItem.End
            };

            return(task);
        }
        // Check read authorization on all the entities of a dataset. usefull when a get, getcollection or save action is configured with includes, to make sure related objects can be read for the given user claims.
        // dataset : the dataset to check
        // entitiesToIgnore : for these entities, the check should be skipped
        // mode : define if an entity not authorized should be removed from the dataset or an exception thrown
        public PermissionLevel CheckReadAuthorizationsOnDataSet(IObjectsDataSet dataset, UserClaims claims, IEnumerable <IDataObject> entitiesToIgnore, DataSetAuthorizationCheckMode mode, Parameters parameters, out string message)
        {
            message = null;
            SecurityPredicate predicate = null;

            // Work on a clone of the dataset so as not to mess with the original (causes save problems otherwise, e.g. if main entity !IsDirty)
            dataset = dataset.Clone();

            foreach (var entity in dataset.GetAllObjects())
            {
                var permissionLevel = CanRead(entity, claims, out message, out predicate);

                if (permissionLevel != PermissionLevel.Authorized)
                {
                    if (mode == DataSetAuthorizationCheckMode.RemoveFromDataSet)
                    {
                        dataset.RemoveObject(entity);
                        continue;
                    }
                    else
                    {
                        string explanation = Explain(EntityAccessEnum.READ, GetEntityAuthorizations(entity).EntityDisplayName);
                        message = FormatAccessDeniedMessage(explanation, predicate);
                        return(PermissionLevel.Denied);
                    }
                }

                if (predicate != null)
                {
                    // If the security filter needs related data, load it first:
                    if (!String.IsNullOrEmpty(predicate.Includes))
                    {
                        DataObjectHelper.RecurseLoadIncludes(entity, parameters, predicate.Includes, skipSecurity: true);
                    }

                    if (!DoesPredicateAccept(entity, predicate.Filter, predicate.Includes, EntityAccessEnum.READ))
                    {
                        if (mode == DataSetAuthorizationCheckMode.RemoveFromDataSet)
                        {
                            dataset.RemoveObject(entity);
                            continue;
                        }
                        else
                        {
                            string explanation = Explain(EntityAccessEnum.READ, GetEntityAuthorizations(entity).EntityDisplayName);
                            message = FormatAccessDeniedMessage(explanation, predicate);
                            return(PermissionLevel.Denied);
                        }
                    }
                }
            }

            return(PermissionLevel.Authorized);
        }
コード例 #5
0
	public override object ConvertTo(object data, string format)
	{

		var payload = DataObjectHelper.GetData(data, typeof(ScheduleViewDragDropPayload), false) as ScheduleViewDragDropPayload;
		if (payload != null)
		{
			var customers = payload.DraggedAppointments;
			return customers.OfType<Appointment>().Select(a => new Customer { Name = a.Subject });
		}		
		return null;
	}
コード例 #6
0
        public override object ConvertTo(object data, string format)
        {
            if (format == typeof(string).FullName && DataObjectHelper.GetDataPresent(data, "DragData", false))
            {
                var customer       = DataObjectHelper.GetData(data, "DragData", false) as Customer;
                var fullInfoString = "Name: " + customer.FirstName + " " + customer.LastName + ", Age: " + customer.Age;
                return(fullInfoString);
            }

            return(null);
        }
コード例 #7
0
 public override object ConvertTo(object data, string format)
 {
     if (format == typeof(ScheduleViewDragDropPayload).FullName && DataObjectHelper.GetDataPresent(data, typeof(Appointment), false))
     {
         var appointments = (IEnumerable)DataObjectHelper.GetData(data, typeof(Appointment), false);
         if (appointments != null)
         {
             return(new ScheduleViewDragDropPayload(null, appointments.OfType <IOccurrence>().ToList()));
         }
     }
     return(null);
 }
        public bool IsAuthorized(
            IDataObject entity,
            SecurityPredicate predicate,
            EntityAccessEnum action,
            ref string message,
            Parameters parameters = null)
        {
            if (parameters == null)
            {
                // connect to existing transaction by using the existing parameters
                var transaction = ApplicationSettings.Resolve <ITransactionProvider>().GetTransaction(parameters) as DatabaseDataProviderTransaction;
                parameters = transaction.Parameters;
                // this following line is probably no necessary. just for safety
                parameters = parameters ?? new Parameters();
            }

            var entityAuthorizations = GetEntityAuthorizations(entity);

            // If the security filter needs related data, load related data first:
            if (!String.IsNullOrEmpty(predicate.Includes))
            {
                DataObjectHelper.RecurseLoadIncludes(entity, parameters, predicate.Includes, skipSecurity: true);
            }

            // First check the submitted data : is submitted data authorized?
            if (predicate.IsEvaluateDataset)
            {
                if (!DoesPredicateAccept(entity, predicate.DatasetFilter, predicate.Includes, action))
                {
                    string explanation = Explain(action, entityAuthorizations.EntityDisplayName);
                    message = FormatAccessDeniedMessage(explanation, predicate);
                    return(false);
                }
            }

            // Then check existing data in database
            if (predicate.IsEvaluateDatabase && !entity.IsNew)
            {
                // Important: We fetch a fresh copy (including the includes) to eliminate possibility of hacker messing with the dataset
                dynamic provider       = ApplicationSettings.Container.Resolve <IEntityDataProvider>().GetDataProviderForEntity(entity);
                var     existingEntity = provider.Get(entity, null, includes: String.IsNullOrEmpty(predicate.Includes) ? null : predicate.Includes.Split(',').ToList(), parameters: parameters, skipSecurity: true);

                if (!DoesPredicateAccept(existingEntity, predicate.DatasetFilter, predicate.Includes, action))
                {
                    string explanation = Explain(action, entityAuthorizations.EntityDisplayName);
                    message = FormatAccessDeniedMessage(explanation, predicate);
                    return(false);
                }
            }

            return(true);
        }
コード例 #9
0
        public override object ConvertTo(object data, string format)
        {
            var payload = DataObjectHelper.GetData(data, typeof(ScheduleViewDragDropPayload), false) as ScheduleViewDragDropPayload;

            if (payload != null)
            {
                var cdm = payload.DraggedAppointments;
                return(cdm.OfType <ScheduleAppointment>().Select(a => new ClassDisplayModel {
                    Name = a.Subject, Id = a.ClassId
                }));
            }
            return(null);
        }
コード例 #10
0
        public override IEnumerable <IOccurrence> ConvertDraggedData(object data)
        {
            var payload = DataObjectHelper.GetData(data, typeof(SchedulingDragOperationPayload), true) as SchedulingDragOperationPayload;

            if (payload != null)
            {
                return(payload.DraggedItems.OfType <IGanttTask>().Select(p => new Appointment {
                    Subject = p.Title, Start = p.Start, End = p.End
                }).ToList <IOccurrence>());
            }

            return(base.ConvertDraggedData(data));
        }
コード例 #11
0
        public override IEnumerable <IOccurrence> ConvertDraggedData(object data)
        {
            if (DataObjectHelper.GetDataPresent(data, typeof(Appointment), false))
            {
                var appointments = DataObjectHelper.GetData(data, typeof(Appointment), true) as IEnumerable;
                if (appointments != null)
                {
                    return(appointments.OfType <IOccurrence>());
                }
            }

            return(base.ConvertDraggedData(data));
        }
コード例 #12
0
        public void Execute(object parameter)
        {
            try
            {
                DataObject obj = DataObjectHelper.GetPrescribedObject(_type, _id);
                if (null != obj)
                {
                    INavigationItem item = null;
                    if (App.Current.MainWindow.NavigationTree.FindItem(_navigateLink, out item))
                    {
                        if ((item as PageItem).Page != App.Current.MainWindow.CurrentPage)
                        {
                            App.Current.MainWindow.Navigate(_navigateLink);
                        }

                        Page pageBase = App.Current.MainWindow.CurrentPage;

                        ISupportDataObjectEditing objectEditing = _GetDataObjectEditing(obj, pageBase);
                        ISupportSelection         selection     = _GetSelection(obj, pageBase);

                        bool isEditingInProgress = false;
                        if (null != objectEditing)
                        {
                            isEditingInProgress = objectEditing.IsEditingInProgress;
                        }

                        if (null != selection)
                        {
                            // if any object is editing - try to save changed
                            if (isEditingInProgress)
                            {
                                isEditingInProgress = !selection.SaveEditedItem();
                            }

                            // if grid isn't editing or changes saved successfully - select items
                            if (!isEditingInProgress)
                            {
                                selection.Select(new Collection <DataObject>()
                                {
                                    obj
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
コード例 #13
0
        public override IEnumerable <IOccurrence> ConvertDraggedData(object data)
        {
            if (DataObjectHelper.GetDataPresent(data, typeof(ClassDisplayModel), false))
            {
                var cdms = DataObjectHelper.GetData(data, typeof(ClassDisplayModel), false) as IEnumerable;
                if (cdms != null)
                {
                    return(cdms.OfType <ClassDisplayModel>().Select(c => new ScheduleAppointment {
                        Subject = c.Name, ClassId = c.Id
                    }));;
                }
            }

            return(base.ConvertDraggedData(data));
        }
コード例 #14
0
	public override IEnumerable<IOccurrence> ConvertDraggedData(object data)
	{

		if (DataObjectHelper.GetDataPresent(data, typeof(Customer), false))
		{
			var customers = DataObjectHelper.GetData(data, typeof(Customer), true) as IEnumerable;
			if (customers != null)
			{
				var newApp = customers.OfType<Customer>().Select(c => new Appointment { Subject = c.Name });
				return newApp;
			}
		}

		return base.ConvertDraggedData(data);
	}
コード例 #15
0
        public override object ConvertTo(object data, string format)
        {
            if (format == typeof(Project).FullName)
            {
                var project = DataObjectHelper.GetData(data, typeof(SchedulingDragOperationPayload), true) as SchedulingDragOperationPayload;
                if (project != null)
                {
                    return(project.DraggedItems.OfType <IGanttTask>().Select(p => new Project {
                        Name = p.Title, Start = p.Start, End = p.End
                    }));
                }
            }

            return(null);
        }
コード例 #16
0
        public override object ConvertTo(object data, string format)
        {
            var result           = new List <Project>();
            var draggedCustomers = ((List <object>)DataObjectHelper.GetData(data, typeof(Customer), false)).OfType <Customer>();

            foreach (var customer in draggedCustomers)
            {
                result.Add(new Project()
                {
                    Name   = customer.Project,
                    Id     = customer.Id,
                    Person = customer.Name
                });
            }

            return(result);
        }
コード例 #17
0
        public override object ConvertTo(object data, string format)
        {
            var result          = new List <Customer>();
            var draggedProjects = ((List <object>)DataObjectHelper.GetData(data, typeof(Project), false)).OfType <Project>();

            foreach (var project in draggedProjects)
            {
                result.Add(new Customer()
                {
                    Name    = project.Person,
                    Id      = project.Id,
                    Project = project.Name
                });
            }

            return(result);
        }
コード例 #18
0
 public ClientConnection(Socket socket)
 {
     this.socket           = socket;
     this.dataObjectHelper = new DataObjectHelper();
 }
コード例 #19
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        public bool CanExecute(object parameter)
        {
            DataObject obj = DataObjectHelper.GetPrescribedObject(_type, _id);

            return(!string.IsNullOrEmpty(_navigateLink) && (null != obj) && !App.Current.UIManager.IsLocked);
        }