Jump to content

Cookie or Message for "credits finishing" ?


SergioFeitoza

Recommended Posts

I have a service with an Unigui code in which  users pay a small amount to use a calculations code  in the browser.

I want to implement something to inform  automatically  30 minutes before  the end of the creditst that they will expire 

I want also to something that, if the credit went to zero (after those 30 minutes) , 5 minutes after the   service is interrupted (Close with a message)

Do you have any small code or sample to do this?   Ideas are welcome

Link to comment
Share on other sites

2 hours ago, SergioFeitoza said:

I have a service with an Unigui code in which  users pay a small amount to use a calculations code  in the browser.

I want to implement something to inform  automatically  30 minutes before  the end of the creditst that they will expire 

I want also to something that, if the credit went to zero (after those 30 minutes) , 5 minutes after the   service is interrupted (Close with a message)

Do you have any small code or sample to do this?   Ideas are welcome

Hi, I have a function in timer that send to Client Message 2 minutes before session timeout expired.

If You think can use it:

 

procedure TUniForm1.DlgMsgCallBack1 (Sender: TComponent; Res: Integer);
begin
    UniMainModule.StillThereAsked := False;
end;//case

procedure TUniForm1.UniTimer1Timer(Sender: TObject);
var
    I,
    WaitStill   : Integer;
begin

//This: send MessageDlg  for client and wait answer every "AskStillThereEveryMin" minutes :

Inc (UniMainModule.WaitForStillThere);

TryStrToInt (UniServerModule.SistemSettingsList.Values ['AskStillThereEveryMin'],WaitStill);
If (WaitStill > 0)
AND ((UniMainModule.WaitForStillThere) >= WaitStill*60)
AND (not UniMainModule.StillThereAsked)
then begin
      UniMainModule.WaitForStillThere := 0;
      UniMainModule.StillThereAsked := True;
      uniGUIDialogs.MessageDlg ('Are You still there ?',mtConfirmation, [mbOK], DlgMsgCallBack1);

end;

 

//this: closes the session at the exact time of the day. Office - closed

//If enabled time to closed office
if (AnsiUPPERCase (UniServerModule.SistemSettingsList.Values ['CloseOnTime']) <> '') then begin
    if FormatDateTime ('HH:mm:ss',Now,UniServerModule.MySettings) = UniServerModule.SistemSettingsList.Values ['CloseOnTime'] then begin
        //close all sessions
        Try
          //UniServerModule.SessionManager.Sessions.Lock;
          for I :=UniServerModule.SessionManager.Sessions.SessionList.Count - 1 downto 0 do begin
              U := UniServerModule.SessionManager.Sessions.SessionList[I];
              //U.LockSession;
              // Check mainModule availability. Some sessions may not have a MainModule instance
              if U.UniMainModule <> nil then begin
                // Do not close my OWN Session
                //if (UniApplication.UniSession.SessionID <> U.SessionId)
                //AND ((U.UniMainModule as TUniMainModule).sUserName = sesionUser)
                //then begin
                   // LogOutUser ( (U.UniMainModule as TUniMainModule).sTermID, (U.UniMainModule as TUniMainModule).sUsername);
                   UniTimer1.Enabled := False;
                   TRY
                     U.LockSession;
                     U.ReleaseSession;
                     U.Terminate ('End of Work
                                  + '</br>'
                                  + 'Your Credit is over.'
                                  );
                  FINALLY
                     U.UnBusy;
                  END;

                //end;
                 // UniMainModule(U.UniMainModule as TUniMainModule).logout ((U.UniMainModule as TUniMainModule).sUsername); // Access custom MainModule props
              end;
          end;
          //UniServerModule.SessionManager.Sessions.Unlock;
        Finally

        End;
        
    end;
end;

end

 

 

Link to comment
Share on other sites

7 minutes ago, irigsoft said:

Hi, I have a function in timer that send to Client Message 2 minutes before session timeout expired.

If You think can use it:

 

procedure TUniForm1.DlgMsgCallBack1 (Sender: TComponent; Res: Integer);
begin
    UniMainModule.StillThereAsked := False;
end;//case

procedure TUniForm1.UniTimer1Timer(Sender: TObject);
var
    I,
    WaitStill   : Integer;
begin

//This: send MessageDlg  for client and wait answer every "AskStillThereEveryMin" minutes :

Inc (UniMainModule.WaitForStillThere);

TryStrToInt (UniServerModule.SistemSettingsList.Values ['AskStillThereEveryMin'],WaitStill);
If (WaitStill > 0)
AND ((UniMainModule.WaitForStillThere) >= WaitStill*60)
AND (not UniMainModule.StillThereAsked)
then begin
      UniMainModule.WaitForStillThere := 0;
      UniMainModule.StillThereAsked := True;
      uniGUIDialogs.MessageDlg ('Are You still there ?',mtConfirmation, [mbOK], DlgMsgCallBack1);

end;

 

//this: close session on exat time of day. Office - Closed

//If enabled time to closed office
if (AnsiUPPERCase (UniServerModule.SistemSettingsList.Values ['CloseOnTime']) <> '') then begin
    if FormatDateTime ('HH:mm:ss',Now,UniServerModule.MySettings) = UniServerModule.SistemSettingsList.Values ['CloseOnTime'] then begin
        //close all sessions
        Try
          //UniServerModule.SessionManager.Sessions.Lock;
          for I :=UniServerModule.SessionManager.Sessions.SessionList.Count - 1 downto 0 do begin
              U := UniServerModule.SessionManager.Sessions.SessionList[I];
              //U.LockSession;
              // Check mainModule availability. Some sessions may not have a MainModule instance
              if U.UniMainModule <> nil then begin
                // Do not close my OWN Session
                //if (UniApplication.UniSession.SessionID <> U.SessionId)
                //AND ((U.UniMainModule as TUniMainModule).sUserName = sesionUser)
                //then begin
                   // LogOutUser ( (U.UniMainModule as TUniMainModule).sTermID, (U.UniMainModule as TUniMainModule).sUsername);
                   UniTimer1.Enabled := False;
                   TRY
                     U.LockSession;
                     U.ReleaseSession;
                     U.Terminate ('End of Work
                                  + '</br>'
                                  + 'Your Credit is over.'
                                  );
                  FINALLY
                     U.UnBusy;
                  END;

                //end;
                 // UniMainModule(U.UniMainModule as TUniMainModule).logout ((U.UniMainModule as TUniMainModule).sUsername); // Access custom MainModule props
              end;
          end;
          //UniServerModule.SessionManager.Sessions.Unlock;
        Finally

        End;
        
    end;
end;

end

 

 

Thank you very much  irigsoft

Your text seems to be what I need . 

I will adaptate it to my use

Thanks again

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...