コード例 #1
0
        // POST api/values
        public void Post([FromBody] FunctionGroup value)
        {
            var folder   = Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData);
            var filePath = Path.Combine(folder, "medusa.json");

            System.IO.File.WriteAllText(filePath, JsonConvert.SerializeObject(value));
        }
コード例 #2
0
        public ActionResult ExistingFuncRec(int GID, int FID, string sub)
        {
            try
            {
                if (GID > 0 && FID > 0)
                {
                    var item = new FunctionGroup()
                    {
                        FunctionID = FID, GroupID = GID
                    };
                    if (sub == "Read")
                    {
                        item.Writable = false;
                    }
                    if (sub == "Write")
                    {
                        item.Writable = true;
                    }
                    db.Insert(item);
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("AddFuncGroups", new { err = $"Please Select The Group: '{e}'" }));
            }

            return(new EmptyResult());
        }
コード例 #3
0
 public ConstructorInitializer(bool baseCall, AstNode arguments, TokenPosition position)
     : base(position)
 {
     this.baseCall  = baseCall;
     this.arguments = arguments;
     this.ctorGroup = null;
 }
コード例 #4
0
 public FunctionGroupConfiguration(FunctionGroup functionGroup)
 {
     Key = functionGroup.Key;
     ControllerFunctions = functionGroup.ControllerFunctions
                           .Select(x => new ControllerFunctionConfiguration(x))
                           .ToList();
 }
コード例 #5
0
        public void AddFunctionEndPointer(int classIndex, string functionName, FunctionEndPoint fep)
        {
            if (functionName == null)
            {
                throw new System.ArgumentNullException("functionName");
            }

            if (fep == null)
            {
                throw new System.ArgumentNullException("fep");
            }

            Dictionary <string, FunctionGroup> funcGroupMap;

            if (!GlobalFuncTable.TryGetValue(classIndex, out funcGroupMap))
            {
                funcGroupMap = new Dictionary <string, FunctionGroup>();
                GlobalFuncTable[classIndex] = funcGroupMap;
            }

            FunctionGroup funcGroup;

            if (!funcGroupMap.TryGetValue(functionName, out funcGroup))
            {
                funcGroup = new FunctionGroup();
                funcGroupMap[functionName] = funcGroup;
            }

            funcGroup.FunctionEndPoints.Add(fep);
        }
コード例 #6
0
        /// <summary>
        /// 初始化功能组数据
        /// </summary>
        /// <param name="functionGroupList">所有的功能组列表,FunctionGroup数组</param>
        /// <param name="selectedList">已选择的功能组列表,RptViewReportSecurity数组</param>
        public void InitFunctionGroupData(object[] functionGroupList, object[] selectedList)
        {
            this.lstUnSelectedUserGroup.Items.Clear();
            this.lstSelectedUserGroup.Items.Clear();

            if (functionGroupList == null || functionGroupList.Length == 0)
                return;
            List<string> selectedFunctionGroup = new List<string>();
            if (selectedList != null && selectedList.Length > 0)
            {
                for (int i = 0; i < selectedList.Length; i++)
                {
                    RptViewReportSecurity rptSecurity = (RptViewReportSecurity)selectedList[i];
                    selectedFunctionGroup.Add(rptSecurity.FunctionGroupCode);
                }
            }

            for (int i = 0; i < functionGroupList.Length; i++)
            {
                FunctionGroup ugroup = (FunctionGroup)functionGroupList[i];
                if (selectedFunctionGroup.Contains(ugroup.FunctionGroupCode) == false)
                {
                    this.lstUnSelectedUserGroup.Items.Add(new ListItem(ugroup.FunctionGroupDescription, ugroup.FunctionGroupCode));
                }
                else
                {
                    this.lstSelectedUserGroup.Items.Add(new ListItem(ugroup.FunctionGroupDescription, ugroup.FunctionGroupCode));
                }
            }
            this.hidSelectedValue.Value = string.Join(";", selectedFunctionGroup.ToArray());
        }
コード例 #7
0
 public FunctionDescriptor(string theName, FunctionGroup theGroup, string[] theAlternates, Functor theFunctor, string description)
 {
     Name        = theName;
     Group       = theGroup;
     Alternates  = theAlternates;
     Functor     = theFunctor;
     Description = description;
 }
コード例 #8
0
ファイル: FunctionDescriptor.cs プロジェクト: gahadzikwa/GAPP
 public FunctionDescriptor(string theName, FunctionGroup theGroup, string[] theAlternates, Functor theFunctor, string description)
 {
     Name = theName;
     Group = theGroup;
     Alternates = theAlternates;
     Functor = theFunctor;
     Description = description;
 }
