// This function is invoked from Ux
        public static BizRulesValidationResult ValidateBizRules(string userName, string homeOrg, ZipArchive zipArchive,
                                                                BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager)
        {
            if (zipArchive == null)
            {
                throw new ArgumentNullException("zipArchive", "zipFile cannot be empty");
            }

            if (bizRuleCertMetadata == null)
            {
                throw new ArgumentNullException("bizRuleCertMetadata", "bizRuleCertMetadata cannot be empty");
            }

            if (dalManager == null)
            {
                throw new ArgumentNullException("dalManager", "dalManager cannot be null");
            }

            #region DummyCode
            if (GCValidatorHelper.AddDummyDataForInstanceValidation)
            {
                List <BizRuleInfo> ruleInfo1 = new List <BizRuleInfo>();
                ruleInfo1.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "BIG->BIG03", Value = "1/2/2014"
                });
                ruleInfo1.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF04", Value = "1/3/2014"
                });
                ruleInfo1.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG05", Value = "1/2/2014"
                });

                List <BizRuleInfo> ruleInfo2 = new List <BizRuleInfo>();
                ruleInfo2.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corp - Spec Cert - 810 - Send", SegmentPath = "BIG->BIG04", Value = "122014"
                });
                ruleInfo2.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF01", Value = "122014"
                });
                ruleInfo2.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG03", Value = "122014"
                });

                List <BizRuleInfo> ruleInfo3 = new List <BizRuleInfo>();
                ruleInfo3.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "IT1->IT101", Value = "123"
                });
                ruleInfo3.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "LIN->LIN01", Value = "234"
                });
                ruleInfo3.Add(new BizRuleInfo()
                {
                    FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "PO1->PO1O1", Value = "345"
                });

                BizRulesValidationResult bizRulesValidationResultDummy = new BizRulesValidationResult()
                {
                    BizRuleCertName = "3M - Biz Rule - X12 810-856-850"
                };
                bizRulesValidationResultDummy.BizRuleValidationResults = new List <BizRuleValidationResult>();
                bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult()
                {
                    RuleName = "Purchase Order Date",
                    Type     = ResultType.Error,
                    RuleInfo = ruleInfo1
                });
                bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult()
                {
                    RuleName = "Purchase Order Number",
                    Type     = ResultType.Success,
                    RuleInfo = ruleInfo2
                });
                bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult()
                {
                    RuleName = "Assigned Identification",
                    Type     = ResultType.Warning,
                    RuleInfo = ruleInfo3
                });

                bizRulesValidationResultDummy.EdiValidationResults = new List <EDIValidationResult>();
                List <SegmentValidationResult> segmentValidationResult = new List <SegmentValidationResult>();
                segmentValidationResult.Add(new SegmentValidationResult()
                {
                    Description    = "Invalid Segment XYZ",
                    Name           = "XYZ",
                    SequenceNumber = 5,
                    Type           = ResultType.Error,
                    StartIndex     = 300,
                    EndIndex       = 305,
                });

                bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult()
                {
                    BeautifiedOriginalPayload = "EDI File Contents",
                    FileName   = "Delphi Corp - Spec Cert - 810 - Send.dat",
                    SchemaName = "Delphi Corp - Spec Cert - 810 - Send",
                    SegmentValidationResults = new List <SegmentValidationResult>(),    // No validation failures
                    TransactionNumbers       = new List <string> {
                        "1"
                    },
                    DisplayName = "Delphi Corp - 810 - Send",
                    Type        = "X12_810"
                });
                bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult()
                {
                    BeautifiedOriginalPayload = "EDI File Contents",
                    FileName   = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat",
                    SchemaName = "Delphi Corporation - Spec Cert - 4010 - 850 - send",
                    SegmentValidationResults = segmentValidationResult,
                    TransactionNumbers       = new List <string> {
                        "1"
                    },
                    DisplayName = "Delphi Corporation - 850 - send",
                    Type        = "X12_850"
                });
                bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult()
                {
                    BeautifiedOriginalPayload = "EDI File Contents",
                    FileName   = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat",
                    SchemaName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive",
                    SegmentValidationResults = new List <SegmentValidationResult>(),    // No validation failures
                    TransactionNumbers       = new List <string> {
                        "1"
                    },
                    DisplayName = "Delphi Corporation - 856 - receive",
                    Type        = "X12_856"
                });

                return(bizRulesValidationResultDummy);
            }
            #endregion

            BizRulesValidationResult bizRulesValidationResult = null;
            string errorMessage = null;

            try
            {
                BizRuleSet bizRuleSet = SchemaCache.GetBizRuleSet(bizRuleCertMetadata, dalManager);

                List <ZipFileEntry> fileEntries = ZipFileUtil.GetFileEntries(zipArchive);
                List <DocumentPlugValidationInfo> documentPlugValidationInfoList = new List <DocumentPlugValidationInfo>();
                foreach (ZipFileEntry fileEntry in fileEntries)
                {
                    documentPlugValidationInfoList.Add(GetDocumentPlugValidationInfo(fileEntry, dalManager));
                }

                bizRulesValidationResult = ValidateBizRules(userName, homeOrg, bizRuleCertMetadata.RuleCertFileName,
                                                            bizRuleSet, documentPlugValidationInfoList, dalManager);
            }
            catch (GCEdiValidatorException gcException)
            {
                errorMessage = gcException.Message;
            }
            catch (Exception)
            {
                errorMessage = "Internal error occurred, please contact Maarg";
            }

            if (errorMessage != null)
            {
                // TODO: Add generic error
            }

            return(bizRulesValidationResult);
        }