示例#1
0
        static void Main(string[] args)
        {
            int[]  returnValue = new int[2];
            int    executionID = 0;
            string batchCode   = string.Empty;
            string batchName   = string.Empty;

            string[] returnMessage;
            bool     IsCurrentAssessmentYear = true;
            int      headerID        = 0;
            string   batchParameters = string.Empty;
            bool     isSuccess       = false;

            // string createdBy = "SYSTEM";
            try
            {
                batchCode   = ConfigurationSettings.AppSettings["BatchCode"];
                executionID = BatchUtility.CreateaExecutionID(batchCode);
                //check to avoid duplicate runs
                if (!BatchUtility.IsDuplicateRun())
                {
                    //Fetch Batch Name from DB
                    batchName = BatchUtility.GetBatchNameBasedOnCode(batchCode, executionID);
                    //log batch start message as type "Information"
                    BatchUtility.LogMessage(batchName + " Batch Started at --" + DateTime.Now.ToString() + ".", executionID, "INFO");
                    returnMessage = BatchUtility.ValidateExecutionID(executionID, batchCode, "");

                    if (returnMessage[1] == "True")
                    {
                        //Log Information of Valid ExecutionID
                        BatchUtility.LogMessage(returnMessage[0], Convert.ToInt32(returnMessage[2]), "INFO");
                        //Actual Batch Call
                        returnValue = DBBalancingCYSupplementalDataAccess.RetrieveControlTotals(executionID, IsCurrentAssessmentYear);

                        if (returnValue[0] > 0)
                        {
                            headerID = returnValue[1];
                            BatchUtility.LogMessage(batchName + "  Completed Creating Control Totals With Header ID " + headerID.ToString() + " -- " + DateTime.Now.ToString(), Convert.ToInt32(returnMessage[2]), "INFO");
                            SaveReportOnBase(executionID, headerID, "RC0006");
                            SaveReportOnBase(executionID, headerID, "RC0018");

                            //Log Batch Success
                            BatchUtility.LogMessage(batchName + " Batch execution finished successfully.", executionID, "SUC");
                            //Updating the Execution End date
                            BatchUtility.UpdateExecutionEndDate(true, Convert.ToInt32(returnMessage[2]));
                            isSuccess = true;
                        }
                        else
                        {
                            //Log Batch Failure
                            BatchUtility.LogMessage(batchName + " Batch execution failed.", executionID, "FAIL");
                            //Updating the Execution End date
                            BatchUtility.UpdateExecutionEndDate(false, Convert.ToInt32(returnMessage[2]));
                        }
                    }
                    else
                    {
                        //Log Information of Invalid Execution ID
                        BatchUtility.LogMessage(returnMessage[0], Convert.ToInt32(returnMessage[2]), "INFO");
                    }
                }
                else
                {
                    //Log Information of duplicate running batch
                    BatchUtility.LogMessage("Batch already in progress. ", executionID, "INFO");
                }
            }
            catch (Exception ex)
            {
                isSuccess = false;
                //Log Batch Exceptions
                BatchUtility.LogMessage(ex.Message + "--" + DateTime.Now.ToString(), executionID, "EXCEP");
            }
            finally
            {
                //Final Log Batch Information
                BatchUtility.LogMessage(batchName + " Batch execution finished at" + "--" + DateTime.Now.ToString() + ".", executionID, "INFO");
                BatchUtility.SendExitCodeToControlM(isSuccess);
            }
        }