Example #1
0
 public Dictionary <string, string> PlaceTrailingStopMarketBuyOrder(IWebDriver driver, string orderSize, string trailingAmount, string pegPriceValue)
 {
     try
     {
         Dictionary <string, string> placeBuyOrderDict = new Dictionary <string, string>();
         UserSetFunctions.EnterText(OrderSizeEditBox(driver), orderSize);
         UserSetFunctions.EnterText(TrailingAmountEditBox(driver), trailingAmount);
         SelectPegPrice(pegPriceValue);
         UserSetFunctions.Click(PlaceBuyOrderButton(driver));
         string placeOrderTime           = GenericUtils.GetCurrentTime();
         string placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute();
         placeBuyOrderDict.Add("PlaceOrderTime", placeOrderTime);
         placeBuyOrderDict.Add("PlaceOrderTimePlusOneMin", placeOrderTimePlusOneMin);
         Thread.Sleep(2000);
         return(placeBuyOrderDict);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        public Dictionary <string, string> PlaceStopMarketBuyOrder(string orderSize, string stopPrice)
        {
            try
            {
                Dictionary <string, string> placeBuyOrderDict = new Dictionary <string, string>();
                UserSetFunctions.EnterText(OrderSizeEditBox(driver), orderSize);
                UserSetFunctions.EnterText(StopPriceEditBox(driver), stopPrice);
                UserSetFunctions.Click(PlaceBuyOrderButton(driver));
                string placeOrderTime           = GenericUtils.GetCurrentTime();
                string placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute();
                placeBuyOrderDict.Add("PlaceOrderTime", placeOrderTime);
                placeBuyOrderDict.Add("PlaceOrderTimePlusOneMin", placeOrderTimePlusOneMin);
                Thread.Sleep(2000);

                return(placeBuyOrderDict);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
 // This method is used to register a new user
 public string RegisterNewUser(IWebDriver driver)
 {
     try
     {
         string randomString;
         string email;
         string randomUserName;
         string userUrl        = data.UserPortal.PortalUrl;
         string userName       = TestData.GetData("TC45_UserName");
         string emailDomain    = Const.EmailDomain;
         string password       = TestData.GetData("TC45_Password");
         string retypePassword = TestData.GetData("TC45_Password");
         randomString   = GenericUtils.RandomString(Const.RandomStringLength);
         email          = randomString + emailDomain;
         randomUserName = userName + randomString;
         logger.LogCheckPoint(String.Format(LogMessage.UserSignUpStarted, randomUserName, email));
         UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, signUpLink, 15));
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpUserName, 15), randomUserName);
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpEmail, 15), email);
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpPassword, 15), password);
         UserSetFunctions.EnterText(GenericUtils.WaitForElementPresence(driver, signUpRetypePassword, 15), retypePassword);
         UserSetFunctions.Click(GenericUtils.WaitForElementPresence(driver, signUpButton, 15));
         GenericUtils.WaitForElementPresence(driver, signUpSuccess, 15);
         logger.LogCheckPoint(String.Format(LogMessage.UserSignUpSuccess, randomUserName, email));
         Thread.Sleep(2000);
         return(randomUserName);
     }
     catch (NoSuchElementException ex)
     {
         logger.TakeScreenshot();
         logger.LogError(LogMessage.UserSignUpFailure, ex);
         throw;
     }
     catch (Exception e)
     {
         logger.TakeScreenshot();
         logger.LogError(LogMessage.UserSignUpFailure, e);
         throw;
     }
 }
