コード例 #1
0
        private async void SaveItemAsync()
        {
            Notification     result      = Notification.Success();
            ModelUpdateEvent updateEvent = _isNewModel ? ModelUpdateEvent.Created : ModelUpdateEvent.Updated;

            result = _validator.ValidateModel(Model);

            if (result.IsValid())
            {
                var saveResult = await _repository.SaveContactAsync(Model, updateEvent);

                result.AddRange(saveResult);
            }

            if (result.IsValid())
            {
                var eventMessenger = CC.IoC.Resolve <IEventAggregator>();
                ModelUpdatedMessageResult <Contact> eventResult = new ModelUpdatedMessageResult <Contact>()
                {
                    UpdatedModel = Model, UpdateEvent = updateEvent
                };
                eventMessenger.GetEvent <ModelUpdatedMessageEvent <Contact> >().Publish(eventResult);
                await Close();
            }
            else
            {
                await UserNotifier.ShowMessageAsync(result.ToString(), "Save Failed");
            }
        }
コード例 #2
0
 private void btnSavePage_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         if (Addin.currentPageFullName == "" || Addin.currentPageFullName == null)
         {
             AddPageForm addPageForm = new AddPageForm(ref Addin.wiki, false, true);
             new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
             addPageForm.ShowDialog();
         }
         else
         {
             try
             {
                 Addin.AddinActions.SaveToServer();
             }
             catch (Exception ex)
             {
                 Log.Exception(ex);
                 UserNotifier.Exclamation("There was an error when trying to save the page to the server");
             }
         }
     }
     catch (NullReferenceException ex)
     {
         Log.Exception(ex);
         UserNotifier.Exclamation("You are not currently editing a wiki page");
     }
 }
コード例 #3
0
        public override async Task InitializeAsync(System.Collections.Generic.Dictionary <string, string> args)
        {
            if (args != null && args.ContainsKey(Constants.Parameters.Id))
            {
                string id          = args[Constants.Parameters.Id];
                var    fetchResult = await _repository.FetchContactAsync(id);

                if (fetchResult.IsValid())
                {
                    Model = fetchResult.Model;
                }
                else
                {
                    await UserNotifier.ShowMessageAsync(fetchResult.Notification.ToString(), "Fetch Error");
                }
            }
            else
            { //assume new model required
                Model = new Contact()
                {
                    Id = Guid.NewGuid().ToString(),
                    //design data
                    PictureName         = "manhattan",
                    Name                = "Dr. Manhattan",
                    Notes               = "Stay on this guy's good side :P",
                    NextAppointmentDate = DateTime.Now.AddDays(2)
                };
                _isNewModel = true;
            }
        }
コード例 #4
0
 /// <summary>
 /// Copies a document to a specified path.
 /// </summary>
 /// <param name="document">The Document instance.</param>
 /// <param name="path">The path where the new file will be saved.</param>
 /// <param name="saveFormat">The save format.</param>
 /// <exception cref="IOException">When the file cannot be saved.</exception>
 /// <remarks>The document is saved in Unicode little endian encoding.</remarks>
 /// <returns>True if the operation succedes. False otherwise.</returns>
 public bool ShadowCopyDocument(Word.Document document, string path, Word.WdSaveFormat saveFormat)
 {
     try
     {
         Object format               = saveFormat;
         Object copyPath             = path;
         Object encoding             = MsoEncoding.msoEncodingUTF8;
         Object missing              = Type.Missing;
         Object originalFilePath     = document.FullName;
         Object initialDocSaveFormat = document.SaveFormat;
         document.SaveAs(ref copyPath, ref format, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing, ref missing, ref encoding,
                         ref missing, ref missing, ref missing, ref missing);
         //Refresh the active instance(required after acquiring chart data from Excel)
         document = addin.Application.ActiveWindow.Document;
         document.SaveAs(ref originalFilePath, ref initialDocSaveFormat, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing);
     }
     catch (IOException ioex)
     {
         Log.Exception(ioex);
         UserNotifier.Error(ioex.Message);
         return(false);
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
         return(false);
     }
     return(true);
 }
