Пример #1
0
        public static TmsStoreCallbackDelegate Callback(Mpos mpos, bool forceUpdate, TaskCompletionSource <bool> source)
        {
            return(GCHelper.ManualFree <TmsStoreCallbackDelegate>(releaseGC =>
            {
                return (version, capkList, aidList, appList, riskProfileList, acquirerList, userData) =>
                {
                    releaseGC();

                    var instance = new TmsStoreCallback()
                    {
                        capkList = capkList,
                        aidList = aidList,
                        appList = appList,
                        riskProfileList = riskProfileList,
                        acquirerList = acquirerList
                    };

                    return instance.insertDataIntoStorage(mpos, forceUpdate, source, version);
                };
            }));
        }
Пример #2
0
        private Error processTables(Mpos mpos, bool forceUpdate, TaskCompletionSource <bool> source)
        {
            var tmsCallback = TmsStoreCallback.Callback(mpos, forceUpdate, source);

            ApiHelper.GetTerminalTables(mpos.EncryptionKey, !forceUpdate ? mpos.TMSStorage.GetGlobalVersion() : "", keyList)
            .ContinueWith(t =>
            {
                if (t.Status == TaskStatus.Faulted)
                {
                    source.SetException(t.Exception);
                    return;
                }

                if (t.Result.Length > 0)
                {
                    try
                    {
                        var error = TmsGetTables(t.Result, t.Result.Length, tmsCallback, IntPtr.Zero);
                        if (error != Error.Ok)
                        {
                            throw new MposException(error);
                        }
                    }
                    catch (Exception e)
                    {
                        source.SetException(e);
                    }
                }

                else
                {
                    // We don't need to do anything; complete operation.
                    mpos.OnTableUpdated(false, 0);
                    source.SetResult(true);
                }
            });

            return(Error.Ok);
        }