private void btnShowDocument_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var azureClient = new AzureDataClient();
                var file        = azureClient.GetFile(CurrentToDo.Path);

                if (file.Exists())
                {
                    string copiedFile = azureClient.DownloadFileToOpen(file, (progress, total) => { });

                    if (String.IsNullOrEmpty(copiedFile))
                    {
                        return;
                    }


                    System.Diagnostics.Process process = new System.Diagnostics.Process();
                    Uri pdf = new Uri(copiedFile, UriKind.RelativeOrAbsolute);
                    process.StartInfo.FileName = pdf.LocalPath;

                    process.Start();
                }
                else
                {
                    throw new FileNotFoundException();
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Could not open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
예제 #2
0
        private void btnRecalculateIndexes_Click(object sender, RoutedEventArgs e)
        {
            Thread td = new Thread(() =>
            {
                DocumentIndexingButtonEnabled = false;

                try
                {
                    DocumentIndexingButtonContent = " Priprema ... ";
                    IDocumentFolderService documentFolderService = DependencyResolver.Kernel.Get <IDocumentFolderService>();
                    IDocumentFileService documentFileService     = DependencyResolver.Kernel.Get <IDocumentFileService>();

                    var clearResponse = documentFolderService.Clear(MainWindow.CurrentCompanyId);

                    if (clearResponse.Success)
                    {
                        var clearFileResponse = documentFileService.Clear(MainWindow.CurrentCompanyId);
                        if (clearFileResponse.Success)
                        {
                            var azureClient = new AzureDataClient();
                            var rootFolder  = new DocumentFolderViewModel()
                            {
                                Identifier = Guid.NewGuid(),

                                Name    = "Documents",
                                Path    = azureClient.rootDirectory.Uri.LocalPath,
                                Company = new CompanyViewModel()
                                {
                                    Id = MainWindow.CurrentCompanyId
                                },
                                CreatedBy = new UserViewModel()
                                {
                                    Id = MainWindow.CurrentUserId
                                }
                            };
                            azureClient.IndexingDirectoryChanged += delegate(string currentPath, int totalIndexed)
                            {
                                DocumentIndexingButtonContent = $" Indeksirano foldera: {totalIndexed}. Trenutni folder: {currentPath}";
                            };
                            azureClient.ResetIndexNumber();
                            azureClient.GetDocumentFolders(documentFolderService, documentFileService, rootFolder, true);
                        }
                    }
                    DocumentIndexingButtonEnabled = true;
                    DocumentIndexingButtonContent = " Indeksiranje dokumenata ";
                } catch (Exception ex)
                {
                    MainWindow.ErrorMessage       = ex.Message;
                    DocumentIndexingButtonEnabled = true;
                }
            });

            td.IsBackground = true;
            td.Start();
        }
        private void btnZipAndMailTo_Click(object sender, RoutedEventArgs e)
        {
            var paths = DocumentsForMail.Where(x => !String.IsNullOrEmpty(x.Path)).Select(x => x.Path).Distinct().ToList();

            if (paths.Count() < 1)
            {
                MainWindow.ErrorMessage = ((string)Application.Current.FindResource("OdaberiBarJedanDokumentUzvicnik"));
                return;
            }

            try
            {
                List <string> completedPaths = new List <string>();


                var azureClient = new AzureDataClient();
                foreach (var item in paths)
                {
                    var file = azureClient.GetFile(item);

                    var localPath = azureClient.DownloadFileToOpen(file, (progress, total) => { });
                    completedPaths.Add(localPath);
                }



                System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
                var result = folderBrowser.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    var path = ZipFileHelper.MakeArchiveFromFiles(completedPaths, folderBrowser.SelectedPath);

                    if (!String.IsNullOrEmpty(path))
                    {
                        try
                        {
                            string outlookPath = AppConfigurationHelper.Configuration?.OutlookDefinedPath ?? "";
                            Process.Start($"{outlookPath}", $"/a \"{path}\" /c ipm.note ");
                        }
                        catch (Exception error)
                        {
                            MainWindow.ErrorMessage = ((string)Application.Current.FindResource("OutlookNijeInstaliranIliNijePovezanUzvicnik"));
                        }
                    }
                }
            } catch (Exception ex)
            {
            }
        }
        public DocumentPathDialog()
        {
            InitializeComponent();
            documentFolderService = DependencyResolver.Kernel.Get <IDocumentFolderService>();

            this.DataContext = this;
            FolderFilterObject.PropertyChanged += FolderFilterObject_PropertyChanged;

            azureClient = new AzureDataClient();

            Thread td = new Thread(() => DisplayFolderTree());

            td.IsBackground = true;
            td.Start();
        }
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            await context.PostAsync("You chose : " + activity.Text + ".\nJust a minute. ");

            responseObject.ToFind         = activity.Text;
            responseObject.RetreivedValue = "";

            AzureDataClient.GetAzureResponse(responseObject, "azuredialog");

            if (responseObject.RetreivedValue == "")
            {
                await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is not found. Please retry.");
            }
            else
            {
                int ValuePosition;
                FormattedToFind         = activity.Text;
                ValuePosition           = responseObject.RetreivedValue.IndexOf(':');
                FormattedRetreivedValue = responseObject.RetreivedValue.Substring(0, ValuePosition);

                await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is " + FormattedRetreivedValue);;


                foreach (string attributeToMail in RootDialog.AttributesToMail)
                {
                    if (activity.Text.Contains(attributeToMail))
                    {
                        context.Call(new SendMailDialog(responseObject), AfterMailDeciderAsync);
                        return;
                    }
                }
            }


            await AfterMailDeciderAsync(context, result);
        }
        private void btnShowPhysicalPersonDocument_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var azureClient = new AzureDataClient();
                var file        = azureClient.GetFile(CurrentPhysicalPersonDocument.Path);

                string localFile = azureClient.DownloadFileToOpen(file, (progress, total) => { });

                if (!String.IsNullOrEmpty(localFile))
                {
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
                    //string path = "C:\\Users\\Zdravko83\\Desktop\\1 ZBORNIK.pdf";
                    Uri pdf = new Uri(localFile, UriKind.RelativeOrAbsolute);
                    process.StartInfo.FileName = pdf.LocalPath;
                    process.Start();
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Could not open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        public async Task StartAsync(IDialogContext context)
        {
            await context.PostAsync(AzureDataClient.ExtractAnswer(responseObject, "threshold"));

            string ThresholdValue = responseObject.ThresholdValue;

            int ValuePosition;

            ValuePosition = responseObject.RetreivedValue.IndexOf(' ');
            int CurrentValue = int.Parse(responseObject.RetreivedValue.Substring(0, ValuePosition));

            ValuePosition = responseObject.ThresholdValue.IndexOf(' ');
            int ThreshValue = int.Parse(responseObject.ThresholdValue.Substring(0, ValuePosition));


            //Formatting
            FormattedLob            = responseObject.SystemObject.Lob.Substring(0, responseObject.SystemObject.Lob.Length - 2);
            FormattedToFind         = responseObject.ToFind;
            ValuePosition           = responseObject.RetreivedValue.IndexOf(':');
            FormattedRetreivedValue = responseObject.RetreivedValue.Substring(0, ValuePosition);
            ValuePosition           = responseObject.ThresholdValue.IndexOf(':');
            FormattedThresholdValue = responseObject.ThresholdValue.Substring(0, ValuePosition);



            if (CurrentValue < ThreshValue)
            {
                await context.PostAsync("The value of " + FormattedToFind + " ( " + FormattedRetreivedValue + " ) is within the threshold value of " + FormattedThresholdValue);

                await context.PostAsync("MAIL INFO\n*Sender: " + fromid + "\n*Receiver: " + helpdesk + "\n*Subject: " + subject + "\n");

                PromptDialog.Choice(
                    context: context,
                    resume: MessageReceivedAsync,
                    options: new List <string>()
                {
                    "Yes, Send a mail", "No, Dont send"
                },
                    prompt: "Do you want to send a mail to the helpdesk anyway?",
                    retry: "Selected feature not available . Please try again.",
                    promptStyle: PromptStyle.Auto
                    );
            }
            else
            {
                await context.PostAsync("It looks like the value of " + FormattedToFind + " ( " + FormattedRetreivedValue + " )  is higher than the threshold value of " + FormattedThresholdValue);

                await context.PostAsync("MAIL INFO\n*Sender: " + fromid + "\n*Receiver: " + helpdesk + "\n*Subject: " + subject + "\n");

                PromptDialog.Choice(
                    context: context,
                    resume: MessageReceivedAsync,
                    options: new List <string>()
                {
                    "Yes, Send a mail", "No, Dont send"
                },
                    prompt: "Do you want to send a mail to the helpdesk regarding the deviation?",
                    retry: "Selected feature not available . Please try again.",
                    promptStyle: PromptStyle.Auto
                    );
            }


            // State transition - complete this Dialog and remove it from the stack
        }
예제 #8
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            responseObject.UserQuery = activity.Text;

            var RedirectTo = activity.Text.Split(' ').Skip(0).FirstOrDefault();
            var SecondWord = activity.Text.Split(' ').Skip(0).FirstOrDefault();
            var response   = "";

            RedirectTo = "Azure";


            foreach (string greet in Greetings)
            {
                if (activity.Text.ToLower().Contains(greet))
                {
                    response   = "Welcome! Ask me any question and I'll fetch it for you!\nExamples:\n* Get replytime of OEM systems.\n* Get responsetime of Health department.\n* Request Database Access\n* Use OEM system";
                    response  += "\nAt any time type HELP to access the guidelines in case you are stuck somewhere :)";
                    RedirectTo = "Greet";
                    break;
                }
            }

            if (activity.Text.ToLower().Contains("request") && activity.Text.ToLower().Contains("access"))
            {
                RedirectTo = "Request";
                context.Call <object>(new DatabaseRequestDialog(), MessageReceivedAsync2);
                return;
            }

            if (RedirectTo == Constants.QA)
            {
                QnAResponseObject QnAResponse = await QnADataClient.GetQnAResponse(responseObject.UserQuery);

                if (QnAResponse.answers[0].score < 50)
                {
                    RedirectTo = Constants.Azure;
                }
                else
                {
                    response = QnAResponse.answers[0].answer;
                }
            }

            else if (RedirectTo == Constants.Azure)
            {
                responseObject.SystemObject = AzureDataClient.GetSystemSelected(responseObject.UserQuery);
                if (responseObject.SystemObject == null)
                {
                    await context.PostAsync("nulll af");
                }

                if (SecondWord.ToLower().Equals("use"))
                {
                    context.Call <object>(new AzureSystemSelectedDialog(responseObject), MessageReceivedAsync2);
                    return;
                }
                else
                {
                    AzureDataClient.GetAzureResponse(responseObject, "RootDialog");
                    if (responseObject.RetreivedValue.Equals(""))
                    {
                        context.Call(new AzureSystemSelectedDialog(responseObject), MessageReceivedAsync2);
                        return;
                    }
                    else
                    {
                        int ValuePosition;
                        FormattedLob            = responseObject.SystemObject.Lob.Substring(0, responseObject.SystemObject.Lob.Length - 2);
                        FormattedToFind         = responseObject.ToFind;
                        ValuePosition           = responseObject.RetreivedValue.IndexOf(':');
                        FormattedRetreivedValue = responseObject.RetreivedValue.Substring(0, ValuePosition);

                        await context.PostAsync("The " + FormattedToFind + " of " + FormattedLob + " is " + FormattedRetreivedValue);

                        foreach (string attributeToMail in AttributesToMail)
                        {
                            if (activity.Text.Contains(attributeToMail))
                            {
                                context.Call <object>(new SendMailDialog(responseObject), MessageReceivedAsync2);
                                return;
                            }
                        }
                    }
                }
            }

            if (RedirectTo != Constants.QA && RedirectTo != Constants.Azure && RedirectTo != "Greet")
            {
                response = "Not able to retreive the information. Rephrase your question.\nAt any time type HELP to access the guidelines in case you are stuck somewhere :)";
            }

            if (RedirectTo == "Greet" || RedirectTo == Constants.QA)
            {
                await context.PostAsync(response);
            }
            context.Wait(MessageReceivedAsync);
        }