コード例 #5
0
        /// <summary>
        /// Informs user about actions perfomed under the registry.
        /// </summary>
        /// <param name="updatedInstances">List of registry keys on whi</param>
        /// <param name="stopInstallation">Indicates if it necessary to exit setup if error occurs.</param>
        private void ShowSetupResult(IList <string> updatedInstances, bool stopInstallation)
        {
            if (updatedInstances.Count <= 0)
            {
                UserNotifier.ShowInfo(InstallerMainWindow, Resources.AcadNotInstalledMessage);

                if (stopInstallation)
                {
                    throw new InvalidOperationException(Resources.AcadNotInstalledMessage);
                }
            }
            else
            {
                var infoMessage = "Following AutoCAD instances were updated:\n"; // Todo : Replace with resources.

                foreach (var updatedInstance in updatedInstances)
                {
                    infoMessage = string.Concat(infoMessage, updatedInstance, Environment.NewLine);
                }

                Log.LogInfo(infoMessage);

                UserNotifier.ShowInfo(InstallerMainWindow, infoMessage);
            }
        }
コード例 #6
0
        /// <summary>
        /// If the document was modified externally, prompts the user with the document merge screen.
        /// </summary>
        /// <param name="pageFullName">The full name of the wiki page.</param>
        /// <returns>Specifies if the page was modified since it was last merged or opened in Word.</returns>
        private bool MergeWithLatestVersion(String pageFullName)
        {
            bool   wasModified = false;
            String lastAuthor  = "";

            Rpc.PageHistorySummary[] history = CheckPageHistory(pageFullName, out wasModified, out lastAuthor);
            if (wasModified)
            {
                String message = "The wiki page was modified by " + lastAuthor + "." + Environment.NewLine;
                message += "You need to merge the versions then publish the page. Continue?";
                DialogResult result = UserNotifier.YesNoQuestion(message);
                if (result != DialogResult.Yes)
                {
                    return(true);
                }
                String        localFileName = "";
                Word.Document originalDoc   = addin.ActiveDocumentInstance;
                OpenForMerge(pageFullName, out localFileName);
                Word.Document revizedDoc = OpenHTMLDocument(localFileName);
                originalDoc = addin.Application.MergeDocuments(originalDoc, revizedDoc,
                                                               Word.WdCompareDestination.wdCompareDestinationOriginal,
                                                               Word.WdGranularity.wdGranularityCharLevel,
                                                               true, true, true, true, true, true, true, true,
                                                               true, true, "Word Version", lastAuthor,
                                                               Word.WdMergeFormatFrom.wdMergeFormatFromPrompt);
                Object _false = false;
                revizedDoc.ActiveWindow.Visible = false;
                revizedDoc.Close(ref _false, ref _false, ref _false);
                //If document was merged then it's considered to be at the latest version.
                pagesHistory[pageFullName] = history;
            }
            return(wasModified);
        }
コード例 #7
0
        /// <summary>
        /// Edits a wiki page.
        /// The LoadingDialog is shown during the operation.
        /// <see cref="EditPage"/>
        /// </summary>
        /// <param name="pageFullName">The full name of the wiki page that is being opened for editing.</param>
        public void EditPage(String pageFullName)
        {
            if (IsOpened(pageFullName))
            {
                UserNotifier.Message("You are already editing this page.");
                return;
            }
            if (!this.Client.LoggedIn)
            {
                Client.Login(addin.username, addin.password);
            }
            if (IsProtectedPage(pageFullName, addin.ProtectedPages))
            {
                String message = "You cannot edit this page." + Environment.NewLine;
                message += "This page contains scrips that provide functionality to the wiki.";
                UserNotifier.StopHand(message);
                return;
            }
            LoadingDialog loadingDialog = new LoadingDialog("Opening page...");

            ThreadPool.QueueUserWorkItem(new WaitCallback(loadingDialog.ShowSyncDialog));

            GetPage(pageFullName);
            loadingDialog.CloseSyncDialog();
        }
コード例 #8
0
ファイル: DocumentCopier.cs プロジェクト: shostak-vu/sandbox
 public void Perform()
 {
     result = true;
     try
     {
         Object format               = saveFormat;
         Object copyPath             = path;
         Object encoding             = MsoEncoding.msoEncodingUnicodeLittleEndian;
         Object missing              = Type.Missing;
         Object originalFilePath     = document.FullName;
         Object initialDocSaveFormat = document.SaveFormat;
         document.SaveAs(ref copyPath, ref format, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing, ref missing, ref encoding,
                         ref missing, ref missing, ref missing, ref missing);
         document.SaveAs(ref originalFilePath, ref initialDocSaveFormat, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                         ref missing, ref missing, ref missing, ref missing);
     }
     catch (IOException ioex)
     {
         Log.Exception(ioex);
         UserNotifier.Error(ioex.Message);
         result = false;
     }
 }