コード例 #9
0
        private T SaveFunctionalGroup(FunctionGroup functionGroup, T interchangeId)
        {
            string   idCode;
            DateTime date          = DateTime.MaxValue;
            int      controlNumber = 0;
            string   version;

            if (functionGroup.FunctionalIdentifierCode.Length <= 2)
            {
                idCode = functionGroup.FunctionalIdentifierCode;
            }
            else
            {
                idCode = functionGroup.FunctionalIdentifierCode.Substring(0, 2);
                Trace.TraceWarning("FunctionalIdentifier code '{0}' will be truncated because it exceeds the max length of 2.", functionGroup.FunctionalIdentifierCode);
            }
            try
            {
                date = functionGroup.Date;
            }
            catch (Exception exc)
            {
                Trace.TraceWarning("FunctionalGroup date '{0}' and time '{1}' could not be parsed. {2}", functionGroup.GetElement(4), functionGroup.GetElement(5), exc.Message);
            }
            try
            {
                controlNumber = functionGroup.ControlNumber;
            }
            catch (Exception exc)
            {
                Trace.TraceWarning("FunctionalGroup control number '{0}' could not be parsed. {1}", functionGroup.GetElement(6), exc.Message);
            }
            if (functionGroup.VersionIdentifierCode.Length <= 12)
            {
                version = functionGroup.VersionIdentifierCode;
            }
            else
            {
                version = functionGroup.VersionIdentifierCode.Substring(0, 12);
                Trace.TraceWarning("FunctionalGroup version number '{0}' will be truncated because it exceeds the max length of 12.", functionGroup.VersionIdentifierCode);
            }

            SqlCommand cmd = new SqlCommand(GetContainerIdSql("GS") + string.Format(@"
INSERT INTO [{0}].[FunctionalGroup] (Id, InterchangeId, FunctionalIdCode, Date, ControlNumber, Version)
VALUES (@id, @interchangeId, @functionalIdCode, @date, @controlNumber, @version)

SELECT @id
", _schema, _commonDb.Schema));

            cmd.Parameters.AddWithValue("@interchangeId", interchangeId);
            cmd.Parameters.AddWithValue("@functionalIdCode", idCode);
            cmd.Parameters.AddWithValue("@date", date);
            cmd.Parameters.AddWithValue("@controlNumber", controlNumber);
            cmd.Parameters.AddWithValue("@version", version);

            return(ConvertT(ExecuteScalar(cmd)));
        }
コード例 #10
0
        private Interchange CreateSample1WithFunctionGroup()
        {
            Interchange   interchange = CreateSample1InterChange(DateTime.Parse("2002-08-16 11:44AM"));
            FunctionGroup fg          = interchange.AddFunctionGroup("HC", DateTime.Parse("2007-08-16 4:15PM"), 31);

            fg.ApplicationSendersCode   = "901234572000";
            fg.ApplicationReceiversCode = "908887732000";
            return(interchange);
        }
コード例 #11
0
 public FunctionGroupSelector(FunctionGroup functionGroup)
     : base(null)
 {
     this.functionGroup = functionGroup;
     this.selected = null;
     this.supressVirtual = false;
     this.implicitThis = false;
     this.genericParameters = null;
 }
コード例 #12
0
 /// <summary>
 /// As we rely on search when generating markdown files and matching them with content from the DynamoDictionary
 /// we need to add all ZT nodes to the SearchModel.
 /// </summary>
 /// <param name="funcGroup"></param>
 /// <param name="nodeSearchModel"></param>
 private static void AddFunctionGroupToSearch(FunctionGroup funcGroup, NodeSearchModel nodeSearchModel)
 {
     foreach (var functionDescriptor in funcGroup.Functions)
     {
         if (functionDescriptor.IsVisibleInLibrary)
         {
             nodeSearchModel.Add(new ZeroTouchSearchElement(functionDescriptor));
         }
     }
 }
コード例 #13
0
        public void RegisterGroup <T>(string groupName, Expression <Func <T, object> > actionExpression, string iconClass, bool hasMenu, params FunctionComponent[] childFunctions) where T : Controller
        {
            FunctionComponent component = new FunctionComposite <T>(groupName, actionExpression, childFunctions);

            component.IconClass   = iconClass;
            component.IsShowOnNav = hasMenu;
            FunctionGroup.Add(component);

            RegisterFunctionDict(component);
        }
コード例 #14
0
        public FunctionGroupViewModel(Dispatcher dispatcher, FunctionGroup functionGroup) : base(dispatcher)
        {
            _functionGroup      = functionGroup;
            Enabled             = functionGroup.Enabled;
            DisplayName         = functionGroup.DisplayName;
            IsGlobal            = functionGroup.IsGlobal;
            ControllerFunctions = new ObservableCollection <ControllerFunctionViewModel>();
            UpdateControllerFunctions(functionGroup.ControllerFunctions);

            functionGroup.PropertyChanged += FunctionGroupOnPropertyChanged;
        }
コード例 #15
0
        public void CreatePurchaseOrder850()
        {
            string expected = @"ISA*00*          *00*          *01*828513080      *01*001903202U     *100817*0850*U*00401*000000245*0*P*:~
  GS*PO*828513080*001903202U*20100817*0850*245*X*005010X222~
    ST*850*0001~
      BEG*05*SA*S41000439**20100810~
      CUR*BY*USD~
      PER*IC*Doe,Jane******Doe,Jane~
    SE*5*0001~
  GE*1*1~
IEA*1*000000245~";

            var purcaseOrderDate = new DateTime(2010, 8, 17, 08, 50, 0);
            var interchange      = new Interchange(purcaseOrderDate, 245, true)
            {
                InterchangeSenderIdQualifier   = "01",
                InterchangeSenderId            = "828513080",
                InterchangeReceiverIdQualifier = "01",
                InterchangeReceiverId          = "001903202U",
                InterchangeDate = purcaseOrderDate,
            };

            interchange.SetElement(14, "0");

            FunctionGroup group = interchange.AddFunctionGroup("PO", purcaseOrderDate, 1, "005010X222");

            group.ApplicationSendersCode   = "828513080";
            group.ApplicationReceiversCode = "001903202U";
            group.Date          = purcaseOrderDate;
            group.ControlNumber = 245;

            Transaction transaction = group.AddTransaction("850", "0001");

            Segment bhtSegment = transaction.AddSegment("BEG");

            bhtSegment.SetElement(1, "05");
            bhtSegment.SetElement(2, "SA");
            bhtSegment.SetElement(3, "S41000439");
            bhtSegment.SetElement(5, "20100810");

            bhtSegment = transaction.AddSegment("CUR");
            bhtSegment.SetElement(1, "BY");
            bhtSegment.SetElement(2, "USD");

            bhtSegment = transaction.AddSegment("PER");
            bhtSegment.SetElement(1, "IC");
            bhtSegment.SetElement(2, "Doe,Jane");
            bhtSegment.SetElement(8, "Doe,Jane");

            var x12 = interchange.SerializeToX12(true);

            Assert.AreEqual(expected, x12);
        }
コード例 #16
0
 public int Insert(FunctionGroup entity)
 {
     try
     {
         functionGroup = db.GetTable <FunctionGroup>();
         functionGroup.InsertOnSubmit(entity);
         db.SubmitChanges();
         return(entity.FunctionGroupID);
     }
     catch
     {
         return(0);
     }
 }
コード例 #17
0
        protected override object GetEditObject()
        {
            //this.ValidateInput();

            if (_facade == null)
            {
                _facade = new SystemSettingFacadeFactory(base.DataProvider).CreateSystemSettingFacade();
            }
            FunctionGroup functionGroup = this._facade.CreateNewFunctionGroup();

            functionGroup.FunctionGroupDescription = FormatHelper.CleanString(this.txtFunctionGroupDescriptionEdit.Text, 100);
            functionGroup.FunctionGroupCode        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtFunctionGroupCodeEdit.Text, 40));
            functionGroup.MaintainUser             = this.GetUserCode();

            return(functionGroup);
        }
コード例 #18
0
ファイル: FunctionDescriptor.cs プロジェクト: gahadzikwa/GAPP
 public static string GroupName(FunctionGroup group) {
     switch (group)
     {
         case FunctionGroup.NumberGroup:
             return StrRes.GetString(StrRes.STR_NUMBER_GROUP);
         case FunctionGroup.CoordinateGroup:
             return StrRes.GetString(StrRes.STR_COORDINATE_GROUP);
         case FunctionGroup.TextGroup:
             return StrRes.GetString(StrRes.STR_TEXT_GROUP);
         case FunctionGroup.ContextGroup:
             return StrRes.GetString(StrRes.STR_CONTEXT_GROUP);
         case FunctionGroup.TrigonometricGroup:
             return StrRes.GetString(StrRes.STR_TRIGONOMETRIC_GROUP);
         default:
             return null;
     }
 }
