Esempio n. 1
0
        public override bool CanLeavePage()
        {
            if (HasUnsavedChanges)
            {
                return(AskUser.Confirmation("Edit Document",
                                            "There are unsaved changes to this document. Are you sure you want to continue?"));
            }

            return(true);
        }
Esempio n. 2
0
            public override void Execute(object parameter)
            {
                if (string.IsNullOrWhiteSpace(index.Name))
                {
                    ApplicationModel.Current.AddNotification(new Notification("Index must have a name!", NotificationLevel.Error));
                    return;
                }
                if (index.Maps.All(item => string.IsNullOrWhiteSpace(item.Text)))
                {
                    ApplicationModel.Current.AddNotification(new Notification("Index must have at least one map with data!", NotificationLevel.Error));
                    return;
                }

                if (index.IsNewIndex == false && index.OriginalName != index.Name)
                {
                    if (AskUser.Confirmation("Can not rename and index",
                                             "If you wish to save a new index with this new name press OK, to cancel the save command press Cancel") == false)
                    {
                        ApplicationModel.Current.Notifications.Add(new Notification("Index Not Saved"));
                        return;
                    }
                }

                index.UpdateIndex();
                if (index.Reduce == "")
                {
                    index.Reduce = null;
                }
                if (index.TransformResults == "" || index.ShowTransformResults == false)
                {
                    index.TransformResults = null;
                }

                var mapIndexes = (from mapItem in index.Maps where mapItem.Text == "" select index.Maps.IndexOf(mapItem)).ToList();

                mapIndexes.Sort();

                for (int i = mapIndexes.Count - 1; i >= 0; i--)
                {
                    index.Maps.RemoveAt(mapIndexes[i]);
                }

                ApplicationModel.Current.AddNotification(new Notification("saving index " + index.Name));
                DatabaseCommands.PutIndexAsync(index.Name, index.index, true)
                .ContinueOnSuccess(() =>
                {
                    ApplicationModel.Current.AddNotification(
                        new Notification("index " + index.Name + " saved"));
                    index.hasUnsavedChanges = false;
                    PutIndexNameInUrl(index.Name);
                })
                .Catch();
            }
            public override void Execute(object parameter)
            {
                transformer.ClearDefinitionErrors();

                if (string.IsNullOrWhiteSpace(transformer.Transformer.Name))
                {
                    transformer.ReportDefinitionError("Transformer must have a name");
                    return;
                }

                if (string.IsNullOrWhiteSpace(transformer.Transformer.TransformResults))
                {
                    transformer.ReportDefinitionError("Transform must contain a C# LINQ query or Query expression");
                    return;
                }

                if (transformer.IsNewTransformer == false && transformer.OriginalName != transformer.Transformer.Name)
                {
                    if (AskUser.Confirmation("Can not rename and transformer",
                                             "If you wish to save a new transformer with this new name press OK, to cancel the save command press Cancel") == false)
                    {
                        ApplicationModel.Current.Notifications.Add(new Notification("Transformer Not Saved"));
                        return;
                    }
                }

                ApplicationModel.Current.AddNotification(new Notification("saving transformer " + transformer.Transformer.Name));
                DatabaseCommands.PutTransformerAsync(transformer.Transformer.Name, transformer.Transformer)
                .ContinueOnSuccess(() =>
                {
                    ApplicationModel.Current.AddNotification(
                        new Notification("transformer " + transformer.Transformer.Name + " saved"));
                    PutTransformerNameInUrl(transformer.Transformer.Name);

                    transformer.IsShowingErrors = false;
                })
                .Catch(ex =>
                {
                    var indexException = ex.ExtractSingleInnerException() as TransformCompilationException;
                    if (indexException != null)
                    {
                        transformer.ReportDefinitionError(indexException.Message);
                        return(true);
                    }
                    return(false);
                });;
            }
Esempio n. 4
0
        public override bool CanLeavePage()
        {
            var unsavedSections = new List <string>();

            foreach (var settingsSectionModel in Settings.Sections)
            {
                settingsSectionModel.CheckForChanges();
                if (settingsSectionModel.HasUnsavedChanges)
                {
                    unsavedSections.Add(settingsSectionModel.SectionName);
                }
            }

            if (unsavedSections.Count != 0)
            {
                return(AskUser.Confirmation("Settings",
                                            string.Format("There are unsaved changes in these sections: {0}. Are you sure you want to continue?"
                                                          , string.Join(", ", unsavedSections))));
            }

            return(base.CanLeavePage());
        }
Esempio n. 5
0
            public override void Execute(object parameter)
            {
                index.ClearDefinitionErrors();

                if (string.IsNullOrWhiteSpace(index.Name))
                {
                    index.ReportDefinitionError("Index must have a name!", "Name");
                    return;
                }

                if (index.Maps.All(item => string.IsNullOrWhiteSpace(item.Text)))
                {
                    index.ReportDefinitionError("Index must have at least one map with data!", "Map");
                    return;
                }

                if (index.IsNewIndex == false && index.OriginalName != index.Name)
                {
                    if (AskUser.Confirmation("Indexes cannot be renamed",
                                             "If you continue, a new index will be created with this name.") == false)
                    {
                        ApplicationModel.Current.Notifications.Add(new Notification("Index Not Saved"));
                        return;
                    }
                }

                index.UpdateIndex();
                if (index.Reduce == "")
                {
                    index.Reduce = null;
                }
                if (index.TransformResults == "" || index.ShowTransformResults == false)
                {
                    index.TransformResults = null;
                }

                var mapIndexes = (from mapItem in index.Maps where mapItem.Text == "" select index.Maps.IndexOf(mapItem)).ToList();

                mapIndexes.Sort();

                for (int i = mapIndexes.Count - 1; i >= 0; i--)
                {
                    index.Maps.RemoveAt(mapIndexes[i]);
                }

                SavePriority(index);

                ApplicationModel.Current.AddNotification(new Notification("Saving index " + index.Name));
                DatabaseCommands.PutIndexAsync(index.Name, index.index, true)
                .ContinueOnSuccess(() =>
                {
                    ApplicationModel.Current.AddNotification(
                        new Notification("Index " + index.Name + " saved"));
                    index.hasUnsavedChanges = false;
                    PutIndexNameInUrl(index.Name);
                })
                .Catch(ex =>
                {
                    var indexException = ex.ExtractSingleInnerException() as IndexCompilationException;
                    if (indexException != null)
                    {
                        index.ReportDefinitionError(indexException.Message, indexException.IndexDefinitionProperty, indexException.ProblematicText);
                        return(true);
                    }
                    return(false);
                });
            }
Esempio n. 6
0
 public override bool CanLeavePage()
 {
     return(!hasUnsavedChanges || AskUser.Confirmation("Edit Index",
                                                       "There are unsaved changes to this index. Are you sure you want to continue?"));
 }