예제 #1
0
        public PrinterViewModel(
            IPrinterProvider printerProvider,
            ISettingsProvider settingsProvider,
            ICurrentSettings <ObservableCollection <PrinterMapping> > printerMappingProvider,
            ICurrentSettings <ObservableCollection <ConversionProfile> > profilesProvider,
            IPrinterActionsAssistant printerActionsAssistant,
            IOsHelper osHelper,
            ITranslationUpdater translationUpdater,
            IPrinterHelper printerHelper,
            IGpoSettings gpoSettings)
            : base(translationUpdater)
        {
            _osHelper                = osHelper;
            _printerHelper           = printerHelper;
            _gpoSettings             = gpoSettings;
            _printerActionsAssistant = printerActionsAssistant;
            _printerProvider         = printerProvider;
            _settingsProvider        = settingsProvider;
            _printerMappingProvider  = printerMappingProvider;
            ProfilesProvider         = profilesProvider;

            AddPrinterCommand        = new DelegateCommand(AddPrintercommandExecute);
            RenamePrinterCommand     = new DelegateCommand(RenamePrinterCommandExecute, ModifyPrinterCommandCanExecute);
            DeletePrinterCommand     = new DelegateCommand(DeletePrinterCommandExecute, ModifyPrinterCommandCanExecute);
            SetPrimaryPrinterCommand = new DelegateCommand(SetPrimaryPrinter);
        }
예제 #2
0
 public RestorePrinterAppStart(ICheckAllStartupConditions checkAllStartupConditions, IPrinterProvider printerProvider,
                               IUacAssistant uacAssistant, IInstallationPathProvider installationPathProvider,
                               ISharedSettingsLoader sharedSettingsLoader) : base(checkAllStartupConditions)
 {
     _uacAssistant             = uacAssistant;
     _printerProvider          = printerProvider;
     _installationPathProvider = installationPathProvider;
     _sharedSettingsLoader     = sharedSettingsLoader;
     SkipStartupConditionCheck = true;
 }
예제 #3
0
        public PrinterTabViewModel(IPrinterProvider printerProvider, IPrinterActionsAssistant printerActionsAssistant, IOsHelper osHelper, TranslationHelper translationHelper, IPrinterHelper printerHelper, PrinterTabTranslation translation)
        {
            Translation              = translation;
            _osHelper                = osHelper;
            _translationHelper       = translationHelper;
            _printerHelper           = printerHelper;
            _printerActionsAssistant = printerActionsAssistant;
            _printerProvider         = printerProvider;

            AddPrinterCommand    = new DelegateCommand(AddPrintercommandExecute);
            RenamePrinterCommand = new DelegateCommand(RenamePrinterCommandExecute, ModifyPrinterCommandCanExecute);
            DeletePrinterCommand = new DelegateCommand(DeletePrinterCommandExecute, ModifyPrinterCommandCanExecute);
        }
