private void button2_Click(object sender, EventArgs e) { string username = ConfigurationManager.AppSettings.Get("rpcusername"); string password = ConfigurationManager.AppSettings.Get("rpcpassword"); string wallet_url = ConfigurationManager.AppSettings.Get("wallet_url"); string wallet_port = ConfigurationManager.AppSettings.Get("wallet_port"); RpcMethods rpc = new RpcMethods(username, password, wallet_url, wallet_port); try { string tx_id2 = txidbox2.Text; JObject obj1 = JObject.Parse(rpc.GetRawTransaction(tx_id2)); if (string.IsNullOrEmpty(obj1["error"].ToString())) { string flodata = ""; flodata = obj1["result"]["flodata"].ToString(); label2.Text = flodata; label2.ForeColor = Color.Green; label2.Visible = true; } else { label2.Text = "Error retrieving reviews from the flo!!"; label2.ForeColor = Color.Green; label2.Visible = true; } } catch (RpcInternalServerErrorException ex) { var errCode = 0; var errMessage = string.Empty; if (ex.RpcErrorCode.GetHashCode() != 0) { errCode = ex.RpcErrorCode.GetHashCode(); errMessage = ex.RpcErrorCode.ToString(); } Console.WriteLine("Exception :" + errCode + "-" + errMessage); label2.Text = "Internal server error!!"; label2.ForeColor = Color.Red; label2.Visible = true; label2.Visible = true; } catch (Exception ex1) { Console.WriteLine("Exception :" + ex1.ToString()); label2.Text = "Error connecting to the server!!"; label2.ForeColor = Color.Red; label2.Visible = true; label2.Visible = true; } }
private void flo_certificate_Load(object sender, EventArgs e) { string username = ConfigurationManager.AppSettings.Get("username"); string password = ConfigurationManager.AppSettings.Get("password"); string wallet_url = ConfigurationManager.AppSettings.Get("wallet_url"); string wallet_port = ConfigurationManager.AppSettings.Get("wallet_port"); string transid = ""; SqlConnection con = new SqlConnection(connstr); con.Open(); SqlCommand cmd = new SqlCommand("select Trans_no from Flo_record where Certi_no=@certno", con); cmd.Parameters.Add(new SqlParameter("@certno", cert_no)); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { transid = reader["Trans_no"].ToString(); } con.Close(); RpcMethods rpc = new RpcMethods(username, password, wallet_url, wallet_port); try { JObject obj = JObject.Parse(rpc.GetRawTransaction(transid)); if (string.IsNullOrEmpty(obj["error"].ToString())) { string res = obj["result"]["floData"].ToString(); string[] data = res.Split('#'); string name = data[1].ToString(); string fname = data[2].ToString(); string reg = data[3].ToString(); string course = data[4].ToString(); string grade = data[5].ToString(); string percentage = data[6].ToString(); string doj = data[7].ToString(); string dop = data[8].ToString(); string cer_date = data[9].ToString(); string cert_num = data[10].ToString(); url = "https://testnet.flocha.in/tx/" + transid; lblName.Text = name; lblGuardian.Text = fname; lblReg_no.Text = reg; lblCourse.Text = course; lblGrade.Text = grade; lblPercent.Text = percentage; lblJoin_Date.Text = doj; lblCompilition_Date.Text = dop; lblDate.Text = cer_date; lblCertificate_no.Text = cert_num; linklblUrl.Text = url; linklblUrl.Visible = true; QRCodeEncoder enc = new QRCodeEncoder(); //Bitmap qrcode = enc.Encode(url); //QRpicbox.Image = qrcode as System.Drawing.Image; Bitmap img; enc.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.H; enc.QRCodeScale = 10; img = enc.Encode(url); QRpicbox.Image = img; } else { MessageBox.Show("Get Transaction Error : " + obj["error"]); } } catch (RpcInternalServerErrorException exception) { var errorCode = 0; var errorMessage = string.Empty; if (exception.RpcErrorCode.GetHashCode() != 0) { errorCode = exception.RpcErrorCode.GetHashCode(); errorMessage = exception.RpcErrorCode.ToString(); } Console.WriteLine("[Failed] {0} {1} {2}", exception.Message, errorCode != 0 ? "Error code: " + errorCode : string.Empty, !string.IsNullOrWhiteSpace(errorMessage) ? errorMessage : string.Empty); MessageBox.Show("Wallet Error Code : " + errorCode); linklblUrl.Visible = false; } }
private void Button1_Click(object sender, EventArgs e) { string username = ConfigurationManager.AppSettings.Get("rpcusername"); string past = ConfigurationManager.AppSettings.Get("rpcpassword"); string url1 = ConfigurationManager.AppSettings.Get("wallet_url"); string port = ConfigurationManager.AppSettings.Get("wallet_port"); RpcMethods rpc = new RpcMethods(username, past, url1, port); string us = response.Text; string p = ComputeSha256Hash(pas.Text).ToString(); try { JObject obj = JObject.Parse(rpc.GetRawTransaction(us)); string flodata = ""; if (string.IsNullOrEmpty(obj["error"].ToString())) { flodata = obj["result"]["floData"].ToString(); string passcode = decrpyt(flodata).ToString(); if (passcode.Equals(p)) { response.Text = "****SUCCESSFULLY LOGGED-IN****"; response.ForeColor = Color.DarkOliveGreen; response.Visible = true; verification ob = new verification(us); this.Hide(); ob.Show(); } else { response.Text = "****INCORRECT PASSWORD****"; response.ForeColor = Color.Firebrick; response.Visible = true; } } else { Console.WriteLine("Error searching the transactions"); response.Text = "****BLOCKCHAIN ERROR****"; response.ForeColor = Color.Blue; response.Visible = true; } } catch (RpcInternalServerErrorException ex) { var err_code = 0; var err_message = string.Empty; if (ex.RpcErrorCode.GetHashCode() != 0) { err_code = ex.RpcErrorCode.GetHashCode(); err_message = ex.RpcErrorCode.ToString(); } Console.WriteLine("Exception:" + err_code + " " + err_message); response.Text = "****BLOCKCHAIN ERROR****"; response.ForeColor = Color.Blue; response.Visible = true; } catch (Exception ex1) { Console.WriteLine("Exception:" + ex1); response.Text = "****VISUAL STUDIO ERROR****" + ex1; response.ForeColor = Color.Red; response.Visible = true; } }