Example #1
0
        public static Container StartupAndRegisterClientServices(IConfiguration root, Container c)
        {
            try
            {
                var reg = new MyRegistry(root, Helper.GetPlatform().ToString());

                reg.For <MyRegistry>().Use(reg);
                c.Inject(typeof(Container), c);

                c.Configure(x =>
                {
                    x.AddRegistry(reg);
                });



                var clientServicePartitionValidator = c.GetInstance <ClientServicePartitionValidator>();
                clientServicePartitionValidator.ValidateServicePartitions();

                c.Inject <ClientServicePartitionValidator>(clientServicePartitionValidator);

                return(c);
            }
            catch (Exception e)
            {
                L.Trace(e.Message);
                if (e.InnerException != null)
                {
                    L.Trace($"Inner exception is {e.InnerException.Message}");
                    L.Trace($"{e.InnerException.StackTrace}");
                }
                L.Trace("Error on initialization ... quitting");
                throw e;
            }
        }
        public void GetViewSettingsTest()
        {
            string value = MyRegistry.GetViewSettings("VIEW_FirearmList", out _errOut, "In Stocks");

            TestContext.WriteLine(value);
            General.HasValue(value, _errOut);
        }
        public void GetSettingsTest()
        {
            string lastSucBackup          = "";
            bool   alertOnBackUp          = false;
            int    trackHistoryDays       = 30;
            bool   trackHistory           = false;
            bool   autoBackup             = false;
            bool   uoimg                  = false;
            bool   usePl                  = false;
            bool   useIPer                = false;
            bool   useCcid                = false;
            bool   useaa                  = false;
            bool   useAacid               = false;
            bool   useUniqueCustId        = false;
            bool   bUseselectiveboundbook = false;


            MyRegistry.GetSettings(out lastSucBackup, out alertOnBackUp, out trackHistoryDays, out trackHistory, out autoBackup, out uoimg, out usePl, out useIPer, out useCcid, out useaa, out useAacid, out useUniqueCustId, out bUseselectiveboundbook, out _errOut);

            TestContext.WriteLine($"lastSucBackup: {lastSucBackup}");
            TestContext.WriteLine($"alertOnBackUp: {alertOnBackUp}");
            TestContext.WriteLine($"trackHistoryDays: {trackHistoryDays}");
            TestContext.WriteLine($"trackHistory: {trackHistory}");
            TestContext.WriteLine($"autoBackup: {autoBackup}");
            TestContext.WriteLine($"uoimg: {uoimg}");
            TestContext.WriteLine($"usePl: {usePl}");
            TestContext.WriteLine($"useIPer: {useIPer}");
            TestContext.WriteLine($"useCcid: {useCcid}");
            TestContext.WriteLine($"useaa: {useaa}");
            TestContext.WriteLine($"useAacid: {useAacid}");
            TestContext.WriteLine($"useUniqueCustId: {useUniqueCustId}");
            TestContext.WriteLine($"bUseselectiveboundbook: {bUseselectiveboundbook}");

            General.HasValue(trackHistory.ToString(), _errOut);
        }
        public void UpDateAppDetailsTest()
        {
            string path  = AppDomain.CurrentDomain.BaseDirectory;
            bool   value = MyRegistry.UpDateAppDetails("1.0", "My Gun Collection Unit Test", path, $"{path}", Path.Combine(path, "log.err"), _databasePath, Path.GetFullPath(_databasePath), out _errOut);

            General.HasTrueValue(value, _errOut);
        }
        public void GetLastWorkingDirTest()
        {
            string value = MyRegistry.GetLastWorkingDir(out _errOut);

            TestContext.WriteLine(value);
            General.HasValue(value, _errOut);
        }
Example #6
0
        public TransactionRoles(ClientServicePartitionValidator validator, IClientFactory factory, MyRegistry reg)
        {
            this.factory   = factory;
            this.validator = validator;
            this.reg       = reg;

            roleCheck = EnumHelper.EnumPrompt <RoleCheck>();
        }
