Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Get Closed Check Details in Simphony / Micros extensibility using C#

Status
Not open for further replies.

Vikram Singh

Programmer
Jan 3, 2018
39
KW
Hello Experts,

How I can get [highlight #FCE94F]closed check details for a selected check number[/highlight].

I have tried OpsContext.DataStore . But I can't find any reading method for getting the check details.
please help

 
The OpsContext.DataStore is more an abstraction over the database, so you would probably be better of making the SQL queries directly to the database.

If you do this from an extension application, you can new up a database connection with the EMC.Data.Sql.DatabaseConnection type, then you don't need to worry about credentials.

We typically encapsulate this in a factory, so it easily can be swapped out with a static SQL DB Connection, when debugging the extension outside of Simphony, or what ever the need is.


Code:
using System.Data;
using Contracts.Factories;
using SimphonyUtilities.Settings;

namespace Factories.DatabaseConnection
{
    public class SimphonyDbConnectionFactory : IDbConnectionFactory
    {
        private readonly DatabaseSettings _databaseSettings;

        public SimphonyDbConnectionFactory()
        {
            _databaseSettings = DatabaseSettings.GetDbSettingsSafe(DatabaseSettings.DatabaseAlias.Master);
        }

        public string DataStore => DatabaseSettings.GetDbSettingsSafe(DatabaseSettings.DatabaseAlias.LocalDb).DBCatalog;

        public string CheckPostingDB => DatabaseSettings.GetDbSettingsSafe(DatabaseSettings.DatabaseAlias.CPServiceDb).DBCatalog;

        public bool CheckPostingDbExists => DatabaseSettings.CheckDbSettingsExist(DatabaseSettings.DatabaseAlias.CPServiceDb);

        public IDbConnection CreateConnection() => new EMC.Data.Sql.DatabaseConnection(_databaseSettings).Connection as System.Data.Common.DbConnection;
    }
}


However, I would always recommend reading check details through the POS API, since the POS API will then handle splits, reopen, voided items, and so on - doing that in SQL is just a mess.

You can use the GetCheckDetail call for this, see more in the Transaction Services API documentation link, it returns nicely formatted XML data.

But the sql query approach works fine to get information about the checks that should be read.


 
Thank you very much for the sample code. I'm trying this code from the [highlight #FCE94F]POS[/highlight] to read [highlight #FCE94F]Datastore database[/highlight] but I'm getting a null screenshot attached could you please guide me with example to read data from Datastore in POS
Capture_ylzuua.png
 
I've made a simple Extension Application Demo project at Github - you should be able to run it within Simphony using Visual Studio and follow the overall logic.

The project can be found here Link

I still think that you would be better of using the above project to get information about which checks to export, and then use the Simphony API to perform the actual export.
 
Thank you very much for the code it is working fine. Really this is very useful code for me.
Once again Thank you very much, Martin[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top