private string StartUploadFile(HttpFileCollection httpFileCollection, string folder, string fullDir)
        {
            string tag = "[UploadMultipleFiles][StartUploadFile]";

            LogHelpers.WriteStatus(tag, "Folder: " + folder, "Start...");
            //=---
            if (httpFileCollection == null)
            {
                return(string.Empty);
            }
            //----
            string result = string.Empty;

            foreach (string fName in httpFileCollection)
            {
                try
                {
                    HttpPostedFile file = httpFileCollection[fName];
                    //---
                    string fileName = Path.GetFileName(file.FileName);

                    string dir = Path.Combine(fullDir, folder);

                    //---
                    file.SaveAs(Path.Combine(fullDir, fileName));
                    //---
                    fileName = Path.Combine(folder, fileName);
                    if (string.IsNullOrEmpty(result))
                    {
                        result = fileName;
                    }
                    else
                    {
                        result += "|" + fileName;
                    }
                }
                catch (Exception ex)
                {
                    LogHelpers.WriteException(tag, ex.ToString());
                }
            }

            return(result);
        }
Beispiel #2
0
        public async Task <bool> UpdateData(string id, Accounttbl obj)
        {
            try
            {
                if (id != obj.Username)
                {
                    return(false);
                }

                using (var context = new smlpobDB())
                {
                    context.Accounttbl.Attach(obj);
                    context.Entry(obj).Property(x => x.AccountNo).IsModified       = true;
                    context.Entry(obj).Property(x => x.Username).IsModified        = true;
                    context.Entry(obj).Property(x => x.Password).IsModified        = true;
                    context.Entry(obj).Property(x => x.RoleName).IsModified        = true;
                    context.Entry(obj).Property(x => x.IsEmailVerified).IsModified = true;


                    await context.SaveChangesAsync();

                    /*
                     * MembershipUser user = Membership.GetUser(obj.username);
                     * if (user != null)
                     * {
                     *  user.IsApproved = true;
                     *
                     *  user.UnlockUser();
                     *  Membership.UpdateUser(user);
                     * }*/

                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelpers.source  = this.GetType().Name;
                LogHelpers.message = ex.Message;
                LogHelpers.user    = "";
                LogHelpers.WriteLog();
            }

            return(false);
        }
        ////////////////

        public static void ApplyAllImplantsToChest(Chest chest)
        {
            var mymod  = ChestImplantsMod.Instance;
            var config = ChestImplantsConfig.Instance;

            // Get chest tile and name
            Tile   chestTile = Main.tile[chest.x, chest.y];
            string chestName;

            if (!TileFrameHelpers.VanillaChestTypeNamesByFrame.TryGetValue(chestTile.frameX / 36, out chestName))
            {
                throw new ModHelpersException("Could not find chest frame");
            }
//LogHelpers.Log("chest "+i+" pos:"+mychest.x+","+mychest.y+", frame:"+(mytile.frameX/36)+", wall:"+mytile.wall+" "+(mychest.item[0]!=null?mychest.item[0].Name:"..."));

            // Apply random implants
            foreach (ChestImplanterSetDefinition setDef in config.GetRandomImplanterSets())
            {
                ChestImplanter.ApplyRandomImplantsSetToChest(chest, chestName, setDef);
            }

            string propName         = nameof(ChestImplantsConfig.AllFromSetChestImplanterDefinitions);
            var    chestImplantDefs = config.Get <ChestImplanterSetDefinition>(propName);

            // Apply guaranteed implants
            foreach (Ref <ChestImplanterDefinition> implantDef in chestImplantDefs.Value)
            {
                ChestImplanter.ApplyImplantToChest(chest, implantDef.Value, chestName);
            }

            foreach ((string name, CustomChestImplanter customStuffer) in mymod.CustomImplanter)
            {
                if (ChestImplantsConfig.Instance.DebugModeInfo)
                {
                    LogHelpers.Log(
                        "ApplyAllImplantsToChest CUSTOM "
                        + "'" + chest.GetHashCode() + " " + chestName + "'"
                        + "- " + name + " at " + chest.x + "," + chest.y
                        );
                }

                customStuffer.Invoke(chestName, chest);
            }
        }
        private static void ReadStreamIntoContainer(BinaryReader reader, StreamProtocol fieldContainer)
        {
            IOrderedEnumerable <FieldInfo> orderedFields = fieldContainer.OrderedFields;
            int i = 0;

            if (ModHelpersMod.Config.DebugModePacketInfo)
            {
                LogHelpers.Log("  Begun reading packet " + fieldContainer.GetType().Name + " (" + fieldContainer.FieldCount + " fields)");
            }

            foreach (FieldInfo field in orderedFields)
            {
                i++;

                Type   fieldType = field.FieldType;
                object fieldData = StreamProtocol.ReadStreamValue(reader, fieldType);

                if (Main.netMode == 1)
                {
                    if (Attribute.IsDefined(field, typeof(ProtocolWriteIgnoreServerAttribute)))
                    {
                        continue;
                    }
                }
                else if (Main.netMode == 2)
                {
                    if (Attribute.IsDefined(field, typeof(ProtocolWriteIgnoreClientAttribute)))
                    {
                        continue;
                    }
                }

                if (ModHelpersMod.Config.DebugModePacketInfo)
                {
                    LogHelpers.Log("  * Reading packet " + fieldContainer.GetType().Name
                                   + " field (" + i + " of " + fieldContainer.FieldCount + ") " + field.Name
                                   + ": " + DotNetHelpers.Stringify(fieldData, 32));
                }

//LogHelpers.Log( "READ "+ fieldContainer.GetType().Name + " FIELD " + field + " VALUE " + fieldData );
                field.SetValue(fieldContainer, fieldData);
            }
        }
        protected void grvSubOtherItems_Sorting(object sender, GridViewSortEventArgs e)
        {
            string tag = __tag + "[grvSubOtherItems_Sorting]";

            try
            {
                string sortExpression = e.SortExpression;
                int    colIndex       = 0;
                foreach (DataControlField col in grvSubOtherItems.Columns)
                {
                    if (col.SortExpression == e.SortExpression)
                    {
                        break;
                    }

                    colIndex++;
                }

                Image sortImage = new Image();
                sortImage.CssClass = "imgSortStyle";

                if (GridViewSortDirection == SortDirection.Ascending)
                {
                    GridViewSortDirection = SortDirection.Descending;
                    SortGridView(sortExpression, DESCENDING);
                    //---
                    sortImage.ImageUrl = Utilities.GetSortImageUrl("ImageSortDesc");
                }
                else
                {
                    GridViewSortDirection = SortDirection.Ascending;
                    SortGridView(sortExpression, ASCENDING);
                    //---
                    sortImage.ImageUrl = Utilities.GetSortImageUrl("ImageSortAsc");
                }

                grvSubOtherItems.HeaderRow.Cells[colIndex].Controls.Add(sortImage);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
        }
Beispiel #6
0
        public static IWebElement FindElementOrTimeOut(this IWebDriver driver, By by, int timeoutInMilliseconds = 2500)
        {
            try
            {
                if (timeoutInMilliseconds <= 0)
                {
                    return(driver.FindElement(by));
                }

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(timeoutInMilliseconds));
                return(wait.Until(webDriver => webDriver.FindElement(by)));
            }

            catch (Exception exception)
            {
                LogHelpers.WriteToLog($"[ERROR] :: Element Not Found :: {by} :: {exception.Message}");
                throw new NoSuchElementException($"No Such Element: {by}");
            }
        }
        /// <summary>
        /// Loads the UI for mod configs.
        /// </summary>
        /// <param name="config"></param>
        public static void OpenModConfigUI(ModConfig config)
        {
            Type interfaceType = ReflectionHelpers.GetMainAssembly()
                                 .GetType("Terraria.ModLoader.UI.Interface");

            if (!Main.gameMenu)
            {
                IngameOptions.Close();
                IngameFancyUI.CoverNextFrame();
                Main.playerInventory = false;
                Main.editChest       = false;
                Main.npcChatText     = "";
                Main.inFancyUI       = true;
            }
            else
            {
                if (!ReflectionHelpers.Get(interfaceType, null, "modConfigID", out Main.menuMode))
                {
                    LogHelpers.Warn("Could not get Interface.modConfigID");
                    return;
                }
            }

            UIState modConfigInterfaceObj;

            if (!ReflectionHelpers.Get(interfaceType, null, "modConfig", out modConfigInterfaceObj) || modConfigInterfaceObj == null)
            {
                LogHelpers.Warn("Could not get Interface.modConfig");
                return;
            }

            object _;

            if (!ReflectionHelpers.RunMethod(modConfigInterfaceObj, "SetMod", new object[] { config.mod, config }, out _))
            {
                LogHelpers.Warn("Could not run Interface.modConfig.SetMod");
                return;
            }

            Main.InGameUI.SetState(modConfigInterfaceObj);

            Main.PlaySound(SoundID.MenuTick);
        }
        private void LoadOuter()
        {
            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.Promises          = new Promises();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers               = new BuffHelpers();
            this.NetHelpers                = new NetHelpers();
            this.ItemIdentityHelpers       = new ItemIdentityHelpers();
            this.NPCIdentityHelpers        = new NPCIdentityHelpers();
            this.ProjectileIdentityHelpers = new ProjectileIdentityHelpers();
            this.BuffIdentityHelpers       = new BuffIdentityHelpers();
            this.NPCBannerHelpers          = new NPCBannerHelpers();
            this.RecipeIdentityHelpers     = new RecipeIdentityHelpers();
            this.RecipeGroupHelpers        = new RecipeGroupHelpers();
            this.PlayerHooks               = new ExtendedPlayerHooks();
            this.WorldStateHelpers         = new WorldStateHelpers();
            this.ControlPanel              = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomEntMngr         = new CustomEntityManager();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XnaHelpers();
            this.ServerInfo            = new ServerInfo();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo    = new SupportInfoDisplay();
            this.RecipeHack     = new RecipeHack();
            this.ModListHelpers = new ModListHelpers();
        }
Beispiel #9
0
        public void StartLoadProjectInfo(int id)
        {
            string tag = __tag + "[StartLoadProjectInfo]";

            //---
            LogHelpers.WriteStatus(tag, "Id = " + id, "Start...");
            //---
            if (id <= 0)
            {
                return;
            }
            _selectedId = id;

            try
            {
                var result = ProjectsDAL.GetAllFromParent(id);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    //---
                    return;
                }

                lbError.Visible = false;
                //---
                StartLoadProjectDetail(result.Data.Tables[0].Rows[0]);
                //---
                _itemsCount = result.Data.Tables[1].Rows.Count;
                //---
                lvProjectsCarousel.DataSource = result.Data.Tables[1];
                lvProjectsCarousel.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //---
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }

            LogHelpers.WriteStatus(tag, "End.");
        }
