コード例 #1
0
        void OnRequestCreateUrl(UrlInfo urlInfo)
        {
            if (urlInfo == null)
            {
                return;
            }
            switch (urlInfo.Mode)
            {
            case UrlMode.CreateByReceive:
                if (!UrlInfos.Any(x => x.Address == urlInfo.Address))
                {
                    UrlInfos.Add(urlInfo);
                }
                break;

            case UrlMode.EditByReceive:
                var result = AccountsService.Default.SetAccountTag(urlInfo.Address, urlInfo.Tag);
                if (!result.IsFail)
                {
                    this.SelectedItem.Tag = urlInfo.Tag;
                    ReceiveAddressBookMonitor.Default.Start(500);
                }
                break;

            default:
                break;
            }
        }
コード例 #2
0
        void Export()
        {
            if (UrlInfos == null || !UrlInfos.Any())
            {
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "CSV£¨*.csv£©|*.csv";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            var result = saveFileDialog.ShowDialog(BootStrapService.Default.Shell.GetWindow());

            if (result.HasValue && result.Value)
            {
                try
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    var           header        = string.Format("{0},{1}", LanguageService.Default.GetLanguageValue("Tag"), LanguageService.Default.GetLanguageValue("Address"));
                    stringBuilder.AppendLine(header);
                    UrlInfos.ToList().ForEach(x =>
                    {
                        var newline = string.Format("{0},{1}", x.Tag, x.Address);
                        stringBuilder.AppendLine(newline);
                    });


                    var file = saveFileDialog.FileName;
                    using (Stream stream = File.Create(file))
                    {
                        using (var writer = new StreamWriter(stream, Encoding.Unicode))
                        {
                            var data = stringBuilder.ToString().Replace(",", "\t");
                            writer.Write(data);
                            writer.Close();
                        }
                        stream.Close();
                    }
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Export_Sucesses));
                }
                catch
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Export_Fail));
                }
            }
        }
コード例 #3
0
ファイル: PayUrlsViewModel.cs プロジェクト: omcdev/wallet
        void OnRequestCreateUrl(UrlInfo urlInfo)
        {
            if (urlInfo == null)
            {
                return;
            }
            var netstr = OmniCoinSetting.NodeTypeStr;

            if (!AddressTools.AddressVerfy(netstr, urlInfo.Address))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_Address));
                return;
            }
            switch (urlInfo.Mode)
            {
            case UrlMode.CreatePay:
                if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address)))
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed));
                    return;
                }
                StaticViewModel.GlobalViewModel.IsLoading = true;
                var result = AddressBookService.Default.UpsertAddrBookItem(urlInfo.Address, urlInfo.Tag);
                if (!result.IsFail)
                {
                    LoadUrls();
                }
                else
                {
                    ShowMessage(result.GetErrorMsg());
                }
                break;

            case UrlMode.Edit:
                if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address) && x.Id != urlInfo.Id))
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed));
                    return;
                }
                var updateResult = AddressBookService.Default.UpsertAddrBookItem(urlInfo.Address, urlInfo.Tag, urlInfo.Id);
                if (!updateResult.IsFail)
                {
                    var selectedUrlinfo = UrlInfos.FirstOrDefault(x => x.Id == urlInfo.Id);
                    if (selectedUrlinfo == null)
                    {
                        UrlInfos.Add(urlInfo);
                    }
                    else
                    {
                        selectedUrlinfo.Tag     = urlInfo.Tag;
                        selectedUrlinfo.Address = urlInfo.Address;
                        selectedUrlinfo.Mode    = urlInfo.Mode;
                        SelectedItem            = selectedUrlinfo;
                    }
                }
                else
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Edit_Fail));
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
        void OnRequestCreateUrl(UrlInfo urlInfo)
        {
            if (urlInfo == null)
            {
                return;
            }
            var netstr = "mainnet";

            switch (NodeSetting.CurrentNetworkType)
            {
            case Biz.NetworkType.MainnetPort:
                break;

            case Biz.NetworkType.TestNetPort:
                netstr = "testnet";
                break;

            default:
                break;
            }

            if (!AddressTools.AddressVerfy(netstr, urlInfo.Address))
            {
                ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Error_Address));
                return;
            }
            switch (urlInfo.Mode)
            {
            case UrlMode.CreatePay:
                if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address)))
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed));
                    return;
                }
                var result = AddressBookService.Default.AddNewAddressBookItem(urlInfo.Address, urlInfo.Tag);
                if (!result.IsFail)
                {
                    //UrlInfos.Add(urlInfo);
                    LoadUrls();
                }
                else
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Add_Fail));
                }
                break;

            case UrlMode.Edit:
                if (UrlInfos.Any(x => x.Address.Equals(urlInfo.Address) && x.Id != urlInfo.Id))
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Address_Existed));
                    return;
                }
                var updateResult = AddressBookService.Default.AddNewAddressBookItem(urlInfo.Address, urlInfo.Tag);
                if (!updateResult.IsFail)
                {
                    var urlinfo = UrlInfos.FirstOrDefault(x => x.Id == urlInfo.Id);
                    if (urlinfo == null)
                    {
                        UrlInfos.Add(urlInfo);
                    }
                    else
                    {
                        urlinfo.Tag     = urlInfo.Tag;
                        urlinfo.Address = urlInfo.Address;
                    }
                }
                else
                {
                    ShowMessage(LanguageService.Default.GetLanguageValue(MessageKeys.Edit_Fail));
                }
                SelectedItem.Address = urlInfo.Address;
                SelectedItem.Tag     = urlInfo.Tag;
                SelectedItem.Mode    = urlInfo.Mode;
                break;

            default:
                break;
            }
        }