예제 #4
0
        public PrinterViewModel(IPrinterProvider printerProvider, IPrinterActionsAssistant printerActionsAssistant, IOsHelper osHelper, TranslationHelper translationHelper, ITranslationUpdater translationUpdater, IPrinterHelper printerHelper, ISettingsProvider settingsProvider, IGpoSettings gpoSettings)
            : base(translationUpdater)
        {
            _osHelper                = osHelper;
            _printerHelper           = printerHelper;
            _gpoSettings             = gpoSettings;
            _printerActionsAssistant = printerActionsAssistant;
            _printerProvider         = printerProvider;

            AddPrinterCommand        = new DelegateCommand(AddPrintercommandExecute);
            RenamePrinterCommand     = new DelegateCommand(RenamePrinterCommandExecute, ModifyPrinterCommandCanExecute);
            DeletePrinterCommand     = new DelegateCommand(DeletePrinterCommandExecute, ModifyPrinterCommandCanExecute);
            SetPrimaryPrinterCommand = new DelegateCommand(SetPrimaryPrinter);

            SetSettingsAndRaiseNotifications(settingsProvider.Settings, gpoSettings);
        }
 public CreatorIniSettingsAssistant
 (
     IInteractionInvoker interactionInvoker,
     ITranslationUpdater translationUpdater,
     ISettingsManager settingsManager,
     IDataStorageFactory dataStorageFactory,
     IIniSettingsLoader iniSettingsLoader,
     IPrinterProvider printerProvider,
     IUacAssistant uacAssistant)
     : base(interactionInvoker, dataStorageFactory, translationUpdater)
 {
     _settingsManager    = settingsManager;
     _settingsProvider   = settingsManager.GetSettingsProvider();
     _dataStorageFactory = dataStorageFactory;
     _iniSettingsLoader  = iniSettingsLoader;
     _printerProvider    = printerProvider;
     _uacAssistant       = uacAssistant;
 }
        //// Events
        //public event EventHandler ActionChanged
        //{
        //    add
        //    {
        //        this._window.MenuModelUpdated += value;
        //    }
        //    remove
        //    {
        //        this._window.MenuModelUpdated -= value;
        //    }
        //}

        //public event EventHandler MenuModelUpdated
        //{
        //    add
        //    {
        //        this._window.MenuModelUpdated += value;
        //    }
        //    remove
        //    {
        //        this._window.MenuModelUpdated -= value;
        //    }
        //}

        // Methods
        public PrintToolComponent(IDesktopWindow window)
        {
            EventHandler handler = null;
            this._lastFilmOrientation =  FilmOrientation.Portrait;
            this._numberOfCopies = 1M;
            this.printListKey = 1;
            this._window = window;
            this.provider = PrinterProviderFactory.CreateProvider();
            this._printerList = this.provider.GetPrinterCollection();
            this._printerList.ActiveChanged += handler;

            foreach (Printer printer in this._printerList)
            {
                if (printer.Selected)
                {
                    this._selectedPrinter = printer;
                    this._currentPrinter = printer.PrinterName;
                    break;
                }
            }
            this._lastFilmSize =  FilmSize.Dimension_8in_x_10in;
            this._printJobManager = new PrintJobManager(this._window, this);
        }
예제 #7
0
 public void Setup()
 {
     _uacAssistant    = Substitute.For <IUacAssistant>();
     _printerProvider = Substitute.For <IPrinterProvider>();
 }