コード例 #19
0
        public FunctionGroupInstance(FunctionGroup template, GenericInstance instance, ScopeMember factory)
            : base(template.GetName(), (Scope)factory)
        {
            // Instance all of the functions.
            foreach(FunctionGroupName gname in template.GetFunctions())
            {
                // Instance the function.
                Function tmplFunction = gname.GetFunction();
                Function function = (Function)tmplFunction.InstanceMember(factory, instance);

                // Create the new group name.
                FunctionGroupName groupName = new FunctionGroupName(function.GetFunctionType(), gname.IsStatic());
                groupName.SetFunction(function);

                // Store the group name.
                functions.Add(groupName);
            }
        }
コード例 #20
0
        public FunctionGroupInstance(FunctionGroup template, GenericInstance instance, ScopeMember factory)
            : base(template.GetName(), (Scope)factory)
        {
            // Instance all of the functions.
            foreach (FunctionGroupName gname in template.GetFunctions())
            {
                // Instance the function.
                Function tmplFunction = gname.GetFunction();
                Function function     = (Function)tmplFunction.InstanceMember(factory, instance);

                // Create the new group name.
                FunctionGroupName groupName = new FunctionGroupName(function.GetFunctionType(), gname.IsStatic());
                groupName.SetFunction(function);

                // Store the group name.
                functions.Add(groupName);
            }
        }
コード例 #21
0
        public void CreatePurchaseOrder850()
        {
            DateTime    purcaseOrderDate = new DateTime(2010, 8, 17, 08, 50, 0);
            Interchange interchange      = new Interchange(purcaseOrderDate, 245, true)
            {
                InterchangeSenderIdQualifier   = "01",
                InterchangeSenderId            = "828513080",
                InterchangeReceiverIdQualifier = "01",
                InterchangeReceiverId          = "001903202U",
                InterchangeDate = purcaseOrderDate,
            };

            interchange.SetElement(14, "0");             //No Aknowlegement is 0

            FunctionGroup group = interchange.AddFunctionGroup("PO", purcaseOrderDate, 1, "005010X222");

            group.ApplicationSendersCode   = "828513080";
            group.ApplicationReceiversCode = "001903202U";
            group.Date          = purcaseOrderDate;
            group.ControlNumber = 245;

            Transaction transaction = group.AddTransaction("850", "0001");

            Segment bhtSegment = transaction.AddSegment("BEG");

            bhtSegment.SetElement(1, "05");
            bhtSegment.SetElement(2, "SA");
            bhtSegment.SetElement(3, "S41000439");
            bhtSegment.SetElement(5, "20100810");

            bhtSegment = transaction.AddSegment("CUR");
            bhtSegment.SetElement(1, "BY");
            bhtSegment.SetElement(2, "USD");

            bhtSegment = transaction.AddSegment("PER");
            bhtSegment.SetElement(1, "IC");
            bhtSegment.SetElement(2, "Doe,Jane");
            bhtSegment.SetElement(8, "Doe,Jane");

            var x12 = interchange.SerializeToX12(true);

            System.Diagnostics.Trace.Write(x12);
        }
コード例 #22
0
        private AckEnvelope ExtractEnv(Interchange isa, FunctionGroup gs, Transaction st)
        {
            return(new AckEnvelope()
            {
                ISA01_AuthInfoQualifier = isa.AuthorInfoQualifier,
                ISA02_AuthInfo = isa.AuthorInfo,
                ISA03_SecurityInfoQualifier = isa.SecurityInfoQualifier,
                ISA04_SecurityInfo = isa.SecurityInfo,
                ISA05_InterchangeSenderIdQualifier = isa.InterchangeSenderIdQualifier,
                ISA06_InterchangeSenderId = isa.InterchangeSenderId,
                ISA07_InterchangeReceiverIdQualifier = isa.InterchangeReceiverIdQualifier,
                ISA08_InterchangeReceiverId = isa.InterchangeReceiverId,
                ISA09_Date = isa.InterchangeDate,

                ISA10_Time = isa.GetElement(10),
                ISA11_InterchangeControlStandardsIdentifier = isa.GetElement(11),
                ISA12_InterchangeControlVersionNumber = isa.GetElement(12),
                ISA13_InterchangeControlNumber = isa.InterchangeControlNumber,
                ISA14_AcknowledgmentRequested = isa.GetElement(14),
                ISA15_UsageIndicator = isa.GetElement(15),
                ISA16_ComponentElementSeparator = isa.GetElement(16),
                IEA01_NumberOfIncludedFunctionalGroups = (isa.TrailerSegments.ToList()[0]).GetElement(1),
                IEA02_InterchangeControlNumber = (isa.TrailerSegments.ToList()[0]).GetElement(2),

                GS01_FunctionalIdentifierCode = gs.FunctionalIdentifierCode,
                GS02_ApplicationSenderCode = gs.ApplicationSendersCode,
                GS03_ApplicationReceiverCode = gs.ApplicationReceiversCode,
                GS04_Date = gs.Date,
                GS06_GroupControlNumber = gs.ControlNumber.ToString(),
                GS07_ResponsibleAgencyCode = gs.ResponsibleAgencyCode,
                GS08_Version = gs.VersionIdentifierCode,
                GS05_Time = gs.GetElement(5),
                GE01_NumberOfTransactionSetsIncluded = (gs.TrailerSegments.ToList()[0]).GetElement(1),
                GE02_GroupControlNumber = (gs.TrailerSegments.ToList()[0]).GetElement(2),

                ST01_TransactionSetIdentifierCode = st.IdentifierCode,
                ST02_TransactionSetControlNumber = st.ControlNumber,
                SE01_NumberOfIncludedSegments = (st.TrailerSegments.ToList()[0]).GetElement(1),
                SE02_TransactionSetControlNumber = (st.TrailerSegments.ToList()[0]).GetElement(2)
            });
        }
