예제 #1
0
        private static void Initialize(IEnumerable <Service> services)
        {
            var allServices = new [] { new UnifiedService() }.Concat(services);

            PlatformManager.InitializePlatform(new WindowsUnix());

            // Initialize the PhoneBook
            var locale = Platform.GetCurrentLocale();

            PhoneBook.Mcc      = "000"; //TODO
            PhoneBook.Mnc      = "000"; //TODO
            PhoneBook.Language = locale.Substring(0, 2);
            PhoneBook.Country  = locale.Substring(3, locale.Length - 3);

            // Uncomment if you want to get information from the Framework
            Utils.Logging = true;

            PlatformManager.InitializeMain(allServices.ToArray());

            Settings = MutableSettingsManager.Load <TerminalSettings>();

            BubbleGroupEvents.OnBubbleInserted += (bubble, bubbleGroup) =>
            {
                var textBubble = bubble as TextBubble;
                if (textBubble != null)
                {
                    Console.WriteLine("Message " + (textBubble.Direction == Bubble.BubbleDirection.Incoming ? "from" : "to") + ": " + bubbleGroup.Title + " (" + bubbleGroup.Address + "): " + textBubble.Message);
                }
            };
        }
예제 #2
0
        public void TestSave()
        {
            var terminalSettings = new TerminalSettings
            {
                Command   = Command,
                Arguments = Arguments
            };
            var repositoryMock = new Mock <IRepository <TerminalSettings> >();

            repositoryMock
            .Setup(m => m.Upsert(It.IsAny <string>(), terminalSettings))
            .Verifiable();
            var uowMock = new Mock <IUnitOfWork>();

            uowMock
            .Setup(m => m.GetRepository <TerminalSettings>())
            .Returns(repositoryMock.Object);
            var uowFactoryMock = new Mock <IUnitOfWorkFactory>();

            uowFactoryMock
            .Setup(m => m.Create())
            .Returns(uowMock.Object);
            var processServiceMock = new Mock <IProcessService>();

            var terminalService = new TerminalService(processServiceMock.Object, uowFactoryMock.Object);

            terminalService.SetTerminalSettings(terminalSettings);

            repositoryMock.Verify(m => m.Upsert(It.IsAny <string>(), terminalSettings));
        }
예제 #3
0
        public void SetTerminalSettings(TerminalSettings terminalSettings)
        {
            using var uow = _unitOfWorkFactory.Create();
            var repository = uow.GetRepository <TerminalSettings>();

            repository.Upsert(TerminalSettingsId, terminalSettings);
        }
예제 #4
0
        public void TestGetSaved()
        {
            var savedTerminalSettings = new TerminalSettings
            {
                Command   = "SavedCommand",
                Arguments = "SavedArguments"
            };
            var repositoryMock = new Mock <IRepository <TerminalSettings> >();

            repositoryMock
            .Setup(m => m.GetById(It.IsAny <string>()))
            .Returns(savedTerminalSettings);
            var uowMock = new Mock <IUnitOfWork>();

            uowMock
            .Setup(m => m.GetRepository <TerminalSettings>())
            .Returns(repositoryMock.Object);
            var uowFactoryMock = new Mock <IUnitOfWorkFactory>();

            uowFactoryMock
            .Setup(m => m.Create())
            .Returns(uowMock.Object);
            var processServiceMock = new Mock <IProcessService>();

            var terminalService = new TerminalService(processServiceMock.Object, uowFactoryMock.Object);

            var terminalSettings = terminalService.GetTerminalSettings();

            Assert.Equal(savedTerminalSettings, terminalSettings);
        }
        public TerminalOptionsViewModel(
            TerminalSettingsRepository settingsRepository)
        {
            this.settingsRepository = settingsRepository;

            //
            // Read current settings.
            //
            // NB. Do not hold on to the settings object because other tabs
            // might apply changes to other application settings.
            //
            var settings = this.settingsRepository.GetSettings();

            this.IsCopyPasteUsingCtrlCAndCtrlVEnabled =
                settings.IsCopyPasteUsingCtrlCAndCtrlVEnabled.BoolValue;
            this.IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled =
                settings.IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled.BoolValue;
            this.IsSelectAllUsingCtrlAEnabled =
                settings.IsSelectAllUsingCtrlAEnabled.BoolValue;
            this.IsSelectUsingShiftArrrowEnabled =
                settings.IsSelectUsingShiftArrrowEnabled.BoolValue;
            this.IsQuoteConvertionOnPasteEnabled =
                settings.IsQuoteConvertionOnPasteEnabled.BoolValue;
            this.IsNavigationUsingControlArrrowEnabled =
                settings.IsNavigationUsingControlArrrowEnabled.BoolValue;
            this.IsScrollingUsingCtrlUpDownEnabled =
                settings.IsScrollingUsingCtrlUpDownEnabled.BoolValue;
            this.IsScrollingUsingCtrlHomeEndEnabled =
                settings.IsScrollingUsingCtrlHomeEndEnabled.BoolValue;
            this.terminalFont = new Font(
                settings.FontFamily.StringValue,
                TerminalSettings.FontSizeFromDword(settings.FontSizeAsDword.IntValue));

            this.isDirty = false;
        }
