Пример #1
0
        //public static SalesContext db = new SalesContext();

        //public static Customer CloneCustomer(Customer SelectedItem)
        //{
        //    using (var db = new SalesContext())
        //    {
        //        var item = db.Customers.Find(SelectedItem.Id);
        //        item.CustomerRank = CustomerRanks.Where(p => p.Id == item.CustomerRankID).Single();
        //        return item;
        //    }
        //}

        #endregion

        #region Asset
        public async static Task GetAllAssets()
        {
            Assets.Clear();
            AssetCategories.Clear();
            using (var db = new SalesContext())
            {
                var result  = await(from c in db.Assets select c).ToListAsync();
                var result1 = await(from c in db.AssetCategories.Include("Assets") select c).ToListAsync();
                var result2 = await(from c in db.Departments.Include("Assets") select c).ToListAsync();
                var result3 = await(from c in db.InstallationLocations.Include("Assets") select c).ToListAsync();
                foreach (Asset item in result)
                {
                    Assets.Add(item);
                }
                foreach (AssetCategory item in result1)
                {
                    AssetCategories.Add(item);
                }
                foreach (Department item in result2)
                {
                    Departments.Add(item);
                }
                foreach (InstallationLocation item in result3)
                {
                    InstallationLocations.Add(item);
                }
            }
        }
Пример #2
0
 public async static Task DeleteInstallationLocation(InstallationLocation itemPara)
 {
     using (var db = new SalesContext())
     {
         db.Entry(itemPara).State = EntityState.Unchanged;   //NOT DELETE - IMPORTANT
         InstallationLocations.Remove(itemPara);
         db.Entry(itemPara).State = EntityState.Deleted;     // must be executed after deleted it in InstallationLocations
         await UpdateDatabase(db);
     }
 }
Пример #3
0
        public async static Task AddInstallationLocation(InstallationLocation itemPara)
        {
            using (var db = new SalesContext())
            {
                db.InstallationLocations.Add(itemPara);
                await UpdateDatabase(db);

                InstallationLocations.Add(itemPara);
            }
        }
Пример #4
0
 public async static Task DeleteManyInstallationLocations(IList itemParas)
 {
     using (var db = new SalesContext())
     {
         List <InstallationLocation> list = new List <InstallationLocation>();
         foreach (object item in itemParas)
         {
             list.Add((InstallationLocation)item);
         }
         foreach (InstallationLocation item in list)
         {
             db.Entry(item).State = EntityState.Unchanged;
             InstallationLocations.Remove(item);
             db.Entry(item).State = EntityState.Deleted;
         }
         await UpdateDatabase(db);
     }
 }
Пример #5
0
        private Dictionary <string, PatchApplication> LoadDestinations(InstallationLocations locations)
        {
            Dictionary <string, PatchApplication> destinations =
                new Dictionary <string, PatchApplication>();

            if (locations.IsRemote)
            {
                // just leave it blank
                return(destinations);
            }

            foreach (InstallationLocation location in locations.Items)
            {
                destinations[location.Path] = CreatePatchDestination(location);
            }

            return(destinations);
        }
        private static void Add_Executed(object target, ExecutedRoutedEventArgs e)
        {
            List <string> guesses = InstallationLocations.GenerateDcsRootDirectoryGuesses();

            string guessName = InstallationLocation.AUTO_UPDATE_CONFIG;

            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
            {
                Title            = $"Navigate to DCS Installation and select {InstallationLocation.AUTO_UPDATE_CONFIG} or {InstallationLocation.DCS_EXE} file",
                InitialDirectory = "",
                FileName         = guessName,
                DefaultExt       = ".cfg",
                CheckPathExists  = true,
                DereferenceLinks = true,
                Multiselect      = false,
                ValidateNames    = true,
                Filter           = $"DCS|{InstallationLocation.AUTO_UPDATE_CONFIG};{InstallationLocation.DCS_EXE}",
                CheckFileExists  = true
            };

            foreach (string guess in guesses)
            {
                if (openFileDialog.InitialDirectory == "")
                {
                    openFileDialog.InitialDirectory = guesses[0];
                }
                else
                {
                    openFileDialog.CustomPlaces.Add(new Microsoft.Win32.FileDialogCustomPlace(guess));
                }
            }

            if (openFileDialog.ShowDialog() == true)
            {
                if (InstallationLocation.TryBrowseLocation(openFileDialog.FileName, out InstallationLocation location))
                {
                    // silently ignore duplicates
                    _ = InstallationLocations.Singleton.TryAdd(location);
                }
            }
            ((InstallationLocationsControl)target).UpdateStatus();
        }
