Пример #1
0
        private async void Sync_upAction(object sender, RoutedEventArgs e)
        {
            /*
             if (WordList.Substring(0, 4) == "false")
             {
                 var dialog = new ContentDialog()
                 {
                     Title = "Info",
                     Content = "WordList is Null!",
                     PrimaryButtonText = "OK",
                     SecondaryButtonText = "Cancel",
                     FullSizeDesired = false,
                 };

                 dialog.PrimaryButtonClick += (_s, _e) => { };
                 await dialog.ShowAsync();
             }*/
            // Clear Erro message 
            // Create proxy instance 
            String Userid = "ljp";
            pdf.ServiceReference1.Service1Client serviceClient_f = new pdf.ServiceReference1.Service1Client();

            // async call WCF method to get returned data 
            pdf.ServiceReference1.querySqlRequest request_f = new pdf.ServiceReference1.querySqlRequest(Userid, "123", true);
            pdf.ServiceReference1.querySqlResponse ds_f = await serviceClient_f.querySqlAsync(request_f);


            if (ds_f.queryParam)
            {
                // Convert Xml to List<Article> 
                //String a = ds_f.querySqlResult.Nodes[1].ToString();
                XDocument xdoc = XDocument.Parse(ds_f.querySqlResult.Nodes[1].ToString(), LoadOptions.None);
                var data = from query in xdoc.Descendants("Table")
                           select new Article_
                           {
                               userid = query.Element("userid").Value,
                               wordlist = query.Element("wordlist").Value,
                           };
                Task.Run(() => { ImportWordList(); });
                while (bgetword == false) ;
                bgetword = false;
                string WordList = "";
                for (int i = 0; i < Wordlist.Length; i++)
                {
                    WordList += Wordlist[i];
                }
                //string WordList = "name01名称";
                pdf.ServiceReference2.Service2Client serviceClient = new pdf.ServiceReference2.Service2Client();
               // WordList = "afcafnohsauauahiubcinskjiwejksbndfuihsdiusdfhajksdbcvnmxbcjhdhsfjhisahfiuafhasjkhfisahfhsajkfhajkajk";
                bool IsInsert = false;
                if (data.Count() == 0)
                {
                    IsInsert = true;
                }
                pdf.ServiceReference2.querySqlRequest request = new pdf.ServiceReference2.querySqlRequest(Userid, WordList, IsInsert);
                pdf.ServiceReference2.querySqlResponse ds = await serviceClient.querySqlAsync(request);

                if (ds.queryParam)
                {
                    var dialog = new ContentDialog()
                    {
                        Title = "wordlist",
                        Content = "Sync Success!",
                        PrimaryButtonText = "OK",
                        SecondaryButtonText = "Cancel",
                        FullSizeDesired = false,
                    };

                    dialog.PrimaryButtonClick += (_s, _e) => { };
                    await dialog.ShowAsync();
                }
                else
                {
                    var dialog = new ContentDialog()
                    {
                        Title = "wordlist",
                        Content = "Insert Error occurs. Please make sure the database has been attached to SQL Server!",
                        PrimaryButtonText = "OK",
                        SecondaryButtonText = "Cancel",
                        FullSizeDesired = false,
                    };

                    dialog.PrimaryButtonClick += (_s, _e) => { };
                    await dialog.ShowAsync();
                }
            }
            else
            {
                var dialog = new ContentDialog()
                {
                    Title = "wordlist",
                    Content = "Insert Error occurs. Please make sure the database has been attached to SQL Server!",
                    PrimaryButtonText = "OK",
                    SecondaryButtonText = "Cancel",
                    FullSizeDesired = false,
                };

                dialog.PrimaryButtonClick += (_s, _e) => { };
                await dialog.ShowAsync();
            }
        }
Пример #2
0
        private async void Sync_downAction(object sender, RoutedEventArgs e)
        {


            // Clear Erro message 
            // Create proxy instance 
            String Userid = "ljp";
            pdf.ServiceReference1.Service1Client serviceClient_f = new pdf.ServiceReference1.Service1Client();

            // async call WCF method to get returned data 
            pdf.ServiceReference1.querySqlRequest request_f = new pdf.ServiceReference1.querySqlRequest(Userid, "123", true);
            pdf.ServiceReference1.querySqlResponse ds_f = await serviceClient_f.querySqlAsync(request_f);


            if (ds_f.queryParam)
            {
                // Convert Xml to List<Article> 
                String a = ds_f.querySqlResult.Nodes[1].ToString();
                XDocument xdoc = XDocument.Parse(ds_f.querySqlResult.Nodes[1].ToString(), LoadOptions.None);
                var data = from query in xdoc.Descendants("Table")
                           select new Article_
                           {
                               userid = query.Element("userid").Value,
                               wordlist = query.Element("wordlist").Value,
                           };
                if (data.Count() == 0)
                {
                    var dialog = new ContentDialog()
                    {
                        Title = "wordlist",
                        Content = "user doesn't exist!",
                        PrimaryButtonText = "OK",
                        SecondaryButtonText = "Cancel",
                        FullSizeDesired = false,
                    };

                    dialog.PrimaryButtonClick += (_s, _e) => { };
                    await dialog.ShowAsync();
                }
                else
                {
                    String WordList = xdoc.Root.Value.ToString();
                    WordList = WordList.Replace(Userid, "");
                    var dialog = new ContentDialog()
                    {
                        Title = "wordlist",
                        Content = "download success!",
                        PrimaryButtonText = "OK",
                        SecondaryButtonText = "Cancel",
                        FullSizeDesired = false,
                    };

                    dialog.PrimaryButtonClick += (_s, _e) => { };
                    await dialog.ShowAsync();
                }

            }
        }