Exemple #1
0
        public ResGetUser Get([FromForm] ReqGetUser user)
        {
            ResGetUser retValue = new ResGetUser();

            try
            {
                using (var db = DbContext.GetInstance())
                {
                    var my = db.Queryable <T_USERS>()
                             .Where(s => s.ID == user.ID)
                             .FirstOrDefault();

                    UsersBase users = new UsersBase();
                    //转化成前端友好的数据
                    users = ModelConvert.FromTo <T_USERS, UsersBase>(my, users);
                    retValue.SuccessDefalut(users, 1, "不存在该用户");
                }
            }
            catch (Exception ex)
            {
                retValue.FailDefalut(ex);
            }

            return(retValue);
        }
Exemple #2
0
        public ResGetUser GetUrl([FromForm] ReqGetUser user)
        {
            ResGetUser retValue   = new ResGetUser();
            string     logContent = string.Empty;

            try
            {
                using (var db = DbContext.GetInstance(ref logContent))
                {
                    var my = db.Queryable <T_USERS>()
                             .Where(s => s.ID == user.ID)
                             .FirstOrDefault();
                    //转化成前端友好的数据
                    UsersBase users = new UsersBase();
                    users = ModelConvert.FromTo <T_USERS, UsersBase>(my, users);
                    retValue.SuccessDefalut(users, 1, "不存在该用户");

                    //记录日志
                    Startup.log.Info(LogHelper.LogDetails(logContent, user, retValue));
                }
            }
            catch (Exception ex)
            {
                retValue.FailDefalut(ex);
                Startup.log.Error(logContent, ex);
            }

            return(retValue);
        }
Exemple #3
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(UsersBase serviceImpl)
 {
     return grpc::ServerServiceDefinition.CreateBuilder()
         .AddMethod(__Method_Get, serviceImpl.GetAsync)
         .AddMethod(__Method_Post, serviceImpl.PostAsync)
         .AddMethod(__Method_Login, serviceImpl.LoginAsync).Build();
 }
        public bool IsLoginPassOk(string login, string pass)
        {
            if (UsersBase.ContainsKey(login))
            {
                return(UsersBase[login].Equals(pass));
            }

            return(false);
        }
        public bool AddUserToBase(string login, string pass)
        {
            if (UsersBase.ContainsKey(login))
            {
                return(false);
            }

            UsersBase.Add(login, pass);
            return(true);
        }
        public bool RemoveUserFromBase(string login)
        {
            if (!UsersBase.ContainsKey(login))
            {
                return(false);
            }

            UsersBase.Remove(login);
            return(true);
        }
Exemple #7
0
 public ViewResult Index(UsersBase uBase)
 {
     if (uBase.CheckForm())
     {
         ViewBag.Title = "Projects";
         ViewBag.List  = divProjects.listProjects;
         return(View("Projects"));
     }
     ViewBag.Title = "Main";
     return(View("Index"));
 }
        public ActionResult <UsersBase> GetUsersBase(int id)
        {
            WebClient client   = new WebClient();
            string    response = client.DownloadString("http://jsonplaceholder.typicode.com/users/" + id + "");

            UsersBase Users = JsonConvert.DeserializeObject <UsersBase>(response);

            byte[] buffer = EncryptStringToBytes_Aes(Users.Email, myAes.Key, myAes.IV);
            Users.Email = Encoding.UTF8.GetString(buffer, 0, buffer.Length);

            return(Users);
        }
        /// <summary>
        /// Fills Users object
        /// </summary>
        /// <param name="usersObject">The object to be filled</param>
        /// <param name="reader">The reader to use to fill a single object</param>
        /// <param name="start">The ordinal position from which to start reading the reader</param>
        protected void FillObject(UsersBase usersObject, SqlDataReader reader, int start)
        {
            usersObject.Id     = reader.GetInt32(start + 0);
            usersObject.UserId = reader.GetGuid(start + 1);
            if (!reader.IsDBNull(2))
            {
                usersObject.FirstName = reader.GetString(start + 2);
            }
            if (!reader.IsDBNull(3))
            {
                usersObject.LastName = reader.GetString(start + 3);
            }
            if (!reader.IsDBNull(4))
            {
                usersObject.PhoneNumber = reader.GetString(start + 4);
            }
            if (!reader.IsDBNull(5))
            {
                usersObject.PhoneNumber2 = reader.GetString(start + 5);
            }
            if (!reader.IsDBNull(6))
            {
                usersObject.EmailAddress = reader.GetString(start + 6);
            }
            if (!reader.IsDBNull(7))
            {
                usersObject.Street = reader.GetString(start + 7);
            }
            if (!reader.IsDBNull(8))
            {
                usersObject.City = reader.GetString(start + 8);
            }
            if (!reader.IsDBNull(9))
            {
                usersObject.State = reader.GetString(start + 9);
            }
            if (!reader.IsDBNull(10))
            {
                usersObject.ZipCode = reader.GetString(start + 10);
            }
            usersObject.CreatedBy = reader.GetGuid(start + 11);
            if (!reader.IsDBNull(12))
            {
                usersObject.CreatedDate = reader.GetDateTime(start + 12);
            }
            usersObject.LastUpdatedBy  = reader.GetGuid(start + 13);
            usersObject.LatUpdatedDate = reader.GetGuid(start + 14);
            FillBaseObject(usersObject, reader, (start + 15));


            usersObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
        }