コード例 #23
0
        public void CopyVisibleFunctionEndPointFromBase(int classIndex, int baseClassIndex)
        {
            if (classIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
            {
                throw new System.ArgumentException("classIndex");
            }

            if (baseClassIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
            {
                throw new System.ArgumentException("classIndex");
            }

            Dictionary <string, FunctionGroup> thisFunctionGroupMap;
            Dictionary <string, FunctionGroup> baseFunctionGroupMap;

            if (!GlobalFuncTable.TryGetValue(classIndex, out thisFunctionGroupMap) ||
                !GlobalFuncTable.TryGetValue(baseClassIndex, out baseFunctionGroupMap))
            {
                return;
            }

            foreach (KeyValuePair <string, FunctionGroup> baseGroup in baseFunctionGroupMap)
            {
                FunctionGroup functionGroup;
                if (thisFunctionGroupMap.TryGetValue(baseGroup.Key, out functionGroup))
                {
                    functionGroup.CopyVisible(baseGroup.Value.FunctionEndPoints);
                }
                else
                {
                    // If this class doesnt have basegroup, create a new group and append the visible feps from the basegoup
                    functionGroup = new FunctionGroup();
                    functionGroup.CopyVisible(baseGroup.Value.FunctionEndPoints);
                    if (functionGroup.FunctionEndPoints.Count > 0)
                    {
                        thisFunctionGroupMap[baseGroup.Key] = functionGroup;
                    }
                }
            }
        }
コード例 #24
0
ファイル: FunctionTable.cs プロジェクト: samuto/designscript
        public void CopyVisibleFunctionEndPointFromBase(int classIndex, int baseClassIndex)
        {
            if (classIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
            {
                throw new System.ArgumentException("classIndex");
            }

            if (baseClassIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
            {
                throw new System.ArgumentException("classIndex");
            }

            Dictionary<string, FunctionGroup> thisFunctionGroupMap;
            Dictionary<string, FunctionGroup> baseFunctionGroupMap;

            if (!GlobalFuncTable.TryGetValue(classIndex, out thisFunctionGroupMap) ||
                !GlobalFuncTable.TryGetValue(baseClassIndex, out baseFunctionGroupMap))
            {
                return;
            }

            foreach (KeyValuePair<string, FunctionGroup> baseGroup in baseFunctionGroupMap)
            {
                FunctionGroup functionGroup;
                if (thisFunctionGroupMap.TryGetValue(baseGroup.Key, out functionGroup))
                {
                    functionGroup.CopyVisible(baseGroup.Value.FunctionEndPoints);
                }
                else
                {
                    // If this class doesnt have basegroup, create a new group and append the visible feps from the basegoup
                    functionGroup = new FunctionGroup();
                    functionGroup.CopyVisible(baseGroup.Value.FunctionEndPoints);
                    if (functionGroup.FunctionEndPoints.Count > 0)
                    {
                        thisFunctionGroupMap[baseGroup.Key] = functionGroup;
                    }
                }
            }
        }
コード例 #25
0
        public override void ControllerValueChanged(int controllerValue, Range controllerRange)
        {
            if (controllerValue != (int)controllerRange.Maximum)
            {
                return;
            }

            var functionGroup = FunctionGroup.GetFunctionGroupFor(_panel);

            if (functionGroup != null)
            {
                if (!functionGroup.Enabled)
                {
                    functionGroup.Enable();

                    ShowHud($"Switched to panel: {functionGroup.Panel.Name}");
                }
                else
                {
                    if (_enablePanelParamter == null)
                    {
                        return;
                    }

                    if (Api.LrDevelopController.GetValue(out var enabled, _enablePanelParamter))
                    {
                        Api.LrDevelopController.SetValue(_enablePanelParamter, !enabled);

                        ShowHud($"{(!enabled ? "Enabled" : "Disabled")} panel: {functionGroup.Panel.Name}");
                    }
                }
            }
            else
            {
                Api.LrDevelopController.RevealPanel(_panel);
                ShowHud($"Switched to panel: {_panel.Name}");
            }
        }
コード例 #26
0
        public void TestEmptyElement()
        {
            string      expectedSegmentString = "BEG*05*SA*S41000439";
            DateTime    purcaseOrderDate      = new DateTime(2010, 8, 17, 08, 50, 0);
            Interchange interchange           = new Interchange(purcaseOrderDate, 245, true)
            {
                InterchangeSenderIdQualifier   = "01",
                InterchangeSenderId            = "828513080",
                InterchangeReceiverIdQualifier = "01",
                InterchangeReceiverId          = "001903202U",
                InterchangeDate = purcaseOrderDate,
            };

            interchange.SetElement(14, "0");             //No Aknowlegement is 0

            FunctionGroup group = interchange.AddFunctionGroup("PO", purcaseOrderDate, 1, "005010X222");

            group.ApplicationSendersCode   = "828513080";
            group.ApplicationReceiversCode = "001903202U";
            group.Date          = purcaseOrderDate;
            group.ControlNumber = 245;

            Transaction transaction = group.AddTransaction("850", "0001");

            string segmentString = string.Empty;

            Segment bhtSegment = transaction.AddSegment("BEG");

            segmentString = bhtSegment.SegmentString;              //test getting it prematurely
            bhtSegment.SetElement(1, "05");
            bhtSegment.SetElement(2, "SA");
            bhtSegment.SetElement(3, "S41000439");
            bhtSegment.SetElement(5, "");

            segmentString = bhtSegment.SegmentString;

            Assert.AreEqual(expectedSegmentString, segmentString);
        }
コード例 #27
0
        public static string GroupName(FunctionGroup group)
        {
            switch (group)
            {
            case FunctionGroup.NumberGroup:
                return(StrRes.GetString(StrRes.STR_NUMBER_GROUP));

            case FunctionGroup.CoordinateGroup:
                return(StrRes.GetString(StrRes.STR_COORDINATE_GROUP));

            case FunctionGroup.TextGroup:
                return(StrRes.GetString(StrRes.STR_TEXT_GROUP));

            case FunctionGroup.ContextGroup:
                return(StrRes.GetString(StrRes.STR_CONTEXT_GROUP));

            case FunctionGroup.TrigonometricGroup:
                return(StrRes.GetString(StrRes.STR_TRIGONOMETRIC_GROUP));

            default:
                return(null);
            }
        }
コード例 #28
0
        public ActionResult ExistingFuncRec(int?GID, FormCollection fm, string sub)
        {
            try
            {
                if (fm["G"] != null && fm["F"] != null)
                {
                    int fid  = int.Parse(fm["F"]);
                    int gid  = int.Parse(fm["G"]);
                    var item = new FunctionGroup()
                    {
                        FunctionID = fid, GroupID = (int)gid
                    };
                    if (sub == "Read")
                    {
                        item.Writable = false;
                    }
                    else if (sub == "Write")
                    {
                        item.Writable = true;
                    }
                    db.Insert(item);
                    GID = gid;
                }

                if (fm["GroupID"] != null)
                {
                    GID = int.Parse(fm["GroupID"]);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Please Select The Group: '{0}'", e);
            }
            List <Cavala.Models.ExistingFuncViewModel> recs = db.Fetch <Cavala.Models.ExistingFuncViewModel>("Select * from UserFunctions uf inner join FunctionGroups fg on uf.FunctionID = fg.FunctionID inner join Groups g on g.GroupID = fg.GroupID where fg.GroupID = @0", GID ?? 0);

            return(PartialView("ExistingFuncPartial", recs));
        }
コード例 #29
0
ファイル: FunctionTable.cs プロジェクト: samuto/designscript
        public void AddFunctionEndPointer(int classIndex, string functionName, FunctionEndPoint fep)
        {
            if (functionName == null)
                throw new System.ArgumentNullException("functionName");

            if (fep == null)
                throw new System.ArgumentNullException("fep");

            Dictionary<string, FunctionGroup> funcGroupMap;
            if (!GlobalFuncTable.TryGetValue(classIndex, out funcGroupMap))
            {
                funcGroupMap = new Dictionary<string, FunctionGroup>();
                GlobalFuncTable[classIndex] = funcGroupMap;
            }

            FunctionGroup funcGroup;
            if (!funcGroupMap.TryGetValue(functionName, out funcGroup))
            {
                funcGroup = new FunctionGroup();
                funcGroupMap[functionName] = funcGroup;
            }

            funcGroup.FunctionEndPoints.Add(fep);
        }
コード例 #30
0
        /// <summary>
        /// Parses all interchanges from an X12 document
        /// </summary>
        /// <param name="stream">Stream pointing to source X12 data</param>
        /// <param name="encoding">Stream encoding for reading data</param>
        /// <returns><see cref="Interchange"/> collection parsed from X12</returns>
        /// <exception cref="InvalidOperationException">Thrown on any missing segments or parent IDs</exception>
        public List <Interchange> ParseMultiple(Stream stream, Encoding encoding)
        {
            var envelopes = new List <Interchange>();

            using (var reader = new X12StreamReader(stream, encoding, this.ignoredChars))
            {
                var envelop = new Interchange(this.specFinder, reader.CurrentIsaSegment);
                envelopes.Add(envelop);
                Container     currentContainer = envelop;
                FunctionGroup fg     = null;
                Transaction   tr     = null;
                var           hloops = new Dictionary <string, HierarchicalLoop>();

                string segmentString  = reader.ReadNextSegment();
                string segmentId      = reader.ReadSegmentId(segmentString);
                int    segmentIndex   = 1;
                var    containerStack = new Stack <string>();
                while (segmentString.Length > 0)
                {
                    switch (segmentId)
                    {
                    case "ISA":
                        envelop = new Interchange(this.specFinder, segmentString + reader.Delimiters.SegmentTerminator);
                        envelopes.Add(envelop);
                        currentContainer = envelop;
                        fg     = null;
                        tr     = null;
                        hloops = new Dictionary <string, HierarchicalLoop>();
                        break;

                    case "IEA":
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMismatchSegment, segmentString, "ISA"));
                        }

                        envelop.SetTerminatingTrailerSegment(segmentString);
                        break;

                    case "GS":
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMissingPrecedingSegment, segmentString, "ISA"));
                        }

                        currentContainer = fg = envelop.AddFunctionGroup(segmentString);
                        break;

                    case "GE":
                        if (fg == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMismatchSegment, segmentString, "GS"));
                        }

                        fg.SetTerminatingTrailerSegment(segmentString);
                        fg = null;
                        break;

                    case "ST":
                        if (fg == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMissingGsSegment, segmentString));
                        }

                        segmentIndex     = 1;
                        currentContainer = tr = fg.AddTransaction(segmentString);
                        hloops           = new Dictionary <string, HierarchicalLoop>();
                        break;

                    case "SE":
                        if (tr == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMismatchSegment, segmentString, "ST"));
                        }

                        tr.SetTerminatingTrailerSegment(segmentString);
                        tr = null;
                        break;

                    case "HL":
                        var    hierarchicalLoopSegment = new Segment(null, reader.Delimiters, segmentString);
                        string id        = hierarchicalLoopSegment.GetElement(1);
                        string parentId  = hierarchicalLoopSegment.GetElement(2);
                        string levelCode = hierarchicalLoopSegment.GetElement(3);

                        while (!(currentContainer is HierarchicalLoopContainer hlCurrentContainer && hlCurrentContainer.AllowsHierarchicalLoop(levelCode)))
                        {
                            if (currentContainer.Parent != null)
                            {
                                currentContainer = currentContainer.Parent;
                            }
                            else
                            {
                                throw new InvalidOperationException(string.Format(
                                                                        Resources.X12ParserInvalidHLoopSpecification,
                                                                        segmentString,
                                                                        tr.ControlNumber));
                            }
                        }

                        bool parentFound = false;
                        if (!string.IsNullOrEmpty(parentId))
                        {
                            if (hloops.ContainsKey(parentId))
                            {
                                parentFound      = true;
                                currentContainer = hloops[parentId].AddHLoop(segmentString);
                            }
                            else
                            {
                                if (this.throwExceptionOnSyntaxErrors)
                                {
                                    throw new InvalidOperationException(string.Format(Resources.X12ParserMissingParentIdError, id, parentId));
                                }

                                this.OnParserWarning(new X12ParserWarningEventArgs
                                {
                                    FileIsValid = false,
                                    InterchangeControlNumber     = envelop.InterchangeControlNumber,
                                    FunctionalGroupControlNumber = fg.ControlNumber,
                                    TransactionControlNumber     = tr.ControlNumber,
                                    SegmentPositionInInterchange = segmentIndex,
                                    Segment   = segmentString,
                                    SegmentId = segmentId,
                                    Message   = string.Format(Resources.X12ParserMissingParentIdWarning, id, parentId)
                                });
                            }
                        }

                        if (string.IsNullOrEmpty(parentId) || !parentFound)
                        {
                            while (!(currentContainer is HierarchicalLoopContainer hlCurrentContainer && hlCurrentContainer.HasHierachicalSpecs()))
                            {
                                currentContainer = currentContainer.Parent;
                            }

                            currentContainer = ((HierarchicalLoopContainer)currentContainer).AddHLoop(segmentString);
                        }

                        if (hloops.ContainsKey(id))
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserHLoopIdExists, segmentString, tr.ControlNumber, id));
                        }

                        hloops.Add(id, (HierarchicalLoop)currentContainer);
                        break;

                    case "TA1":
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(string.Format(Resources.X12ParserMismatchSegment, segmentString, "ISA"));
                        }

                        envelop.AddSegment(segmentString);
                        break;

                    default:
                        var originalContainer = currentContainer;
                        containerStack.Clear();
                        while (currentContainer != null)
                        {
                            if (currentContainer.AddSegment(segmentString) != null)
                            {
                                if (segmentId == "LE")
                                {
                                    currentContainer = currentContainer.Parent;
                                }

                                break;
                            }

                            if (currentContainer is LoopContainer loopContainer)
                            {
                                Loop newLoop = loopContainer.AddLoop(segmentString);
                                if (newLoop != null)
                                {
                                    currentContainer = newLoop;
                                    break;
                                }

                                if (currentContainer is Transaction tran)
                                {
                                    if (this.throwExceptionOnSyntaxErrors)
                                    {
                                        throw new TransactionValidationException(
                                                  Resources.X12ParserSegmentCannotBeIdentitied,
                                                  tran.IdentifierCode,
                                                  tran.ControlNumber,
                                                  string.Empty,
                                                  segmentString,
                                                  segmentIndex,
                                                  string.Join(",", containerStack));
                                    }

                                    currentContainer = originalContainer;
                                    currentContainer.AddSegment(segmentString, true);
                                    this.OnParserWarning(new X12ParserWarningEventArgs
                                    {
                                        FileIsValid = false,
                                        InterchangeControlNumber     = envelop.InterchangeControlNumber,
                                        FunctionalGroupControlNumber = fg.ControlNumber,
                                        TransactionControlNumber     = tran.ControlNumber,
                                        SegmentPositionInInterchange = segmentIndex,
                                        SegmentId = segmentId,
                                        Segment   = segmentString,
                                        Message   = string.Format(
                                            Resources.X12ParserSegmentWarning,
                                            tran.IdentifierCode,
                                            tran.ControlNumber,
                                            segmentString,
                                            segmentIndex,
                                            string.Join(",", containerStack),
                                            containerStack.LastOrDefault())
                                    });
                                    break;
                                }

                                if (currentContainer is Loop containerLoop)
                                {
                                    containerStack.Push(containerLoop.Specification.LoopId);
                                }

                                if (currentContainer is HierarchicalLoop hloop)
                                {
                                    containerStack.Push($"{hloop.Specification.LoopId}[{hloop.Id}]");
                                }

                                currentContainer = currentContainer.Parent;
                                continue;
                            }

                            break;
                        }

                        break;
                    }

                    segmentString = reader.ReadNextSegment();
                    segmentId     = reader.ReadSegmentId(segmentString);
                    segmentIndex++;
                }

                return(envelopes);
            }
        }
