Exemple #1
0
        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void krpbDisable_Click(object sender, EventArgs e)
        {
            string ErrMsgName = Resources.GetRes().GetString("Disable");

            int sendType = 17; // ExtInfo

            ExtendInfo info = new ExtendInfo();



            if (Resources.GetRes().ExtendInfo.SliderMode == "2")
            {
                ErrMsgName = Resources.GetRes().GetString("Enable");

                info.SliderMode = "1";
            }
            else
            {
                info.SliderMode = "2";
            }


            var confirm = KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("ConfirmOperate"), ErrMsgName), Resources.GetRes().GetString("Warn"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm == DialogResult.Yes)
            {
                // 所有设备ID都发送
                Send(Resources.GetRes().Devices.Select(x => x.DeviceId).ToList(), ErrMsgName, sendType, info, () =>
                {
                    InitLock();
                });
            }
        }
        public ExtendInfo UpdateInfo(ExtendInfo input)
        {
            //TODO:更新前的逻辑判断,是否允许更新
            _repository.Update(AutoMapper.Mapper.Map <ExtendInfo>(input));

            _repository.Update(input);
            return(input);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="input"></param>
        /// <param name="EntityTypeFullName"></param>
        /// <param name="EnityID"></param>
        /// <returns></returns>
        public ExtendInfo BindToInfo(ExtendInfo input, string EntityTypeFullName, string EnityID)
        {
            //var entity = AutoMapper.Mapper.Map<ExtendInfo>(input);
            input.Id = null;
            if (input != null)
            {
                _repository.Insert(input);

                CurrentUnitOfWork.SaveChanges();
                return(input);// AutoMapper.Mapper.Map<ExtendInfo>(input);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 发送
        /// </summary>
        private void Send(List <long> RoomsId, string ErrMsgName, int SendType, ExtendInfo info, Action success = null)
        {
            _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, null, null, PopupType.AnimationOn));

            Task.Factory.StartNew(() =>
            {
                try
                {
                    bool result = OperatesService.GetOperates().ServiceSend(RoomsId, SendType, JsonConvert.SerializeObject(info));

                    // 如果成功则提示
                    if (result)
                    {
                        _element.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, string.Format(Resources.GetRes().GetString("OperateSuccess"), ErrMsgName), (x) =>
                            {
                                //if (x == "OK")
                                //{
                                if (null != success)
                                {
                                    success();
                                }
                                //}
                            }, PopupType.Information));
                        }));
                    }
                }
                catch (Exception ex)
                {
                    _element.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, message, null, PopupType.Error));
                        }), false, string.Format(Resources.GetRes().GetString("OperateFaild"), ErrMsgName));
                    }));
                }
                _element.Dispatcher.BeginInvoke(new Action(() =>
                {
                    _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, null, null, PopupType.AnimationOff));
                }));
            });
        }
Exemple #5
0
        public ExtendInfo BindToInfo(ExtendInfo input, string entityTypeFullName, long enityID)
        {
            var entity = AutoMapper.Mapper.Map <ExtendInfo>(input);

            entity.Id = null;
            if (entity != null)
            {
                entity.EntityTypeFullName = entityTypeFullName;
                entity.EnityID            = enityID;
                var pid = _repository.InsertAndGetId(entity);

                CurrentUnitOfWork.SaveChanges();
                return(entity);// AutoMapper.Mapper.Map<ExtendInfo>(input);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        /// <summary>
        /// 发送
        /// </summary>
        private void Send(List <long> RoomsId, string ErrMsgName, int SendType, ExtendInfo info, Action success = null)
        {
            StartLoad(this, null);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    bool result = OperatesService.GetOperates().ServiceSend(RoomsId, SendType, JsonConvert.SerializeObject(info));

                    // 如果成功则提示
                    if (result)
                    {
                        this.BeginInvoke(new Action(() =>
                        {
                            KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("OperateSuccess"), ErrMsgName), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);

                            if (null != success)
                            {
                                success();
                            }
                        }));
                    }
                }
                catch (Exception ex)
                {
                    this.BeginInvoke(new Action(() =>
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }), false, string.Format(Resources.GetRes().GetString("OperateFaild"), ErrMsgName));
                    }));
                }
                StopLoad(this, null);
            });
        }
        /// <summary>
        /// 发送
        /// </summary>
        private async Task Send(List <long> RoomsId, string ErrMsgName, int SendType, ExtendInfo info, Action success = null)
        {
            IsLoading = true;

            try
            {
                bool result = await OperatesService.Instance.ServiceSend(RoomsId, SendType, JsonConvert.SerializeObject(info));


                // 如果成功则提示
                if (result)
                {
                    QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Information, string.Format(Resources.Instance.GetString("OperateSuccess"), ErrMsgName), MessageBoxMode.Dialog, MessageBoxImageMode.Information, MessageBoxButtonMode.OK, null, null);



                    if (null != success)
                    {
                        success();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                {
                    QueueMessageBoxNotification.Instance.ActionMessageBox(null, null, CommandTitles.Instance.Error, message, MessageBoxMode.Dialog, MessageBoxImageMode.Error, MessageBoxButtonMode.OK, null, null);
                }), false, string.Format(Resources.Instance.GetString("OperateFaild"), ErrMsgName));
            }

            IsLoading = false;
        }