Ejemplo n.º 1
0
 private void AddHostHandler <T>(Action <T> onReceive) where T : Message, new()
 {
     processor.Add(typeof(T), (peer, reader) => {
         var inst = new T();
         if (serializer.Deserialize(reader, inst))
         {
             try {
                 LogMessage("Recv", inst);
                 onReceive(inst);
             } catch (Exception exception) {
                 UnityEngine.Debug.LogException(exception);
             }
         }
     });
 }
Ejemplo n.º 2
0
 public void Apply()
 {
     PRC.Add(PTH);
 }
        ////////////////////////////////////////////////////////////////////


        ////////////////////////////////////////////////////////////////////
        // Control for create daily report
        private void btn_refresh_daily_Click(object sender, EventArgs e)
        {
            DateTime _dateTime = date_daily.Value;

            list_daily.Items.Clear();

            DataTable _data = PassbookModel.SelectAllPeriod();

            for (int i = 0; i < _data.Rows.Count; i++)
            {
                ListViewItem _item = new ListViewItem((i + 1).ToString());

                // Set period name
                object[] _period = _data.Rows[i].ItemArray;
                _item.SubItems.Add(_period[TblColumn.T_NAME].ToString());


                // Set income value
                string    _income = "0";
                DataTable _data1  = PassbookModel.SelectAllIncomesByPeriodId(_period[TblColumn.T_ID].ToString());
                for (int j = 0; j < _data1.Rows.Count; j++)
                {
                    object[] _row     = _data1.Rows[j].ItemArray;
                    DateTime _current = DateTime.Parse(_row[TblColumn.D_DATE_TIME].ToString());

                    if (_dateTime.DayOfYear == _current.DayOfYear)
                    {
                        _income = Processor.Add(_income, _row[TblColumn.D_CASH].ToString());
                    }
                }

                string _incomeFormatted = string.Format("{0:#,##0}", Processor.ConvertToDouble(_income));
                _item.SubItems.Add(_incomeFormatted + " VND");


                // Set outcome value
                string    _outcome = "0";
                DataTable _data2   = PassbookModel.SelectAllOutcomesByPeriodId(_period[TblColumn.T_ID].ToString());
                for (int j = 0; j < _data2.Rows.Count; j++)
                {
                    object[] _row     = _data2.Rows[j].ItemArray;
                    DateTime _current = DateTime.Parse(_row[TblColumn.W_DATE_TIME].ToString());

                    if (_dateTime.DayOfYear == _current.DayOfYear)
                    {
                        _outcome = Processor.Add(_outcome, _row[TblColumn.W_CASH].ToString());
                    }
                }

                string _outcomeFormatted = string.Format("{0:#,##0}", Processor.ConvertToDouble(_outcome));
                _item.SubItems.Add(_outcomeFormatted + " VND");


                // Set total value
                string _totalFormatted = string.Format("{0:#,##0}", Processor.ConvertToDouble(Processor.Sub(_income, _outcome)));
                _item.SubItems.Add(_totalFormatted + " VND");


                list_daily.Items.Add(_item);
            }
        }
Ejemplo n.º 4
0
        private void ProcessFiles(CancellationToken token)
        {
            if (_model.IsProcessing)
            {
                var result = MessageBox.Show(Window, "Abort processing?", "Batch", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                if (result == MessageBoxResult.Yes)
                {
                    Cancel();
                }
                return;
            }

            if (string.IsNullOrEmpty(_model.Settings.OutputPath))
            {
                MessageBox.Show(Window, "No output path specified", "Batch", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (!Directory.Exists(_model.Settings.OutputPath))
            {
                MessageBox.Show(Window, "Invalid directory or directory not found", "Batch", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (_model.BatchEntries.Count == 0)
            {
                MessageBox.Show(Window, "Nothing to process. Please Scan a directory first.", "Batch", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var processor = new Processor(_dispatcher, _gameDb, _settings, new ProcessEventHandler());

            foreach (var entry in _model.BatchEntries.Where(e => e.Status != "Complete"))
            {
                entry.HasError     = false;
                entry.MaxProgress  = 100;
                entry.Progress     = 0;
                entry.ErrorMessage = null;
                entry.Status       = "Queued";

                processor.Add(new ConvertJob()
                {
                    Entry = entry
                });
            }

            _dispatcher.Invoke(() =>
            {
                _model.IsProcessing = true;
            });

            processor.Start(_model, token).ContinueWith(t =>
            {
                _dispatcher.Invoke(() =>
                {
                    _model.IsProcessing = false;
                });

                if (t.IsCompletedSuccessfully)
                {
                    if (token.IsCancellationRequested)
                    {
                        _dispatcher.Invoke(() =>
                        {
                            MessageBox.Show(Window, "Conversion aborted!", "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Warning);
                        });
                    }
                    else
                    {
                        _dispatcher.Invoke(() =>
                        {
                            MessageBox.Show(Window, "Conversion completed.", "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Information);
                        });
                    }
                }
            });
        }
        private void btn_create_deposit_Click(object sender, EventArgs e)
        {
            if (txt_name_deposit.Text == "" ||
                txt_identity_number_deposit.Text == "" ||
                txt_address_deposit.Text == "" ||
                txt_phone_number_deposit.Text == "" ||
                txt_cash_deposit.Text == "" ||
                cbb_passbook_deposit.Text == "" ||
                cbb_staff_deposit.Text == "")
            {
                MessageBox.Show(IMessage.MSG_REQUIRED_ALL, IMessage.CPT_NOTICE);
                return;
            }

            // Validate input
            double _income = Processor.ConvertToDouble(txt_cash_deposit.Text);

            if (_income == Processor.UNIDENTIFIED)
            {
                MessageBox.Show(IMessage.MSG_WRONG_INPUT, IMessage.CPT_NOTICE);
                return;
            }

            if (_income < Processor.ConvertToDouble(Params.PARAMS[Params.MIN_INCOME].ToString()))
            {
                MessageBox.Show(IMessage.MSG_TOO_FEW_CASH, IMessage.CPT_NOTICE);
                return;
            }


            // Submit income
            DateTime _dateTime   = calendar_deposit.SelectionEnd.Date;
            string   _passbookId = cbb_passbook_deposit.Text.Split(':')[0];
            string   _staffId    = cbb_staff_deposit.Text.Split(':')[0];

            if (PassbookModel.InsertIncome(_passbookId, _staffId, txt_cash_deposit.Text, _dateTime.ToString()) == false)
            {
                MessageBox.Show(IMessage.MSG_SOMETHING_WENT_WRONG, IMessage.CPT_NOTICE);
                return;
            }


            ///////////////////////////////////////////////////////////////////
            // Update passbook info
            DataTable _data = PassbookModel.SelectPassbookById(_passbookId);

            object[] _passbook = _data.Rows[0].ItemArray;

            // Reopen passbook
            if (Processor.Compare(_passbook[TblColumn.P_CASH].ToString(), "0") == 0)
            {
                List <string> _status = _passbook[TblColumn.P_STATUS].ToString().Split('|').ToList();
                _status.Add("open-" + _dateTime.ToString());
                PassbookModel.UpdateStatusByPassbookId(_passbookId, string.Join("|", _status));
            }

            // Update cash
            string _cash = Processor.Add(txt_cash_deposit.Text, _passbook[TblColumn.P_CASH].ToString());

            PassbookModel.UpdateCashByPassbookId(_passbookId, _cash);

            MessageBox.Show(IMessage.MSG_SUCCESS_CREATE_DEPOSIT, IMessage.CPT_CREATE_DEPOSIT);
        }