Example #1
1
        private void tspControl2_DropDownClosed(object sender, RoutedEventArgs e)
        {
            TimeSpan? totalTime = tspControl2.Value;

            var alert = new RadDesktopAlert();
            alert.Header = "Triggered Alert!";
            alert.Content = $"Hello, this message will self-destruct in {totalTime.Value.Seconds} seconds.";
            alert.ShowDuration = (int)totalTime.Value.TotalMilliseconds;

            //Add Icon from Theme
            alert.Icon = new Image { Source = Application.Current.FindResource("DesktopAlertIcon") as ImageSource, Width = 48, Height = 48 };
            alert.IconColumnWidth = 75;
            alert.IconMargin = new Thickness(0, 0, 10, 10);

            RadDesktopAlertManager manager = new RadDesktopAlertManager();
            manager.ShowAlert(alert);
        }
        private void BtnStartTimer_Click(object sender, RoutedEventArgs e)
        {
            var manager = new RadDesktopAlertManager();

            manager = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter);
            manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, 5);
            manager = new RadDesktopAlertManager(AlertScreenPosition.TopRight, new Point(0, 0));
            manager = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter, new Point(0, 0), 10);
            if (TimerAmount != null && TimerAmount != 0)
            {
                Timer timer = new Timer();
                timer.StartTime = DateTime.Now;
                timer.StopTime  = DateTime.Now.AddMinutes(TimerAmount);
                timer.isDeleted = false;
                TimerRepository.Instance.Service.Add(timer);
                var alert = new RadDesktopAlert
                {
                    Header       = "Timer Started",
                    Content      = "Timer has been started on the display monitor.",
                    ShowDuration = 5000,
                };
                manager.ShowAlert(alert);
            }
            else
            {
                var alert1 = new RadDesktopAlert
                {
                    Header       = "Timer Not Started Sucessfully",
                    Content      = "Timer has not been started on the display monitor.",
                    ShowDuration = 5000,
                };
                manager.ShowAlert(alert1);
            }
            tbTime.Clear();
        }
Example #3
0
 public void ShowFailedToastNotification(string content, string header = "FAILED", int duration = 86400000)
 {
     DispatcherHelper.CheckBeginInvokeOnUI(() =>
     {
         RadDesktopAlert alert = CreateRadDesktopAlert(content, header, duration);
         alert.Background      = (SolidColorBrush)Application.Current.Resources["IconColorRed"];
         radDesktopAlertManager.ShowAlert(alert);
     });
 }
 private Boolean checksoftwareshouldrun()
 {
     try
     {
         softwaresetting softwareshouldrun = userutils.ravicosoftbusinessbookcanrun;
         if (softwareshouldrun != null)
         {
             if (softwareshouldrun.stringvalue == "no")
             {
                 RadDesktopAlertManager manager = new RadDesktopAlertManager();
                 var alert = new RadDesktopAlert();
                 alert.Header       = "Alert";
                 alert.Content      = "Software usage not allowed. Please contact Ravicosoft for info";
                 alert.ShowDuration = 5000;
                 System.Media.SystemSounds.Hand.Play();
                 manager.ShowAlert(alert);
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     catch
     {
         return(true);
     }
 }
Example #5
0
        public void ShowNotification(string header, string content)
        {
            if (_window.Dispatcher.CheckAccess())
            {
                var alert = new RadDesktopAlert();
                alert.Header       = header;
                alert.Content      = content;
                alert.ShowDuration = 3000;
                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(alert);
            }
            else
            {
                _window.Dispatcher.Invoke(() =>
                {
                    var alert                      = new RadDesktopAlert();
                    alert.Header                   = header;
                    alert.Content                  = content;
                    alert.ShowDuration             = 3000;
                    RadDesktopAlertManager manager = new RadDesktopAlertManager();

                    manager.ShowAlert(alert);
                });
            }
        }
Example #6
0
        private void GLDataForm_DeletedItem(object sender, Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
        {
            // var r = _viewModel.DeleteGL((GL));
            //// var r = _viewModel.DeleteGL((GL)e.DeletedItem);

            if (_dialogResult == true)
            {
                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = ".حذف با موفقیت انجام شد",
                    ShowDuration  = 5000,
                };
                manager.ShowAlert(alert);
            }

            //else
            //{
            //    DialogParameters parameters = new DialogParameters();
            //    parameters.OkButtonContent = "بله";
            //    parameters.Header = "اخطار";
            //    parameters.Content = ".امکان حذف وجود ندارد";
            //    // parameters.Closed = OnClosed;
            //    RadWindow.Alert(parameters);
            //}
        }
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (ImageLogo.Source != null)
            {
                String filePath = $"{Environment.CurrentDirectory}\\Image\\CompanyInformationPictur.jpg";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                var encoder = new JpegBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImageLogo.Source));
                using (FileStream stream = new FileStream(filePath, FileMode.Create))
                    encoder.Save(stream);
                companyInformationViewModel.CompanyInformationModel.Logo = filePath;
            }
            companyInformationViewModel.onSave();
            var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

            var alert = new RadDesktopAlert
            {
                FlowDirection = FlowDirection.RightToLeft,
                Header        = "اطلاعات",
                Content       = ".اطلاعات با موفقیت ثبت شد",
                ShowDuration  = 5000,
            };

            manager.ShowAlert(alert);
        }
        private void SLDataForm_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e)
        {
            var commitEditCommand = RadDataFormCommands.CommitEdit as RoutedUICommand;

            if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)
            {
                _viewModel.Save();
                commitEditCommand.Execute(null, SLDataForm);
                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = "اطلاعات با موفقیت ثبت شد",
                    ShowDuration  = 2000,
                };
                manager.ShowAlert(alert);
                //  if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)
                //  _viewModel.Save();
            }
            else if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Cancel)
            {
                _viewModel.Reject();
            }
        }
        //type
        #endregion
        #region Methods
        public void DocumentNumbering()
        {
            var order = _uow.AccDocumentHeaders.OrderBy(x => x.DocumentDate).ThenBy(x => x.DailyNumber).ToList();
            var getDocumentNumbering = _uow.Set <DocumentNumbering>().AsNoTracking().FirstOrDefault(x => x.AccountDocumentId == 1);
            var startNumber          = getDocumentNumbering.StartNumber;

            for (long i = 1; i < order.Count(); i++)
            {
                int ii = Convert.ToInt32(i);
                order[ii].DocumentNumber = startNumber;
                startNumber++;
            }
            _uow.SaveChanges();
            var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

            var alert = new RadDesktopAlert
            {
                FlowDirection = FlowDirection.RightToLeft,
                Header        = "اطلاعات",
                Content       = ".شماره گذاری با موفقیت انجام شد",
                ShowDuration  = 2000,
            };

            manager.ShowAlert(alert);
        }