Beispiel #10
0
        public int GetTotalPages()
        {
            string       src = HttpUtils.MakeHttpGet(String.Format(LIST_PAGE_URL, 1));
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(src);

            LogHelpers.LogDebug("LHMANGA: pagesource " + src);
            HtmlNode ul = doc.DocumentNode.Descendants().FirstOrDefault(x => x.GetAttributeValue("class", "").Contains("pagination"));

            LogHelpers.LogDebug("LHMANGA: found pagination.");
            LogHelpers.LogDebug("LHMANGA: " + ul.OuterHtml);
            List <HtmlNode> liList = ul.Descendants("li").ToList();
            HtmlNode        a      = liList[liList.Count - 2].Descendants().FirstOrDefault(x => x.Name.Equals("a"));
            string          href   = a.GetAttributeValue("href", "");

            LogHelpers.LogDebug("LHMANGA: last page index " + a.OuterHtml);
            return(int.TryParse(a.InnerText, out int idx) ? idx : 1);
        }
Beispiel #11
0
        ////////////////

        public bool Spend(int points, Player forPlayer)
        {
            if (this.ProgressPoints < points)
            {
                return(false);
            }

            var mymod = RewardsMod.Instance;

            this.ProgressPoints -= points;

            if (mymod.SettingsConfig.DebugModePPInfo && points != 0)
            {
                LogHelpers.Alert("PP spent: " + points + " (now " + this.ProgressPoints
                                 + " for " + (forPlayer.name) + ")");
            }

            return(true);
        }
        private void ComputeGroups <T>(IList <KeyValuePair <string, Func <T, bool> > > matchers,
                                       ref IDictionary <string, ReadOnlySet <int> > groups,
                                       ref IDictionary <int, ReadOnlySet <string> > groups_per_ent) where T : Entity
        {
            var raw_groups_per_ent = new Dictionary <int, ISet <string> >();

            IList <T> pool = this.GetPool <T>();

            foreach (var kv in matchers)
            {
                string         grp_name = kv.Key;
                Func <T, bool> matcher  = kv.Value;
                var            grp      = new HashSet <int>();

                for (int i = 1; i < pool.Count; i++)
                {
                    try {
                        if (matcher(pool[i]))
                        {
                            grp.Add(i);
                        }
                    } catch (Exception) {
                        LogHelpers.Log("EntityGroups.ComputeGroups - Compute fail for '" + grp_name + "' with ent (" + i + ") " + (pool[i] == null?"null":pool[i].ToString()));
                    }
                }

                groups[grp_name] = new ReadOnlySet <int>(grp);

                foreach (int idx in grp)
                {
                    if (!raw_groups_per_ent.ContainsKey(idx))
                    {
                        raw_groups_per_ent[idx] = new HashSet <string>();
                    }
                    raw_groups_per_ent[idx].Add(grp_name);
                }
            }

            foreach (var kv in raw_groups_per_ent)
            {
                groups_per_ent[kv.Key] = new ReadOnlySet <string>(kv.Value);
            }
        }
