Ejemplo n.º 1
0
 /// <summary>
 /// Start application in FrontOffice mode.
 /// Please see IN009005 and IN009034 for details.
 /// </summary>
 private static void StartPOSFrontOffice()
 {
     if (!GlobalFramework.AppUseBackOfficeMode)
     {
         LogicPos logicPos = new LogicPos();
         logicPos.StartApp(AppMode.FrontOffice);
     }
     else
     {
         LogicPos logicPos = new LogicPos();
         logicPos.StartApp(AppMode.Backoffice);
     }
 }
Ejemplo n.º 2
0
        public LicenseRouter()
        {
            //Local Vars
            string dialogMessage = string.Empty;

            if (showDebug)
            {
                _log.Debug("Debug Mode");
            }

            _loadApp = true;

#if (DEBUG)
            GlobalFramework.LicenceDate       = DateTime.Now.ToString("dd/MM/yyyy");
            GlobalFramework.LicenceVersion    = "POS_CORPORATE";
            GlobalFramework.LicenceName       = "DEBUG";
            GlobalFramework.LicenceHardwareId = "####-####-####-####-####-####";
            //Company Details
            GlobalFramework.LicenceCompany   = "Empresa Demonstração";
            GlobalFramework.LicenceNif       = "NIF Demonstração";
            GlobalFramework.LicenceAddress   = "Morada Demonstração";
            GlobalFramework.LicenceEmail     = "*****@*****.**";
            GlobalFramework.LicenceTelephone = "DEBUG";
#else
            if (showDebug)
            {
                _log.Debug("Not Debug Mode");
            }
#endif

#if (!DEBUG)
            if (showDebug)
            {
                _log.Debug("Before GetLicenceInfo");
            }

            GetLicenceInfo();

            try
            {
                // If Plugin is Not Registered in Container
                if (GlobalFramework.PluginLicenceManager == null)
                {
                    if (showDebug)
                    {
                        _log.Debug("Skip License Manager, Plugin is Not Registered!");
                    }
                }
                // If Plugin Registered in Container
                else
                {
                    byte[] registredLicence = new byte[0];

                    hardwareID = GlobalFramework.PluginLicenceManager.GetHardwareID();
                    GlobalFramework.LicenceHardwareId = hardwareID;
                    _log.Debug("Detected hardwareID: " + GlobalFramework.LicenceHardwareId);
                    string version = "logicpos";

                    //Try Update Licence
                    try
                    {
                        if (GlobalFramework.PluginLicenceManager.GetLicenseInformation().Count > 0)
                        {
                            version = GlobalFramework.PluginLicenceManager.GetLicenseInformation()["version"].ToString();
                        }

                        //Compare WS License with Local License (GlobalFramework.LicenceVersion)
                        registredLicence = GlobalFramework.PluginLicenceManager.GetLicence(hardwareID, version);

                        //If Diferent Licenses return 1 byte and update local license file, else if equal return byte 0, skipping if
                        if (showDebug)
                        {
                            _log.Debug("registredLicence.Length: " + registredLicence.Length);
                        }

                        if (registredLicence.Length > 0)
                        {
                            string completeFilePath = string.Format("{0}{1}", LicenseRouter.GetCurrentDirectory(), GlobalFramework.PluginLicenceManager.GetLicenseFilename());
                            completeFilePath = completeFilePath.Replace("\\", "/");
                            //Used to generate diferent license file names per HardwareId : to Enable find "completeFilePath"
                            //string completeFilePath = GetCurrentDirectory() + string.Format("logicpos_{0}.license", textBoxHardwareID.Text);

                            WriteByteArrayToFile(registredLicence, completeFilePath);

                            Utils.ShowMessageTouch(null, DialogFlags.Modal, new System.Drawing.Size(600, 300), MessageType.Info, ButtonsType.Close, Resx.global_information, Resx.dialog_message_license_updated);

                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message);
                    }
                    //Detected Blocked Version : Code must be here to works with Online and Offline Mode
                    if (version == "LOGICPOS_BLOCK")
                    {
                        Utils.ShowMessageTouch(null, DialogFlags.Modal, new System.Drawing.Size(600, 300), MessageType.Error, ButtonsType.Close, Resx.global_error, Resx.dialog_message_license_blocked);

                        return;
                    }
                }

                if (showDebug)
                {
                    _log.Debug("Check if need register");
                }

                if (NeedToRegister())
                {
                    if (showDebug)
                    {
                        _log.Debug("Need Register");
                    }

                    //Show Form Register
                    if (showDebug)
                    {
                        _log.Debug("ShowDialog");
                    }
                    LicenseUIResult licenseUIResult = PosLicenceDialog.GetLicenseDetails(hardwareID);
                }
                else
                {
                    _loadApp = true;
                    GlobalFramework.LicenceRegistered = true;
                    _log.Debug("LicenceRegistered: " + GlobalFramework.LicenceRegistered);
                }
            }
            catch (Exception ex)
            {
                _log.Error("Cannot connect with the intellilock WebService: " + ex.Message, ex);
            }
#endif

            if (showDebug)
            {
                _log.Debug("loadPOS = " + _loadApp);
            }

            if (_loadApp)
            {
                LogicPos logicPos = new LogicPos();
                if (showDebug)
                {
                    _log.Debug("StartApp: AppMode.FrontOffice");
                }
                logicPos.StartApp(AppMode.FrontOffice);
            }

            if (showDebug)
            {
                _log.Debug("end");
            }
        }