예제 #1
0
        private static string UpdateEvents(HPatternInstance instance, HPatternSettings settings, Transaction transaction)
        {
            BasicParser parser = new BasicParser("");

            DeleteGeneratedBlocks(parser);

            UpdateEventCodes(instance.Settings, parser);

            parser.InsertBefore(0, MenuContext.get(instance.WebObject.Actions).Events());

            // Se não vou gerar BC e tenho abas
            if (!instance.Transaction.WebBC && instance.Transaction.Form.Tabs.Count > 0)
            {
                Tab tabs = Tab.getTab(instance.Transaction.Form, transaction);
                parser.InsertBefore(0, tabs.Subs());
                //parser.InsertBefore(0, TemplateAbas.EventsExtra(instance.Transaction.Form));
            }
            UpdateEventActions(instance, settings, parser);
            UpdateEventPrompts(instance, settings,parser);
            UpdateEventAfterTrn(instance, transaction, parser);
            UpdateEventStart(instance, settings, transaction, parser);

            return parser.Text;
        }
예제 #2
0
        private static void UpdateEventCodes( HPatternSettings settings, BasicParser parser)
        {
            string codes = TemplateInternal.EventCodes(TemplateInternal.CodeType.Transaction, settings);
            if (!String.IsNullOrEmpty(codes))
            {

                StringBuilder eventBuilder = new StringBuilder();
                //eventBuilder.AppendLine(k_GeneratedMarkerStart);
                eventBuilder.AppendLine(codes);
                //eventBuilder.AppendLine(k_GeneratedMarkerEnd);
                eventBuilder.Append(Environment.NewLine);
                parser.InsertBefore(0, eventBuilder.ToString());

            }
        }
예제 #3
0
 private static void UpdateEventPrompts(HPatternInstance instance,HPatternSettings settings, BasicParser parser)
 {
     string tmp = Helpers.Template.PromptEvents(instance.Transaction.Form, settings);
     if (!String.IsNullOrEmpty(tmp))
     {
         StringBuilder eventCode = new StringBuilder();
         //eventCode.AppendLine(Indentation.Indent(k_GeneratedMarkerStart, 1));
         eventCode.Append(tmp);
         eventCode.Append(Environment.NewLine);
         //eventCode.AppendLine(Indentation.Indent(k_GeneratedMarkerEnd, 1));
         parser.InsertBefore(0, eventCode.ToString());
     }
 }
예제 #4
0
        private static void UpdateEventCode(BasicParser parser, string[] eventName, string eventCode)
        {
            StringBuilder eventBuilder = new StringBuilder();
            eventBuilder.AppendLine("Event " + String.Join(" ", eventName));
            bool isNewEvent = true;

            // Keep the current event code, if any.
            List<string> beginEvent = new List<string>();

            beginEvent.Add("Event");
            beginEvent.AddRange(eventName);
            string currentEvent = parser.GetBlock(beginEvent.ToArray(), new string[] { "EndEvent" }, 0, true);
            if (currentEvent != null)
            {
                isNewEvent = false;
                string eventNameLastToken = eventName[eventName.Length - 1];
                int eventBodyStart = currentEvent.ToLower().IndexOf(eventNameLastToken.ToLower()) + eventNameLastToken.Length;
                int eventBodyEnd = currentEvent.ToLower().IndexOf("endevent");

                if (eventBodyStart != -1 && eventBodyEnd != -1)
                {
                    string currentEventCode = currentEvent.Substring(eventBodyStart, eventBodyEnd - eventBodyStart);
                    if (currentEventCode.Trim() != String.Empty)
                    {
                        currentEventCode = currentEventCode.TrimStart(Environment.NewLine.ToCharArray());
                        currentEventCode = currentEventCode.TrimEnd(Environment.NewLine.ToCharArray());
                        eventBuilder.AppendLine(currentEventCode);
                    }
                }
            }

            // Add the desired code.
            //eventBuilder.AppendLine(Indentation.Indent(k_GeneratedMarkerStart, 1));
            eventBuilder.AppendLine(Indentation.Indent(eventCode, 1));
            //eventBuilder.AppendLine(Indentation.Indent(k_GeneratedMarkerEnd, 1));
            eventBuilder.Append("EndEvent");

            if (isNewEvent)
            {
                eventBuilder.Append(Environment.NewLine);
                parser.InsertBefore(0, eventBuilder.ToString());
            }
            else
            {
                parser.ReplaceBlock(beginEvent.ToArray(), new string[] { "EndEvent" }, eventBuilder.ToString());
            }
        }