コード例 #1
0
        private async Task btnValidateProject()
        {
            WcfExt116 cAX = null;

            try
            {
                SetProgress(.0);
                //lvProjects.ItemsSource = m_ocProjSearch;
                //this.pbDownload.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                //this.tbDownloadStatus.Text = String.Empty;

                //this.m_bIgnoreReset = true;
                this.txtProjectNo.Text = this.txtProjectNo.Text.Trim().ToUpper();

                if (this.txtProjectNo.Text.Length == 0)
                {
                    await DisplayAlert("Project no required.", "You need to provide a project number before you can validate.", "OK");

                    this.txtProjectNo.Focus();
                    return;
                }


                //Check project is not already downloaded.
                bool bAlreadyDownloaded = await this.IsProjectAlreadyOnDevice(this.txtProjectNo.Text);

                SetProgress(.1);
                if (bAlreadyDownloaded == true)
                {
                    return;
                }


                bool bConnectedOK = await Main.p_cSettings.IsAXSystemAvailable(true);

                if (bConnectedOK == true)
                {
                    SetProgress(.2);
                    await Main.CheckForUpdates();

                    SetProgress(.4);
                    cAX = new WcfExt116();
                    ProjectValidationResult cResult = await cAX.ValidateProjectNo(this.txtProjectNo.Text);

                    if (cResult != null)
                    {
                        if (cResult.bSuccessfull == true)
                        {
                            SetProgress(.6);
                            if (cResult.bProjectFound == true)
                            {
                                //Mark project as valid.
                                //this.m_bProjectValid = true;

                                //Fetch status name from base enum table.
                                string       sStatus  = Main.p_cDataAccess.GetEnumValueName("ProjTable", "Status", Convert.ToInt32(cResult.ValidationResult.Status));
                                SearchResult srResult = new SearchResult();
                                SetProgress(.8);
                                srResult.ProjectName = cResult.ValidationResult.ProjectName;
                                srResult.ProjectNo   = cResult.ValidationResult.ProjectNo;
                                srResult.Status      = sStatus;
                                try
                                {
                                    m_ocProjSearch.Clear();
                                }
                                catch (Exception ex)
                                {
                                    lvProjects.ItemsSource = null;
                                }
                                //m_ocProjSearch.Clear();
                                m_ocProjSearch.Add(srResult);
                                lvProjects.ItemsSource = m_ocProjSearch;
                                SetProgress(.9);

                                //Display project details.
                                //this.DisplayProjectDetails(cResult.ValidationResult.ProjectName, sStatus);

                                //Display download section.
                                //this.UpdateValidationStatus(ValidationStatus.Valid);
                                //this.gdDownload.Visibility = Windows.UI.Xaml.Visibility.Visible;
                            }
                            else
                            {
                                SearchResult srResult = new SearchResult();
                                SetProgress(.8);
                                srResult.ProjectName = "N/A";
                                srResult.ProjectNo   = "N/A";
                                srResult.Status      = "N/A";
                                try
                                {
                                    m_ocProjSearch.Clear();
                                }
                                catch (Exception ex)
                                {
                                    lvProjects.ItemsSource = null;
                                }
                                m_ocProjSearch.Add(srResult);
                                lvProjects.ItemsSource = m_ocProjSearch;
                                SetProgress(.9);
                                //Mark project as invalid.
                                //this.m_bProjectValid = false;

                                //this.UpdateValidationStatus(ValidationStatus.Invalid);
                                //this.gdDownload.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                            }
                        }
                        else
                        {
                            //Mark project as invalid.
                            //this.m_bProjectValid = false;

                            //this.UpdateValidationStatus(ValidationStatus.Error);
                            //this.gdDownload.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                        }
                    }
                }
                SetProgress(1.0);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
                //cMain.ReportError(ex, cMain.GetCallerMethodName(), string.Empty);
            }
        }