示例#1
0
        private async void nvSample_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            Debug.WriteLine(Windows.Storage.ApplicationData.Current.LocalFolder.Path);
            if (args.IsSettingsSelected)
            {
                contentFrame.Navigate(typeof(Settings));
            }
            else
            {
                Model = null;
                var selectedItem = (Microsoft.UI.Xaml.Controls.NavigationViewItem)args.SelectedItem;
                if (selectedItem != null)
                {
                    string selectedItemTag = ((string)selectedItem.Tag);

                    foreach (var item in Info)
                    {
                        if (item.NameOfPlace == selectedItemTag)
                        {
                            GridRing.IsActive = true;
                            File.Delete(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\" + "Out.xml");

                            Model = await CommandsToWorkWithDB.GetXML(item, Info);

                            GridRing.IsActive = false;
                            DGBig.IsEnabled   = true;
                            GridFilling(item.NameOfPlace);
                        }
                    }
                }
            }
        }
示例#2
0
 public MainPage()
 {
     this.InitializeComponent();
     modelForDG = new ObservableCollection <ModelForDGBig>();
     Model      = new class1.Envelope();
     //CommandsToWorkWithDB.xmlFinish += GridFilling;
     DGBig.IsEnabled = false;
 }
        public static void Serialize(class1.Envelope xml)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(xml.GetType());

            using (FileStream fs = new FileStream(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\" + "Out.xml", FileMode.OpenOrCreate))
            {
                xmlSerializer.Serialize(fs, xml);

                Console.WriteLine("Объект сериализован");
            }
        }
        public static async Task <class1.Envelope> GetXML(Model selectedOne, ObservableCollection <Model> Info)
        {
            var response = await HttpRest.InfoPostAsync(IenumerationPaths.PostFirstTime, selectedOne);

            var filledModel = XmlParser.Desirialize(response);
            var xml         = new class1.Envelope();

            //string text = "No Data";

            if (filledModel.Body.submitApplicationResponse != null)
            {
                if (filledModel.Body.submitApplicationResponse.application.status == "ACCEPTED")
                {
                    foreach (var elem in Info)
                    {
                        if (elem == selectedOne)
                        {
                            elem.AppId = filledModel.Body.submitApplicationResponse.application.applicationId;
                            var Query = $"Update Merc_xs set AppID=\'{elem.AppId}\' where CodM= {elem.CodeFil} and CodB= {elem.CodePred}";
                            await ConnHolder.NonQueryAsyncConnect(Query);

                            Debug.WriteLine("Updated");
                        }
                    }
                    // = filledModel.Body.submitApplicationResponse.application.applicationId;
                    xml = XmlParser.DesirializeBig(await HttpRest.InfoPostAsync(IenumerationPaths.PostToCheck, selectedOne));
                    Debug.WriteLine(xml.Body.ReceiveApplicationResultResponse.Application.Status);
                    while (xml.Body.ReceiveApplicationResultResponse.Application.Status == "IN_PROCESS")
                    {
                        xml = XmlParser.DesirializeBig(await HttpRest.InfoPostAsync(IenumerationPaths.PostToCheck, selectedOne));
                        System.Threading.Thread.Sleep(2000);
                        //Debug.WriteLine(xml.Body.ReceiveApplicationResultResponse.Application.Status);
                    }
                    //Debug.WriteLine(xml.Body.ReceiveApplicationResultResponse.Application.Status);
                    //XmlParser.Serialize(xml);
                    //xmlFinish();
                    //text = File.ReadAllText(Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\" + "Out.xml");
                }
            }
            else
            {
                ContentDialog dialog = new ContentDialog()
                {
                    Title             = "Error",
                    Content           = "Failed to parse answer. This may means, you send wrong data or XML file is damaged.",
                    PrimaryButtonText = "ОК",
                };
                await dialog.ShowAsync();
            }
            return(xml);
        }