コード例 #1
0
        public static void OnSynchTimerTick(object state)
        {
            LogableTask task = LogableTask.NewTask("Update terminal Details");

            try
            {
                UpdateTerminalDetails(task);
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, ex);
            }
            finally { task.EndTask(); }

            task = LogableTask.NewTask("Synch data");
            try
            {
                UpdateSadadaData(task);
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, ex);
            }
            finally { task.EndTask(); }
        }
コード例 #2
0
        public void SetStartUpData(StartUpData req)
        {
            LogableTask task = LogableTask.NewTask("SetStartupData");

            try
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "Session started, TSN = " + req.TSN);

                if (req.ReuseSession == false)
                {
                    UserSession.CurrentSession = new UserSession();

                    UserSession.CurrentSession.Language = req.Lang == "eng" ? Language.Eng : Language.Ara;
                    task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "language set as " + UserSession.CurrentSession.Language);
                    SessionController.MachineID    = UserSession.CurrentSession.MachineID = req.MachineID;
                    UserSession.CurrentSession.PAN = req.PAN;
                    var token = GetRequesterAuthorizer(req.PAN);
                    UserSession.CurrentSession.Requester   = token.Data.requester;
                    UserSession.CurrentSession.Authorizer  = token.Data.authorizer;
                    UserSession.CurrentSession.SessionData = new List <KeyValuePair <string, string> >();
                }
                else
                {
                    task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "Reusing session");
                }

                UserSession.CurrentSession.TSN = req.TSN;
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Error, ex);
            }
            finally { task.EndTask(); }
        }
コード例 #3
0
        public bool QRImageLoaded(SingleFieldRequest <string> request)
        {
            var task = LogableTask.NewTask("QRImageLoaded");

            try
            {
                ShowTimeOut = false;

                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "received request");

                ServerHelper.GetResponse <string>("MobileCash/" + MethodBase.GetCurrentMethod().Name, request, false);
                var startTimeSpan  = TimeSpan.Zero;
                var periodTimeSpan = TimeSpan.FromSeconds(3);

                this.FindTrx = new System.Threading.Timer((e) =>
                {
                    if (this.ElapsedDisplayTime > this.TotalQRCodeDisplayTime)
                    {
                        this.FindTrx.Dispose();
                        //navigate to error
                    }
                    else
                    {
                        StagedTrxDetails getQRTrxDetails = this.GetQRTrxDetails(new SingleFieldRequest <string>
                        {
                            Data = request.Data
                        });

                        if (getQRTrxDetails.TrxFound)
                        {
                            Console.WriteLine(getQRTrxDetails.TrxFound);
                            this.Amount = getQRTrxDetails.Amount;
                            this.RefNo  = getQRTrxDetails.refNo;


                            navigationManager.NavigateTo(STCPayUrls.ShowTrxDetailsPageUrl);

                            this.FindTrx.Dispose();
                        }

                        else
                        {
                            this.ElapsedDisplayTime = this.ElapsedDisplayTime + 3;
                        }
                    }
                }
                                                          , null, startTimeSpan, periodTimeSpan);

                return(true);
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Error, ex);
                return(false);
            }
            finally
            { task.EndTask(); }
        }
コード例 #4
0
        /// <summary>
        /// throws (WebException e) when (e.Status == WebExceptionStatus.Timeout)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="subUrl"></param>
        /// <param name="request"></param>
        /// <param name="task"></param>
        /// <returns></returns>
        public static Response <T> GetResponse <T>(string subUrl, BaseTerminalRequest request, bool waitForCustomerDetails = true)
        {
            LogableTask task = LogableTask.NewTask("Posting to " + subUrl);

            try
            {
                if (waitForCustomerDetails)
                {
                    if (UserSession.CurrentSession.CustomerDetailsStatus.WaitOne(1000 * 150) == false)
                    {
                        task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, "wait of 150 sec expired for customer details ");
                    }

                    if (UserSession.CurrentSession.CustomerDetailsResponse == null)
                    {
                        task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, "CustomerDetailsResponse is null");
                        return(new Response <T>
                        {
                            Success = false,
                            ErrorCode = "Exception",
                            ErrorDesc = "UserSession.CurrentSession.CustomerDetailsResponse is null"
                        });
                    }

                    if (UserSession.CurrentSession.CustomerDetailsResponse.Success == false)
                    {
                        task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error,
                                 "customer details was failed. " + UserSession.CurrentSession.CustomerDetailsResponse.ErrorDesc);
                        return(new Response <T>
                        {
                            Success = false,
                            ErrorCode = UserSession.CurrentSession.CustomerDetailsResponse.ErrorCode,
                            ErrorDesc = UserSession.CurrentSession.CustomerDetailsResponse.ErrorDesc
                        });
                    }
                }
                request.CommonParams = ServerHelper.GetCommonParameters();
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "sending req to " + subUrl);

                return(GetResponse <T>(subUrl, request, task));
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, ex);
                throw ex;
            }
            finally { task.EndTask(); }
        }