Exemple #10
0
        /// <summary>
        /// Copies the specified destination.
        /// </summary>
        /// <param name="destination">The destination.</param>
        protected override void Copy(object destination)
        {
            UsersBase <TPool> dest = destination as UsersBase <TPool>;

            dest._Email     = _Email;
            dest._FirstName = _FirstName;
            dest._LastName  = _LastName;
            dest._Login     = _Login;
            dest._Password  = _Password;
            dest._UserID    = _UserID;

            base.Copy(destination);
        }
 /// <summary>
 /// Add common parameters before calling a procedure
 /// </summary>
 /// <param name="cmd">command object, where parameters will be added</param>
 /// <param name="usersObject"></param>
 private void AddCommonParams(SqlCommand cmd, UsersBase usersObject)
 {
     AddParameter(cmd, pGuid(UsersBase.Property_UserId, usersObject.UserId));
     AddParameter(cmd, pNVarChar(UsersBase.Property_FirstName, 100, usersObject.FirstName));
     AddParameter(cmd, pNVarChar(UsersBase.Property_LastName, 100, usersObject.LastName));
     AddParameter(cmd, pNVarChar(UsersBase.Property_PhoneNumber, 100, usersObject.PhoneNumber));
     AddParameter(cmd, pNVarChar(UsersBase.Property_PhoneNumber2, 100, usersObject.PhoneNumber2));
     AddParameter(cmd, pNVarChar(UsersBase.Property_EmailAddress, 500, usersObject.EmailAddress));
     AddParameter(cmd, pNVarChar(UsersBase.Property_Street, 500, usersObject.Street));
     AddParameter(cmd, pNVarChar(UsersBase.Property_City, 500, usersObject.City));
     AddParameter(cmd, pNVarChar(UsersBase.Property_State, 500, usersObject.State));
     AddParameter(cmd, pNVarChar(UsersBase.Property_ZipCode, 50, usersObject.ZipCode));
     AddParameter(cmd, pGuid(UsersBase.Property_CreatedBy, usersObject.CreatedBy));
     AddParameter(cmd, pDateTime(UsersBase.Property_CreatedDate, usersObject.CreatedDate));
     AddParameter(cmd, pGuid(UsersBase.Property_LastUpdatedBy, usersObject.LastUpdatedBy));
     AddParameter(cmd, pGuid(UsersBase.Property_LatUpdatedDate, usersObject.LatUpdatedDate));
 }
        /// <summary>
        /// Updates Users
        /// </summary>
        /// <param name="usersObject">Object to be updated</param>
        /// <returns>Number of rows affected</returns>
        public long Update(UsersBase usersObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(UPDATEUSERS);

                AddParameter(cmd, pInt32(UsersBase.Property_Id, usersObject.Id));
                AddCommonParams(cmd, usersObject);

                long result = UpdateRecord(cmd);
                if (result > 0)
                {
                    usersObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectUpdateException(usersObject, x);
            }
        }
        /// <summary>
        /// Inserts Users
        /// </summary>
        /// <param name="usersObject">Object to be inserted</param>
        /// <returns>Number of rows affected</returns>
        public long Insert(UsersBase usersObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(INSERTUSERS);

                AddParameter(cmd, pInt32Out(UsersBase.Property_Id));
                AddCommonParams(cmd, usersObject);

                long result = InsertRecord(cmd);
                if (result > 0)
                {
                    usersObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                    usersObject.Id       = (Int32)GetOutParameter(cmd, UsersBase.Property_Id);
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectInsertException(usersObject, x);
            }
        }
Exemple #14
0
        static void Main()
        {
            Operator A1 = new Operator();

            TariffsBase tariffs = new TariffsBase();

            tariffs.AddTariff(A1.MakeTariff("Comfort", 12.1));
            tariffs.AddTariff(A1.MakeTariff("Lite", 1));

            UsersBase usersBase = new UsersBase();

            for (int i = 0; i < 10_000_000; i++)
            {
                usersBase.AddUser(A1.MakeUser($"{i}", tariffs.Tariffs["Lite"]));
            }

            var st = new Stopwatch();
            //usersBase.AddUser(A1.MakeUser("Kostya", tariffs.Tariffs["Lite"]));

            NonParallelManager nonParallelManager = new NonParallelManager();
            ParallelManager    parallelManager    = new ParallelManager();

            st.Start();
            Printer.Print($"{nonParallelManager.MonthlyIncome(usersBase.Base)}\n");
            st.Stop();

            Printer.Print($"NonParllel - {st.ElapsedMilliseconds}\n");

            st.Reset();

            st.Start();
            Printer.Print($"{parallelManager.MonthlyIncome(usersBase.Base)}\n");
            st.Stop();

            Printer.Print($"Parallel - {st.ElapsedMilliseconds}\n");
        }
 public async Task <ActionResult <UsersBase> > PostUsersBase(UsersBase usersBase)
 {
     return(NoContent());
 }
 public async Task <IActionResult> PutUsersBase(int id, UsersBase usersBase)
 {
     return(NoContent());
 }
 /// <summary>
 /// Fills Users object
 /// </summary>
 /// <param name="usersObject">The object to be filled</param>
 /// <param name="reader">The reader to use to fill a single object</param>
 protected void FillObject(UsersBase usersObject, SqlDataReader reader)
 {
     FillObject(usersObject, reader, 0);
 }
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(UsersBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_GetUsers, serviceImpl.GetUsers).Build());
 }
Exemple #19
0
 /// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, UsersBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Get, serviceImpl.GetAsync);
     serviceBinder.AddMethod(__Method_Post, serviceImpl.PostAsync);
     serviceBinder.AddMethod(__Method_Login, serviceImpl.LoginAsync);
 }
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, UsersBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_GetUsers, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod <global::UserService.UserRequest, global::UserService.UserResponse>(serviceImpl.GetUsers));
 }