Example #4
0
    void AddItem(string folder, string workspace)
    {
        var rrt  = item_.transform as UnityEngine.RectTransform;
        var obj  = GameObject.Instantiate(item_);
        var text = GenericUtils.FindChildByName <UnityEngine.UI.Text>(obj, "name");

        text.text = folder;
        text      = GenericUtils.FindChildByName <UnityEngine.UI.Text>(obj, "path");
        text.text = workspace + "/" + folder;

        GenericUtils.SetListenerOnClick(obj, () =>
        {
            scroll_rect_ = null;
            item_        = null;
            GameObject.Destroy(gameObject);
            //Start Game
            GenericUtils.StartCoroutine(Run(workspace, folder));
        });

        var rt      = obj.transform as UnityEngine.RectTransform;
        var content = scroll_rect_.content;

        rt.SetParent(content);
        rt.localScale    = Vector3.one;
        rt.anchorMax     = rrt.anchorMax;
        rt.anchorMin     = rrt.anchorMin;
        rt.offsetMax     = rrt.offsetMax;
        rt.offsetMin     = rrt.offsetMin;
        rt.sizeDelta     = rrt.sizeDelta;
        rt.localPosition = new Vector2(0, -rt.sizeDelta.y * itemcount_);
        itemcount_      += 1;

        var ih = rt.sizeDelta.y * itemcount_;

        if (ih > content.sizeDelta.y)
        {
            content.sizeDelta = new Vector2(content.sizeDelta.x, ih);
        }
        obj.SetActive(true);
    }
        protected virtual void OnClickCreate()
        {
            var gameInstance = GameInstance.Singleton;
            var selectedUI   = SelectionManager.SelectedUI;

            if (selectedUI == null)
            {
                UISceneGlobal.Singleton.ShowMessageDialog("Cannot create character", "Please select character class");
                Debug.LogWarning("Cannot create character, did not selected character class");
                return;
            }
            var characterName          = inputCharacterName.text.Trim();
            var minCharacterNameLength = gameInstance.minCharacterNameLength;
            var maxCharacterNameLength = gameInstance.maxCharacterNameLength;

            if (characterName.Length < minCharacterNameLength)
            {
                UISceneGlobal.Singleton.ShowMessageDialog("Cannot create character", "Character name is too short");
                Debug.LogWarning("Cannot create character, character name is too short");
                return;
            }
            if (characterName.Length > maxCharacterNameLength)
            {
                UISceneGlobal.Singleton.ShowMessageDialog("Cannot create character", "Character name is too long");
                Debug.LogWarning("Cannot create character, character name is too long");
                return;
            }

            var characterId   = GenericUtils.GetUniqueId();
            var characterData = new PlayerCharacterData();

            characterData.Id = characterId;
            characterData.SetNewPlayerCharacterData(characterName, selectedUI.Data.DataId, selectedUI.Data.EntityId);
            characterData.SavePersistentCharacterData();

            if (eventOnCreateCharacter != null)
            {
                eventOnCreateCharacter.Invoke();
            }
        }
Example #6
0
        public async Task BackupParser_ComplexTypesWithSerializers()
        {
            var complexDataBackupFolderPath = Path.Combine(ClassTestPath, @"..\UserFullBackup");
            // from this test run's bin\Debug\netstandard2.0\<testname> dir to parent of bin
            var codePackagePath = Path.Combine(ClassTestPath, @"..\..\..\..\UserType\bin\");

            using (var backupParser = new BackupParser(complexDataBackupFolderPath, codePackagePath))
            {
                backupParser.StateManager.TryAddStateSerializer <User>(new UserSerializer());

                int totalUsers = 0;

                backupParser.TransactionApplied += (sender, args) =>
                {
                    foreach (var reliableStateChange in args.Changes)
                    {
                        if (reliableStateChange.Name == DictionaryName)
                        {
                            foreach (var change in reliableStateChange.Changes)
                            {
                                // we can't link against User project as that will make it easy to load the dll.
                                bool isAddChange = GenericUtils.IsSubClassOfGeneric(change.GetType(), typeof(NotifyDictionaryItemAddedEventArgs <,>));
                                if (isAddChange)
                                {
                                    // make sure that this is Add event with User type.
                                    if (change.GetType().ToString().Contains("UserType.User"))
                                    {
                                        totalUsers++;
                                    }
                                }
                            }
                        }
                    }
                };

                await backupParser.ParseAsync(CancellationToken.None);

                Assert.IsTrue(totalUsers > 0, "Could not parse any user from backup");
            }
        }
        public string PlaceStopBuyOrder(double buyAmount, double stopPrice)
        {
            //UserFunctions objUserFunctionality = new UserFunctions(output);
            if (BuyOrderEntryButton().Displayed&& StopOrderTypeButton().Displayed)
            {
                logger.Info("For Buy Stop Order case ---> Balances stored successfully.");
                UserSetFunctions.Click(OrderEntryButton());
                UserSetFunctions.Click(BuyOrderEntryButton());
                UserSetFunctions.Click(StopOrderTypeButton());
                UserSetFunctions.EnterText(BuyAmountTextField(), buyAmount.ToString());
                UserSetFunctions.EnterText(StopPriceTextField(), stopPrice.ToString());
                Thread.Sleep(2000);

                // Verify Market Price, Fees and Order Total
                Dictionary <string, string> balances = new Dictionary <string, string>();

                if (OrderTotalText().Enabled&& MarketPriceText().Enabled)
                {
                    // Storing balances in Dictionary
                    balances = UserCommonFunctions.StoreOrderEntryAmountBalances(driver);
                    logger.Info("For Buy Stop Order case ---> Balances stored successfully.");
                }
                else
                {
                    logger.Error("For Buy stop Order case ---> Market or Order Total or Net amount is not present");
                }
                UserSetFunctions.Click(PlaceBuyOrderButton());
                Thread.Sleep(2000);
                string verifyTransactionsMesg = UserCommonFunctions.GetTextOfSuccessfulMessage(driver, logger);
                logger.Info("Current order transaction message ---> " + verifyTransactionsMesg);
                UserCommonFunctions.ScrollingDownVertical(driver);
                Thread.Sleep(2000);
                return(GenericUtils.GetCurrentTime());
            }
            else
            {
                logger.Error("For Buy Stop Order case ---> Balances stored successfully.");
                return(GenericUtils.GetCurrentTime());
            }
        }
        public void TC47_VerifySingleReportTradeActivities()
        {
            string reportTypeValue;
            string startDate;
            string endDate;

            reportTypeValue = TestData.GetData("TC47_SingleReportTradeActivityValue");
            TradeReportsPage objTradeReportsPage = new TradeReportsPage(driver, TestProgressLogger);

            try
            {
                TestProgressLogger.StartTest();
                UserFunctions objUserFunctionality = new UserFunctions(TestProgressLogger);
                objUserFunctionality.LogIn(TestProgressLogger, Const.USER14);
                startDate = GenericUtils.GetCurrentDateMinusOne();
                endDate   = GenericUtils.GetCurrentDate();

                //This will verify trade activities of single report and their details
                Assert.True(objTradeReportsPage.VerifySingleReportData(reportTypeValue, startDate, endDate));
                TestProgressLogger.LogCheckPoint(String.Format(LogMessage.VerifySingleReportTradeActivitiesPassed, reportTypeValue));
            }
            catch (NoSuchElementException ex)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(ex.Message + ex.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifySingleReportTradeActivitiesFailed, reportTypeValue), ex);
                throw ex;
            }
            catch (Exception e)
            {
                TestProgressLogger.TakeScreenshot();
                TestProgressLogger.LogCheckPoint(e.Message + e.StackTrace);
                TestProgressLogger.LogError(String.Format(LogMessage.VerifySingleReportTradeActivitiesFailed, reportTypeValue), e);
                throw e;
            }
            finally
            {
                TestProgressLogger.EndTest();
            }
        }
        // This method will verify the order placed in inactive orders tab through Order Entry
        public bool VerifyInactiveOrdersTab(string instrument, string side, string type, double size, string price, string placeOrderTime, string placeOrderTimePlusOneMin, string status)
        {
            var    flag = false;
            string orderSize;
            string priceValue;
            string expectedRow_1;
            string expectedRow_2;

            try
            {
                orderSize  = GenericUtils.ConvertToDoubleFormat(size);
                priceValue = GenericUtils.ConvertToDoubleFormat(Double.Parse(price));

                UserCommonFunctions.InactiveTab(driver);
                expectedRow_1 = instrument + " || " + side + " || " + type + " || " + orderSize + " || " + priceValue + " || " + status;
                expectedRow_2 = instrument + " || " + side + " || " + type + " || " + orderSize + " || " + priceValue + " || " + status;

                var listOfInactiveOrders = GetListOfInactiveOrders();

                //This will verify the expected details with actual in inactive orders tab
                if (listOfInactiveOrders.Contains(expectedRow_1) || listOfInactiveOrders.Contains(expectedRow_2))
                {
                    flag = true;
                }
                if (flag)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderVerifiedInInactiveOrdersTab, side));
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.OrderNotFoundInInactiveOrdersTab, side));
                }
                return(flag);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #10