예제 #9
0
        private void btnSavePdf_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(DocumentName))
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasUnetiNazivDokumentaUzicnik");
                return;
            }
            if (Images == null || Images.Where(x => x.IsSelected).Count() < 1)
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasSkeniratiNestoIOznacitiStavkeUzvicnik");
                return;
            }
            if (String.IsNullOrEmpty(SelectedPath))
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasOdabratiFolderUzvicnik");
                return;
            }
            CanInteractWithForm = false;
            Thread td = new Thread(() =>
            {
                try
                {
                    var tempPath = System.IO.Path.GetTempPath();

                    var generator = new PDFGenerator(Images
                                                     .Where(x => x.IsSelected)
                                                     .OrderBy(x => x.CreatedAt)
                                                     .Select(x => x.ImagePath)
                                                     .ToList(),
                                                     tempPath, DocumentName,
                                                     MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName);

                    CurrentDocumentFullPath = generator.Generate();

                    if (DocumentSavePathOption.Value == true)
                    {
                        File.Copy(CurrentDocumentFullPath, $"{SelectedPath}\\{DocumentName}.pdf");
                        Dispatcher.BeginInvoke((Action)(() => {
                            DocumentSaved?.Invoke(CurrentDocumentFullPath);
                        }));
                    }
                    else
                    {
                        var documentFolderResp = new DocumentFolderSQLiteRepository().GetDirectoryByPath(MainWindow.CurrentCompanyId, SelectedPath);
                        var documentFolder     = documentFolderResp?.DocumentFolder ?? null;


                        var azureClient = new AzureDataClient();



                        var file = azureClient.GetFile($"{SelectedPath}/{DocumentName}.pdf");
                        file.UploadFromFile(CurrentDocumentFullPath);

                        file.FetchAttributes();

                        var documentFile = new DocumentFileViewModel()
                        {
                            Identifier     = Guid.NewGuid(),
                            Name           = $"{DocumentName}.pdf",
                            DocumentFolder = documentFolder,
                            Path           = file.Uri.LocalPath,
                            Size           = file.Properties.Length / 1024,
                            CreatedAt      = file.Properties.LastModified.Value.DateTime,
                            Company        = new CompanyViewModel()
                            {
                                Id = MainWindow.CurrentCompanyId
                            },
                            CreatedBy = new UserViewModel()
                            {
                                Id = MainWindow.CurrentUserId
                            }
                        };

                        var documentFileService = DependencyResolver.Kernel.Get <IDocumentFileService>();

                        var response = documentFileService.Create(documentFile);
                        if (response.Success)
                        {
                            Dispatcher.BeginInvoke((Action)(() => {
                                DocumentSaved?.Invoke(file.Uri.LocalPath);
                            }));
                        }
                        else
                        {
                            MainWindow.WarningMessage = "Dokument je sačuvan na serveru ali nije indeksiran, molimo kontaktirajte administraciju!";
                            Dispatcher.BeginInvoke((Action)(() => {
                                DocumentSaved?.Invoke(file.Uri.LocalPath);
                            }));
                        }
                    }


                    MainWindow.SuccessMessage = (string)Application.Current.FindResource("DokumentJeUspesnoSacuvanUzvicnik");
                } catch (Exception ex)
                {
                    MainWindow.ErrorMessage = ex.Message;
                } finally
                {
                    CanInteractWithForm = true;
                }
            });

            td.IsBackground = true;
            td.Start();
        }