private void CreateReport()
 {
     if (isSinglePersonReport)
     {
         if (SelectedApplicant != null)
         {
             DocumentsHandler dh = new DocumentsHandler();
             dh.CreateSingleEnrollmentReport(DocumentsSettings.Settings["EnrollmentReports"] + $"\\Приказ о зачислении ({SelectedApplicant}, {GroupName}).docx", GroupName, applicants.FirstOrDefault(c => c.Name == SelectedApplicant));
         }
     }
     else
     {
         if (applicants != null && applicants.Count > 0)
         {
             DocumentsHandler dh = new DocumentsHandler();
             dh.CreateEnrollmentReport(DocumentsSettings.Settings["EnrollmentReports"] + $"\\Приказ о зачислении ({applicants[0].Speciality}, {GroupName}).docx", applicants[0].Speciality, GroupName, applicants);
             Return();
         }
         else
         {
             MessageBox.Show("Список абитуриентов пуст");
         }
     }
     Return();
 }
Beispiel #2
0
        public void RunClangCompile(int aCommandId)
        {
            if (mCommandsController.Running)
            {
                return;
            }

            mCommandsController.Running = true;

            var task = System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    if (VsServiceProvider.TryGetService(typeof(DTE), out object dte))
                    {
                        DocumentsHandler.SaveActiveDocuments();
                        AutomationUtil.SaveDirtyProjects((dte as DTE2).Solution);
                    }

                    CollectSelectedItems(false, ScriptConstants.kAcceptedFileExtensions);
                    RunScript(aCommandId);
                }
                catch (Exception exception)
                {
                    VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error",
                                                    OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            }).ContinueWith(tsk => mCommandsController.OnAfterClangCommand());
        }
Beispiel #3
0
        /// <inheritdoc/>
        public IDocumentsHandler <DocumentHandler> CreateDocumentsHandler()
        {
            var docsHandler = new DocumentsHandler <DocumentHandler>(App, m_Logger);

            m_DocsHandlers.Add(docsHandler);

            return(docsHandler);
        }
Beispiel #4
0
 /// <summary>
 /// This function is the callback used to execute the command when the menu item is clicked.
 /// See the constructor to see how the menu item is associated with this function using
 /// OleMenuCommandService service and MenuCommand class.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event args.</param>
 public void RunIgnoreCompileCommand(int aId)
 {
     var task = System.Threading.Tasks.Task.Run(() =>
     {
         List <string> documentsToIgnore = DocumentsHandler.GetDocumentsToIgnore();
         AddIgnoreFilesToSettings(documentsToIgnore);
     });
 }
Beispiel #5
0
        /// <inheritdoc/>
        public IDocumentsHandler <TDocHandler> CreateDocumentsHandler <TDocHandler>()
            where TDocHandler : IDocumentHandler, new()
        {
            var docsHandler = new DocumentsHandler <TDocHandler>(App, m_Logger);

            m_DocsHandlers.Add(docsHandler);

            return(docsHandler);
        }
Beispiel #6
0
        public void RunClangTidy(int aCommandId)
        {
            if (mCommandsController.Running)
            {
                return;
            }

            mCommandsController.Running = true;

            var task = System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    DocumentsHandler.SaveActiveDocuments();

                    if (!VsServiceProvider.TryGetService(typeof(DTE), out object dte))
                    {
                        return;
                    }

                    var dte2 = dte as DTE2;
                    AutomationUtil.SaveDirtyProjects(dte2.Solution);

                    CollectSelectedItems(false, ScriptConstants.kAcceptedFileExtensions);

                    using (var silentFileController = new SilentFileChangerController())
                    {
                        using (var fileChangerWatcher = new FileChangerWatcher())
                        {
                            var tidySettings = SettingsProvider.GetSettingsPage(typeof(ClangTidyOptionsView)) as ClangTidyOptionsView;

                            if (CommandIds.kTidyFixId == aCommandId || tidySettings.AutoTidyOnSave)
                            {
                                fileChangerWatcher.OnChanged += FileOpener.Open;

                                string solutionFolderPath = dte2.Solution.FullName
                                                            .Substring(0, dte2.Solution.FullName.LastIndexOf('\\'));

                                fileChangerWatcher.Run(solutionFolderPath);

                                FilePathCollector fileCollector = new FilePathCollector();
                                var filesPath = fileCollector.Collect(mItemsCollector.GetItems).ToList();

                                silentFileController.SilentFiles(filesPath);
                                silentFileController.SilentFiles(dte2.Documents);
                            }
                            RunScript(aCommandId);
                        }
                    }
                }
                catch (Exception exception)
                {
                    VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error",
                                                    OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                }
            }).ContinueWith(tsk => DispatcherHandler.Invoke(() => mCommandsController.OnAfterClangCommand(), DispatcherPriority.Background));
        }