コード例 #9
0
        private void createLiveDataCacheAndDependencies()
        {
            // The idea is that:
            // 1. Already cached MR that became closed remotely will not be removed from the cache
            // 2. Open MR that are missing in the cache, will be added to the cache
            // 3. Open MR that exist in the cache, will be updated
            // 4. Non-cached MR that are closed remotely, will not be added to the cache even if directly requested by IId
            bool updateOnlyOpened = true;

            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords,
                                                                     Program.Settings.UpdateManagerExtendedLogging, "Live",
                                                                     new DataCacheCallbacks(onForbiddenProject, onNotFoundProject),
                                                                     new DataCacheUpdateRules(Program.Settings.AutoUpdatePeriodMs, Program.Settings.AutoUpdatePeriodMs,
                                                                                              updateOnlyOpened), true, true);

            _liveDataCache = new DataCache(dataCacheContext);
            getListView(EDataCacheType.Live).SetDataCache(_liveDataCache);
            getListView(EDataCacheType.Live).SetFilter(_mergeRequestFilter);

            DataCache dataCache = getDataCache(EDataCacheType.Live);

            _expressionResolver = new ExpressionResolver(dataCache);
            selectColorScheme(); // requires ExpressionResolver

            _eventFilter  = new EventFilter(Program.Settings, dataCache, _mergeRequestFilter);
            _userNotifier = new UserNotifier(dataCache, _eventFilter, _trayIcon);
        }
コード例 #10
0
        private void ReportSaveProblem()
        {
            String error   = Log.GetLastException().Message;
            String message = "There was an error on the server when trying to save the page";

            message += Environment.NewLine + "Details:" + Environment.NewLine + error;
            UserNotifier.Error(message);
        }
コード例 #11
0
        private void createLiveDataCacheAndDependencies()
        {
            DataCacheContext dataCacheContext = new DataCacheContext(this, _mergeRequestFilter, _keywords);

            _liveDataCache      = new DataCache(dataCacheContext, _modificationNotifier);
            _expressionResolver = new ExpressionResolver(_liveDataCache);
            _eventFilter        = new EventFilter(Program.Settings, _liveDataCache, _mergeRequestFilter);
            _userNotifier       = new UserNotifier(_liveDataCache, _eventFilter, _trayIcon);
        }
コード例 #12
0
ファイル: DeRangeMain.cs プロジェクト: bright-tools/DeRange
        public DeRange(Config.Top p_config, UserNotifier p_notifier)
        {
            InitializeComponent();

            m_config   = p_config;
            m_notifier = p_notifier;

            resetHotKeys();
        }
コード例 #13
0
        /// <summary>
        /// Event triggered when the textbox loses the focus.
        /// </summary>
        /// <param name="sender">The control that triggered the event.</param>
        /// <param name="e">The event parameters.</param>
        private void txtAttachmentsRepo_Leave(object sender, EventArgs e)
        {
            bool isValid = ValidatePath(txtAttachmentsRepo.Text);

            if (!isValid)
            {
                UserNotifier.Error("The path you provided is not valid. Please select a valid path");
            }
        }
コード例 #14
0
        /// <summary>
        /// Attaches the current Word document to the selected wiki page.
        /// <remarks>Event triggered when the "Attach file" button in the context menu is pressed.</remarks>
        /// </summary>
        /// <param name="sender">The control that triggered the event.</param>
        /// <param name="e">The event parameters.</param>
        private void cmnuAttachFile_Click(object sender, EventArgs e)
        {
            String page     = Globals.XWikiAddIn.AddinStatus.TaskPaneSelectedPage.Get("page");
            bool   finished = Globals.XWikiAddIn.AddinActions.AttachCurrentFile(page);

            if (finished)
            {
                UserNotifier.Message("Upload finished.");
            }
        }
コード例 #15
0
        public void TestDecorator()
        {
            Notifier notifier = new UserNotifier();

            notifier = new SmsNotifier(notifier);
            notifier.Send();
            Console.WriteLine("\n");
            notifier = new InternetBankingNotifier(notifier);
            notifier.Send();
        }
コード例 #16
0
        public static void Run()
        {
            ConsoleColor.Green.WriteLine(nameof(SrpGoodExample));

            var validator  = new UserValidator();
            var repository = new UserRepository();
            var notifier   = new UserNotifier();
            var service    = new RegisterService(validator, repository, notifier);

            service.RegisterUser("me", "*****@*****.**");
        }
コード例 #17
0
        void XWikiAddIn_LoginFailed()
        {
            String authMessage = "Login failed!" + Environment.NewLine;

            authMessage += "Unable to login, please check your username & password." + Environment.NewLine;
            authMessage += "Hint: make sure you are using correct letter case. Username and password are case sensitive.";
            UserNotifier.StopHand(authMessage);
            Log.Error("Login to server " + serverURL + " failed");
            //Remove TaskPanes
            RemoveAllTaskPanes();
        }