Beispiel #13
0
        ////////////////

        protected override bool ReceiveRequestWithServer(int fromWho)
        {
            if (this.WorldData == null || this.PlayerData == null)
            {
                LogHelpers.Alert("Could not reply to request; no player id available ("
                                 + "WorldData:" + (this.WorldData != null) + ", PlayerData:" + (this.PlayerData != null) + ").");
                return(true);
            }

            var    mymod    = RewardsMod.Instance;
            Player player   = Main.player[fromWho];
            var    myplayer = (RewardsPlayer)TmlHelpers.SafelyGetModPlayer(player, mymod, "RewardsPlayer");

            bool isSynced;

            myplayer.OnFinishPlayerEnterWorldForServer(out isSynced);

            return(!isSynced);
        }
        public void TC1_UserLogin()
        {
            //string fileName = Environment.CurrentDirectory.ToString() + "\\Data\\TestData.xlsx";
            //string fileName  = @"C:\\Users\\vpshy\\source\\repos\\nopCommerse\\nopCommerseTestProject\\Data\\TestData.xlsx";


            CurrentPage = GetInstance <HomePage>();
            LogHelpers.Write("Opened the browser and navigated to Home Page !!!");
            CurrentPage = CurrentPage.As <HomePage>().ClickLoginLink();
            LogHelpers.Write("Clicked on LoginLink from HomePage !!!");
            CurrentPage.As <LoginPage>().Login("howareu", "123123");
            LogHelpers.Write("Entered UserName and Password !!!");
            CurrentPage = CurrentPage.As <LoginPage>().ClickLogin();
            LogHelpers.Write("Clicked on login after entering UserName and Password !!!");
            CurrentPage = CurrentPage.As <AccountHomePage>().logout();
            LogHelpers.Write("Login Successful and logged out");
            CurrentPage.As <LoginPage>().CheckIfLoginLinkExist();
            DriverContext.Driver.Close();
        }
        ////////////////

        public override void HandlePacket(BinaryReader reader, int playerWho)
        {
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 );
            try {
                int protocolCode = reader.ReadInt32();

                if (Main.netMode == 1)
                {
                    PacketProtocol.HandlePacketOnClient(protocolCode, reader, playerWho);
                }
                else if (Main.netMode == 2)
                {
                    PacketProtocol.HandlePacketOnServer(protocolCode, reader, playerWho);
                }
            } catch (Exception e) {
                LogHelpers.Alert(e.ToString());
            }
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 );
        }
