コード例 #1
0
        public UserResult Create(UserParam param)
        {
            Data.Entity.User entity = UserParamConverter.Convert(param, null);
            UserDao.Save(entity);

            return(UserResultConverter.Convert(entity));
        }
コード例 #2
0
        public async Task <string> QueryPagedAsync([FromQuery] UserParam param)
        {
            var filter = param.SearchLambda <User, UserParam>();
            var result = await _userRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter);

            var userList = new List <User>();

            foreach (var item in result.Items)
            {
                var userLogins = await _userLoginRepository.QueryAsync(c => c.UserId == item.Id);

                item.LoginTimes = userLogins.Count();
                var userlogin = userLogins.OrderByDescending(c => c.CreateTime).Skip(1).FirstOrDefault();
                if (userlogin == null)
                {
                    continue;
                }
                item.LastLoginTime = userlogin.CreateTime;
                item.LastLoginIp   = userlogin.LoginIp;
            }
            var pageData = new PagedDto <User>
            {
                Code     = 200,
                Msg      = "获取数据成功",
                Total    = result.TotalResults,
                PageSize = param.PageSize,
                Data     = result.Items.ToList()
            };
            var json = pageData.ToString();

            return(json);
        }
コード例 #3
0
        public async Task <ApiRequestResult> AddAsync([FromBody] UserParam param)
        {
            var userId      = Guid.NewGuid();
            var asampleUser = new ASampleUser
            {
                Id          = userId.ToString(),
                UserName    = param.UserName,
                Email       = param.Email,
                PhoneNumber = param.PhoneNumber,
            };
            var hashedNewPassword = _userManager.PasswordHasher.HashPassword(asampleUser, param.Password);
            var user = new TUser
            {
                Id          = userId,
                UserName    = param.UserName,
                Email       = param.Email,
                PhoneNumber = param.PhoneNumber,
                Password    = hashedNewPassword,
                OrgId       = param.OrgId,
                LoginName   = param.LoginName,
            };
            var result = await _userManager.CreateAsync(asampleUser, param.Password);

            if (result.Succeeded)
            {
                await _iTUserRepository.AddAsync(user);

                return(ApiRequestResult.Success("添加成功"));
            }
            return(ApiRequestResult.Error(result.Errors.FirstOrDefault().Description));
        }
コード例 #4
0
ファイル: ProcessingListView.cs プロジェクト: zrolfs/pwiz
        public SpectrumList_Thresholder_ListViewItem(ProcessingMethod method)
            : base("Thresholder")
        {
            initializeComponents();

            // parse type, orientation, and threshold from method
            UserParam param = method.userParam("threshold");

            if (param.type == "SeeMS")
            {
                thresholdTextBox.Text = param.value;
            }

            param = method.userParam("type");
            if (param.type == "SeeMS")
            {
                thresholdingTypeComboBox.SelectedIndex = (int)param.value;
            }

            param = method.userParam("orientation");
            if (param.type == "SeeMS")
            {
                thresholdingOrientationComboBox.SelectedIndex = (int)param.value;
            }
        }
コード例 #5
0
        public UserEditForm(UserParam user, bool createMode)
        {
            _createMode = createMode;
            InitializeComponent();

            teRate.MaxValue = 1.00;
            if (createMode)
            {
                User        = new UserParam();
                User.Roles  = new RoleTypes[0];
                tePass.Text = null;
            }
            else
            {
                User             = user;
                tePass.Text      = "hiden_pass";
                teLogin.Enabled  = false;
                teLogin.ReadOnly = true;
            }

            teLogin.Text     = User.Login;
            teName.Text      = User.UserName;
            teRate.Text      = User.Rate.ToString();
            cbPayIn.Checked  = User.Roles.Contains(RoleTypes.Payin);
            cbPayOut.Checked = User.Roles.Contains(RoleTypes.Payout);
            _passIsChanged   = false;
        }