예제 #6
0
    public void TestGetSaved()
    {
        var savedTerminalSettings = new TerminalSettings
        {
            Command   = "SavedCommand",
            Arguments = "SavedArguments"
        };
        var repositoryMock = new Mock <IRepository <TerminalSettings> >();

        repositoryMock
        .Setup(m => m.GetById(It.IsAny <string>()))
        .Returns(savedTerminalSettings);
        var uowMock = new Mock <IUnitOfWork>();

        uowMock
        .Setup(m => m.GetRepository <TerminalSettings>())
        .Returns(repositoryMock.Object);
        _autoMocker
        .Setup <IUnitOfWorkFactory, IUnitOfWork>(m => m.Create())
        .Returns(uowMock.Object);

        var terminalService = _autoMocker.CreateInstance <TerminalService>();

        var(command, arguments) = terminalService.GetTerminalSettings();
        Assert.Equal(savedTerminalSettings.Arguments, arguments);
        Assert.Equal(savedTerminalSettings.Command, command);
    }
예제 #7
0
 private static TerminalSettingsStateModel CreateFrom(TerminalSettings model) =>
 model is null
         ? null
         : new TerminalSettingsStateModel
 {
     Arguments = model.Arguments,
     Command   = model.Command
 };
        public void DeleteTerminalSettings(TerminalSettings terminalSettings)
        {
            if (terminalSettings == null)
            {
                throw new ArgumentNullException(nameof(terminalSettings));
            }

            _context.TerminalSettings.Remove(terminalSettings);
        }
예제 #9
0
        public void SaveChanges()
        {
            var settings = new TerminalSettings
            {
                Command   = TerminalCommandText,
                Arguments = TerminalCommandArguments
            };

            _terminalService.SetTerminalSettings(settings);
        }
        public void AddTerminalSettings(Guid terminalSettingsId, TerminalSettings terminalSettings)
        {
            if (terminalSettingsId == null)
            {
                throw new ArgumentNullException(nameof(terminalSettingsId));
            }

            terminalSettings.Id = terminalSettingsId;

            _context.TerminalSettings.Add(terminalSettings);
        }
        public void UpdateTerminalSettings(Guid terminalSettingsId, TerminalSettings terminalSettings)
        {
            if (terminalSettingsId == null || terminalSettings == null)
            {
                throw new ArgumentNullException(nameof(UpdateTerminalSettings));
            }

            terminalSettings.Id = terminalSettingsId;

            _context.TerminalSettings.Update(terminalSettings);
        }
예제 #12
0
        public InternalTerminalInstance(ProtocolType protocol, InternalPoderosaInstance _internalPoderosaWorld, ITerminalParameter _IterminalParameter)
        {
            _basePoderosaInstance = _internalPoderosaWorld;
            _window = _basePoderosaInstance.WindowManagerPlugin.CreateLibraryMainWindow();

            _protocol = protocol;

            _terminalSettings  = new TerminalSettings();
            _terminalParameter = _IterminalParameter;
            _terminalView      = _window.ViewManager.GetCandidateViewForNewDocument();
        }
        public object Deserialize(StructuredText node) {
            PipeTerminalSettings ts = new PipeTerminalSettings();

            StructuredText baseNode = node.GetChildOrNull(0);
            if (baseNode != null) {
                TerminalSettings baseTs = PipePlugin.Instance.SerializeService.Deserialize(baseNode) as TerminalSettings;
                if (baseTs != null) {
                    ts.Import(baseTs);
                }
            }
            return ts;
        }
        public void AddTerminalSettings(TerminalSettings terminalSettings)
        {
            if (terminalSettings == null)
            {
                throw new ArgumentNullException(nameof(terminalSettings));
            }

            terminalSettings.Id = Guid.NewGuid();


            _context.TerminalSettings.Add(terminalSettings);
        }
