public void AddGenesisBlock(string type) { switch (type) { case "credentrails": BlockchainCredentials bcCredentials = new BlockchainCredentials(); Chain.Add(new Block(DateTime.Now, null, bcCredentials)); break; case "data": BlockchainData bcData = new BlockchainData(); Chain.Add(new Block(DateTime.Now, null, bcData)); break; case "reports": BlockchainReports bcReports = new BlockchainReports(); Chain.Add(new Block(DateTime.Now, null, bcReports)); break; case "ratings": BlockchainRatings bcRatings = new BlockchainRatings(); Chain.Add(new Block(DateTime.Now, null, bcRatings)); break; } }
public ArticleDetails(BlockchainData Article, List <ArticleReports> AR, int UserID) { InitializeSender(); this.Article = Article; this.AR = AR; this.UserID = UserID; InitializeComponent(); ratedReports = new List <int>(); FlowDocument doc = new FlowDocument(); Paragraph p = new Paragraph(new Run(Article.Title)); p.FontSize = 36; doc.Blocks.Add(p); lstReports.ItemsSource = AR; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lstReports.ItemsSource); p = new Paragraph(new Run(Article.Content)); p.FontSize = 14; p.FontStyle = FontStyles.Italic; p.TextAlignment = TextAlignment.Left; p.Foreground = Brushes.Gray; doc.Blocks.Add(p); ContentView.Document = doc; txtAuthor.Text = Article.Author; txtDate.Text = Article.ReleaseDate; txtReports.Text = AR.Count.ToString(); }
public ArticleDetails(BlockchainData Article, List <ArticleReports> AR, int UserID, List <Block> listOfVotes) { InitializeSender(); //InitializeReceiver(); this.Article = Article; this.AR = AR; this.UserID = UserID; this.listOfVotes = listOfVotes; InitializeComponent(); FlowDocument doc = new FlowDocument(); Paragraph p = new Paragraph(new Run(Article.Title)); //Paragraph p = new Paragraph(new Run("Hello World "+ chain.Chain[lstProducts.SelectedIndex].Data.Title.ToString())); p.FontSize = 36; doc.Blocks.Add(p); lstReports.ItemsSource = AR; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lstReports.ItemsSource); p = new Paragraph(new Run(Article.Content)); p.FontSize = 14; p.FontStyle = FontStyles.Italic; p.TextAlignment = TextAlignment.Left; p.Foreground = Brushes.Gray; doc.Blocks.Add(p); ContentView.Document = doc; txtAuthor.Text = Article.Author; txtDate.Text = Article.ReleaseDate; txtReports.Text = AR.Count.ToString(); }
public Block(DateTime timeStamp, string previousHash, BlockchainData data) { Index = 0; TimeStamp = timeStamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffff"); PreviousHash = previousHash; Data = data; Hash = CalculateHash(); }
private void SendMessage() { MessagePack mp = new MessagePack(); BlockchainData bd = new BlockchainData(); /* * //Dane podstawowe * bd.NumerInwentaryzacyjny = tbRegNumber.Text; * bd.Nazwa = tbName.Text; * bd.NumerFabryczny = tbSerialNumber.Text; * bd.Model = tbModel.Text; * bd.Producent = tbProducer.Text; * bd.SymbolKST = tbSymbolKST.Text; * bd.Rodzaj = tbType.Text; * * //Daty * bd.DataZakupu = tbPurchaseDate.Text; * bd.DataPrzyjecia = tbStartDate.Text; * bd.DataZbycia = tbEndDate.Text; * bd.DataRozpoczeciaAmortyzacji = tbDepreciationStartDate.Text; * bd.RokProdukcji = (tbProductionYear.Text != String.Empty) ? Convert.ToInt32(tbProductionYear.Text) : 0; * bd.DataKoncaGwarancji = tbWarrantyDate.Text; * * //Lokalizacja * bd.MiejsceUzytkowania = tbAddress.Text; * bd.Dzial = tbSection.Text; * bd.NumerPomieszczenia = tbRoomNumber.Text; * bd.OsobaOdpowiedzialna = tbResponsiblePerson.Text; * * //Amortyzacja * bd.WartoscPoczatkowa = (tbOriginValue.Text != String.Empty) ? Convert.ToDouble(tbOriginValue.Text) : 0; * bd.StawkaAmortyzacji = (tbDepreciationRate.Text != String.Empty) ? Convert.ToDouble(tbDepreciationRate.Text) : 0; * bd.WartoscZamortyzowana = (tbAmortizedValue.Text != String.Empty) ? Convert.ToDouble(tbAmortizedValue.Text) : 0; * bd.Status = cbStatus.Text; * * //Dodatkowe informacje * bd.Uwagi = new TextRange(tbDescription.Document.ContentStart, tbDescription.Document.ContentEnd).Text; * * bd.IdentyfikatorModyfikatora = userID; */ mp.SmObj = new Block(System.DateTime.Now, null, bd); mp.Text = "newBlock"; byte[] data = Blockchain.ObjectToByteArray(mp); sendingClient.Send(data, data.Length); this.Close(); }
private void BtnSend_Click(object sender, RoutedEventArgs e) { MessagePack mp = new MessagePack(); BlockchainData bd = new BlockchainData(); bd.Title = new TextRange(tbContent.Document.ContentStart, tbContent.Document.ContentEnd).Text; // OPCJONALNE bd.Content = rtbEditor.Document; bd.Content = new TextRange(rtbEditor.Document.ContentStart, rtbEditor.Document.ContentEnd).Text; bd.Author = UserID; bd.ReleaseDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); mp.SmObj = new Block(System.DateTime.Now, null, bd); mp.Text = "newBlock"; byte[] data = Blockchain.ObjectToByteArray(mp); sendingClient.Send(data, data.Length); this.Close(); }
public Report(BlockchainData Article, int UserID, int ArticleID) { this.Article = Article; this.UserID = UserID; this.ArticleID = ArticleID; InitializeComponent(); FlowDocument doc = new FlowDocument(); Paragraph p = new Paragraph(new Run(Article.Title)); p.FontSize = 36; doc.Blocks.Add(p); p = new Paragraph(new Run(Article.Content)); p.FontSize = 14; p.FontStyle = FontStyles.Italic; p.TextAlignment = TextAlignment.Left; p.Foreground = Brushes.Gray; doc.Blocks.Add(p); ContentView.Document = doc; }
public Report(BlockchainData Article, int UserID, int ArticleID) { this.Article = Article; this.UserID = UserID; this.ArticleID = ArticleID; InitializeComponent(); FlowDocument doc = new FlowDocument(); Paragraph p = new Paragraph(new Run(Article.Title)); //Paragraph p = new Paragraph(new Run("Hello World "+ chain.Chain[lstProducts.SelectedIndex].Data.Title.ToString())); p.FontSize = 36; doc.Blocks.Add(p); p = new Paragraph(new Run(Article.Content)); p.FontSize = 14; p.FontStyle = FontStyles.Italic; p.TextAlignment = TextAlignment.Left; p.Foreground = Brushes.Gray; doc.Blocks.Add(p); ContentView.Document = doc; }
public Block CreateGenesisBlock() { BlockchainData bd = new BlockchainData(); return(new Block(DateTime.Now, null, bd)); }