Ejemplo n.º 1
0
		public void TestRegisterDocumentCursorPosition()
		{
			var workingDocument = new WorkDocument();
			const int originalPosition = 10;
			const int position2 = 99;
			const int lastPosition = 43;
			EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, originalPosition);
			EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, position2);
			EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, lastPosition);
			EditorNavigationService.GetNextEdit().ShouldBe(null);
			var previousEdit = EditorNavigationService.GetPreviousEdit();
			previousEdit.ShouldNotBe(null);
			previousEdit.Document.ShouldBe(workingDocument);
			previousEdit.CursorPosition.ShouldBe(position2);
			previousEdit = EditorNavigationService.GetPreviousEdit();
			previousEdit.ShouldNotBe(null);
			previousEdit.Document.ShouldBe(workingDocument);
			previousEdit.CursorPosition.ShouldBe(originalPosition);
			previousEdit = EditorNavigationService.GetPreviousEdit();
			previousEdit.ShouldNotBe(null);
			previousEdit.Document.ShouldBe(workingDocument);
			previousEdit.CursorPosition.ShouldBe(originalPosition);

			var nextEdit = EditorNavigationService.GetNextEdit();
			nextEdit.ShouldNotBe(null);
			nextEdit.Document.ShouldBe(workingDocument);
			nextEdit.CursorPosition.ShouldBe(position2);
			nextEdit = EditorNavigationService.GetNextEdit();
			nextEdit.ShouldNotBe(null);
			nextEdit.Document.ShouldBe(workingDocument);
			nextEdit.CursorPosition.ShouldBe(lastPosition);
			EditorNavigationService.GetNextEdit().ShouldBe(null);
		}
Ejemplo n.º 2
0
 private async void CheckUploadJobComplete(WorkDocument document)
 {
     if (document.LicenseData != null && document.PassportData != null && document.BackLicenseUploaded)
     {
         document.Ready = true;
         bool didCreate = await _workQueue.UpdateWorkDocumentAsync(document);
     }
 }
Ejemplo n.º 3
0
 void FormatWorkingDocumentsStringToHash(ref StringBuilder toHash, WorkDocument doc, string hashAnterior)
 {
     toHash.Clear();
     toHash.AppendFormat("{0};{1};{2};{3};{4}"
                         , doc.WorkDate
                         , doc.SystemEntryDate
                         , doc.DocumentNumber
                         , doc.DocumentTotals.GrossTotal
                         , hashAnterior);
 }
        public async Task <ServiceResult> CreateFinalJob(string userId)
        {
            // Okay, get the user from the database and also get the mongo work document.
            // Create a job in a new database table called FinalJob. When this is created, we can then push it to the database. Then, the mvc can request a list of jobs. Each with information about the Job.
            // The way to handle the images.. we can get download links for each of them for 10 minutes..pass that in the
            // Job JSON then display this in the MVC?

            try
            {
                WorkDocument document = await workQueue.FindByUserId(userId);

                var user = Db.Users.Find(int.Parse(userId));;
                user.Status = Dependency.Enums.UserStatus.Pending;

                JobDM dm = new JobDM()
                {
                    UserId             = userId,
                    ClaimedFirstName   = user.FirstName,
                    ClaimedLastName    = user.LastName,
                    FirstNameLicense   = document.LicenseData.FirstName,
                    LastNameLicense    = document.LicenseData.LastName,
                    LicenseNumber      = document.LicenseData.Number,
                    LicenseDateOfBirth = document.LicenseData.DateOfBirth,
                    LicenseExpiry      = document.LicenseData.Expiry,
                    FirstNamePassport  = document.PassportData.FirstName,
                    LastNamePassport   = document.PassportData.LastName,
                    PassportNumber     = document.PassportData.Number,
                    PassportExpiry     = document.PassportData.Expiry,
                    MRZ = document.PassportData.MRZ,
                    PassportDateOfBirth = document.PassportData.DateOfBirth,
                    AppId   = user.AppID,
                    Created = DateTime.Now
                };

                Db.Jobs.Add(dm);
                await Db.SaveChangesAsync();
            }
            catch (Exception e)
            {
                Logger.Error(e.ToString());
                ServiceResult.Errors.Add("Error creating the final job.");
            }

            return(ServiceResult);
        }
