Ejemplo n.º 1
0
        async void PollAndUpdateData(ThreadPoolTimer timer)
        {
            try
            {
                if (_cancelRequested)
                {
                    _periodicTimer.Cancel();
                    _deferral.Complete();
                }
                else
                {
                    if (Stage2Interface.GetInstance().IsStag2Inited)
                    {
                        await PostNotifications();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is FaultException <eBridgeServiceExceptionType> )
                {
                    FaultException <eBridgeServiceExceptionType> fx = ex as FaultException <eBridgeServiceExceptionType>;
                    if (fx.Detail.FaultType == "ERR_EBS_INVALID_TOKEN")
                    {
                        await Stage2Interface.GetInstance().InternalLogin();
                    }
                }
                if (ex is TimeoutException)
                {
                    await Task.Delay(5000);

                    await Stage2Interface.GetInstance().InternalLogin();
                }
            }
        }
Ejemplo n.º 2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string strUname = unameValue.Text;
            string strPwd   = passValue.Text;

            if (!(string.IsNullOrEmpty(strUname)) && !(string.IsNullOrEmpty(strPwd)))
            {
                progRing.IsActive     = true;
                statusText.Foreground = new SolidColorBrush(Colors.Green);
                statusText.Text       = "Logging In...";

                await Stage2Interface.GetInstance().InternalLogin(unameValue.Text, passValue.Text);

                if (Stage2Interface.GetInstance().IsStag2Inited)
                {
                    this.Frame.Navigate(typeof(MainPage));
                }
                else
                {
                    progRing.IsActive     = false;
                    progRing.Visibility   = Visibility.Collapsed;
                    statusText.Foreground = new SolidColorBrush(Colors.Red);
                    statusText.Text       = "Logging Failure!!!";
                }
            }
            else
            {
                statusText.Text       = "User Name and/or Password cannot be empty!!!";
                statusText.Foreground = new SolidColorBrush(Colors.Red);
            }
        }
Ejemplo n.º 3
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                if (Stage2Interface.GetInstance().IsStag2Inited)
                {
                    await PopulateMFPInfo();
                }
                else
                {
                    loginPopup.IsOpen  = true;
                    ipValue.Text       = Helper.MFPIP;
                    statusLabel.Text   = string.Empty;
                    statusMsg.Text     = string.Empty;
                    progBar.Visibility = Visibility.Collapsed;
                }
            }
            catch (Exception ex)
            {
                HandleError();

                ContentDialog dialog = Helper.GetDialog();
                dialog.Content = ex.Message;
                await dialog.ShowAsync();
            }
        }
Ejemplo n.º 4
0
        async Task PopulateDeviceStatus()
        {
            try
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Green);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_DEVSTATUS_MSG");
                getDeviceStatusResponse1 devStatus = await Stage2Interface.GetInstance().GetDeviceStatusAsync();

                if (devStatus != null)
                {
                    statusLabel.Text = devStatus.getDeviceStatusResponse.Status.DeviceStatus.ToString();
                    prinStatus.Text  = devStatus.getDeviceStatusResponse.Status.PrinterStatus.ToString();
                    statusDetailType[] statusTypes = devStatus.getDeviceStatusResponse.Status.Detail;

                    statusDetail.Children.Clear();
                    foreach (statusDetailType type in statusTypes)
                    {
                        TextBlock txtBlk = new TextBlock();

                        string strTitle   = string.Empty;
                        string strContent = string.Empty;
                        Helper.GetDisplayStrings(type.CodeName, out strTitle, out strContent);
                        txtBlk.Text = strTitle;

                        if (string.IsNullOrEmpty(strTitle))
                        {
                            txtBlk.Text = type.CodeName;
                        }
                        txtBlk.FontSize = 20;
                        statusDetail.Children.Add(txtBlk);
                    }

                    statusExpander.IsExpanded = true;
                }
            }
            catch (FaultException <OutputManagementService.eBridgeServiceExceptionType> ex)
            {
                //statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                //statusMsg.Text = ex.Detail.Description;

                if (ex is FaultException <OutputManagementService.eBridgeServiceExceptionType> )
                {
                    FaultException <OutputManagementService.eBridgeServiceExceptionType> fx = ex as FaultException <OutputManagementService.eBridgeServiceExceptionType>;
                    if (fx.Detail.FaultType == "ERR_EBS_INVALID_TOKEN")
                    {
                        statusMsg.Foreground = new SolidColorBrush(Colors.Blue);
                        statusMsg.Text       = Helper.GetResourceString("ID_REFRESH");
                        await Stage2Interface.GetInstance().InternalLogin();

                        PopulateDeviceStatus();
                    }
                }
            }
            catch (TimeoutException)
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_DEVSTATUS_TIMEOUT_MSG");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            await Stage2Interface.GetInstance().Logout();

            deferral.Complete();
        }
