Beispiel #1
0
        private void btnProcessAll_Click(object sender, System.EventArgs e)
        {
            waitForm = new WaitForm();
            waitForm.Show();
            BackgroundWorker bcw         = new BackgroundWorker();
            string           archiveName = archives.Where(x => x.IdArchive == new Guid(radComboBoxArchive.SelectedValue.ToString())).FirstOrDefault().Name;
            bool             result      = false;

            bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
            {
                using (serviceTransito.TransitClient client = new serviceTransito.TransitClient("Binding_Transit"))
                {
                    result = client.StoreTransitArchiveDocuments(archiveName);
                }
            };
            bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
            {
                waitForm.Close();
                if (e1.Error == null)
                {
                    RadMessageBox.Show(result ? "File in transito processato correttamente." : "Non tutti i file in transito processati.", "Risultato processo", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Info);
                    LoadDocument(0);
                }
                else
                {
                    RadMessageBox.Show(e1.Error.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
                }
            };

            bcw.RunWorkerAsync();
        }
Beispiel #2
0
        private void LoadDocument(int pageNumber)
        {
            if (pageNumber < 1)
            {
                pageNumber = 0;
            }
            if (pageNumber > 0)
            {
                pageNumber--;
            }

            waitForm = new WaitForm();
            waitForm.Show();
            archiveName = radComboBoxArchive.Text;
            Exception error = null;

            #region NEW

            try
            {
                using (var client = new serviceTransito.TransitClient("Binding_Transit"))
                {
                    if (!string.IsNullOrEmpty(archiveName))
                    {
                        var response = client.GetTransitListDocumentsPaged(archiveName, pageNumber * TAKE, TAKE);
                        if (response.Error != null)
                        {
                            error = new Exception(response.Error.Message);
                        }
                        else
                        {
                            if (response.TotalRecords < 1)
                            {
                                this.ucPager.Initialize();
                            }
                            else
                            {
                                double numPagine = (double)response.TotalRecords / (double)TAKE;
                                this.ucPager.Initialize(1, (int)Math.Ceiling(numPagine), pageNumber + 1);
                            }
                        }
                        documents = response.Documents;
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }
            finally
            {
                waitForm.Close();

                if (error == null)
                {
                    radGridView1.DataSource = documents;
                }
                else
                {
                    this.ucPager.Initialize();
                    RadMessageBox.Show(error.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
                }
            }

            #endregion

            #region OLD

            //var bcw = new BackgroundWorker();
            //bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1)
            //{
            //    using (serviceTransito.TransitClient client = new serviceTransito.TransitClient("Binding_Transit"))
            //    {
            //        if (!string.IsNullOrEmpty(archiveName))
            //        {
            //            documents = client.GetTransitListDocumentsPaged(archiveName, pageNumber * TAKE, TAKE).Documents;
            //        }
            //    }
            //};
            //bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1)
            //{
            //    waitForm.Close();
            //    if (e1.Error == null)
            //        radGridView1.DataSource = documents;
            //    else
            //        RadMessageBox.Show(e1.Error.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error);
            //};

            //bcw.RunWorkerAsync();

            #endregion
        }