コード例 #6
0
        public ResponseResultDto <bool> UpdateUserPassword(UserParam userParam)
        {
            var res = userRepository.ValidateSmsCode(userParam.Phone, userParam.SmsCode);

            if (!res.Item1)
            {
                return(new ResponseResultDto <bool>
                {
                    IsSuccess = false,
                    ErrorMessage = "验证码不正确",
                    Result = false
                });
            }
            userRepository.DeleteSmsCode(userParam.Phone, userParam.SmsCode);

            if (userParam == null || string.IsNullOrWhiteSpace(userParam.Phone) || string.IsNullOrWhiteSpace(userParam.Password))
            {
                return(new ResponseResultDto <bool>
                {
                    IsSuccess = false,
                    ErrorMessage = "参数异常",
                    Result = false
                });
            }
            var result = userRepository.UpdateUserPassword(userParam);

            return(new ResponseResultDto <bool>
            {
                IsSuccess = result,
                ErrorMessage = string.Empty,
                Result = result
            });
        }
コード例 #7
0
        /// <summary>
        /// 执行提交操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtUserName.Text))
            {
                MessageBox.Show("姓名不为空", "错误提示!");
                return;
            }
            if (String.IsNullOrEmpty(txtUserPhone.Text))
            {
                MessageBox.Show("电话不为空", "错误提示!");
                return;
            }
            if (String.IsNullOrEmpty(txtUserAdd.Text))
            {
                MessageBox.Show("地址不为空", "错误提示!");
                return;
            }
            if (String.IsNullOrEmpty(txtUserSex.Text))
            {
                MessageBox.Show("性别不为空", "错误提示!");
                return;
            }


            UserParam up = new UserParam()
            {
                UserAdd = txtUserAdd.Text, UserName = txtUserName.Text, UserPhone = txtUserPhone.Text, UserSex = txtUserSex.Text
            };
            CreateUserInfoHelper creatUser = new CreateUserInfoHelper(up);

            creatUser.CreateProcess += new EventHandler <CreateUserInfoHelper.CreateArgs>(CreateProcess);
            creatUser.Create();
            processPanel.Visibility = Visibility.Visible;
        }
コード例 #8
0
        public Response Index(UserParam param, [FromServices] IConfiguration configuration)
        {
            var currentUser = _user.Query(param, configuration);

            if (currentUser == null)
            {
                return(new Response(Enum.ResultEnum.Fail, "账号或密码不正确"));
            }

            var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JwtSettiing:IssuerSigningKey"]));

            var claims = new List <Claim>
            {
                new Claim(ClaimTypes.Name, currentUser.Name),
                new Claim("userId", currentUser.ID.ToString())
            };

            claims.AddRange(currentUser.RolesId.Split(',').Select(u => new Claim(ClaimTypes.Role, u)));

            var token = new JwtSecurityToken(
                configuration["JwtSettiing:ValidIssuer"],
                configuration["JwtSettiing:ValidAudience"],
                claims,
                null,
                DateTime.Now.AddMinutes(30),
                new SigningCredentials(key, SecurityAlgorithms.HmacSha256)
                );

            return(new Response(new JwtSecurityTokenHandler().WriteToken(token)));
        }
