コード例 #1
0
        public async Task <VerificationResult> GetVerificationResult(TransactionDownloadData <Transaction> transaction)
        {
            if (transaction == null || !(transaction.Transaction is AttachementDataTransaction attachementTransaction))
            {
                return(null);
            }

            var serviceNode = transaction.Tag as ServiceNode;

            var result = await serviceNode.GetTransactionDownloadManager(transaction.Transaction.ChainIndex).DownloadTransactionAttachement(transaction);

            if (result.AttachementsState == TransactionAttachementsState.Ok)
            {
                var attachement = result.GetAttachementData(VerifyServiceInfo.JsonFileName);
                if (attachement != null)
                {
                    var hash = Hash.Generate(Protocol.AttachementsHashType, attachement);
                    if (hash == attachementTransaction.Items[0].DataHash)
                    {
                        var json   = Encoding.UTF8.GetString(attachement);
                        var verify = json.FromJson <VerifyJson>();
                        if (verify != null)
                        {
                            return(new VerificationResult(attachementTransaction, verify, serviceNode));
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        protected override ButtonRow AddRow(StackPage page, TransactionDownloadData<Transaction> transaction)
        {
            var message = _chat.GetMessage(transaction);
            var accountId = transaction.Transaction.AccountId;

            var button = page.AddButtonRow(null, Message);
            button.LabelPadding = 0;
            button.RowStyle = Theme.MessageButton;

            button.RowLayout.Children.RemoveAt(0);
            button.RowLayout.Children.Remove(button.FontIcon);
            button.Label.Margin = new Thickness(5, 2, 5, 2);

            var (text, detail) = GetMessageText(message);
            button.SetMultilineText(text, detail);
            button.Tag = message;

            if (accountId == _chat.AccountId)
            {
                button.Margin = new Thickness(0, 0, 46, 0);
            }
            else
            {
                button.Margin = new Thickness(46, 0, 0, 0);
            }

            return button;
        }
コード例 #3
0
        StackRow AddMessageRow(TransactionDownloadData <Transaction> transaction)
        {
            var             att      = transaction.Transaction as AttachementDataTransaction;
            var             hasImage = att.Items.Any((i) => i.Name == StatusServiceInfo.ImageFileName);
            ButtonLayoutRow row      = null;

            if (!hasImage)
            {
                var view = new TextMessageView(transaction, _page);
                row     = new ButtonLayoutRow(Icons.RowMore, view.Button, view);
                row.Tag = view;
            }
            else
            {
                var view = new ImageMessageView(transaction, _page);
                row = new ButtonLayoutRow(Icons.RowMore, view.Button, view);

                row.OnColorStyleChange = (colorStyle) => view.LabelFrame.ColorStyle = colorStyle;
                row.Tag = view;
            }

            //row.RowStyle = Theme.MessageRowButton;
            _page.AddView(row);
            return(row);
        }
コード例 #4
0
ファイル: TodoList.cs プロジェクト: HeleusCore/Heleus.Todo
        async Task ProcessTransaction(TransactionDownloadData <Transaction> transactionDownload)
        {
            try
            {
                var transaction = transactionDownload.Transaction;

                var data = transaction.GetFeature <Data>(Data.FeatureId);
                if (data == null) // Group Stuff
                {
                    return;
                }

                var group   = transaction.GetFeature <Group>(Group.FeatureId);
                var groupId = group.GroupId;
                var index   = group.GroupIndex;

                var storage = LoadTodoStorage(transactionDownload);
                if (storage == null)
                {
                    using (var unpacker = new Unpacker(data.Items[0].Data))
                    {
                        var targetedTransactionId = Operation.InvalidTransactionId;

                        var transactionTarget = transaction.GetFeature <TransactionTarget>(TransactionTarget.FeatureId);
                        if (transactionTarget != null)
                        {
                            targetedTransactionId = transactionTarget.Targets[0];
                        }

                        if (index == TodoServiceInfo.TodoTaskStatusIndex)
                        {
                            storage = new TodoRecordStorage <TodoTaskStatusRecord>(new TodoTaskStatusRecord(unpacker), transaction.TransactionId, transaction.AccountId, transaction.Timestamp, targetedTransactionId, groupId);
                        }
                        else if (index == TodoServiceInfo.TodoTaskIndex)
                        {
                            storage = await GetDecryptedRecord <TodoTaskRecord>(transaction, targetedTransactionId, groupId, unpacker);
                        }
                        else if (index == TodoServiceInfo.TodoListNameIndex)
                        {
                            storage = await GetDecryptedRecord <TodoListNameRecord>(transaction, targetedTransactionId, groupId, unpacker);
                        }

                        if (storage != null)
                        {
                            await SaveTodoStorage(transactionDownload, storage);
                        }
                    }
                }

                if (storage != null && MissingSecretKeys.Count == 0)
                {
                    Process(storage);
                }
            }
            catch (Exception ex)
            {
                Log.IgnoreException(ex);
            }
        }
コード例 #5
0
            protected override void UpdateRow(ButtonViewRow <NoteView> row, TransactionDownloadData <Transaction> newItem)
            {
                var noteData    = NoteApp.Current.GetNoteData(newItem);
                var serviceNode = noteData.ServiceNode;

                row.View.Update(noteData);
                row.RowLayout.SetAccentColor(serviceNode.AccentColor);
            }
コード例 #6
0
        public DecryptedRecordData <MessageRecord> GetMessage(TransactionDownloadData <Transaction> transaction)
        {
            if (!_messages.TryGetValue(transaction.TransactionId, out var record))
            {
                record = new DecryptedRecordData <MessageRecord>(transaction, _serviceNode, Index, "message", DecryptedRecordDataSource.DataFeature);
                _messages[transaction.TransactionId] = record;
            }

            return(record);
        }
コード例 #7
0
            protected override ButtonViewRow <NoteView> AddRow(StackPage page, TransactionDownloadData <Transaction> item)
            {
                var noteData    = NoteApp.Current.GetNoteData(item);
                var serviceNode = noteData.ServiceNode;

                var button = page.AddButtonViewRow(new NoteView(noteData), Note);

                button.RowLayout.SetAccentColor(serviceNode.AccentColor);

                return(button);
            }
コード例 #8
0
ファイル: TodoList.cs プロジェクト: HeleusCore/Heleus.Todo
 async Task SaveTodoStorage(TransactionDownloadData <Transaction> transactionDownload, IRecordStorage todoStorage)
 {
     try
     {
         transactionDownload.AddDecryptedAttachement("todo", todoStorage.ToByteArray());
         await transactionDownload.TransactionManager.StoreDecryptedTransactionData(transactionDownload);
     }
     catch (Exception ex)
     {
         Log.IgnoreException(ex);
     }
 }
コード例 #9
0
        protected MessageViewBase(ExtContentPage page, TransactionDownloadData <Transaction> transaction)
        {
            Transaction = transaction;
            Page        = page;

            TextLabel.InputTransparent = true;
            //TextLabel.FontStyle = Theme.TextFont;
            //TextLabel.ColorStyle = Theme.TextColor;
            TextLabel.Margin = new Thickness(15, 10, 15, 10);

            SizeChanged   += LayoutChangedd;
            LayoutChanged += LayoutChangedd;
        }
コード例 #10
0
        public ImageMessageView(TransactionDownloadData <Transaction> transaction, ExtContentPage page) : base(page, transaction)
        {
            //LabelFrame.ColorStyle = Theme.MessageRowColor;
            LabelFrame.Content          = TextLabel;
            LabelFrame.InputTransparent = true;

            Image.Aspect           = Aspect.Fill;
            Image.InputTransparent = true;

            AbsoluteLayout.SetLayoutFlags(LabelFrame, AbsoluteLayoutFlags.WidthProportional | AbsoluteLayoutFlags.YProportional);
            AbsoluteLayout.SetLayoutBounds(LabelFrame, new Rectangle(0, 1, 1, AbsoluteLayout.AutoSize));

            AbsoluteLayout.SetLayoutFlags(Image, AbsoluteLayoutFlags.SizeProportional);
            AbsoluteLayout.SetLayoutBounds(Image, new Rectangle(0, 0, 1, 1));

            Update();

            Children.Add(Image);
            Children.Add(LabelFrame);
        }
コード例 #11
0
        public NoteData GetNoteData(TransactionDownloadData <Transaction> transaction)
        {
            var serviceNode = transaction.Tag as ServiceNode;

            if (!_notes.TryGetValue(serviceNode.Id, out var lookup))
            {
                lookup = new Dictionary <long, NoteData>();
                _notes[serviceNode.Id] = lookup;
            }

            if (lookup.TryGetValue(transaction.TransactionId, out var noteData))
            {
                return(noteData);
            }

            noteData = new NoteData(transaction, serviceNode);
            lookup[transaction.TransactionId] = noteData;

            return(noteData);
        }
コード例 #12
0
ファイル: TodoList.cs プロジェクト: HeleusCore/Heleus.Todo
        public IRecordStorage LoadTodoStorage(TransactionDownloadData <Transaction> transactionDownload)
        {
            try
            {
                var data = transactionDownload.GetDecryptedData("todo");
                if (data != null)
                {
                    using (var unpacker = new Unpacker(data))
                    {
                        var recordType = (TodoRecordTypes)RecordStorage.ReadRecordType(unpacker);

                        Type type = null;
                        if (recordType == TodoRecordTypes.ListName)
                        {
                            type = typeof(TodoRecordStorage <TodoListNameRecord>);
                        }
                        else if (recordType == TodoRecordTypes.Task)
                        {
                            type = typeof(TodoRecordStorage <TodoTaskRecord>);
                        }
                        else if (recordType == TodoRecordTypes.TaskStatus)
                        {
                            type = typeof(TodoRecordStorage <TodoTaskStatusRecord>);
                        }

                        if (type != null)
                        {
                            return((IRecordStorage)Activator.CreateInstance(type, unpacker));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.IgnoreException(ex);
            }

            return(null);
        }
コード例 #13
0
        public TextMessageView(TransactionDownloadData <Transaction> transaction, ExtContentPage page) : base(page, transaction)
        {
            Update();

            Children.Add(TextLabel);
        }
コード例 #14
0
 public NoteData(TransactionDownloadData <Transaction> transaction, ServiceNode serviceNode) : base(transaction, serviceNode, NoteServiceInfo.NoteIndex, NoteServiceInfo.NoteFileName, DecryptedRecordDataSource.Attachement)
 {
 }