0
        public IActionResult ChangePassword(string newPassword)
        {
            var user = User.GetUser(dataContext);

            if (user == null)
            {
                return(new NotFoundResult());
            }

            try
            {
                user.password = BCrypt.Net.BCrypt.HashPassword(newPassword);
                user.updated  = GenericUtils.GetDateTime();
                dataContext.users.Update(user);
                dataContext.SaveChanges();
                return(Ok());
            }
            catch
            {
                return(BadRequest());
            }
        }
Example #11
0
        protected override IEnumerable <IWeldComponent> Resolve(ComponentResolvable resolvable, ref IEnumerable <IWeldComponent> components)
        {
            var results = components.ToArray();

            if (GenericUtils.OpenIfGeneric(resolvable.Type) == typeof(IEvents <>))
            {
                return new IWeldComponent[]
                       { new EventComponent(resolvable.Type.GetGenericArguments()[0], new Annotations(resolvable.Qualifiers), Manager) }
            }
            ;

            var unwrappedType = UnwrapType(resolvable.Type);
            var isWrapped     = unwrappedType != resolvable.Type;

            results = _typeComponents.GetOrAdd(unwrappedType, t =>
                                               results.Select(x => x.Resolve(t)).Where(x => x != null).ToArray());

            results = results.Where(c => c.Qualifiers.CanSatisfy(resolvable.Qualifiers)).ToArray();

            if (results.Length > 1)
            {
                var onMissings = results.Where(x => x.IsConditionalOnMissing).ToArray();

                var others = results.Except(onMissings).ToArray();

                results = others.Any() ? others : onMissings.Take(1).ToArray();
            }

            foreach (var result in results)
            {
                result.Touch();
            }
            components = results;

            return(isWrapped
                ? new IWeldComponent[] { new InstanceComponent(unwrappedType, new Annotations(resolvable.Qualifiers), Manager, results) }
                : results);
        }
    }
