コード例 #1
0
        //If Orders!=null , we get the potential
        protected double GetNetContracts(string firmId, string symbol, ClientPosition[] Positions, char?side = null, List <OrderDTO> Orders = null)
        {
            List <UserRecord> usersForFirm = UserRecords != null?UserRecords.Where(x => x.FirmId == firmId).ToList() : null;

            double potentialNetContracts = 0;

            if (usersForFirm != null)
            {
                foreach (UserRecord userForFirms in usersForFirm)
                {
                    Positions.Where(x => x.Symbol == symbol && x.UserId == userForFirms.UserId).ToList()
                    .ForEach(x => potentialNetContracts += x.Contracts);


                    if (Orders != null && side.HasValue)
                    {
                        Orders.Where(x => x.cSide == side.Value && x.cStatus == OrderDTO._STATUS_OPEN &&
                                     x.InstrumentId == symbol && x.UserId == userForFirms.UserId).ToList()
                        .ForEach(x => potentialNetContracts += (x.cSide == OrderDTO._SIDE_BUY) ? x.LvsQty : (-1 * x.LvsQty));
                    }
                }
            }
            else
            {
                Positions.Where(x => x.Symbol == symbol).ToList().ForEach(x => potentialNetContracts += x.Contracts);

                if (Orders != null && side.HasValue)
                {
                    Orders.Where(x => x.cSide == side.Value && x.cStatus == OrderDTO._STATUS_OPEN && x.InstrumentId == symbol).ToList()
                    .ForEach(x => potentialNetContracts += (x.cSide == OrderDTO._SIDE_BUY) ? x.LvsQty : (-1 * x.LvsQty));
                }
            }
            return(potentialNetContracts);
        }
コード例 #2
0
        // GET: User
        public ActionResult Index(UserRecords ur)
        {
            string        mainconn = ConfigurationManager.ConnectionStrings["Myconn"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);
            string        s1       = "SELECT * FROM [dbo].[User]";
            SqlCommand    sqlcomm  = new SqlCommand(s1);

            sqlcomm.Connection = sqlconn;
            sqlconn.Open();
            SqlDataReader      sdr      = sqlcomm.ExecuteReader();
            List <UserRecords> objmodel = new List <UserRecords>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    var details = new UserRecords();
                    details.FirstName    = sdr["FirstName"].ToString();
                    details.MiddleName   = sdr["MiddleName"].ToString();
                    details.LastName     = sdr["LastName"].ToString();
                    details.EmailAddress = sdr["EmailAddress"].ToString();
                    details.Password     = sdr["Password"].ToString();
                    details.PhoneNumber  = sdr["PhoneNumber"].ToString();
                    objmodel.Add(details);
                }
                ur.userinfo = objmodel;
                sqlconn.Close();
            }
            return(View("Index", ur));
        }
コード例 #3
0
        public void productList()
        {
            try
            { ProductDataBase.Products.ForEach(x => Console.WriteLine(x.ToString()));

              if (ProductDataBase.Products.Count() <= 0)
              {
                  Console.WriteLine("Product List Is Empty ..!\nLogin as Manager to Add Some Product");
                  userRecords = new UserRecords();
                  userRecords.Login();
              }
            }
            catch (Exception) {
                Console.WriteLine("Error");
            }
            this.AddProductToCart();
            Console.WriteLine("\nY to ADD more Product or N to Exit");
            string yesORno = Console.ReadLine().ToLower();

            if (yesORno == "y")
            {
                this.productList();
            }
            else
            {
                Console.WriteLine("Thankyou..!!");
            }
        }
コード例 #4
0
 public void DeleteProgress()
 {
     if (File.Exists(Application.persistentDataPath + filename))
     {
         File.Delete(Application.persistentDataPath + filename);
         records = new UserRecords();
     }
 }
コード例 #5
0
        public void User_records_maintains_single_copy_of_user_saved_twice()
        {
            UserRecords records  = new UserRecords();
            User        saveUser = factory.Generate("gitty", "Gyn Mitty", false);

            records.Save(saveUser);
            records.Save(saveUser);
            Assert.That(records.Count, Is.EqualTo(1));
        }