Ejemplo n.º 6
0
 public static Stage2Interface GetInstance()
 {
     if (_instance == null)
     {
         _instance = new Stage2Interface();
     }
     return(_instance);
 }
Ejemplo n.º 7
0
        async Task PopulateDeviceCounters()
        {
            try
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Green);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_COUNT_MSG");
                getDeviceTotalResponse1 devTotals = await Stage2Interface.GetInstance().GetDeviceTotalAsync();

                if (devTotals != null)
                {
                    deviceTotalType devTotalType = devTotals.getDeviceTotalResponse.Total as deviceTotalType;

                    printCounter.Text = devTotalType.JobCounter.Printer.Total.Total.TotalCount.ToString();
                    scanCounter.Text  = devTotalType.JobCounter.Scanner.Total.Total.TotalCount.ToString();
                    faxCounter.Text   = devTotalType.JobCounter.Fax.Total.TotalCount.ToString();

                    counterExpander.IsExpanded = true;
                }
            }
            catch (FaultException <OutputManagementService.eBridgeServiceExceptionType> ex)
            {
                //statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                //statusMsg.Text = ex.Detail.Description;

                if (ex is FaultException <OutputManagementService.eBridgeServiceExceptionType> )
                {
                    FaultException <OutputManagementService.eBridgeServiceExceptionType> fx = ex as FaultException <OutputManagementService.eBridgeServiceExceptionType>;
                    if (fx.Detail.FaultType == "ERR_EBS_INVALID_TOKEN")
                    {
                        statusMsg.Foreground = new SolidColorBrush(Colors.Blue);
                        statusMsg.Text       = Helper.GetResourceString("ID_REFRESH");
                        await Stage2Interface.GetInstance().InternalLogin();

                        PopulateDeviceCounters();
                    }
                }
            }
            catch (TimeoutException)
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_COUNT_TIMEOUT_MSG");
            }
        }
Ejemplo n.º 8
0
        async Task PopulateDeviceInfo()
        {
            try
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Green);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_BASIC_MSG");
                OutputManagementService.getBasicDeviceInfoResponse1 devInfo = await Stage2Interface.GetInstance().GetBasicDeviceInfoAsync();

                if (devInfo != null)
                {
                    mfpName.Text     = devInfo.getBasicDeviceInfoResponse.BasicInfo.Name;
                    mfpManf.Text     = devInfo.getBasicDeviceInfoResponse.BasicInfo.Manufacturer;
                    mfpSerial.Text   = devInfo.getBasicDeviceInfoResponse.BasicInfo.MFPSerialNumber;
                    mfpMAC.Text      = devInfo.getBasicDeviceInfoResponse.BasicInfo.MACAddress[0];
                    mfpModel.Text    = devInfo.getBasicDeviceInfoResponse.BasicInfo.CopierModel;
                    mfpLoc.Text      = devInfo.getBasicDeviceInfoResponse.BasicInfo.PhysicalLocation;
                    mfpShipType.Text = devInfo.getBasicDeviceInfoResponse.BasicInfo.ShipmentType;
                }
            }
            catch (FaultException <OutputManagementService.eBridgeServiceExceptionType> ex)
            {
                //statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                //statusMsg.Text = ex.Detail.Description;

                if (ex is FaultException <OutputManagementService.eBridgeServiceExceptionType> )
                {
                    FaultException <OutputManagementService.eBridgeServiceExceptionType> fx = ex as FaultException <OutputManagementService.eBridgeServiceExceptionType>;
                    if (fx.Detail.FaultType == "ERR_EBS_INVALID_TOKEN")
                    {
                        statusMsg.Foreground = new SolidColorBrush(Colors.Blue);
                        statusMsg.Text       = Helper.GetResourceString("ID_REFRESH");
                        await Stage2Interface.GetInstance().InternalLogin();

                        PopulateDeviceInfo();
                    }
                }
            }
            catch (TimeoutException)
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_BASIC_TIMEOUT_MSG");
            }
        }