Ejemplo n.º 5
0
        private void LoadWorkDocument()
        {
            var result = this.DialogService.ShowOpenFileDialog(this, new OpenFileDialogOption()
            {
                DefaultExt = "xml",
                Filter     = "Work Document files (*.xml)|*.xml|All files (*.*)|*.*",
            });

            if (result != null)
            {
                using (var stream = File.OpenRead(result.FileNames.First()))
                {
                    var element  = XElement.Load(stream);
                    var document = new WorkDocument(element);
                    this.ApplicationService.CurrentWorkDocument = document;
                }
            }
        }
Ejemplo n.º 6
0
        public async Task <bool> AddLicenseDataToJob(LicenseSM licenseSM, string userId, string appId)
        {
            var currentDocument = await _workQueue.FindByUserId(userId);

            if (currentDocument == null)
            {
                // This is the first thing that a user has uploaded. Create a new work task for them.
                var document = new WorkDocument()
                {
                    UserId      = userId,
                    LicenseData = CreateLicenseData(licenseSM),
                    AppID       = appId
                };

                bool didCreate = await _workQueue.CreateWorkDocumentAsync(document);

                if (!didCreate)
                {
                    _logger.Error("Failed to create new work document using license data.");
                    return(false);
                }

                CheckUploadJobComplete(document);

                // All good, work document created.
                return(true);
            }
            else
            {
                currentDocument.LicenseData = CreateLicenseData(licenseSM);
                bool didCreate = await _workQueue.UpdateWorkDocumentAsync(currentDocument);

                if (!didCreate)
                {
                    _logger.Error("Failed to create new work document using license data.");
                    return(false);
                }

                // All good, work document updated.
                CheckUploadJobComplete(currentDocument);
                return(true);
            }
        }
Ejemplo n.º 7
0
        public DataSourceInfoListViewModel(IApplicationService applicationService, IEventAggregator eventAggregator)
        {
            if (applicationService == null)
            {
                throw new ArgumentNullException("dataService");
            }
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }

            this._eventAggregator    = eventAggregator;
            this._applicationService = applicationService;

            this._eventAggregator.GetEvent <WorkDocumentChangedEvent>().Subscribe((workDocument) =>
            {
                this._workDocument = workDocument;

                //  Refresh when new document selected
                if (this._workDocument == null)
                {
                    this.DataSourceInfoList = null;

                    this.NotifyOfPropertyChange(() => this.DataSourceInfoList);
                }
                else
                {
                    this._workDocument.DataSources.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e)
                    {
                        this.RefreshDataSourceInfoList();
                    };

                    this.RefreshDataSourceInfoList();
                }
            });
        }
Ejemplo n.º 8
0
        public void TestRegisterDocumentCursorPosition()
        {
            var       workingDocument  = new WorkDocument();
            const int originalPosition = 10;
            const int position2        = 99;
            const int lastPosition     = 43;

            EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, originalPosition);
            EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, position2);
            EditorNavigationService.RegisterDocumentCursorPosition(workingDocument, lastPosition);
            EditorNavigationService.GetNextEdit().ShouldBeNull();
            var previousEdit = EditorNavigationService.GetPreviousEdit();

            previousEdit.ShouldNotBeNull();
            previousEdit.Document.ShouldBe(workingDocument);
            previousEdit.CursorPosition.ShouldBe(position2);
            previousEdit = EditorNavigationService.GetPreviousEdit();
            previousEdit.ShouldNotBeNull();
            previousEdit.Document.ShouldBe(workingDocument);
            previousEdit.CursorPosition.ShouldBe(originalPosition);
            previousEdit = EditorNavigationService.GetPreviousEdit();
            previousEdit.ShouldNotBeNull();
            previousEdit.Document.ShouldBe(workingDocument);
            previousEdit.CursorPosition.ShouldBe(originalPosition);

            var nextEdit = EditorNavigationService.GetNextEdit();

            nextEdit.ShouldNotBeNull();
            nextEdit.Document.ShouldBe(workingDocument);
            nextEdit.CursorPosition.ShouldBe(position2);
            nextEdit = EditorNavigationService.GetNextEdit();
            nextEdit.ShouldNotBeNull();
            nextEdit.Document.ShouldBe(workingDocument);
            nextEdit.CursorPosition.ShouldBe(lastPosition);
            EditorNavigationService.GetNextEdit().ShouldBeNull();
        }