コード例 #6
0
        /* InitNewUserRecord()
         *   Initializes a new UserRecords object with user credentials
         */
        public static UserRecords InitNewUserRecord(string user, string pass)
        {
            UserRecords newRecord = new UserRecords
            {
                Name = user,
                Pass = pass
            };

            return(newRecord);
        }
コード例 #7
0
        public void The_user_records_provides_a_count_of_users_and_admins()
        {
            UserRecords records = new UserRecords();
            UserFactory factory = new UserFactory();

            records.Save(factory.Generate("alvin", "Alvin Sooq", false));
            records.Save(factory.Generate("terra", "Terra Haute", true));
            records.Save(factory.Generate("gitty", "Gyn Mitty", false));

            Assert.That(records.Count, Is.EqualTo(3));
            Assert.That(records.AdminCount, Is.EqualTo(1));
        }
コード例 #8
0
        /*** Data retrieval/manipulation. ***/

        /* CreateUser()
         *   Creates a new user account, if the username is not already taken.
         *
         *   Returns: true if account is created, false if not created
         */
        public static bool CreateUser(string user, string pass)
        {
            string      cacheName   = GetCacheName(user);
            UserRecords newUserData = InitNewUserRecord(user, pass);

            if (Cache.Exists(cacheName))
            {
                return(false);
            }

            Cache.Store(cacheName, newUserData);
            return(true);
        }
コード例 #9
0
 public void LoadProgres()
 {
     if (File.Exists(Application.persistentDataPath + filename))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + filename, FileMode.Open);
         records = (UserRecords)bf.Deserialize(file);
         file.Close();
     }
     else
     {
         records = new UserRecords();
         records.appSettings.fullscreen = Screen.fullScreen;
     }
 }
コード例 #10
0
 public void ClearRecords()
 {
     AssetFilterRecords.Clear();
     PartRecords.Clear();
     PhaseRecords.Clear();
     UserRecords.Clear();
     ScoreRecords.Clear();
     TroopRecords.Clear();
     BarrackRecords.Clear();
     TowerRecords.Clear();
     HeroRecords.Clear();
     SkillRecords.Clear();
     CutsceneRecords.Clear();
     SceneRecords.Clear();
     SpeakRecords.Clear();
 }
コード例 #11
0
        public void The_user_records_can_save_load_and_delete_records()
        {
            UserRecords records = new UserRecords();

            User saveUser = factory.Generate("gitty", "Gyn Mitty", false);

            records.Save(saveUser);

            User testUser = records.Load(saveUser.ID);

            Assert.True(testUser.IsActive);
            Assert.That(records.Count, Is.EqualTo(1));

            records.Delete(testUser.ID);
            Assert.That(records.Count, Is.EqualTo(0));
        }
コード例 #12
0
        /*** Helper functions, etc ***/

        /* AuthUserAndFetchData()
         *   Checks that user exists, verifies credentials, and fetches account
         *   infromation/records if account is authenticated
         *
         *   Modifies: userData to hold the account data
         *   Returns:  true or false reflecting if records could be retrieved
         */
        public static bool AuthUserAndFetchData(string user, string pass, ref UserRecords userData)
        {
            string cacheName = GetCacheName(user);

            if (!DoesUserExist(user))
            {
                return(false);
            }
            if (!DoesPasswordMatch(user, pass))
            {
                return(false);
            }

            userData = (DBAct.UserRecords)Cache.Get(cacheName);

            return(true);
        }
コード例 #13
0
        public void The_user_records_does_not_crash_when_given_empty_or_missing_parameters()
        {
            UserRecords records = new UserRecords();
            User        test    = records.Load("");

            Assert.True(test.IsEmpty);

            records.Delete("");
            try {
                records.Save(new User());
                Assert.Fail("Should not have saved an empty user");
            }
            catch (InvalidOperationException exception) {
                log.Info("Captured expected exception: " + exception.Message);
            }
            Assert.That(records.Count, Is.EqualTo(0));
        }
コード例 #14
0
        protected void ProcessUserRecord(IWebSocketConnection socket, WebSocketSubscribeMessage subscrMsg)
        {
            if (subscrMsg.ServiceKey != "*")
            {
                UserRecord userRecord = UserRecords.Where(x => x.UserId == subscrMsg.ServiceKey).FirstOrDefault();

                if (userRecord != null)
                {
                    DoSend <UserRecord>(socket, userRecord);
                }
            }
            else
            {
                foreach (UserRecord userRecord in UserRecords)
                {
                    DoSend <UserRecord>(socket, userRecord);
                }
            }
            ProcessSubscriptionResponse(socket, "TB", subscrMsg.ServiceKey, subscrMsg.UUID);
        }