Beispiel #7
0
        private void FormatAllSelectedDocuments(CommandUILocation commandUILocation)
        {
            foreach (var item in CollectItems(true, ScriptConstants.kAcceptedFileExtensions, commandUILocation))
            {
                var document = (item.GetObject() as ProjectItem).Document;

                if (null == document)
                {
                    document = DocumentsHandler.GetActiveDocument();
                }

                mClangFormatView = SettingsProvider.ClangFormatSettings;
                mDocument        = document;

                RunClangFormat(commandUILocation);
            }
        }
Beispiel #8
0
        private void FormatAllSelectedDocuments()
        {
            foreach (var item in CollectSelectedItems(true))
            {
                var document = (item.GetObject() as ProjectItem).Document;

                if (null == document)
                {
                    document = DocumentsHandler.GetActiveDocument();
                }

                mClangFormatView = SettingsProvider.GetSettingsPage(typeof(ClangFormatOptionsView)) as ClangFormatOptionsView;
                mDocument        = document;

                RunClangFormat();
            }
        }
        private void FormatAllSelectedDocuments()
        {
            foreach (var item in CollectSelectedItems(true))
            {
                var document = (item.GetObject() as ProjectItem).Document;

                if (null == document)
                {
                    document = DocumentsHandler.GetActiveDocument();
                }

                mClangFormatView = GetUserOptions();
                mDocument        = document;

                RunClangFormat(new object(), new EventArgs());
            }
        }
Beispiel #10
0
        private void FormatAllSelectedDocuments()
        {
            ItemsCollector itemsCollector = new ItemsCollector();

            itemsCollector.CollectSelectedProjectItems();
            List <Document> activeDocs     = DocumentsHandler.GetListOfActiveDocuments();
            Document        activeDocument = DocumentsHandler.GetActiveDocument();

            foreach (var item in itemsCollector.items)
            {
                try
                {
                    var projectItem = item.GetObject() as ProjectItem;
                    mDocument = projectItem.Open().Document;
                    ExecuteFormatCommand();

                    if (DocumentsHandler.IsOpen(mDocument, activeDocs))
                    {
                        mDocument.Save();
                    }
                    else
                    {
                        mDocument.Close(vsSaveChanges.vsSaveChangesYes);
                    }
                }
                catch (Exception) { }
                finally
                {
                    mDocument = null;
                }
            }
            if (activeDocument != null)
            {
                activeDocument.Activate();
            }
        }
Beispiel #11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Fix for external startup environements (for instance when clicking on mailto links from IE)
            Directory.SetCurrentDirectory(path);

            AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler;
            Current.DispatcherUnhandledException       += GlobalWPFExceptionHandler;

            // Increase maximum concurrent HttpWebRequest connections
            ServicePointManager.DefaultConnectionLimit = 100;

            if (CheckForUpgrade())
            {
                // first check if we need elevated permissions
                new Process {
                    StartInfo = new ProcessStartInfo(Path.Combine(path, "Inbox2Upgrade.exe"))
                    {
                        Arguments = "upgrade", UseShellExecute = true, Verb = "runas"
                    }
                }.Start();

                // Shutdown current application
                Current.Shutdown();
            }
            else
            {
                LoadTheme("/Settings/Application/Theme".AsKey("DarkSide"));

                // Run startup code
                ThreadPool.QueueUserWorkItem(delegate { Core.Startup.PyBinding(); });

                Core.Startup.Logging("log4net.config");
                Core.Startup.TypeConverters();
                Core.Startup.DataSources();
                Core.Startup.Search();
                Core.Startup.CorePlugins();
                Core.Startup.AppPlugins();
                Core.Startup.Plumbing();
                Core.Startup.Channels();
                Core.Startup.Commands();
                Core.Startup.KeyboardHooks();
                Core.Startup.LoadStats();

                MessagesHandler.Init();
                DocumentsHandler.Init();
                ContactsHandler.Init();
                UserStatusHandler.Init();

                // Can also help in ssl debugging with Fiddler2
                if (SettingsManager.ClientSettings.AppConfiguration.IgnoreSslCertificateIssues)
                {
                    ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }
                }
                ;

                OverrideDependencyProperties();

                var window = new MainWindow();
                window.Show();

                stopwatch.Start();

                startupSuccess = true;
            }
        }