コード例 #18
0
        void XWikiAddIn_LoginFailed()
        {
            String authMessage = "Login failed!" + Environment.NewLine;

            authMessage += "Unable to login, please check your username & password." + Environment.NewLine;
            authMessage += "Hint: make sure you are using correct letter case. Username and password are case sensitive.";
            UserNotifier.StopHand(authMessage);
            Log.Error("Login to server " + serverURL + " failed");
            menuManager.DisableXWordMenus();
            toolbarManager.DisableXWordToolbarButtons();
        }
コード例 #19
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionAddAttachments()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         Globals.XWord2003AddIn.AddinActions.AttachFiles(Globals.XWord2003AddIn.CurrentPageFullName);
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }
コード例 #20
0
ファイル: About.cs プロジェクト: shahjahan0275/acad2fds
 private void WebSiteClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     // Todo : Move strings to assembly attributes like version.
     try
     {
         Process.Start(lbWebSite.Text);
     }
     catch (Exception exception)
     {
         log.LogError(exception);
         UserNotifier.ShowError(exception.Message);
     }
 }
コード例 #21
0
        private void dropDownSyntax_SelectionChanged(object sender, RibbonControlEventArgs e)
        {
            String selectedValue = dropDownSyntax.SelectedItem.Label;

            if (syntaxes.Contains(selectedValue))
            {
                Addin.AddinStatus.Syntax = selectedValue;
            }
            else
            {
                UserNotifier.StopHand("Invalid syntax selected");
            }
        }
コード例 #22
0
ファイル: About.cs プロジェクト: shahjahan0275/acad2fds
 private void MailToClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     // Todo : Move strings to assembly attributes like version.
     try
     {
         Process.Start(string.Format("mailto:{0}", lbMailTo.Text));
     }
     catch (Exception exception)
     {
         log.LogError(exception);
         UserNotifier.ShowError(exception.Message);
     }
 }
コード例 #23
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionOpenWikiPage()
 {
     if (Globals.XWord2003AddIn.Wiki != null)
     {
         EditPageForm editPageForm = new EditPageForm();
         new EditPageFormManager(ref editPageForm).EnqueueAllHandlers();
         editPageForm.ShowDialog();
     }
     else
     {
         UserNotifier.Error(UIMessages.WIKI_STRUCTURE_NOT_LOADED);
     }
 }
コード例 #24
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionNewSpaceOrPage()
 {
     if (Globals.XWord2003AddIn.Wiki != null)
     {
         AddPageForm addPageForm = new AddPageForm(ref Globals.XWord2003AddIn.Wiki);
         new AddPageFormManager(ref addPageForm).EnqueueAllHandlers();
         addPageForm.ShowDialog();
     }
     else
     {
         UserNotifier.Error(UIMessages.WIKI_STRUCTURE_NOT_LOADED);
     }
 }
