public Form1() { InitializeComponent(); dataConnector = new DataConnector(); dataConnector.OpenConnection("all"); // Recupera os relatórios em formato Crystal Reports ( Categoria C ) ReportingDocumentDAO reportingDocumentDAO = new ReportingDocumentDAO(dataConnector.SqlServerConnection); List <ReportingDocumentDTO> reportList = reportingDocumentDAO.GetReports("Category = 'C'"); // Recupera dados do firebird ProdutoDAO productDAO = new ProdutoDAO(dataConnector.FirebirdConnection); List <ProdutoDTO> productList = productDAO.GetAll(); CidadeDAO cidadeDAO = new CidadeDAO(dataConnector.FirebirdConnection); List <CidadeDTO> cityList = cidadeDAO.GetAll(); FormaPagamentoDAO formaPagamentoDAO = new FormaPagamentoDAO(dataConnector.FirebirdConnection); List <FormaPagamentoDTO> paymentMethodList = formaPagamentoDAO.GetAll(); dataConnector.CloseConnection(); cmbReport.Items.AddRange(reportList.ToArray()); cmbReport.SelectedIndex = 0; cmbProduct.Items.AddRange(productList.ToArray()); cmbProduct.SelectedIndex = 0; cmbCity.Items.AddRange(cityList.ToArray()); cmbCity.SelectedIndex = 0; cmbPaymentMethod.Items.AddRange(paymentMethodList.ToArray()); cmbPaymentMethod.SelectedIndex = 0; }
static void Main(string[] args) { // read config var appConfig = new AppliedConfig(new ConfigurationBuilder() .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName) .AddJsonFile("appsettings.json", false)); // establish data access IDataAccess connector = DataConnector.getDBConnector(appConfig.ConnnectionString, appConfig.ConnectorType); WorkDay workDay = new WorkDay(appConfig.Culture, connector); // closest thing to UI at the moment foreach (var entry in connector.GetEntries()) { Console.WriteLine("Date: {0} Week: {1} Start Time {2}, End Time {3} and active hours {4}", entry.date, entry.calWeek.ToString("00"), entry.startTime, entry.endTime, entry.hoursActive.ToString("0.00")); } Console.WriteLine("Press Enter to exit..."); Console.ReadLine(); // update db before quiting connector.StoreEntry(workDay.generateNewEntry()); }
public ILogicEvaluatorType BuildEvaluatorType(IProcessExecutionContext executionContext, IRecordPointer <Guid> evaluatorTypeId, bool useCache = true) { if (evaluatorTypeId is null) { throw new ArgumentNullException("evaluatorTypeId"); } var cacheTimeout = useCache ? getCacheTimeout(executionContext) : null; useCache = useCache && executionContext.Cache != null && cacheTimeout != null; string cacheKey = null; if (useCache) { cacheKey = CACHE_KEY + evaluatorTypeId.Id.ToString(); if (executionContext.Cache.Exists(cacheKey)) { return(executionContext.Cache.Get <ILogicEvaluatorType>(cacheKey)); } } try { var record = DataConnector.GetEvaluatorTypeRecord(executionContext.DataService, evaluatorTypeId); return(this.BuildEvaluatorType(executionContext, record, record.Name, record.AssemblyName, record.ClassName)); } catch (Exception) { throw; } }
/// <summary> /// Describes the schema of the underlying data and services to the K2 platform. /// </summary> /// <returns>A string containing the schema XML.</returns> public override string DescribeSchema() { try { // Makes better use of resources and avoids any unnecessary open connections to data sources. using (DataConnector connector = new DataConnector(this)) { // Get the configuration from the service instance. connector.GetConfiguration(); // Set the type mappings. connector.SetTypeMappings(); // Describe the schema. connector.DescribeSchema(); // Set up the service instance. connector.SetupService(); } // Indicate that the operation was successful. ServicePackage.IsSuccessful = true; } catch (Exception ex) { // Record the exception message and indicate that this was an error. ServicePackage.ServiceMessages.Add(ex.Message, MessageSeverity.Error); if (ex.InnerException != null) { ServicePackage.ServiceMessages.Add(ex.InnerException.Message, MessageSeverity.Error); } // Indicate that the operation was unsuccessful. ServicePackage.IsSuccessful = false; } return base.DescribeSchema(); }
public override void ProcessRequest(HttpContext context) { base.ProcessRequest(context); string entity = GetEntityName(context.Request.Path); // the only entity we support is "Books" if (string.Compare(entity, "books", true) != 0) { throw new HttpException(HttpErrorCode.NotFound, string.Format("Entity '{0}' not supported", entity)); } Book[] books = DataConnector.GetInstance().GetAllBooks(); StringBuilder sb = new StringBuilder(XML_HEADER); sb.Append("<books>"); foreach (var b in books) { sb.Append(b.AsXml()); } sb.Append("</books>"); throw new HttpException(HttpErrorCode.Forbidden, "My Test Description"); context.Response.StatusCode = 201; context.Response.StatusDescription = "WOOHOO"; context.Response.Write(sb.ToString()); context.Response.Flush(); }
internal int AddRestriction(Restriction restriction) { int ID = 0; foreach (Restriction r in Restrictions) { if (r.ID >= ID) { ID = r.ID + 1; } } restriction.ID = ID; Dictionary <string, dynamic> restrictionData = new Dictionary <string, dynamic> { { "RestrictionID", restriction.ID }, { "Locale", restriction.ISO_3166_1 }, { "Certification", restriction.Certification }, { "Description", restriction.Description }, { "Sequence", restriction.Order } }; return(DataConnector.InsertData("Restrictions", restrictionData)); }
public void AddFee(IProcessExecutionContext executionContext, IWorkSession session, IFee fee, decimal quantity = 1) { try { // check to see if the related fee is already in the list. If so we will update that item rather than create // a new one. var transactionFee = FeeList.Where(r => r.Fee.Id == fee.Id).FirstOrDefault(); if (transactionFee is null) { var transactionFeeRecord = DataConnector.CreateTransactionFee( executionContext.DataService, Transaction, fee as IRecordPointer <Guid>, fee.Name, quantity); transactionFee = new TransactionFee(transactionFeeRecord, fee); FeeList.Add(transactionFee); } else { transactionFee.IncrementQuantity(quantity); } var priceCalculator = PriceCalculatorFactory.CreatePriceCalculator(executionContext, session, Transaction); transactionFee.CalculatePrice(executionContext, priceCalculator); DataConnector.UpdateTransactionFee(executionContext.DataService, transactionFee); } catch (Exception ex) { throw ex; } }
public void getDBConnector_typeEntityReturn() { var SUT = DataConnector.getDBConnector(null, EDataConnector.Entity); SUT.Should().NotBeOfType <SQLiteDataAccess>(); SUT.Should().BeOfType <EntityFwDataAccess>(); }
/// <summary> /// Describes the schema of the underlying data and services to the K2 platform. /// </summary> /// <returns>A string containing the schema XML.</returns> public override string DescribeSchema() { try { // Makes better use of resources and avoids any unnecessary open connections to data sources. using (DataConnector connector = new DataConnector(this)) { // Get the configuration from the service instance. connector.GetConfiguration(); // Set the type mappings. connector.SetTypeMappings(); // Describe the schema. connector.DescribeSchema(); // Set up the service instance. connector.SetupService(); } // Indicate that the operation was successful. ServicePackage.IsSuccessful = true; } catch (Exception ex) { // Record the exception message and indicate that this was an error. ServicePackage.ServiceMessages.Add(ex.Message, MessageSeverity.Error); if (ex.InnerException != null) { ServicePackage.ServiceMessages.Add(ex.InnerException.Message, MessageSeverity.Error); } // Indicate that the operation was unsuccessful. ServicePackage.IsSuccessful = false; } return(base.DescribeSchema()); }
public ITransactionFeeList CreateFeeList(IProcessExecutionContext executionContext, ITransaction transaction) { try { if (executionContext is null) { throw new ArgumentNullException("executionContext"); } if (transaction is null) { throw new ArgumentNullException("transaction"); } IList <ITransactionFee> transactionFees = new List <ITransactionFee>(); var transactionFeeRecords = DataConnector.GetTransactionFees(executionContext.DataService, transaction); foreach (var r in transactionFeeRecords) { var fee = r.Fee != null?DataConnector.GetFeeById(executionContext.DataService, r.Fee) : null; transactionFees.Add(new TransactionFee(r, fee)); } return(new TransactionFeeList(this.DataConnector, this.PriceCalculatorFactory, transaction, transactionFees)); } catch (Exception ex) { throw ex; } }
private IList <IRequirement> getRequirements(IProcessExecutionContext executionContext, bool useCache) { try { IList <IRequirement> registeredRequirements = new List <IRequirement>(); var requirements = DataConnector.GetAllRequirements(executionContext.DataService); var waiverRoles = DataConnector.GetAllRequirementWaiverRoles(executionContext.DataService); foreach (var requirement in requirements) { ILogicEvaluatorType evaluatorType = this.EvaluatorTypeFactory.BuildEvaluatorType(executionContext, requirement.EvaluatorTypeId, useCache); registeredRequirements.Add( RequirementFactory.CreateRequirement( executionContext, requirement as IRecordPointer <Guid>, requirement.Name, requirement.TypeFlag ?? eRequirementTypeFlags.Validation, requirement.TransactionTypeId, evaluatorType, requirement.RequirementParameters, waiverRoles.Where(r => r.TransactionRequirementId != null && r.TransactionRequirementId.Id == requirement.Id).Select(r => r.RoleId), useCache)); } return(registeredRequirements); } catch (Exception) { throw; } }
/// <summary> /// Returns all registered <see cref="ITransactionProcess"/> items in the system. Each item is fully configured with all associated /// <see cref="IProcessStep"/> items. /// </summary> /// <param name="executionContext"></param> /// <param name="cacheTimeout"></param> /// <returns></returns> private IList <ITransactionProcess> getProcesses(IProcessExecutionContext executionContext, bool useCache) { try { IList <ITransactionProcess> registeredProceses = new List <ITransactionProcess>(); var processes = DataConnector.GetAllTransactionProcesses(executionContext.DataService); executionContext.Trace("Retrieved {0} Transaction Process records.", processes.Count); var processSteps = getProcessSteps(executionContext, useCache); foreach (var process in processes) { executionContext.Trace("Building Transaction Process {0}", process.Name); var steps = processSteps.Where(s => s.TransactionProcessPointer.Id == process.Id); registeredProceses.Add( this.TransactionProcessFactory.CreateTransactionProcess( executionContext, process, process.Name, process.TransactionTypeId ?? throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessInvalid), process.InitialProcessStepId ?? throw TransactionException.BuildException(TransactionException.ErrorCode.ProcessInvalid), steps, useCache)); } return(registeredProceses); } catch (Exception) { throw; } }
public IPrinterResponse SignInCashier(ICashier ch) { string id = ch.Id; if (File.Exists(cashierLog)) { id = IOUtil.ReadAllText(cashierLog).Trim(); cashier = DataConnector.FindCashierById(id); if (id == ch.Id) { cashier = ch; return(toResponse); } else if (id != "") { throw new CashierAlreadyAssignedException("already assigned", id); } } StartCurrentLog(2000); IOUtil.WriteAllText(cashierLog, ch.Id); guiDocument.AddLines(Logo); guiDocument.AddLines(Formatter.FormatReceiptHeader("FÝÞ", currentDocumentId)); guiDocument.AddLines(Formatter.FormatInfo(String.Format("KASÝYER : {0} {1}", ch.Id, ch.Name).PadRight(40))); guiDocument.AddLines(Formatter.FormatInfo("GÝRÝÞ".PadRight(40))); guiDocument.AddLine(""); guiDocument.AddLines(Formatter.FormatEnd()); cashier = ch; return(toResponse); }
public void TestSetup() { var mockPDFManager = new Mock <IPDFManager>(); getPDFFieldsResponse = new List <PDFField>() { new PDFField() { Name = "VOAFieldOne" }, new PDFField() { Name = "VOAFieldTwo" }, new PDFField() { Name = "VOAFieldThree" } }; mockPDFManager.Setup(x => x.GetPDFields(String.Empty, String.Empty)).ReturnsAsync(getPDFFieldsResponse); FileNameManager fileNameManager = new FileNameManager(); DataManager dataManager = new DataManager(null, null); DataConnector <IVOAType> dataConnector = new DataConnector <IVOAType>(); mainWindowViewModel = new MainWindowViewModel(mockPDFManager.Object, new IOManager(fileNameManager), fileNameManager, dataManager, dataConnector, new CSVManager(new CSVRepository(), new IOManager(new FileNameManager()))); mainWindowViewModel.Prefix = ""; mainWindowViewModel.TemplatePath = ""; }
// Busca o nome do vendedor no SQL Server private static String ObterNomeVendedor(DataConnector connector, ContractDTO contract) { SalesPersonDAO salesPersonDAO = new SalesPersonDAO(connector.SqlServerConnection); String nomeVendedor = salesPersonDAO.GetSalespersonName(contract.vendedor); return(nomeVendedor); }
public JsonResult GetSummary(Models.FlightPlan plan) { var chartTypes = DataConnector.GetChartTypes(); var response = OperationProcessor.GetFlightPlanSummary(plan); return(Json(response, JsonRequestBehavior.AllowGet)); }
private static Boolean AreContractsActive(DataConnector connector, MailingDTO mailing) { Boolean active; ContractDAO contractDAO = new ContractDAO(connector.MySqlConnection); ContractItemDAO contractItemDAO = new ContractItemDAO(connector.MySqlConnection); // Faturamento de um contrato apenas if (mailing.codigoContrato != 0) { ContractDTO contract = contractDAO.GetContract(mailing.codigoContrato); active = (contract.status != 3) && (contract.status != 4); return(active); } // Caso contrário é o faturamento de todos os equipamentos do cliente (um ou mais contratos) active = false; List <ContractItemDTO> itemList = contractItemDAO.GetItems("businessPartnerCode = '" + mailing.businessPartnerCode + "'"); foreach (ContractItemDTO item in itemList) { ContractDTO contract = contractDAO.GetContract(item.contrato_id); if ((contract.status != 3) && (contract.status != 4)) { active = true; } } return(active); }
public ITransactionContext CreateTransactionContext(IProcessExecutionContext executionContext, IRecordPointer <Guid> transactionContextId, bool useCache = true) { useCache = useCache && executionContext.Cache != null; string cacheKey = null; if (useCache) { cacheKey = CACHE_KEY + transactionContextId.Id.ToString(); if (executionContext.Cache.Exists(cacheKey)) { return(executionContext.Cache.Get <ITransactionContext>(cacheKey)); } } var record = DataConnector.GetTransactionContextRecord(executionContext.DataService, transactionContextId); var customer = CustomerFactory.CreateCustomer(executionContext, record.CustomerId, useCache); var transactionContext = new TransactionContext(record, customer); if (useCache) { var settings = SettingsFactory.CreateSettings(executionContext.Settings); var cacheTimeout = settings.TransactionContextCacheTimeout; executionContext.Cache.Add <ITransactionContext>(cacheKey, transactionContext, cacheTimeout.Value); } return(transactionContext); }
/// <summary> /// Extracts data from a data source and copies it into Excel. The information starts at cell A1 and /// is not formatted /// </summary> /// <param name="SQLQuery">The filter to be applied</param> public void generateReport(string SQLQuery) { DataConnector myHandler = new DataConnector(); DataSet myRecords = new DataSet(); switch (m_conType) { case "ADO": System.Data.OleDb.OleDbConnection dataConn = new System.Data.OleDb.OleDbConnection(m_connString); myRecords = myHandler.getDataSetViaSQL(SQLQuery, "ReportRecords", dataConn); break; case "SQL": break; default: throw new System.Exception("The reporting system cannot connect to a data source via " + m_conType + "."); } if (myRecords.Tables.Count != 1) { throw new System.Exception("The connection details supplied has not returned a valid connection."); } myRecords.WriteXml(m_targetPath); }
public Pimp() { _mongoConnector = DataConnector.Instance; _localChangeset = 1; const string connectionString = "Initial Catalog=osmdb;Data Source=Hecarim\\MainServer;Integrated Security=true;"; _db = new SqlConnection(connectionString); }
public void ArchiveHistoryForStep(IProcessExecutionContext executionContext, IWorkSession session, IProcessStep processStep, bool isRolledBack = false) { var historyRecord = GetHistoryForStep(processStep) as StepHistory; var statusCode = isRolledBack ? eProcessStepHistoryStatusEnum.RolledBack : eProcessStepHistoryStatusEnum.Archived; historyRecord.StepStatus = statusCode; DataConnector.UpdateStepHistoryStatus(executionContext.DataService, historyRecord, statusCode); }
public static void Register <TElement, TFieldType>(Connector <TFieldType, TValue> connector) where TElement : BaseField <TFieldType>, INotifyValueChanged <TFieldType> { var updater = new DataConnector <TElement, TFieldType>(connector); m_AvailableTranslators.Add(updater); Connectors.Register(typeof(TValue), updater); }
/// <summary> /// This method deletes a 'Method' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'Method' to delete. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject DeleteMethod(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Delete StoredProcedure DeleteMethodStoredProcedure deleteMethodProc = null; // verify the first parameters is a(n) 'Method'. if (parameters[0].ObjectValue as Method != null) { // Create Method Method method = (Method)parameters[0].ObjectValue; // verify method exists if (method != null) { // Now create deleteMethodProc from MethodWriter // The DataWriter converts the 'Method' // to the SqlParameter[] array needed to delete a 'Method'. deleteMethodProc = MethodWriter.CreateDeleteMethodStoredProcedure(method); } } // Verify deleteMethodProc exists if (deleteMethodProc != null) { // Execute Delete Stored Procedure bool deleted = this.DataManager.MethodManager.DeleteMethod(deleteMethodProc, dataConnector); // Create returnObject.Boolean returnObject.Boolean = new NullableBoolean(); // If delete was successful if (deleted) { // Set returnObject.Boolean.Value to true returnObject.Boolean.Value = NullableBooleanEnum.True; } else { // Set returnObject.Boolean.Value to false returnObject.Boolean.Value = NullableBooleanEnum.False; } } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } // return value return(returnObject); }
internal static List <SelectListItem> GetChartTypes() { var chartTypes = DataConnector.GetChartTypes(); chartTypes.Insert(0, new SelectListItem { Value = "-1", Text = "-Chart Type-" }); return(chartTypes); }
internal int AddGenre(Genre genre) { Dictionary <string, dynamic> genreData = new Dictionary <string, dynamic> { { "GenreID", genre.ID }, { "Genre", genre.Name } }; return(DataConnector.InsertData("Genres", genreData)); }
public IWorkSession GenerateSession(IProcessExecutionContext executionContext, ISystemUser systemUser, bool useCache = true) { IAgent agent = AgentFactory.BuildAgent(executionContext, systemUser); //temporary implementation until data structures are in place to link a user to a location and channel. IChannel channel = this.GetChannels(executionContext).FirstOrDefault(); //Temporary ILocation location = DataConnector.GetLocationRecords(executionContext.DataService).FirstOrDefault(); //Temporary return(new WorkSession(agent, channel, location, null, null, null, null)); }
internal static List <SelectListItem> GetICaoCodes() { var codes = DataConnector.GetICAOCodes(); codes.Insert(0, new SelectListItem { Value = "-1", Text = "-Select-" }); return(codes); }
internal int AddMovie(Movie movie) { int result = 0; int ID = 0; foreach (Movie m in Movies) { if (m.ID >= ID) { ID = m.ID + 1; } } movie.ID = ID; Dictionary <string, dynamic> movieData = new Dictionary <string, dynamic> { { "MovieID", movie.ID }, { "Title", movie.Title }, { "Release Date", movie.ReleaseDate.ToString("yyyy-MM-dd") }, { "Price", movie.Price }, { "Poster", movie.Poster }, { "IMDbID", movie.IMDbID }, { "IMDbRating", movie.IMDbRating } }; DataConnector.InsertData("Movies", movieData); foreach (Restriction r in movie.Restrictions) { Dictionary <string, dynamic> movieRestData = new Dictionary <string, dynamic> { { "MovieID", movie.ID }, { "RestrictionID", r.ID } }; DataConnector.InsertData("MovieRestrictions", movieRestData); } foreach (Genre g in movie.Genres) { Dictionary <string, dynamic> movieGenreData = new Dictionary <string, dynamic> { { "MovieID", movie.ID }, { "GenreID", g.ID } }; DataConnector.InsertData("MovieGenres", movieGenreData); } return(result); }
/// <summary> /// This method finds a 'Method' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'Method' to delete. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject FindMethod(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // locals Method method = null; // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Find StoredProcedure FindMethodStoredProcedure findMethodProc = null; // verify the first parameters is a 'Method'. if (parameters[0].ObjectValue as Method != null) { // Get MethodParameter Method paramMethod = (Method)parameters[0].ObjectValue; // verify paramMethod exists if (paramMethod != null) { // Now create findMethodProc from MethodWriter // The DataWriter converts the 'Method' // to the SqlParameter[] array needed to find a 'Method'. findMethodProc = MethodWriter.CreateFindMethodStoredProcedure(paramMethod); } // Verify findMethodProc exists if (findMethodProc != null) { // Execute Find Stored Procedure method = this.DataManager.MethodManager.FindMethod(findMethodProc, dataConnector); // if dataObject exists if (method != null) { // set returnObject.ObjectValue returnObject.ObjectValue = method; } } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } } // return value return(returnObject); }
public ObservableCollection <Project> GetRMSISProjects() { DataConnector dc = new DataConnector(); List <Project> project = dc.GetProjectList(); if (projectData == null) { projectData = new ObservableCollection <Project>(); } project.ForEach(x => projectData.Add(x)); return(projectData); }
/// <summary> /// This method finds a 'Adverb' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'Adverb' to delete. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject FindAdverb(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // locals Adverb adverb = null; // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Find StoredProcedure FindAdverbStoredProcedure findAdverbProc = null; // verify the first parameters is a 'Adverb'. if (parameters[0].ObjectValue as Adverb != null) { // Get AdverbParameter Adverb paramAdverb = (Adverb)parameters[0].ObjectValue; // verify paramAdverb exists if (paramAdverb != null) { // Now create findAdverbProc from AdverbWriter // The DataWriter converts the 'Adverb' // to the SqlParameter[] array needed to find a 'Adverb'. findAdverbProc = AdverbWriter.CreateFindAdverbStoredProcedure(paramAdverb); } // Verify findAdverbProc exists if (findAdverbProc != null) { // Execute Find Stored Procedure adverb = this.DataManager.AdverbManager.FindAdverb(findAdverbProc, dataConnector); // if dataObject exists if (adverb != null) { // set returnObject.ObjectValue returnObject.ObjectValue = adverb; } } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } } // return value return(returnObject); }
/// <summary> /// Sets up the required configuration parameters in the service instance. When a new service instance is registered for this ServiceBroker, the configuration parameters are surfaced to the appropriate tooling. The configuration parameters are provided by the person registering the service instance. /// </summary> /// <returns>A string containing the configuration XML.</returns> public override string GetConfigSection() { try { // Makes better use of resources and avoids any unnecessary open connections to data sources. using (DataConnector connector = new DataConnector(this)) { // Set up the required parameters in the service instance. connector.SetupConfiguration(); } } catch (Exception ex) { // Record the exception message and indicate that this was an error. ServicePackage.ServiceMessages.Add(ex.Message, MessageSeverity.Error); } return base.GetConfigSection(); }
private DriveController() { DataConnector = new DatabaseMSSQLCE.MsSqlCeAdoConnector(); SetEditWindows(); }
/// <summary> /// Executes the Service Object method and returns any data. /// </summary> public override void Execute() { try { // Makes better use of resources and avoids any unnecessary open connections to data sources. using (DataConnector connector = new DataConnector(this)) { // Get the configuration from the service instance. connector.GetConfiguration(); // Get the populated Service Object definition. ServiceObject serviceObject = Service.ServiceObjects[0]; // Get the method to execute. Method method = serviceObject.Methods[0]; // InputProperties and ReturnProperties are string collections, create property collections for later ease-of-use. Property[] inputs = new Property[method.InputProperties.Count]; Property[] returns = new Property[method.ReturnProperties.Count]; for (int i = 0; i < method.InputProperties.Count; i++) { inputs[i] = serviceObject.Properties[method.InputProperties[i]]; } for (int i = 0; i < method.ReturnProperties.Count; i++) { returns[i] = serviceObject.Properties[method.ReturnProperties[i]]; } // Execute the Service Object method and return any data. connector.Execute(inputs, method.Validation.RequiredProperties, returns, method.Type, serviceObject); } // Indicate that the operation was successful. ServicePackage.IsSuccessful = true; } catch (Exception ex) { // Record the exception message and indicate that this was an error. ServicePackage.ServiceMessages.Add(ex.Message, MessageSeverity.Error); // Indicate that the operation was unsuccessful. ServicePackage.IsSuccessful = false; } }