コード例 #15
0
        protected virtual void ProcessClientLoginMock(IWebSocketConnection socket, string m)
        {
            WebSocketLoginMessage wsLogin = JsonConvert.DeserializeObject <WebSocketLoginMessage>(m);


            UserRecord loggedUser = UserRecords.Where(x => x.UserId == wsLogin.UserId).FirstOrDefault();

            DoLog(string.Format("Incoming Login request for user {0}", wsLogin.UUID), MessageType.Information);

            if (loggedUser != null)
            {
                ClientLoginResponse resp = new ClientLoginResponse()
                {
                    Msg          = "ClientLoginResponse",
                    Sender       = wsLogin.Sender,
                    UUID         = wsLogin.UUID,
                    UserId       = wsLogin.UserId,
                    JsonWebToken = _TOKEN
                };


                DoLog(string.Format("user {0} Successfully logged in", wsLogin.UUID), MessageType.Information);
                UserLogged = true;
                DoSend <ClientLoginResponse>(socket, resp);
            }
            else
            {
                ClientReject reject = new ClientReject()
                {
                    Msg          = "ClientReject",
                    Sender       = wsLogin.Sender,
                    UUID         = wsLogin.UUID,
                    UserId       = wsLogin.UserId,
                    RejectReason = string.Format("Invalid user or password")
                };

                DoLog(string.Format("user {0} Rejected because of wrong user or password", wsLogin.UUID), MessageType.Information);
                DoSend <ClientReject>(socket, reject);
                socket.Close();
            }
        }