Example #12
0
        public override IWeldComponent Resolve(Type requestedType)
        {
            if (IsConcrete)
            {
                return(requestedType.IsAssignableFrom(Type) ? this : null);
            }

            var typeResolution = GenericUtils.ResolveGenericType(Type, requestedType);

            if (typeResolution == null || typeResolution.ResolvedType == null || typeResolution.ResolvedType.ContainsGenericParameters)
            {
                return(null);
            }

            var component = TranslateTypes(typeResolution);

            if (component != null)
            {
                TransferInjectionPointsTo(component, typeResolution);
            }
            return(component);
        }
Example #13
0
    public void Ready()
    {
        var texts  = inprogress.GetComponentsInChildren <Text>();
        var length = texts.Length;

        for (int i = 0; i < length; ++i)
        {
            var text = texts[i];
            text.color = EmueraBehaviour.FontColor;
        }

        var buttoncolor = EmueraBehaviour.FontColor;

        buttoncolor.a = 0.6f;
        quick_button.GetComponent <Image>().color     = buttoncolor;
        input_button.GetComponent <Image>().color     = buttoncolor;
        magnifier_button.GetComponent <Image>().color = buttoncolor;
        option_button.GetComponent <Image>().color    = buttoncolor;
        orientation_lock_image.color = buttoncolor;
        scale_pad.SetColor(buttoncolor);
        input_pad.SetColor(buttoncolor,
                           GenericUtils.ToUnityColor(MinorShift.Emuera.Config.BackColor));

        buttoncolor.a  = 1.0f;
        button_shadows = new List <Shadow>();
        var shadow = quick_button.GetComponent <Shadow>();

        shadow.effectColor = buttoncolor;
        button_shadows.Add(shadow);
        shadow             = input_button.GetComponent <Shadow>();
        shadow.effectColor = buttoncolor;
        button_shadows.Add(shadow);
        shadow             = magnifier_button.GetComponent <Shadow>();
        shadow.effectColor = buttoncolor;
        button_shadows.Add(shadow);
        shadow             = option_button.GetComponent <Shadow>();
        shadow.effectColor = buttoncolor;
        button_shadows.Add(shadow);
    }