Ejemplo n.º 9
0
        async Task HandleLogin()
        {
            try
            {
                string strUname = unameValue.Text;
                string strPwd   = passValue.Password;

                if (!(string.IsNullOrEmpty(strUname)) && !(string.IsNullOrEmpty(strPwd)))
                {
                    progRing.IsActive     = true;
                    progRing.Visibility   = Visibility.Visible;
                    statusText.Foreground = new SolidColorBrush(Colors.Green);
                    statusText.Text       = Helper.GetResourceString("ID_LOGIN_PROGRESS_MSG");

                    await Stage2Interface.GetInstance().InternalLogin(strUname, strPwd);

                    if (Stage2Interface.GetInstance().IsStag2Inited)
                    {
                        loginPopup.IsOpen  = false;
                        loginUI.IsEnabled  = false;
                        parentUI.IsEnabled = true;
                        PopulateMFPInfo();
                    }
                    else
                    {
                        string strMsg = Helper.GetResourceString("ID_LOGIN_FAILURE_MSG");
                        HandleFailure(strMsg);
                    }
                }
                else
                {
                    statusText.Text       = Helper.GetResourceString("ID_LOGIN_EMPTY_MSG");
                    statusText.Foreground = new SolidColorBrush(Colors.Red);
                }
            }
            catch (CommunicationException cx)
            {
                string strMsg = Helper.GetResourceString("ID_LOGIN_EXCPTN_MSG");
                HandleFailure(strMsg);
            }
        }
Ejemplo n.º 10
0
        async Task PopulateMFPInfo()
        {
            try
            {
                parentUI.IsEnabled = true;
                statusLabel.Text   = Helper.GetResourceString("ID_FOOTER_DEF_STATUS");
                statusMsg.Text     = Helper.GetResourceString("ID_STATUS_DEF_MSG");
                progBar.Visibility = Visibility.Visible;
                //await Stage2Interface.GetInstance().InternalLogin();

                if (Stage2Interface.GetInstance().IsStag2Inited)
                {
                    statusLabel.Foreground = new SolidColorBrush(Colors.Green);
                    statusLabel.Text       = "Connected";
                    ipLabel.Text           = Helper.MFPIP;

                    await Task.Delay(1000);
                    await PopulateDeviceInfo();

                    await Task.Delay(1000);
                    await PopulateDeviceStatus();

                    await Task.Delay(1000);
                    await PopulateHardwareInfo();

                    await Task.Delay(1000);
                    await PopulateDeviceCounters();

                    progBar.Visibility   = Visibility.Collapsed;
                    statusMsg.Foreground = new SolidColorBrush(Colors.Green);
                    statusMsg.Text       = Helper.GetResourceString("ID_STATUS_SUCCESS_MSG");
                    await Task.Delay(2000);

                    statusMsg.Text       = string.Empty;
                    statusMsg.Visibility = Visibility.Collapsed;
                }
                else
                {
                    HandleError();
                }
            }
            catch (Exception ex)
            {
                ContentDialog dialog = Helper.GetDialog();
                dialog.Content = ex.Message;

                if (ex is TimeoutException)
                {
                    dialog.PrimaryButtonText   = Helper.GetResourceString("ID_RETRY_MSG");
                    dialog.PrimaryButtonClick += Dialog_PrimaryButtonClick;
                    dialog.CloseButtonClick   += Dialog_CloseButtonClick;
                    dialog.Content             = Helper.GetResourceString("ID_TIMEOUT_MSG");
                    await dialog.ShowAsync();
                }
                else
                {
                    await dialog.ShowAsync();

                    HandleError();
                }
            }
        }