예제 #8
0
        public static async Task <bool> ProcessCallQueueItem(CallQueueItem cqi)
        {
            try
            {
                if (cqi != null && cqi.Call != null && cqi.Call.HasAnyDispatches())
                {
                    if (_communicationService == null)
                    {
                        _communicationService = Bootstrapper.GetKernel().Resolve <ICommunicationService>();
                    }

                    if (_callsService == null)
                    {
                        _callsService = Bootstrapper.GetKernel().Resolve <ICallsService>();
                    }

                    List <int> groupIds = new List <int>();

                    /* Trying to see if I can eek out a little perf here now that profiles are in Redis. Previously the
                     * the parallel operation would cause EF errors. This shouldn't be the case now because profiles are
                     * cached and GetProfileForUser operations will hit that first.
                     */
                    if (cqi.Profiles == null || !cqi.Profiles.Any())
                    {
                        if (_userProfilesService == null)
                        {
                            _userProfilesService = Bootstrapper.GetKernel().Resolve <IUserProfileService>();
                        }

                        cqi.Profiles = (await _userProfilesService.GetAllProfilesForDepartmentAsync(cqi.Call.DepartmentId)).Select(x => x.Value).ToList();
                    }

                    if (cqi.CallDispatchAttachmentId > 0)
                    {
                        //var callsService = Bootstrapper.GetKernel().Resolve<ICallsService>();
                        cqi.Call.ShortenedAudioUrl = await _callsService.GetShortenedAudioUrlAsync(cqi.Call.CallId, cqi.CallDispatchAttachmentId);
                    }

                    cqi.Call.ShortenedCallUrl = await _callsService.GetShortenedCallLinkUrl(cqi.Call.CallId);

                    try
                    {
                        cqi.Call.CallPriority = await _callsService.GetCallPrioritiesByIdAsync(cqi.Call.DepartmentId, cqi.Call.Priority, false);
                    }
                    catch { /* Doesn't matter */ }

                    var dispatchedUsers = new HashSet <string>();

                    // Dispatch Personnel
                    if (cqi.Call.Dispatches != null && cqi.Call.Dispatches.Any())
                    {
                        Parallel.ForEach(cqi.Call.Dispatches, d =>
                        {
                            dispatchedUsers.Add(d.UserId);

                            try
                            {
                                var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == d.UserId);

                                if (profile != null)
                                {
                                    _communicationService.SendCallAsync(cqi.Call, d, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                }
                            }
                            catch (SocketException sex)
                            {
                            }
                        });
                    }

                    if (_departmentGroupsService == null)
                    {
                        _departmentGroupsService = Bootstrapper.GetKernel().Resolve <IDepartmentGroupsService>();
                    }

                    // Dispatch Groups
                    if (cqi.Call.GroupDispatches != null && cqi.Call.GroupDispatches.Any())
                    {
                        foreach (var d in cqi.Call.GroupDispatches)
                        {
                            if (!groupIds.Contains(d.DepartmentGroupId))
                            {
                                groupIds.Add(d.DepartmentGroupId);
                            }

                            var members = await _departmentGroupsService.GetAllMembersForGroupAsync(d.DepartmentGroupId);

                            foreach (var member in members)
                            {
                                if (!dispatchedUsers.Contains(member.UserId))
                                {
                                    dispatchedUsers.Add(member.UserId);
                                    try
                                    {
                                        var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                        await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                        {
                                            UserId = member.UserId
                                        }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                    }
                                    catch (SocketException sex)
                                    {
                                    }
                                    catch (Exception ex)
                                    {
                                        Logging.LogException(ex);
                                    }
                                }
                            }
                        }
                    }

                    // Dispatch Units
                    if (cqi.Call.UnitDispatches != null && cqi.Call.UnitDispatches.Any())
                    {
                        if (_unitsService == null)
                        {
                            _unitsService = Bootstrapper.GetKernel().Resolve <IUnitsService>();
                        }

                        foreach (var d in cqi.Call.UnitDispatches)
                        {
                            var unit = await _unitsService.GetUnitByIdAsync(d.UnitId);

                            if (unit != null && unit.StationGroupId.HasValue)
                            {
                                if (!groupIds.Contains(unit.StationGroupId.Value))
                                {
                                    groupIds.Add(unit.StationGroupId.Value);
                                }
                            }

                            await _communicationService.SendUnitCallAsync(cqi.Call, d, cqi.DepartmentTextNumber, cqi.Address);

                            var unitAssignedMembers = await _unitsService.GetCurrentRolesForUnitAsync(d.UnitId);

                            if (unitAssignedMembers != null && unitAssignedMembers.Count() > 0)
                            {
                                foreach (var member in unitAssignedMembers)
                                {
                                    if (!dispatchedUsers.Contains(member.UserId))
                                    {
                                        dispatchedUsers.Add(member.UserId);
                                        try
                                        {
                                            var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                            await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                            {
                                                UserId = member.UserId
                                            }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                        }
                                        catch (SocketException sex)
                                        {
                                        }
                                        catch (Exception ex)
                                        {
                                            Logging.LogException(ex);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (unit.StationGroupId.HasValue)
                                {
                                    var members = await _departmentGroupsService.GetAllMembersForGroupAsync(unit.StationGroupId.Value);

                                    foreach (var member in members)
                                    {
                                        if (!dispatchedUsers.Contains(member.UserId))
                                        {
                                            dispatchedUsers.Add(member.UserId);
                                            try
                                            {
                                                var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                                await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                                {
                                                    UserId = member.UserId
                                                }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                            }
                                            catch (SocketException sex)
                                            {
                                            }
                                            catch (Exception ex)
                                            {
                                                Logging.LogException(ex);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Dispatch Roles
                    if (cqi.Call.RoleDispatches != null && cqi.Call.RoleDispatches.Any())
                    {
                        if (_rolesService == null)
                        {
                            _rolesService = Bootstrapper.GetKernel().Resolve <IPersonnelRolesService>();
                        }

                        foreach (var d in cqi.Call.RoleDispatches)
                        {
                            var members = await _rolesService.GetAllMembersOfRoleAsync(d.RoleId);

                            foreach (var member in members)
                            {
                                if (!dispatchedUsers.Contains(member.UserId))
                                {
                                    dispatchedUsers.Add(member.UserId);
                                    try
                                    {
                                        var profile = cqi.Profiles.FirstOrDefault(x => x.UserId == member.UserId);
                                        await _communicationService.SendCallAsync(cqi.Call, new CallDispatch()
                                        {
                                            UserId = member.UserId
                                        }, cqi.DepartmentTextNumber, cqi.Call.DepartmentId, profile, cqi.Address);
                                    }
                                    catch (SocketException sex)
                                    {
                                    }
                                    catch (Exception ex)
                                    {
                                        Logging.LogException(ex);
                                    }
                                }
                            }
                        }
                    }

                    // Send Call Print to Printer
                    if (_printerProvider == null)
                    {
                        _printerProvider = Bootstrapper.GetKernel().Resolve <IPrinterProvider>();
                    }

                    Dictionary <int, DepartmentGroup> fetchedGroups = new Dictionary <int, DepartmentGroup>();
                    if (cqi.Call.Dispatches != null && cqi.Call.Dispatches.Any())
                    {
                        foreach (var d in cqi.Call.Dispatches)
                        {
                            var group = await _departmentGroupsService.GetGroupForUserAsync(d.UserId, cqi.Call.DepartmentId);

                            if (group != null)
                            {
                                if (!groupIds.Contains(group.DepartmentGroupId))
                                {
                                    groupIds.Add(group.DepartmentGroupId);
                                }

                                if (!fetchedGroups.ContainsKey(group.DepartmentGroupId))
                                {
                                    fetchedGroups.Add(group.DepartmentGroupId, group);
                                }
                            }
                        }
                    }

                    foreach (var groupId in groupIds)
                    {
                        try
                        {
                            DepartmentGroup group = null;

                            if (fetchedGroups.ContainsKey(groupId))
                            {
                                group = fetchedGroups[groupId];
                            }
                            else
                            {
                                group = await _departmentGroupsService.GetGroupByIdAsync(groupId);
                            }

                            if (!String.IsNullOrWhiteSpace(group.PrinterData) && group.DispatchToPrinter)
                            {
                                var printerData = JsonConvert.DeserializeObject <DepartmentGroupPrinter>(group.PrinterData);
                                var apiKey      = SymmetricEncryption.Decrypt(printerData.ApiKey, Config.SystemBehaviorConfig.ExternalLinkUrlParamPassphrase);
                                var callUrl     = await _callsService.GetShortenedCallPdfUrl(cqi.Call.CallId, true, groupId);

                                var printJob = _printerProvider.SubmitPrintJob(apiKey, printerData.PrinterId, "CallPrint", callUrl);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogException(ex);
                        }
                    }
                }
            }
            finally
            {
                _communicationService = null;
            }

            return(true);
        }
예제 #9
0
 public void CacheProvider(int printerId, IPrinterProvider provider)
 {
     ProviderCache[printerId] = provider;
 }
 public CreatorIniSettingsAssistantHelper(IInteractionInvoker interactionInvoker, ITranslationUpdater translationUpdater, ISettingsManager settingsManager,
                                          IDataStorageFactory dataStorageFactory, IIniSettingsLoader iniSettingsLoader, IPrinterProvider printerProvider,
                                          IUacAssistant uacAssistant) :
     base(interactionInvoker, translationUpdater, settingsManager, dataStorageFactory, iniSettingsLoader, printerProvider, uacAssistant)
 {
 }
예제 #11
0
 public RestorePrinterAppStart(ICheckAllStartupConditions checkAllStartupConditions, IPrinterProvider printerProvider, IUacAssistant uacAssistant, IInstallationPathProvider installationPathProvider) : base(checkAllStartupConditions)
 {
     _uacAssistant             = uacAssistant;
     _printerProvider          = printerProvider;
     _installationPathProvider = installationPathProvider;
 }