Example #10
0
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateGL())
            {
                //if (_viewModel.AddGLCommand.CanExecute(null))
                //{
                //    RaiseCanExecuteChanged();
                //}
                //else
                //{
                //    RaiseNoCanExecuteChanged();

                //}
                //NavStateTrue();
                GLDataForm.CommitEdit();
                _viewModel.Save();
                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = "اطلاعات با موفقیت ثبت شد",
                    ShowDuration  = 2000,
                };
                manager.ShowAlert(alert);
            }// _viewModel.SaveCommand
        }
        private void RadButtonGuardar_Click(object sender, RoutedEventArgs e)
        {
            if (txtNombreEjecutor.Text == "")
            {
                txtNombreEjecutor.Background = Brushes.Orange;
                var alert = new RadDesktopAlert();
                alert.Header  = "NOTIFICACIÓN";
                alert.Content = "Por favor registra un nombre al ejecutor.";

                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(alert);
            }
            else
            {
                var padre = Window.GetWindow(this) as MainWindow;
                padre.radBusyIndicator.IsBusy = true;


                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork             += new DoWorkEventHandler(GuardarEjecutor);
                bw.ProgressChanged    += new ProgressChangedEventHandler(GuardarEjecutorChanged);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(GuardarEjecutorFin);

                bw.RunWorkerAsync();
            }
        }
Example #12
0
        public static Boolean initdatabase()
        {
            RadDesktopAlertManager alertmanager = new RadDesktopAlertManager();
            var r = loaddatabseconnectionfile();

            if (!r)
            {
                var alert = new RadDesktopAlert();
                alert.Header       = "Database Configuration File Error";
                alert.Content      = "Please update " + System.AppDomain.CurrentDomain.BaseDirectory + "/data/databaseconnection.json";
                alert.ShowDuration = 10000;
                System.Media.SystemSounds.Hand.Play();
                alertmanager.ShowAlert(alert);
                return(false);
            }

            var r1 = checkdatabaseserverconnection();

            if (!r1)
            {
                var alert = new RadDesktopAlert();
                alert.Header       = "Database server not running";
                alert.Content      = "Please update " + System.AppDomain.CurrentDomain.BaseDirectory + "/data/databaseconnection.json";
                alert.ShowDuration = 10000;
                System.Media.SystemSounds.Hand.Play();
                alertmanager.ShowAlert(alert);
                return(false);
            }

            var r2 = checkdatabase();

            if (!r2)
            {
                var alert = new RadDesktopAlert();
                alert.Header       = "Database " + databaseconnection.database + " does not exists.";
                alert.Content      = "Trying to create database. Please restart software";
                alert.ShowDuration = 10000;
                System.Media.SystemSounds.Hand.Play();
                alertmanager.ShowAlert(alert);
                createdatabase();
                return(false);
            }
            return(true);
        }
        public static void notify(string title, string text, int timems)
        {
            var alert = new RadDesktopAlert();

            alert.Header       = title;
            alert.Content      = text;
            alert.ShowDuration = timems;
            System.Media.SystemSounds.Hand.Play();
            manager.ShowAlert(alert);
        }
Example #14
0
        private void OnInformation(string error)
        {
            var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

            var alert = new RadDesktopAlert
            {
                FlowDirection = FlowDirection.RightToLeft,
                Header        = "اطلاعات",
                Content       = error,
                ShowDuration  = 2000,
            };

            manager.ShowAlert(alert);
        }
