Ejemplo n.º 1
0
 /// <summary>
 /// Updates the data.
 /// </summary>
 private void UpdateData()
 {
     StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");
     try
     {
         if (ValidateData())
         {
             SmtpDetail mailDetails = FillData(null);
             int        result      = SmtpDataAccess.UpdateSmtpDetails(mailDetails);
             if (result > 0)
             {
                 NotificationHelper.ShowMessage(Utilities.GetResourceValue("DataUpdateSuccess"), Utilities.GetResourceValue("CaptionInfo"));
                 LoadData();
             }
             else
             {
                 NotificationHelper.ShowMessage(Utilities.GetResourceValue("NothingUpdated"), Utilities.GetResourceValue("CaptionWarning"));
             }
         }
     }
     catch (Exception exception)
     {
         string message = exception.Message;
         if (exception.InnerException != null)
         {
             message += Environment.NewLine + exception.InnerException.Message;
         }
         NotificationHelper.ShowMessage(message, Utilities.GetResourceValue("CaptionError"));
     }
     StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
 }
Ejemplo n.º 2
0
        private void Validate()
        {
            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");
            Data.ValidationMessage     = string.Empty;
            Data.IsResultsVisible      = false;

            if (Data.ValidateSqlDetails())
            {
                if (!Data.IsDatabasesVisible)
                {
                    Data.IsDatabasesVisible = BindDatabases();
                    OnPropertyChanged("Databases");
                    Data.SelectedDatabase = "0";
                }
                else if (Data.IsDatabasesVisible)
                {
                    Data.UpdateConnectionString();
                    Responses.Clear();

                    Responses.Add(DiagnosticsService.CheckSqlPermission(Data));
                    Responses.Add(DiagnosticsService.CheckGPeConnect(Data));
                    Responses.Add(DiagnosticsService.CheckWebServicesRunning(Data));
                    Responses.Add(DiagnosticsService.CheckCloudIsRunning(Data));
                    Responses.Add(DiagnosticsService.CheckSubscription(Data));
                    //Responses.Add(DiagnosticsService.CheckMagentoIsRunning(Data));
                    //Responses.Add(DiagnosticsService.CheckMagentoConnectorIsRunning(Data));

                    Data.IsResultsVisible = true;
                    DiagnosticsService.SaveToDatabase(Responses, validationId);
                }
            }
            StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the specified object.
        /// </summary>
        private void Update()
        {
            try
            {
                bool isUpdated = false;
                if (IsUpdateLogConfiguration)
                {
                    ConfigurationHelper.SetConfigurationValue(ConfigurationConstants.DeleteLogFiles, IsDeleteLogFiles);
                    ConfigurationHelper.SetConfigurationValue(ConfigurationConstants.LogDeleteDays, LogDeleteDays);
                    ConfigurationHelper.SetConfigurationValue(ConfigurationConstants.ZipLogDeleteMonths, LogDeleteMonths);
                    isUpdated = true;
                }

                if (IsUpdateSchedulerConfiguration)
                {
                    IEnumerable <EntityViewModel> checkedRecords = SchedulerData.Where(c1 => c1.IsChecked).ToList();
                    if (checkedRecords.Any())
                    {
                        foreach (EntityViewModel model in checkedRecords)

                        {
                            if (model.LastSyncTime == null)
                            {
                                continue;
                            }
                            var data = new EntityModel {
                                EntityId = model.EntityId, EndTime = model.LastSyncTime.Value
                            };
                            EntityDataAccess.UpdateLastSyncTime(data);
                        }
                        isUpdated = true;
                    }
                }

                if (IsUpdateEntityConfiguration)
                {
                    foreach (EntityViewModel model in EntityData)
                    {
                        var data = new EntityModel {
                            EntityId = model.EntityId, IsInboundActive = model.IsInboundActive, IsOutboundActive = model.IsOutboundActive
                        };
                        EntityDataAccess.UpdateEntityInformation(data);
                    }
                    isUpdated = true;
                }

                if (isUpdated)
                {
                    NotificationHelper.ShowMessage(Utilities.GetResourceValue("DataUpdateSuccess"), Utilities.GetResourceValue("CaptionInfo"));
                }
                else
                {
                    NotificationHelper.ShowMessage(Utilities.GetResourceValue("NothingUpdated"), Utilities.GetResourceValue("CaptionWarning"));
                }
            }
            catch (Exception exception)
            {
                NotificationHelper.ShowMessage(exception.Message, Utilities.GetResourceValue("CaptionError"));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads the configurations.
        /// </summary>
        private void LoadConfigurations(bool isRefreshData)
        {
            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");
            try
            {
                if (isRefreshData)
                {
                    ConfigurationHelper.FillAllConfigurations();
                }
                Settings.Clear();

                IQueryable <ConfigurationModel> query = ConfigurationHelper.Keys.AsQueryable();
                if (SearchModel.ConfigurationType.HasValue)
                {
                    query = query.Where(c1 => c1.ConfigurationType == SearchModel.ConfigurationType);
                }
                if (!string.IsNullOrEmpty(SearchModel.GroupName))
                {
                    query = query.Where(c1 => c1.GroupName.ToLower().Contains(SearchModel.GroupName.ToLower()));
                }
                if (!string.IsNullOrEmpty(SearchModel.ConfigurationKey))
                {
                    query = query.Where(c1 => c1.ConfigurationKey.ToLower().Contains(SearchModel.ConfigurationKey.ToLower()));
                }

                Settings.AddRange(query.OrderBy(c1 => c1.ConfigurationType).ThenBy(c1 => c1.GroupName).ThenBy(c1 => c1.ConfigurationKey).ToList());
            }
            catch (Exception exception)
            {
                NotificationHelper.ShowMessage(exception.Message, Utilities.GetResourceValue("CaptionError"));
            }
            StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
        }
Ejemplo n.º 5
0
 public DiagnosticsViewModel()
 {
     validationId = Guid.NewGuid().ToString();
     LoadDefaultData();
     ValidateCommand            = new BaseCommand(Validate);
     ClearCommand               = new BaseCommand(Clear);
     StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Views the error.
        /// </summary>
        /// <param name="arg">The argument.</param>
        private void ViewError(object arg)
        {
            MessageReportModel model = arg as MessageReportModel;

            if (model != null)
            {
                NotificationHelper.ShowMessage(model.ErrorMessage, Utilities.GetResourceValue("CaptionError"));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Loads the summary.
        /// </summary>
        private void LoadReport()
        {
            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");

            IList <MessageCountModel> messages = localSql.GetErpMessageSummary(SearchData);

            CountMessages(messages);

            StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Tests the mail.
 /// </summary>
 private void TestMail()
 {
     StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");
     if (ValidateData())
     {
         bool result = SendTestMail(FillData(null));
         if (result)
         {
             NotificationHelper.ShowMessage(Utilities.GetResourceValue("TestMailSuccessful"), Utilities.GetResourceValue("CaptionInfo"));
         }
     }
     StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Views the records.
        /// </summary>
        /// <param name="entityId">The entity identifier.</param>
        /// <param name="statusId">The status identifier.</param>
        /// <param name="recordCount">The record count.</param>
        private void ViewRecords(int entityId, int statusId, int recordCount)
        {
            if (recordCount == 0)
            {
                NotificationHelper.ShowMessage(Utilities.GetResourceValue("NoRecordsToShow"), Utilities.GetResourceValue("CaptionInfo"));
                return;
            }

            ViewRecordsEventHandler handler = ViewRecordsClicked;

            if (handler == null)
            {
                return;
            }
            SearchData.StatusId = statusId;
            SearchData.EntityId = entityId;
            handler.Invoke(SearchData);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Synchronizes the records.
        /// </summary>
        private void SyncRecords()
        {
            if (!RecordList.Any(c1 => c1.IsCheckBoxChecked))
            {
                NotificationHelper.ShowMessage("Please select records to sync", Utilities.GetResourceValue("CaptionWarning"));
                return;
            }

            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");

            ThreadHelper.RunBackGround(delegate
            {
                int?entityId = RecordList.FirstOrDefault(c1 => c1.IsCheckBoxChecked)?.EntityId;
                if (!entityId.HasValue)
                {
                    NotificationHelper.ShowMessage("Entity not found", Utilities.GetResourceValue("CaptionWarning"));
                    return;
                }

                IList <long> processRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.Error))
                                              .Select(c1 => c1.CloudMessageId).ToList();

                if (processRecords.Any())
                {
                    Connector.Base.Services.Inbound.MessageReceiveService.ReceiveRecords(processRecords, entityId.Value);
                }

                IList <DataModel> sendRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.RequestProcessed))
                                                .Select(c1 => new DataModel
                {
                    CloudMessageId = c1.CloudMessageId,
                    SourceId       = c1.EcommerceId,
                    TargetId       = c1.ErpId,
                    Reference      = c1.Reference,
                    Result         = true,
                }).ToList();
                if (sendRecords.Any())
                {
                    Connector.Base.Services.Inbound.MessageReceiveService.SendResponses(sendRecords, entityId.Value);
                }
                Application.Current.Dispatcher.Invoke(LoadReport);
                StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
            });
        }
Ejemplo n.º 11
0
        private void SyncRecords()
        {
            if (!RecordList.Any(c1 => c1.IsCheckBoxChecked))
            {
                NotificationHelper.ShowMessage("Please select records to sync", Utilities.GetResourceValue("CaptionWarning"));
                return;
            }

            StatusUpdate.StatusMessage = Utilities.GetResourceValue("Loading");

            ThreadHelper.RunBackGround(delegate
            {
                int?entityId = RecordList.FirstOrDefault(c1 => c1.IsCheckBoxChecked)?.EntityId;
                if (!entityId.HasValue)
                {
                    NotificationHelper.ShowMessage("Entity not found", Utilities.GetResourceValue("CaptionWarning"));
                    return;
                }

                IList <long> processRecords = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.Error || c1.StatusId == (int)MessageStatus.TransferPending))
                                              .Select(c1 => c1.MessageId).ToList();

                if (processRecords.Any())
                {
                    Connector.Base.Services.Outbound.MessageSendService.SyncRecords(processRecords, entityId.Value);
                }

                IList <MessageModel> getResponse = RecordList.Where(c1 => c1.IsCheckBoxChecked & (c1.StatusId == (int)MessageStatus.RequestTransferred))
                                                   .Select(c1 => new MessageModel
                {
                    CloudMessageId = c1.CloudMessageId,
                    LocalMessageId = c1.MessageId,
                    SyncCounter    = c1.SyncCounter + 1,
                    MessageStatus  = (MessageStatus)c1.StatusId
                }).ToList();
                if (getResponse.Any())
                {
                    Connector.Base.Services.Outbound.ResponseReceiveService.PullResponse(getResponse, entityId.Value);
                }
                Application.Current.Dispatcher.Invoke(LoadReport);
                StatusUpdate.StatusMessage = Utilities.GetResourceValue("DefaultStatus");
            });
        }
Ejemplo n.º 12
0
        public SchedulerViewModel(int schedulerId, string name, string description, TimeSpan timeSpan)
        {
            initialLoading = true;
            dialogService  = Utilities.CreateDialogServiceInstance();
            string instancePostfix = ConfigurationHelper.GetConfigurationValue(ConfigurationConstants.InstanceType);

            SchedulerGroupName = string.Format(CultureInfo.CurrentCulture, "{0}_{1}", CompanyName, instancePostfix);
            SchedulerId        = schedulerId;
            SchedulerName      = name;
            Description        = description;
            IntervalTime       = timeSpan;
            CreateCommand      = new BaseCommand(CanCreate, Create);
            RefreshCommand     = new BaseCommand(Refresh);

            using (var taskScheduler = new TaskService())
            {
                TaskFolder taskFolder = taskScheduler.GetFolder("\\");
                CheckFolder(taskFolder);
            }
            LoadSchedulerStatus();
            initialLoading = false;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Sends the test mail.
        /// </summary>
        /// <param name="mailDetails">The mail details.</param>
        /// <returns></returns>
        private static bool SendTestMail(SmtpDetail mailDetails)
        {
            bool result = MailService.SendMail(mailDetails, Utilities.GetResourceValue("MailSubjectTest"), GetNotificationMailBody());

            return(result);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates the scheduler.
        /// </summary>
        /// <param name="schedulerData">The scheduler data.</param>
        /// <param name="showStatus">if set to <c>true</c> [status].</param>
        /// <returns></returns>
        private bool CreateScheduler(SchedulerModel schedulerData, bool showStatus)
        {
            bool result = false;

            try
            {
                using (var taskScheduler = new TaskService())
                {
                    TaskDefinition newTaskDefinition = taskScheduler.NewTask();
                    newTaskDefinition.RegistrationInfo.Author      = schedulerData.Author;
                    newTaskDefinition.RegistrationInfo.Description = schedulerData.Description;
                    newTaskDefinition.Settings.Compatibility       = TaskCompatibility.V2;

                    var action = (ExecAction)newTaskDefinition.Actions.AddNew(TaskActionType.Execute);
                    action.Id                             = schedulerData.Id;
                    action.Path                           = schedulerData.Path;
                    action.Arguments                      = schedulerData.Arguments;
                    action.WorkingDirectory               = schedulerData.WorkingDirectory;
                    newTaskDefinition.Principal.UserId    = Environment.UserName;
                    newTaskDefinition.Principal.LogonType = TaskLogonType.Password;

                    DailyTrigger trigger = newTaskDefinition.Triggers.AddNew(TaskTriggerType.Daily) as DailyTrigger;
                    if (trigger != null)
                    {
                        trigger.StartBoundary       = DateTime.Now.Date;
                        trigger.DaysInterval        = schedulerData.DaysInterval;
                        trigger.Repetition.Interval = schedulerData.RepetitionInterval;
                        trigger.Enabled             = true;
                    }

                    TaskFolder taskFolder = taskScheduler.GetFolder("\\");
                    CheckFolder(taskFolder);

                    if (string.IsNullOrEmpty(currentUserPassword))
                    {
                        var viewModel = new PasswordViewModel();
                        System.Windows.Window window = null;

                        if (System.Windows.Application.Current != null)
                        {
                            window = System.Windows.Application.Current.MainWindow;
                        }
                        if (window == null)
                        {
CheckPassword:
                            string password = null;
                            if (InputBox.Show("Authentication", string.Format(Constants.DefaultCulture, "Enter {0} Password:"******"UnableToCreateScheduler"), schedulerData.Description), Utilities.GetResourceValue("CaptionError"));
                            }
                            return(false);
                        }
                    }

                    taskFolder = taskScheduler.GetFolder("\\" + schedulerData.TaskFolder);
                    string userId = string.Concat(Environment.UserDomainName, "\\", Environment.UserName);
                    taskFolder.RegisterTaskDefinition(schedulerData.Id, newTaskDefinition, TaskCreation.CreateOrUpdate, userId, currentUserPassword, TaskLogonType.InteractiveTokenOrPassword);
                    result = true;
                    if (showStatus)
                    {
                        if (IsUiProcess)
                        {
                            NotificationHelper.ShowMessage(string.Format(CultureInfo.CurrentCulture, Utilities.GetResourceValue("SchedulerCreated"), schedulerData.Id), Utilities.GetResourceValue("CaptionInfo"));
                        }
                        SetFilePermission(schedulerData.Id);
                    }
                }
            }
            catch (Exception exception)
            {
                if (IsUiProcess)
                {
                    NotificationHelper.ShowMessage(string.Format(CultureInfo.CurrentCulture, Utilities.GetResourceValue("UnableToCreateScheduler"), schedulerData.Description, exception.Message), Utilities.GetResourceValue("CaptionError"));
                }
                else
                {
                    Logger.LogMessage(exception.Message, "CreateScheduler", LogType.Error, exception);
                }
            }
            return(result);
        }