Beispiel #12
0
        protected override void ExecuteCore()
        {
            try
            {
                Logger.Debug("Retreiving message {0} from {1}", LogSource.Receive, header, config.DisplayName);

                foreach (var channelMessage in channel.GetMessage(header))
                {
                    // Create a duck copy from the mailMessage.
                    var message = new Message
                    {
                        MessageNumber     = header.MessageNumber,
                        MessageIdentifier = channelMessage.MessageIdentifier,
                        From                   = channelMessage.From,
                        ReturnTo               = channelMessage.ReturnTo,
                        To                     = channelMessage.To,
                        CC                     = channelMessage.CC,
                        BCC                    = channelMessage.BCC,
                        InReplyTo              = channelMessage.InReplyTo,
                        Size                   = header.Size,
                        Context                = channelMessage.Context.ToClearSubject(),
                        OriginalContext        = channelMessage.Context,
                        ConversationIdentifier = channelMessage.ConversationId,
                        SourceFolder           = channelMessage.SourceFolder,
                        SourceChannelId        = channelMessage.SourceChannelId,
                        TargetChannelId        = channelMessage.TargetChannelId,
                        Metadata               = channelMessage.Metadata,
                        IsRead                 = channelMessage.IsRead,
                        IsStarred              = channelMessage.IsStarred,
                        DateReceived           = channelMessage.DateReceived,
                        DateSent               = channelMessage.DateSent
                    };

                    message.Context = message.Context != null?message.Context.Trim() : String.Empty;

                    string bodyText = channelMessage.BodyText.ReadString();
                    string bodyHtml = channelMessage.BodyHtml.ReadString();

                    var access = new ClientMessageAccess(message, bodyText, bodyHtml);

                    if (folder.ToStorageFolder() == Folders.SentItems)
                    {
                        // For sent items we sent the TargetChannelId
                        message.TargetChannelId = config.ChannelId;
                    }
                    else
                    {
                        // For all other items we sent the SourceChannelId
                        message.SourceChannelId = config.ChannelId;
                    }

                    // Create BodyPreview field from reader
                    message.BodyPreview        = access.GetBodyPreview();
                    message.BodyHtmlStreamName = access.WriteBodyHtml();
                    message.BodyTextStreamName = access.WriteBodyText();
                    message.MessageFolder      = folder.ToStorageFolder();
                    message.Metadata           = header.Metadata;

                    // Fix for messages which have a timestamp in the futre
                    if (message.DateReceived > DateTime.Now)
                    {
                        message.DateReceived = DateTime.Now;
                    }

                    // Set IsNew state for message
                    if (!message.IsRead)
                    {
                        message.IsNew = true;
                    }

                    // Save message
                    ClientState.Current.DataService.Save(message);


                    // Message received, process attachments
                    foreach (var attachment in channelMessage.Attachments)
                    {
                        var document = new Document
                        {
                            Filename        = attachment.Filename,
                            SourceChannelId = attachment.SourceChannelId,
                            TargetChannelId = attachment.TargetChannelId,
                            DocumentFolder  = folder.ToStorageFolder(),
                            ContentType     = attachment.ContentType,
                            ContentId       = attachment.ContentId,
                            ContentStream   = attachment.ContentStream
                        };

                        document.SourceChannelId = config.ChannelId;
                        document.DateReceived    = message.DateReceived;
                        document.DateSent        = message.DateSent;
                        document.Message         = message;

                        DocumentsHandler.DocumentReceived(document);

                        if (attachment.ContentStream != null)
                        {
                            attachment.ContentStream.Dispose();
                            attachment.ContentStream = null;
                        }
                    }

                    if (channelMessage.BodyText != null)
                    {
                        channelMessage.BodyText.Dispose();
                    }

                    if (channelMessage.BodyHtml != null)
                    {
                        channelMessage.BodyHtml.Dispose();
                    }

                    // Match thread
                    MessageMatcher.Match(message);

                    // Add to search index
                    ClientState.Current.Search.Store(message);

                    new ProfileMatcher(message).Execute();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("An error occured when trying to download header {0}. Exception = {1}", LogSource.BackgroundTask, header, ex);

                throw;
            }
        }