Ejemplo n.º 9
0
        private List <Line> GetWorkDocumentListLines(WorkDocument pWorkDocument)
        {
            List <Line> lista = new List <Line>();

            try
            {
                bdContext.ComandText = "stp_SAFT_WORKING_DOCUMENTS_LINES";
                bdContext.AddParameter("@INVOICE_ID", pWorkDocument.WorkID);

                MySqlDataReader dr = bdContext.ExecuteReader();
                while (dr.Read())
                {
                    var item = new Line
                    {
                        LineNumber = dr[0].ToString(),

                        /*OrderReferences = new OrderReferences
                         * {
                         *  OriginatingON = dr[1].ToString(),
                         *  OrderDate = dr[2].ToString() == string.Empty ? DateTime.MinValue.ToString("yyyy-MM-dd") : DateTime.Parse(dr[2].ToString()).ToString("yyyy-MM-dd"),
                         * },*/
                        ProductCode        = dr[3].ToString(),
                        ProductDescription = dr[4].ToString(),
                        Quantity           = dr[5].ToString().Replace(",", ".").Replace("-", string.Empty),
                        UnitPrice          = dr[6].ToString().Replace(",", ".").Replace("-", string.Empty).Replace("-", string.Empty),
                        UnitOfMeasure      = dr[7].ToString(),
                        //TaxBase = null,// Math.Round(decimal.Parse(dr[8].ToString()), 2).ToString().Replace(",", ".").ToString().Replace("-", string.Empty),
                        TaxPointDate = dr[9].ToString() == string.Empty ? DateTime.MinValue.ToString("yyyy-MM-dd") : DateTime.Parse(dr[9].ToString()).ToString("yyyy-MM-dd"),

                        /*References = new References
                         * {
                         *  Reference = dr[10].ToString(),
                         *  Reason = dr[11].ToString()
                         * },*/
                        Description = dr[12].ToString(),

                        DebitAmount  = null,//dr[14].ToString().Replace(",", ".").Replace("-", string.Empty),
                        CreditAmount = dr[15].ToString().Replace(",", ".").Replace("-", string.Empty),
                        Tax          = new Tax
                        {
                            TaxType          = dr[16].ToString(),
                            TaxCountryRegion = dr[17].ToString() == "" ? "AO" : dr[17].ToString(),
                            TaxCode          = dr[18].ToString(),
                            TaxPercentage    = dr[19].ToString().Replace(",", ".").Replace("-", string.Empty).Replace("-", string.Empty),
                            TaxAmount        = null, //dr[20].ToString().Replace(",", ".").Replace("-", string.Empty)
                        },
                        ProductSerialNumber = null,

                        /*
                         * TaxExemptions = new TaxExemptions
                         * {
                         *  TaxExemptionReason = dr[21].ToString(),
                         *  TaxExemptionCode = dr[22].ToString()
                         * },*/
                        TaxExemptionReason = dr[21].ToString(),
                        TaxExemptionCode   = dr[22].ToString(),
                        SettlementAmount   = dr[23].ToString().Replace(",", ".").Replace("-", string.Empty)
                    };

                    if (item.TaxExemptionCode == "")
                    {
                        item.TaxExemptionCode   = null;
                        item.TaxExemptionReason = null;
                    }
                    //decimal debitAmount = decimal.Parse(item.DebitAmount), creditAmount = decimal.Parse(item.CreditAmount);

                    lista.Add(item);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                bdContext.FecharConexao();
            }

            return(lista);
        }
Ejemplo n.º 10
0
        private WorkDocument[] GetWorkDocumentList(SaftDTO pFilter)
        {
            List <WorkDocument> lista = new List <WorkDocument>();

            try
            {
                bdContext.ComandText = "stp_SAFT_WORKING_DOCUMENTS";
                bdContext.AddParameter("@COMPANY_ID", pFilter.Filial);
                bdContext.AddParameter("@FILE_TYPE", pFilter.FileType);
                bdContext.AddParameter("@DATE_INI", pFilter.DateFrom);
                bdContext.AddParameter("@DATE_TERM", pFilter.DateUntil);
                bdContext.AddParameter("@TRANSACTION_ID", pFilter.SaftID);
                bdContext.AddParameter("@FISCAL_YEAR", pFilter.FiscalYear);

                MySqlDataReader dr = bdContext.ExecuteReader();
                while (dr.Read())
                {
                    var workDocument = new WorkDocument
                    {
                        DocumentNumber = dr[0].ToString(),
                        DocumentStatus = new WorkingDocumentStatus
                        {
                            WorkStatus     = dr[1].ToString(),
                            WorkStatusDate = DateTime.Parse(dr[2].ToString()).ToString("yyyy-MM-ddTHH:mm:ss"),
                            //Reason = dr[3].ToString(),
                            SourceID      = dr[4].ToString(),
                            SourceBilling = dr[5].ToString()
                        },
                        Hash        = dr[6].ToString(),
                        HashControl = dr[7].ToString(),
                        Period      = dr[8].ToString(),
                        WorkDate    = DateTime.Parse(dr[9].ToString()).ToString("yyyy-MM-dd"),
                        WorkType    = dr[10].ToString().Replace("FP", "PP").Replace("NP", "PP").Replace("ORT", "OR").Replace("EC", "NE").Replace("ECL", "NE"),

                        SourceID        = dr[11].ToString(),
                        EACCode         = null,//dr[12].ToString(),
                        SystemEntryDate = DateTime.Parse(dr[13].ToString()).ToString("yyyy-MM-ddTHH:mm:ss"),
                        TransactionID   = pFilter.FileType == "F" ? null : dr[14].ToString(),
                        CustomerID      = dr[15].ToString(),
                        WorkID          = int.Parse(dr[16].ToString()),
                        DocumentTotals  = new WorkingDocumentsTotals
                        {
                            TaxPayable = dr[17].ToString().Replace(",", ".").Replace("-", string.Empty),
                            NetTotal   = dr[18].ToString().Replace(",", ".").Replace("-", string.Empty),
                            GrossTotal = dr[19].ToString().Replace(",", ".").Replace("-", string.Empty),
                            Currency   = new Currency
                            {
                                CurrencyCode   = dr[20].ToString(),
                                CurrencyAmount = Math.Round(decimal.Parse(dr[21].ToString()), 2).ToString().Replace(",", ".").Replace("-", string.Empty),
                                ExchageRate    = dr[22].ToString().Replace(",", ".").Replace("-", string.Empty)
                            },
                        },
                    };

                    if (dr[20].ToString() == "AOA")
                    {
                        workDocument.DocumentTotals.Currency = null;
                    }

                    lista.Add(workDocument);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                bdContext.FecharConexao();
                for (int i = 0; i < lista.Count; i++)
                {
                    lista[i].Line = GetWorkDocumentListLines(lista[i]);//.ToArray();
                }
            }



            return(lista.ToArray());
        }
Ejemplo n.º 11
0
		public void SerializationTest()
		{
			WorkDocumentCollection.WorkingDocuments.Count.ShouldBe(0);

			const string statementText = "SELECT * FROM DUAL";
			const string watchVariable1 = "variable1";
			const string watchVariable2 = "variable2";

			var newWorkingDocument =
				new WorkDocument
				{
					ConnectionName = "DummyConnection",
					CursorPosition = 999,
					DocumentFileName = "DummyDocument.sql",
					IsModified = true,
					SchemaName = "DummySchema",
					SelectionLength = 20,
					SelectionStart = 10,
					EditorGridRowHeight = 142.17,
					EditorGridColumnWidth = 98.32,
					Text = statementText,
					TabIndex = 3,
					EnableDatabaseOutput = true,
					KeepDatabaseOutputHistory = true,
					FontSize = 16,
					DebuggerViewDefaultTabIndex = 1,
					ExportOutputPath = Path.GetRandomFileName(),
					ExportOutputFileName = "OutputFile.dat",
					DataExporter = typeof(SqlInsertDataExporter).FullName,
					RefreshInterval = TimeSpan.FromSeconds(900),
					HeaderTextColorCode = Colors.Crimson.ToString(),
					HeaderBackgroundColorCode = Colors.CornflowerBlue.ToString(),
					WatchItems = new[] { watchVariable1, watchVariable2 }
				};

			const int expectedActiveDocumentIndex = 666;
			WorkDocumentCollection.ActiveDocumentIndex = expectedActiveDocumentIndex;
			WorkDocumentCollection.AddDocument(newWorkingDocument);

			const string providerName = "Oracle.DataAccess.Client";
			const string bindVariableDataType = "CHAR";
			const string bindVariableName = "Variable";
			const string bindVariableValue = "TestValue";
			var providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(providerName);
			providerConfiguration.SetBindVariable(
				new BindVariableConfiguration
				{
					DataType = bindVariableDataType,
					Name = bindVariableName,
					Value = bindVariableValue,
					IsFilePath = true
				});

			var statementExecutedAt = new DateTime(2015, 7, 22, 7, 53, 55);
			const string historyEntryTag = "Test";
			providerConfiguration.AddStatementExecution(
				new StatementExecutionHistoryEntry(statementText, statementExecutedAt)
				{
					Tags = historyEntryTag
				});

			WorkDocumentCollection.Save();

			var fileInfo = new FileInfo(Path.Combine(TempDirectoryName, "WorkArea", WorkDocumentCollection.ConfigurationFileName));
			fileInfo.Exists.ShouldBe(true);
			fileInfo.Length.ShouldBe(482);

			WorkDocumentCollection.Configure();
			WorkDocumentCollection.WorkingDocuments.Count.ShouldBe(1);
			var deserializedWorkingDocument = WorkDocumentCollection.WorkingDocuments.Single();

			deserializedWorkingDocument.ShouldNotBeSameAs(newWorkingDocument);
			deserializedWorkingDocument.ConnectionName.ShouldBe(newWorkingDocument.ConnectionName);
			deserializedWorkingDocument.CursorPosition.ShouldBe(newWorkingDocument.CursorPosition);
			deserializedWorkingDocument.DocumentFileName.ShouldBe(newWorkingDocument.DocumentFileName);
			deserializedWorkingDocument.IsModified.ShouldBe(newWorkingDocument.IsModified);
			deserializedWorkingDocument.SchemaName.ShouldBe(newWorkingDocument.SchemaName);
			deserializedWorkingDocument.SelectionLength.ShouldBe(newWorkingDocument.SelectionLength);
			deserializedWorkingDocument.SelectionStart.ShouldBe(newWorkingDocument.SelectionStart);
			deserializedWorkingDocument.Text.ShouldBe(newWorkingDocument.Text);
			deserializedWorkingDocument.DocumentId.ShouldBe(newWorkingDocument.DocumentId);
			deserializedWorkingDocument.EditorGridRowHeight.ShouldBe(newWorkingDocument.EditorGridRowHeight);
			deserializedWorkingDocument.EditorGridColumnWidth.ShouldBe(newWorkingDocument.EditorGridColumnWidth);
			deserializedWorkingDocument.TabIndex.ShouldBe(newWorkingDocument.TabIndex);
			deserializedWorkingDocument.EnableDatabaseOutput.ShouldBe(newWorkingDocument.EnableDatabaseOutput);
			deserializedWorkingDocument.KeepDatabaseOutputHistory.ShouldBe(newWorkingDocument.KeepDatabaseOutputHistory);
			deserializedWorkingDocument.FontSize.ShouldBe(newWorkingDocument.FontSize);
			deserializedWorkingDocument.RefreshInterval.ShouldBe(newWorkingDocument.RefreshInterval);
			deserializedWorkingDocument.DebuggerViewDefaultTabIndex.ShouldBe(newWorkingDocument.DebuggerViewDefaultTabIndex);
			deserializedWorkingDocument.HeaderTextColorCode.ShouldBe(newWorkingDocument.HeaderTextColorCode);
			deserializedWorkingDocument.HeaderBackgroundColorCode.ShouldBe(newWorkingDocument.HeaderBackgroundColorCode);
			deserializedWorkingDocument.ExportOutputFileName.ShouldBe(newWorkingDocument.ExportOutputFileName);
			deserializedWorkingDocument.ExportOutputPath.ShouldBe(newWorkingDocument.ExportOutputPath);
			deserializedWorkingDocument.DataExporter.ShouldBe(newWorkingDocument.DataExporter);
			deserializedWorkingDocument.WatchItems.Length.ShouldBe(newWorkingDocument.WatchItems.Length);
			deserializedWorkingDocument.WatchItems[0].ShouldBe(watchVariable1);
			deserializedWorkingDocument.WatchItems[1].ShouldBe(watchVariable2);

			var deserializedProviderConfiguration = WorkDocumentCollection.GetProviderConfiguration(providerName);
			providerConfiguration.ShouldNotBeSameAs(deserializedProviderConfiguration);
			deserializedProviderConfiguration.BindVariables.Count.ShouldBe(1);
			var deserializedBindVariable = deserializedProviderConfiguration.BindVariables.First();
			deserializedBindVariable.DataType.ShouldBe(bindVariableDataType);
			deserializedBindVariable.Name.ShouldBe(bindVariableName);
			deserializedBindVariable.Value.ShouldBe(bindVariableValue);
			deserializedBindVariable.IsFilePath.ShouldBe(true);

			deserializedProviderConfiguration.StatementExecutionHistory.Count.ShouldBe(1);
			var historyEntry = deserializedProviderConfiguration.StatementExecutionHistory.Single();
			historyEntry.ExecutedAt.ShouldBe(statementExecutedAt);
			historyEntry.StatementText.ShouldBe(statementText);
			historyEntry.Tags.ShouldBe(historyEntryTag);

			WorkDocumentCollection.ActiveDocumentIndex.ShouldBe(expectedActiveDocumentIndex);
		}
Ejemplo n.º 12
0
		public RecentFileItem(WorkDocument workDocument, int index)
		{
			Index = index;
			WorkDocument = workDocument;
			DocumentFileName = workDocument.DocumentFileName.Replace("_", "__");
			var command = new RoutedCommand($"OpenRecentFile{index}", typeof(ContextMenu));

			Command = command;
		}
Ejemplo n.º 13
0
		private DocumentPage OpenExistingWorkDocument(WorkDocument document)
		{
			DocumentPage documentPage;
			WorkDocument workDocument;
			if (WorkDocumentCollection.TryGetWorkingDocumentFor(document.DocumentFileName, out workDocument))
			{
				documentPage = AllDocuments.Single(d => d.WorkDocument == workDocument);
				DocumentTabControl.SelectedItem = documentPage.TabItem;
			}
			else
			{
				WorkDocumentCollection.AddDocument(document);
				documentPage = AddNewDocumentPage(document);
			}

			return documentPage;
		}
Ejemplo n.º 14
0
		public DocumentPage AddNewDocumentPage(WorkDocument workDocument = null)
		{
			var newDocumentPage = new DocumentPage(workDocument);
			
			_editorAdapters.Add(newDocumentPage.EditorAdapter);

			AddDocumentTabItemContextMenuCommandBindings(newDocumentPage);

			DocumentTabControl.Items.Insert(DocumentTabControl.Items.Count - 1, newDocumentPage.TabItem);
			DocumentTabControl.SelectedItem = newDocumentPage.TabItem;

			_findReplaceManager.CurrentEditor = newDocumentPage.EditorAdapter;

			return newDocumentPage;
		}
Ejemplo n.º 15
0
        public void SerializationTest()
        {
            WorkDocumentCollection.WorkingDocuments.Count.ShouldBe(0);

            const string statementText  = "SELECT * FROM DUAL";
            const string watchVariable1 = "variable1";
            const string watchVariable2 = "variable2";

            var newWorkingDocument =
                new WorkDocument
            {
                ConnectionName        = "DummyConnection",
                CursorPosition        = 999,
                DocumentFileName      = "DummyDocument.sql",
                IsModified            = true,
                SchemaName            = "DummySchema",
                SelectionLength       = 20,
                SelectionStart        = 10,
                EditorGridRowHeight   = 142.17,
                EditorGridColumnWidth = 98.32,
                Text                        = statementText,
                TabIndex                    = 3,
                EnableDatabaseOutput        = true,
                KeepDatabaseOutputHistory   = true,
                FontSize                    = 16,
                DebuggerViewDefaultTabIndex = 1,
                ExportOutputPath            = Path.GetRandomFileName(),
                ExportOutputFileName        = "OutputFile.dat",
                DataExporter                = typeof(SqlInsertDataExporter).FullName,
                RefreshInterval             = TimeSpan.FromSeconds(900),
                HeaderTextColorCode         = Colors.Crimson.ToString(),
                HeaderBackgroundColorCode   = Colors.CornflowerBlue.ToString(),
                WatchItems                  = new[] { watchVariable1, watchVariable2 }
            };

            const int expectedActiveDocumentIndex = 666;

            WorkDocumentCollection.ActiveDocumentIndex = expectedActiveDocumentIndex;
            WorkDocumentCollection.AddDocument(newWorkingDocument);

            const string providerName          = "Oracle.DataAccess.Client";
            const string bindVariableDataType  = "CHAR";
            const string bindVariableName      = "Variable";
            const string bindVariableValue     = "TestValue";
            var          providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(providerName);

            providerConfiguration.SetBindVariable(
                new BindVariableConfiguration
            {
                DataType   = bindVariableDataType,
                Name       = bindVariableName,
                Value      = bindVariableValue,
                IsFilePath = true
            });

            var          statementExecutedAt = new DateTime(2015, 7, 22, 7, 53, 55);
            const string historyEntryTag     = "Test";

            providerConfiguration.AddStatementExecution(
                new StatementExecutionHistoryEntry(statementText, statementExecutedAt)
            {
                Tags = historyEntryTag
            });

            WorkDocumentCollection.Save();

            var fileInfo = new FileInfo(Path.Combine(TempDirectoryName, "WorkArea", WorkDocumentCollection.ConfigurationFileName));

            fileInfo.Exists.ShouldBeTrue();
            fileInfo.Length.ShouldBe(482);

            WorkDocumentCollection.Configure();
            WorkDocumentCollection.WorkingDocuments.Count.ShouldBe(1);
            var deserializedWorkingDocument = WorkDocumentCollection.WorkingDocuments.Single();

            deserializedWorkingDocument.ShouldNotBeSameAs(newWorkingDocument);
            deserializedWorkingDocument.ConnectionName.ShouldBe(newWorkingDocument.ConnectionName);
            deserializedWorkingDocument.CursorPosition.ShouldBe(newWorkingDocument.CursorPosition);
            deserializedWorkingDocument.DocumentFileName.ShouldBe(newWorkingDocument.DocumentFileName);
            deserializedWorkingDocument.IsModified.ShouldBe(newWorkingDocument.IsModified);
            deserializedWorkingDocument.SchemaName.ShouldBe(newWorkingDocument.SchemaName);
            deserializedWorkingDocument.SelectionLength.ShouldBe(newWorkingDocument.SelectionLength);
            deserializedWorkingDocument.SelectionStart.ShouldBe(newWorkingDocument.SelectionStart);
            deserializedWorkingDocument.Text.ShouldBe(newWorkingDocument.Text);
            deserializedWorkingDocument.DocumentId.ShouldBe(newWorkingDocument.DocumentId);
            deserializedWorkingDocument.EditorGridRowHeight.ShouldBe(newWorkingDocument.EditorGridRowHeight);
            deserializedWorkingDocument.EditorGridColumnWidth.ShouldBe(newWorkingDocument.EditorGridColumnWidth);
            deserializedWorkingDocument.TabIndex.ShouldBe(newWorkingDocument.TabIndex);
            deserializedWorkingDocument.EnableDatabaseOutput.ShouldBe(newWorkingDocument.EnableDatabaseOutput);
            deserializedWorkingDocument.KeepDatabaseOutputHistory.ShouldBe(newWorkingDocument.KeepDatabaseOutputHistory);
            deserializedWorkingDocument.FontSize.ShouldBe(newWorkingDocument.FontSize);
            deserializedWorkingDocument.RefreshInterval.ShouldBe(newWorkingDocument.RefreshInterval);
            deserializedWorkingDocument.DebuggerViewDefaultTabIndex.ShouldBe(newWorkingDocument.DebuggerViewDefaultTabIndex);
            deserializedWorkingDocument.HeaderTextColorCode.ShouldBe(newWorkingDocument.HeaderTextColorCode);
            deserializedWorkingDocument.HeaderBackgroundColorCode.ShouldBe(newWorkingDocument.HeaderBackgroundColorCode);
            deserializedWorkingDocument.ExportOutputFileName.ShouldBe(newWorkingDocument.ExportOutputFileName);
            deserializedWorkingDocument.ExportOutputPath.ShouldBe(newWorkingDocument.ExportOutputPath);
            deserializedWorkingDocument.DataExporter.ShouldBe(newWorkingDocument.DataExporter);
            deserializedWorkingDocument.WatchItems.Length.ShouldBe(newWorkingDocument.WatchItems.Length);
            deserializedWorkingDocument.WatchItems[0].ShouldBe(watchVariable1);
            deserializedWorkingDocument.WatchItems[1].ShouldBe(watchVariable2);

            var deserializedProviderConfiguration = WorkDocumentCollection.GetProviderConfiguration(providerName);

            providerConfiguration.ShouldNotBeSameAs(deserializedProviderConfiguration);
            deserializedProviderConfiguration.BindVariables.Count.ShouldBe(1);
            var deserializedBindVariable = deserializedProviderConfiguration.BindVariables.First();

            deserializedBindVariable.DataType.ShouldBe(bindVariableDataType);
            deserializedBindVariable.Name.ShouldBe(bindVariableName);
            deserializedBindVariable.Value.ShouldBe(bindVariableValue);
            deserializedBindVariable.IsFilePath.ShouldBeTrue();

            deserializedProviderConfiguration.StatementExecutionHistory.Count.ShouldBe(1);
            var historyEntry = deserializedProviderConfiguration.StatementExecutionHistory.Single();

            historyEntry.ExecutedAt.ShouldBe(statementExecutedAt);
            historyEntry.StatementText.ShouldBe(statementText);
            historyEntry.Tags.ShouldBe(historyEntryTag);

            WorkDocumentCollection.ActiveDocumentIndex.ShouldBe(expectedActiveDocumentIndex);
        }
Ejemplo n.º 16
0
        private void AddEventWorkDTO(EventDetail eventDetail, EventDTO eventDTO)
        {
            if (eventDetail.WorkID == null || Work.WorkShouldBeExcludedByGroupId((int)eventDetail.WorkGroupId))
            {
                return;
            }

            var work = eventDTO.works.FirstOrDefault(w => w.workID == (int)eventDetail.WorkID);

            if (work == null)
            {
                work = new WorkDTO
                {
                    WorkTitle        = eventDetail.WorkTitle,
                    ComposerFullName = eventDetail.ComposerFullName,
                    workID           = (int)eventDetail.WorkID,
                    Arranger         = eventDetail.WorkArrangement,
                    WorkArtists      = new List <ArtistDTO>(),
                    WorkDocuments    = new List <WorkDocumentDTO>()
                };

                eventDTO.works.Add(work);
            }

            var artistID = eventDetail.ArtistID;

            if (artistID != null)
            {
                var workArtist = work.WorkArtists.FirstOrDefault(wa => wa.ArtistID == (int)eventDetail.ArtistID);

                var    instrumentID = eventDetail.InstrumentID ?? 0;
                string instrument;
                if (instrumentID == 0)
                {
                    instrument = "";
                }
                else
                {
                    instrument = Instrument.GetInstrumentByID((int)eventDetail.InstrumentID).Instrument1;
                }

                if (workArtist == null)
                {
                    var artist = Artist.GetArtistByID((int)artistID);

                    workArtist = new ArtistDTO
                    {
                        ArtistFullName   = artist.ArtistFullName,
                        ArtistInstrument = instrument,
                        ArtistID         = (int)eventDetail.ArtistID
                    };

                    work.WorkArtists.Add(workArtist);
                }
            }
            var documentID = eventDetail.WorkDocumentID;

            if (documentID != null)
            {
                var workDocument = work.WorkDocuments.FirstOrDefault(wd => wd.WorkDocumentID == (int)eventDetail.WorkDocumentID);
                if (workDocument == null)
                {
                    var document = WorkDocument.GetDocumentByID((int)documentID);
                    workDocument = new WorkDocumentDTO
                    {
                        WorkDocumentID           = (int)eventDetail.WorkDocumentID,
                        WorkDocumentName         = document.WorkDocumentName,
                        WorkDocumentFileLocation = document.WorkDocumentFileLocation,
                    };
                    work.WorkDocuments.Add(workDocument);
                }
            }
        }