コード例 #31
0
        public void CreatePurchaseOrderChangeNotice860()
        {
            DateTime purcaseOrderDate  = new DateTime(2010, 8, 17, 08, 50, 0);
            DateTime changeOrderDate   = DateTime.Now;
            DateTime requestedShipDate = DateTime.Now.AddDays(2d);

            Interchange interchange = new Interchange(changeOrderDate, 245, true)
            {
                InterchangeSenderIdQualifier   = "01",
                InterchangeSenderId            = "828513080",
                InterchangeReceiverIdQualifier = "01",
                InterchangeReceiverId          = "001903202U",
                InterchangeDate = changeOrderDate,
            };

            interchange.SetElement(14, "0");             //No Aknowlegement is 0

            FunctionGroup group = interchange.AddFunctionGroup("PO", changeOrderDate, 1, "005010X222");

            group.ApplicationSendersCode   = "828513080";
            group.ApplicationReceiversCode = "001903202U";
            group.Date          = changeOrderDate;
            group.ControlNumber = 245;

            Transaction transaction = group.AddTransaction("860", "0001");

            //BCH - Beginning Segment for Purchase Order Change
            //Mandatory / Max Use=1 time
            Segment bhtSegment = transaction.AddSegment("BCH");

            bhtSegment.SetElement((int)BeginningSegmentPurchaseOrderChangeIndex.TransactionSetPurpose, "01");               //01 is cancelllation  04 is change
            bhtSegment.SetElement((int)BeginningSegmentPurchaseOrderChangeIndex.TransactionSetTypeCode, "SA");
            bhtSegment.SetElement((int)BeginningSegmentPurchaseOrderChangeIndex.PurchaseOrderDate, purcaseOrderDate.ToString("yyyyMMdd"));
            bhtSegment.SetElement((int)BeginningSegmentPurchaseOrderChangeIndex.ChangeRequestDate, changeOrderDate.ToString("yyyyMMdd"));

            //REF- Reference Identification
            //Optional / Max Use=1 time
            bhtSegment = transaction.AddSegment("REF");
            bhtSegment.SetElement((int)ReferenceIdentificationIndex.ReferenceIdentificationQualifier, "IA");
            bhtSegment.SetElement((int)ReferenceIdentificationIndex.ReferenceNumber, "1to30chars");

            //DTM – Date/Time Reference
            //Optional/ Max Use=1 time
            bhtSegment = transaction.AddSegment("DTM");
            bhtSegment.SetElement((int)DateTimeReferenceIndex.TermsTypeCode, "010");
            bhtSegment.SetElement((int)DateTimeReferenceIndex.RequestedShipDate, requestedShipDate.ToString("yyyyMMdd"));

            //Add to test
            //N1 – Name
            //Optional / Max Use=1

            //N3 – Address Information
            //Conditional – use if N1 used/ Max Use=2

            //N4 – Geographic Location
            //Conditional – use if N3 used / Max Use=1 time

            //POC – Line Item Change
            //Mandatory / Max Use=1 times per loop / Max Loop=99 times

            //DTM – Date/Time Reference
            //Mandatory / Max Use=1 times per loop

            //CTT – Transaction Totals
            //Mandatory / Max Use=1 time

            var x12 = interchange.SerializeToX12(true);

            System.Diagnostics.Trace.Write(x12);
        }
