Пример #1
0
        void dbBackup_OnBackupDataError(DataErrorType errorType, string message)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { dbBackup_OnBackupDataError(errorType, message); }));
                return;
            }

            bool shouldContinue = false;

            if (errorType == DataErrorType.InvalidData || errorType == DataErrorType.SQLError)
            {
                shouldContinue =
                    MessageBox.Show(string.Format("Error with backup data: {0}\r\nWould you like to continue and skip this item?", message), "Error", MessageBoxButtons.YesNo)
                    == System.Windows.Forms.DialogResult.Yes;
                dbBackup.ShouldContinue = shouldContinue;
            }
            else
            {
                MessageBox.Show(string.Format("Error: {0}", message), "Error", MessageBoxButtons.OK);
            }

            if (!shouldContinue)
            {
                if (worker != null && worker.IsAlive)
                {
                    worker.Join();
                }
                Close();
            }
        }
Пример #2
0
        //metoda pomocnicza zbierająca informacje o błędach
        private static void PodajBledy(this InsERT.Mox.BusinessObjects.IBusinessObject obiektBiznesowy,
                                       InsERT.Mox.Validation.IValidationMetadataStore store,
                                       List <BladInfo> bledy)
        {
            HashSet <ITypedDataErrorInfo> invalidData = new HashSet <ITypedDataErrorInfo>();

            ((InsERT.Mox.DataAccess.IGetDataDomain)obiektBiznesowy).DataDomain.TraverseData(
                obiektBiznesowy.Data, (o) =>
            {
                ITypedDataErrorInfo dataErrorInfoEx = o as ITypedDataErrorInfo;
                if (HasAnyErrors(store, dataErrorInfoEx))
                {
                    invalidData.Add(dataErrorInfoEx);
                }
                return(true);
            });

            foreach (var encjaZBledami in invalidData)
            {
                foreach (var bladNaCalejEncji in encjaZBledami.Errors)
                {
                    StringBuilder sb = new StringBuilder(3);
                    sb.AppendLine(bladNaCalejEncji.ToString());
                    sb.Append(" na encjach:" + encjaZBledami.GetType().Name);
                    DataErrorType errorType = store.GetEntryForClrType(bladNaCalejEncji.GetType());
                    bledy.Add(new BladInfo(sb.ToString(), errorType.Severity));
                }
                foreach (var bladNaKonkretnychPolach in encjaZBledami.MemberErrors)
                {
                    StringBuilder sb = new StringBuilder(3);
                    sb.AppendLine(bladNaKonkretnychPolach.Key.ToString());
                    sb.AppendLine(" na polach:");
                    sb.AppendLine(string.Join(", ", bladNaKonkretnychPolach.Select(b => encjaZBledami.GetType().Name + "." + b)));
                    DataErrorType errorType = store.GetEntryForClrType(bladNaKonkretnychPolach.Key.GetType());
                    bledy.Add(new BladInfo(sb.ToString(), errorType.Severity));
                }
            }
        }
Пример #3
0
 public DataErrorInfoContainer(DataErrorType dataErrorType, string displayMessage)
 {
     ErrorType      = dataErrorType;
     DisplayMessage = displayMessage;
 }