Beispiel #16
0
        internal void SendRequestToClient(int toWho, int ignoreWho, int retries)
        {
            var       mymod  = ModHelpersMod.Instance;
            ModPacket packet = this.GetServerPacket(true);

            try {
                packet.Send(toWho, ignoreWho);
            } catch (Exception e) {
                LogHelpers.Warn(e.ToString());
                return;
            }

            if (mymod.Config.DebugModeNetInfo && this.IsVerbose)
            {
                LogHelpers.Log(">" + this.GetPacketName() + " SendRequestToClient " + toWho + ", " + ignoreWho);
            }

            this.RetryRequestToClientIfTimeout(toWho, ignoreWho, retries);
        }
Beispiel #17
0
        internal void SendRequestToServer(int retries)
        {
            var       mymod  = ModHelpersMod.Instance;
            ModPacket packet = this.GetClientPacket(true, false);

            try {
                packet.Send();
            } catch (Exception e) {
                LogHelpers.Warn(e.ToString());
                return;
            }

            if (mymod.Config.DebugModeNetInfo && this.IsVerbose)
            {
                LogHelpers.Log(">" + this.GetPacketName() + " SendRequestToServer");
            }

            this.RetryRequestToServerIfTimeout(retries);
        }
        protected override void InitializeServerRequestReplyDataOfClient(int toWho, int fromWho)
        {
            Player plr = Main.player[toWho];

            if (plr == null /*|| !plr.active*/)
            {
                LogHelpers.Warn("Player (" + toWho + ": " + (plr == null ? "null" : plr.name) + ") not available.");
                return;
            }

            string uid = PlayerIdentityHelpers.GetUniqueId(plr);

            if (uid == null)
            {
                return;
            }

            this.PrepareDataForPlayer(plr);
        }
        ////////////////

        internal Timers()
        {
            this.OnTickGet = Timers.MainOnTickGet();
            Main.OnTick   += Timers._Update;
//TICKSTART = DateTime.Now.Ticks;

            Promises.Promises.AddWorldUnloadEachPromise(() => {
                lock (Timers.MyLock) {
                    foreach (var kv in this.Running)
                    {
                        LogHelpers.Log("Aborted timer " + kv.Key);
                    }

                    this.Running.Clear();
                    this.Elapsed.Clear();
                    this.Expired.Clear();
                }
            });
        }
        ////////////////

        private void SwitchToUI(UIState ui)
        {
            MenuUIDefinition openingUiDef = 0;
            MenuUIDefinition closingUiDef = this.CurrentMenuUI;

            // Out with the old
            if (closingUiDef != 0 && this.Contexts.ContainsKey(closingUiDef))
            {
                foreach ((string ctxName, MenuContext ctx) in this.Contexts[closingUiDef])
                {
                    ctx.Hide(MainMenuHelpers.GetMenuUI(closingUiDef));
                }
            }

            // Validate
            if (ui != null)
            {
                if (!Enum.TryParse(ui.GetType().Name, out openingUiDef))
                {
                    LogHelpers.WarnOnce("Could not get MenuUIDefinition " + ui.GetType().Name);
                    this.CurrentMenuUI = 0;
                    return;
                }
            }
            else
            {
                this.PreviousMenuUI = this.CurrentMenuUI;
                this.CurrentMenuUI  = 0;
            }

            // In with the new
            if (this.Contexts.ContainsKey(openingUiDef))
            {
                foreach (MenuContext ctx in this.Contexts[openingUiDef].Values.ToArray())
                {
                    ctx.ActivateIfInactive(ui);
                    ctx.Show(ui);
                }
            }

            this.PreviousMenuUI = this.CurrentMenuUI;
            this.CurrentMenuUI  = openingUiDef;
        }