Example #7
0
 public VMuseRegistry(MyRegistry root, VMfunction parent) : base(root, parent)
 {
     this.CommandOpen = new DelegateCommand(() => new RegistryWindow()
     {
         DataContext = this
     }.ShowDialog());
     this.CommandSet = new DelegateCommand(() => this.SetVar = this.Parent.SelectVar());
 }
Example #8
0
 private static string Convert(MyRegistry input, Function f, ref int i)
 {
     return(string.Join("\n", new List <string> {
         string.Format("{0}const reg = await get{1}Registry(namespace.{2}).catch(function (error) {{", Indent(i), input.Variable.Value.Type.Name.Replace("My", ""), input.Variable.Value.ObjectName),
         string.Format("{0}throw new Error('[{1}] An error occurred: ' + error);", Indent(i + 1), f.Name),
         string.Format("{0}}});", Indent(i)),
         string.Format("{0}await reg.{1}({2}).catch(function (error) {{", Indent(i), input.Action, ConvertOutput(input.Variable.Output)),
         string.Format("{0}throw new Error('[{1}] An error occurred: ' + error);", Indent(i + 1), f.Name),
         string.Format("{0}}});", Indent(i))
     }));
 }
        public void GetHotxesTest()
        {
            List <HotFixList> value = MyRegistry.GetHotxes(out _errOut);

            foreach (HotFixList h in value)
            {
                TestContext.WriteLine($"id: {h.Id}");
                TestContext.WriteLine($"DateInstalled: {h.DateInstalled}");
                TestContext.WriteLine($"Was from Install: {h.WasFromInstall}");
            }
            General.HasTrueValue(value.Count > 0, _errOut);
        }
Example #10
0
        static void Main(string[] args)
        {
            var registry = new MyRegistry();
            var catalog  = registry.catalogManager.CreateNewCatalog();

            registry.catalogManager.FillLiteratureContent(catalog);
            registry.catalogPrinter.PrintLiteratureContent(catalog);
            registry.catalogPrinter.PrintMusicContent(catalog);
            registry.catalogManager.FillMusicContent(catalog);
            registry.catalogPrinter.PrintMusicContent(catalog);
            Console.ReadKey();
        }
Example #11
0
        public ClientServicePartitionValidator(ILogger <Test> logger, Container c, MyRegistry reg, ClientFactory factory)
        {
            this.logger        = logger;
            this.reg           = reg;
            this.c             = c;
            this.clientFactory = factory;
            if (!Directory.Exists(reg.DataDirectory + "/db"))
            {
                Directory.CreateDirectory(reg.DataDirectory + "/db");
            }
            dbConnection = reg.DataDirectory + "/db/client.mdb";

            c.Inject(typeof(IClientFactory), factory);
        }
Example #12
0
        public LoadFuzzyNames(ClientServicePartitionValidator validator,IClientFactory factory,MyRegistry reg)
        {
            this.factory = factory;
            this.validator = validator;
            this.reg = reg;
            Console.WriteLine($"Enter file name from '{reg.DataDirectory}\\input' or 'y' to use default ('Retail-Large.csv')");
            var s = Console.ReadLine().ToLower();
            if (s == "y")
                DataFile = $"{reg.DataDirectory}\\input\\Retail-Large.csv";
            else
            {
                DataFile = $"{reg.DataDirectory}\\input\\s";
            }

            if (File.Exists(DataFile) == false)
                throw new Exception($"File does not exist - {DataFile}");
        }
Example #13
0
        public LoadFromCSV(ClientServicePartitionValidator validator, IClientFactory factory, MyRegistry reg)
        {
            this.factory   = factory;
            this.reg       = reg;
            this.validator = validator;


            dataType = EnumHelper.Parse <DataType>(Helper.Prompt($"Enter type of data - {EnumHelper.ListValues(typeof(DataType))}"));

            if (dataType == DataType.Party)
            {
                partyType = EnumHelper.EnumPrompt <Party.Types.PartyType>();
            }

            if (dataType == DataType.AccountToParty)
            {
                linkageDirection = EnumHelper.EnumPrompt <LinkageDirection>();
            }
        }
