Flynet Studio Code Generation Properties

TSCustomMethods - Custom Code

TSCustomMethods - Custom Code

Previous topic Next topic  

TSCustomMethods - Custom Code

Previous topic Next topic  

Contains the Custom Methods region for the TaskSession class.  The TaskSession class is the "work horse" for the screen integration activities and provides session management and a variety of supporting methods to manage a screen session.

 

The Custom Code properties are special code-oriented string properties with a dedicated editor and the capability for import/export functionality between the Tester GUI generations and the full application generation.

 

Inside the TaskSession class is a region named Custom Methods...if changed in a unit test solution, you can import or set this property so that the changes implemented in the test can be propagated to other tests or the complete web service solution (once regenerated).

 

Example of a stock (as initially generated) Custom Methods region:

 

 #region Custom Methods (Preserve)

 // All user-written code in this region is preserved during code generation, simplifying

 // any ongoing merge requirements

 

 /// <summary>

 /// As generated, returns false.

 /// If you check the active screen, you can detect if a special host "you have been timed out"

 /// or similar is displayed, end the screen and return true to run the HostLogon method.

 /// </summary>

 bool NeedHostLogon

 {

         get

         {

                 //TODO check active screen to determine if a HostLogon call is needed

                 return false;

         }

 }

 

 /// <summary>

 /// Creates a new Debug object constructing with a file name

 /// This is included in the Preserve section so that the file name can be customized

 /// to include user credentials such as UserID part of the logon...

 /// </summary>

 /// <param name="ioBag">For new, non-pooled connection, the keyField navigation field values.

 /// null for a pooled session</param>

 void DebugFactory(IOBag ioBag)

 {

         System.DateTime dt=System.DateTime.Now;

         //TODO if userid is in the ioBag, uncomment this code

         //and ensure userID fieldID reference is correct

         //        oConn.owner=ioBag[FieldID.Userid]; // Displays owner in admin console...:)

         //TODO replace Users with real userid parameter into the Dbg constructor to give unique logs to all users

         Dbg=new Debug(null,String.Format("{0}_{1}_{2,-14:HH:mm:ss:fff}","Users",dt.ToShortDateString(),dt));

 }

 /// <summary>

 /// ScreenIDsToInts is for recognition where a set of screenIDs is to be

 /// converted to an array of integers

 /// </summary>

 /// <param name="screenIDs">Array of ScreenID values</param>

 /// <returns>Array of integer values with system-wide screenid's possibly added, such

 /// as Abend or iSeries System Programming Error screens</returns>

 int[] ScreenIDsToInts(ScreenID[] screenIDs)

 {

         //TODO if iSeries, uncomment and comment-out or delete next line

         //int[] ids=new int[screenIDs.Length+2];

         int[] ids = new int[screenIDs.Length];

         int s;

         for (s = 0; s < screenIDs.Length; s++)

                 ids[s] = (int)screenIDs[s];

         //TODO if iSeries, uncomment following two lines and ensure you have screens

         //of the right name identified for the Program Messages and Signon Screens

         //ids[screenIDs.Length]=(int) ScreenID.PgmMessages;

         //ids[screenIDs.Length+1]=(int) ScreenID.SignOn;

         return ids;

 }

 

 /// <summary>

 /// AllowDefaultScreens set to false will cause a Console Alert if a default

 /// screen is displayed as well as an exception if a target screen is not 

 /// reached during navigation.

 /// </summary>

 public bool AllowDefaultScreens = false;

 /// <summary>

 /// CheckNavExceptions will send a Console Alert if the default (unrecognized screen)

 /// is displayed, requesting navigation to one of the requested screen ID's

 /// </summary>

 /// <param name="screenIDs">List of ScreenIDs, null for any</param>

 /// <returns>Result screenid</returns>

 public ScreenID CheckNavExceptions(ScreenID[] screenIDs)

 {

         bool IssueAlert=(!AllowDefaultScreens && (activeScreen == ScreenID.DefaultScreen));

         if (!IssueAlert &&

                  (screenIDs!=null))

         {

                 foreach(ScreenID id in screenIDs)

                 {

                         if (m_activeScreen==id)

                                 return id;

                 }

                 IssueAlert=true;

         }

         if (IssueAlert)

         {

                 string screenList;

                 if (screenIDs == null)

                         screenList = "*Any Recognized";

                 else

                 {

                         StringBuilder sb = new StringBuilder();

                         sb.Append(screenIDs[0].ToString());

                         int i;

                         for (i = 1; i < screenIDs.Length; i++)

                         {

                                 sb.Append(", " + screenIDs[i].ToString());

                         }

                         screenList = sb.ToString();

                 }

                 activeScreen = AlertNavigateDetailed(oScreen, Dbg, activeTaskID, "NextScreen", screenList);

                 if (screenIDs == null)

                 {

                         if (activeScreen != ScreenID.DefaultScreen)

                                 return activeScreen;

                 }

                 else

                 {

                         if (screenList.IndexOf(activeScreen.ToString()) != -1)

                                 return activeScreen;

                 }

                 throw new System.Exception("Expected Screen not found (" + screenList + "), Active Screen=" + oScreen.getScreenName());

         }

         //TODO if iSeries, uncomment following block

         //TODO if iSeries, ensure that the EndOfJob, PgmMessages and SignOn screens have definitions

         /*

         else if (activeScreen==ScreenID.PgmMessages)

         {

                 while (activeScreen==ScreenID.PgmMessages)

                 {

                         oScreen.putCommand("[pf3]");

                         activeScreen=(ScreenID) oScreen.waitForScreen(new int[]{(int) ScreenID.PgmMessages,(int) ScreenID.EndOfJob, (int) ScreenID.SignOn});

                 }

                 if (activeScreen!=ScreenID.SignOn)

                 {

                         oScreen.putCommand("[enter]");

                         activeScreen=(ScreenID) oScreen.waitForScreen((int) ScreenID.SignOn);

                 }

                 this.SessionDisconnect();

                 throw new System.Exception("Job Ended Abnormally--Session was terminated, please re-signon and continue...");

         }

         else if (activeScreen==ScreenID.SignOn)

         {

                 this.SessionDisconnect();

                 throw new System.Exception("You are probably signed-on more recently with another browser--Session was terminated, please re-signon and continue...");

         }

         */

         return activeScreen;

 }

 #endregion Custom Methods