Beispiel #21
0
        ////////////////

        public bool Load(string baseFileName, Player forPlayer = null)
        {
            var      mymod = RewardsMod.Instance;
            KillData data;
            bool     success = false;

            try {
                if (mymod.SettingsConfig.DebugModeSaveKillsAsJson)
                {
                    data = ModCustomDataFileHelpers.LoadJson <KillData>(mymod, baseFileName);
                }
                else
                {
                    data    = ModCustomDataFileHelpers.LoadBinaryJson <KillData>(mymod, baseFileName);
                    success = data != null;
                }
            } catch (IOException e) {
                throw new ModHelpersException("Failed to load file: " + baseFileName, e);
            }

            if (success)
            {
                this.KilledNpcs                = data.KilledNpcs;
                this.GoblinsConquered          = data.GoblinsConquered;
                this.FrostLegionConquered      = data.FrostLegionConquered;
                this.PiratesConquered          = data.PiratesConquered;
                this.MartiansConquered         = data.MartiansConquered;
                this.PumpkinMoonWavesConquered = data.PumpkinMoonWavesConquered;
                this.FrostMoonWavesConquered   = data.FrostMoonWavesConquered;
                this.ProgressPoints            = data.ProgressPoints;

                if (mymod.SettingsConfig.DebugModePPInfo)
                {
                    LogHelpers.Alert("PP set: " + this.ProgressPoints + " (for " + (forPlayer?.name ?? "world") + ")");
                }
            }
            else
            {
                LogHelpers.Alert("Could not load player's NPC kill (and PP) data. New player?");
            }

            return(success);
        }