예제 #15
0
 public static LicenceKey ReadLicenceKey(LicenceKey settings, string path, string filename)
 {
     //string filename = "StartUpSettings.xml";
     try
     {
         XmlSerializer x      = new XmlSerializer(typeof(LicenceKey));
         StreamReader  reader = new StreamReader(path + filename);
         settings = (LicenceKey)x.Deserialize(reader);
         reader.Dispose();
         return(settings);
     }
     catch
     {
         return(settings);
     }
 }
예제 #16
0
        public void WhenKeyEmpty_ThenDefaultsAreProvided()
        {
            var baseKey    = hkcu.CreateSubKey(TestKeyPath);
            var repository = new TerminalSettingsRepository(baseKey);

            var settings = repository.GetSettings();

            Assert.IsTrue(settings.IsCopyPasteUsingCtrlCAndCtrlVEnabled.BoolValue);
            Assert.IsFalse(settings.IsSelectAllUsingCtrlAEnabled.BoolValue);
            Assert.IsTrue(settings.IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled.BoolValue);
            Assert.IsTrue(settings.IsSelectUsingShiftArrrowEnabled.BoolValue);
            Assert.IsTrue(settings.IsQuoteConvertionOnPasteEnabled.BoolValue);
            Assert.IsTrue(settings.IsNavigationUsingControlArrrowEnabled.BoolValue);
            Assert.IsTrue(settings.IsScrollingUsingCtrlUpDownEnabled.BoolValue);
            Assert.IsTrue(settings.IsScrollingUsingCtrlHomeEndEnabled.BoolValue);
            Assert.AreEqual(TerminalFont.DefaultFontFamily, settings.FontFamily.StringValue);
            Assert.AreEqual(TerminalFont.DefaultSize,
                            TerminalSettings.FontSizeFromDword(settings.FontSizeAsDword.IntValue));
        }
예제 #17
0
        public TerminalCommands()
        {
            TerminalSettings settings = new TerminalSettings();

            //settings.TerminalId = Global.terminalId;
            //settings.LogDir = Global.terminalLog;
            terminal = new SIX.TimApi.Terminal(settings);
            terminal.ActivateCompleted     += new ActivateCompletedEventHandler(terminal_ActivateComplete);
            terminal.DeactivateCompleted   += new DeactivateCompletedEventHandler(terminal_DeactivateComplete);
            terminal.TerminalStatusChanged += new Terminal.TerminalStatusChangedHandler(terminal_TerminalStatusChanged);
            terminal.TransactionCompleted  += new Terminal.TransactionCompletedEventHandler(terminal_TransactionCompleted);
            terminal.BalanceCompleted      += new Terminal.BalanceCompletedEventHandler(terminal_BalanceCompleted);
            terminal.PrintOptions.Cardholder.PrintWidth = Global.sixPrintReceiptWidth;


            _balanceTimer          = new Timer();
            _balanceTimer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            _balanceTimer.Interval = Global.BalanceTimer;
            _balanceTimer.Enabled  = true;
        }
예제 #18
0
        private static void Initialize(IEnumerable<Service> services)
        {
            var allServices = new [] { new UnifiedService() }.Concat(services);

            PlatformManager.InitializePlatform(new WindowsUnix());

            // Initialize the PhoneBook
            var locale = Platform.GetCurrentLocale();
            PhoneBook.Mcc = "000"; //TODO
            PhoneBook.Mnc = "000"; //TODO
            PhoneBook.Language = locale.Substring(0, 2);
            PhoneBook.Country = locale.Substring(3, locale.Length - 3);

            // Uncomment if you want to get information from the Framework
            Utils.Logging = true;

            PlatformManager.InitializeMain(allServices.ToArray());

            Settings = MutableSettingsManager.Load<TerminalSettings>();

            BubbleGroupEvents.OnBubbleInserted += (bubble, bubbleGroup) =>
            {
                var textBubble = bubble as TextBubble;
                if (textBubble != null)
                {
                    Console.WriteLine("Message " + (textBubble.Direction == Bubble.BubbleDirection.Incoming ? "from" : "to") + ": " + bubbleGroup.Title + " (" + bubbleGroup.Address + "): " + textBubble.Message);
                }
            };
        }