コード例 #16
0
    void Load(String jsonUnarrangedData, String userId, Action onDataLoaded)
    {
        var unarrangedData = JsonConvert
                             .DeserializeObject <Dictionary <string, Dictionary <string, List <object> > > >(jsonUnarrangedData);

        /* Quando o userId é nulo, isso indica que apenas os dados iniciais são
         * carregados, independentemente do usuário */

        ClearRecords();

        foreach (var table in unarrangedData)
        {
            string tableName = table.Key;
            IEnumerable <string> primaryKeys = table.Value["primaryKeys"].Select(i => ToString());
            List <JObject>       records     = table.Value["records"].Cast <JObject>().ToList();

            foreach (var record in records)
            {
                AssetFilter filter = AssetFilterRecords
                                     .SingleOrDefault(i => i.NamTable == tableName);

                switch (tableName)
                {
                case "assetfilter":
                    AssetFilter assetFilter = record.ToObject <AssetFilter>();
                    // assetFilter.TxtAssetPath = $"Assets/{assetFilter.TxtAssetPath}";
                    AssetFilterRecords.Add(assetFilter);
                    break;

                case "score":     // only current user scores are retrieved
                    Score score = record.ToObject <Score>();
                    ScoreRecords.Add(score);
                    break;

                case "part":
                    Part part = record.ToObject <Part>();
                    PartRecords.Add(part);
                    break;

                case "phase":
                    Phase phase = record.ToObject <Phase>();
                    phase.Part = PartRecords
                                 .SingleOrDefault(i => i.CodPart == phase.CodPart);
                    phase.UserScore = ScoreRecords
                                      .SingleOrDefault(i => i.NumPhase == phase.NumPhase);
                    PhaseRecords.Add(phase);
                    phase.TilemapsGrid = dataUtil
                                         .LoadAsset <Grid>($"Grid_{filter.TxtAssetFilter}_{phase.NumPhase}",
                                                           new[] { filter.TxtAssetPath });
                    break;

                case "gameuser":     // only current user data is retrieved
                    GameUser user = record.ToObject <GameUser>();
                    user.CurrentPhase = PhaseRecords
                                        .SingleOrDefault(i => i.NumPhase == user.NumCurrentPhase);
                    UserRecords.Add(user);
                    break;

                case "troop":
                    Troop troop = record.ToObject <Troop>();
                    troop.GameObject = dataUtil
                                       .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{troop.TxtAssetIdentifier}",
                                                               new[] { filter.TxtAssetPath });
                    TroopRecords.Add(troop);
                    break;

                case "barrack":
                    Barrack barrack = record.ToObject <Barrack>();
                    barrack.Part = PartRecords
                                   .SingleOrDefault(i => i.CodPart == barrack.CodPart);
                    barrack.Troop = TroopRecords
                                    .SingleOrDefault(i => i.CodTroop == barrack.CodTroop);
                    barrack.GameObject = dataUtil
                                         .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{barrack.Troop.TxtAssetIdentifier}",
                                                                 new[] { filter.TxtAssetPath });
                    BarrackRecords.Add(barrack);
                    break;

                case "tower":
                    Tower tower = record.ToObject <Tower>();
                    tower.GameObject = dataUtil
                                       .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{(tower.IsEnemy ? "enemy" : "player")}",
                                                               new[] { filter.TxtAssetPath });
                    TowerRecords.Add(tower);
                    break;

                case "skill":
                    Skill skill = record.ToObject <Skill>();
                    skill.Action = dataUtil
                                   .LoadAsset <SkillAction>($"{filter.TxtAssetFilter}_{skill.TxtAssetIdentifier}",
                                                            new[] { filter.TxtAssetPath });
                    SkillRecords.Add(skill);
                    break;

                case "hero":
                    Hero hero = record.ToObject <Hero>();
                    hero.Part = PartRecords
                                .SingleOrDefault(i => i.CodPart == hero.CodPart);
                    hero.Skills = SkillRecords
                                  .Where(i => i.CodHero == hero.CodHero)
                                  .ToList();
                    hero.GameObject = dataUtil
                                      .LoadAsset <GameObject>($"{filter.TxtAssetFilter}_{hero.TxtAssetIdentifier}",
                                                              new[] { filter.TxtAssetPath });
                    HeroRecords.Add(hero);
                    break;

                case "speak":
                    Speak speak = record.ToObject <Speak>();
                    SpeakRecords.Add(speak);
                    break;

                case "scene":
                    Scene scene = record.ToObject <Scene>();
                    scene.Texts = SpeakRecords
                                  .Where(i => i.CodCutscene == scene.CodCutscene && i.CodScene == scene.CodScene)
                                  .ToList();
                    scene.Sprite = dataUtil
                                   .LoadAsset <Sprite>(new[] { $"{filter.TxtAssetPath}/{scene.TxtImagePath}" });
                    SceneRecords.Add(scene);
                    break;

                case "cutscene":
                    Cutscene cutscene = record.ToObject <Cutscene>();
                    cutscene.Scenes = SceneRecords
                                      .Where(i => i.CodCutscene == cutscene.CodCutscene)
                                      .ToList();
                    CutsceneRecords.Add(cutscene);
                    break;

                default:
                    break;
                }
            }
        }

        if (userId != null && userId.Length != 0 && UserRecords.Count == 1)
        {
            loadedUser = UserRecords.SingleOrDefault();
            SaveUserData(loadedUser); // remove later
        }

        if (!(onDataLoaded is null))
        {
            onDataLoaded();
        }
    }
