コード例 #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            _queryText = e.NavigationParameter as String;

            // Fetch the serach results from JobsDataSource
            var searchResults = await JobDataSource.SearchJobsBySearchTextAsync(_queryText);

            // Add the counts for various job status
            int countOnSite     = searchResults.Count(item => item.Status == "On Site");
            int countNotStarted = searchResults.Count(item => item.Status == "Not Started");
            int countCompleted  = searchResults.Count(item => item.Status == "Completed");

            // Add the filters based upon the job status
            var filterList = new List <Filter>();

            filterList.Add(new Filter("All", searchResults.Count, true));
            if (countOnSite > 0)
            {
                filterList.Add(new Filter("On Site", countOnSite, false));
            }
            if (countNotStarted > 0)
            {
                filterList.Add(new Filter("Not Started", countNotStarted, false));
            }
            if (countCompleted > 0)
            {
                filterList.Add(new Filter("Completed", countCompleted, false));
            }

            // Communicate results through the view model
            this.DefaultViewModel["QueryText"]   = " " + '\u201c' + _queryText + '\u201d';
            this.DefaultViewModel["Filters"]     = filterList;
            this.DefaultViewModel["ShowFilters"] = filterList.Count > 0;
            this.DefaultViewModel["Results"]     = searchResults;
        }
コード例 #2
0
 public static void Initialize(string urlPrefix)
 {
     //Initialize static members
     EquipmentDataSource = new EquipmentDataSource(urlPrefix);
     JobDataSource       = new JobDataSource();
     EquipmentSpecificationDataSource = new EquipmentSpecificationDataSource();
     isInitialized = true;
 }
コード例 #3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // Fetch the job object and assign the values to be bound to the various controls
            job = await JobDataSource.GetDetailsAsync(e.NavigationParameter.ToString());

            this.DefaultViewModel["JobHistory"]      = job.JobHistory;
            this.DefaultViewModel["JobSummaryItems"] = new ObservableCollection <Job>(new List <Job> {
                job
            });
            this.DefaultViewModel["JobStockItems"] = await EquipmentDataSource.GetListAsync_Dummy(job.EquipmentIds);
        }
コード例 #4
0
        /// <summary>
        /// This method creates a new notification for each job by iterating through a list of pending jobs and
        /// passes the notification to the TileNotificationManager.
        /// It then enables notification for the application.
        /// </summary>
        private async void CreateLiveTiles()
        {
            var pendingJobs = await JobDataSource.GetPendingJobsAsync();

            foreach (var job in pendingJobs)
            {
                // Create a tile notification.
                TileNotification tileNotification = new TileNotification(CreateWideTile(job));
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
            }
            TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
        }
コード例 #5
0
        private JobBatch ProcessJobBatch(SyncSide syncSide, DataSource dataSource, List <EntityBatch> entityBatches)
        {
            var jobDataSource = new JobDataSource(syncSide, dataSource);

            var jobBatch = new JobBatch(syncSide, jobDataSource);

            foreach (var entityBatch in entityBatches)
            {
                jobBatch.EntityBatches.Add(entityBatch);
            }

            dataSource.ProcessBatch(jobBatch);

            return(jobBatch);
        }
コード例 #6
0
        /// <summary>
        /// Invoked when a filter is selected using a RadioButton when not snapped.
        /// </summary>
        /// <param name="sender">The selected RadioButton instance.</param>
        /// <param name="e">Event data describing how the RadioButton was selected.</param>
        async void Filter_Checked(object sender, RoutedEventArgs e)
        {
            var filter = (sender as FrameworkElement).DataContext;

            // Mirror the change into the CollectionViewSource.
            // This is most likely not needed.
            if (filtersViewSource.View != null)
            {
                filtersViewSource.View.MoveCurrentTo(filter);
            }

            // Determine what filter was selected
            var selectedFilter = filter as Filter;

            if (selectedFilter != null)
            {
                // Mirror the results into the corresponding Filter object to allow the
                // RadioButton representation used when not snapped to reflect the change
                selectedFilter.Active = true;

                // Load the search results and filter them based on user-selected filter value
                _searchResults = await JobDataSource.SearchJobsBySearchTextAsync(_queryText);

                _searchResults = (selectedFilter.Name.Equals("All")) ? _searchResults :
                                 new List <Job>(_searchResults.Where(job => job.Status.Equals(selectedFilter.Name)).ToList());
                this.DefaultViewModel["Results"] = _searchResults;

                // Ensure results are found
                object      results;
                ICollection resultsCollection;
                if (this.DefaultViewModel.TryGetValue("Results", out results) &&
                    (resultsCollection = results as ICollection) != null &&
                    resultsCollection.Count != 0)
                {
                    VisualStateManager.GoToState(this, "ResultsFound", true);
                    return;
                }
            }

            // Display informational text when there are no search results.
            this.DefaultViewModel["ShowFilters"] = false;
            VisualStateManager.GoToState(this, "NoResultsFound", true);
        }