Example #15
0
        private void GLs_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);
                long z = 1;
                long r = 0;
                for (int i = 1; i <= SystemAccountingSettingModelGLLength; i++)
                {
                    r += z * 9;
                    z *= 10;
                }
                if (!_uow.GLs.Any())
                {
                    LastGLCode = 1;
                }
                else
                {
                    LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                if (LastGLCode == 1)
                {
                    var stringLastGLCode = LastGLCode.ToString();
                    var lastGLsCode      = stringLastGLCode.ToString().PadRight(SystemAccountingSettingModelGLLength, '0');
                    ((GL)e.NewItems[0]).GLCode = int.Parse(lastGLsCode);
                    LastGLCode++;
                    // LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                else if (LastGLCode > 1 && LastGLCode <= r)
                {
                    ((GL)e.NewItems[0]).GLCode = LastGLCode;
                    LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                else
                {
                    var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                    var alert = new RadDesktopAlert
                    {
                        FlowDirection = FlowDirection.RightToLeft,
                        Header        = "اطلاعات",
                        Content       = ".شماره گذاری حساب گروه به پایان رسیده است",
                        ShowDuration  = 1000,
                    };
                    manager.ShowAlert(alert);
                }
                GLCodeEmptyValue = LastGLCode;
            }
        }
Example #16
0
        //Перевірка події - День народження працівника
        private void BirthDayCheck()
        {
            SqlConnection conn = new SqlConnection {
                ConnectionString = connection
            };

            //Відкриваємо з'єднання
            conn.Open();

            //виведення працівника, в якого День народження
            SqlCommand query =
                new SqlCommand("SELECT Surname + ' ' + Name + ' ' + MiddleName FROM Workers WHERE DATEPART" +
                               "(d, BirthDate) = DATEPART(d, GETDATE()) AND DATEPART(m, BirthDate) = DATEPART(m, GETDATE())",
                               conn);
            //Виконання запиту
            object result = query.ExecuteScalar();

            //обичслення віку працівника
            SqlCommand queryAge = new SqlCommand("SELECT DATEDIFF(YY, [BirthDate], GETDATE()) AS [AGE] FROM Workers",
                                                 conn);
            //Виконання запиту
            object age = queryAge.ExecuteScalar();

            //якщо сьогодні немає іменин у працівників
            if (query.ExecuteScalar() == null)
            {
                //Показ повідомлення
                var nonbirthdayAlert = new RadDesktopAlert();
                nonbirthdayAlert.Header       = "Повідомлення";
                nonbirthdayAlert.Content      = "Днів народжень у працівників сьогодні немає.";
                nonbirthdayAlert.ShowDuration = 10000;

                RadDesktopAlertManager manager2 = new RadDesktopAlertManager();
                manager2.ShowAlert(nonbirthdayAlert);
            }
            //якщо у працівника є день народження
            else if (query.ExecuteScalar() != null && queryAge.ExecuteScalar() != null)
            {
                //Показ повідомлення
                var birthdayAlert = new RadDesktopAlert();
                birthdayAlert.Header  = "День народження!";
                birthdayAlert.Content = "Працівник " + result + " сьогодні святкує свій День народження!" + " (" + age +
                                        " років)";
                birthdayAlert.ShowDuration = 10000;

                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(birthdayAlert);
            }
        }
        public void btnClickMe(object sender, RoutedEventArgs e)
        {
            var alert = new RadDesktopAlert();
            alert.Header = "NEW EMAIL";
            alert.Content = "Hello, Here are the resources to the Q2 DevTools Webinar.";
            alert.ShowDuration = 5000;

            //Add Icon from Theme
            alert.Icon = new Image { Source = Application.Current.FindResource("DesktopAlertIcon") as ImageSource, Width = 48, Height = 48 };
            alert.IconColumnWidth = 75;
            alert.IconMargin = new Thickness(0, 0, 10, 10);

            RadDesktopAlertManager manager = new RadDesktopAlertManager();
            manager.ShowAlert(alert);
        }
        private void SLDataForm_DeletedItem(object sender, Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
        {
            if (_dialogResult == true)
            {
                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = ".حذف با موفقیت انجام شد",
                    ShowDuration  = 5000,
                };
                manager.ShowAlert(alert);
            }
        }
Example #19
0
 public static void authorizerole(Window window, string[] roles)
 {
     if (roles.Contains(loggedinuserd.role))
     {
         window.Show();
     }
     else
     {
         RadDesktopAlertManager manager = new RadDesktopAlertManager();
         var alert = new RadDesktopAlert();
         alert.Header       = "Alert";
         alert.Content      = "This page can only accessed by " + String.Join(",", roles);
         alert.ShowDuration = 5000;
         System.Media.SystemSounds.Hand.Play();
         manager.ShowAlert(alert);
     }
 }
Example #20
0
        //Перевірка події - закінчення випр. терміну
        private void TermCheck()
        {
            SqlConnection conn = new SqlConnection {
                ConnectionString = connection
            };

            //Відкриваємо з'єднання
            conn.Open();
            //запит, який виводить працівників, в яких завершується випробовувальний термін
            SqlCommand queryProbationExpiry =
                new SqlCommand(
                    "SELECT ' (' + CONVERT(VARCHAR(10),con.Probation) + ') в працівника '+ wk.Surname + ' ' + wk.Name + ' ' + wk.MiddleName " +
                    "FROM  Workers wk join Contract con on con.ID=wk.ID " +
                    "WHERE DATEPART( Week, DATEADD( Year, DATEPART( Year, GETDATE()) - " +
                    "DATEPART( Year, con.Probation), con.Probation))= DATEPART( Week, GETDATE());", conn);

            //Виконання запиту
            object resultExpiry = queryProbationExpiry.ExecuteScalar();

            //якщо цього тижня в жодного з працівників не закінчується випробовувальний термін
            if (queryProbationExpiry.ExecuteScalar() == null)
            {
                //Показ повідомлення
                var nonbirthdayAlert = new RadDesktopAlert();
                nonbirthdayAlert.Header  = "Повідомлення";
                nonbirthdayAlert.Content =
                    "Протягом цього тижня випробовувальний термін не закінчується в жодного з працівників";
                nonbirthdayAlert.ShowDuration = 10000;

                RadDesktopAlertManager manager2 = new RadDesktopAlertManager();
                manager2.ShowAlert(nonbirthdayAlert);
            }
            //якщо у працівника найближчим часом завершується випробовувальний термін
            else if (queryProbationExpiry.ExecuteScalar() != null)
            {
                //Показ повідомлення
                var birthdayAlert = new RadDesktopAlert();
                birthdayAlert.Header  = "Завершення випробовувального терміну!";
                birthdayAlert.Content = "Протягом цього тижня " + resultExpiry +
                                        " завершується випробовувальний термін!";
                birthdayAlert.ShowDuration = 10000;

                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(birthdayAlert);
            }
        }
Example #21
0
        private async void OnOpenDevice(object obj)
        {
            if (!IsOpen)
            {
                var result = await _hcdzClient.DeviceOpen(0);

                if (result)
                {
                    BtnIsEnabled   = true;
                    OpenDeviceText = "关闭设备";
                    IsOpen         = true;
                    DeviceDesc     = await _hcdzClient.InitDeviceInfo(0);
                }
                else
                {
                    RadDesktopAlertManager desktop = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter);

                    desktop.ShowAlert(new RadDesktopAlert()
                    {
                        Content = "设备连接失败!"
                    });
                }
            }
            else
            {
                var flag = await _hcdzClient.DeviceClose(0);

                if (flag)
                {
                    OpenDeviceText = "连接设备";
                    IsOpen         = false;
                    DeviceDesc     = string.Empty;
                }
                else
                {
                    RadDesktopAlertManager desktop = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter);

                    desktop.ShowAlert(new RadDesktopAlert()
                    {
                        Content = "设备断开失败!"
                    });
                }
                CloseDMAChannel();
            }
        }
        private void StcDocumentHeaderDataForm_DeletedItem(object sender, Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
        {
            var r = _viewModel.DeleteDocumentHeader((StcDocumentHeader)e.DeletedItem);

            if (r > 0)
            {
                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = ".حذف با موفقیت انجام شد",
                    ShowDuration  = 5000,
                };
                manager.ShowAlert(alert);
            }
        }
        private void PermanentButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateDocumetHeader())
            {
                //  StcDocumentHeader.Status = StatusEnum.Permanent;
                CommitAndBeginEdit();
                RaiseCanExecuteChanged();

                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = ".صند قطعی شد",
                    ShowDuration  = 2000,
                };
                manager.ShowAlert(alert);
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateProductModel())
            {
                RaiseCanExecuteChanged();
                NavStateTrue();
                CommitAndBeginEdit();

                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = "اطلاعات با موفقیت ثبت شد",
                    ShowDuration  = 2000,
                };
                manager.ShowAlert(alert);
            }// _viewModel.SaveCommand
        }
        private void BackFromEndButton_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateDocumetHeader())
            {
                //  StcDocumentHeader.Status = StatusEnum.Temporary;
                CommitAndBeginEdit();
                isModified = true;
                RaiseCanExecuteChanged();

                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                var alert = new RadDesktopAlert
                {
                    FlowDirection = FlowDirection.RightToLeft,
                    Header        = "اطلاعات",
                    Content       = ". برگشت از خاتمه انجام شد",
                    ShowDuration  = 2000,
                };
                manager.ShowAlert(alert);
            }
        }