コード例 #25
0
        private async void RemoveContact(Contact contact)
        {
            var result = await UserNotifier.ShowConfirmAsync("Are your sure you want to delete this contact?", "delete contact", "yes");

            if (result)
            {
                var deleteResult = await _repository.DeleteContactAsync(contact);

                if (deleteResult.IsValid())
                {
                    RecentContacts.UpdateCollection(contact, ModelUpdateEvent.Deleted);
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Validates the data.
        /// </summary>
        /// <returns>True if data is valid. False if data is invalid.</returns>
        private bool ValidateFormData()
        {
            bool   isValid = true;
            String err     = "";

            if (comboBoxSpaceName.Text.Length == 0 && radioButtonExistingSpace.Checked)
            {
                err     = err + Environment.NewLine + " - The space name is not valid";
                isValid = false;
            }
            if (txtSpaceName.Text.Length == 0 && radioButtonNewSpace.Checked)
            {
                err     = err + Environment.NewLine + " - The space name is not valid.";
                isValid = false;
            }
            if (txtPageName.Text.Length == 0)
            {
                err     = err + Environment.NewLine + " - The page name connot be empty.";
                isValid = false;
            }
            if (radioButtonExistingSpace.Checked && (selectedSpace != null))
            {
                foreach (XWikiDocument doc in selectedSpace.documents)
                {
                    if (doc.name == txtPageName.Text)
                    {
                        err = err + " - The page name is not valid. A page named '" + doc.name + "' already exists. Please choose another name.";
                    }
                }
            }
            if (isValid)
            {
                if (radioButtonExistingSpace.Checked)
                {
                    spaceName = comboBoxSpaceName.Text;
                }
                else
                {
                    spaceName = txtSpaceName.Text;
                }
                pageName  = txtPageName.Text;
                pageTitle = txtPageTitle.Text;
            }
            else
            {
                UserNotifier.StopHand(err);
            }
            return(isValid);
        }
コード例 #27
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionViewInBrowser()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         string pageFullName = Globals.XWord2003AddIn.CurrentPageFullName;
         string pageURL      = Globals.XWord2003AddIn.Client.GetURL(pageFullName);
         Globals.XWord2003AddIn.AddinActions.StartProcess(pageURL);
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }
コード例 #28
0
        /// <summary>
        /// Searches the server response for error strings.
        /// </summary>
        /// <param name="content">The server response.</param>
        /// <returns>True if the response contains error reports. False if the response does not ocntain error reports.</returns>
        public bool CheckForErrors(string content)
        {
            bool hasErrors = false;

            if (content.Contains(HTTPResponses.NO_PROGRAMMING_RIGHTS))
            {
                Log.Error("Server " + addin.serverURL + " has no programming rights on getPageservice");
                UserNotifier.Error("There was an error on the server. The pages in MSOffice space don't have programming rights");
                hasErrors = true;
            }
            else if (content.Contains(HTTPResponses.WRONG_REQUEST))
            {
                Log.Error("Server " + addin.serverURL + " wrong request");
                UserNotifier.Error("Server error: Wrong request");
                hasErrors = true;
            }
            else if (content.Contains(HTTPResponses.NO_EDIT_RIGHTS))
            {
                Log.Information("User tried to edit a page on " + addin.serverURL + " whithout edit rights");
                UserNotifier.Error("You dont have the right to edit this page");
                hasErrors = true;
            }
            else if (content.Contains(HTTPResponses.NO_GROOVY_RIGHTS))
            {
                Log.Error("Server " + addin.serverURL + " error on parsing groovy - no groovy rights");
                String message = "There was an error on the server." + Environment.NewLine;
                message += "Please contact your server adminitrator. Error on executing groovy page in MSOffice space";
                UserNotifier.Error(message);
                hasErrors = true;
            }
            else if (content.Contains(HTTPResponses.INSUFFICIENT_MEMMORY))
            {
                Log.Error("Server " + addin.serverURL + " reported OutOfMemmoryException");
                String message = "There was an error on the server." + Environment.NewLine;
                message += "The server has insufficient memmory to execute the current tasks.";
                UserNotifier.Error(message);
                hasErrors = true;
            }
            else if (content.Contains(HTTPResponses.VELOCITY_PARSER_ERROR))
            {
                Log.Error("Server " + addin.serverURL + " error when parsing page. ");
                String message = "There was an error on the server" + Environment.NewLine;
                message += "'Error while parsing velocity page'";
                UserNotifier.Error(message);
                hasErrors = true;
            }
            return(hasErrors);
        }
コード例 #29
0
 /// <summary>
 /// Reloads the wiki structure displayed in the wiki explorer.
 /// </summary>
 public void RefreshWikiExplorer()
 {
     pictureBox.Visible = true;
     treeView.Nodes.Clear();
     pictureBox.BringToFront();
     loadingWikiData = true;
     timerUI.Start();
     try
     {
         backgroundWorker.RunWorkerAsync(this);
     }
     catch (InvalidOperationException)
     {
         UserNotifier.Error("This operation is already in progress");
     }
 }
コード例 #30
0
ファイル: UIActions.cs プロジェクト: dilipkumarj/sandbox
 public static void ActionViewAttachments()
 {
     if (Globals.XWord2003AddIn.Wiki != null &&
         ("" + Globals.XWord2003AddIn.CurrentPageFullName).Length > 1 &&
         Globals.XWord2003AddIn.CurrentPagePublished)
     {
         ViewPageAttachmentsForm        viewPageAttachmentsForm = new ViewPageAttachmentsForm(Globals.XWord2003AddIn.CurrentPageFullName);
         ViewPageAttachmentsFormManager viewAttachmentsManager  = new ViewPageAttachmentsFormManager(ref viewPageAttachmentsForm);
         viewAttachmentsManager.EnqueueAllHandlers();
         viewPageAttachmentsForm.ShowDialog();
     }
     else
     {
         UserNotifier.Exclamation(UIMessages.NOT_A_PUBLISHED_PAGE);
     }
 }