Пример #7
0
        public override IEnumerable <StatusReportItem> PerformReadyCheck()
        {
            // while we do not have the ability to measure the DPI setting for each screen, we just report the system dpi and an advisory message
            // we always include this advisory because it is affecting basically all our widescreen users right now
            int dpi = ConfigManager.DisplayManager.DPI;

            yield return(new StatusReportItem
            {
                Status = $"Windows reports a scaling value of {Math.Round(dpi / 0.96d)}% ({dpi} dpi)",
                Recommendation = "This version of Helios does not support using different display scaling (DPI) on different monitors.  Make sure you use the same scaling value for all displays.",
                Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate | StatusReportItem.StatusFlags.Verbose
            });

            if (!_parent.CheckMonitorsValid)
            {
                yield return(new StatusReportItem
                {
                    Status = "Monitor configuration in profile does not match this computer",
                    Recommendation = "Perform 'Reset Monitors' function from the 'Profile' menu",
                    Link = StatusReportItem.ProfileEditor,
                    Severity = StatusReportItem.SeverityCode.Error
                });

                yield break;
            }

            if (string.IsNullOrWhiteSpace(_parent.Profile.Path))
            {
                yield return(new StatusReportItem
                {
                    Status =
                        "You must save the profile before you can use Monitor Setup, because it needs to know the profile name",
                    Recommendation = "Save the profile at least once before configuring Monitor Setup",
                    Link = StatusReportItem.ProfileEditor,
                    Severity = StatusReportItem.SeverityCode.Error
                });

                yield break;
            }

            // check if DCS install folders are configured
            InstallationLocations locations = InstallationLocations.Singleton;

            if (!locations.Active.Any())
            {
                yield return(new StatusReportItem
                {
                    Status = "No DCS installation locations are configured for monitor setup",
                    Recommendation = "Configure any DCS installation location you use",
                    Link = StatusReportItem.ProfileEditor,
                    Severity = StatusReportItem.SeverityCode.Error
                });
            }

            // gather viewport providers from this profile
            List <IViewportProvider> viewportProviders =
                _parent.Profile.Interfaces.OfType <IViewportProvider>().ToList();

            if (!_parent.UsingViewportProvider)
            {
                foreach (HeliosInterface viewportProvider in viewportProviders.OfType <HeliosInterface>())
                {
                    yield return(new StatusReportItem
                    {
                        Status = $"interface '{viewportProvider.Name}' is providing additional viewport patches but this profile uses a third-party solution for those",
                        Severity = StatusReportItem.SeverityCode.Warning,
                        Recommendation = $"Remove the '{viewportProvider.Name}' interface since this profile is configured to expect a third-party solution to provide viewport modifications"
                    });
                }
            }

            // check if any referenced viewports require patches to work
            foreach (IViewportExtent viewport in _parent.Viewports
                     .Select(shadow => shadow.Viewport)
                     .Where(v => v.RequiresPatches))
            {
                if (!_parent.UsingViewportProvider)
                {
                    yield return(new StatusReportItem
                    {
                        Status =
                            $"viewport '{viewport.ViewportName}' must be provided by third-party solution for additional viewports",
                        Recommendation =
                            "Verify that your third-party viewport modifications match the viewport names for this profile",
                        Flags = StatusReportItem.StatusFlags.Verbose |
                                StatusReportItem.StatusFlags.ConfigurationUpToDate
                    });

                    continue;
                }
                bool found = false;
                foreach (IViewportProvider provider in viewportProviders)
                {
                    if (provider.IsViewportAvailable(viewport.ViewportName))
                    {
                        yield return(new StatusReportItem
                        {
                            Status =
                                $"viewport '{viewport.ViewportName}' is provided by '{((HeliosInterface) provider).Name}'",
                            Flags = StatusReportItem.StatusFlags.Verbose |
                                    StatusReportItem.StatusFlags.ConfigurationUpToDate
                        });

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    yield return(new StatusReportItem
                    {
                        Status = $"viewport '{viewport.ViewportName}' requires patches to be installed",
                        Recommendation =
                            "Add an Additional Viewports interface or configure the viewport extent not to require patches",
                        Link = StatusReportItem.ProfileEditor,
                        Severity = StatusReportItem.SeverityCode.Error,
                        Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate
                    });
                }
            }

            bool updated = true;
            bool hasFile = false;

            // calculate shared monitor config
            // and see if it is up to date in all locations
            MonitorSetupTemplate combinedTemplate = CreateCombinedTemplate();
            string monitorSetupName = combinedTemplate.MonitorSetupName;

            foreach (StatusReportItem item in UpdateMonitorSetup(combinedTemplate, true))
            {
                yield return(item);
            }

            foreach (StatusReportItem item in EnumerateMonitorSetupFiles(CheckSetupFile, combinedTemplate))
            {
                if (!item.Flags.HasFlag(StatusReportItem.StatusFlags.ConfigurationUpToDate))
                {
                    updated = false;
                }

                hasFile = true;
                yield return(item);
            }

            // also calculate separate config, if applicable
            // and see if it is up to date in all locations
            if (!_parent.GenerateCombined)
            {
                MonitorSetupTemplate separateTemplate = CreateSeparateTemplate();
                monitorSetupName = separateTemplate.MonitorSetupName;
                foreach (StatusReportItem item in UpdateMonitorSetup(separateTemplate, false))
                {
                    yield return(item);
                }

                foreach (StatusReportItem item in EnumerateMonitorSetupFiles(CheckSetupFile, separateTemplate))
                {
                    if (!item.Flags.HasFlag(StatusReportItem.StatusFlags.ConfigurationUpToDate))
                    {
                        updated = false;
                    }

                    hasFile = true;
                    yield return(item);
                }
            }

            foreach (InstallationLocation location in locations.Active)
            {
                if (DCSOptions.TryReadOptions(location, out DCSOptions options))
                {
                    // check if correct monitor resolution selected in DCS
                    yield return(ReportResolutionSelected(location, options));

                    // don't tell the user to do this yet if the file isn't done
                    if (hasFile && updated)
                    {
                        // check if monitor setup selected in DCS
                        yield return(ReportMonitorSetupSelected(location, options, monitorSetupName));
                    }
                }
                else
                {
                    // report that the user has to check this themselves (we may not have access and that's ok)
                    string qualifier = _parent.MonitorLayoutMode == MonitorLayoutMode.FromTopLeftCorner ? "at least " : "";
                    yield return(new StatusReportItem
                    {
                        Status = $"Helios was unable to check the DCS settings stored in {location.DescribeOptionsPath}",
                        Recommendation =
                            $"Using DCS, please make sure the 'Resolution' in the 'System' options is set to {qualifier}{_parent.Rendered.Width}x{_parent.Rendered.Height}",
                        Severity = StatusReportItem.SeverityCode.Info,
                        Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate
                    });

                    // don't tell the user to do this yet if the file isn't done
                    if (hasFile && updated)
                    {
                        yield return(new StatusReportItem
                        {
                            Status = $"Helios was unable to check the DCS monitor setup selection stored in {location.DescribeOptionsPath}",
                            Recommendation =
                                $"Using DCS, please make sure 'Monitors' in the 'System' options is set to '{monitorSetupName}'",
                            Severity = StatusReportItem.SeverityCode.Info,
                            Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate
                        });
                    }
                }
            }

            if (_parent.GenerateCombined)
            {
                yield break;
            }

            yield return(new StatusReportItem
            {
                Status = "This profile requires a specific monitor setup file",
                Recommendation =
                    "You will need to switch 'Monitors' in DCS when you switch Helios Profile",
                Severity = StatusReportItem.SeverityCode.Info,
                Flags = StatusReportItem.StatusFlags.ConfigurationUpToDate
            });
        }