Ejemplo n.º 11
0
        async Task PopulateHardwareInfo()
        {
            try
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Green);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_HWINFO_MSG");
                getHardwareInfoResponse1 devHWResp = await Stage2Interface.GetInstance().GetHardwareInfoAsync();

                if (devHWResp != null)
                {
                    DeviceInfoService.finisherType finInfo = devHWResp.getHardwareInfoResponse.HardwareInfo.Finisher;
                    finishStatus.Text = finInfo.Status;
                    stapleStatus.Text = finInfo.StapleUnit.Status;
                    saddleStatus.Text = finInfo.SaddleStitchUnit.Status;
                    holeStatus.Text   = finInfo.HolePunch.Status;

                    faxStatus.Text = devHWResp.getHardwareInfoResponse.HardwareInfo.Fax.Status;
                    adfStatus.Text = devHWResp.getHardwareInfoResponse.HardwareInfo.ADF.Status;
                    hddStatus.Text = devHWResp.getHardwareInfoResponse.HardwareInfo.HDD.Status;

                    DeviceInfoService.tonerUnitType tonerInfo = devHWResp.getHardwareInfoResponse.HardwareInfo.Toner;
                    tonerStatus.Text  = tonerInfo.Status;
                    yTonerStatus.Text = tonerInfo.Y.State;
                    mTonerStatus.Text = tonerInfo.M.State;
                    cTonerStatus.Text = tonerInfo.C.State;
                    kTonerStatus.Text = tonerInfo.K.State;

                    DeviceInfoService.memoryType memInfo = devHWResp.getHardwareInfoResponse.HardwareInfo.Memory;
                    memStatus.Text = memInfo.Status;
                    memSize.Text   = memInfo.MainMemory.Size + " MB";

                    DeviceInfoService.cassetteUnitType cassetteInfo = devHWResp.getHardwareInfoResponse.HardwareInfo.Cassette;
                    cas1Status.Text    = cassetteInfo.Cassette1.Status;
                    cas1PaperSize.Text = cassetteInfo.Cassette1.PaperSize;
                    cas1RemPaper.Text  = cassetteInfo.Cassette1.RemainingPaper;
                    cas2Status.Text    = cassetteInfo.Cassette2.Status;
                    cas2PaperSize.Text = cassetteInfo.Cassette2.PaperSize;
                    cas2RemPaper.Text  = cassetteInfo.Cassette2.RemainingPaper;

                    hWInfoExpander.IsExpanded = true;
                }
            }
            catch (FaultException <DeviceInfoService.eBridgeServiceExceptionType> ex)
            {
                //statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                //statusMsg.Text = ex.Detail.Description;

                if (ex is FaultException <DeviceInfoService.eBridgeServiceExceptionType> )
                {
                    FaultException <DeviceInfoService.eBridgeServiceExceptionType> fx = ex as FaultException <DeviceInfoService.eBridgeServiceExceptionType>;
                    if (fx.Detail.FaultType == "ERR_EBS_INVALID_TOKEN")
                    {
                        statusMsg.Foreground = new SolidColorBrush(Colors.Blue);
                        statusMsg.Text       = Helper.GetResourceString("ID_REFRESH");
                        await Stage2Interface.GetInstance().InternalLogin();

                        PopulateHardwareInfo();
                    }
                }
            }
            catch (TimeoutException)
            {
                statusMsg.Foreground = new SolidColorBrush(Colors.Red);
                statusMsg.Text       = Helper.GetResourceString("ID_STATUS_HWINFO_TIMEOUT_MSG");
            }
        }
