Esempio n. 1
0
 public OutputPin(SimulationEngine engine, int dataBitWidth)
     : base(engine)
 {
     this.DataBitWidth         = dataBitWidth;
     this.In                   = new ReadConnection(this.DataBitWidth);
     this.In.DataValueChanged += this.OnInputDataValueChanged;
 }
 public override Task <IEnumerable <TEntity> > GetAllListAsync()
 {
     using (ReadConnection)
     {
         return(ReadConnection.GetAllAsync <TEntity>());
     }
 }
Esempio n. 3
0
        public async Task <List <People> > GetPeoples()
        {
            string sql     = "Select * From people";
            var    peoples = ReadConnection.Query <People>(sql).ToList();

            return(peoples);
        }
 public override Task <TEntity> GetAsync(TPrimaryKey id)
 {
     using (ReadConnection)
     {
         return(ReadConnection.GetAsync <TEntity>(id));
     }
 }
 public async Task ImportExcel(Queue <DriverVM> listModel)
 {
     try
     {
         if (listModel != null && listModel.Count > 0)
         {
             //Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
             //MySqlConnection con = new MySqlConnection("server=192.168.1.208;userid=root;pwd=lyh888150;database=ccp(latest);sslmode=none;");
             foreach (var item in listModel)
             {
                 string sql  = $"select * from aspnetusers where PhoneNumber={item.PhoneNumber}";
                 var    user = new Aspnetusers();
                 using (ReadConnection)
                 {
                     user = await ReadConnection.QueryFirstOrDefaultAsync <Aspnetusers>(sql);
                 }
                 if (user != null)
                 {
                     if (user.UserCategory != UserCategory.JFEmployees)
                     {
                         user.UserCategory = UserCategory.JFEmployees;
                         using (WriteConnection)
                         {
                             await WriteConnection.UpdateAsync(user);
                         }
                     }
                 }
                 else
                 {
                     var newuser = new Aspnetusers()
                     {
                         PhoneNumber = item.PhoneNumber,
                         UserName    = item.PhoneNumber,
                         CertificatePhotoCertificationState  = CertificationStatus.Uncommitted,
                         DrivingLicenseKeyCertificationState = CertificationStatus.Uncommitted,
                         IdentityCardCertificationState      = CertificationStatus.Uncommitted,
                         LockoutEnabled      = true,
                         RealNameStatus      = CertificationStatus.Uncommitted,
                         CertificationStatus = CertificationStatus.Uncommitted,
                         TrailerLicenseCertificationStatus = CertificationStatus.Uncommitted,
                         VehiclePhotoCertificationStatus   = CertificationStatus.Uncommitted,
                         RoleType            = ApplicationRoleType.Driver,
                         RoadTransportStatus = CertificationStatus.Uncommitted,
                         Date         = DateTime.Now,
                         UserCategory = UserCategory.JFEmployees
                     };
                     using (WriteConnection)
                     {
                         await WriteConnection.InsertAsync(newuser);;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task <Tuple <List <MaintenanceInfoResponse>, int> > GetPageListAsync(MaintenanceInfoPageRequest request)
        {
            StringBuilder     sbSql      = new StringBuilder();
            StringBuilder     sbCount    = new StringBuilder();
            DynamicParameters parameters = new DynamicParameters();

            sbSql.Append(@" SELECT * FROM maintenanceinfo m 
                            LEFT JOIN servicebusiness s ON m.RepairId = s.Id
                            LEFT JOIN attachment a ON m.Id = a.DataId AND a.IsDeleted = 0 AND a.DataType = 1 
                            WHERE 1=1 ");
            sbCount.Append(" SELECT COUNT(*) FROM maintenanceinfo m WHERE 1=1 ");
            var where = this.GetWhere(request, parameters);
            if (where?.Item1?.Length > 0)
            {
                sbSql.Append(where.Item1);
                sbCount.Append(where.Item1);
            }
            //添加排序
            sbSql.Append(" Order By m.CreationTime DESC ");
            if (request.Count.HasValue && request.Count.Value > 0)
            {
                sbSql.Append(" LIMIT @Skip,@Count ");
                parameters.Add("@Skip", request.Skip.Value);
                parameters.Add("@Count", request.Count.Value);
            }
            using (ReadConnection)
            {
                var lookup = new Dictionary <Guid, MaintenanceInfoResponse>();
                var query  = ReadConnection.Query <MaintenanceInfoResponse, ServiceBusiness, Attachment, List <MaintenanceInfoResponse> >(sbSql.ToString(), (a, c, b) =>
                {
                    if (!lookup.Keys.Contains(a.Id))
                    {
                        if (a != null && c != null)
                        {
                            a.ServiceBusiness = c;
                        }
                        lookup.Add(a.Id, a);
                        if (lookup[a.Id].Attachments == null)
                        {
                            lookup[a.Id].Attachments = new List <Attachment>();
                        }
                        lookup[a.Id].Attachments.Add(b);
                    }
                    else
                    {
                        lookup[a.Id].Attachments.Add(b);
                    }
                    return(lookup.Values.ToList());
                }, parameters);


                int r2 = 0;
                if (request.Count.HasValue && request.Count.Value > 0)
                {
                    r2 = await ReadConnection.QueryFirstAsync <int>(sbCount.ToString(), parameters);
                }
                return(new Tuple <List <MaintenanceInfoResponse>, int>(lookup.Values.ToList(), r2));
            }
        }
Esempio n. 7
0
 public Probe(SimulationEngine engine, int dataBitWidth)
     : base(engine)
 {
     this.DataBitWidth         = dataBitWidth;
     this.DataValue            = DataValue.Floating(this.DataBitWidth);
     this.In                   = new ReadConnection(this.DataBitWidth);
     this.In.DataValueChanged += this.OnInputDataValueChanged;
 }
Esempio n. 8
0
        public void Join(string channel)
        {
            ReadConnection.WriteLine("JOIN " + channel);

            if (!SingleConnection)
            {
                WriteConnection.WriteLine("JOIN " + channel);
            }
        }
Esempio n. 9
0
        public void Reconnect()
        {
            ReadConnection.Reconnect();

            if (!SingleConnection)
            {
                WriteConnection.Reconnect();
            }
        }
Esempio n. 10
0
        public void Part(string channel)
        {
            ReadConnection.WriteLine("PART " + channel);

            if (!SingleConnection)
            {
                WriteConnection.WriteLine("PART " + channel);
            }
        }
Esempio n. 11
0
        public void Connect(string username, string password)
        {
            ReadConnection.Connect(username, password);

            if (!SingleConnection)
            {
                WriteConnection.Connect(username, password);
            }
        }
Esempio n. 12
0
        public void Disconnect()
        {
            ReadConnection.Dispose();

            if (!SingleConnection)
            {
                WriteConnection.Dispose();
            }
        }
Esempio n. 13
0
        public async Task <List <Users> > GetUsers()
        {
            using (ReadConnection)
            {
                string sql = @"select * from Users;";
                var    res = await ReadConnection.QueryAsync <Users>(sql);

                return(res.ToList());
            }
        }
Esempio n. 14
0
        private IModel GetOrCreateChannel(string @event)
        {
            if (SubscribeChannels.TryGetValue(@event, out var channel))
            {
                return(channel);
            }
            var createChannel = ReadConnection.CreateModel();

            SubscribeChannels.TryAdd(@event, createChannel);
            return(createChannel);
        }
Esempio n. 15
0
        /// <summary>
        ///     Disconnect disconnects the Client from the Amqp Server.
        /// </summary>
        /// <param name="code">The status code of the disconnect.</param>
        /// <param name="text">The status text of the disconnect.</param>
        public void Disconnect(ushort code, string text)
        {
            lock (PublishChannel)
            {
                PublishChannel.Close(code, text);
            }

            foreach (var value in SubscribeChannels.Values)
            {
                value.Close();
            }
            WriteConnection.Close(code, text);
            ReadConnection.Close(code, text);
        }
Esempio n. 16
0
        public async Task <UserInfo> FindByLoginKeyAsync(string keyWord)
        {
            DynamicParameters param = new DynamicParameters();
            string            sql   = @"select * from userinfo
                         where PhoneNumber=@keyWord or Email=@KeyWord";

            param.Add("@keyWord", keyWord);
            param.Add("@KeyWord", keyWord);
            using (ReadConnection)
            {
                var result = await ReadConnection.QueryFirstOrDefaultAsync <UserInfo>(sql, param);

                return(result);
            }
        }
Esempio n. 17
0
        public async Task <UserDO> Login(string username, string password)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from ums_user u where u.enabled=1 and u.username=@username and u.password=@password");
            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("@username", username);
            parameters.Add("@password", password);
            using (ReadConnection)
            {
                var result = await ReadConnection.QueryAsync <UserDO>(sql.ToString(), parameters);

                return(result.FirstOrDefault());
            }
        }
Esempio n. 18
0
        public async Task <int> GetCodeTotalCount(string tableName, string paramName)
        {
            int           totalCount = 0;
            StringBuilder codeSql    = new StringBuilder();

            codeSql.AppendFormat("SELECT {0} FROM {1} WHERE CreationTime >= @TodayStart AND CreationTime < @TodayEnd ORDER BY {0} DESC LIMIT 0,1;", paramName, tableName);
            DateTime TodayStart = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            DateTime TodayEnd   = TodayStart.AddDays(1);
            var      list       = ReadConnection.Query <string>(codeSql.ToString(), new { TodayStart = TodayStart, TodayEnd = TodayEnd }).ToList();

            if (list?.Count > 0)
            {
                totalCount = int.Parse(list.FirstOrDefault().Substring(7, 4));
            }
            return(totalCount);
        }
Esempio n. 19
0
        public async override Task <Tuple <int, IList <TEntity> > > GetListAsync(IQueryObject <TEntity> query)
        {
            var parameters = new DynamicParameters();
            var select     = ExpressionHelper.Select <TEntity>();
            var count      = ExpressionHelper.Count <TEntity>();

            foreach (var where in query.QueryExpression)
            {
                select.Where(where);
            }
            foreach (var where in query.QueryExpression)
            {
                count.Where(where);
            }
            select.Where(x => x.IsDeleted == false);
            count.Where(x => x.IsDeleted == false);
            if (query.OrderSort == SortOrder.ASC)
            {
                select.OrderBy(query.OrderField);
            }
            else if (query.OrderSort == SortOrder.DESC)
            {
                select.OrderByDesc(query.OrderField);
            }
            else
            {
                select.OrderByDesc(x => x.CreationTime);
            }
            if (query.Count >= 0)
            {
                select.Limit(query.Skip, query.Count);
            }

            foreach (KeyValuePair <string, object> item in select.DbParams)
            {
                parameters.Add(item.Key, item.Value);
            }

            using (Connection)
            {
                var customerRepresentativeList = await ReadConnection.QueryAsync <TEntity>(select.Sql, parameters);

                int totalCount = await ReadConnection.QuerySingleAsync <int>(count.Sql, parameters);

                return(new Tuple <int, IList <TEntity> >(totalCount, customerRepresentativeList.ToList()));
            }
        }
Esempio n. 20
0
        public async Task <List <MachineryInfo> > GetListAsync(MachineryInfoSearchRequest request)
        {
            StringBuilder     sbSql      = new StringBuilder();
            DynamicParameters parameters = new DynamicParameters();

            sbSql.Append(" SELECT * FROM machineryinfo WHERE IsDeleted = 0  ");
            var where = this.GetWhere(request, parameters);
            if (where?.Item1?.Length > 0)
            {
                sbSql.Append(where.Item1);
            }
            //添加排序
            sbSql.Append(" Order By CreationTime DESC ");
            using (ReadConnection)
            {
                var r1 = await ReadConnection.QueryAsync <MachineryInfo>(sbSql.ToString(), parameters);

                return(r1.ToList());
            }
        }
        /// <summary>
        /// 根据查询条件查询总数
        /// </summary>
        /// <param name="query">查询对象</param>
        /// <returns></returns>
        public override async Task <int> CountAsync(IQueryObject <TEntity> query)
        {
            var parameters = new DynamicParameters();
            var count      = ExpressionHelper.Count <TEntity>();

            foreach (var where in query.QueryExpression)
            {
                count.Where(where);
            }

            foreach (KeyValuePair <string, object> item in count.DbParams)
            {
                parameters.Add(item.Key, item.Value);
            }

            using (ReadConnection)
            {
                var Count = await ReadConnection.QuerySingleAsync <int>(count.Sql, parameters);

                return(Count);
            }
        }
Esempio n. 22
0
        public override async Task <Tuple <int, IList <GoodsInfo> > > GetListAsync(IQueryObject <GoodsInfo> query)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select g.*, u.* from goodsinfo g LEFT JOIN userinfo u ON g.UserId=u.Id WHERE 1=1 and g.IsDelete=0 ");
            StringBuilder sbCount = new StringBuilder();

            sbCount.Append("select COUNT(g.Id) from goodsinfo g LEFT JOIN userinfo u ON g.UserId=u.Id WHERE 1=1 and g.IsDelete=0 ");
            var queryandsort = query.QuerySql.FirstOrDefault();

            if (query.QuerySql.Count > 0)
            {
                sb.Append(queryandsort.Key);
                sbCount.Append(queryandsort.Key);
            }
            if (query.Count <= 0)
            {
                query.Count = int.MaxValue;
            }
            sb.Append(" LIMIT " + query.Skip + "," + query.Count);
            using (ReadConnection)
            {
                var GoodsList = await ReadConnection.QueryAsync <GoodsInfo, UserInfo, GoodsInfo>(sb.ToString(), (goodsinfo, usersinfo) =>
                {
                    if (goodsinfo != null)
                    {
                        goodsinfo.UserInfo = usersinfo;
                    }
                    return(goodsinfo);
                }, queryandsort.Value);

                int totalCount = await ReadConnection.QuerySingleAsync <int>(sbCount.ToString(), queryandsort.Value);

                return(new Tuple <int, IList <GoodsInfo> >(totalCount, GoodsList.ToList()));
            }
        }
Esempio n. 23
0
        public void ReadConnection()
        {
            var bitWidth = 2;

            var connection = new ReadConnection(bitWidth);
        }