コード例 #9
0
        public bool AddNewLogin(UserParam loginInfo)
        {
            if (string.IsNullOrWhiteSpace(loginInfo.Login))
            {
                return(false);
            }

            _usersLock.EnterUpgradeableReadLock();
            if (_users.ContainsKey(loginInfo.Login))
            {
                _usersLock.ExitUpgradeableReadLock();
                return(false);
            }

            _usersLock.EnterWriteLock();
            _users.Add(loginInfo.Login, loginInfo);
            _usersLock.ExitWriteLock();
            _usersLock.ExitUpgradeableReadLock();

            try
            {
                _userProvider.Logins.Add(loginInfo);
                _watcher.EnableRaisingEvents = false;
                _userProvider.Save(_basePath);
                _watcher.EnableRaisingEvents = true;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #10
0
ファイル: UserValidation.cs プロジェクト: Tonparn/COS2209
 public static void ValidateRegister(UserParam user)
 {
     if (!validateEmail(user.Email) || string.IsNullOrWhiteSpace(user.Password))
     {
         throw new EmailException(Message.InvalidEmail);
     }
 }
コード例 #11
0
        private UsersProvider(bool AddDefaultData)
        {
            AdminPass = LogonManager.GetMd5Hash("admin");
            Logins    = new List <UserParam>();

            if (AddDefaultData)
            {
                var testLogin = new UserParam
                {
                    Login    = "******",
                    Password = LogonManager.GetMd5Hash("test1"),
                    Rate     = 0.50,
                    Roles    = new List <RoleTypes> {
                        RoleTypes.Payin
                    },
                    UserName = "******"
                };

                Logins.Add(testLogin);

                testLogin = new UserParam
                {
                    Login    = "******",
                    Password = LogonManager.GetMd5Hash("test2"),
                    Rate     = 0.50,
                    Roles    = new List <RoleTypes> {
                        RoleTypes.Payout
                    },
                    UserName = "******"
                };

                Logins.Add(testLogin);
            }
        }
コード例 #12
0
            public async Task <User> Detail(
                string userId,
                bool withCustomData = false,
                CancellationToken cancellationToken = default)
            {
                if (withCustomData)
                {
                    var _param = new UserWithCustomDataParam()
                    {
                        Id = userId
                    };
                    var _res = await client.Request <UserWithCustomDataResponse>(_param.CreateRequest(), cancellationToken);

                    return(_res.Result);
                }
                var param = new UserParam()
                {
                    Id = userId
                };
                await client.GetAccessToken();

                var res = await client.Request <UserResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
コード例 #13
0
        public async Task <IActionResult> Index(UserParam param)
        {
            // Эти параметры берутся только после перехода с формы логина или регистрации.
            // Защищает от того, чтоб не получилось так что форма загружена, а логина пароля для апи нет.
            if (param.Password == null || param.Password == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            // Логика для формирования страницы чата.
            var chatRoomData = new ChatRoomVM();

            chatRoomData.Login    = param.Login;
            chatRoomData.Password = param.Password;
            // Пользователь авторизованый.
            var user = await _context.Users.FirstOrDefaultAsync(e => e.UserName.ToLower() == param.Login.ToLower());

            chatRoomData.Pseudonym = user.Pseudonym;
            // Список собеседников.
            chatRoomData.Opponents = new List <Opponent>();
            chatRoomData.Opponents.Add(new Opponent {
                OpponentId = "0", Pseudonym = "Общий чат"
            });
            chatRoomData.Opponents.AddRange(_context.Users.Select(e => new Opponent {
                OpponentId = e.Id, Pseudonym = e.Pseudonym
            }).OrderBy(e => e.Pseudonym).ToList());
            // Список сообщений для общего чата.
            chatRoomData.Messages = await _context.Messages.Where(e => e.CommonChat == true).OrderByDescending(e => e.Date).Take(12).ToListAsync();

            return(View(chatRoomData));
        }
コード例 #14
0
        public bool Insert(UserParam userParam)
        {
            var result = 0;

            user.FirstName      = userParam.FirstName;
            user.LastName       = userParam.LastName;
            user.Gender         = userParam.Gender;
            user.Phone          = userParam.Phone;
            user.Email          = userParam.Email;
            user.Amount         = userParam.Amount;
            user.Username       = userParam.Username;
            user.Password       = userParam.Password;
            user.Address        = userParam.Address;
            user.SecretQuestion = userParam.SecretQuestion;
            user.SecretAnswer   = userParam.SecretAnswer;
            user.Religions      = myContext.Religions.Find(userParam.Religions_Id);
            user.Villages       = myContext.Villages.Find(userParam.Villages_Id);
            user.CreateDate     = DateTimeOffset.Now.LocalDateTime;
            user.IsDelete       = false;
            myContext.Users.Add(user);
            result = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #15
0
        public bool Update(int?Id, UserParam userParam)
        {
            var  result  = 0;
            User getUser = Get(Id);

            getUser.FirstName      = userParam.FirstName;
            getUser.LastName       = userParam.LastName;
            getUser.Gender         = userParam.Gender;
            getUser.Phone          = userParam.Phone;
            getUser.Email          = userParam.Email;
            getUser.Amount         = userParam.Amount;
            getUser.Username       = userParam.Username;
            getUser.Password       = userParam.Password;
            getUser.Address        = userParam.Address;
            getUser.SecretQuestion = userParam.SecretQuestion;
            getUser.SecretAnswer   = userParam.SecretAnswer;
            getUser.Religions      = myContext.Religions.Find(userParam.Religions_Id);
            getUser.Villages       = myContext.Villages.Find(userParam.Villages_Id);
            getUser.UpdateDate     = DateTimeOffset.Now.LocalDateTime;
            result = myContext.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
コード例 #16
0
        public bool EditLogin(UserParam loginInfo)
        {
            if (string.IsNullOrWhiteSpace(loginInfo.Login))
            {
                return(false);
            }

            _usersLock.EnterUpgradeableReadLock();
            if (!_users.ContainsKey(loginInfo.Login))
            {
                _usersLock.ExitUpgradeableReadLock();
                return(false);
            }

            _usersLock.EnterWriteLock();
            _users[loginInfo.Login] = loginInfo;
            _usersLock.ExitWriteLock();
            _usersLock.ExitUpgradeableReadLock();

            try
            {
                _userProvider.Logins.RemoveAll(item => item.Login.Equals(loginInfo.Login));
                _userProvider.Logins.Add(loginInfo);
                _watcher.EnableRaisingEvents = false;
                _userProvider.Save(_basePath);
                _watcher.EnableRaisingEvents = true;
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #17
0
        public async Task <UserModel> Login([FromForm] UserParam param)
        {
            string   md5pwd   = SafeHelper.MD5TwoEncrypt(param.PassWord);
            UserInfo userInfo = await _userService.QueryEntity(u => u.UserName == param.UserName && u.PassWord == md5pwd);

            if (userInfo == null)
            {
                throw new UserFriendlyException("用户名或密码错误");
            }
            JwtModel jwtModel = new JwtModel
            {
                Uid = userInfo.Id,
                //Role = "admin"
            };
            string jwtStr = JwtHelper.IssueJwt(jwtModel);

            return(new UserModel
            {
                Token = jwtStr,
                UserId = userInfo.HexId,
                UserName = userInfo.UserName,
                NickName = userInfo.NickName,
                AvatarUrl = userInfo.AvatarUrl,
            });
        }
コード例 #18
0
 /// <summary>
 /// 获取当前用户
 /// </summary>
 /// <param name="accessToken">用户 access token</param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task<User> GetCurrentUser(
     string accessToken = null,
     CancellationToken cancellationToken = default)
 {
     var param = new UserParam();
     var res = await Request<UserResponse>(param.CreateRequest(), cancellationToken, accessToken);
     return res.Result;
 }
コード例 #19
0
        //public UserProcessor(IUserDao dao, IUserParamConverter paramConverter,
        //    IUserResultConverter resultConverter)
        //{
        //    this.Dao = dao;
        //    this.ParamConverter = paramConverter;
        //    this.ResultConverter = resultConverter;
        //}

        public UserResult Create(UserParam param)
        {
            Model.User entity = ParamConverter.Convert(param, null);

            entity = Dao.Save(entity);

            return(ResultConverter.Convert(entity));
        }
コード例 #20
0
ファイル: User.cs プロジェクト: DeveilMayCry/MallAPI
 public User Query(UserParam param, IConfiguration configuration)
 {
     using (var conn = new MySqlConnection(configuration["ConnectString"]))
     {
         var sql = $"SELECT A.*,GROUP_CONCAT(B.ROLEID) AS ROLESID FROM `USER` A INNER JOIN USERANDROLE B  ON A.ID=B.USERID AND A.`STATUS`=0 AND B.`STATUS`= 0 WHERE A.TEL='{param.Tel}' AND A.PASSWORD='******' GROUP BY A.ID";
         return(conn.QueryFirstOrDefault <User>(sql));
     }
 }
コード例 #21
0
        public HackResponse Post([FromBody] UserParam param)
        {
            User user = service.GetUser(param);

            return
                (new HackResponse
                     (HackResType.Success, HackRspCode.HackRspCode_0000, "查询成功", user));
        }
コード例 #22
0
    public static bool FarstLevel;                    //ゲーム開始時のプレイヤーレベル

    // Use this for initialization
    void Start()
    {
        // シーン移動してもプレイヤーのステータスを残しておく
        // レベルでステータスを管理する
        DontDestroyOnLoad(this.gameObject);
        FarstLevel = false;
        userParam  = new UserParam();
    }
コード例 #23
0
ファイル: UserDao.cs プロジェクト: A-Cubic/HouseServer
        public bool addUser(UserParam param, string openId)
        {
            StringBuilder builder1 = new StringBuilder();

            builder1.AppendFormat(ShipSqls.INSERT_USER, param.userPhone, param.userType, param.userName, param.remark, openId);
            string sql1 = builder1.ToString();

            return(DatabaseOperationWeb.ExecuteDML(sql1));
        }
コード例 #24
0
ファイル: Settings.cs プロジェクト: iyus/scada
            /// <summary>
            /// Создать полную копию пользовательского параметра
            /// </summary>
            public UserParam Clone()
            {
                UserParam userParam = new UserParam();

                userParam.Name  = Name;
                userParam.Value = Value;
                userParam.Descr = Descr;
                return(userParam);
            }
コード例 #25
0
ファイル: UserDao.cs プロジェクト: A-Cubic/HouseServer
        public bool updateUser(UserParam param)
        {
            StringBuilder builder1 = new StringBuilder();

            builder1.AppendFormat(ShipSqls.UPDATE_USER, param.userType, param.userName, param.remark, param.userPhone);
            string sql1 = builder1.ToString();

            return(DatabaseOperationWeb.ExecuteDML(sql1));
        }
コード例 #26
0
        public void LogIn(UserParam userParam)
        {
            try
            {
                var userInfo = UserInfo.Instance;
                userInfo.Mobile          = userParam.Mobile;
                userInfo.Password        = userParam.Password;
                userInfo.IsAuthenticated = true;
                var passengerParam = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <PassengerParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "Passenger", "GetByMobile", userParam.Mobile));

                userParam.Language = string.IsNullOrEmpty(userParam.Language) ? userInfo.Language : userParam.Language;

                passengerParam.UserParam.IsAuthenticated = true;
                passengerParam.UserParam.Language        = userParam.Language;
                passengerParam.UserParam.Password        = userParam.Password;
                userParam.Id = passengerParam.UserParam.Id;
                userParam.IsAuthenticated = true;


                var users = _userRepository.GetAll();
                foreach (var user in users)
                {
                    user.IsAuthenticated = false;
                    _userRepository.Update(user);
                }


                var currentUser = users.FirstOrDefault(c => c.Mobile == userParam.Mobile);
                if (currentUser == null)
                {
                    var userInsert = new User()
                    {
                        Id = userParam.Id,
                        IsAuthenticated = true,
                        Password        = userParam.Password,
                        Language        = userParam.Language,
                        Mobile          = userParam.Mobile
                    };
                    _userRepository.Insert(userInsert);
                }
                else
                {
                    currentUser.IsAuthenticated = true;
                    _userRepository.Update(currentUser);
                }



                MapToUserInfo(passengerParam);
            }
            catch (Exception e)
            {
                UserInfo.Instance.IsAuthenticated = false;
                throw new Exception(e.Message);
            }
        }
コード例 #27
0
ファイル: UserService.cs プロジェクト: AnsamSky/ApiTemplate
        public ResultInfo Save(UserParam param)
        {
            ResultInfo result = null;

            try
            {
                var entity = this.mapper.Map <UserEntity>(param);
                int userId;
                if (entity.Id == 0)
                {
                    //user exists
                    if (this.dbContext.UserRepository.Select.Where(m => m.UserName == entity.UserName).ToOne() != null)
                    {
                        return(new ResultInfo()
                        {
                            ResultCode = OcmStatusCode.USER_ALREADY_EXIST,
                            IsSuccess = false
                        });
                    }
                    entity.Password = "******";
                    //insert
                    this.dbContext.UserRepository.Add(entity);
                }
                else
                {
                    var oldEntity = this.dbContext.UserRepository.Select.Where(m => m.Id == entity.Id).ToOne();
                    entity.UserName = oldEntity.UserName;
                    entity.Password = oldEntity.Password;
                    //update
                    this.dbContext.UserRepository.Update(entity);
                }
                userId = entity.Id;
                if (param.Roles != null)
                {
                    this.dbContext.UserRoleRepository.Remove(m => m.UserId == userId); //根据userid删除与角色的关联
                    foreach (var role in param.Roles)
                    {
                        this.dbContext.UserRoleRepository.Add(new UserRoleRelationEntity()
                        {
                            RoleId = role,
                            UserId = userId
                        });
                    }
                }
                this.dbContext.SaveChanges();
                result = new ResultInfo();
            }
            catch (Exception ex)
            {
                result = new ResultExceptionInfo()
                {
                    Exception = ex
                };
            }
            return(result);
        }
コード例 #28
0
        public Result UpdateUser(UserParam user, Guid sessionGuid)
        {
            var result = CheckLoginAndDataProvider(sessionGuid, Operations.UpdateUser);

            if (!result.IsSucssied)
            {
                return(result);
            }

            return(new Result(_logonManager.EditLogin(user)));
        }
コード例 #29
0
        /// <summary>
        /// 执行命令
        /// </summary>
        private void ExcuteAddRecordCmd()
        {
            UserParam up = new UserParam {
                UserAdd = User.UserAdd, UserName = User.UserName, UserPhone = User.UserPhone, UserSex = User.UserSex
            };
            CreateUserInfoThread creatUser = new CreateUserInfoThread(up);

            creatUser.Create();
            IsEnableForm     = false;
            IsWaitingDisplay = true;
        }
コード例 #30
0
 public bool CheckUser([FromBody] UserParam userParam)
 {
     try
     {
         return(_loginService.checkUserByPassword(userParam.UserName, userParam.Password));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #31
0
ファイル: Settings.cs プロジェクト: iyus/scada
        /// <summary>
        /// Загрузить линии связи
        /// </summary>
        private void LoadCommLines(XmlDocument xmlDoc, StringBuilder errorBuilder)
        {
            try
            {
                XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode("CommLines");
                if (xmlNode == null)
                {
                    throw new Exception(AppPhrases.NoCommLines);
                }
                else
                {
                    XmlNodeList listCommLine = xmlNode.SelectNodes("CommLine");
                    foreach (XmlElement elemCommLine in listCommLine)
                    {
                        string lineNumStr = elemCommLine.GetAttribute("number");
                        try
                        {
                            CommLine commLine = new CommLine();
                            commLine.Active = elemCommLine.GetAttrAsBool("active");
                            commLine.Bind = elemCommLine.GetAttrAsBool("bind");
                            commLine.Name = elemCommLine.GetAttribute("name");
                            commLine.Number = elemCommLine.GetAttrAsInt("number");
                            CommLines.Add(commLine);

                            // загрузка настроек соединения линии связи
                            XmlElement elemConn = elemCommLine.SelectSingleNode("Connection") as XmlElement;
                            if (elemConn != null)
                            {
                                XmlElement elemConnType = elemConn.SelectSingleNode("ConnType") as XmlElement;
                                if (elemConnType != null)
                                    commLine.ConnType = elemConnType.GetAttribute("value");

                                XmlElement elemCommSett = elemConn.SelectSingleNode("ComPortSettings") as XmlElement;
                                if (elemCommSett != null)
                                {
                                    try
                                    {
                                        commLine.PortName = elemCommSett.GetAttribute("portName");
                                        commLine.BaudRate = elemCommSett.GetAttrAsInt("baudRate");
                                        commLine.DataBits = elemCommSett.GetAttrAsInt("dataBits");
                                        commLine.Parity = (Parity)Enum.Parse(typeof(Parity),
                                            elemCommSett.GetAttribute("parity"), true);
                                        commLine.StopBits = (StopBits)Enum.Parse(typeof(StopBits),
                                            elemCommSett.GetAttribute("stopBits"), true);
                                        commLine.DtrEnable = elemCommSett.GetAttrAsBool("dtrEnable");
                                        commLine.RtsEnable = elemCommSett.GetAttrAsBool("rtsEnable");
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(AppPhrases.IncorrectPortSettings + ":\r\n" + ex.Message);
                                    }
                                }
                            }

                            // загрузка параметров линии связи
                            XmlElement elemLineParams = elemCommLine.SelectSingleNode("LineParams") as XmlElement;
                            if (elemLineParams != null)
                            {
                                XmlNodeList listParam = elemLineParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name = elemParam.GetAttribute("name");
                                    string nameL = name.ToLower();
                                    string val = elemParam.GetAttribute("value");

                                    try
                                    {
                                        if (nameL == "reqtriescnt")
                                            commLine.ReqTriesCnt = int.Parse(val);
                                        else if (nameL == "cycledelay")
                                            commLine.CycleDelay = int.Parse(val);
                                        else if (nameL == "maxcommerrcnt")
                                            commLine.MaxCommErrCnt = int.Parse(val);
                                        else if (nameL == "cmdenabled")
                                            commLine.CmdEnabled = bool.Parse(val);
                                    }
                                    catch
                                    {
                                        throw new Exception(AppPhrases.IncorrectCommSettings + ":\r\n" +
                                            string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                                    }
                                }
                            }

                            // загрузка пользовательских параметров линии связи
                            XmlElement elemUserParams = elemCommLine.SelectSingleNode("UserParams") as XmlElement;
                            if (elemUserParams != null)
                            {
                                XmlNodeList listParam = elemUserParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name = elemParam.GetAttribute("name");
                                    if (name != "")
                                    {
                                        UserParam userParam = new UserParam();
                                        userParam.Name = name;
                                        userParam.Value = elemParam.GetAttribute("value");
                                        userParam.Descr = elemParam.GetAttribute("descr");
                                        commLine.UserParams.Add(userParam);
                                    }
                                }
                            }

                            // загрузка последовательности опроса линии связи
                            XmlElement elemReqSeq = elemCommLine.SelectSingleNode("ReqSequence") as XmlElement;
                            if (elemReqSeq != null)
                            {
                                XmlNodeList listKP = elemReqSeq.SelectNodes("KP");
                                foreach (XmlElement elemKP in listKP)
                                {
                                    string kpNumStr = elemKP.GetAttribute("number");
                                    try
                                    {
                                        KP kp = new KP();
                                        kp.Active = elemKP.GetAttrAsBool("active");
                                        kp.Bind = elemKP.GetAttrAsBool("bind");
                                        kp.Number = elemKP.GetAttrAsInt("number");
                                        kp.Name = elemKP.GetAttribute("name");
                                        kp.Dll = elemKP.GetAttribute("dll");
                                        kp.CallNum = elemKP.GetAttribute("callNum");
                                        kp.CmdLine = elemKP.GetAttribute("cmdLine");
                                        commLine.ReqSequence.Add(kp);

                                        string address = elemKP.GetAttribute("address");
                                        if (address != "")
                                            kp.Address = elemKP.GetAttrAsInt("address");

                                        kp.Timeout = elemKP.GetAttrAsInt("timeout");
                                        kp.Delay = elemKP.GetAttrAsInt("delay");

                                        string time = elemKP.GetAttribute("time");
                                        if (time != "")
                                            kp.Time = elemKP.GetAttrAsDateTime("time");

                                        string period = elemKP.GetAttribute("period");
                                        if (period != "")
                                            kp.Period = elemKP.GetAttrAsTimeSpan("period");
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(string.Format(AppPhrases.IncorrectKPSettings, kpNumStr) +
                                            ":\r\n" + ex.Message);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format(AppPhrases.IncorrectLineSettings, lineNumStr) +
                                ":\r\n" + ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errorBuilder.AppendLine(AppPhrases.LoadCommLinesError + ":\r\n" + ex.Message);
            }
        }
コード例 #32
0
ファイル: Settings.cs プロジェクト: iyus/scada
 /// <summary>
 /// Создать полную копию пользовательского параметра
 /// </summary>
 public UserParam Clone()
 {
     UserParam userParam = new UserParam();
     userParam.Name = Name;
     userParam.Value = Value;
     userParam.Descr = Descr;
     return userParam;
 }
コード例 #33
0
ファイル: MzMLReader.cs プロジェクト: javamng/GitHUB
        /// <summary>
        /// Handle the userParam element
        /// </summary>
        /// <param name="reader">XmlReader that is only valid for the scope of the single "userParam" element</param>
        private UserParam ReadUserParam(XmlReader reader)
        {
            reader.MoveToContent();
            UserParam userParam = new UserParam();
            userParam.Name = reader.GetAttribute("name");
            userParam.Type = reader.GetAttribute("type");
            userParam.Value = reader.GetAttribute("value");
            userParam.UnitAccession = reader.GetAttribute("unitAccession");
            userParam.UnitCVRef = reader.GetAttribute("unitCVRef");
            userParam.UnitName = reader.GetAttribute("unitName");

            reader.Close();
            return userParam;
        }
コード例 #34
0
ファイル: MsDataFileImpl.cs プロジェクト: lgatto/proteowizard
 private static bool HasInfo(UserParam uParam)
 {
     return !uParam.empty() && !String.IsNullOrEmpty(uParam.value) &&
            !String.Equals("unknown", uParam.value.ToString().ToLowerInvariant()); // Not L10N
 }