コード例 #7
0
        public TaskCommandStatus(int? exitStatus, string stdout, string stderr)
        {
            this.exitStatus = exitStatus;

            if (!stdout.IsNullOrEmpty())
            {
                this.dataSource = JobDataSource.stdout;
                this.data = stdout;
            }
            else if (!stderr.IsNullOrEmpty())
            {
                this.dataSource = JobDataSource.stderr;
                this.data = stderr;
            }
            else
            {
                this.dataSource = JobDataSource.stdout;
                this.data = String.Empty; // TODO empty or null?
            }
        }
コード例 #8
0
        public TaskCommandStatus(int?exitStatus, string stdout, string stderr)
        {
            this.exitStatus = exitStatus;

            if (!String.IsNullOrEmpty(stdout))
            {
                this.dataSource = JobDataSource.stdout;
                this.data       = stdout;
            }
            else if (!String.IsNullOrEmpty(stderr))
            {
                this.dataSource = JobDataSource.stderr;
                this.data       = stderr;
            }
            else
            {
                this.dataSource = JobDataSource.stdout;
                this.data       = String.Empty; // TODO empty or null?
            }
        }
コード例 #9
0
        public JobInstance(JobQueueRequest queueRequest, Guid jobInstanceGuid, Integration integration, Job jobToRun, DataSource sourceDataSource, DataSource targetDataSource, List <JobStepInstance> jobStepInstances,
                           DateTime scheduledStartTime, string invocationSource, JobInvocationSourceType invocationSourceType, List <JobFilter> filters = null)
        {
            if (integration == null)
            {
                throw new Exception("Integration can not be null.");
            }

            if (jobToRun == null)
            {
                throw new Exception("Job to run can not be null.");
            }

            if (sourceDataSource == null)
            {
                throw new Exception("Source-side data source can not be null.");
            }

            if (jobToRun.SourceDataSources.Where(d => d.Value.Id == sourceDataSource.Id).Count() == 0)
            {
                throw new Exception(string.Format("'{0}' ({1}) is not associated with job '{2}' ({3}) as a source-side data source.",
                                                  sourceDataSource.Name, sourceDataSource.Id, jobToRun.Name, jobToRun.Id));
            }

            if (targetDataSource == null)
            {
                throw new Exception("Target-side data source can not be null.");
            }

            if (jobToRun.TargetDataSource.Id != targetDataSource.Id)
            {
                throw new Exception(string.Format("'{0}' ({1}) is not associated with job '{2}' ({3}) as the target-side data source.",
                                                  targetDataSource.Name, targetDataSource.Id, jobToRun.Name, jobToRun.Id));
            }

            if (jobStepInstances == null || jobStepInstances.Count == 0)
            {
                throw new Exception(string.Format("At least one job step is required for queued job '{0}'.  The job will not be executed.", jobToRun.Name));
            }

            QueueRequest = queueRequest;

            if (jobInstanceGuid == Guid.Empty)
            {
                Id = Guid.NewGuid();
            }
            else
            {
                Id = jobInstanceGuid;
            }

            Integration = integration;

            Job = jobToRun;

            if (JobQueueManager.Configurator == null)
            {
                SourceDataSource = new JobDataSource(SyncSide.Source, sourceDataSource);
                TargetDataSource = new JobDataSource(SyncSide.Target, targetDataSource);

                SyncEngineLogger.WriteToLog(LogEntryType.Warning, integration, "Update history could not be set for source and target data sources. No configurator has been set for the JobQueueManager.");
            }
            else
            {
                var runHistory = JobQueueManager.Configurator.GetJobDataSourceRunHistory(jobToRun.Id, sourceDataSource.Id, targetDataSource.Id);

                SourceDataSource = new JobDataSource(SyncSide.Source, sourceDataSource, runHistory);
                TargetDataSource = new JobDataSource(SyncSide.Target, targetDataSource, runHistory);
            }

            if (filters != null)
            {
                _filters = filters;
            }

            _jobStepInstances = jobStepInstances.OrderBy(d => d.OrderIndex).ToList();

            ScheduledStartTime = scheduledStartTime;

            InvocationSource = invocationSource;

            InvocationSourceType = invocationSourceType;

            Id = Guid.NewGuid();

            foreach (var jobStepInstance in _jobStepInstances)
            {
                jobStepInstance.AssociatedJobInstance = this;
            }
        }