コード例 #5
0
        public bool SendingDispenseReq([FromBody] SingleFieldRequest <string> request)
        {
            var task = LogableTask.NewTask("SendingDispenseReq");

            try
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "received request");

                ServerHelper.GetResponse <string>("MobileCash/" + MethodBase.GetCurrentMethod().Name, request, false);
                return(true);
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Error, ex);
                return(false);
            }
            finally
            { task.EndTask(); }
        }
コード例 #6
0
        public StagedTrxDetails GetQRTrxDetails(SingleFieldRequest <string> qrCodeSeqNoReq)
        {
            var task = LogableTask.NewTask("GetQRTrxDetails");

            try
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "received request");

                var trxDetails = ServerHelper.GetResponse <StagedTrxDetails>("MobileCash/" + MethodBase.GetCurrentMethod().Name,
                                                                             new SingleFieldRequest <string> {
                    Data = qrCodeSeqNoReq.Data
                }, false);

                if (trxDetails.Success && trxDetails.Data.HasError == false)
                {
                    if (trxDetails.Data.TrxFound)
                    {
                        UserSession.CurrentSession.QRCodeSeqNo = trxDetails.Data.SeqNo;
                    }

                    return(trxDetails.Data);
                }
                else
                {
                    return new StagedTrxDetails
                           {
                               TrxFound = false
                           }
                };
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Error, ex);
                return(new StagedTrxDetails
                {
                    TrxFound = false
                });
            }

            finally
            { task.EndTask(); }
        }
コード例 #7
0
        public void SetCommonParams(SetCommonParamsReq req)
        {
            LogableTask task = LogableTask.NewTask("SetCommonParams");

            try
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Info, "called");
                if (req.SetCustNum)
                {
                    UserSession.CurrentSession.CustNum = req.CustNum;
                }

                if (req.SetPAN)
                {
                    UserSession.CurrentSession.PAN = req.PAN;
                }
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), TraceLevel.Error, ex);
            }
            finally { task.EndTask(); }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            DebugLog("Starting");
            if (Debugger.IsAttached == false)
            {
                var pathToExe         = Process.GetCurrentProcess().MainModule.FileName;
                var pathToContentRoot = Path.GetDirectoryName(pathToExe);
                Directory.SetCurrentDirectory(pathToContentRoot);
                DebugLog("Set Current Dir as " + pathToContentRoot);
            }

            Program.textLogWriter = new TextLogWriter();
            DebugLog("Creating logs at " + Environment.CurrentDirectory + "\\Logs");

            Program.textLogWriter.InitializeLogWriter(System.Environment.CurrentDirectory + "\\Logs", "ConceptsClient", false, true, true, true);
            LogableTask task = LogableTask.NewTask("Main");

            try
            {
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "Starting app");
                appSettings = JsonConvert.DeserializeObject <appSettingsDTO>(System.IO.File.ReadAllText(System.Environment.CurrentDirectory + "\\ConceptsClient.json"));

                appSettings.ServerUrl = string.Format(appSettings.ServerUrl, appSettings.Server);
                if (Program.appSettings.ServerUrl.EndsWith('/') == false && Program.appSettings.ServerUrl.EndsWith('\\') == false)
                {
                    appSettings.ServerUrl += "/";
                }

                //if (appSettings.LogsFolderPath == null || appSettings.LogsFolderPath == "")
                //    appSettings.LogsFolderPath = Startup.hostingEnvironment.ContentRootPath + "\\Logs";

                //textLogWriter.InitializeLogWriter(appSettings.LogsFolderPath, "ConceptsClient", false, true, true, true);


                var builder = CreateWebHostBuilder(args);
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "web host builder created");

                builder.UseKestrel().UseIISIntegration();
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "going to use URL " + appSettings.LocalUrl);

                //    builder.UseUrls("http://0.0.0.0:82");


                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "useUrls set");

                //   if (Debugger.IsAttached == false)// that is running as windows service
                //   builder.UseContentRoot(System.Environment.CurrentDirectory);


                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "Content root set as " + Environment.CurrentDirectory);

                var host = builder.Build();
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "Host built now. Run as Service =" + appSettings.RunAsService);

                if (appSettings.RunAsService)
                {
                    task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "Host starting as windows service");
                    task.EndTask();
                    // host.RunAsCustomService();// host.RunAsService();
                }
                else
                {
                    task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Info, "Host starting now as process");
                    task.EndTask();
                    host.Run();
                }
            }
            catch (Exception ex)
            {
                task.Log(MethodBase.GetCurrentMethod(), System.Diagnostics.TraceLevel.Error, ex);
            }
            finally
            {
                if (task.ended == false)
                {
                    task.EndTask();
                }
            }
        }