Example #14
0
    // Use this for initialization
    void Start()
    {
        GenericUtils.SetListenerOnClick(quick_button.gameObject, OnQuickButtonClick);
        GenericUtils.SetListenerOnClick(input_button.gameObject, OnInputPadButtonClick);
        GenericUtils.SetListenerOnClick(magnifier_button.gameObject, OnScalePadButtonClick);
        GenericUtils.SetListenerOnClick(option_button.gameObject, OnShowMenu2);

        orientation_lock_image = orientation_lock_button.GetComponent <Image>();
        GenericUtils.SetListenerOnClick(orientation_lock_button.gameObject, OnLockOrientationClick);

        GenericUtils.SetListenerOnClick(msg_confirm, OnMsgConfirm);
        GenericUtils.SetListenerOnClick(msg_cancel, OnMsgCancel);

        GenericUtils.SetListenerOnClick(menu_pad, OnMenuPad);
        GenericUtils.SetListenerOnClick(menu_1_exit, OnMenuExit);

        GenericUtils.SetListenerOnClick(menu_2_back, OnMenu2Back);
        GenericUtils.SetListenerOnClick(menu_2_restart, OnMenu2Restart);
        GenericUtils.SetListenerOnClick(menu_2_gototitle, OnMenuGotoTitle);
        GenericUtils.SetListenerOnClick(menu_2_savelog, OnMenuSaveLog);
        GenericUtils.SetListenerOnClick(menu_2_exit, OnMenuExit);
    }
 public Dictionary <string, string> PlaceStopLimitSellOrder(string orderSize, string limitPrice, string stopPrice, string timeInForce)
 {
     try
     {
         Dictionary <string, string> placeSellOrderDict = new Dictionary <string, string>();
         UserSetFunctions.EnterText(OrderSizeEditBox(driver), orderSize);
         UserSetFunctions.EnterText(LimitPriceEditBox(driver), orderSize);
         UserSetFunctions.EnterText(StopPriceEditBox(driver), stopPrice);
         UserSetFunctions.SelectDropdown(TimeInForce(driver), timeInForce);
         UserSetFunctions.Click(PlaceSellOrderButton(driver));
         string placeOrderTime           = GenericUtils.GetCurrentTime();
         string placeOrderTimePlusOneMin = GenericUtils.GetCurrentTimePlusOneMinute();
         placeSellOrderDict.Add("PlaceOrderTime", placeOrderTime);
         placeSellOrderDict.Add("PlaceOrderTimePlusOneMin", placeOrderTimePlusOneMin);
         Thread.Sleep(2000);
         return(placeSellOrderDict);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #16
0
 public async Task <IResponseService> ListByType(Pagination param)
 {
     try
     {
         param = GenericUtils.ValidatePagination(param);
         var type = Enum.Parse <CatalogType>(param.Criterion);
         _responseService.EstablecerRespuesta(true,
                                              await _repository.List(o => o.OrderBy(x => x.Name),
                                                                     x => x.Type == type,
                                                                     param.Page,
                                                                     param.PageSize,
                                                                     x => x.Childs)
                                              );
         _unit.Dispose();
         return(_responseService);
     }
     catch (Exception ex)
     {
         _responseService.Errores.Add(_exceptionHandler.GetMessage(ex));
         return(_responseService);
     }
 }
Example #17
0
        private string AttemptLogin(LoginApiModel loginObject)
        {
            var sessionProvider          = ProviderFactory.Instance.CreateSessionServiceProvider();
            var sessionValidityInSeconds = 43200;

            try
            {
                sessionValidityInSeconds = Int32.Parse(WebConfigurationManager.AppSettings["session-valididity-in-seconds"]);
            }
            catch { }

            return(sessionProvider.SignIn(new SignInRequest()
            {
                Email = loginObject.username,
                Password = GenericUtils.CalculateMD5Hash(loginObject.password),
                SessionDetails = new SessionDetails()
                {
                    Timeout = sessionValidityInSeconds
                },
                UseDefaultTenant = true
            }).SessionToken);
        }
Example #18
0
 public void ClickInstrumentDetails(IWebDriver driver, string instrumentname)
 {
     try
     {
         Thread.Sleep(2000);
         IReadOnlyCollection <IWebElement> arr = driver.FindElements(By.XPath("//div[@class='wallet-card-grid']/div"));
         for (int i = 1; i <= arr.Count; i++)
         {
             IWebElement div        = GenericUtils.WaitForElementClickable(driver, By.XPath("//div[@class='wallet-card-grid']/div[" + i + "]/div//span"), 10);
             string      instrument = div.Text;
             if (instrument.Contains(instrumentname))
             {
                 IWebElement details = GenericUtils.WaitForElementClickable(driver, By.XPath("//div[@class='wallet-card-grid']/div[" + i + "]/div[3]/div/a"), 10);
                 GenericUtils.ActionClick(driver, details);
                 break;
             }
         }
     }
     catch (StaleElementReferenceException)
     {
         Thread.Sleep(2000);
         IReadOnlyCollection <IWebElement> arr = driver.FindElements(By.XPath("//div[@class='wallet-card-grid']/div"));
         for (int i = 1; i <= arr.Count; i++)
         {
             IWebElement div        = GenericUtils.WaitForElementClickable(driver, By.XPath("//div[@class='wallet-card-grid']/div[" + i + "]/div//span"), 10);
             string      instrument = div.Text;
             if (instrument.Contains(instrumentname))
             {
                 IWebElement details = GenericUtils.WaitForElementClickable(driver, By.XPath("//div[@class='wallet-card-grid']/div[" + i + "]/div[3]/div/a"), 10);
                 GenericUtils.ActionClick(driver, details);
                 break;
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #19
0
        public async Task <IResponseService> Update(User entity)
        {
            try
            {
                if (!await _repository.Any(x => x.Id.Equals(entity.Id)))
                {
                    throw new ApplicationException(ErrorCodes.NotFoundEntity.ToString());
                }
                entity.BirthDate = GenericUtils.GetDateZone(entity.BirthDate);
                _repository.Update(entity);
                await _unit.Commit();

                _responseService.EstablecerRespuesta(true);
                _unit.Dispose();
                return(_responseService);
            }
            catch (Exception ex)
            {
                _responseService.Errores.Add(_exceptionHandler.GetMessage(ex));
                return(_responseService);
            }
        }
Example #20
0
    public static void GetSprite(ASprite src,
                                 object obj, Action <object, SpriteInfo> callback)
    {
        if (src == null || src.Bitmap == null)
        {
            if (callback != null)
            {
                callback(null, null);
            }
            return;
        }

        var         basename = src.Bitmap.filename;
        TextureInfo ti       = null;

        texture_dict.TryGetValue(basename, out ti);
        if (ti == null)
        {
            var item = new CallbackInfo(src, obj, callback);
            List <CallbackInfo> list = null;
            if (loading_set.TryGetValue(basename, out list))
            {
                list.Add(item);
            }
            else
            {
                list = new List <CallbackInfo> {
                    item
                };
                loading_set.Add(basename, list);
                GenericUtils.StartCoroutine(Loading(src.Bitmap));
            }
        }
        else
        {
            callback(obj, GetSpriteInfo(ti, src));
        }
    }
Example #21
0
        /// <summary>
        /// Creates the loot bag entity building and configures it according to configuration settings.
        /// </summary>
        /// <param name="position">position in gameworld to spawn loot bag entity</param>
        /// <param name="rotation">rotation to use for lootbag entity</param>
        /// <param name="lootItems">items to place on lootbag</param>
        protected void CreateLootBag(Vector3 position, Quaternion rotation, List <CharacterItem> lootItems)
        {
            BuildingEntity buildingEntity;

            if (!GameInstance.BuildingEntities.TryGetValue(lootBagEntity.EntityId, out buildingEntity))
            {
                return;
            }

            if (!(buildingEntity is LootBagEntity))
            {
                return;
            }

            string creatorName = EntityTitle;

            if (this is BasePlayerCharacterEntity)
            {
                creatorName = CharacterName;
            }

            BuildingSaveData bsd = new BuildingSaveData();

            bsd.Id              = GenericUtils.GetUniqueId();
            bsd.ParentId        = string.Empty;
            bsd.EntityId        = buildingEntity.EntityId;
            bsd.CurrentHp       = buildingEntity.MaxHp;
            bsd.RemainsLifeTime = buildingEntity.LifeTime;
            bsd.Position        = position;
            bsd.Rotation        = rotation;
            bsd.CreatorId       = Id;
            bsd.CreatorName     = creatorName;
            LootBagEntity lbe = CurrentGameManager.CreateBuildingEntity(bsd, false) as LootBagEntity;

            lbe.SetOwnerEntity(this);
            lbe.AddItems(lootItems).Forget();
            lbe.SetDestroyDelay(characterDB.lootBagDestroyDelay);
        }
    private void generateDataStruct()
    {
        dataStruct               = new MinaretDataStruct();
        dataStruct.baseWidth     = 7;
        dataStruct.baseHeight    = 3;
        dataStruct.shaftHeight   = Randomiser.intBetween(25, 40);
        dataStruct.shaftWidth    = 5;
        dataStruct.ringNumber    = Randomiser.intBetween(1, 3);
        dataStruct.ringWidth     = 6;
        dataStruct.ringHeight    = 1.5f;
        dataStruct.galleryWidth  = 4;
        dataStruct.galleryHeight = 3.5f;
        dataStruct.topWidth      = dataStruct.galleryWidth;
        dataStruct.topHeight     = dataStruct.galleryWidth;
        dataStruct.decorHeight   = 1;
        dataStruct.decorWidth    = 1;

        GameObject[] basePrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/base_M");
        dataStruct.basePrefab = basePrefabs [Random.Range(0, basePrefabs.Length)];
        GameObject[] shaftPrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/shaft_M");
        dataStruct.shaftPrefab = shaftPrefabs [Random.Range(0, shaftPrefabs.Length)];
        GameObject[] ringPrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/ring_M");
        dataStruct.ringPrefab = ringPrefabs [Random.Range(0, ringPrefabs.Length)];
        GameObject[] galleryPrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/gallery_M");
        dataStruct.galleryPrefab = galleryPrefabs [Random.Range(0, galleryPrefabs.Length)];
        GameObject[] topPrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/top_M");
        dataStruct.topPrefab = topPrefabs [Random.Range(0, topPrefabs.Length)];
        GameObject[] decorPrefabs = GenericUtils.loadAllPrefabs("prefabs/minaret/decoration_M");
        dataStruct.decorPrefab   = decorPrefabs [Random.Range(0, decorPrefabs.Length)];
        dataStruct.decorSequence = generateDecorSequence();

        ArchData ad = gameObject.GetComponent <ArchData> ();

        dataStruct.columnBase    = ad.getColumnBase();
        dataStruct.columnShaft   = ad.getColumnShaft();
        dataStruct.columnCapital = ad.getColumnCapital();
        dataStruct.arch          = ad.getSimpleArch();
    }
 public void RandomSelection()
 {
     Sleep(500);
     //SAVINGS
     if (Populate)
     {
         if (saving.Displayed())
         {
             saving.ClickCustom("Saving", driver);
         }
     }
     Sleep(300);
     //CHECKING
     if (Populate)
     {
         if (checking.Displayed())
         {
             checking.ClickCustom("Checking", driver);
         }
         if (FindBy(By.XPath("(//div[@class='dropdown-menu show']/a)[1]"), 2).Displayed())
         {
             dropDowns[1].ClickCustom(dropDowns[1].Text, driver);
             courtesy_Checkbox.ClickCustom("Courtesy Checkbox", driver);
             iAgree.ClickCustom("I Agree", driver);
         }
     }
     Sleep(200);
     //CERTIFICATE
     if (Populate)
     {
         certificate.ClickCustom("Certificate", driver);
         int[] numbers = new int[] { 3, 6, 12, 24, 36, 48, 60 };
         int   random  = numbers[GenericUtils.GetRandomNumber(0, numbers.Length - 1)];
         dropDowns[GenericUtils.GetRandomNumber(0, numbers.Length - 1)].ClickCustom("Certificate Option", driver);
     }
     Sleep(200);
     next.ClickCustom("Next", driver);
 }
Example #24
0
        // Verify amount in transfer section.
        public void VerifyAmountInTransferSection(IWebDriver driver, string userName, string receivedAmount)
        {
            string actualAmountFromUI;
            string usernameFromUI;
            string expectedRow;
            string actualRow = null;
            string receivedAmountInDouble;

            try
            {
                receivedAmountInDouble = GenericUtils.ConvertToDoubleFormat(GenericUtils.ConvertStringToDouble(receivedAmount));
                expectedRow            = userName + " || " + receivedAmountInDouble;
                IWebElement pagination = driver.FindElement(nextPagination);
                if (pagination.Enabled)
                {
                    pagination.Click();
                }
                Thread.Sleep(6000);
                IReadOnlyCollection <IWebElement> arr = driver.FindElements(By.XPath("//div[@class='flex-table__body transfers__body']/div"));
                for (int i = 1; i <= arr.Count; i++)
                {
                    IWebElement div = driver.FindElement(By.XPath("//div[@class='flex-table__body transfers__body']/div[" + i + "]/div[1]/div/div[2]"));
                    usernameFromUI = div.Text.Split(" ")[1];
                    IWebElement amount = driver.FindElement(By.XPath("//div[@class='flex-table__body transfers__body']/div[" + i + "]/div[2]/div/div[1]"));
                    actualAmountFromUI = amount.Text;
                    actualRow          = usernameFromUI + " || " + actualAmountFromUI;
                    if (actualRow.Equals(expectedRow))
                    {
                        break;
                    }
                }
                Assert.Equal(expectedRow, actualRow);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #25
0
        // This method verifies selectable dates are greater than start date and equal to current date
        public bool VerifyEndDateSelectableDates(string startDate)
        {
            int    today;
            string disabledFields;
            int    startDateSelected = GenericUtils.GetOnlyDateFromDateString(startDate);
            bool   flag = false;

            today = GenericUtils.GetOnlyCurrentDate();
            Thread.Sleep(2000);
            UserSetFunctions.Click(EndDate());
            IWebElement dateWidgetEnd = driver.FindElement(By.XPath("//table[@class='pika-table' and @aria-labelledby='pika-title-zk']/tbody"));
            //This are the columns of the from date picker table
            List <IWebElement> columns = new List <IWebElement>();
            var dateColumn             = dateWidgetEnd.FindElements(By.ClassName("is-disabled"));

            foreach (IWebElement fields in dateColumn)
            {
                disabledFields = fields.Text;
                int fieldValueInInt = Int32.Parse(disabledFields);
                if (fieldValueInInt > today)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.EndCurrentDateGreaterThanStartDatePassed));//fieldValueInInt
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.EndCurrentDateGreaterThanStartDateFailed));
                }
                if (fieldValueInInt < startDateSelected)
                {
                    logger.LogCheckPoint(String.Format(LogMessage.LessThanStartDatePassed, fieldValueInInt));
                }
                else
                {
                    logger.LogCheckPoint(String.Format(LogMessage.LessThanStartDateFailed, fieldValueInInt));
                }
            }
            return(flag);
        }
        public bool BuyAndVerifyFilledOrdersTab(string instrument, string side, double size)
        {
            var flag = false;

            driver.Navigate().GoToUrl("https://apexwebqa.azurewebsites.net/exchange");
            driver.Manage().Window.Maximize();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

            UserFunctionality objUserFunctionality = new UserFunctionality(output);

            objUserFunctionality.LogIn();

            UserHomePage selectExchange = new UserHomePage(driver, output);

            selectExchange.SelectInstrumentFromExchange(instrument);

            GenericUtils gen            = new GenericUtils(output);
            string       buyAmountValue = gen.ConvertToDecimal(size);

            BuyOrderEntry boe = new BuyOrderEntry(driver, output);
            string        buyMarketOrderTime    = boe.PlaceMaketBuyOrder(0.07);
            string        lastPrice             = boe.GetLastPrice();
            double        doubleLastPrice       = Convert.ToDouble(lastPrice);
            string        totalAmountCalculated = gen.FilledOrdersTotalAmount(size, doubleLastPrice);

            driver.FindElement(selectFilledOrdersTab).Click();

            string expectedRow = instrument + " || " + side + " || " + size + " || " + lastPrice + " || " + totalAmountCalculated + " || " + buyMarketOrderTime;

            output.WriteLine("expectedRow********* " + expectedRow);

            if (GetListOfFilledOrders().Contains(expectedRow))
            {
                output.WriteLine("Matched Expected -> " + expectedRow + " Actual -> ");
                flag = true;
            }
            return(flag);
        }
Example #27
0
        public Mat Extract(string path)
        {
            //if true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.
            Utils.setDebugMode(true);

            var embedder = Dnn.readNetFromTorch(model_filepath);

            Mat img = Imgcodecs.imread(Utils.getFilePath("faces/" + path));

            if (img.empty())
            {
                Debug.LogError("image is not loaded");
                return(img);
            }

            Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2RGB);
            var roi          = GetBB(img);
            Mat cropped_face = img.submat((int)roi.y, (int)roi.y + (int)roi.height,
                                          (int)roi.x, (int)roi.width + (int)roi.x);
            var faceBlob = Dnn.blobFromImage(cropped_face, scalefactor, new Size(inpWidth, inpHeight), new Scalar(0, 0, 0), true, false);

            embedder.setInput(faceBlob);
            var netOut = embedder.forward();

            if (gameObject.GetComponent <Renderer>() != null && displayBB)
            {
                GenericUtils.AdjustImageScale(cropped_face, this.gameObject);
                Texture2D texture = new Texture2D(cropped_face.cols(), cropped_face.rows(), TextureFormat.RGBA32, false);
                Utils.matToTexture2D(cropped_face, texture);
                gameObject.GetComponent <Renderer>().material.mainTexture = texture;
            }

            //_embedder.Dispose();
            //cropped_face.Dispose();
            img.Dispose();

            return(netOut);
        }
Example #28
0
        //This method will verify the order placed in Filled orders tab through Order Entry
        public bool VerifyFilledOrdersTab(string instrument, string side, double size)
        {
            var    flag            = false;
            string marketOrderTime = null;

            UserCommonFunctions.DashBoardMenuButton(driver);
            Thread.Sleep(2000);
            UserCommonFunctions.SelectAnExchange(driver);

            OrderEntryPage boe = new OrderEntryPage(driver, output);

            if (side.Equals("Buy"))
            {
                marketOrderTime = boe.PlaceMarketBuyOrder(size);
            }

            else if (side.Equals("Sell"))
            {
                marketOrderTime = boe.PlaceMarketSellOrder(size);
            }

            string buyAmountValue        = GenericUtils.ConvertToDoubleFormat(size);
            string lastPrice             = boe.GetLastPrice();
            double doubleLastPrice       = Convert.ToDouble(lastPrice);
            string totalAmountCalculated = GenericUtils.FilledOrdersTotalAmount(size, doubleLastPrice);

            Thread.Sleep(2000);
            UserCommonFunctions.FilledOrderTab(driver);

            string expectedRow = instrument + " || " + side + " || " + size + " || " + lastPrice + " || " + totalAmountCalculated + " || " + marketOrderTime;

            if (GetListOfFilledOrders().Contains(expectedRow))
            {
                logger.Info(side + "Order Successfully verifed in Filled orders tab");
                flag = true;
            }
            return(flag);
        }
Example #29
0
        protected virtual void NetFuncBuild(short itemIndex, Vector3 position, Quaternion rotation, PackedUInt parentObjectId)
        {
            if (!CanDoActions() ||
                itemIndex >= NonEquipItems.Count)
            {
                return;
            }

            BuildingEntity buildingEntity;
            CharacterItem  nonEquipItem = NonEquipItems[itemIndex];

            if (!nonEquipItem.NotEmptySlot() ||
                nonEquipItem.GetBuildingItem() == null ||
                nonEquipItem.GetBuildingItem().buildingEntity == null ||
                !GameInstance.BuildingEntities.TryGetValue(nonEquipItem.GetBuildingItem().buildingEntity.DataId, out buildingEntity) ||
                !this.DecreaseItemsByIndex(itemIndex, 1))
            {
                return;
            }

            BuildingSaveData buildingSaveData = new BuildingSaveData();

            buildingSaveData.Id       = GenericUtils.GetUniqueId();
            buildingSaveData.ParentId = string.Empty;
            BuildingEntity parentBuildingEntity;

            if (TryGetEntityByObjectId(parentObjectId, out parentBuildingEntity))
            {
                buildingSaveData.ParentId = parentBuildingEntity.Id;
            }
            buildingSaveData.DataId      = buildingEntity.DataId;
            buildingSaveData.CurrentHp   = buildingEntity.maxHp;
            buildingSaveData.Position    = position;
            buildingSaveData.Rotation    = rotation;
            buildingSaveData.CreatorId   = Id;
            buildingSaveData.CreatorName = CharacterName;
            gameManager.CreateBuildingEntity(buildingSaveData, false);
        }
Example #30
0
        /// <summary>
        /// Parse the given mtl file
        /// </summary>
        /// <param name="file">File to parse</param>
        /// <returns></returns>
        public static MtlData ParseMtl(string file)
        {
            string[] lines = GenericUtils.RemoveBlankSpaces(FileUtilsShared.ReadFile(file)); // Read the file and remove blankspaces
            if (lines != null)
            {
                // Store all the other data to parse
                List <Tuple <string, string> > listKeysValues = GetListKeysValues(lines);

                MtlData mtlData = new MtlData(file);

                lines = null; // To let the garbage collector free the file from memory
                int i      = 0;
                int length = listKeysValues.Count;

                while (i < length)
                {
                    Tuple <string, string> keyValue = listKeysValues[i];
                    if (keyValue != null) // Never null unless error or final line
                    {
                        if (MtlUtils.IsNewMtl(keyValue.Item1))
                        {
                            int materialStart = i;
                            int materialEnd   = GetIndexEnd(listKeysValues, length, materialStart);

                            if (materialEnd != -1)
                            {
                                mtlData.MaterialsList.Add(MaterialData(listKeysValues, materialStart, materialEnd));
                                i = materialEnd; // Set to next material
                                continue;
                            }
                        }
                    }
                    i++;
                }
                return(mtlData);
            }
            return(null);
        }