protected void firstButton_Click(object sender, EventArgs e)
        {
            Writter writter = writterManager.GetWritter(0);

            GetValueFromDatabase(writter);
            Session["active"] = 0;
        }
Exemplo n.º 2
0
        private void ProcessFile2DecCallback(object obj)
        {
            TaskObject taskObject = (TaskObject)obj;
            var        filePath   = taskObject.FilePath;

            byte[] bytes2DecryptWSalt = File.ReadAllBytes(filePath);
            byte[] salt          = this.decrypter.ExtractSalt(bytes2DecryptWSalt);
            byte[] bytes2Decrypt = this.decrypter.
                                   ExtractBytes2Dec(bytes2DecryptWSalt);

            try
            {
                byte[] plainText = this.decrypter.DecryptBytes(
                    bytes2Decrypt, taskObject.Pwd, salt
                    );
#if DEBUG
                string fileNoExtension =
                    Path.GetFileNameWithoutExtension(filePath);
                string fileDir     = Path.GetDirectoryName(filePath);
                string rescuedPath = Path.Combine(fileDir, fileNoExtension +
                                                  ".rescued");
                Writter.WriteBytes2File(plainText, rescuedPath);
#else
#endif
            }
            catch (CryptographicException)
            {
                Console.WriteLine("Process File 2 Decrypt Thread " +
                                  "Callback Exception");
                System.Environment.Exit(1);
            }
        }
Exemplo n.º 3
0
        public void WritterKonstruktorDobar(float value, int code)
        {
            Writter w = new Writter((Codes)code, value);

            Assert.AreEqual(w.Value, value);
            Assert.AreEqual(w.Code, (Codes)code);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var printer = new Emailer();
            var writter = new Writter(printer);

            writter.Write("My text");
        }
Exemplo n.º 5
0
 public void WritterKonstruktorLos(float value, int code)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Writter w = new Writter((Codes)code, value);
     });
 }
Exemplo n.º 6
0
 public void WritterKonstruktorLosValue(float val)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Codes code = Codes.CODE_ANALOG;
         Writter w  = new Writter(code, val);
     });
 }
Exemplo n.º 7
0
 public void ManualWriteToHistory(string code, Value value)
 {
     Task.Run(() =>
     {
         Writter.ManualWriteToHistory(code, value);
     });
     
 }
Exemplo n.º 8
0
 public void WritterKonstruktorLosCode(int code)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         float val = 5;
         Writter w = new Writter((Codes)code, val);
     });
 }
 private void GetValueFromDatabase(Writter writter)
 {
     writterCodeTextBox.Text          = writter.WritterCode;
     writterNameTextBox.Text          = writter.WritterName;
     writterPhoneTextBox.Text         = writter.WritterPhone;
     writterAddressTextArea.InnerText = writter.WritterAddress;
     openingBalanceTextBox.Text       = writter.WritterOpeningBalance.ToString();
 }
 public string Save(Writter writter)
 {
     if (writterGateway.Insert(writter) > 0)
     {
         return("Saved Successfully!!");
     }
     return("Could Not Save data in Database!!");
 }
        protected void lastButton_Click(object sender, EventArgs e)
        {
            List <Writter> writterList = (List <Writter>)Session["writters"];
            int            x           = writterList.Count - 1;
            Writter        writter     = writterManager.GetWritter(x);

            GetValueFromDatabase(writter);
            Session["active"] = x;
        }
 private static void GetDataFromDatabase(Writter writter, SqlDataReader reader)
 {
     writter.WritterId             = int.Parse(reader["id"].ToString());
     writter.WritterCode           = reader["writter_code"].ToString();
     writter.WritterName           = reader["writter_name"].ToString();
     writter.WritterAddress        = reader["writter_address"].ToString();
     writter.WritterPhone          = reader["writter_phone"].ToString();
     writter.WritterOpeningBalance = Convert.ToDouble(reader["writter_opening_balance"].ToString());
 }
Exemplo n.º 13
0
        /// <summary>
        /// Starting writer
        /// </summary>
        /// <param name="args">Arguments</param>
        public static void Main(string[] args)
        {
            Writter w = new Writter();

            while (true)
            {
                w.StartWritting();
            }
        }
Exemplo n.º 14
0
    public void WriteToDumpingBuffer(string code, Value value, bool bflag)
    {
        Task.Run(() =>
        {
            Writter.WriteToDumpingBuffer(code, value, bflag);
        });
        //Writter.WriteToDumpingBuffer(code, value);

    
    }
Exemplo n.º 15
0
 private void RightButton_Click(object sender, EventArgs e)
 {
     if (BookName.Text != "" && Writter.Text != "" && Page.Text != "" && PublishCompany.Text != "")
     {
         OnTimeEventFuntion(BookName.Text, Writter.Text, DateTimePicker.Value.ToString("yyyy-MM-dd"), PublishCompany.Text, Page.Text);
         BookName.Clear();
         Writter.Clear();
         PublishCompany.Clear();
         Page.Clear();
         MessageBox.Show("书籍加入成功");
     }
 }