コード例 #32
0
 public FunctionGroupInstance(FunctionGroup template)
     : base(template.GetName(), template.GetParentScope())
 {
 }
コード例 #33
0
        private static List <MdFileInfo> Scan(IEnumerable <string> assemblyPaths)
        {
            var fileInfos       = new List <MdFileInfo>();
            var nodeSearchModel = new NodeSearchModel();
            var pathManager     = new PathManager(new PathManagerParams());

            Console.WriteLine($"Starting scan of following assemblies: {string.Join(", ", assemblyPaths)}");

            var functionGroups = new Dictionary <string, Dictionary <string, FunctionGroup> >(new LibraryPathComparer());

            foreach (var path in assemblyPaths)
            {
                try
                {
                    var functionDescriptors = new List <FunctionDescriptor>();

                    if (new FileInfo(path).Extension == ".ds")
                    {
                        var dsDescriptors = GetFunctionDescriptorsFromDsFile(pathManager, path);
                        if (dsDescriptors != null)
                        {
                            functionDescriptors.AddRange(dsDescriptors);
                        }
                    }

                    else
                    {
                        //load the assembly.
                        Assembly     asm  = Assembly.LoadFrom(path);
                        AssemblyName name = asm.GetName();

                        if (NodeModelAssemblyLoader.ContainsNodeModelSubType(asm))
                        {
                            AddNodeModelsToSearchModel(asm, nodeSearchModel);
                            continue;
                        }

                        var dllDescriptors = GetFunctionDescriptorsFromDll(pathManager, asm);
                        if (dllDescriptors != null)
                        {
                            functionDescriptors.AddRange(dllDescriptors);
                        }
                    }

                    foreach (var descriptor in functionDescriptors)
                    {
                        Dictionary <string, FunctionGroup> functionGroupDict;
                        if (!functionGroups.TryGetValue(descriptor.Assembly, out functionGroupDict))
                        {
                            functionGroupDict = new Dictionary <string, FunctionGroup>();
                            functionGroups[descriptor.Assembly] = functionGroupDict;
                        }

                        var           qualifiedName = descriptor.QualifiedName;
                        FunctionGroup functionGroup;
                        if (!functionGroupDict.TryGetValue(qualifiedName, out functionGroup))
                        {
                            functionGroup = new FunctionGroup(qualifiedName);
                            functionGroupDict[qualifiedName] = functionGroup;
                        }
                        functionGroup.AddFunctionDescriptor(descriptor);
                    }
                }
                catch (Exception e)
                {
                    CommandHandler.LogExceptionToConsole(e);
                    continue;
                }
            }

            if (functionGroups.Any())
            {
                AddFunctionGroupsToSearch(functionGroups.Values.SelectMany(x => x.Values.Select(g => g)), nodeSearchModel);
            }

            fileInfos.AddRange(FileInfosFromSearchModel(nodeSearchModel));
            Console.WriteLine($"{fileInfos.Count()} nodes found during scan");

            return(fileInfos);
        }
