Exemple #1
0
        /// <summary>
        ///     Return a list of problems in the script
        /// </summary>
        /// <param name="problemList"></param>
        /// <param name="settings"></param>
        public void GetScriptProblems(List <SiebelProblem> problemList, ScriptSettings settings)
        {
            Boolean checkFinally  = settings.CheckRetInFinally;
            Boolean checkDestroy  = settings.CheckDestruction;
            Boolean checkForBack  = settings.CheckForwardBackward;
            Boolean checkComments = settings.CheckNoComments;

            if (checkFinally)
            {
                GetRetInFinally(problemList);
            }
            if (checkDestroy || checkForBack)
            {
                ParseScriptLines(problemList, checkDestroy, checkForBack);
            }
            if (checkComments)
            {
                CheckForComments(problemList);
            }
        }
        /// <summary>
        /// Return the number of lines of code across the whole repository
        /// </summary>
        /// <param name="scriptLine"></param>
        /// <param name="settings"></param>
        /// <param name="updateStatusBar"></param>
        /// <returns></returns>
        public SiebelScriptLines GetCodeLineCount(SiebelScriptLines scriptLine, ScriptSettings settings, StatusUpdateCallback updateStatusBar)
        {
            scriptLine.ApplicationBsLine = GetObjCodeLines("Repository Application", "Repository Application Browser Script", "Script", settings, updateStatusBar);
            scriptLine.ApplicationSsLine = GetObjCodeLines("Repository Application", "Repository Application Server Script", "Script", settings, updateStatusBar);

            scriptLine.AppletBsLine = GetObjCodeLines("Repository Applet", "Repository Applet Browser Script", "Script", settings, updateStatusBar);
            scriptLine.AppletSsLine = GetObjCodeLines("Repository Applet", "Repository Applet Server Script", "Script", settings, updateStatusBar);

            scriptLine.BcbsLine = GetObjCodeLines("Repository Business Component", "Repository BusComp Browser Script", "Script", settings, updateStatusBar);
            scriptLine.BcssLine = GetObjCodeLines("Repository Business Component", "Repository BusComp Server Script", "Script", settings, updateStatusBar);

            scriptLine.BsbsLine = GetObjCodeLines("Repository Business Service", "Repository Business Service Browser Script", "Script", settings, updateStatusBar);
            scriptLine.BsssLine = GetObjCodeLines("Repository Business Service", "Repository Business Service Server Script", "Script", settings, updateStatusBar);

            scriptLine.TotalLine = scriptLine.ApplicationBsLine + scriptLine.ApplicationSsLine + scriptLine.AppletBsLine +
                                   scriptLine.AppletSsLine +
                                   scriptLine.BcbsLine + scriptLine.BcssLine + scriptLine.BsbsLine + scriptLine.BsssLine;

            return(scriptLine);
        }
        /// <summary>
        ///     Returns a list of code problems across the whole repository
        /// </summary>
        /// <param name="allProblems"></param>
        /// <param name="settings"></param>
        /// <param name="updateStatusBar"></param>
        public void GetCodeProblems(List <SiebelProblem> allProblems, ScriptSettings settings,
                                    StatusUpdateCallback updateStatusBar)
        {
            GetObjectCodeProblems("Application", "Repository Application", "Repository Application Browser Script",
                                  "Script", allProblems, settings, updateStatusBar);
            GetObjectCodeProblems("Application", "Repository Application", "Repository Application Server Script",
                                  "Script", allProblems, settings, updateStatusBar);

            GetObjectCodeProblems("Applet", "Repository Applet", "Repository Applet Browser Script", "Script",
                                  allProblems, settings, updateStatusBar);
            GetObjectCodeProblems("Applet", "Repository Applet", "Repository Applet Server Script", "Script",
                                  allProblems, settings, updateStatusBar);

            GetObjectCodeProblems("Business Component", "Repository Business Component",
                                  "Repository BusComp Browser Script", "Script", allProblems, settings, updateStatusBar);
            GetObjectCodeProblems("Business Component", "Repository Business Component",
                                  "Repository BusComp Server Script", "Script", allProblems, settings, updateStatusBar);

            GetObjectCodeProblems("Business Service", "Repository Business Service",
                                  "Repository Business Service Browser Script", "Script", allProblems, settings, updateStatusBar);
            GetObjectCodeProblems("Business Service", "Repository Business Service",
                                  "Repository Business Service Server Script", "Script", allProblems, settings, updateStatusBar);
        }
        /// <summary>
        ///     Returns a list of code problems for a given object
        /// </summary>
        /// <param name="objType"></param>
        /// <param name="busObjName"></param>
        /// <param name="busCompName"></param>
        /// <param name="codeFieldName"></param>
        /// <param name="allProblems"></param>
        /// <param name="settings"></param>
        /// <param name="updateStatusBar"></param>
        private void GetObjectCodeProblems(string objType, string busObjName, string busCompName, string codeFieldName,
                                           List <SiebelProblem> allProblems, ScriptSettings settings, StatusUpdateCallback updateStatusBar)
        {
            // Declare Siebel objects

            // Initialise BO and BC objects
            SiebelBusObject busObj  = _siebApp.GetBusObject(busObjName);
            SiebelBusComp   busComp = busObj.GetBusComp(busCompName);

            // Set up query context
            busComp.ClearToQuery();
            busComp.SetViewMode(SiebelConstants.AllView);
            busComp.ActivateField(codeFieldName);
            busComp.ActivateField("Name");
            busComp.ActivateField("Updated By");
            busComp.ActivateField("Parent Name");
            busComp.ActivateField("Inactive");
            busComp.ActivateField("Parent Inactive");
            busComp.SetSearchSpec("Repository Name", Name);
            busComp.SetSortSpec("Parent Name(ASC), Name(ASC)");

            string userFilter = settings.UserFilter;
            string objFilter  = settings.ObjNameFilter;

            // Filter by Update Date and Obj Name, if required
            if (userFilter != "" && userFilter != "All" && userFilter != null)
            {
                busComp.SetSearchSpec("Updated By", "'" + GetUserLoginId(userFilter) + "'");
            }

            if (!string.IsNullOrEmpty(objFilter))
            {
                busComp.SetSearchSpec("Parent Name", "'" + objFilter + "'");
            }

            if (settings.IgnoreInactive)
            {
                busComp.SetSearchSpec("Inactive", "'N'");
                busComp.SetSearchSpec("Parent Inactive", "'N'");
            }

            busComp.ExecuteQuery(SiebelConstants.ForwardOnly);

            // Check that records are returned
            bool isRecord = busComp.FirstRecord();

            // Determine if Server or Browser script
            string scriptType = busCompName.IndexOf("Browser Script", StringComparison.Ordinal) > 0 ? "Browser" : "Server";

            // Process each record
            while (isRecord)
            {
                // Get the script field from the BC
                string script     = busComp.GetFieldValue(codeFieldName);
                string methodName = busComp.GetFieldValue("Name");
                string parentName = busComp.GetFieldValue("Parent Name");

                // Update UI status bar
                updateStatusBar("Processing: " + busCompName + " (" + parentName + "." + methodName + ")");

                SiebelScript scriptObject = new SiebelScript(script, parentName, methodName, objType, scriptType);

                // Search the script for problems
                scriptObject.GetScriptProblems(allProblems, settings);
                // Get the next record
                isRecord = busComp.NextRecord();
            }
        }
        /// <summary>
        ///     Gets the number of code lines for a specific object type
        /// </summary>
        /// <param name="busObjName"></param>
        /// <param name="busCompName"></param>
        /// <param name="codeFieldName"></param>
        /// <param name="settings"></param>
        /// <param name="updateStatusBar"></param>
        /// <returns></returns>
        private int GetObjCodeLines(string busObjName, string busCompName, string codeFieldName, ScriptSettings settings, StatusUpdateCallback updateStatusBar)
        {
            // Reset counts
            int numLines = 0;

            // Declare Siebel objects

            // Initialise BO and BC objects
            SiebelBusObject busObj  = _siebApp.GetBusObject(busObjName);
            SiebelBusComp   busComp = busObj.GetBusComp(busCompName);

            // Set up query context
            busComp.SetViewMode(SiebelConstants.AllView);
            busComp.ActivateField(codeFieldName);
            busComp.ActivateField("Inactive");
            busComp.ActivateField("Parent Inactive");
            busComp.ClearToQuery();
            busComp.SetSearchSpec("Repository Name", Name);

            string userFilter = settings.CountUserNameFIlter;
            string objFilter  = settings.CountObjNameFilter;

            // Filter by Update Date and Obj Name, if required
            if (!string.IsNullOrEmpty(userFilter) && userFilter != "All")
            {
                busComp.SetSearchSpec("Updated By", "'" + GetUserLoginId(userFilter) + "'");
            }

            if (!string.IsNullOrEmpty(objFilter))
            {
                busComp.SetSearchSpec("Parent Name", "'" + objFilter + "'");
            }

            if (settings.IgnoreInactive)
            {
                busComp.SetSearchSpec("Inactive", "'N'");
                busComp.SetSearchSpec("Parent Inactive", "'N'");
            }
            busComp.ExecuteQuery(SiebelConstants.ForwardOnly);

            // Check that records are returned
            bool isRecord = busComp.FirstRecord();

            // Process each record
            while (isRecord)
            {
                // Get the script field from the BC
                string script = busComp.GetFieldValue(codeFieldName);

                SiebelScript scriptObject = new SiebelScript(script);
                updateStatusBar("Processing: " + busCompName);

                // Count the lines in the single script object and add to the total
                numLines += scriptObject.NumberOfLines();

                // Get the next record
                isRecord = busComp.NextRecord();
            }

            return(numLines);
        }