Example #14
0
        public FrmMain()
        {
            InitializeComponent();

            // Form initial settings
            ShowInTaskbar = false;
            Visible       = false;

            // Add app to Startup
            if (Properties.Settings.Default.AddedToStartup)
            {
                return;
            }
            MyRegistry.AddToStartup();
            Properties.Settings.Default.AddedToStartup = true;

            // Error handling for application
            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += CrashHandler;
            Application.ThreadException      += CrashHandler_thread;
        }
Example #15
0
        static void Main(string[] args)
        {
            try
            {
                Container c = null;
                if (args.Length == 0)
                {
                    throw new Exception("Invalid argument - expecting name of node from appsettings.json, e.g., 'Apple'");
                }
                var reg = new MyRegistry(args[0]);
                c = new Container(reg);
                reg.For <IContainer>().Use(c);



                c.GetInstance <Node>().Run();

                /*
                 *
                 * var workers = c.GetInstance<WorkerActors>();
                 *
                 * for (byte i = 0; i < workers.NumNodes; i++)
                 * {
                 *  var z = new MyWorkerActor($"{workers.Service}_{i}",i,c.GetInstance<IWorker>());
                 *  z.Run();
                 * }
                 */

                Console.ReadLine();
                L.CloseLog();
            }
            catch (Exception e)
            {
                L.Exception(e);
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
        public void SaveFirearmListSortTest()
        {
            bool value = MyRegistry.SaveFirearmListSort("In Stock", out _errOut);

            General.HasTrueValue(value, _errOut);
        }
Example #17
0
        public void HideRows()
        {
            if (gridView1.Rows.Count <= 0)
            {
                return;
            }

            var isUpdateAvailable = false;

            // Row associated with the currency manager's position cannot be made invisible
            var currencyManager = (CurrencyManager)BindingContext[gridView1.DataSource];

            currencyManager.SuspendBinding();

            foreach (DataGridViewRow row in gridView1.Rows)
            {
                // Make row invisible whose folder not exists
                if (Directory.Exists(Convert.ToString(row.Cells["InstallationFolder"].Value)))
                {
                    row.Visible = true;

                    #region Toggle button enabling as per key availability

                    if (MyRegistry.CheckKeyExistence(row.Cells["RegistryKey"].Value.ToString())) //Key exist true
                    {
                        var button = (DataGridViewDisableButtonCell)row.Cells["OpenDirectory"];

                        if (button.Enabled)
                        {
                            button.Enabled  = false;
                            button.ReadOnly = true;
                            button.UseColumnTextForButtonValue = false;
                            button.Value = "Already installed";
                        }

                        UpdaterNotifyIcon.Text = "No new updates";
                        UpdaterNotifyIcon.Icon = Properties.Resources.AppIco;
                    }
                    else
                    {
                        var button = (DataGridViewDisableButtonCell)row.Cells["OpenDirectory"];
                        if (!button.Enabled)
                        {
                            button.Enabled = true;
                            button.UseColumnTextForButtonValue = false;
                            button.Value = "Open";
                        }

                        isUpdateAvailable      = true;
                        UpdaterNotifyIcon.Text = "Updates available!";
                        UpdaterNotifyIcon.Icon = Properties.Resources.IcoUpdateReady;
                    }

                    #endregion
                }
                else
                {
                    row.Visible = false;
                    if (!isUpdateAvailable)
                    {
                        UpdaterNotifyIcon.Text = "No new updates";
                        UpdaterNotifyIcon.Icon = Properties.Resources.AppIco;
                    }
                }
            }

            currencyManager.ResumeBinding();
        }
        public void SetSettingDetailsTest()
        {
            bool value = MyRegistry.SetSettingDetails(out _errOut);

            General.HasTrueValue(value, _errOut);
        }
 /// <summary>
 /// Mies the gun collection is installed.
 /// </summary>
 /// <param name="errOut">The error out.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public static bool MyGunCollectionIsInstalled(out string errOut)
 {
     return(MyRegistry.MyGunCollectionIsInstalled(out errOut));
 }
        public void SaveLastWorkingDirTest()
        {
            bool value = MyRegistry.SaveLastWorkingDir(Path.GetFullPath(_databasePath), out _errOut);

            General.HasTrueValue(value, _errOut);
        }
Example #21
0
        static void Main(string[] args)
        {
            try
            {
                var s2 = Stopwatch.StartNew();
                for (int i = 0; i < 1000000; i++)
                {
                    var stream = new MemoryStream(Encoding.UTF8.GetBytes("this is a blooming small test"));
                    var z22    = MurMurHash3.Hash(stream);
//                    var mm1 = z22 % 100;
                }
                s2.Stop();
                var q24 = s2.ElapsedMilliseconds;

                Container c   = null;
                var       reg = new MyRegistry(args.Any() == false ? "appsettings.json" : args[0]);
                c = new Container(reg);
                reg.For <IContainer>().Use(c);


                var databasePath = reg.DataDirectory;

                var db = new SQLiteConnection(databasePath + "\\client.mdb");

                db.CreateTable <ClientWithBucket>();

                bool clearBucketState = false;
                if (clearBucketState)
                {
                    db.Delete <ClientWithBucket>("IFuzzyMatcher");
                }

                var clientFactory = new ClientFactory(c);

                var bucketMax = clientFactory.GetClientBuckets <IFuzzyMatcher>().Max();
                var bucketMin = clientFactory.GetClientBuckets <IFuzzyMatcher>().Min();

                if (bucketMin != 0)
                {
                    throw new Exception($"Minimum bucket is not zero it is - {bucketMin} - should be zero");
                }

                if (db.Find <ClientWithBucket>("IFuzzyMatcher") == null)
                {
                    db.Insert(new ClientWithBucket {
                        BucketCount = bucketMax, ClientName = "IFuzzyMatcher"
                    });
                }
                else
                {
                    var ppp = db.Find <ClientWithBucket>("IFuzzyMatcher");
                    if (ppp.BucketCount != bucketMax)
                    {
                        throw new Exception($"We have (dynamic) bucketMax for 'IFuzzyMatcher = {bucketMax} - but last recorded run bucketMax was - {ppp.BucketCount}... cannot continue - need to match bucketCount - or rebuild");
                    }
                }

                var multiplexer = new Multiplexer <FuzzyWordEntry>(bucketMax + 1 /*number of buckets*/);

                CsvReader rdr     = new CsvReader(new StreamReader(@"C:\home\colin\as\input\Retail-Large.csv"));
                var       records = rdr.GetRecords <Retail>();
                records.Take(100000)
                .Do(x => multiplexer.Add(x.Name, new FuzzyWordEntry {
                    DocId = Int32.Parse(x.Id), Phrase = x.Name
                }));

                List <Task> tasks = new List <Task>();
                multiplexer.GetBuckets().Do(x =>
                {
                    tasks.Add(new Task(() => clientFactory.GetClient <IFuzzyMatcher>(x.Item1).AddEntry(x.Item2)));
                    tasks.Last().Start();
                });

                Task.WaitAll(tasks.ToArray());

                foreach (var bucket in clientFactory.GetClientBuckets <IFuzzyMatcher>())
                {
                    var z = clientFactory.GetClient <IFuzzyMatcher>(bucket);

                    if (false)
                    {
                    }
                    else
                    {
                        var q = z.FuzzyQuery(new List <string>(new[]
                                                               { "aleshia tomkiewicz", "daniel towers", "morna dick", "colin dick" }));

                        foreach (var g in q)
                        {
                            Console.WriteLine(g.Query);
                            foreach (var n in g.Detail)
                            {
                                Console.WriteLine($"            {n.Candidate} - {n.Score} - {n.PhraseId}");
                            }
                        }
                    }
                }
                Console.ReadLine();
                L.CloseLog();
            }
            catch (Exception e)
            {
                L.Exception(e);
            }
        }
        /// <summary>
        /// Finds the next command for auto completion
        /// </summary>
        /// <param name="partialCommand">The partial command being completed</param>
        /// <param name="lastResult">The last result returned. Null to get the first match</param>
        /// <param name="registries">The list of registries to search for matches</param>
        /// <returns>The next command matching the partial string</returns>
        public static string FindNextCommand(ReadOnlySpan <char> partialCommand, ReadOnlySpan <char> lastResult, IEnumerable <TerminalRegistry> registries)
        {         //****************************************
            ReadOnlySpan <char> CommandText, PartialText;
            ReadOnlySpan <char> Prefix       = default;
            ReadOnlySpan <char> InstanceName = default;

            int CharIndex;

            TerminalTypeSet?     TypeSet = null;
            TerminalTypeInstance?TypeInstance;

            var PartialMatches = new List <string>();

            //****************************************

            if (partialCommand.StartsWith("help ".AsSpan(), StringComparison.InvariantCultureIgnoreCase))
            {
                partialCommand = partialCommand.Slice(5);

                Prefix = "Help ".AsSpan();
            }

            //****************************************

            // Find the first word (split on a space)
            CharIndex = partialCommand.IndexOf(' ');

            // If there's a space, we're parsing an Instance Type and optional Instance Name, with a partial Command/Variable
            if (CharIndex != -1)
            {
                CommandText = partialCommand.Slice(0, CharIndex);
                PartialText = partialCommand.Slice(CharIndex + 1);

                CharIndex = CommandText.IndexOf('.');

                // Split into Type and Name if necessary
                if (CharIndex != -1)
                {
                    InstanceName = CommandText.Slice(CharIndex + 1);
                    CommandText  = CommandText.Slice(0, CharIndex);
                }

                foreach (var Registry in registries)
                {
                    if (Registry.TryGetTypeSet(CommandText, out TypeSet))
                    {
                        break;
                    }
                }

                // If the instance type doesn't match, return the partial command as is
                if (TypeSet == null)
                {
                    return(Prefix.Concat(partialCommand));
                }

                if (InstanceName == null)
                {
                    TypeInstance = TypeSet.Default;
                    CommandText  = TypeSet.TypeName.AsSpan();
                }
                else
                {
                    if (!TypeSet.TryGetNamedInstance(InstanceName, out TypeInstance))
                    {
                        return(Prefix.Concat(partialCommand));
                    }

                    CommandText = $"{TypeSet.TypeName}.{TypeInstance.Name}".AsSpan();
                }

                // If the instance doesn't exist, return as is
                if (TypeInstance == null)
                {
                    return(Prefix.Concat(partialCommand));
                }

                // Add matching commands
                foreach (var MyCommand in TypeInstance.Type.Commands)
                {
                    if (MyCommand.Name.StartsWith(PartialText, StringComparison.InvariantCultureIgnoreCase))
                    {
                        PartialMatches.Add(CommandText.Concat(" ", MyCommand.Name));
                    }
                }

                // Add matching variables
                foreach (var MyVariable in TypeInstance.Type.Variables)
                {
                    if (MyVariable.Name.StartsWith(PartialText, StringComparison.InvariantCultureIgnoreCase))
                    {
                        PartialMatches.Add(CommandText.Concat(" ", MyVariable.Name));
                    }
                }
            }
            else
            {
                CharIndex = partialCommand.IndexOf('.');

                // If there's a dot, we're parsing an Instance Type, with a partial Instance Name
                if (CharIndex != -1)
                {
                    CommandText = partialCommand.Slice(0, CharIndex);
                    PartialText = partialCommand.Slice(CharIndex + 1);

                    foreach (var MyRegistry in registries)
                    {
                        if (MyRegistry.TryGetTypeSet(CommandText, out TypeSet))
                        {
                            break;
                        }
                    }

                    // If the instance type doesn't match, return the partial command as is
                    if (TypeSet == null)
                    {
                        return(Prefix.Concat(partialCommand));
                    }

                    foreach (var MyInstanceName in TypeSet.Instances)
                    {
                        if (MyInstanceName.StartsWith(PartialText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            PartialMatches.Add(string.Format("{0}.{1}", TypeSet.TypeName, MyInstanceName));
                        }
                    }
                }
                else
                {
                    // No dot, we're parsing a partial Command/Variable/Instance Type
                    foreach (var Registry in registries)
                    {
                        // Add matching commands
                        foreach (var Command in Registry.Commands)
                        {
                            if (Command.Name.StartsWith(partialCommand, StringComparison.InvariantCultureIgnoreCase))
                            {
                                PartialMatches.Add(Command.Name);
                            }
                        }

                        // Add matching variables (with an equals sign, so they can't be the same as commands)
                        foreach (var Variable in Registry.Variables)
                        {
                            if (Variable.Name.StartsWith(partialCommand, StringComparison.InvariantCultureIgnoreCase))
                            {
                                PartialMatches.Add(Variable.Name);
                            }
                        }

                        foreach (var Instance in Registry.DefaultInstances)
                        {
                            foreach (var Command in Instance.Type.Commands)
                            {
                                if (Command.Name.StartsWith(partialCommand, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    PartialMatches.Add(Command.Name);
                                }
                            }

                            // Add matching variables (with an equals sign, so they can't be the same as commands)
                            foreach (var Variable in Instance.Type.Variables)
                            {
                                if (Variable.Name.StartsWith(partialCommand, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    PartialMatches.Add(Variable.Name);
                                }
                            }
                        }

                        // Add matching type sets
                        foreach (var Type in Registry.TypeSets)
                        {
                            // Only add ones that have an instance
                            if (Type.TypeName.StartsWith(partialCommand, StringComparison.InvariantCultureIgnoreCase) && Type.HasInstance)
                            {
                                PartialMatches.Add(Type.TypeName);
                            }
                        }
                    }
                }
            }

            //****************************************

            // Any results?
            if (PartialMatches.Count == 0)
            {
                return("");
            }

            // Sort them, so we can pick the next matching result
            PartialMatches.Sort();

            if (lastResult != null)
            {
                // Find one greater than our last match (user has requested the next one)
                foreach (var NextCommand in PartialMatches)
                {
                    if (NextCommand.AsSpan().CompareTo(lastResult, StringComparison.OrdinalIgnoreCase) > 0)
                    {
                        return(Prefix.Concat(NextCommand));
                    }
                }
                // Nothing greater, go back to the start
            }

            return(Prefix.Concat(PartialMatches[0]));
        }
 /// <summary>
 /// Gets the database location.
 /// </summary>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.String.</returns>
 public static string GetDatabaseLocation(out string errOut)
 {
     return(MyRegistry.GetDatabaseLocation(out errOut));
 }
Example #24
0
 public GenerateTestFiles(MyRegistry reg)
 {
     this.reg = reg;
     TransactionsPerRetailCustomer = Int32.Parse(As.Shared.Helper.Prompt("Number of transactions per customer"));
 }
 /// <summary>
 /// Gets the MGC executable path.
 /// </summary>
 /// <param name="errOut">The error out.</param>
 /// <returns>System.String.</returns>
 public static string GetMgcExePath(out string errOut)
 {
     return(MyRegistry.GetMgcExePath(out errOut));
 }