Example #26
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (_accessUtility.HasAccess(66))
            {
                ObservableCollection <object> tLDocHeaders = RadGridView1.SelectedItems;
                if (tLDocHeaders.Count > 0)
                {
                    Deleting();
                    if (_dialogResult == true)
                    {
                        var list = RadGridView1.SelectedItems;
                        _viewModel.DeleteTLDocumentHeader((tLDocHeaders));
                        _viewModel.LoadTLDocumentHeaders();
                        var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                        var alert = new RadDesktopAlert
                        {
                            FlowDirection = FlowDirection.RightToLeft,
                            Header        = "اطلاعات",
                            Content       = ".حذف با موفقیت انجام شد",
                            ShowDuration  = 1200,
                        };
                        manager.ShowAlert(alert);
                    }
                    else
                    {
                        var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter);

                        var alert = new RadDesktopAlert
                        {
                            FlowDirection = FlowDirection.RightToLeft,
                            Header        = "اطلاعات",
                            Content       = "سند برای حذف وجود ندارد.",
                            ShowDuration  = 1200,
                        };
                        manager.ShowAlert(alert);
                    }
                }
            }
        }
        public static async void changeaccount(dynamic obj)
        {
            try
            {
                softwaresettingrepo ssr = new softwaresettingrepo();
                var ravicosoftuser      = ssr.getbyname(commonsettingfields.ravicosoftuserid);
                if (ravicosoftuser == null)
                {
                    return;
                }
                var apiendpoint = apiendpointdefault;
                if (userutils.apiendpoint != null)
                {
                    apiendpoint = userutils.apiendpoint.stringvalue;
                }
                RestClient client  = new RestClient(apiendpoint);
                var        request = new RestRequest("changeaccount");
                obj.userid = ravicosoftuser.stringvalue;
                request.AddJsonBody(obj);
                var response = await client.PostAsync <apiresponsetype>(request);

                if (response.status == "success")
                {
                    var user = Newtonsoft.Json.JsonConvert.DeserializeObject <apiresponseuserclass>(response.data);
                    userutils.updateusersetting(user);
                    RadDesktopAlertManager manager = new RadDesktopAlertManager();
                    var alert = new RadDesktopAlert();
                    alert.Header       = "Information";
                    alert.Content      = "User account changed. Please restart software to apply update";
                    alert.ShowDuration = 5000;
                    System.Media.SystemSounds.Hand.Play();
                    manager.ShowAlert(alert);
                }
            }
            catch (Exception ex)
            {
            }
        }
        private Boolean checksystemdate()
        {
            RadDesktopAlertManager manager = new RadDesktopAlertManager();
            var currentdate   = DateTime.Now;
            var lastsaveddate = Settings.Default.lastsavedate;

            if (currentdate < lastsaveddate)
            {
                var alert = new RadDesktopAlert();
                alert.Header       = "Business Book Alert";
                alert.Content      = "Please correct your system date first";
                alert.ShowDuration = 30000;
                System.Media.SystemSounds.Hand.Play();
                manager.ShowAlert(alert);
                return(false);
            }
            else
            {
                Settings.Default.lastsavedate = DateTime.Now;
                Settings.Default.Save();
                return(true);
            }
        }