Beispiel #22
0
 public void HandleGDPRCookiesPopUpIfExist()
 {
     try
     {
         btnAcceptCookies.AssertElementPresent();
         btnAcceptCookies.Click();
     }
     catch (Exception e)
     {
         if (e.Message == "Element not present exception")
         {
             LogHelpers.Write("Cookies already handled");
         }
         else
         {
             throw e;
         }
     }
 }
Beispiel #23
0
        protected void grvIntroItems_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }

            try
            {
                string    id       = grvIntroItems.DataKeys[e.Row.RowIndex].Value.ToString();
                HyperLink newsLink = (HyperLink)e.Row.Cells[1].Controls[0];
                newsLink.NavigateUrl = string.Format("~/{0}?MenuId={1}&Id={2}", _navigationUrl, _menuId, id);
                //---
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError("[ucNewsItems][grvIntroItems_RowDataBound]", ex.ToString());
            }
        }
        private static void RetrieveAllModInfoAsync(Action <bool, BasicModInfoDatabase> onCompletion)
        {
            Action <Exception, string> onError = (e, jsonStr) => {
                if (e == null)
                {
                    LogHelpers.Alert((jsonStr.Trunc(64) ?? "") + " - Invalid exception?");
                }
                else if (e is JsonReaderException)
                {
                    LogHelpers.Alert("Bad JSON: " + jsonStr.Trunc(256));
                }
                else if (e is WebException || e is NullReferenceException)
                {
                    LogHelpers.Alert(("'" + jsonStr.Trunc(64) + "'" ?? "...") + " - " + e.Message);
                }
                else
                {
                    LogHelpers.Alert(("'" + jsonStr.Trunc(64) + "'" ?? "...") + " - " + e.ToString());
                }
            };

            Action <bool, string> onWrappedCompletion = (success, jsonStr) => {
                BasicModInfoDatabase modInfoDb;

                if (success)
                {
                    try {
                        success = GetModInfo.HandleModInfoReceipt(jsonStr, out modInfoDb);
                    } catch (Exception e) {
                        modInfoDb = new BasicModInfoDatabase();
                        onError(e, jsonStr);
                    }
                }
                else
                {
                    modInfoDb = new BasicModInfoDatabase();
                }

                onCompletion(success, modInfoDb);
            };

            WebConnectionHelpers.MakeGetRequestAsync(GetModInfo.ModInfoUrl, e => onError(e, ""), onWrappedCompletion);
        }
Beispiel #25
0
        public void StartBidingOtherType(int id)
        {
            string tag = __tag + "[StartBidingOtherType]";

            LogHelpers.WriteStatus(tag, "Start...");

            lbError.Visible = false;

            try
            {
                ResultBOL <DataSet> result = null;
                if (id <= 0)
                {
                    result = OtherTypeDAL.GetAll();
                }
                else
                {
                    result = OtherDAL.GetAll(id);
                }

                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    return;
                }

                _dataSource = result.Data.Tables[0];
                grvOtherItems.DataSource   = result.Data;
                grvOtherItems.DataKeyNames = new string[] { "Id" };
                grvOtherItems.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Beispiel #26
0
 public static IWebElement FindById(this RemoteWebDriver remoteWebDriver, string element)
 {
     try
     {
         if (remoteWebDriver.FindElementById(element).IsElementPresent())
         {
             return(remoteWebDriver.FindElementById(element));
         }
     }
     catch (Exception e)
     {
         LogHelpers.Write("Exception: " + e.InnerException);
         LogHelpers.Write("Message: " + e.Message);
         LogHelpers.Write("Traza: " + e.StackTrace);
         LogHelpers.Write("Fuente: " + e.Source);
         throw new ElementNotVisibleException($"Element not found : {element}");
     }
     return(null);
 }
Beispiel #27
0
        public static ReadOnlyCollection <IWebElement> FindElementsOrTimeOut(this IWebDriver driver, By by, int timeoutInMilliseconds = 5000)
        {
            try
            {
                if (timeoutInMilliseconds <= 0)
                {
                    return(driver.FindElements(by));
                }

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMilliseconds(timeoutInMilliseconds));
                return(wait.Until(drv => drv.FindElements(by).Count > 0 ? drv.FindElements(by) : null));
            }

            catch (Exception exception)
            {
                LogHelpers.WriteToLog($"[ERROR] :: No Elements Found :: {by} :: {exception.Message}");
                throw new NoSuchElementException($"No Such Elements: {by}");
            }
        }