Ejemplo n.º 12
0
        async Task PostNotifications()
        {
            getDeviceStatusResponse1 devStatus = await Stage2Interface.GetInstance().GetDeviceStatusAsync();

            if (devStatus != null)
            {
                statusDetailType[] statusTypes = devStatus.getDeviceStatusResponse.Status.Detail;

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                              () =>
                {
                    HomeInst.StatusExpander.IsExpanded = false;
                    HomeInst.StatusBlock.Children.Clear();

                    foreach (statusDetailType type in statusTypes)
                    {
                        TextBlock txtBlk = new TextBlock();
                        Helper.GetDisplayStrings(type.CodeName, out strTitle, out strContent);
                        txtBlk.Text = strTitle;
                        if (string.IsNullOrEmpty(strTitle))
                        {
                            txtBlk.Text = type.CodeName;
                        }
                        txtBlk.FontSize = 20;
                        HomeInst.StatusBlock.Children.Add(txtBlk);
                    }

                    HomeInst.StatusLabel.Text          = devStatus.getDeviceStatusResponse.Status.DeviceStatus.ToString();
                    HomeInst.PrinStatus.Text           = devStatus.getDeviceStatusResponse.Status.PrinterStatus.ToString();
                    HomeInst.StatusExpander.IsExpanded = true;
                });

                bool bCoverNtfctnEnable = localSettings.Values.ContainsKey("CoverOpenNtfctn") ? (bool)localSettings.Values["CoverOpenNtfctn"] : false;
                if (bCoverNtfctnEnable)
                {
                    foreach (statusDetailType type in statusTypes)
                    {
                        Helper.GetDisplayStrings(type.CodeName, out strTitle, out strContent);

                        switch (type.CodeName)
                        {
                        case "ADUMissingError":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.ADUMissingError.ToString());
                            break;

                        case "ADFCoverOpen":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.ADFCoverOpen.ToString());
                            break;

                        case "Drawer1Open":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer1Open.ToString());
                            break;

                        case "Drawer2Open":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer2Open.ToString());
                            break;

                        case "Drawer3Open":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer3Open.ToString());
                            break;

                        case "Drawer4Open":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer4Open.ToString());
                            break;
                        }
                    }
                }

                bool bDrawOpenNtfctnEnable = localSettings.Values.ContainsKey("DrawEmptyNtfctn") ? (bool)localSettings.Values["DrawEmptyNtfctn"] : false;
                if (bDrawOpenNtfctnEnable)
                {
                    foreach (statusDetailType type in statusTypes)
                    {
                        Helper.GetDisplayStrings(type.CodeName, out strTitle, out strContent);

                        switch (type.CodeName)
                        {
                        case "Drawer1PaperEmpty":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer1PaperEmpty.ToString());
                            break;

                        case "Drawer2PaperEmpty":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer2PaperEmpty.ToString());
                            break;

                        case "Drawer3PaperEmpty":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer3PaperEmpty.ToString());
                            break;

                        case "Drawer4PaperEmpty":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.Drawer4PaperEmpty.ToString());
                            break;
                        }
                    }
                }

                bool bUsedTonerFullNtfctnEnable = localSettings.Values.ContainsKey("NewWasteTonerNtfctn") ? (bool)localSettings.Values["NewWasteTonerNtfctn"] : false;
                if (bUsedTonerFullNtfctnEnable)
                {
                    bool bExitLoop = false;
                    foreach (statusDetailType type in statusTypes)
                    {
                        Helper.GetDisplayStrings(type.CodeName, out strTitle, out strContent);

                        switch (type.CodeName)
                        {
                        case "WasteTonerBoxNearFull":
                            NotificationHandler.PostAToast(strTitle, strContent, eNotification.NewWasteTonerBox.ToString());
                            bExitLoop = true;
                            break;
                        }

                        if (bExitLoop)
                        {
                            break;
                        }
                    }
                }
            }

            bool bJobNtfctnEnable = localSettings.Values.ContainsKey("JobSuspendNtfctn") ? (bool)localSettings.Values["JobSuspendNtfctn"] : false;

            if (bJobNtfctnEnable)
            {
                getAllWorkflowResponse1 allWorkflowResponse = await Stage2Interface.GetInstance().GetAllWorkFlows();

                int iAllWorkflows = allWorkflowResponse.getAllWorkflowResponse.WorkflowList.Length;

                foreach (workflowType workItem in allWorkflowResponse.getAllWorkflowResponse.WorkflowList)
                {
                    if (string.Equals(workItem.BasicInfo.Status, eNotification.Suspended.ToString(), StringComparison.CurrentCultureIgnoreCase) == true)
                    {
                        string stTemp = Helper.GetResourceString("ID_NT_TITLE_JOBSUSPEND");
                        strTitle   = workItem.Name + stTemp;
                        strContent = ((printJobType)workItem.StepInfo[0].Item).DocumentName;
                        NotificationHandler.PostAToast(strTitle, strContent, eNotification.Completed.ToString());
                    }
                }
            }
        }