Exemple #1
0
        internal static bool CheckEnvironment()
        {
            Task <bool> checking = CheckVersion();

            checking.Wait();
            if (!checking.Result)
            {
                MessageBox.Show(Encoding.UTF8.GetString(Convert.FromBase64String("VGhlIHZlcnNpb24gaXMgcmV2b2tlZA=="))
                                + "\n" + Encoding.UTF8.GetString(Convert.FromBase64String("UGxlYXNlIGRvd25sb2FkIHRoZSBuZXcgdmVyc2lvbiBmcm9tIHNreW1wLmlv")),
                                Encoding.UTF8.GetString(Convert.FromBase64String("SXMgbm90IGEgYnVn")), MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }

            UID = Hashing.GetMD5FromText(SystemFunctions.GetHWID());
            AesEncoder.Init();
#if (DEBUG)
#elif (BETA)
            if (!CheckInjection())
            {
                return(false);
            }
#else
            if (!CheckInjection())
            {
                return(false);
            }
#endif
            return(true);
        }
Exemple #2
0
        public async Task <ApiResponse <string> > Create(ProductRequest request)
        {
            if (string.IsNullOrEmpty(request.Name))
            {
                return(new ApiErrorResponse <string>(ConstantStrings.emptyNameFieldError));
            }
            var product = _mapper.Map <Product>(request);

            _db.Products.Add(product);
            await _db.SaveChangesAsync();

            var productImage = new ProductImage()
            {
                ImageUrl  = ConstantStrings.blankProductImageUrl,
                PublicId  = ConstantStrings.blankProductImagePublicId,
                Caption   = SystemFunctions.BlankProductImageCaption(product.Name),
                ProductId = _db.Products.Where(x => x.Name == request.Name).FirstOrDefaultAsync().Id,
                SortOrder = 1
            };

            _db.ProductImages.Add(productImage);
            await _db.SaveChangesAsync();

            return(new ApiSuccessResponse <string>(ConstantStrings.addSuccessfully));
        }
        public void TestTryGetDictVal()
        {
            var dict = new Dictionary <string, int>
            {
                ["Key1"] = 1,
                ["Key2"] = 2,
            };

            Assert.AreEqual(1, SystemFunctions.TryGetDictVal(dict, "Key1"));
            Assert.AreEqual(2, SystemFunctions.TryGetDictVal(dict, "Key2"));

            Assert.IsNull(SystemFunctions.TryGetDictVal(dict, "BadKey"));
            Assert.IsNull(SystemFunctions.TryGetDictVal(null, "Key1"));
            Assert.IsNull(SystemFunctions.TryGetDictVal(dict, null));
            Assert.IsNull(SystemFunctions.TryGetDictVal(Guid.NewGuid(), "Key1"));

            var objKey   = new object();
            var objValue = new Random();
            var dict2    = new Hashtable
            {
                [1]      = "One",
                ["Two"]  = Guid.Empty,
                [objKey] = objValue,
            };

            Assert.AreEqual("One", SystemFunctions.TryGetDictVal(dict2, 1));
            Assert.AreEqual(Guid.Empty, SystemFunctions.TryGetDictVal(dict2, "Two"));
            Assert.AreSame(objValue, SystemFunctions.TryGetDictVal(dict2, objKey));
        }
        public void TestGetDictVal()
        {
            var dict = new Dictionary <string, int>
            {
                ["Key1"] = 1,
                ["Key2"] = 2,
            };

            Assert.AreEqual(1, SystemFunctions.GetDictVal(dict, "Key1"));
            Assert.AreEqual(2, SystemFunctions.GetDictVal(dict, "Key2"));

            ExceptionAssert.Throws <KeyNotFoundException>(() => SystemFunctions.GetDictVal(dict, "BadKey"), "The given key \"BadKey\" was not present in the dictionary");
            ExceptionAssert.Throws <ArgumentNullException>(() => SystemFunctions.GetDictVal(null, "Key1"));
            ExceptionAssert.Throws <ArgumentNullException>(() => SystemFunctions.GetDictVal(dict, null));
            ExceptionAssert.Throws <ArgumentException>(() => SystemFunctions.GetDictVal(Guid.NewGuid(), "Key1"), $"Parameter \"dictionary\" must implement {nameof(IDictionary)} interface");

            var objKey   = new object();
            var objValue = new Random();
            var dict2    = new Hashtable
            {
                [1]      = "One",
                ["Two"]  = Guid.Empty,
                [objKey] = objValue,
            };

            Assert.AreEqual("One", SystemFunctions.GetDictVal(dict2, 1));
            Assert.AreEqual(Guid.Empty, SystemFunctions.GetDictVal(dict2, "Two"));
            Assert.AreSame(objValue, SystemFunctions.GetDictVal(dict2, objKey));
        }
        private void cancelAsyncButton_Click(System.Object sender, System.EventArgs e)
        {
            SystemFunctions.cancelAutomatedSearch();
            SystemFunctions.cancelQuickSearch();

            this.buttonWorkerCancel.Enabled = false;
        }
        private void tree_OnDeleteRequest(Object sender, DeleteRequestFromTreeEventArgs e)
        {
            try {
                var deletePath = e.Directory;

                // To simplify the code here there is only the RecycleBinWithQuestion or simulate possible here
                // (all others will be ignored)
                SystemFunctions.ManuallyDeleteDirectory(deletePath, ( DeleteModes )Settings.Default.delete_mode);

                // Remove root node
                this.tree.RemoveNode(deletePath);

                this.Data.AddLogMessage("Manually deleted: \"" + deletePath + "\" including all subdirectories");

                // Disable the delete button because the user has to re-scan after he manually deleted a directory
                this.btnDelete.Enabled = false;
            }
            catch (OperationCanceledException) {
                // The user canceled the deletion
            }
            catch (Exception ex) {
                this.Data.AddLogMessage("Could not manually delete \"" + e.Directory + "\" because of the following error: " + ex.Message);

                MessageBox.Show(this, "The directory was not deleted, because of the following error:" + Environment.NewLine + ex.Message);
            }
        }
Exemple #7
0
        public string SetVolume(int value)
        {
            if (_handle == IntPtr.Zero)
            {
                Reset();
            }

            if (value > 100.0 || value < 0.0)
            {
                return("Volume out of range");
            }

            if (_volume == value)
            {
                return("No volume change");
            }

            if (_volume < value)
            {
                int howManuClicksUp = (value - _volume) / 4;
                SystemFunctions.SendKey(_handle, SystemFunctions.UpArrow, howManuClicksUp);
                _volume = _volume + howManuClicksUp * 4;
            }
            else
            {
                int howManyClicksDown = (_volume - value) / 4;
                SystemFunctions.SendKey(_handle, SystemFunctions.DownArrow, howManyClicksDown);
                _volume = _volume - howManyClicksDown * 4;
            }

            return($"Volume set to {_volume}");
        }
        public void TestFormat()
        {
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy"));
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", "RU"));
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", "ru-ru"));
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", 25));   // ru
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", 1049)); // ru-RU
            Assert.AreEqual("31.01.2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d"));
            Assert.AreEqual("01/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", CultureInfo.InvariantCulture));
            Assert.AreEqual("01/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", 127)); // Invariant
            Assert.AreEqual("1/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", "en"));
            Assert.AreEqual("1/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", "en-US"));
            Assert.AreEqual("1/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", 9));    // en
            Assert.AreEqual("1/31/2018", SystemFunctions.Format(new DateTime(2018, 1, 31), "d", 1033)); // en-US
            Assert.AreEqual(6535.676.ToString("0,0.##"), SystemFunctions.Format(6535.676, "0,0.##"));
            Assert.AreEqual(6535.676.ToString("0,0.##", CultureInfo.InvariantCulture), SystemFunctions.Format(6535.676, "0,0.##", CultureInfo.InvariantCulture));

            Assert.AreEqual(new DateTime(2018, 1, 31).ToString((string)null), SystemFunctions.Format(new DateTime(2018, 1, 31), null));
            Assert.AreEqual(new DateTime(2018, 1, 31).ToString(null, CultureInfo.InvariantCulture), SystemFunctions.Format(new DateTime(2018, 1, 31), null, CultureInfo.InvariantCulture));
            Assert.IsNull(SystemFunctions.Format(null, "dd.MM.yyyy"));
            Assert.IsNull(SystemFunctions.Format(null, "dd.MM.yyyy", CultureInfo.InvariantCulture));

            ExceptionAssert.Throws <ArgumentException>(() => SystemFunctions.Format(new Random(), "0,0.##"), $"Parameter \"input\" must implement {nameof(IFormattable)} interface");
            ExceptionAssert.Throws <CultureNotFoundException>(() => SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", "BadCulture"));
            ExceptionAssert.Throws <CultureNotFoundException>(() => SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", 10000000));
            ExceptionAssert.Throws <ArgumentOutOfRangeException>(() => SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", -1));
            ExceptionAssert.Throws <ArgumentException>(() => SystemFunctions.Format(new DateTime(2018, 1, 31), "dd.MM.yyyy", new Random()), "Invalid type \"Random\" of formatProvider");
        }
        public StorageFeaturesWithConcurrentDictionary(StoreOptions options)
        {
            _options = options;

            SystemFunctions = new SystemFunctions(options);

            Transforms = options.Transforms.As <Marten.Transforms.Transforms>();
        }
Exemple #10
0
 public CoolToCil()
 {
     method    = new Current_Method();
     take_data = new Take_str("data");
     Data      = new Dictionary <string, string>();
     Data[""]  = "vacio";
     Code      = SystemFunctions.GetAllSysFunctions();
     Types     = new Dictionary <string, CIL_OneType>();
 }
        private void settingsButtonAutomated_Click(object sender, EventArgs e)
        {
            DialogResult response = MessageBoxFunctions.openMessageBoxWithResponse("The automatic search can take longer and cause problems with slow systems. Especially if you have more than two hard drives. If you continue your system might slow down.", "Attention");

            if (response == DialogResult.Yes)
            {
                SystemFunctions.startAutomatedSearch(this);
            }
        }
        private void settingsButtonQuickSearch_Click(object sender, EventArgs e)
        {
            DialogResult response = MessageBoxFunctions.openMessageBoxWithResponse("This automatic search only works if you've installed Among Us using Steam. If you didn't install the game using Steam, try using the Automated search", "Attention");

            if (response == DialogResult.Yes)
            {
                SystemFunctions.startQuickSearch(this);
            }
        }
Exemple #13
0
        public string TogglePlayPause()
        {
            if (_handle == IntPtr.Zero)
            {
                Reset();
            }

            SystemFunctions.SendKey(_handle, SystemFunctions.Space);
            return("Toggled");
        }
Exemple #14
0
        public string ToTop()
        {
            if (_handle == IntPtr.Zero)
            {
                Reset();
            }

            SystemFunctions.BringToForeground(_handle);
            return("top");
        }
 private void Default_SettingChanging(Object sender, SettingChangingEventArgs e)
 {
     if (e.SettingName == "keep_system_folders" && !( Boolean )e.NewValue)
     {
         if (MessageBox.Show(this, SystemFunctions.ConvertLineBreaks(Resources.warning_really_delete), Resources.warning, MessageBoxButtons.OKCancel,
                             MessageBoxIcon.Asterisk) == DialogResult.Cancel)
         {
             e.Cancel = true;
         }
     }
 }
Exemple #16
0
        /// <summary>
        /// Executes the specified parameter.
        /// </summary>
        /// <param name="param">The parameter.</param>
        public override void Execute(string param)
		{
			if (param == "sysinfo")
			{
				SystemFunctions.PrintInfo();
			}
            else if (param == "ram_info")
            {
                SystemFunctions.PrintRAMInfo();
            }
			else if (param == "ram_used")
			{
				SystemFunctions.PrintUsedRAM();
			}
			else if (param == "ram_free")
			{
				SystemFunctions.PrintFreeRAM();
			}
			else if (param == "ram_total")
			{
				SystemFunctions.PrintTotalRAM();
			}
			else if (param == "host")
			{
				Console.WriteLine(Kernel.Host);
			}
			else if (param == "lspci")
			{
				SystemFunctions.lspci();
			}
            else if (param == "lscpu")
            {
                SystemFunctions.lscpu();
            }
            else if (param == "list_vols")
			{
				FS.ListVols();
			}
			else if (param == "list_vol")
			{
				FS.ListVol();
			}
            else if (param == "fs_log")
            {
                Console.WriteLine("FS Log:");
                Console.WriteLine(ServiceLogging.PrintLog(MCS.FSService.ServiceLogger));
            }
		}
        //Settings Actions
        private void panelMenu_MouseUp(object sender, MouseEventArgs e)
        {
            if (new Point(this.Left, this.Top) == lastPointTmp || lastPointTmp == new Point(0, 0))
            {
                string url = "";
                switch (selectedMod)
                {
                case "The Other Roles":
                    url = TheOtherRoles.TheOtherRoles.projectUrl;
                    break;
                }

                if (!string.IsNullOrWhiteSpace(url))
                {
                    SystemFunctions.openLinkInBrowser(url);
                }
            }
        }
Exemple #18
0
        internal static bool CheckEnvironment()
        {
            UID = Hashing.GetMD5FromText(SystemFunctions.GetHWID());
            AesEncoder.Init();
#if (DEBUG)
#elif (BETA)
            if (!CheckInjection())
            {
                return(false);
            }
#else
            if (!CheckInjection())
            {
                return(false);
            }
#endif
            return(true);
        }
        public async Task <ApiResponse <string> > Create(int productId, ProductImageRequest request)
        {
            var productFromDb = await _db.Products.FindAsync(productId);

            if (productFromDb == null)
            {
                return(new ApiErrorResponse <string>(ConstantStrings.FindByIdError(productId)));
            }
            var productImageFromDb = await _db.ProductImages.Where(x => x.ProductId == productFromDb.Id)
                                     .OrderByDescending(x => x.SortOrder).ToListAsync();

            if (productFromDb == null)
            {
                return(new ApiErrorResponse <string>(ConstantStrings.FindByIdError(productId)));
            }
            if (request.ProductImages == null)
            {
                return(new ApiErrorResponse <string>(ConstantStrings.imgIsEmptyOrNull));
            }
            var images = request.ProductImages.ToList();

            for (int i = 0; i < images.Count; i++)
            {
                var uploadResult = await UploadImage(images[i]);

                if (uploadResult.Error != null)
                {
                    return(new ApiErrorResponse <string>(uploadResult.Error.ToString()));
                }
                var productImage = new ProductImage()
                {
                    ImageUrl  = uploadResult.SecureUrl.ToString(),
                    PublicId  = uploadResult.PublicId,
                    Caption   = SystemFunctions.ProductImageCaption(productFromDb.Name, productImageFromDb.FirstOrDefault().SortOrder + i + 1),
                    ProductId = productFromDb.Id,
                    SortOrder = productImageFromDb.FirstOrDefault().SortOrder + i + 1
                };
                _db.ProductImages.Add(productImage);
            }
            _db.ProductImages.Remove(productImageFromDb.Where(x => x.PublicId == ConstantStrings.blankProductImagePublicId).FirstOrDefault());
            await _db.SaveChangesAsync();

            return(new ApiSuccessResponse <string>(ConstantStrings.addSuccessfully));
        }
Exemple #20
0
        /// <summary>
        /// Initialise filesystem and system services
        /// </summary>
        protected override void BeforeRun()
        {
            Console.Clear();
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();
            try
            {
                /*
                 *
                 * SystemFunctions.IDEs = MDFS.Physical.IDE.Devices.ToArray();
                 * for (int i = 0; i < SystemFunctions.IDEs.Length; i++)
                 * {
                 *  new MDFS.DiskListing(i, SystemFunctions.IDEs[i]);
                 * }
                 */
                Kernel.IsLive = true;


                Level3.Init();

                //Kernel.Hostname = "MedliLive";
                Kernel.Running = true;
                Console.Clear();
                //Hardware.AddDisks.Detect();
                Console.Write(Kernel.Logo);
                Console.WriteLine(Kernel.Welcome);
                Console.WriteLine("");
                Console.WriteLine("Current system date and time:");
                Date.printDate();
                Time.printTime();
                SystemFunctions.PrintInfo();
            }
            catch (Exception ex)
            {
                Console.ReadKey();
                FatalError.Crash(ex);
            }
        }
        public void TestGetByIndex()
        {
            int[] intArray = { 100, 200 };
            Assert.AreEqual(100, SystemFunctions.GetByIndex(intArray, 0));
            Assert.AreEqual(200, SystemFunctions.GetByIndex(intArray, 1));

            Guid   guid = Guid.NewGuid();
            string str  = "Str";
            Random rnd  = new Random();

            object[] mixedArray = { guid, str, rnd };

            Assert.AreEqual(guid, SystemFunctions.GetByIndex(mixedArray, 0));
            Assert.AreEqual("Str", SystemFunctions.GetByIndex(mixedArray, 1));
            Assert.AreSame(rnd, SystemFunctions.GetByIndex(mixedArray, 2));

            IList <string> strList = new List <string> {
                "One", "Two"
            };

            Assert.AreEqual("One", SystemFunctions.GetByIndex(strList, 0));
            Assert.AreEqual("Two", SystemFunctions.GetByIndex(strList, 1));

            IList mixedList = new ArrayList();

            mixedList.Add(guid);
            mixedList.Add(str);
            mixedList.Add(rnd);

            Assert.AreEqual(guid, SystemFunctions.GetByIndex(mixedList, 0));
            Assert.AreEqual("Str", SystemFunctions.GetByIndex(mixedList, 1));
            Assert.AreSame(rnd, SystemFunctions.GetByIndex(mixedList, 2));

            ExceptionAssert.Throws <ArgumentNullException>(() => SystemFunctions.GetByIndex(null, 0));
            ExceptionAssert.Throws <ArgumentException>(() => SystemFunctions.GetByIndex(Guid.NewGuid(), 0), $"Parameter \"list\" must implement {nameof(IList)} interface");
            ExceptionAssert.Throws <IndexOutOfRangeException>(() => SystemFunctions.GetByIndex(mixedArray, -1));
            ExceptionAssert.Throws <IndexOutOfRangeException>(() => SystemFunctions.GetByIndex(mixedArray, 3));
        }
        public void TestTryGetByIndex()
        {
            int[] intArray = { 100, 200 };
            Assert.AreEqual(100, SystemFunctions.TryGetByIndex(intArray, 0));
            Assert.AreEqual(200, SystemFunctions.TryGetByIndex(intArray, 1));

            Guid   guid = Guid.NewGuid();
            string str  = "Str";
            Random rnd  = new Random();

            object[] mixedArray = { guid, str, rnd };

            Assert.AreEqual(guid, SystemFunctions.TryGetByIndex(mixedArray, 0));
            Assert.AreEqual("Str", SystemFunctions.TryGetByIndex(mixedArray, 1));
            Assert.AreSame(rnd, SystemFunctions.TryGetByIndex(mixedArray, 2));

            IList <string> strList = new List <string> {
                "One", "Two"
            };

            Assert.AreEqual("One", SystemFunctions.TryGetByIndex(strList, 0));
            Assert.AreEqual("Two", SystemFunctions.TryGetByIndex(strList, 1));

            IList mixedList = new ArrayList();

            mixedList.Add(guid);
            mixedList.Add(str);
            mixedList.Add(rnd);

            Assert.AreEqual(guid, SystemFunctions.TryGetByIndex(mixedList, 0));
            Assert.AreEqual("Str", SystemFunctions.TryGetByIndex(mixedList, 1));
            Assert.AreSame(rnd, SystemFunctions.TryGetByIndex(mixedList, 2));

            Assert.IsNull(SystemFunctions.TryGetByIndex(null, 0));
            Assert.IsNull(SystemFunctions.TryGetByIndex(Guid.NewGuid(), 0));
            Assert.IsNull(SystemFunctions.TryGetByIndex(mixedArray, -1));
            Assert.IsNull(SystemFunctions.TryGetByIndex(mixedArray, 3));
        }
Exemple #23
0
 public static void ScriptReferences()     //Assigns script references
 {
     systemListConstructor = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemListConstructor>();
     cameraFunctionsScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFunctions>();
     turnInfoScript        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <TurnInfo>();
     playerTurnScript      = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <PlayerTurn>();
     diplomacyScript       = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <DiplomacyControlScript>();
     systemGUI             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <SystemGUI>();
     heroGUI               = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <HeroGUI>();
     racialTraitScript     = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <RacialTraits> ();
     galaxyGUI             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <GalaxyGUI>();
     invasionGUI           = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <InvasionGUI> ();
     mapConstructor        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <MapConstructor> ();
     winConditions         = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <WinConditions> ();
     systemFunctions       = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemFunctions> ();
     systemInvasion        = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <SystemInvasions> ();
     uiObjects             = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <UIObjects> ();
     ambientStarRandomiser = GameObject.FindGameObjectWithTag("ScriptContainer").GetComponent <AmbientStarRandomiser> ();
     voronoiGenerator      = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <VoronoiGeneratorAndDelaunay> ();
     heroResource          = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <HeroResourceImprovement> ();
     systemPopup           = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <SystemInfoPopup> ();
     triangulation         = GameObject.FindGameObjectWithTag("GUIContainer").GetComponent <Triangulation> ();
 }
        public ActionResult Index(users param)
        {
            string typedPassword    = param.password;
            string dataBasePassword = (from u in db.users where u.login == param.login select u.password).FirstOrDefault();

            bool isValid = SystemFunctions.VerifyHash(typedPassword, dataBasePassword);

            if (isValid)
            {
                Session["logged"] = "HomeSweetHome";
                var userData = (from u in db.users
                                join t in db.usertype on u.idusertype equals t.id
                                where u.login == param.login select new {
                    u.id,
                    u.name,
                    t.description
                }).FirstOrDefault();

                int    userId        = userData.id;
                string userName      = userData.name;
                string userFirstName = userData.name.Split(' ').FirstOrDefault();

                Session["userId"]        = userId;
                Session["userName"]      = userName;
                Session["userFirstName"] = userFirstName;
                Session["userType"]      = userData.description;

                ViewBag.Error = null;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Session["logged"] = null;
                ViewBag.Error     = "Invalid data Input, try another Login or Password!";
                return(View());
            }
        }
        public override IEnumerable <MemberResult> GetDefinedMembers(int index, AstMemberType memberType, bool isMemberAccess = false)
        {
            HashSet <MemberResult> members = new HashSet <MemberResult>();

            HashSet <GeneroPackage> includedPackages = new HashSet <GeneroPackage>();

            if (memberType.HasFlag(AstMemberType.SystemTypes) && !isMemberAccess)
            {
                // Built-in types
                members.AddRange(BuiltinTypes.Select(x => new MemberResult(Tokens.TokenKinds[x], GeneroMemberType.Keyword, this)));

                foreach (var package in Packages.Values.Where(x => _importedPackages[x.Name] && x.ContainsInstanceMembers &&
                                                              (this.LanguageVersion >= x.MinimumLanguageVersion && this.LanguageVersion <= x.MaximumLanguageVersion)))
                {
                    members.Add(new MemberResult(package.Name, GeneroMemberType.Module, this));
                    includedPackages.Add(package);
                }
            }
            if (memberType.HasFlag(AstMemberType.Constants) && !isMemberAccess)
            {
                members.AddRange(SystemConstants.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion)
                                 .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Keyword, this)));
                members.AddRange(SystemMacros.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion)
                                 .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
            }
            if (memberType.HasFlag(AstMemberType.Variables) && !isMemberAccess)
            {
                members.AddRange(SystemVariables.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion)
                                 .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Keyword, this)));
            }
            if (memberType.HasFlag(AstMemberType.Functions) && !isMemberAccess)
            {
                members.AddRange(SystemFunctions.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion)
                                 .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Function, this)));
                foreach (var package in Packages.Values.Where(x => _importedPackages[x.Name] && x.ContainsStaticClasses &&
                                                              (this.LanguageVersion >= x.MinimumLanguageVersion && this.LanguageVersion <= x.MaximumLanguageVersion)))
                {
                    if (!includedPackages.Contains(package))
                    {
                        members.Add(new MemberResult(package.Name, GeneroMemberType.Module, this));
                    }
                }
            }

            // TODO: need to handle multiple results of the same name
            AstNode containingNode = GetContainingNode(_body, index);

            if (containingNode != null)
            {
                if (containingNode is IFunctionResult)
                {
                    if (memberType.HasFlag(AstMemberType.Variables))
                    {
                        members.AddRange((containingNode as IFunctionResult).Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)));
                        foreach (var varList in (containingNode as IFunctionResult).LimitedScopeVariables)
                        {
                            foreach (var item in varList.Value)
                            {
                                if (item.Item2.IsInSpan(index))
                                {
                                    members.Add(new MemberResult(item.Item1.Name, item.Item1, GeneroMemberType.Instance, this));
                                    break;
                                }
                            }
                        }
                    }
                    if (memberType.HasFlag(AstMemberType.SystemTypes))
                    {
                        members.AddRange((containingNode as IFunctionResult).Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Constants))
                    {
                        members.AddRange((containingNode as IFunctionResult).Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Functions))
                    {
                        foreach (var res in (containingNode as IFunctionResult).Variables /*.Where(x => x.Value.HasChildFunctions(this))
                                                                                           */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)))
                        {
                            if (!members.Contains(res))
                            {
                                members.Add(res);
                            }
                        }

                        foreach (var varList in (containingNode as IFunctionResult).LimitedScopeVariables)
                        {
                            foreach (var item in varList.Value)
                            {
                                if (item.Item2.IsInSpan(index))
                                {
                                    members.Add(new MemberResult(item.Item1.Name, item.Item1, GeneroMemberType.Instance, this));
                                    break;
                                }
                            }
                        }
                    }
                }

                if (_body is IModuleResult)
                {
                    // check for module vars, types, and constants (and globals defined in this module)
                    if (memberType.HasFlag(AstMemberType.Variables))
                    {
                        members.AddRange((_body as IModuleResult).Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)));
                        members.AddRange((_body as IModuleResult).GlobalVariables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.UserDefinedTypes))
                    {
                        members.AddRange((_body as IModuleResult).Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this)));
                        members.AddRange((_body as IModuleResult).GlobalTypes.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Constants))
                    {
                        members.AddRange((_body as IModuleResult).Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
                        members.AddRange((_body as IModuleResult).GlobalConstants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Dialogs))
                    {
                        members.AddRange((_body as IModuleResult).Functions.Where(x => x.Value is DeclarativeDialogBlock)
                                         .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Dialog, this)));
                        members.AddRange((_body as IModuleResult).FglImports.Select(x => new MemberResult(x, GeneroMemberType.Module, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Reports))
                    {
                        members.AddRange((_body as IModuleResult).Functions.Where(x => x.Value is ReportBlockNode)
                                         .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Report, this)));
                    }
                    if (memberType.HasFlag(AstMemberType.Functions))
                    {
                        members.AddRange((_body as IModuleResult).Functions
                                         .Where(x => !(x.Value is ReportBlockNode) && !(x.Value is DeclarativeDialogBlock))
                                         .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Method, this)));
                        foreach (var res in (_body as IModuleResult).Variables /*.Where(x => x.Value.HasChildFunctions(this))
                                                                                */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)))
                        {
                            if (!members.Contains(res))
                            {
                                members.Add(res);
                            }
                        }
                        foreach (var res in (_body as IModuleResult).GlobalVariables /*.Where(x => x.Value.HasChildFunctions(this))
                                                                                      */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)))
                        {
                            if (!members.Contains(res))
                            {
                                members.Add(res);
                            }
                        }
                    }

                    // Tables and cursors are module specific, and cannot be accessed via fgl import
                    if (memberType.HasFlag(AstMemberType.DeclaredCursors) ||
                        memberType.HasFlag(AstMemberType.PreparedCursors) ||
                        memberType.HasFlag(AstMemberType.Tables))
                    {
                        if (memberType.HasFlag(AstMemberType.DeclaredCursors))
                        {
                            members.AddRange((_body as IModuleResult).Cursors.Where(x => x.Value is DeclareStatement).Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.Cursor, this)));
                        }
                        if (memberType.HasFlag(AstMemberType.PreparedCursors))
                        {
                            members.AddRange((_body as IModuleResult).Cursors.Where(x => x.Value is PrepareStatement).Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.Cursor, this)));
                        }
                        if (memberType.HasFlag(AstMemberType.Tables))
                        {
                            members.AddRange((_body as IModuleResult).Tables.Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.DbTable, this)));
                        }
                    }
                    else
                    {
                        members.AddRange((_body as IModuleResult).FglImports.Select(x => new MemberResult(x, GeneroMemberType.Module, this)));
                    }
                }
            }

            // TODO: this could probably be done more efficiently by having each GeneroAst load globals and functions into
            // dictionaries stored on the IGeneroProject, instead of in each project entry.
            // However, this does required more upkeep when changes occur. Will look into it...
            if (_projEntry != null && _projEntry is IGeneroProjectEntry)
            {
                IGeneroProjectEntry genProj = _projEntry as IGeneroProjectEntry;
                if (genProj.ParentProject != null &&
                    !genProj.FilePath.ToLower().EndsWith(".inc"))
                {
                    foreach (var projEntry in genProj.ParentProject.ProjectEntries.Where(x => x.Value != genProj))
                    {
                        if (projEntry.Value.Analysis != null &&
                            projEntry.Value.Analysis.Body != null)
                        {
                            projEntry.Value.Analysis.Body.SetNamespace(null);
                            IModuleResult modRes = projEntry.Value.Analysis.Body as IModuleResult;
                            if (modRes != null)
                            {
                                // check global types
                                // TODO: need to add an option to enable/disable legacy linking (to not reference other modules' non-public members
                                if (memberType.HasFlag(AstMemberType.Variables))
                                {
                                    members.AddRange(modRes.GlobalVariables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)));
                                    members.AddRange(modRes.Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)));
                                }
                                if (memberType.HasFlag(AstMemberType.UserDefinedTypes))
                                {
                                    members.AddRange(modRes.GlobalTypes.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this)));
                                    members.AddRange(modRes.Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this)));
                                }
                                if (memberType.HasFlag(AstMemberType.Constants))
                                {
                                    members.AddRange(modRes.GlobalConstants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
                                    members.AddRange(modRes.Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this)));
                                }
                                if (memberType.HasFlag(AstMemberType.Dialogs))
                                {
                                    members.AddRange(modRes.Functions.Where(x => x.Value is DeclarativeDialogBlock)
                                                     .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Dialog, this)));
                                }
                                if (memberType.HasFlag(AstMemberType.Reports))
                                {
                                    members.AddRange(modRes.Functions.Where(x => x.Value is ReportBlockNode)
                                                     .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Report, this)));
                                }
                                if (memberType.HasFlag(AstMemberType.Functions))
                                {
                                    members.AddRange(modRes.Functions.Where(x => !(x.Value is ReportBlockNode) && !(x.Value is DeclarativeDialogBlock))
                                                     .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Method, this)));
                                    foreach (var res in modRes.GlobalVariables/*.Where(x =>
                                                                               * {
                                                                               * return x.Value.HasChildFunctions(this);
                                                                               * })*/
                                             .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)))
                                    {
                                        if (!members.Contains(res))
                                        {
                                            members.Add(res);
                                        }
                                    }
                                    foreach (var res in modRes.Variables/*.Where(x =>
                                                                         * {
                                                                         * return x.Value.HasChildFunctions(this);
                                                                         * })*/
                                             .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this)))
                                    {
                                        if (!members.Contains(res))
                                        {
                                            members.Add(res);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (memberType.HasFlag(AstMemberType.Functions))
            {
                _includePublicFunctions = true; // allow for deferred adding of public functions
            }

            if (memberType.HasFlag(AstMemberType.Tables))
            {
                _includeDatabaseTables = true;  // allow for deferred adding of external database tables
            }

            members.AddRange(this.ProjectEntry.GetIncludedFiles().Where(x => x.Analysis != null).SelectMany(x => x.Analysis.GetDefinedMembers(1, memberType)));

            return(members);
        }
 private void newVersionButton_Click(object sender, EventArgs e)
 {
     SystemFunctions.openLinkInBrowser(newVersionUrl);
     Application.Exit();
 }
Exemple #27
0
 public void Reset()
 {
     _handle = SystemFunctions.GetWindowConstains("bestplayer");
     SystemFunctions.SendKey(_handle, SystemFunctions.UpArrow, 25);
     _volume = 100;
 }
 private void settingsButton_Click(object sender, EventArgs e)
 {
     SystemFunctions.switchPanelVisibility(1, menuPanels, menuButtons, panelMenuActive);
 }
 private void logo_Click(object sender, EventArgs e)
 {
     SystemFunctions.openLinkInBrowser(projectUrl);
 }
 //Help Actions
 private void linkLabelResourcesGit_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     SystemFunctions.openLinkInBrowser(projectUrl);
 }