コード例 #34
0
 public void SetConstructorGroup(FunctionGroup ctorGroup)
 {
     this.ctorGroup = ctorGroup;
 }
コード例 #35
0
        public List <Interchange> ParseMultiple(Stream stream, Encoding encoding)
        {
            var envelopes = new List <Interchange>();

            using (X12StreamReader reader = new X12StreamReader(stream, encoding))
            {
                Interchange envelop = new Interchange(_specFinder, reader.CurrentIsaSegment);
                envelopes.Add(envelop);
                Container     currentContainer = envelop;
                FunctionGroup fg = null;
                Transaction   tr = null;
                Dictionary <string, HierarchicalLoop> hloops = new Dictionary <string, HierarchicalLoop>();

                string segmentString = reader.ReadNextSegment();
                string segmentId     = reader.ReadSegmentId(segmentString);
                int    segmentIndex  = 1;
                while (segmentString.Length > 0)
                {
                    switch (segmentId)
                    {
                    case "ISA":
                        envelop = new Interchange(_specFinder, segmentString + reader.Delimiters.SegmentTerminator);
                        envelopes.Add(envelop);
                        currentContainer = envelop;
                        fg     = null;
                        tr     = null;
                        hloops = new Dictionary <string, HierarchicalLoop>();
                        break;

                    case "IEA":
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(string.Format("Segment {0} does not have a matching ISA segment preceding it.", segmentString));
                        }
                        envelop.SetTerminatingTrailerSegment(segmentString);
                        break;

                    case "GS":
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(String.Format("Segment '{0}' cannot occur before and ISA segment.", segmentString));
                        }

                        currentContainer = fg = envelop.AddFunctionGroup(segmentString);;
                        break;

                    case "GE":
                        if (fg == null)
                        {
                            throw new InvalidOperationException(String.Format("Segment '{0}' does not have a matching GS segment precending it.", segmentString));
                        }
                        fg.SetTerminatingTrailerSegment(segmentString);
                        fg = null;
                        break;

                    case "ST":
                        if (fg == null)
                        {
                            throw new InvalidOperationException(string.Format("segment '{0}' cannot occur without a preceding GS segment.", segmentString));
                        }
                        segmentIndex     = 1;
                        currentContainer = tr = fg.AddTransaction(segmentString);
                        hloops           = new Dictionary <string, HierarchicalLoop>();
                        break;

                    case "SE":
                        if (tr == null)
                        {
                            throw new InvalidOperationException(string.Format("Segment '{0}' does not have a matching ST segment preceding it.", segmentString));
                        }

                        tr.SetTerminatingTrailerSegment(segmentString);
                        tr = null;
                        break;

                    case "HL":
                        Segment hlSegment = new Segment(null, reader.Delimiters, segmentString);
                        string  id        = hlSegment.GetElement(1);
                        string  parentId  = hlSegment.GetElement(2);

                        if (parentId == "")
                        {
                            currentContainer = tr.AddHLoop(segmentString);
                        }
                        else
                        {
                            if (hloops.ContainsKey(parentId))
                            {
                                currentContainer = hloops[parentId].AddHLoop(segmentString);
                            }
                            else
                            {
                                throw new InvalidOperationException(String.Format("Hierarchical Loop {0} expects Parent ID {1} which did not occur preceding it.", id, parentId));
                            }
                        }
                        if (hloops.ContainsKey(id))
                        {
                            throw new InvalidOperationException(String.Format("Hierarchical Loop {0} cannot be added to transaction {1} because the ID {2} already exists.", segmentString, tr.ControlNumber, id));
                        }
                        hloops.Add(id, (HierarchicalLoop)currentContainer);
                        break;

                    case "TA1":     // Technical acknowledgement
                        if (envelop == null)
                        {
                            throw new InvalidOperationException(string.Format("Segment {0} does not have a matching ISA segment preceding it.", segmentString));
                        }
                        envelop.AddSegment(segmentString);
                        break;

                    default:
                        while (currentContainer != null)
                        {
                            if (currentContainer.AddSegment(segmentString) != null)
                            {
                                break;
                            }
                            else
                            {
                                if (currentContainer is LoopContainer)
                                {
                                    LoopContainer loopContainer = (LoopContainer)currentContainer;

                                    Loop newLoop = loopContainer.AddLoop(segmentString);
                                    if (newLoop != null)
                                    {
                                        currentContainer = newLoop;
                                        break;
                                    }
                                    else
                                    {
                                        if (currentContainer is Transaction)
                                        {
                                            var tran = (Transaction)currentContainer;

                                            throw new TransactionValidationException(
                                                      "Segment '{3}' in segment position {4} within transaction '{1}' cannot be identified within the supplied specification for transaction set {0}.", tran.IdentifierCode, tran.ControlNumber, "", segmentString, segmentIndex);
                                        }
                                        else
                                        {
                                            currentContainer = currentContainer.Parent;
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        break;
                    }
                    segmentString = reader.ReadNextSegment();
                    segmentId     = reader.ReadSegmentId(segmentString);
                    segmentIndex++;
                }
                return(envelopes);
            }
        }
コード例 #36
0
 /// <summary>
 /// BPS Logic Builder function category.
 /// </summary>
 /// <param name="functionGroup"></param>
 public FunctionGroupAttribute(FunctionGroup functionGroup)
 {
     this.FunctionGroup = functionGroup;
 }
コード例 #37
0
ファイル: X12Extensions.cs プロジェクト: alcheByte/X12.NET
        public static void Add999Transaction(this FunctionGroup group, IEnumerable <FunctionalGroupResponse> groupResponses)
        {
            int transactionId = 0;

            foreach (var groupResponse in groupResponses)
            {
                var trans = group.AddTransaction("999", string.Format("{0:0000}", ++transactionId));
                if (group.VersionIdentifierCode.Contains("5010"))
                {
                    trans.SetElement(3, group.VersionIdentifierCode);
                }

                // Functional group response header
                var ak1 = trans.AddSegment <TypedSegmentAK1>(new TypedSegmentAK1());
                ak1.AK101_FunctionalIdCode      = groupResponse.FunctionalIdCode;
                ak1.AK102_GroupControlNumber    = groupResponse.GroupControlNumber;
                ak1.AK103_VersionIdentifierCode = groupResponse.VersionIdentifierCode;

                foreach (var response in groupResponse.TransactionSetResponses)
                {
                    // Transaction Set Response Header
                    var ak2 = trans.AddLoop <TypedLoopAK2>(new TypedLoopAK2());
                    ak2.AK201_TransactionSetIdentifierCode = response.TransactionSetIdentifierCode;
                    ak2.AK202_TransactionSetControlNumber  = response.TransactionSetControlNumber;
                    if (!string.IsNullOrEmpty(response.ImplementationConventionReference))
                    {
                        ak2.AK203_ImplementationConventionReference = response.ImplementationConventionReference;
                    }


                    foreach (var segmentError in response.SegmentErrors.OrderBy(se => se.SegmentPosition))
                    {
                        var ik3 = ak2.AddLoop <TypedLoopIK3>(new TypedLoopIK3());
                        ik3.IK301_SegmentIdCode = segmentError.SegmentIdCode;
                        ik3.IK302_SegmentPositionInTransactionSet = segmentError.SegmentPosition;
                        if (segmentError.LoopIdentifierCode != null)
                        {
                            ik3.IK303_LoopIdentifierCode = segmentError.LoopIdentifierCode;
                        }
                        if (segmentError.ImplementationSegmentSyntaxErrorCode != null)
                        {
                            ik3.IK304_SyntaxErrorCode = segmentError.ImplementationSegmentSyntaxErrorCode;
                        }

                        foreach (var context in segmentError.ContextErrors)
                        {
                            var ctx = ik3.AddSegment <TypedSegmentCTX>(new TypedSegmentCTX());
                            ctx.CTX01._1_ContextName                  = "SITUATIONAL TRIGGER";
                            ctx.CTX01._2_ContextReference             = context.IdentificationReference;
                            ctx.CTX02_SegmentIdCode                   = context.SegmentIdCode;
                            ctx.CTX03_SegmentPositionInTransactionSet = context.SegmentPositionInTransactionSet;
                            ctx.CTX04_LoopIdentifierCode              = context.LoopIdentifierCode;
                        }

                        foreach (var elementNote in segmentError.ElementNotes)
                        {
                            var ik4 = ik3.AddLoop <TypedLoopIK4>(new TypedLoopIK4());
                            ik4.IK401._1_ElementPositionInSegment = elementNote.PositionInSegment.ElementPositionInSegment;
                            ik4.IK401._2_ComponentDataElementPositionInComposite = elementNote.PositionInSegment.ComponentDataElementPositionInComposite;
                            ik4.IK401._3_RepeatingDataElementPosition            = elementNote.PositionInSegment.RepeatingDataElementPosition;
                            if (elementNote.DataElementReferenceNumber != null)
                            {
                                ik4.IK402_DataElementReferenceNumber = elementNote.DataElementReferenceNumber;
                            }
                            ik4.IK403_SyntaxErrorCode = elementNote.SyntaxErrorCode;
                            if (elementNote.CopyOfBadElement != null)
                            {
                                ik4.IK404_CopyOfBaDataElement = elementNote.CopyOfBadElement;
                            }

                            foreach (var context in elementNote.ContextErrors)
                            {
                                var ctx = ik4.AddSegment <TypedSegmentCTX>(new TypedSegmentCTX());
                                ctx.CTX01._1_ContextName                  = "SITUATIONAL TRIGGER";
                                ctx.CTX01._2_ContextReference             = context.IdentificationReference;
                                ctx.CTX02_SegmentIdCode                   = context.SegmentIdCode;
                                ctx.CTX03_SegmentPositionInTransactionSet = context.SegmentPositionInTransactionSet;
                                ctx.CTX04_LoopIdentifierCode              = context.LoopIdentifierCode;
                            }
                        }
                    }

                    // Transaction Set Response Trailer
                    var ik5 = ak2.AddSegment <TypedSegmentIK5>(new TypedSegmentIK5());
                    ik5.IK501_TransactionSetAcknowledgmentCode = response.AcknowledgmentCode.ToString().Substring(0, 1);

                    if (response.SyntaxErrorCodes.Count > 0)
                    {
                        ik5.IK502_SyntaxErrorCode = response.SyntaxErrorCodes[0];
                    }
                    if (response.SyntaxErrorCodes.Count > 1)
                    {
                        ik5.IK503_SyntaxErrorCode = response.SyntaxErrorCodes[1];
                    }
                    if (response.SyntaxErrorCodes.Count > 2)
                    {
                        ik5.IK504_SyntaxErrorCode = response.SyntaxErrorCodes[2];
                    }
                    if (response.SyntaxErrorCodes.Count > 3)
                    {
                        ik5.IK505_SyntaxErrorCode = response.SyntaxErrorCodes[3];
                    }
                    if (response.SyntaxErrorCodes.Count > 4)
                    {
                        ik5.IK506_SyntaxErrorCode = response.SyntaxErrorCodes[4];
                    }
                }

                // Functional group response trailer
                var ak9 = trans.AddSegment <TypedSegmentAK9>(new TypedSegmentAK9());
                ak9.AK901_FunctionalGroupAcknowledgeCode  = groupResponse.AcknowledgmentCode.ToString().Substring(0, 1);
                ak9.AK902_NumberOfTransactionSetsIncluded = groupResponse.TransactionSetResponses.Count;
                ak9.AK903_NumberOfReceivedTransactionSets = groupResponse.TransactionSetResponses.Count;
                ak9.AK904_NumberOfAcceptedTransactionSets = groupResponse.TransactionSetResponses.Where(tsr => tsr.AcknowledgmentCode == AcknowledgmentCodeEnum.A_Accepted || tsr.AcknowledgmentCode == AcknowledgmentCodeEnum.E_Accepted_ButErrorsWereNoted).Count();

                if (groupResponse.SyntaxErrorCodes.Count > 0)
                {
                    ak9.AK905_FunctionalGroupSyntaxErrorCode = groupResponse.SyntaxErrorCodes[0];
                }
                if (groupResponse.SyntaxErrorCodes.Count > 1)
                {
                    ak9.AK906_FunctionalGroupSyntaxErrorCode = groupResponse.SyntaxErrorCodes[1];
                }
                if (groupResponse.SyntaxErrorCodes.Count > 2)
                {
                    ak9.AK907_FunctionalGroupSyntaxErrorCode = groupResponse.SyntaxErrorCodes[2];
                }
                if (groupResponse.SyntaxErrorCodes.Count > 3)
                {
                    ak9.AK908_FunctionalGroupSyntaxErrorCode = groupResponse.SyntaxErrorCodes[3];
                }
                if (groupResponse.SyntaxErrorCodes.Count > 4)
                {
                    ak9.AK909_FunctionalGroupSyntaxErrorCode = groupResponse.SyntaxErrorCodes[4];
                }
            }
        }