コード例 #17
0
        public ActionResult Registration(UserRecords usermodel)
        {
            usermodel.AddressId         = 1;
            usermodel.UserId            = 12;
            usermodel.LoginErrorMessage = "No error";
            using (IPHISEntities dbmodel = new IPHISEntities())
            {
                List <UserType> list = dbmodel.UserTypes.ToList();
                ViewBag.UserTypeList = new SelectList(list, "UserTypeId", "TypeName");

                List <Country> Clist = dbmodel.Countries.ToList();
                ViewBag.CountryList = new SelectList(Clist, "CountryId", "CountryName");

                List <State> Slist = dbmodel.States.ToList();
                ViewBag.StateList = new SelectList(Slist, "StateId", "StateName");

                List <City> Cilist = dbmodel.Cities.ToList();
                ViewBag.CityList = new SelectList(Cilist, "CityId", "CityName");
                ////dbmodel.Addresses.Add(usermodel);
                //dbmodel.Users.Add(usermodel);
                //usermodel1.UserTypesCollection = dbmodel.UserTypes.ToList<UserType>();
                //dbmodel.SaveChanges();
                ////var emp = dbmodel.User_Addr_Sec_Ans(usermodel.FirstName, usermodel.MiddleName, usermodel.LastName, usermodel.EmailAddress, usermodel.Password, usermodel.PhoneNumber, usermodel.UserUniqueId, usermodel.UserTypeId);

                User usermodel1 = new User();
                usermodel1.FirstName    = usermodel.FirstName;
                usermodel1.MiddleName   = usermodel.MiddleName;
                usermodel1.LastName     = usermodel.LastName;
                usermodel1.EmailAddress = usermodel.EmailAddress;
                usermodel1.Password     = usermodel.Password;
                usermodel1.PhoneNumber  = usermodel.PhoneNumber;
                usermodel1.UserUniqueId = usermodel.UserUniqueId;
                usermodel1.UserTypeId   = usermodel.UserTypeId;
                usermodel1.CountryId    = usermodel.CountryId;
                usermodel1.StateId      = usermodel.StateId;
                usermodel1.CityId       = usermodel.CityId;

                dbmodel.Users.Add(usermodel1);
                try
                {
                    dbmodel.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    Console.WriteLine(e);
                }


                int     LatestUserId = usermodel1.UserId;
                Address addrmodel    = new Address();
                addrmodel.UserId       = LatestUserId;
                addrmodel.AddressLine1 = usermodel.AddressLine1;
                addrmodel.AddressLine2 = usermodel.AddressLine2;
                addrmodel.Pincode      = usermodel.Pincode;

                dbmodel.Addresses.Add(addrmodel);
                try
                {
                    dbmodel.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    Console.WriteLine(e);
                }

                //Country countrymodel = new Country();
                //countrymodel.UserId = LatestUserId;
                //countrymodel.CountryId = usermodel.CountryId;
            }

            ModelState.Clear();
            ViewBag.SuccessMessage = "Registration Successfull.";
            return(View("Registration", new UserRecords()));
        }
コード例 #18
0
        public ActionResult Registration(int id = 0)
        {
            UserRecords usermodel = new UserRecords();

            usermodel.UserTypesCollection = new List <UserType>();
            usermodel.CountriesCollection = new List <Country>();
            usermodel.StatesCollection    = new List <State>();
            usermodel.CitiesCollection    = new List <City>();
            using (IPHISEntities dbmodel = new IPHISEntities())
            {
                List <UserType> list = dbmodel.UserTypes.ToList();
                ViewBag.UserTypeList = new SelectList(list, "UserTypeId", "TypeName");
                var v = dbmodel.UserTypes.OrderBy(x => x.UserTypeId);
                int a = v.Count();
                foreach (UserType t in v)
                {
                    usermodel.UserTypesCollection.Add(new UserType
                    {
                        UserTypeId = t.UserTypeId,
                        TypeName   = t.TypeName
                    });
                }

                List <Country> Clist = dbmodel.Countries.ToList();
                ViewBag.CountryList = new SelectList(Clist, "CountryId", "CountryName", "CountryCode");
                var c = dbmodel.Countries.OrderBy(x => x.CountryId);
                int b = c.Count();
                foreach (Country ct in c)
                {
                    usermodel.CountriesCollection.Add(new Country
                    {
                        CountryId   = ct.CountryId,
                        CountryName = ct.CountryName,
                        CountryCode = ct.CountryCode
                    });
                }

                List <State> Slist = dbmodel.States.ToList();
                ViewBag.StateList = new SelectList(Slist, "StateId", "StateName");
                var s = dbmodel.States.OrderBy(x => x.StateId);
                int d = s.Count();
                foreach (State st in s)
                {
                    usermodel.StatesCollection.Add(new State
                    {
                        StateId   = st.StateId,
                        StateName = st.StateName
                    });
                }

                List <City> Cilist = dbmodel.Cities.ToList();
                ViewBag.CityList = new SelectList(Cilist, "CityId", "CityName");
                var ci = dbmodel.Cities.OrderBy(x => x.CityId);
                int e  = ci.Count();
                foreach (City cty in ci)
                {
                    usermodel.CitiesCollection.Add(new City
                    {
                        CityId   = cty.CityId,
                        CityName = cty.CityName
                    });
                }
                return(View(usermodel));
            }
        }