Exemplo n.º 16
0
        private static void WriteToBuffer(Writter writter)
        {
            using (var mutex = new Mutex())
            {
                mutex.WaitOne();
                lock (_locker)
                {
                    writter.ReadDataFromFile();
                    //Thread.Sleep(2000);
                }

                mutex.ReleaseMutex();
            }
        }
        public int Insert(Writter writter)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "INSERT INTO tbl_writter VALUES('" + writter.WritterCode + "','" + writter.WritterName +
                                       "','" + writter.WritterAddress + "','" + writter.WritterPhone + "','" +
                                       writter.WritterOpeningBalance + "')";
            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected);
        }
        protected void searchButton_Click(object sender, EventArgs e)
        {
            var     w       = writterTextBox.Value;
            Writter writter = writterManager.GetSearchInfo(w);

            if (writter.WritterCode == null)
            {
                message.InnerText = "Invalid Writter Code!!";
            }
            else
            {
                GetValueFromDatabase(writter);
                message.InnerText = "";
            }
        }
        protected void nextButton_Click(object sender, EventArgs e)
        {
            int active = (int)Session["active"];

            active++;
            List <Writter> writterList = (List <Writter>)(Session["writters"]);

            if (active >= writterList.Count)
            {
                active = 0;
            }
            Writter writter = writterManager.GetWritter(active);

            GetValueFromDatabase(writter);
            Session["active"] = active;
        }
        public Writter GetWritter(int i)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_writter ORDER BY id ASC OFFSET " + i + " ROWS FETCH NEXT 1 ROWS ONLY";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader  = command.ExecuteReader();
            Writter       writter = new Writter();

            while (reader.Read())
            {
                GetDataFromDatabase(writter, reader);
            }
            reader.Close();
            connection.Close();
            return(writter);
        }
        public Writter GetSearchInfo(string s)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_writter WHERE writter_code='" + s + "'";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            Writter       writter = new Writter();
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                GetDataFromDatabase(writter, reader);
            }
            reader.Close();
            connection.Close();
            return(writter);
        }
        private string LoadNextCode()
        {
            Writter writter = writterManager.GetNextCode();
            string  wCode   = writter.WritterCode;
            int     c;

            if (wCode == null)
            {
                c = 1;
            }
            else
            {
                c = (wCode[2] - '0') * 10 + (wCode[3] - '0') + 1;
            }
            string nextCode = "Wr" + c.ToString("00");

            return(nextCode);
        }
Exemplo n.º 23
0
        private async Task <ILogger> WriteAsync(Type callerType, int eventId, LogType type, object resource, Exception exception, string message, string memberName, string sourceFilePath, int sourceLineNumber)
        {
            if (ApplicationSettings.Logger == LogType.None || ApplicationSettings.Logger > type)
            {
                return(this);
            }

            await Writter.SaveDataAsync(new LoggerEntity(exception, callerType)
            {
                LogLevel         = type,
                Resource         = resource,
                Message          = message,
                SourceMethod     = memberName,
                SourceFilePath   = sourceFilePath,
                SourceLineNumber = sourceLineNumber
            });

            return(this);
        }
        public Writter GetNextCode()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT TOP 1 * FROM tbl_writter ORDER BY id DESC";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader  = command.ExecuteReader();
            Writter       writter = new Writter();

            while (reader.Read())
            {
                writter.WritterId   = int.Parse(reader["id"].ToString());
                writter.WritterCode = reader["writter_code"].ToString();
            }
            reader.Close();
            connection.Close();
            return(writter);
        }
        public List <Writter> GetAllWritter()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "SELECT * FROM tbl_writter";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader  reader      = command.ExecuteReader();
            List <Writter> writterList = new List <Writter>();

            while (reader.Read())
            {
                Writter writter = new Writter();
                GetDataFromDatabase(writter, reader);
                writterList.Add(writter);
            }
            reader.Close();
            connection.Close();
            return(writterList);
        }
Exemplo n.º 26
0
        private void ProcessFile2EncCallback(object obj)
        {
            TaskObject taskObject = (TaskObject)obj;
            var        filePath   = taskObject.FilePath;

            byte[] generatedSalt = this.encrypter.GenerateRandomSalt();
            byte[] bytes2Encrypt = File.ReadAllBytes(filePath);
            byte[] encrypted     = this.encrypter.EncryptBytes(
                bytes2Encrypt, taskObject.Pwd, generatedSalt
                );
#if DEBUG
            Writter.WriteBytes2File(encrypted, filePath + ".locked");
            Console.WriteLine("[T: " + Thread.CurrentThread.ManagedThreadId +
                              "] " + filePath + " | " +
                              Utilities.ConvertBytes2B64(generatedSalt));
            Console.WriteLine("Encrypted bytes: " +
                              Utilities.ConvertBytes2B64(encrypted));
#else
#endif
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            Writter writter = new Writter();

            writter.WritterCode    = writterCodeTextBox.Text;
            writter.WritterName    = writterNameTextBox.Text;
            writter.WritterPhone   = writterPhoneTextBox.Text;
            writter.WritterAddress = writterAddressTextArea.InnerText;
            string openingBalance = openingBalanceTextBox.Text;

            if (writterCodeTextBox.Text == "" || writterNameTextBox.Text == "" || writterPhoneTextBox.Text == "" ||
                writterAddressTextArea.InnerText == "" || openingBalanceTextBox.Text == "")
            {
                message.InnerText = "All Fields are Required!!";
            }
            else
            {
                writter.WritterOpeningBalance = Convert.ToDouble(openingBalance);
                messageLabel.InnerText        = writterManager.Save(writter);
                message.InnerText             = "";
            }
        }
Exemplo n.º 28
0
 public void Update(Writter entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 29
0
    public Client(){
        Writter = new Writter();
        Reader = new Reader();
	}
Exemplo n.º 30
0
        public void WritterKonstruktor()
        {
            Writter w = new Writter();

            Assert.AreNotEqual(w, null);
        }