private void BindData()
        {
            StringBuilder sbSql = new StringBuilder("Select logId,menuName,operationType,cuserId,operationContent,cdate FROM sys_client_syslog WHERE 1=1 ");

            if (txtUserName.Text.Trim() != "")
            {
                sbSql.Append(" AND cuserId='" + txtUserName.Text.Trim() + "' ");
            }

            if (cmbOperationType.SelectedIndex > 0)
            {
                sbSql.Append(" AND operationType='" + (cmbOperationType.SelectedItem as ComboBoxItem).Content.ToString() + "' ");
            }

            sbSql.Append(" AND DATE(cdate)>='" + Convert.ToDateTime(dtpStartDate.SelectedDate).ToString("yyyy-MM-dd") + "' AND DATE(cdate)<='" + Convert.ToDateTime(dtpEndDate.SelectedDate).ToString("yyyy-MM-dd") + "'");

            try
            {
                IOperationContract operationService = ServiceFactory.GetWcfService <IOperationContract>();
                lvlist.DataContext = operationService.GetClientLog(sbSql.ToString());
                currentTable       = operationService.GetClientLog(sbSql.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }
        public IOperation <T> Resolve(IOperationContract <T> contract)
        {
            var operation = AllOperations.FirstOrDefault(s => s.OperationIdentifier.Equals(contract.Operation));

            if (operation != null)
            {
                return(operation);
            }

            return(DefaultOperation ?? throw new OperationsResolverException($"Cannot find operation for '{contract.Operation.ToString()}' and default operation is not set!"));
        }
        public static Operation ContractToViewAdapter(IOperationContract contract)
        {
            var addInAdapter = contract as OperationViewToContractAddInAdapter;

            if (addInAdapter != null)
            {
                return(addInAdapter._view);
            }

            throw new InvalidOperationException("contract is null");
        }
示例#4
0
        public static IOperationDataValidator <T> Resolve(IOperationContract <T> contract)
        {
            if (Validators == null)
            {
                Initialize();
            }

            // ReSharper disable once AssignNullToNotNullAttribute
            var validators = Validators.Where(s => s.IsModelSupported(contract.Operation)).ToList();

            if (validators.Count == 1)
            {
                return(validators[0]);
            }

            if (validators.Count > 1)
            {
                throw new OperationDataValidatorResolverException(
                          $"There is more then one validator for specified operation '{contract.Operation.ToString()}'");
            }
            throw new OperationDataValidatorResolverException($"Cannot find validator for specified operation '{contract.Operation.ToString()}'");
        }
示例#5
0
        public override void Execute(IOperationContract <RpiOperationContracts> contract)
        {
            var data = (TemperatureModel)contract.Data;

            new AirConditionerFacade().Start(data.Temperature);
        }
示例#6
0
        private void Login()
        {
            if (this.cmbName.Text.Trim() == "")
            {
                txtMsg.Text = "*用户名不能为空!";
                return;
            }

            if (_password.Password.Trim() == "")
            {
                txtMsg.Text = "*密码不能为空!";
                return;
            }
            IOperationContract operationService = ServiceFactory.GetWcfService <IOperationContract>();

            try
            {
                //FoodSafety.Model.sys_client_user logUserModel = new FoodSafety.Model.sys_client_user();
                //logUserModel.userId = cmbName.Text.Trim();
                //MD5 md5 = new MD5CryptoServiceProvider();
                //string password = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(this._password.Password))).Replace("-", "");
                //logUserModel.userPassword = password;
                //if (sysSetContract.GetUserModel(logUserModel) == null)
                //{
                //    Toolkit.MessageBox.Show("您输入的密码和账户名不匹配!\n\n请重新输入!");
                //    cmbName.Focus();
                //    return;
                //}
                //else
                //{
                //    this.Close();

                //}
                try
                {
                    MD5    md5      = new MD5CryptoServiceProvider();
                    string password = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(this._password.Password))).Replace("-", "");


                    UserInfo userInfo = operationService.GetMenu(this.cmbName.Text, password);

                    if (userInfo.ID != "" && userInfo.ID != null)
                    {
                        UserLoginInfo userLoginInfo = new UserLoginInfo()
                        {
                            UserName = this.cmbName.Text, Password = _password.Password, LastLoginTime = DateTime.Now
                        };

                        if (list == null)
                        {
                            list = new List <UserLoginInfo>();
                        }
                        var query = from item in list where item.UserName == userLoginInfo.UserName select item;

                        if (query.Count() > 0)
                        {
                            foreach (UserLoginInfo item in list)
                            {
                                if (item.UserName == userLoginInfo.UserName)
                                {
                                    item.Password      = userLoginInfo.Password;
                                    item.LastLoginTime = userLoginInfo.LastLoginTime;
                                }
                            }
                        }
                        else
                        {
                            if (_rememberPassword.IsChecked == true)
                            {
                                list.Add(userLoginInfo);
                            }
                        }

                        try
                        {
                            //将用户列表写入文件
                            Common.SerializerTool.SerializeToFile(list, rememberPasswordPath);
                        }
                        catch (Exception e)
                        {
                            txtMsg.Text = "请以管理员身份运行软件!";
                            return;
                        }

                        Application.Current.Resources.Add("User", userInfo);

                        PubClass.userInfo = Application.Current.Resources["User"] as UserInfo;

                        if (PubClass.userInfo != null)
                        {
                            PubClass.supplierid = PubClass.userInfo.SupplierId;
                        }

                        string current_version = ConfigurationManager.AppSettings["version"];
                        string new_version     = operationService.GetNewVersion(PubClass.supplierid);

                        if (Convert.ToDouble(new_version == "" ? "0" : new_version) > Convert.ToDouble(current_version))
                        {
                            if (Toolkit.MessageBox.Show("当前有新版本,是否升级?", "系统询问", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                            {
                                ProcessStartInfo info = new ProcessStartInfo("AutoUpdate.exe", new_version);
                                Process.Start(info);
                            }
                            else
                            {
                                MainWindow mainWindow = new MainWindow();
                                mainWindow.Show();
                                Common.SysLogEntry.WriteLog("登录", PubClass.userInfo.ShowName, Common.OperationType.Login, "登录系统");
                                this.Close();
                            }
                        }
                        else
                        {
                            MainWindow mainWindow = new MainWindow();
                            mainWindow.Show();
                            Common.SysLogEntry.WriteLog("登录", PubClass.userInfo.ShowName, Common.OperationType.Login, "登录系统");
                            this.Close();
                        }
                    }
                    else
                    {
                        txtMsg.Text = "用户名或密码错误,请确认!";
                        return;
                    }
                }
                catch (Exception e)
                {
                    txtMsg.Text = "数据库处理失败!";
                    writeLog(e.Message);
                    return;
                }
            }
            catch (Exception ex)
            {
                txtMsg.Text = "数据库连接失败!";
                writeLog(ex.Message);
                return;
            }
        }
 public override void Execute(IOperationContract <RpiOperationContracts> contract)
 {
     new LedLightsFacade().SwitchOn();
 }
 public OperationContractToViewHostAdapter(IOperationContract contract)
 {
     Contract = contract;
     _handle  = new ContractHandle(contract);
 }
示例#9
0
 public double Operate(IOperationContract operation, double[] operands)
 {
     return(view.Operate(OperationViewToContractAddInAdapter.ContractToViewAdapter(operation),
                         operands));
 }
示例#10
0
 public override void Execute(IOperationContract <RpiOperationContracts> contract)
 {
     new AirConditionerFacade().Stop();
 }
示例#11
0
 public static Operation ContractToViewAdapter(IOperationContract contract)
 {
     return((contract as OperationViewToContractAddInAdapter).view);
 }
示例#12
0
        public IEnumerable <ValidationResult> Validate(IOperationContract <T> contract)
        {
            var validator = ValidatorResolver <T> .Resolve(contract);

            return(validator.Validate(contract.Data));
        }
示例#13
0
 public abstract void Execute(IOperationContract <T> contract);
 internal static Operation ContractToViewAdapter(IOperationContract contract)
 {
     return(new OperationContractToViewHostAdapter(contract));
 }
示例#15
0
 public override void Execute(IOperationContract <RpiOperationContracts> contract)
 {
     Logger.LogError("Invalid operation.");
 }