Example #29
0
        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Datos     datos       = new DAL.Datos();
                DataTable dt          = datos.ObtenerAñosPOM(Convert.ToDecimal(lblPOM.Content)).Tables[0];
                decimal   FechaInicio = 0;
                decimal   FechaFin    = 0;
                string    sNombre     = "";

                foreach (DataRow row in dt.Rows)
                {
                    sNombre     = row["Nombre"].ToString();
                    FechaInicio = Convert.ToDecimal(row["Fecha_Inicio"]);
                    FechaFin    = Convert.ToDecimal(row["Fecha_Fin"]);
                }


                IList lista = lstScripts.SelectedItems;



                //INSERTA SI NO EXISTE EJECUTOR CALENDARIZADO
                DataTable dtEjecutor = datos.VerificaEjecutorCalendarizado(Convert.ToDecimal(lblTitulo.Content), sNombre).Tables[0];
                if (dtEjecutor.Rows.Count != 0)
                {
                    //ACTUALIZA EJECUTOR
                    foreach (ListBoxItem item in lstScripts.SelectedItems)
                    {
                        var valor = item.Content.ToString();

                        if (valor == "Script 1")
                        {
                            datos.CalendarizarEjecutor1(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 2")
                        {
                            datos.CalendarizarEjecutor2(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 3")
                        {
                            datos.CalendarizarEjecutor3(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 4")
                        {
                            datos.CalendarizarEjecutor4(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 5")
                        {
                            datos.CalendarizarEjecutor5(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 6")
                        {
                            datos.CalendarizarEjecutor6(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 7")
                        {
                            datos.CalendarizarEjecutor7(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 8")
                        {
                            datos.CalendarizarEjecutor8(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 9")
                        {
                            datos.CalendarizarEjecutor9(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 10")
                        {
                            datos.CalendarizarEjecutor10(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 11")
                        {
                            datos.CalendarizarEjecutor11(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 12")
                        {
                            datos.CalendarizarEjecutor12(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 13")
                        {
                            datos.CalendarizarEjecutor13(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 14")
                        {
                            datos.CalendarizarEjecutor14(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 15")
                        {
                            datos.CalendarizarEjecutor15(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 16")
                        {
                            datos.CalendarizarEjecutor16(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 17")
                        {
                            datos.CalendarizarEjecutor17(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }

                        if (valor == "Politicas de pago")
                        {
                            //Politicas de Pago
                            datos.CalendarizarPolitica180(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica120(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica90(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica60(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica45(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica2030(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }

                        if (valor == "Script 18")
                        {
                            datos.CalendarizarEjecutor18(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 19")
                        {
                            datos.CalendarizarEjecutor19(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 20")
                        {
                            datos.CalendarizarEjecutor20(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 21")
                        {
                            datos.CalendarizarEjecutor21(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 22")
                        {
                            datos.CalendarizarEjecutor22(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 23")
                        {
                            datos.CalendarizarEjecutor23(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 24")
                        {
                            datos.CalendarizarEjecutor24(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 25")
                        {
                            datos.CalendarizarEjecutor25(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 26")
                        {
                            datos.CalendarizarEjecutor26(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                    }
                }
                else
                {
                    //INSERTA EJECUTOR
                    datos.CalendarizarEjecutor(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);

                    foreach (ListBoxItem item in lstScripts.SelectedItems)
                    {
                        var valor = item.Content.ToString();

                        if (valor == "Script 1")
                        {
                            datos.CalendarizarEjecutor1(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 2")
                        {
                            datos.CalendarizarEjecutor2(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 3")
                        {
                            datos.CalendarizarEjecutor3(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 4")
                        {
                            datos.CalendarizarEjecutor4(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 5")
                        {
                            datos.CalendarizarEjecutor5(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 6")
                        {
                            datos.CalendarizarEjecutor6(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 7")
                        {
                            datos.CalendarizarEjecutor7(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 8")
                        {
                            datos.CalendarizarEjecutor8(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 9")
                        {
                            datos.CalendarizarEjecutor9(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 10")
                        {
                            datos.CalendarizarEjecutor10(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 11")
                        {
                            datos.CalendarizarEjecutor11(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 12")
                        {
                            datos.CalendarizarEjecutor12(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 13")
                        {
                            datos.CalendarizarEjecutor13(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 14")
                        {
                            datos.CalendarizarEjecutor14(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 15")
                        {
                            datos.CalendarizarEjecutor15(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 16")
                        {
                            datos.CalendarizarEjecutor16(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 17")
                        {
                            datos.CalendarizarEjecutor17(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }

                        if (valor == "Politicas de pago")
                        {
                            //Politicas de Pago
                            datos.CalendarizarPolitica180(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica120(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica90(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica60(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica45(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                            datos.CalendarizarPolitica2030(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }

                        if (valor == "Script 18")
                        {
                            datos.CalendarizarEjecutor18(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 19")
                        {
                            datos.CalendarizarEjecutor19(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 20")
                        {
                            datos.CalendarizarEjecutor20(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 21")
                        {
                            datos.CalendarizarEjecutor21(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 22")
                        {
                            datos.CalendarizarEjecutor22(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 23")
                        {
                            datos.CalendarizarEjecutor23(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 24")
                        {
                            datos.CalendarizarEjecutor24(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 25")
                        {
                            datos.CalendarizarEjecutor25(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                        if (valor == "Script 26")
                        {
                            datos.CalendarizarEjecutor26(Convert.ToDecimal(lblTitulo.Content), Convert.ToDecimal(lblPOM.Content), FechaInicio, FechaFin, sNombre);
                        }
                    }
                }


                this.Close();
                var alert = new RadDesktopAlert();
                alert.Header  = "NOTIFICACIÓN";
                alert.Content = "El Ejecutor se calendarizó.";
                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(alert);
            }
            catch (Exception ex)
            {
                var alert = new RadDesktopAlert();
                alert.Header  = "NOTIFICACIÓN";
                alert.Content = ex.Message;
                RadDesktopAlertManager manager = new RadDesktopAlertManager();
                manager.ShowAlert(alert);
            }
        }
        private async void ScanForUpdates()
        {
            var alertManager = new RadDesktopAlertManager();

            var changesSince = GreatestDateTime((DateTime.Now - TimeSpan.FromHours(24)), _reportsSettings.LastUpdatesScan);
            var projectKeys = _reportsSettings.SelectedProjectsList.Split(',').Select(p => p.Trim());
            try
            {
                var query = string.Format("updated >= '{0}'", changesSince.ToString("yyyy-MM-dd HH:mm"));
                if (projectKeys.Any())
                    query += string.Format(" AND project IN ({0})", string.Join(",", projectKeys));

                var updatedIssues = await _jiraApi.SearchForIssues(query);
                foreach (var issue in updatedIssues.Where(i => i.BuiltInFields.Updated >= _reportsSettings.LastUpdatesScan))
                {
                    var openIssueCommand = new RelayCommand(() =>
                    {
                        var i = issue;
                        Process.Start(string.Format("{0}/browse/{1}", _jiraApi.Server.ServerUri, i.Key));
                    });

                    if (issue.Created >= changesSince && _reportsSettings.ShowCreatedIssues)
                    {
                        if (_reportsSettings.SkipOwnChanges && issue.BuiltInFields.Reporter.Name == _jiraSession.Profile.Name)
                            continue;

                        alertManager.ShowAlert(new RadDesktopAlert
                        {
                            Header = string.Format("New issue: {0}", issue.Key),
                            Content = issue.Summary,
                            ShowDuration = 5000,
                            Icon = new Image { Source = GetImageFromResources("/Assets/Avatars/PlusSign.png"), Width = 48, Height = 48 },
                            IconColumnWidth = 48,
                            Command = openIssueCommand
                        });
                    }
                    else if (issue.Created < changesSince && _reportsSettings.ShowUpdatedIssues)
                    {
                        var changes = issue.Changelog.Where(ch => ch.Created >= changesSince
                                                                && !(_reportsSettings.SkipOwnChanges
                                                                && ch.Author.Name == _jiraSession.Profile.Name));

                        changes = changes.Concat(issue.BuiltInFields.Comments.Comments.Where(c => c.Updated >= changesSince
                                                                && !(_reportsSettings.SkipOwnChanges
                                                                && c.UpdateAuthor.Name == _jiraSession.Profile.Name))
                                                                .Select(c => new RawChangesHistory
                                                                {
                                                                    Author = c.UpdateAuthor,
                                                                    Created = c.Updated,
                                                                    Items = new[]
                                                                    {
                                                                        new RawChangelogItem
                                                                        {
                                                                            Field = "Comment",
                                                                            Fieldtype = "string",
                                                                            From = "",
                                                                            FromString = "",
                                                                            To = c.Body,
                                                                            toString = c.Body
                                                                        }
                                                                    }
                                                                }));

                        if (changes.Any() == false)
                            continue;

                        _messenger.Send(new IssueUpdatedMessage(issue, changes.SelectMany(c => c.Items), changes.First().Created, changes.First().Author));

                        var rawChangeSummary = new Dictionary<string, string>();

                        foreach (var change in changes)
                        {
                            foreach (var item in change.Items)
                            {
                                rawChangeSummary[item.Field] = item.toString;
                            }
                        }

                        var changeSummaryBuilder = new StringBuilder();
                        foreach (var changeSummary in rawChangeSummary)
                        {
                            var newValue = changeSummary.Value ?? "(None)";
                            changeSummaryBuilder.AppendFormat("{0}: {1}\n", changeSummary.Key, newValue);
                        }

                        alertManager.ShowAlert(new RadDesktopAlert
                        {
                            Header = string.Format("[{0}] {1}", issue.Key, issue.Summary),
                            Content = changeSummaryBuilder.ToString(),
                            ShowDuration = 5000,
                            Icon = new Image { Source = GetImageFromResources("/Assets/Avatars/EditSign.png"), Width = 48, Height = 48 },
                            IconColumnWidth = 48,
                            Command = openIssueCommand
                        });
                    }
                }
                _reportsSettings.LastUpdatesScan = DateTime.Now;
            }
            catch (SearchFailedException e)
            {
                _logger.Log(LogLevel.Warn, "Failed to retrieve updated issues.", e);
                alertManager.ShowAlert(new RadDesktopAlert
                {
                    Header = "Invalid configuration",
                    Content = "Please verify that you provided correct list of project keys",
                    ShowDuration = 2000
                });
            }
        }
Example #31
0
        private void ContextMenuClick(object sender, RoutedEventArgs e)
        {
            //GL gl = ClickedTreeViewItem.DataContext as GL;
            //TL tl = ClickedTreeViewItem.DataContext as TL;
            var SystemAccountingSettingModel = _systemAccountingSettingsService.GetSystemAccountingSettingModel();

            int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);

            // var SystemAccountingSettingModelGLLength = int.Parse(SystemAccountingSettingModel.GLLength);
            long   lastGLCode   = _gLsService.GetLastGLCode() + 1;
            var    lastGLLenght = (lastGLCode.ToString()).Length;
            string tag          = (e.OriginalSource as RadMenuItem).Tag as string;

            if (ClickedTreeViewItem == null)
            {
                if (lastGLLenght == SystemAccountingSettingModelGLLength)
                {
                    AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                    var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                    //   treeGL.GL = gl;
                    treeGL.SaveClicked += (g) =>
                    {
                        //addTLTreeItemWindow0.DataItem.GL = gl;
                        g.ImageUrl = "../../Resources/cian.png";
                        _vm.AddGL(g);
                        g.GLId = _vm.GetGLId(g.GLCode);
                        _vm.Items.Add(g);
                        //_vm.Save();
                        addGLTreeItemWindow0.Close();
                        // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                        //     gl.IsExpanded = true; // Ensure that the new child is visible
                        //using (var uow = new SainaDbContext())
                        //{
                        //    uow.GLs.Add(g);
                        //    uow.SaveChanges();
                        //    addGLTreeItemWindow0.Close();
                        //}
                    };
                    addGLTreeItemWindow0.Width    = 1000;
                    addGLTreeItemWindow0.Height   = 500;
                    addGLTreeItemWindow0.CanClose = true;
                    addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                    addGLTreeItemWindow0.Show();
                }
                else
                {
                    DialogParameters parameters = new DialogParameters();
                    parameters.OkButtonContent = "بستن";
                    parameters.Header          = "اخطار";
                    parameters.Content         = " شماره گذاری این حساب  به پایان رسیده است";
                    RadWindow.Alert(parameters);
                }
            }
            else if (ClickedTreeViewItem.DataContext is GL gl)
            {
                if (tag == "newGL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        if (lastGLLenght == SystemAccountingSettingModelGLLength)
                        {
                            AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                            var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                            //   treeGL.GL = gl;
                            treeGL.SaveClicked += (g) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                g.ImageUrl = "../../Resources/cian.png";
                                _vm.AddGL(g);
                                g.GLId = _vm.GetGLId(g.GLCode);
                                _vm.Items.Add(g);
                                //_vm.Save();
                                addGLTreeItemWindow0.Close();
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                gl.IsExpanded = true; // Ensure that the new child is visible
                                                      //using (var uow = new SainaDbContext())
                                                      //{
                                                      //    uow.GLs.Add(g);
                                                      //    uow.SaveChanges();
                                                      //    addGLTreeItemWindow0.Close();
                                                      //}
                            };
                            addGLTreeItemWindow0.Width    = 1000;
                            addGLTreeItemWindow0.Height   = 500;
                            addGLTreeItemWindow0.CanClose = true;
                            addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                            addGLTreeItemWindow0.Show();
                        }

                        else
                        {
                            DialogParameters parameters = new DialogParameters();
                            parameters.OkButtonContent = "بستن";
                            parameters.Header          = "اخطار";
                            parameters.Content         = " شماره گذاری این حساب  به پایان رسیده است";
                            RadWindow.Alert(parameters);
                        }
                    }
                    // break;
                }
                else if (tag == "newTL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;

                        treeTL.TL           = new TL();
                        treeTL.TL.GLId      = gl.GLId;
                        treeTL.TL.GL        = gl;
                        treeTL.SaveClicked += (t) =>
                        {
                            //addTLTreeItemWindow0.DataItem.GL = gl;
                            //t.GLId = gl.GLId;
                            t.ImageUrl = "../../Resources/cian.png";
                            _vm.AddTL(t);
                            t.GLId = _vm.GetTLId(t.TLCode);
                            gl.TLs.Add(t);
                            //_vm.Save();
                            addTLTreeItemWindow0.Close();
                            gl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.TLs.Add(t);
                                                  //    //uow.Entry(gl).State = EntityState.Modified;
                                                  //    var vv = uow.SaveChanges();
                                                  //    addTLTreeItemWindow0.Close();
                                                  //}
                        };
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                        var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                        treeGL.GL = gl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasGL = uow.GLs.FirstOrDefault(x => x.GLId == gl.GLId)?.TLs?.Any() == true;
                            if (hasGL == true)
                            {
                                addGLTreeItemWindow0.gLCodeTextbox.IsEnabled = false;
                            }
                            treeGL.SaveClicked += (g) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                g.GLId     = gl.GLId;
                                g.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                gl.IsExpanded = true; // Ensure that the new child is visible
                                                      // _vm.Save();

                                uow.GLs.Attach(g);
                                uow.Entry <GL>(g).State = EntityState.Modified;
                                //  uow.GLs(g);
                                var x = uow.SaveChanges();
                                addGLTreeItemWindow0.Close();
                            };
                        }
                        addGLTreeItemWindow0.Width    = 1000;
                        addGLTreeItemWindow0.Height   = 500;
                        addGLTreeItemWindow0.CanClose = true;
                        addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addGLTreeItemWindow0.Show();
                    }
                    // break;
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasGL = uow.GLs.FirstOrDefault(x => x.GLId == gl.GLId)?.TLs?.Any() == true;

                            if (hasGL == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                var test = uow.GLs.ToList().Select(x => x.GLId);
                                _vm.Items.Remove(gl);
                                uow.Database.ExecuteSqlCommand($"Delete Info.GLs where  GLId={gl.GLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
            else if (ClickedTreeViewItem.DataContext is TL tl)
            {
                if (tag == "newTL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        gl = tl.GL;
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;
                        treeTL.TL      = new TL();
                        treeTL.TL.GLId = gl.GLId;
                        treeTL.TL.GL   = gl;
                        //treeTL.SelectedGL = gl;
                        //treeTL.TL = new TL { GL = gl, GLId = gl.GLId };
                        treeTL.SaveClicked += (t) =>
                        {
                            //   t.GLId = gl.GLId;
                            t.ImageUrl = "../../Resources/cian.png";
                            _vm.AddTL(t);
                            t.GLId = _vm.GetTLId(t.TLCode);
                            gl.TLs.Add(t);
                            addTLTreeItemWindow0.Close();

                            gl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.TLs.Add(t);
                                                  //   // uow.Entry(gl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addTLTreeItemWindow0.Close();
                            //}
                        };
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "newSL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL      = new SL();
                        treeSL.SL.TLId = tl.TLId;
                        treeSL.SL.TL   = tl;
                        //treeSL.SelectedTL = tl;
                        //treeSL.SL = new SL { TL = tl, TLId = tl.TLId };
                        treeSL.SaveClicked += (s) =>
                        {
                            //addTLTreeItemWindow0.DataItem.GL = gl;
                            // s.TLId = tl.TLId;
                            s.ImageUrl = "../../Resources/cian.png";
                            _vm.AddSL(s);
                            s.TLId = _vm.GetSLId(s.SLCode);

                            tl.SLs.Add(s);
                            // _vm.Save();
                            addSLTreeItemWindow0.Close();
                            tl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.SLs.Add(s);
                                                  //    uow.Entry(tl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addSLTreeItemWindow0.Close();
                            //}
                        };
                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;
                        treeTL.TL = tl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasTL = uow.TLs.FirstOrDefault(x => x.TLId == tl.TLId)?.SLs?.Any() == true;
                            if (hasTL == true)
                            {
                                addTLTreeItemWindow0.tLCodeTextbox.IsEnabled = false;
                            }
                            treeTL.SaveClicked += (t) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                t.TLId     = tl.TLId;
                                t.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                tl.IsExpanded = true; // Ensure that the new child is visible

                                uow.TLs.Attach(t);
                                uow.Entry <TL>(t).State = EntityState.Modified;
                                //  uow.GLs(g);
                                //  uow.GLs(g);
                                uow.SaveChanges();
                                addTLTreeItemWindow0.Close();
                            };
                        }
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasTL = uow.TLs.FirstOrDefault(x => x.TLId == tl.TLId)?.SLs?.Any() == true;

                            if (hasTL == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                //   var test = uow.TLs.ToList().Select(x => x.TLId);
                                foreach (var item in _vm.Items)
                                {
                                    item.TLs.Remove(tl);
                                }
                                uow.Database.ExecuteSqlCommand($"Delete Info.TLs where  TLId={tl.TLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
            else if (ClickedTreeViewItem.DataContext is SL)
            {
                SL sl = ClickedTreeViewItem.DataContext as SL;

                if (tag == "newSL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();

                        tl = sl.TL;
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL           = new SL();
                        treeSL.SL.TLId      = tl.TLId;
                        treeSL.SL.TL        = tl;
                        treeSL.SaveClicked += (s) =>
                        {
                            s.TLId     = tl.TLId;
                            s.ImageUrl = "../../Resources/cian.png";
                            tl.SLs.Add(s);
                            _vm.AddSL(s);
                            // _vm.Save();
                            addSLTreeItemWindow0.Close();

                            tl.IsExpanded = true;     // Ensure that the new child is visible
                                                      //using (var uow = new SainaDbContext())
                                                      //{
                                                      //    uow.SLs.Add(s);
                            ////    uow.Entry(tl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addSLTreeItemWindow0.Close();
                            //}
                        };


                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL = sl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasItem = uow.AccDocumentItems.Any(x => x.SLId == sl.SLId);
                            if (hasItem == true)
                            {
                                addSLTreeItemWindow0.sLCodeTextbox.IsEnabled = false;
                                addSLTreeItemWindow0.DL1.IsEnabled           = false;
                                addSLTreeItemWindow0.DL2.IsEnabled           = false;
                            }
                            treeSL.SaveClicked += (s) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                s.SLId     = sl.SLId;
                                s.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                sl.IsExpanded = true; // Ensure that the new child is visible

                                uow.SLs.Attach(s);
                                uow.Entry <SL>(s).State = EntityState.Modified;
                                //  uow.GLs(g);
                                uow.SaveChanges();
                                addSLTreeItemWindow0.Close();
                            };
                        }
                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasItem = uow.AccDocumentItems.Any(x => x.SLId == sl.SLId);


                            if (hasItem == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                //   var test = uow.TLs.ToList().Select(x => x.TLId);
                                foreach (var item in _vm.Items)
                                {
                                    foreach (var x in item.TLs)
                                    {
                                        if (x.SLs.Remove(sl))
                                        {
                                            break;
                                        }
                                    }
                                }
                                uow.Database.ExecuteSqlCommand($"Delete Info.SLs where  SLId={sl.SLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
        }
        public void importa()
        {
            try
            {
                OpenFileDialog openfile = new OpenFileDialog();
                openfile.DefaultExt = ".xlsx";
                openfile.Filter     = "(.xlsx)|*.xlsx";
                //openfile.ShowDialog();

                var browsefile = openfile.ShowDialog();

                if (browsefile == true)
                {
                    txtFilePath.Text = openfile.FileName;

                    Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
                    //Static File From Base Path...........
                    //Microsoft.Office.Interop.Excel.Workbook excelBook = excelApp.Workbooks.Open(AppDomain.CurrentDomain.BaseDirectory + "TestExcel.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    //Dynamic File Using Uploader...........
                    Microsoft.Office.Interop.Excel.Workbook  excelBook  = excelApp.Workbooks.Open(txtFilePath.Text.ToString(), 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                    Microsoft.Office.Interop.Excel.Worksheet excelSheet = (Microsoft.Office.Interop.Excel.Worksheet)excelBook.Worksheets.get_Item(1);;
                    Microsoft.Office.Interop.Excel.Range     excelRange = excelSheet.UsedRange;

                    string strCellData = "";
                    double douCellData;
                    int    rowCnt = 0;
                    int    colCnt = 0;

                    DataTable dt = new DataTable();
                    for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
                    {
                        string strColumn = "";
                        strColumn = (string)(excelRange.Cells[1, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                        dt.Columns.Add(strColumn, typeof(string));
                    }

                    for (rowCnt = 2; rowCnt <= excelRange.Rows.Count; rowCnt++)
                    {
                        string strData = "";
                        for (colCnt = 1; colCnt <= excelRange.Columns.Count; colCnt++)
                        {
                            try
                            {
                                strCellData = (string)(excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                                strData    += strCellData + "|";
                            }
                            catch (Exception ex)
                            {
                                douCellData = (excelRange.Cells[rowCnt, colCnt] as Microsoft.Office.Interop.Excel.Range).Value2;
                                strData    += douCellData.ToString() + "|";
                            }
                        }
                        strData = strData.Remove(strData.Length - 1, 1);
                        dt.Rows.Add(strData.Split('|'));
                    }

                    gvData.ItemsSource = dt;

                    excelBook.Close(true, null, null);
                    excelApp.Quit();

                    var alert = new RadDesktopAlert();
                    alert.Header       = "NOTIFICACIÓN";
                    alert.Content      = "El archivo se cargó exitosamente.";
                    alert.ShowDuration = 3000;
                    RadDesktopAlertManager manager = new RadDesktopAlertManager();
                    manager.ShowAlert(alert);
                }
                else
                {
                    btGuardar.Visibility  = Visibility.Hidden;
                    btCancelar.Visibility = Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
        private async void ScanForUpdates()
        {
            var alertManager = new RadDesktopAlertManager();

            var changesSince = GreatestDateTime((DateTime.Now - TimeSpan.FromHours(24)), _reportsSettings.LastUpdatesScan);
            var projectKeys  = _reportsSettings.SelectedProjectsList.Split(',').Select(p => p.Trim());

            try
            {
                var query = string.Format("updated >= '{0}'", changesSince.ToString("yyyy-MM-dd HH:mm"));
                if (projectKeys.Any())
                {
                    query += string.Format(" AND project IN ({0})", string.Join(",", projectKeys));
                }

                var updatedIssues = await _jiraApi.SearchForIssues(query);

                foreach (var issue in updatedIssues.Where(i => i.BuiltInFields.Updated >= _reportsSettings.LastUpdatesScan))
                {
                    var openIssueCommand = new RelayCommand(() =>
                    {
                        var i = issue;
                        Process.Start(string.Format("{0}/browse/{1}", _jiraApi.Server.ServerUri, i.Key));
                    });

                    if (issue.Created >= changesSince && _reportsSettings.ShowCreatedIssues)
                    {
                        if (_reportsSettings.SkipOwnChanges && issue.BuiltInFields.Reporter.Name == _jiraSession.Profile.Name)
                        {
                            continue;
                        }

                        alertManager.ShowAlert(new RadDesktopAlert
                        {
                            Header       = string.Format("New issue: {0}", issue.Key),
                            Content      = issue.Summary,
                            ShowDuration = 5000,
                            Icon         = new Image {
                                Source = GetImageFromResources("/Assets/Avatars/PlusSign.png"), Width = 48, Height = 48
                            },
                            IconColumnWidth = 48,
                            Command         = openIssueCommand
                        });
                    }
                    else if (issue.Created < changesSince && _reportsSettings.ShowUpdatedIssues)
                    {
                        var changes = issue.Changelog.Where(ch => ch.Created >= changesSince &&
                                                            !(_reportsSettings.SkipOwnChanges &&
                                                              ch.Author.Name == _jiraSession.Profile.Name));

                        changes = changes.Concat(issue.BuiltInFields.Comments.Comments.Where(c => c.Updated >= changesSince &&
                                                                                             !(_reportsSettings.SkipOwnChanges &&
                                                                                               c.UpdateAuthor.Name == _jiraSession.Profile.Name))
                                                 .Select(c => new RawChangesHistory
                        {
                            Author  = c.UpdateAuthor,
                            Created = c.Updated,
                            Items   = new[]
                            {
                                new RawChangelogItem
                                {
                                    Field      = "Comment",
                                    Fieldtype  = "string",
                                    From       = "",
                                    FromString = "",
                                    To         = c.Body,
                                    toString   = c.Body
                                }
                            }
                        }));

                        if (changes.Any() == false)
                        {
                            continue;
                        }

                        _messenger.Send(new IssueUpdatedMessage(issue, changes.SelectMany(c => c.Items), changes.First().Created, changes.First().Author));

                        var rawChangeSummary = new Dictionary <string, string>();

                        foreach (var change in changes)
                        {
                            foreach (var item in change.Items)
                            {
                                rawChangeSummary[item.Field] = item.toString;
                            }
                        }

                        var changeSummaryBuilder = new StringBuilder();
                        foreach (var changeSummary in rawChangeSummary)
                        {
                            var newValue = changeSummary.Value ?? "(None)";
                            changeSummaryBuilder.AppendFormat("{0}: {1}\n", changeSummary.Key, newValue);
                        }

                        alertManager.ShowAlert(new RadDesktopAlert
                        {
                            Header       = string.Format("[{0}] {1}", issue.Key, issue.Summary),
                            Content      = changeSummaryBuilder.ToString(),
                            ShowDuration = 5000,
                            Icon         = new Image {
                                Source = GetImageFromResources("/Assets/Avatars/EditSign.png"), Width = 48, Height = 48
                            },
                            IconColumnWidth = 48,
                            Command         = openIssueCommand
                        });
                    }
                }
                _reportsSettings.LastUpdatesScan = DateTime.Now;
            }
            catch (SearchFailedException e)
            {
                _logger.Log(LogLevel.Warn, "Failed to retrieve updated issues.", e);
                alertManager.ShowAlert(new RadDesktopAlert
                {
                    Header       = "Invalid configuration",
                    Content      = "Please verify that you provided correct list of project keys",
                    ShowDuration = 2000
                });
            }
        }