예제 #19
0
        public override void ValidateTerminalData(ConfigSerializer serializer)
        {
            try
            {
                if (serializer != null)
                {
                    byte []     tlv = null;
                    RETURN_CODE rt  = IDT_Augusta.SharedController.emv_retrieveTerminalData(ref tlv);

                    if (rt == RETURN_CODE.RETURN_CODE_DO_SUCCESS)
                    {
                        Debug.WriteLine("VALIDATE TERMINAL DATA ----------------------------------------------------------------------");

                        // Get Configuration File AID List
                        SortedDictionary <string, string> cfgTerminalData      = serializer.GetTerminalData(serialNumber, EMVKernelVer);
                        Dictionary <string, Dictionary <string, string> > dict = Common.processTLV(tlv);

                        bool update = false;

                        // TAGS from device
                        foreach (Dictionary <string, string> devCollection in dict.Where(x => x.Key.Equals("unencrypted")).Select(x => x.Value))
                        {
                            foreach (var devTag in devCollection)
                            {
                                string devTagName  = devTag.Key;
                                string cfgTagValue = "";
                                bool   tagfound    = false;
                                bool   tagmatch    = false;
                                foreach (var cfgTag in cfgTerminalData)
                                {
                                    // Matching TAGNAME: compare keys
                                    if (devTag.Key.Equals(cfgTag.Key, StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        tagfound = true;
                                        //Debug.Write("key: " + devTag.Key);

                                        // Compare value
                                        if (cfgTag.Value.Equals(devTag.Value, StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            tagmatch = true;
                                            //Debug.WriteLine(" matches value: {0}", (object) devTag.Value);
                                        }
                                        else
                                        {
                                            //Debug.WriteLine(" DOES NOT match value: {0}!={1}", devTag.Value, cfgTag.Value);
                                            cfgTagValue = cfgTag.Value;
                                            update      = true;
                                        }
                                        break;
                                    }
                                    if (tagfound)
                                    {
                                        break;
                                    }
                                }
                                if (tagfound)
                                {
                                    Debug.WriteLine("TAG: {0} FOUND AND IT {1}", devTagName.PadRight(6, ' '), (tagmatch ? "MATCHES" : "DOES NOT MATCH"));
                                    if (!tagmatch)
                                    {
                                        Debug.WriteLine("{0}!={1}", devTag.Value, cfgTagValue);
                                    }
                                }
                                else
                                {
                                    Debug.WriteLine("TAG: {0} NOT FOUND", (object)devTagName.PadRight(6, ' '));
                                    update = true;
                                }
                            }
                        }

                        // Update Terminal Data
                        if (update)
                        {
                            TerminalSettings termsettings = serializer.GetTerminalSettings();
                            string           workerstr    = termsettings.MajorConfiguration;
                            string           majorcfgstr  = Regex.Replace(workerstr, "[^0-9.]", string.Empty);
                            int majorcfgint = 5;
                            if (Int32.TryParse(majorcfgstr, out majorcfgint))
                            {
                                rt = IDT_Augusta.SharedController.emv_setTerminalMajorConfiguration(majorcfgint);
                                if (rt == RETURN_CODE.RETURN_CODE_DO_SUCCESS)
                                {
                                    try
                                    {
                                        List <byte[]> collection = new List <byte[]>();
                                        foreach (var item in cfgTerminalData)
                                        {
                                            byte [] bytes   = null;
                                            string  payload = string.Format("{0}{1:X2}{2}", item.Key, item.Value.Length / 2, item.Value).ToUpper();
                                            if (System.Text.RegularExpressions.Regex.IsMatch(item.Value, @"[g-zG-Z\x20\x2E]+"))
                                            {
                                                List <byte> byteArray = new List <byte>();
                                                byteArray.AddRange(Device_IDTech.HexStringToByteArray(item.Key));
                                                byte [] item1   = Encoding.ASCII.GetBytes(item.Value);
                                                byte    itemLen = Convert.ToByte(item1.Length);
                                                byte [] item2   = new byte[] { itemLen };
                                                byteArray.AddRange(item2);
                                                byteArray.AddRange(item1);
                                                bytes = new byte[byteArray.Count];
                                                byteArray.CopyTo(bytes);
                                                //Logger.debug( "device: ValidateTerminalData() DATA={0}", BitConverter.ToString(bytes).Replace("-", string.Empty));
                                            }
                                            else
                                            {
                                                bytes = Device_IDTech.HexStringToByteArray(payload);
                                            }
                                            collection.Add(bytes);
                                        }
                                        var     flattenedList = collection.SelectMany(bytes => bytes);
                                        byte [] terminalData  = flattenedList.ToArray();
                                        rt = IDT_Augusta.SharedController.emv_setTerminalData(terminalData);
                                        if (rt != RETURN_CODE.RETURN_CODE_DO_SUCCESS)
                                        {
                                            Debug.WriteLine("emv_setTerminalData() error: {0}", rt);
                                            Logger.error("device: ValidateTerminalData() error={0} DATA={1}", rt, BitConverter.ToString(terminalData).Replace("-", string.Empty));
                                        }
                                    }
                                    catch (Exception exp)
                                    {
                                        Debug.WriteLine("device: ValidateTerminalData() - exception={0}", (object)exp.Message);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.WriteLine("TERMINAL DATA: emv_retrieveTerminalData() - ERROR={0}", rt);
                    }
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine("device: ValidateTerminalData() - exception={0}", (object)exp.Message);
            }
        }
예제 #20
0
        public void ReadConfig()
        {
            try
            {
                JsonSerializer serializer = new JsonSerializer();
                string         path       = System.IO.Directory.GetCurrentDirectory();
                fileName = path + "\\" + JSON_CONFIG;
                string FILE_CFG = File.ReadAllText(fileName);

                //string s = @"{ ""ModelFirmware"": { ""VP5300"": [ ""VP5300 FW v1.00.028.0192.S"", ""VP5300 FW v1.00.028.0192.S Test"" ] } }";
                //var Json = JsonConvert.DeserializeObject<EMVDeviceSettings>(s);
                //string s = @"{ ""GroupTags"": { ""0"": [ ""9F53"" ], ""1"": [ ""DFED0A"" ] } }";
                //var Json = JsonConvert.DeserializeObject<EMVGroupTags>(s);
                //string s = @"{ ""GroupTags"": { ""0"": [ ""9F53"" ], ""1"": [ ""DFED0A"" ] } }";
                //EMVGroupTags Json = JsonConvert.DeserializeObject<EMVGroupTags>(s);

                terminalCfg = JsonConvert.DeserializeObject <TerminalConfiguration>(FILE_CFG);

                if (terminalCfg != null)
                {
                    // devConfig
                    DeviceConfig = terminalCfg.Configuration.First();
                    // Manufacturer
                    Debug.WriteLine("device configuration: manufacturer ----------------: [{0}]", (object)DeviceConfig.ConfigurationID.Manufacturer);
                    // Models
                    md = DeviceConfig.ConfigurationID.Models;
                    //DisplayCollection(mf.modelFirmware, "modelFirmware");
                    // AID List
                    aid.Aid = DeviceConfig.EMVConfiguration.AIDList;
                    //DisplayCollection(aid.Aid, "AIDList");
                    // CAPK List
                    capk.CAPK = DeviceConfig.EMVConfiguration.CAPKList;
                    //DisplayCollection(capk.Capk, "CapkList");
                    // Terminal Settings
                    termSettings = DeviceConfig.EMVConfiguration.TerminalSettings;
                    //Debug.WriteLine("device configuration: Terminal Settings --------------");
                    //Debug.WriteLine("MajorConfiguration        : {0}", (object) termSettings.MajorConfiguration);
                    //Debug.WriteLine("MajorConfigurationChecksum: {0}", (object) termSettings.MajorConfigurationChecksum[0]);
                    // SerialNumberTag
                    //Debug.WriteLine("device configuration: Serial Number TAG -----------: [{0}]", (object) termSettings.SerialNumberTag);
                    // TerminalData
                    //DisplayCollection(termSettings.TerminalData, "Terminal Data");
                    // TransactionTagsRequested
                    //DisplayCollection(termSettings.TransactionTags, "TransactionTagsRequested");
                    // TransactionValues
                    emvTransactionData = DeviceConfig.EMVTransactionData;
                    //DisplayCollection(transactionValues.EMVKernelMapping, "EMVKernelMapping");
                    //DisplayCollection(transactionValues.TransactionStartTags, "TransactionStartTags");
                    //DisplayCollection(transactionValues.TransactionAuthenticateTags, "TransactionAuthenticateTags");
                    //DisplayCollection(transactionValues.TransactionCompleteTags, "TransactionCompleteTags");
                    emvDeviceSettings = DeviceConfig.EMVDeviceSettings;
                    foreach (var devSettings in emvDeviceSettings)
                    {
                        EMVGroupTags item = new EMVGroupTags(devSettings.GroupTags);
                        emvGroupTags.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("JsonSerializer: exception: {0}", (object)ex.Message);
            }
        }