Ejemplo n.º 1
0
        /// <summary>
        /// 指定したアドレスを読み出す命令を実行します。
        /// この命令は即時に実行されます。
        /// </summary>
        /// <param name="address">YMF825 のレジスタ番号。範囲は 0x00 から 0x7f です。</param>
        /// <returns>YMF825 から返されたデータ。</returns>
        public virtual byte Read(byte address)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(ToString());
            }

            if (address >= 0x80)
            {
                throw new ArgumentOutOfRangeException(nameof(address));
            }

            lock (lockObject)
            {
                var result = SpiInterface.Read((byte)(address | 0x80));

                WriteBytes++;
                ReadBytes++;
                ReadCommandCount++;

                DataRead?.Invoke(this, new DataTransferedEventArgs(CurrentTargetChip, address, result));

                return(result);
            }
        }
        public override int Read(float[] buffer, int offset, int count)
        {
            var read = base.Read(buffer, offset, count);

            DataRead?.Invoke(this, new DataReadEventArgs(buffer, offset, read));
            return(read);
        }
        public void AddDataRead(DataRead readToAdd)
        {
            MongoClient client = new MongoClient();

            MongoCollection <DataRead> dataReads = client.GetServer().GetDatabase("test").GetCollection <DataRead>("DataReads");

            dataReads.Insert(readToAdd);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            string filename = openFile();

            if (!filename.Equals("openfaild"))
            {
                try {
                    DataRead.ImportDkFromExcel(filename, nzydata);
                    MessageBox.Show("提交成功");
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                User user = DataRead.GetUser(1);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return;
            }
        }
Ejemplo n.º 6
0
 // 값 초기화
 void Start()
 {
     if (Application.loadedLevelName == "Test5")
     {
         i   = new bool[32];
         Max = 32;
     }
     else if (Application.loadedLevelName == "Test6")
     {
         i   = new bool[42];
         Max = 42;
     }
     else if (Application.loadedLevelName == "Test7")
     {
         i   = new bool[46];
         Max = 46;
     }
     else if (Application.loadedLevelName == "Test8")
     {
         i   = new bool[34];
         Max = 34;
     }
     for (int a = 0; a < i.Length; a++)
     {
         i[a] = true;
     }
     if (!instance)
     {
         instance = this;
     }
     else
     {
         DestroyImmediate(this);
     }
     if (PlayerPrefs.HasKey("storyPhase"))   //값 초기화
     {
         storyPhase = PlayerPrefs.GetInt("storyPhase");
     }
     else
     {
         storyPhase = 0;
         //storyIndex = 0;
         //SetStory();
         SetText();
     }
 }
Ejemplo n.º 7
0
        private void Button_Click(object sender, EventArgs e)
        {
            //   MySqlConnection conn = null;
            ///  MySqlDataReader rdr = null;

            try
            {
                //  conn = new MySqlConnection("Server=kira-web.mysql.database.azure.com; Port=3306; Database=kira-db; Uid=incentrio@kira-web; Pwd=Incentri0; SslMode=Preferred;");
                //  conn.Open();

                //   string stm =  "SELECT * FROM kira_user WHERE username = '******' and pass ='******'";

                //   MySqlCommand cmd = new MySqlCommand(stm, conn);
//             rdr = cmd.ExecuteReader();

                //     int count = 0;
                //     while (rdr.Read())
                //    {

                //       count ++;

                // }
                User user = DataRead.GetUser(this.txt_user_name.Text, this.txt_password.Text);



                /*    if(count == 1){
                 *      MessageBox.Show("Username and password is correct");
                 *
                 *  }
                 *  if(count >1){
                 *      MessageBox.Show(" Duplicate Username and password, please try again!");
                 *
                 *  }
                 *  if(count <1){
                 *      MessageBox.Show(" Username and password is incorrect");
                 *
                 *  } */
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();


            try
            {
                User user = DataRead.GetUser(1);
            }
            catch (Exception e)
            {
                string msg = e.Message;
                return;
            }

            //  var loginView = new LoginViews();
            //  var window = new MainWindow();
            //  window.Content = loginView;
        }
Ejemplo n.º 9
0
        private async Task <byte[]> ReadInternalAsync(int length, CancellationToken cancellationToken)
        {
            InactivityTimer?.Reset();

            var result = new List <byte>();

            var buffer         = new byte[Options.BufferSize];
            var totalBytesRead = 0;

            try
            {
                while (totalBytesRead < length)
                {
                    var bytesRemaining = length - totalBytesRead;
                    var bytesToRead    = bytesRemaining > buffer.Length ? buffer.Length : bytesRemaining;

                    var bytesRead = await Stream.ReadAsync(buffer, 0, bytesToRead, cancellationToken).ConfigureAwait(false);

                    if (bytesRead == 0)
                    {
                        Disconnect($"Remote connection closed.");
                        break;
                    }

                    totalBytesRead += bytesRead;
                    var data = buffer.Take(bytesRead);
                    result.AddRange(data);

                    DataRead?.Invoke(this, new ConnectionDataEventArgs(data.ToArray(), totalBytesRead, length));
                    InactivityTimer?.Reset();
                }

                return(result.ToArray());
            }
            catch (Exception ex)
            {
                Disconnect($"Read error: {ex.Message}");
                throw new ConnectionReadException($"Failed to read {length} bytes from {IPAddress}:{Port}: {ex.Message}", ex);
            }
        }
Ejemplo n.º 10
0
        private async Task <byte[]> ReadInternalAsync(long length, CancellationToken cancellationToken)
        {
            InactivityTimer?.Reset();

            var result = new List <byte>();

            var buffer         = new byte[TcpClient.Client.ReceiveBufferSize];
            var totalBytesRead = 0;

            try
            {
                while (totalBytesRead < length)
                {
                    var bytesRemaining = length - totalBytesRead;
                    var bytesToRead    = bytesRemaining > buffer.Length ? buffer.Length : (int)bytesRemaining; // cast to int is safe because of the check against buffer length.

                    var bytesRead = await Stream.ReadAsync(buffer, 0, bytesToRead, cancellationToken).ConfigureAwait(false);

                    if (bytesRead == 0)
                    {
                        throw new ConnectionException($"Remote connection closed");
                    }

                    totalBytesRead += bytesRead;
                    var data = buffer.Take(bytesRead);
                    result.AddRange(data);

                    DataRead?.Invoke(this, new ConnectionDataEventArgs(totalBytesRead, length));
                    InactivityTimer?.Reset();
                }

                return(result.ToArray());
            }
            catch (Exception ex) when(!(ex is TimeoutException) && !(ex is OperationCanceledException))
            {
                Disconnect($"Read error: {ex.Message}");
                throw new ConnectionReadException($"Failed to read {length} bytes from {IPAddress}:{Port}: {ex.Message}", ex);
            }
        }
Ejemplo n.º 11
0
        public virtual float[] GetData(int sampleCount, int?position = null)
        {
            float[] result = new float[sampleCount];

            if (position.HasValue)
            {
                while (position < 0)
                {
                    position += this.BufferSize;
                }

                while (position >= this.BufferSize)
                {
                    position -= this.BufferSize;
                }
            }

            lock (this.Data)
            {
                int dataCount    = (sampleCount > BufferSize ? BufferSize : sampleCount);
                int readRosition = (position.HasValue ? position.Value : BufferPosition);

                int secondSegmentDataCount = (readRosition < dataCount ? readRosition : dataCount);
                if (secondSegmentDataCount > 0)
                {
                    Array.Copy(this.Data, readRosition - secondSegmentDataCount, result, result.Length - secondSegmentDataCount, secondSegmentDataCount);
                }

                int firstSegmentDataCount = dataCount - secondSegmentDataCount;
                if (firstSegmentDataCount > 0)
                {
                    Array.Copy(this.Data, BufferSize - firstSegmentDataCount, result, result.Length - secondSegmentDataCount - firstSegmentDataCount, firstSegmentDataCount);
                }

                DataRead?.Invoke(this, new DataChangedEventArgs(this, readRosition, dataCount));
            }

            return(result);
        }
        /// <summary>
        ///     Reads a sequence of samples from the <see cref="SampleAggregatorBase" /> and advances the position within the
        ///     stream by
        ///     the number of samples read. Triggers the <see cref="DataRead" /> event and if the [(number of total samples read) /
        ///     (number of channels)] %
        ///     <see cref="BlockCount" /> = 0, the <see cref="BlockRead" /> event gets triggered.
        /// </summary>
        /// <param name="buffer">
        ///     An array of floats. When this method returns, the <paramref name="buffer" /> contains the specified
        ///     float array with the values between <paramref name="offset" /> and (<paramref name="offset" /> +
        ///     <paramref name="count" /> - 1) replaced by the floats read from the current source.
        /// </param>
        /// <param name="offset">
        ///     The zero-based offset in the <paramref name="buffer" /> at which to begin storing the data
        ///     read from the current stream.
        /// </param>
        /// <param name="count">The maximum number of samples to read from the current source.</param>
        /// <returns>
        ///     The total number of samples read into the buffer.
        /// </returns>
        public override int Read(float[] buffer, int offset, int count)
        {
            int read     = base.Read(buffer, offset, count);
            int channels = WaveFormat.Channels;

            EventHandler blockRead = BlockRead;

            if (blockRead != null)
            {
                for (int i = 0; i < read / channels; i++)
                {
                    _blocksRead++;
                    if (_blocksRead >= BlockCount)
                    {
                        blockRead(this, EventArgs.Empty);
                        _blocksRead = 0;
                    }
                }
            }

            DataRead?.Invoke(this, EventArgs.Empty);

            return(read);
        }
Ejemplo n.º 13
0
 protected virtual void OnDataRead(byte[] buffer, int offset, int count)
 {
     DataRead?.Invoke(this, new DataEventArgs(buffer, offset, count));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// コンストラクタ。
 /// </summary>
 /// 問題文を読み込み、点数を初期化する。
 /// <param name="file">問題文</param>
 public Exam(string file)
 {
     this.score             = 0;
     this.currentQuestionNo = 0;
     this.questions         = DataRead.ReadQuestion(file);
 }
Ejemplo n.º 15
0
        public void データ読み込み()
        {
            var questions = DataRead.ReadQuestion("test.txt");

            Assert.AreEqual("1+1=", questions[0].Sentence);
        }
Ejemplo n.º 16
0
        public void ERR1002テスト()
        {
            var e = Assert.ThrowsException <UserException>(() => DataRead.ReadQuestion("testERR1002.txt"));

            Assert.AreEqual("ファイル(testERR1002.txt)の3行目の書式が不正です。0=>abc", e.ToString());
        }
Ejemplo n.º 17
0
 void OnDataRead(object sender, DataReadEventArgs e) =>
 DataRead?.Invoke(sender, e);
 public ReportRepository()
 {
     _connectionString = AuthGuard();
     _db = new DBManager(_connectionString);
     _dr = new DataRead();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Event triggered on data read.
 /// </summary>
 /// <param name="buffer">buffer</param>
 /// <param name="count">bytes read</param>
 private void OnDataRead(IEnumerable <byte> buffer, int count)
 {
     DataRead?.ThreadSafeInvoke(this, new IgbClientDataReadEventArgs(buffer, count));
 }
Ejemplo n.º 20
0
 protected virtual void OnDataRead(DataReadEventArgs e) =>
 DataRead?.Invoke(this, e);
        public async Task <DataResult <MfbViewModel> > UPLOADMFBEXCEL(HttpPostedFileBase upload, string username)
        {
            try
            {
                if (string.IsNullOrEmpty(username))
                {
                    throw new PlatformCustomException("invalid user");
                }

                var objResult = new DataResult <MfbViewModel>();
                var parameter = new List <IDbDataParameter>();

                //declare all variables for indents for excel
                #region IndentVariables
                var indentId               = string.Empty;
                var micrAccountNo          = string.Empty;
                var sortCode               = string.Empty;
                var lastSerialNumber       = 0;
                var branchCode             = string.Empty;
                var branchName             = string.Empty;
                var firstChequeNumber      = string.Empty;
                var numberOfCheques        = string.Empty;
                var numberOfChequesPrinted = string.Empty;
                var chequeType             = string.Empty;
                var dateOfRequest          = DateTime.Now.ToString("dd-MMM-yy");
                var dateEnterted           = DateTime.Now.ToString("dd-MMM-yy");
                var pulled             = string.Empty;
                var datePulled         = DateTime.Now.ToString("dd-MMM-yy");
                var printed            = string.Empty;
                var approved           = string.Empty;
                var approver           = string.Empty;
                var uploaded           = string.Empty;
                var requisitionId      = string.Empty;
                var scheduleNo         = string.Empty;
                var indentSource       = string.Empty;
                var deliveryBranchCode = string.Empty;
                var customerName       = string.Empty;
                var ranged             = string.Empty;
                var recieved           = string.Empty;
                var dateRecieved       = DateTime.Now.ToString("dd-MMM-yy");
                var deleted            = string.Empty;
                var acknowledged       = string.Empty;
                var dateAcknowledged   = DateTime.Now.ToString("dd-MMM-yy");
                var dispatched         = string.Empty;
                var dateDispatched     = DateTime.Now.ToString("dd-MMM-yy");
                var dispatchNumber     = string.Empty;
                var dateApproved       = DateTime.Now.ToString("dd-MMM-yy");
                var costOfBooklet      = string.Empty;
                var cancel             = string.Empty;
                var mult               = string.Empty;
                var cmcCode            = string.Empty;
                var batchId            = string.Empty;
                var generated          = string.Empty;
                var dateOfPrinting     = DateTime.Now.ToString("dd-MMM-yy");
                var receivedApprovedBy = string.Empty;
                int lastSerialCounter  = 0;
                #endregion

                var validateUpload = await MfbExcelValidation(upload);

                //convert excel to list
                var convertExcelToDT = FileUploadToDataTable(upload);
                //convert databaTable to List
                var convertDtToList = ConvertDataTableToList <MFBIndentsUpload>(convertExcelToDT);
                var listMfb         = new List <MFBIndentsUpload>();

                foreach (var item in convertDtToList)
                {
                    var          branchParam = new List <IDbDataParameter>();
                    DbConnection connection  = null;
                    branchParam.Add(_db.CreateParameter("p_branchname", 100, item.BRANCHNAME, DbType.String, ParameterDirection.Input));
                    branchParam.Add(_db.CreateParameter("p_branchcode", 5, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_sortcode", 9, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_cmcinuse", 5, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                    if (string.IsNullOrEmpty(branchCode))
                    {
                        var getBranchCodeByName = _db.GetExecuteNonQuery(STOREDPROC.GETBRANCHCODEBYBRANCHNAME, CommandType.StoredProcedure, branchParam, 0, out connection);

                        branchCode = getBranchCodeByName.Parameters["p_branchcode"].Value.ToString();
                        sortCode   = getBranchCodeByName.Parameters["p_sortcode"].Value.ToString();
                        cmcCode    = getBranchCodeByName.Parameters["p_cmcinuse"].Value.ToString();
                        string error = getBranchCodeByName.Parameters["p_error_msg"].Value.ToString();

                        if (!string.IsNullOrEmpty(error))
                        {
                            objResult.Data    = null;
                            objResult.Status  = false;
                            objResult.Message = error;
                            ErrorWriter.WriteLog($"MFB upload process returned : { objResult.Message } at { DateTime.Now }");
                            return(objResult);
                        }
                    }
                    var currentUser = username;
                    var reqId       = item.REQUISITION_ID.ToString();

                    micrAccountNo      = item.MICR_ACCOUNT_NO;
                    requisitionId      = Convert.ToInt32(item.REQUISITION_ID).ToString("D8");
                    approved           = "N";
                    branchName         = item.BRANCHNAME;
                    cancel             = "N";
                    chequeType         = GetConfigValue("MFBChequeType");
                    deleted            = "N";
                    dispatched         = "N";
                    numberOfCheques    = item.NUMBEROFCHEQUES;
                    indentSource       = GetConfigValue("IndentSource");
                    pulled             = "N";
                    acknowledged       = "N";
                    printed            = "N";
                    scheduleNo         = item.SCHEDULE_NO;
                    deliveryBranchCode = item.DELIVERY_BRANCHCODE;
                    customerName       = item.CUSTOMER_NAME;
                    recieved           = "N";
                    deleted            = "N";
                    dispatched         = "N";

                    indentId = $"{branchCode}{micrAccountNo}{requisitionId}";

                    var lastSerialParam = new List <IDbDataParameter>();


                    if (lastSerialCounter <= Convert.ToInt32(lastSerialNumber))
                    {
                        var dR = new DataRead();
                        var dt = new DataTable();

                        var ds = dR.GetLastSerialNumberByBranchCode(branchCode);
                        if (ds.Tables[0].Rows.Count < 1)
                        {
                            //SETLAST_SERIAL_NUMBER TO 1
                            lastSerialCounter = 1;

                            var insertParams = new List <IDbDataParameter>();

                            insertParams.Add(_db.CreateParameter("p_branchcode", 13, branchCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_sortcode", 9, sortCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_lastserial", 12, 0, DbType.Decimal, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_cmccode", 3, cmcCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                            //INSERT NEW RECORD FOR THE BRANCH
                            _db.InsertWithTransaction(STOREDPROC.INSERTINTOLASTSERIALNUMBER, CommandType.StoredProcedure, insertParams, 0);
                        }
                        else
                        {
                            dt = ds.Tables[0];
                            var getLastSerial = dt.Rows[0]["LAST_SERIAL_NUMBER"].ToString();

                            lastSerialNumber = Convert.ToInt32(getLastSerial);
                            var lastSerialNumberToUse = Convert.ToInt32(lastSerialNumber) + 1;
                            lastSerialCounter = Convert.ToInt32(lastSerialNumberToUse);
                        }
                    }

                    var objMfb = new MFBIndentsUpload()
                    {
                        INDENT_ID              = indentId,
                        MICR_ACCOUNT_NO        = micrAccountNo,
                        SORTCODE               = sortCode,
                        BRANCHNAME             = branchName,
                        BRANCHCODE             = branchCode,
                        FIRST_CHEQUE_NUMBER    = lastSerialCounter.ToString(),
                        NUMBEROFCHEQUES        = numberOfCheques,
                        NUMBEROFCHEQUESPRINTED = numberOfChequesPrinted,
                        CHEQUETYPE             = chequeType,
                        DATEOFREQUEST          = dateOfRequest,
                        DATEENTERED            = dateEnterted,
                        PULLED              = pulled,
                        DATEPULLED          = datePulled,
                        PRINTED             = printed,
                        DATEOFPRINTING      = dateOfPrinting,
                        RECEIVEDAPPROVED_BY = receivedApprovedBy,
                        ORIGINATOR          = currentUser,
                        APPROVED            = approved,
                        APPROVER            = approver,
                        UPLOADED            = uploaded,
                        REQUISITION_ID      = requisitionId,
                        SCHEDULE_NO         = scheduleNo,
                        INDENTSOURCE        = indentSource,
                        DELIVERY_BRANCHCODE = deliveryBranchCode,
                        CUSTOMER_NAME       = customerName,
                        RANGED              = ranged,
                        RECEIVED            = recieved,
                        DATERECEIVED        = dateRecieved,
                        DELETED             = deleted,
                        ACKNOWLEDGED        = acknowledged,
                        DATEACKNOWLEDGED    = dateAcknowledged,
                        DISPATCHED          = dispatched,
                        DATEDISPATCHED      = dateDispatched,
                        DISPATCHNUMBER      = dispatchNumber,
                        DATEAPPROVED        = dateApproved,
                        COST_OF_BOOKLET     = costOfBooklet,
                        CANCEL              = cancel,
                        MULT      = mult,
                        BATCHID   = batchId,
                        GENERATED = generated
                    };

                    lastSerialCounter++;
                    listMfb.Add(objMfb);
                }

                var listMfbDT = new ListtoDataTable().ToDataTable(listMfb);

                _db.BulkCopyWriteToServer(listMfbDT, "INDENTS_TEST");

                //update last serial table with the last id used by branch code
                var updateParam = new List <IDbDataParameter>();

                updateParam.Add(_db.CreateParameter("p_lastserialnumber", 100, lastSerialCounter - 1, DbType.String, ParameterDirection.Input));
                updateParam.Add(_db.CreateParameter("p_branchcode", 5, branchCode, DbType.String, ParameterDirection.Input));
                updateParam.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                _db.Update(STOREDPROC.UPDATELASTSERIALNUMBER, CommandType.StoredProcedure, updateParam, 0);

                objResult.Data    = null;
                objResult.Status  = true;
                objResult.Message = listMfbDT.Rows.Count.ToString();

                ErrorWriter.WriteLog($"MFB upload process returned : { objResult.Message } indents processed at { DateTime.Now }");

                return(objResult);
            }
            catch (Exception ex)
            {
                var error = await ExceptionRefiner.LogError(ex);

                ErrorWriter.WriteLog($"MFB upload process returned error: { ex.Message } at { DateTime.Now }");
                return(new DataResult <MfbViewModel>()
                {
                    Data = null,
                    Message = error,
                    Status = false
                });
            }
        }