コード例 #10
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: Assign a collection of bindable groups to this.DefaultViewModel["Groups"]
            // Fetch the groups of Job Cards and assign them as the items source for the gridview displaying all Jobs
            ObservableCollection <JobGroup> allGroups = new ObservableCollection <JobGroup>(await JobDataSource.GetJobGroupsAsync());

            groupedItemsViewSource.Source = allGroups;

            // Assign the groups as the data source for Zoomed Out view
            (SemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = groupedItemsViewSource.View.CollectionGroups;

            // Check the window size and update the Visual State
            UpdateVisualState(Window.Current.Bounds.Width);
        }
コード例 #11
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: Assign a collection of bindable groups to this.DefaultViewModel["Groups"]
            // Fetch the groups of Job Cards and assign them as the items source for the gridview displaying all Jobs
            ObservableCollection <JobGroup> allGroups = new ObservableCollection <JobGroup>(await JobDataSource.GetJobGroupsAsync());

            groupedItemsViewSource.Source = allGroups;
        }
コード例 #12
0
        public JobBatch(SyncSide syncSide, JobDataSource associatedDataSource)
        {
            SyncSide = syncSide;

            AssociatedDataSource = associatedDataSource ?? throw new Exception("Data source can not be null.");

            EntityBatches.ListChanged += new ListChangedEventHandler((sender, args) =>
            {
                if (args.ListChangedType == ListChangedType.ItemAdded)
                {
                    EntityBatches[args.NewIndex].OrderIndex = EntityBatches.Count;

                    var childEntityBatch = EntityBatches[args.NewIndex];

                    if (EntityBatches.Where(d => d.EntityDefinition.UniqueRelationshipName.Equals(childEntityBatch.EntityDefinition.UniqueRelationshipName, StringComparison.OrdinalIgnoreCase)).Count() > 1)
                    {
                        throw new Exception(string.Format("An entity batch with unique relationship name '{0}' already exists.", childEntityBatch.EntityDefinition.UniqueRelationshipName));
                    }

                    foreach (var relationship in childEntityBatch.EntityDefinition.Relationships)
                    {
                        var parentEntityBatch = EntityBatches.Where(d => d.EntityDefinition.UniqueRelationshipName.Equals(relationship.Value.ParentUniqueRelationshipName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                        if (parentEntityBatch == null)
                        {
                            throw new Exception(string.Format("{0}-side entity batch with unique relationship name '{1}' was not found. If the referenced entity batch is within a previous job step, ensure DeferExecutionUntilNextStep is set to true within the parent job step.",
                                                              childEntityBatch.EntityDefinition.SyncSide, relationship.Value.ParentUniqueRelationshipName));
                        }

                        // associate child records w/o change
                        foreach (var childRecordWithoutChange in childEntityBatch.RecordsWithoutChange)
                        {
                            List <string> childKeyValues = new List <string>();

                            foreach (var childFieldName in relationship.Value.ChildFieldNamesToMatchOn)
                            {
                                try
                                {
                                    childKeyValues.Add(childRecordWithoutChange.DataOnlyValues[childFieldName]);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(string.Format("Field '{0}' not found in {1} when applying relationship '{2}'.",
                                                                      childFieldName, typeof(EntityRecordWithoutChange).Name, relationship.Value.Name), ex);
                                }
                            }

                            EntityRecord parentRecord;

                            if (relationship.Value.LinkOn == RecordKeyType.PrimaryKey)
                            {
                                parentEntityBatch.PrimaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else if (relationship.Value.LinkOn == RecordKeyType.SecondaryKey)
                            {
                                parentEntityBatch.SecondaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else
                            {
                                throw new EnumValueNotImplementedException <RecordKeyType>(relationship.Value.LinkOn);
                            }

                            if (parentRecord != null)
                            {
                                childRecordWithoutChange.AssociateParent(relationship.Value.Name, parentRecord);
                            }
                        }

                        // associate child records to add
                        foreach (var childRecordToAdd in childEntityBatch.RecordsToAdd)
                        {
                            List <string> childKeyValues = new List <string>();

                            foreach (var childFieldName in relationship.Value.ChildFieldNamesToMatchOn)
                            {
                                try
                                {
                                    childKeyValues.Add(childRecordToAdd.DataOnlyValues[childFieldName]);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(string.Format("Field '{0}' not found in {1} when applying relationship '{2}'.",
                                                                      childFieldName, typeof(RecordToAdd).Name, relationship.Value.Name), ex);
                                }
                            }

                            EntityRecord parentRecord;

                            if (relationship.Value.LinkOn == RecordKeyType.PrimaryKey)
                            {
                                parentEntityBatch.PrimaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else if (relationship.Value.LinkOn == RecordKeyType.SecondaryKey)
                            {
                                parentEntityBatch.SecondaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else
                            {
                                throw new EnumValueNotImplementedException <RecordKeyType>(relationship.Value.LinkOn);
                            }

                            if (parentRecord != null)
                            {
                                childRecordToAdd.AssociateParent(relationship.Value.Name, parentRecord);
                            }
                        }

                        // associate child records to update
                        foreach (var childRecordToUpdate in childEntityBatch.RecordsToUpdate)
                        {
                            List <string> childKeyValues = new List <string>();

                            foreach (var childFieldName in relationship.Value.ChildFieldNamesToMatchOn)
                            {
                                try
                                {
                                    childKeyValues.Add(childRecordToUpdate.DataOnlyValues[childFieldName]);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(string.Format("Field '{0}' not found in {1} when applying relationship '{2}'.",
                                                                      childFieldName, typeof(RecordToUpdate).Name, relationship.Value.Name), ex);
                                }
                            }

                            EntityRecord parentRecord;

                            if (relationship.Value.LinkOn == RecordKeyType.PrimaryKey)
                            {
                                parentEntityBatch.PrimaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else if (relationship.Value.LinkOn == RecordKeyType.SecondaryKey)
                            {
                                parentEntityBatch.SecondaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else
                            {
                                throw new EnumValueNotImplementedException <RecordKeyType>(relationship.Value.LinkOn);
                            }

                            if (parentRecord != null)
                            {
                                childRecordToUpdate.AssociateParent(relationship.Value.Name, parentRecord);
                            }
                        }

                        // associate child records to delete
                        foreach (var childRecordToDelete in childEntityBatch.RecordsToDelete)
                        {
                            List <string> childKeyValues = new List <string>();

                            foreach (var childFieldName in relationship.Value.ChildFieldNamesToMatchOn)
                            {
                                try
                                {
                                    childKeyValues.Add(childRecordToDelete.DataOnlyValues[childFieldName]);
                                }
                                catch (Exception ex)
                                {
                                    throw new Exception(string.Format("Field '{0}' not found in {1} when applying relationship '{2}'.",
                                                                      childFieldName, typeof(RecordToDelete).Name, relationship.Value.Name), ex);
                                }
                            }

                            EntityRecord parentRecord;

                            if (relationship.Value.LinkOn == RecordKeyType.PrimaryKey)
                            {
                                parentEntityBatch.PrimaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else if (relationship.Value.LinkOn == RecordKeyType.SecondaryKey)
                            {
                                parentEntityBatch.SecondaryKeys.TryGetValue(new RecordKeyCombo(childKeyValues), out parentRecord);
                            }
                            else
                            {
                                throw new EnumValueNotImplementedException <RecordKeyType>(relationship.Value.LinkOn);
                            }

                            if (parentRecord != null)
                            {
                                childRecordToDelete.AssociateParent(relationship.Value.Name, parentRecord);
                            }
                        }
                    }
                }
                else
                {
                    throw new EnumValueNotImplementedException <ListChangedType>(args.ListChangedType);
                }
            });
        }