Beispiel #28
0
        private void StartLoadContactInfo()
        {
            string tag = __tag + "[StartLoadContactInfo]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                var result = AboutsDAL.GetAll();
                if (result.Code < 0)
                {
                    LogHelpers.WriteError(tag, result.ErrorMessage);
                }

                AboutBOL about = new AboutBOL(result.Data.Tables[0].Rows[0]);
                if (Utilities.IsLangueEN())
                {
                    lbName.InnerText        = about.Name_EN;
                    lbAddress.InnerText     = "Address:";
                    lbAddressInfo.InnerText = about.Address_EN;
                    lbPhone.InnerText       = "Phone:";
                }
                else
                {
                    lbName.InnerText        = about.Name_VN;
                    lbAddress.InnerText     = "Địa chỉ:";
                    lbAddressInfo.InnerText = about.Address_VN;
                    lbPhone.InnerText       = "Điện thoại:";
                }

                lbPhoneInfo.InnerText = about.Phone;
                lbFaxInfo.InnerText   = about.Fax;
                lbEmailInfo.InnerText = about.Email;
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
        internal static IDictionary <int, Type> GetProtocolTypes()
        {
            IEnumerable <Type>      protocolTypes   = ReflectionHelpers.GetAllAvailableSubTypesFromMods(typeof(PacketProtocol));
            IDictionary <int, Type> protocolTypeMap = new Dictionary <int, Type>();

            foreach (Type subclassType in protocolTypes)
            {
                ConstructorInfo ctorInfo = subclassType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null,
                                                                       new Type[] { typeof(PacketProtocolDataConstructorLock) }, null);

                if (ctorInfo == null)
                {
                    ctorInfo = subclassType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null,
                                                           new Type[] { }, null);

                    if (ctorInfo == null)
                    {
                        throw new HamstarException("Missing private constructor for " + subclassType.Name + " (" + subclassType.Namespace + ")");
                    }
                    if (ctorInfo.IsFamily)
                    {
                        throw new HamstarException("Invalid constructor for " + subclassType.Name + " (" + subclassType.Namespace + "); must be private, not protected.");
                    }
                }

                if (ModHelpersMod.Instance.Config.DebugModeNetInfo)
                {
                    string name = subclassType.Namespace + "." + subclassType.Name;
                    LogHelpers.Alert(name);
                }

                try {
                    string name = subclassType.Namespace + "." + subclassType.Name;
                    int    code = PacketProtocol.GetPacketCode(name);

                    protocolTypeMap[code] = subclassType;
                } catch (Exception e) {
                    LogHelpers.Log(subclassType.Name + " - " + e.Message);
                }
            }

            return(protocolTypeMap);
        }
        public override void PostDrawInterface(SpriteBatch sb)
        {
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 );
            if (this.LoadHelpers != null)
            {
                this.LoadHelpers.IsClientPlaying_Hackish = true;                  // Ugh!
            }

            try {
                if (!Main.mapFullscreen && (Main.mapStyle == 1 || Main.mapStyle == 2))
                {
                    //this.DrawMiniMapForAll( sb );
                }
            } catch (Exception e) {
                LogHelpers.Warn(e.ToString());
                throw e;
            }
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 );
        }