Пример #1
0
 public static Button CreateButton(object content,
                                   VerticalAlignment verticalAlignment     = VerticalAlignment.Center,
                                   HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center,
                                   Thickness?margin = null,
                                   object tag       = null)
 {
     return(new Button {
         Content = content,
         Margin = (margin != null) ? margin.Value : new Thickness(0),
         BorderThickness = new Thickness(0),
         VerticalContentAlignment = verticalAlignment,
         HorizontalContentAlignment = horizontalAlignment,
         Effect = ControlsFactory.CreateDropShadowEffect(),
         Tag = tag
     });
 }
        private void ParsePatientAppointmentRow(DataRow row, ref ItemPatient patient)
        {
            try {
                string group = row["GROUPS"].ToString().TrimStart(' ').TrimEnd(' ');
                string info  = row["INFO"].ToString().TrimStart(' ').TrimEnd(' ');

                if (info.Equals("0"))
                {
                    return;
                }

                string[] infoData = info.Split('@');
                if (infoData.Length == 0)
                {
                    return;
                }

                switch (group)
                {
                case "_STOP_CODE":
                    foreach (string code in infoData)
                    {
                        switch (code)
                        {
                        case "cash":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Cash);
                            break;

                        case "firsttime":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.FirstTime);
                            break;

                        case "lock":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Lock);
                            break;

                        case "late":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Late);
                            break;

                        //case "not_available_now":
                        //	patient.StopCodesCurrent.Add(ItemPatient.StopCodes.NotAvailableNow);
                        //	break;
                        case "depout":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.DepOut);
                            break;

                        case "debt":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Debt);
                            break;

                        case "sogl":
                            if (isThisASpbFilial)
                            {
                                patient.StopCodesCurrent.Add(ItemPatient.StopCode.Agreement);
                            }
                            break;

                        case "akt":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Akt);
                            break;

                        case "":
                            break;

                        default:
                            Logging.ToLog("DataHandle - Не удается распознать StopCode: " + code);
                            break;
                        }
                    }
                    break;

                case "_INFO_CODE":
                    foreach (string code in infoData)
                    {
                        switch (code)
                        {
                        case "inform_about_lk":
                            patient.InfoCodesCurrent.Add(ItemPatient.InfoCode.InformAboutLK);
                            break;

                        case "":
                            break;

                        default:
                            Logging.ToLog("DataHandle - Не удается распознать InfoCode: " + code);
                            break;
                        }
                    }
                    break;

                default:
                    if (infoData.Length != 7)
                    {
                        Logging.ToLog("DataHandle - Количество элементов в строке не равно 6: " + info);
                        break;
                    }

                    ItemAppointment itemAppointment = new ItemAppointment()
                    {
                        DateTimeScheduleBegin = infoData[0],
                        DateTimeScheduleEnd   = infoData[1],
                        DepShortName          = infoData[2],
                        DepName = ControlsFactory.FirstCharToUpper(infoData[3]),
                        DName   = infoData[4],
                        RNum    = infoData[5].Replace('№', ' '),
                        SchedID = infoData[6]
                    };

                    switch (group)
                    {
                    case "visited":
                        patient.AppointmentsVisited.Add(itemAppointment);
                        itemAppointment.AlreadyChecked = true;
                        break;

                    case "available":
                        patient.AppointmentsAvailable.Add(itemAppointment);
                        break;

                    case "not_available":
                        patient.AppointmentsNotAvailable.Add(itemAppointment);
                        break;

                    default:
                        break;
                    }

                    break;
                }
            } catch (Exception e) {
                Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
            }
        }
        public PageNotificationViewModel(NotificationType type, string replacement = "", bool returnBack = false, Exception exception = null)
        {
            CurrentNotificationType = type;
            this.returnBack         = returnBack;
            //MainWindow.ConfigurePage(this);
            TextBlockBottom.Foreground        = Properties.Settings.Default.BrushTextDisabledForeground;
            TextBlockTapToContinue.Foreground = Properties.Settings.Default.BrushTextDisabledForeground;

            string textTop    = string.Empty;
            string textBottom = string.Empty;

            ControlsFactory.ImageType imageType = ControlsFactory.ImageType.NotificationRegistry;
            string textToShow = string.Empty;

            title = Properties.Resources.title_notification;

            switch (type)
            {
            case NotificationType.Welcome:
                textToShow = Properties.Resources.notification_welcome;
                title      = Properties.Resources.title_welcome;
                MediaElementWelcomeAnimation.Visibility = Visibility.Visible;
                TextBlockAboutDeveloper.Visibility      = Visibility.Visible;
                GridImage.Visibility = Visibility.Hidden;
                KeepAlive            = true;
                isError = false;
                break;

            case NotificationType.NumberNotFound:
                textToShow = Properties.Resources.notification_nothing_found;
                imageType  = ControlsFactory.ImageType.NotificationNumberNotFound;
                break;

            case NotificationType.NoAppointmentsForNow:
                textToShow = Properties.Resources.notification_no_appointmetns_for_now;
                break;

            case NotificationType.NameNotCorrect:
                textToShow = Properties.Resources.notification_wrong_name;
                break;

            case NotificationType.FirstVisit:
                textToShow = Properties.Resources.notification_first_visit;
                break;

            case NotificationType.CardBlocked:
                textToShow = Properties.Resources.notification_need_go_to_registry;
                break;

            case NotificationType.DbError:
                textToShow = Properties.Resources.notification_db_not_available;
                title      = Properties.Resources.title_welcome;
                TextBlockAboutDeveloper.Visibility = Visibility.Visible;
                imageType = ControlsFactory.ImageType.NotificationDbError;
                TextBlockTapToContinue.Visibility = Visibility.Collapsed;
                TextBlockBottom.Margin            = new Thickness(0);
                isError = true;

                if (exception != null)
                {
                    string msg = exception.Message + Environment.NewLine + exception.StackTrace;
                    if (exception.InnerException != null)
                    {
                        msg += Environment.NewLine + Environment.NewLine + exception.InnerException.Message +
                               Environment.NewLine + exception.InnerException.StackTrace;
                    }

                    Mail.SendMail("Ошибка в работе инфомата", msg, Properties.Settings.Default.MailTo);
                }

                DispatcherTimer dispatcherTimer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromMinutes(1)
                };

                dispatcherTimer.Tick += (s, e) => {
                    try {
                        DataHandle.CheckDbAvailable();
                        PageNotification_PreviewMouseDown(null, null);
                    } catch (Exception exc) {
                        Logging.ToLog("PageNotification - " + exc.Message + Environment.NewLine + exc.StackTrace);
                    }
                };
                dispatcherTimer.Start();

                break;

            default:
                break;
            }

            ImageCenter.Source = ControlsFactory.GetImage(imageType);
            string[] splittedTextToShow = textToShow.Split(new string[] { "\r\n\r\n" }, StringSplitOptions.None);
            TextBlockTop.Text = splittedTextToShow[0].Replace("*", replacement);

            if (splittedTextToShow.Length > 1)
            {
                TextBlockBottom.Text = splittedTextToShow[1];
            }

            Loaded           += PageNotification_Loaded;
            IsVisibleChanged += PageNotification_IsVisibleChanged;
        }