public override void BeforeSaveObjects(PatternInstance instance, InstanceObjects instanceObjects)
        {
            base.BeforeSaveObjects(instance, instanceObjects);

            foreach (InstanceObject instanceObject in instanceObjects)
            {
                string outputSDTName;

                List <KeyValuePair <string, object> > props = new List <KeyValuePair <string, object> >();
                if (instanceObject.Name.EndsWith("DataProvider"))
                {
                    props.Add(new KeyValuePair <string, object>("OutputCollection", true));
                    props.Add(new KeyValuePair <string, object>("OutputCollectionName", "DataCollection"));

                    outputSDTName = "Data";
                }
                else
                {
                    outputSDTName = "Definition";
                }

                SDT outputSDT = SDT.Get(instanceObject.Model, new QualifiedName("GeneXusAI.Custom", outputSDTName));
                if (outputSDT != null)
                {
                    props.Add(new KeyValuePair <string, object>("OutputSDT", new DataProviderOutputReference(outputSDT)));
                }

                instanceObject.GeneratedObject.SetPropertyValues(props);
            }
        }
Exemplo n.º 2
0
        internal static bool IsGeneratedByPattern(KBObject obj)
        {
            Boolean           isGeneratedWithPattern = false;
            PatternDefinition pattern;

            if (InstanceManager.IsInstanceObject(obj, out pattern))
            {
                isGeneratedWithPattern = true;
            }
            bool isParentPattern = false;

            foreach (PatternDefinition p in PatternEngine.Patterns)
            {
                if (PatternInstance.Get(obj, p.Id) != null)
                {
                    isParentPattern = true;
                }
            }
            if (isGeneratedWithPattern || isParentPattern)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public override bool OnUpdate(float deltaTime)
        {
            PatternInstance pattern = _instances[_currentPattern];
            bool            done    = pattern.Update(deltaTime, _hostEntity.Position);

            if (done)
            {
                _currentPattern++;
                if (_currentPattern >= _instances.Length)
                {
                    _currentLoop++;
                }

                bool doLoop = everyFrame & (_loops < 0 | _currentLoop <= _loops);
                _currentPattern = doLoop ? _currentPattern % _instances.Length : _currentPattern;
                if (everyFrame & _currentPattern == 0)
                {
                    for (int i = 0; i < _instances.Length; i++)
                    {
                        _instances[i].Reset();
                    }
                }
            }
            return(_currentPattern >= _instances.Length);
        }
Exemplo n.º 4
0
        private void listViewPatterns_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                ListViewItem item = listViewPatterns.GetItemAt(e.X, e.Y);
                if (item == null)
                {
                    return;
                }

                ContextMenuStrip contextMenu = new ContextMenuStrip();

                PatternInstance instance = item.Tag as PatternInstance;
                foreach (var pair in instance.GetInvolvingEvents())
                {
                    ToolStripMenuItem menuItem = new ToolStripMenuItem(pair.Item1);
                    int targetID = pair.Item2;

                    menuItem.Click += delegate(object s, EventArgs ea)
                    {
                        PatternDoubleClick(targetID);
                    };

                    contextMenu.Items.Add(menuItem);
                }

                contextMenu.Show(this, e.Location);
            }
        }
Exemplo n.º 5
0
        public override void Generate(KBObject baseObject, PatternInstance instance)
        {
            MLModelInstance mlModelInstance = new MLModelInstance(instance.Model);

            mlModelInstance.Initialize();
            mlModelInstance.SaveTo(instance);
        }
Exemplo n.º 6
0
        // Use only internal memory to analysis and respond to given speech input
        // Expecting well formatd input
        // <Debug> This function isn't complete yet and currently only deplyed for debug purpose
        // <Development> In the fucture this fuction will be integrated as part of original Speak() function and change its access level from public to private
        public List <string> SpeakNative(string input, string instigator, string themeContext = null)
        {
            // Do preprocessing on inputs to suite better to our conceptual model (e.g. Pronoun interpretation)
            // ...

            // Do first order accessor/interrupter handling events
            // ...

            // (Option) Emotional State Filtering: short path thinking (Do it here or below)
            // ...

            // Do memory and conceptual construction etc. operations
            // ...

            // Recognize pattern and do pattern specific response
            PatternInstance instance = AiriMemory.Recognize(input);

            //Instruction.Action action = instance.Type.PatternAction;
            //List<string> response = action.Execute(instance);
            //return response;

            // Comprehension
            // ... NExt

            // Organize generated output, substitution proper pronouns
            // ...

            // Coutersy decorations
            // ...

            // (Option) Emotional State Filtering (Do it here or above)
            // ...

            return(null);
        }
Exemplo n.º 7
0
        private void listViewPatterns_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListViewItem    selectedListViewItem    = null;
            PatternInstance selectedPatternInstance = null;

            Utils.Utils.LockWindowUpdate(this.Handle);

            if (listViewPatterns.SelectedIndices.Count > 0)
            {
                selectedListViewItem    = listViewPatterns.Items[listViewPatterns.SelectedIndices[0]];
                selectedPatternInstance = selectedListViewItem.Tag as PatternInstance;

                if (selectedPatternInstance is IPreviewablePatternInstance)
                {
                    IPreviewablePatternInstance previewable = (IPreviewablePatternInstance)selectedPatternInstance;

                    SnapshotCalculator snapshotCalculator = new SnapshotCalculator(LogProvider);
                    snapshotPreview1.SetSnapshot(snapshotCalculator.CalculateSnapshotAtID(previewable.FirstID));
                    snapshotPreview2.SetSnapshot(snapshotCalculator.CalculateSnapshotAtID(previewable.SecondID));
                }
            }
            else
            {
                snapshotPreview1.Clear();
                snapshotPreview2.Clear();
            }

            Utils.Utils.LockWindowUpdate((IntPtr)0);
        }
 public override StateAction Clone()
 {
     PatternInstance[] instances = new PatternInstance[_instances.Length];
     for (int i = 0; i < _instances.Length; i++)
     {
         instances[i] = _instances[i].Clone();
     }
     return(new SpawnPatternAction(_loops, instances, everyFrame, mustWait));
 }
Exemplo n.º 9
0
        public WebPanelUpdater(WebPanel obj,PatternInstance instance)
        {
            HPatternInstance wwInstance = HPatternInstance.Load(instance);

            ParserFactory pf = new ParserFactory(instance,null,null);
            ParserFactory.UpdateObject uo = getUpdateObject(wwInstance);
            if (uo != ParserFactory.UpdateObject.DoNotUpdate)
            {
                ParserFactory.ObjectTemplate ot = new ParserFactory.ObjectTemplate("",ParserFactory.ObjectType.WebPanel,"WPWebForm", "WPVariables", "WPEvents", "WPRules", "WPConditions");
                pf.MergeWebPanel(obj, instance.PatternPart.SelectSingleElement("instance/webPanelRoot"), uo, ot);
            }
        }
        protected override bool ConvertAfterRead(PatternInstance instance, XmlDocument rawData, Version fromVersion, Version toVersion)
        {
            bool converted = false;

            if (fromVersion < new Version(0, 5) && toVersion >= new Version(0, 5))
            {
                AssignLevelIds(instance);
                converted = true;
            }

            return converted;
        }
Exemplo n.º 11
0
        public override void Generate(KBObject baseObject, PatternInstance instance)
        {
            if (baseObject is Transaction)
            {

                //modMain.SetGXPath(Artech.Common.Helpers.IO.PathHelper.StartupPath);

                pinstance = instance;
                Transaction transaction = (Transaction)baseObject;
                HPatternInstance wwInstance = new HPatternInstance(transaction.Model);

                settings = wwInstance.Settings;

                //Dictionary<string, object> propertiesg = new Dictionary<string, object>();
                //propertiesg[Properties.HTMLATT.ReadOnly] = true;
                //settings.Grid.Rules

                //Dictionary<string, object> propertiesg = new Dictionary<string, object>();
                //propertiesg[Properties.HTMLSFL.Rules] = Properties.HTMLSFL.Rules_Values.Rows;

                //System.Text.Encoding.w
                // string template = System.Text.Encoding.Default.GetString(file.BlobPart.Data);

                // testes
                /*
                KBModel model = Artech.Architecture.UI.Framework.Services.UIServices.KB.CurrentModel;
                foreach (WikiFileKBObject file in WikiFileKBObject.GetAll(model)) {
                    System.Windows.Forms.MessageBox.Show("File: " + file.Name);
                    byte[] b = file.BlobPart.Data;
                    string saida = System.Text.StringBuilder .GetString(b);
                    System.Text.StringBuilder sb = System.Text.StringBuilder();

                }
                */

                //Antlr.StringTemplate.FileSystemTemplateLoader st = new Antlr.StringTemplate.FileSystemTemplateLoader("");

                Generate(transaction, wwInstance);
                wwInstance.SaveTo(instance);
            }
            else if (baseObject is WebPanel)
            {
                HPatternInstance wwInstance = new HPatternInstance(instance);
                if (wwInstance.WebPanelRoot == null)
                {
                    wwInstance.WebPanelRoot = new WebPanelRootElement();
                }
                wwInstance.SaveTo(instance);
            } else {
                throw new PatternException(Messages.ParentMustBeTransaction);
            }
        }
Exemplo n.º 12
0
        private void listViewPatterns_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && (e.Modifiers & Keys.Control) == Keys.Control)
            {
                if (listViewPatterns.SelectedIndices.Count == 1)
                {
                    PatternInstance patternInst = listViewPatterns.Items[
                        listViewPatterns.SelectedIndices[0]].Tag as PatternInstance;

                    patternInst.CopyToClipboard();
                }
            }
        }
        /// <summary>
        /// Группирует экземпляры паттернов по пересечениям.
        /// </summary>
        private IEnumerable <PatternInstance[]> GroupInstances(PatternInstance[] instances)
        {
            var disjointSet = PatternInstance.GetIntersectionGroups(instances);

            var instancesByGroup = instances.Select((x, i) => new {
                Value = x,
                Group = disjointSet.Find(i)
            });
            var groups      = instancesByGroup.GroupBy(i => i.Group);
            var groupValues = groups.Select(g => g.Select(h => h.Value).ToArray());

            return(groupValues);
        }
        public void PassIntParam(int value, out int retVal)
        {
            // Create and init a parameter list
            // We can't just use the CallMethod helper because we have out-parameters
            var paramList = new UiaParameterListHelper(TestSchema.GetInstance().PassIntParamMethod);

            paramList[0] = value;

            // Call through
            PatternInstance.CallMethod(TestSchema.GetInstance().PassIntParamMethod.Index, paramList.Data, paramList.Count);

            // Get the out-parameter
            retVal = (int)paramList[1];
        }
Exemplo n.º 15
0
        public override void UpdateParentObject(KBObject parent, PatternInstance instance)
        {
            base.UpdateParentObject(parent, instance);
            if (!GXVersion.IsGenexusServer)
            {
                Debug.Assert(parent != null && (parent is Transaction || parent is WebPanel));

                if (parent is Transaction)
                {
                    Transaction transaction = (Transaction)parent;
                    HPatternTransactionUpdater.Clear(instance, transaction);
                }
            }
        }
Exemplo n.º 16
0
        public static void Apply(PatternInstance instance, Transaction transaction)
        {
            HPatternInstance wwInstance = HPatternInstance.Load(instance);
            HPatternSettings wwSettings = wwInstance.Settings;

            // Update rules and events.
            bool gera = wwInstance.Transaction.WebBC;
            /*
            bool gera = wwSettings.Template.DataEntryWebPanelBC;
            if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                gera = true;
            if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                gera = false;
            */

            bool overwrite = (wwInstance.Transaction.UpdateObject == TransactionElement.UpdateObjectValue.Overwrite);

            if (gera)
            {
                transaction.SetPropertyValue(Properties.TRN.BusinessComponent, true);
            }

            if (wwSettings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor)
            {
                transaction.SetPropertyValue(Properties.TRN.Type, Properties.TRN.Type_Values.Component);
                transaction.SetPropertyValue(Properties.TRN.UrlAccess, Properties.TRN.UrlAccess_Values.Yes);
            }

            if (wwInstance.Transaction.UpdateObject != TransactionElement.UpdateObjectValue.DoNotUpdate)
            {

                UpdateProperties(wwInstance, wwSettings, transaction);
                UpdateVariables(wwInstance,wwSettings, transaction);
                ParserFactory.MergeRules(transaction.Rules, UpdateRules(wwInstance, wwSettings, transaction),overwrite);
                ParserFactory.MergeEvents(transaction.Events, UpdateEvents(wwInstance, wwSettings, transaction), overwrite);
                UpdateAttributes(wwInstance, wwSettings, transaction);

                if (wwInstance.Transaction.UpdateObject != TransactionElement.UpdateObjectValue.OnlyRulesEventsAndConditions)
                {
                    ParserFactory.MergeWebForm(transaction.WebForm, Heurys.Patterns.HPattern.Helpers.Template.TrnWebForm(transaction, wwSettings, wwInstance, false, "", false, wwInstance.Transaction));
                }

                if (wwInstance.DocumentationEnabled)
                {
                    TemplateInternal.DocumentationSave(transaction.Documentation, transaction, wwInstance, wwSettings);
                }

            }
        }
Exemplo n.º 17
0
        // Interaction Interface: Find which patterns a given sentence matches (Ideally any sentence matches only one pattern because we require EXACT match but designers can make mistakes so we return all matches)
        public List <PatternInstance> FindMatchPatterns(string sentence)
        {
            List <PatternInstance> matchedPatterns = new List <PatternInstance>();

            foreach (KeyValuePair <string, Pattern> entry in RecognizedPatterns)
            {
                PatternInstance result = IsMatchPattern(sentence, entry.Value);
                if (result != null)
                {
                    matchedPatterns.Add(result);
                }
            }

            return(matchedPatterns);
        }
 private void AssignLevelIds(PatternInstance instance)
 {
     IBaseCollection<PatternInstanceElement> levels = instance.PatternPart.SelectElements("instance/level");
     for (int i = 0; i < levels.Count; i++)
         levels[i].Attributes["id"] = String.Format("{0}:{1}", instance.KBObject.Guid, i + 1);
 }
Exemplo n.º 19
0
        public static HPatternInstance FastLoad(PatternInstance instance)
        {
            if (instance == null)
                throw new ArgumentNullException("instance");

            HPatternInstance wwInstance = new HPatternInstance(instance);
            return wwInstance;
        }
Exemplo n.º 20
0
 public static void Clear(PatternInstance instance, Transaction transaction)
 {
     // HPatternInstance wwInstance = HPatternInstance.Load(instance);
     ClearProperties(transaction);
     ClearRules(transaction);
     ClearEvents(transaction);
     ClearVariables(transaction);
 }
Exemplo n.º 21
0
        // Interaction Interface: Return whether or not a given sentence matches given pattern: If a match is found a PatternInstance will be returned other wise null
        // Notice that patterns provide EXACT matches, this gives designers flexibility in defining general or specific matches per need/context; For subpatterns the length cannot be decided though so an option if given
        // <Debug> Pending thorough logic check
        // @sentence: input sentence must be well formed: no auxiliary blanks, no punctuation (only words are allowed for now).
        public PatternInstance IsMatchPattern(string sentence, Pattern pattern, bool bExactMatch = true)
        {
            // Prepare return value
            PatternInstance instance = new PatternInstance();

            instance.Type = pattern;

            // Split sentence into words
            string[] words = sentence.Split(new char[] { ' ' });    // <Debug><Improvement> Current we are not dealing with sentences that might contain commas (and we should deal with it here),
            // or multiple sentences types in one piece (and this one should be handled and seperated by higher level input engine because a pattern is designed to handle one setence only (with commas)).

            int currentWord = 0;    // ID of the word we are matching against

            // Stage 1: Iterate through pattern elements: if all elements match then it is likely a good match
            foreach (PatternElement element in pattern.Elements)
            {
                // Make sure we still have more words to match against, otherwise input string is too short for this pattern
                if (words.Length <= currentWord)
                {
                    return(null);
                }

                // Predefine so later it won't cause local variable name conflict
                Phrase          phrase;
                bool            result;
                PatternInstance temp;
                WordAttribute   attribute;
                string          tempString;
                int             overlap;
                // Match element type and vlaue
                switch (element.Type)
                {
                case PatternElementType.SpecificWord:
                    // Prepare two strings
                    tempString = words[currentWord];
                    for (int i = currentWord + 1; i < words.Length; i++)
                    {
                        tempString = tempString + ' ' + words[i];
                    }
                    overlap = GetStringOverlapLowerCase(tempString, element.Key);

                    // If the following words don't match and it's not optional then this pattern doesn't match
                    if (overlap == -1 && element.bOptional == false)
                    {
                        return(null);
                    }
                    else
                    {
                        // Generate Pattern Element Instance and Proceed to next word
                        instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.SpecificWord, tempString.Substring(0, overlap)));
                        currentWord += GetNumOfWords(element.Key);
                    }
                    break;

                case PatternElementType.VarietyWord:
                    result = Vocabulary.IsWordVaryingFormOrSynonym(words[currentWord], element.Key);
                    if (result == false && element.bOptional == false)
                    {
                        return(null);
                    }
                    else
                    {
                        // Generate Pattern Element Instance and Proceed to next word
                        instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.VarietyWord, words[currentWord]));
                        currentWord++;
                    }
                    break;

                case PatternElementType.WordAttribute:
                    // <Debug> This is currently incomplete implementation, i.e. + for multiple constriants (e.g. for verbs)
                    attribute = (WordAttribute)Enum.Parse(typeof(WordAttribute), element.Key);
                    // foundWord = Vocabulary.ProbeWord(words[currentWord], attribute); // Notice for WordAttribute we are not matching against word, but phrase
                    tempString = words[currentWord];
                    for (int i = currentWord + 1; i < words.Length; i++)
                    {
                        tempString = tempString + ' ' + words[i];
                    }
                    phrase = Vocabulary.GetPhrase(tempString, attribute);
                    if (phrase == null && element.bOptional == false)
                    {
                        return(null);
                    }
                    else
                    {
                        // Generate Pattern Element Instance and Proceed to next word
                        instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.WordAttribute, phrase.Key));
                        currentWord += phrase.WordCount;
                    }
                    break;

                case PatternElementType.SubPattern:
                    tempString = words[currentWord];
                    for (int i = currentWord + 1; i < words.Length; i++)
                    {
                        tempString = tempString + ' ' + words[i];
                    }
                    temp = IsMatchPattern(tempString, element.SubPattern, false);       // Do not do an exact match in this case
                    if (temp == null && element.bOptional == false)
                    {
                        return(null);
                    }
                    else
                    {
                        // Generate Pattern Element Instance and Proceed to next word
                        instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.SubPattern, temp));
                        currentWord += temp.WordCount;
                    }
                    break;

                case PatternElementType.Choice:
                    // Return the first matched selection
                    bool bLoopBreak = false;
                    foreach (PatternElement choiceElement in element.Choices)
                    {
                        // break loop, not just the switch
                        if (bLoopBreak)
                        {
                            break;
                        }

                        // Match CHOICE element type and vlaue
                        // Notice that CHOICE elements are always optional, but at least one must be selected
                        switch (choiceElement.Type)
                        {
                        case PatternElementType.SpecificWord:
                            // Prepare two strings
                            tempString = words[currentWord];
                            for (int i = currentWord + 1; i < words.Length; i++)
                            {
                                tempString = tempString + ' ' + words[i];
                            }
                            overlap = GetStringOverlapLowerCase(tempString, choiceElement.Key);

                            // If next word doesn't match then continue; If match then no more loop
                            if (overlap == -1)
                            {
                                continue;
                            }
                            else
                            {
                                // Generate Pattern Element Instance and Proceed to next word
                                instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.SpecificWord, tempString.Substring(0, overlap)));
                                currentWord += GetNumOfWords(choiceElement.Key);
                                bLoopBreak   = true;
                            }
                            break;

                        case PatternElementType.VarietyWord:
                            // If word doesn't match then continue; If match then no more loop
                            result = Vocabulary.IsWordVaryingFormOrSynonym(words[currentWord], choiceElement.Key);
                            if (result == false)
                            {
                                continue;
                            }
                            else
                            {
                                // Generate Pattern Element Instance and Proceed to next word
                                instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.VarietyWord, words[currentWord]));
                                currentWord++;
                                bLoopBreak = true;
                            }
                            break;

                        case PatternElementType.WordAttribute:
                            attribute = (WordAttribute)Enum.Parse(typeof(WordAttribute), choiceElement.Key);
                            // foundWord = Vocabulary.ProbeWord(words[currentWord], attribute); // Notice for WordAttribute we are not matching against word, but phrase
                            tempString = words[currentWord];
                            for (int i = currentWord + 1; i < words.Length; i++)
                            {
                                tempString = tempString + ' ' + words[i];
                            }
                            phrase = Vocabulary.GetPhrase(tempString, attribute);
                            // If trailing string doesn't match then continue; If match then no more loop
                            if (phrase == null && choiceElement.bOptional == false)
                            {
                                continue;
                            }
                            else
                            {
                                // Generate Pattern Element Instance and Proceed to next word
                                instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.WordAttribute, phrase.Key));
                                currentWord += phrase.WordCount;
                                bLoopBreak   = true;
                            }
                            break;

                        case PatternElementType.SubPattern:
                            tempString = words[currentWord];
                            for (int i = currentWord + 1; i < words.Length; i++)
                            {
                                tempString = tempString + ' ' + words[i];
                            }
                            // If trailing string doesn't match then continue; If match then no more loop
                            temp = IsMatchPattern(tempString, choiceElement.SubPattern);
                            if (temp == null)
                            {
                                continue;
                            }
                            else
                            {
                                // Generate Pattern Element Instance and Proceed to next word
                                instance.ComponentElements.Add(new PatternElementInstance(PatternElementType.SubPattern, temp));
                                currentWord += temp.WordCount;
                                bLoopBreak   = true;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    // If no match was found then this pattern doesn't match, otherwise continue
                    if (bLoopBreak == false)
                    {
                        return(null);
                    }
                    break;

                default:
                    break;
                }
            }

            // Stage 2: If we are doing an exact match then make sure there is no auxiliary words
            if (bExactMatch == true && words.Length != currentWord)
            {
                return(null);
            }

            return(instance);
        }
Exemplo n.º 22
0
        public override void BeforeGenerateObject(PatternInstance instance, InstanceObject instanceObject)
        {
            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeGenerateObject Begin {0}", DateTime.Now.ToString()));
                CommonServices.Output.AddLine(String.Format(">>> instanceObject.Name {0}", instanceObject.Name));
            }
            HPatternInstance wwInstance = null;
            if (instanceObject.Instance != null)
                wwInstance = HPatternInstance.Load(instanceObject.Instance);

            //TESTS

            HPatternSettings settings = HPatternSettings.Get(instanceObject.Model);

            if (instanceObject.Object == HPatternObject.ListPrograms && !settings.Template.GenerateListPrograms)
            {
                instanceObject.Generate = false;
                return;
            }

            // 0.- Se temos a view, vamos verificar se é para gerar, se não, vamos apagar :D
            if (instanceObject.Object == HPatternObject.View
                || instanceObject.Object == HPatternObject.TabTabular
                || instanceObject.Object == HPatternObject.TabGrid
                || instanceObject.Object == HPatternObject.TabGridTrn
                || instanceObject.Object == HPatternObject.ExportTabGrid
                || instanceObject.Object == HPatternObject.TabGridSDT)
            {
                if (wwInstance != null)
                {
                    if (wwInstance.Transaction != null)
                    {
                        if (settings.Template.GenerateViewOnlyBC)
                        {
                            if (wwInstance.Levels != null)
                            {
                                if (wwInstance.Levels.Count > 0)
                                {
                                    if (!wwInstance.Transaction.WebBC)
                                    {

                                        instanceObject.Generate = false;
                                        return;

                                    }
                                }
                            }
                        } else {
                            if (instanceObject.Object == HPatternObject.TabGridTrn) {
                                if (wwInstance.Levels != null)
                                {
                                    if (wwInstance.Levels.Count > 0)
                                    {
                                        if (!wwInstance.Transaction.WebBC)
                                        {

                                            instanceObject.Generate = false;
                                            return;

                                        }
                                    }
                                }
                            }
                            if (instanceObject.Object == HPatternObject.TabTabular && settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor && wwInstance.Levels != null && wwInstance.Levels.Count > 0)
                            {
                                instanceObject.Generate = false;
                            }
                        }
                    }
                }
            }

            if (instanceObject.Object == HPatternObject.DataProviderGridModel || instanceObject.Object == HPatternObject.DataProviderGrid || instanceObject.Object == HPatternObject.SDTGrid || instanceObject.Object == HPatternObject.ProcedureGrid)
            {
                if (settings.Grid.GridType != HPattern.SettingsGridElement.GridTypeValue.Gxui)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            string trnName = "";
            if (wwInstance != null)
            {
                if (wwInstance.Transaction != null)
                {
                    trnName = wwInstance.Transaction.TransactionName.ToLower();
                }
            }

            // Gera BC
            if (instanceObject.Object == HPatternObject.TransactionBC || instanceObject.Object == HPatternObject.TransactionBCTab  || instanceObject.Object == HPatternObject.SDTBC || instanceObject.Object == HPatternObject.DataProviderBC || instanceObject.Object == HPatternObject.ProcedureBC || instanceObject.Object == HPatternObject.ProcedureSaveBC)
            {
                bool gera = wwInstance.Transaction.WebBC;
                /*
                bool gera = settings.Template.DataEntryWebPanelBC;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                    gera = true;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                b    gera = false;
                */

                if (gera)
                {
                    if (instanceObject.Object == HPatternObject.TransactionBC)
                    {
                        if (wwInstance.Transaction.Form.Tabs.Count > 0)
                            gera = false;
                    }
                    if (instanceObject.Object == HPatternObject.TransactionBCTab)
                    {
                        if (wwInstance.Transaction.Form.Tabs.Count <= 0)
                            gera = false;
                    }
                }

                if (gera)
                {
                    if (instanceObject.Object == HPatternObject.DataProviderBC) {

                    }

                } else {

                    instanceObject.Generate = false;
                    return;
                }
            }

            if (instanceObject.Object == HPatternObject.DataProviderDSM)
            {
                bool geraAba = false;
                bool gera = false;
                if (wwInstance.Transaction != null && wwInstance.Transaction.WebBC)
                    gera = true;
                /*
                bool gera = settings.Template.DataEntryWebPanelBC;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                    gera = true;
                if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                    gera = false;
                */

                if (gera)
                {
                    if (wwInstance.Levels != null && wwInstance.Levels.Count > 0)
                    {
                        LevelElement l = wwInstance.Levels[0];
                        if (l.View != null)
                        {
                            if (l.View.Tabs.Count > 0)
                            {
                                geraAba = true;
                            }
                        }
                    }
                }

                if (!geraAba)
                {
                    if (wwInstance.WebObject.Form.Tabs != null)
                    {
                        if (wwInstance.WebObject.Form.Tabs.Count > 0)
                        {
                            geraAba = true;
                        }
                    }
                }
                if (geraAba)
                {
                    if (settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor)
                    {
                        geraAba = false;
                    }

                }
                if (!geraAba)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            // Customize generation of export procedure.
            if (instanceObject.Object == HPatternObject.ExportSelection || instanceObject.Object == HPatternObject.ExportTabGrid)
            {
                IGridObject gridObject = wwInstance.GetElement<IGridObject>(instanceObject.Element);
                if (gridObject.Actions.Export == null)
                {
                    instanceObject.Generate = false;
                    return;
                }
            }

            // Customize names.
            if (instanceObject.Object == HPatternObject.Selection)
            {
                SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                instanceObject.Name = settings.Objects.SelectionName(selec);
                instanceObject.Description = selec.Description;
            }

            if (instanceObject.Object == HPatternObject.Prompt)
            {
                PromptElement prompt = wwInstance.GetElement<PromptElement>(instanceObject.Element);
                instanceObject.Name = settings.Objects.PromptName(prompt);
                instanceObject.Description = prompt.Description;
            }

            if (instanceObject.Object == HPatternObject.View)
            {

                ViewElement view = wwInstance.GetElement<ViewElement>(instanceObject.Element);
                if (view != null)
                {
                    if (view.Tabs.Count > 0)
                    {
                        bool gera2 = wwInstance.Transaction.WebBC;
                        /*
                        bool gera2 = settings.Template.DataEntryWebPanelBC;
                        if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                            gera2 = true;
                        if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                            gera2 = false;
                        */

                        if (gera2)
                            instanceObject.Generate = false;
                    }

                    instanceObject.Name = settings.Objects.ViewName(view);

                }

            }

            if (!settings.Template.LoadSDTWithDataProvider)
            {
                if (instanceObject.Object == HPatternObject.DataProviderBC)
                {
                    instanceObject.Generate = false;
                }
            }

            if (instanceObject.Object == HPatternObject.ExportSelection || instanceObject.Object == HPatternObject.ExportTabGrid)
                instanceObject.Name = settings.Objects.ExportProcedureName(wwInstance.GetElement<IGridObject>(instanceObject.Element));

            if (instanceObject.Object == HPatternObject.GridSDT || instanceObject.Object == HPatternObject.TabGridSDT)
                instanceObject.Name = settings.Objects.GridSdtName(wwInstance.GetElement<IGridObject>(instanceObject.Element));

            if (instanceObject.Object == HPatternObject.TabGridTrn)
            {
                TabElement tabtrn = wwInstance.GetElement<TabElement>(instanceObject.Element);
                if (tabtrn.GetCallMethod != TabElement.CallMethodValue.Popup)
                {
                    instanceObject.Generate = false;
                }
            }

            // Vamos colocar os nomes conforme arquivo separado por ";"
            if (!String.IsNullOrEmpty(settings.Template.ObjectsNamesName))
            {
                if (instanceObject.Generate)
                {
                    if (instanceObject.Object == HPatternObject.Selection)
                    {
                        /*
                        string tmpN = GetSugestName(trnName, settings);
                        if (!String.IsNullOrEmpty(tmpN))
                        {
                            instanceObject.Name = tmpN;
                            SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                            selec.ObjectName = tmpN;

                        }
                        */
                        SelectionElement selec = wwInstance.GetElement<SelectionElement>(instanceObject.Element);
                        if (!String.IsNullOrEmpty(selec.ObjName))
                        {
                            instanceObject.Name = selec.ObjName;
                        }

                    }

                    if (wwInstance != null)
                    {
                        if (wwInstance.Transaction.WebBC)
                        {

                            if (instanceObject.Object == HPatternObject.TransactionBC)
                            {
                                /*
                                string tmpN = GetSugestName(trnName, settings);
                                if (!String.IsNullOrEmpty(tmpN))
                                {
                                    instanceObject.Name = tmpN;
                                    TransactionElement selec = wwInstance.GetElement<TransactionElement>(instanceObject.Element);
                                    selec.ObjectName = tmpN;
                                }
                                */
                                TransactionElement selec = wwInstance.GetElement<TransactionElement>(instanceObject.Element);
                                if (!String.IsNullOrEmpty(selec.ObjName))
                                {
                                    instanceObject.Name = selec.ObjName;
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TransactionBCTab)
                            {
                                if (wwInstance.Transaction.Form.Tabs.Count > 0)
                                {
                                    /*
                                    string tmpN = GetSugestName(trnName, settings);
                                    if (!String.IsNullOrEmpty(tmpN))
                                    {
                                        instanceObject.Name = tmpN;
                                        TabFormElement selec = wwInstance.GetElement<TabFormElement>(instanceObject.Element);
                                        selec.ObjectName = tmpN;

                                    }
                                    */
                                    TabFormElement selec = wwInstance.GetElement<TabFormElement>(instanceObject.Element);
                                    if (!String.IsNullOrEmpty(selec.ObjName))
                                    {
                                        instanceObject.Name = selec.ObjName;
                                    }
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TabGrid)
                            {
                                if (wwInstance.Levels[0].View != null)
                                {
                                    ViewElement v = wwInstance.Levels[0].View;
                                    if (v.Tabs.Count > 0)
                                    {
                                        TabElement selec = wwInstance.GetElement<TabElement>(instanceObject.Element);
                                        if (!String.IsNullOrEmpty(selec.ObjName))
                                        {
                                            instanceObject.Name = selec.ObjName;
                                        }
                                    }
                                }
                            }

                            if (instanceObject.Object == HPatternObject.TabGridTrn)
                            {
                                if (wwInstance.Levels[0].View != null)
                                {
                                    ViewElement v = wwInstance.Levels[0].View;
                                    if (v.Tabs.Count > 0)
                                    {
                                        TabElement selec = wwInstance.GetElement<TabElement>(instanceObject.Element);
                                        if (!String.IsNullOrEmpty(selec.ObjNameTrn))
                                        {
                                            instanceObject.Name = selec.ObjNameTrn;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            /*
            if (wwInstance != null)
            {
                if (instanceObject.Generate && (!settings.Template.WebPanelBCDefault) && wwInstance.UpdateWebPanelBC == HPatternInstance.UpdateWebPanelBCValue.Default)
                {
                    if (instanceObject.Object == HPatternObject.TransactionBC || instanceObject.Object == HPatternObject.TransactionBCTab)
                    {
                        WebPanel web3 = WebPanel.Get(instance.Model, instanceObject.Name);
                        if (web3 != null)
                        {
                            web3.Rules.IsDefault = true;
                            web3.Events.IsDefault = true;
                            web3.Conditions.IsDefault = true;
                            web3.Variables.IsDefault = true;
                            web3.WebForm.IsDefault = true;
                            web3.Save();

                        }
                    }
                }
            }
            */

            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeGenerateObject End {0}", DateTime.Now.ToString()));
            }
        }
Exemplo n.º 23
0
        public static void CountGeneratedByPattern()
        {
            IKBService kbserv = UIServices.KB;

            string title      = "KBDoctor - Count objects generated by patterns";
            string outputFile = Functions.CreateOutputFile(kbserv, title);

            IOutputService output = CommonServices.Output;

            output.StartSection(title);


            KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);

            writer.AddHeader(title);
            writer.AddTableHeader(new string[] { "Name", "Type", "Description" });


            Int32 Objcount      = 0;
            Int32 ObjNoPattern  = 0;
            Int32 ObjOther      = 0;
            Int32 ObjNoGenerate = 0;

            foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll())
            {
                Objcount += 1;
                if (KBDoctorCore.Sources.Utility.isGenerated(obj) && (obj is WebPanel || obj is Transaction || obj is WorkPanel || obj is DataSelector))
                {
                    //El objeto es generado con algun pattern?
                    Boolean           isGeneratedWithPattern = false;
                    PatternDefinition pattern;
                    if (InstanceManager.IsInstanceObject(obj, out pattern))
                    {
                        isGeneratedWithPattern = true;
                    }

                    //El objeto tiene algun pattern asociado? En caso de transacciones y webpanels del WW+
                    bool isParentPattern = false;
                    foreach (PatternDefinition p in PatternEngine.Patterns)
                    {
                        if (PatternInstance.Get(obj, p.Id) != null)
                        {
                            isParentPattern = true;
                        }
                    }

                    if (!isGeneratedWithPattern && !isParentPattern)
                    {
                        ObjNoPattern += 1;
                        writer.AddTableData(new string[] { Functions.linkObject(obj), obj.TypeDescriptor.Name, obj.Description });
                    }
                }
            }

            writer.AddTableData(new string[] { " ", " ", " " });
            Int32 IndexP = Objcount == 0 ? 0 : (ObjNoPattern * 100 / Objcount);

            writer.AddTableData(new string[] { "Objects no generated with patterns / Total objects", IndexP.ToString() + " %", "Obj.No Patterns=" + ObjNoPattern.ToString() + " Total Objects=" + Objcount.ToString() });

            string texto = "Objects no generated with patterns / Total objects = " + IndexP.ToString() + " %" + ",No generated with Patterns=" + ObjNoPattern.ToString() + ", Total Objects=" + Objcount.ToString();

            Functions.AddLineSummary("SummaryPatternGeneration.txt", texto);


            writer.AddFooter();
            writer.Close();

            KBDoctorHelper.ShowKBDoctorResults(outputFile);
            bool success = true;

            output.EndSection(title, success);
        }
Exemplo n.º 24
0
 public override IEnumerable<KBObjectNameKey> GetObsoleteObjects(PatternInstance instance, OldInstanceFile instanceFile)
 {
     Transaction parentTransaction = (instance.KBObject as Transaction);
     if (parentTransaction != null)
         yield return new KBObjectNameKey(instance.Model, ObjClass.WebPanel, "Controller" + parentTransaction.Name);
 }
Exemplo n.º 25
0
        public static HPatternInstance Load(PatternInstance instance)
        {
            if (instance == null)
                throw new ArgumentNullException("instance");

            HPatternInstance cachedWWInstance = instance.GetPropertyValue<HPatternInstance>(k_CacheProperty);
            if (cachedWWInstance != null)
                return cachedWWInstance;

            HPatternInstance wwInstance = new HPatternInstance(instance);
            wwInstance.Prepare();

            instance.PatternPart.InstanceChanged += new EventHandler<InstanceChangedEventArgs>(wwInstance.AssociatedInstance_InstanceChanged);
            instance.SilentSetPropertyValue(k_CacheProperty, wwInstance);
            return wwInstance;
        }
Exemplo n.º 26
0
 // Execute the action
 // This should ideally be data driven and use Instructions for specific actions
 // An action might be textual and produce many text outputs as response
 static public List <string> Execute(string ActionName, PatternInstance instance)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 27
0
        public override void UpdateParentObject(KBObject parent, PatternInstance instance)
        {
            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> UpdateParentObject Begin {0}", DateTime.Now.ToString()));
            }
            base.UpdateParentObject(parent, instance);

            if (!GXVersion.IsGenexusServer)
            {
                Debug.Assert(parent != null && (parent is Transaction || parent is WebPanel));

                if (parent is Transaction)
                {

                    Transaction transaction = (Transaction)parent;
                    HPatternTransactionUpdater.Apply(instance, transaction);

                    HPatternSettings settings = HPatternSettings.Get(instance.Model);
                    HPatternInstance wwInstance = HPatternInstance.Load(instance);

                    bool gera = wwInstance.Transaction.WebBC;
                    /*
                    bool gera = settings.Template.DataEntryWebPanelBC;
                    if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                        gera = true;
                    if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                        gera = false;
                    */

                    if (gera)
                    {
                        if (wwInstance.Levels[0] != null)
                        {
                            if (wwInstance.Levels[0].View != null)
                            {
                                foreach (TabElement tabe in wwInstance.Levels[0].View.Tabs)
                                {
                                    if (tabe.Type == TabElement.TypeValue.Grid && tabe.Transaction != null && tabe.Transaction.Transaction != null)
                                    {
                                        Transaction trn = tabe.Transaction.Transaction;
                                        trn.SetPropertyValue(Properties.TRN.BusinessComponent, true);
                                        trn.Save();
                                    }
                                }
                            }
                        }
                    }

                }
                else if (parent is WebPanel)
                {
                    //CommonServices.Output.AddLine(">>> WebPanel não implementado!");
                    new WebPanelUpdater((WebPanel)parent, instance);
                }
            }

            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> UpdateParentObject End {0}", DateTime.Now.ToString()));
            }
        }
Exemplo n.º 28
0
        //public static VersionC GetLic()
        //{
        //    return VersionC.GetLic();
        //}
        public override void BeforeStartBuild(PatternInstance instance)
        {
            //modMain.SetGXPath(Artech.Common.Helpers.IO.PathHelper.StartupPath);
            //GetLic().CheckC();

            if (Messages.TestTime())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeStartBuild Begin {0}", DateTime.Now.ToString()));
            }
            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeStartBuild {0}", DateTime.Now.ToString()));
            }

            /*
            if (modActiveLockVb2005.InitActivelock())
            {
                CommonServices.Output.AddLine(">>> Activelock True");
            }
            else
            {
                CommonServices.Output.AddLine(">>> Activelock False");
            }
            */

            base.BeforeStartBuild(instance);
            HPatternSettings.ResetCache(instance.Model);
            if (Messages.TestTime())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeStartBuild End {0}", DateTime.Now.ToString()));
            }
        }
Exemplo n.º 29
0
        public override void BeforeSaveObjects(PatternInstance instance, InstanceObjects instanceObjects)
        {
            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeSaveObjects Begin {0}", DateTime.Now.ToString()));
            }
            base.BeforeSaveObjects(instance, instanceObjects);

            ParserFactory.getFactory(instance, instanceObjects);

            HPatternSettings settings = HPatternSettings.Get(instance.Model);
            HPatternInstance wwInstance = HPatternInstance.Load(instance);
            string trnName = "";
            if (wwInstance.Transaction != null && wwInstance.Transaction.Transaction != null)
            {
                trnName = wwInstance.Transaction.TransactionName;
            }

            foreach (DataProvider dp in instanceObjects.GetGroup(HPatternObject.DataProviderDSM).GetObjects<DataProvider>())
            {
                SDT sdt = SDT.Get(instance.Model, "MenuData");

                if (sdt != null)
                    dp.SetPropertyValue(Properties.DPRV.Output, new DataProviderOutputReference(new KBObjectReference(sdt)));
            }

            foreach (DataProvider dp in instanceObjects.GetGroup(HPatternObject.DataProviderGridModel).GetObjects<DataProvider>())
            {
                SDT sdt = SDT.Get(instance.Model, "gxuiGridColumnModel");

                if (sdt != null)
                    dp.SetPropertyValue(Properties.DPRV.Output, new DataProviderOutputReference(new KBObjectReference(sdt)));
            }

            if (wwInstance != null)
            {
                if (wwInstance.Levels.Count > 0)
                {
                    if (wwInstance.Levels[0].Selection != null)
                    {
                        if (wwInstance.Levels[0].Selection.GridType == SettingsGridElement.GridTypeValue.Gxui)
                        {
                            foreach (Procedure p in instanceObjects.GetGroup(HPatternObject.ProcedureGrid).GetObjects<Procedure>())
                            {
                                p.SetPropertyValue(Properties.PRC.MainProgram, true);
                                p.SetPropertyValue(Properties.PRC.CallProtocol, Properties.PRC.CallProtocol_Values.Http);
                            }
                        }
                    }
                }
            }

            bool gera = false;
            if (wwInstance.Transaction != null)
            {
                gera = wwInstance.Transaction.WebBC;
            }
            /*
            bool gera = settings.Template.DataEntryWebPanelBC;
            if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "true")
                gera = true;
            if (wwInstance.Transaction.DataEntryWebPanelBC.ToLower() == "false")
                gera = false;
            */

            LevelElement level = null;
            if (wwInstance.Levels != null && wwInstance.Levels.Count > 0)
            {
                level = wwInstance.Levels[0];
            }
            ViewElement view = null;
            if (gera || level == null)
            {
                gera = false;
            }
            else
            {
                view = level.View;
                if (view == null)
                    gera = false;
            }

            if (gera)
            {

                InstanceObjectsGroup group = instanceObjects.GetGroup(HPatternObject.TabGrid);

                foreach (WebPanel webi in group.GetObjects<WebPanel>())
                {
                    foreach (TabElement tabe in view.Tabs)
                    {
                        if (tabe.Type == TabElement.TypeValue.Grid && tabe.Transaction !=null && tabe.Transaction.Transaction != null)
                        {
                            if (webi.Name == tabe.Wcname) {
                                webi.SetPropertyValue(Properties.WBP.Type, Properties.WBP.Type_Values.WebPage);
                            }
                        }
                    }

                }

                InstanceObjectsGroup group2 = instanceObjects.GetGroup(HPatternObject.TabGridTrn);

                foreach (WebPanel webi in group2.GetObjects<WebPanel>())
                {
                    webi.SetPropertyValue(Properties.WBP.Type, Properties.WBP.Type_Values.WebPage);
                }
            }

            WebPanel mSelection = settings.MasterPages.Selection;
            WebPanel mPrompt = settings.MasterPages.Prompt;
            WebPanel mView = settings.MasterPages.View;
            WebPanel mTransaction = settings.MasterPages.Transaction;
            Theme tTema = null;
            string AMP = SettingsThemeElement.SetObjectThemeValue.True;
            string ATema = settings.Theme.SetObjectTheme;
            if (ATema != SettingsThemeElement.SetObjectThemeValue.False)
                tTema = settings.Theme.Theme;

            if (settings.CustomThemeMasterPage != null)
            {
                foreach (SettingsThemeMasterPageElement sis in settings.CustomThemeMasterPage)
                {
                    if (wwInstance.Transaction != null && wwInstance.Transaction.Transaction != null)
                    {
                        if (wwInstance.Transaction.TransactionName.IndexOf(sis.Name, StringComparison.InvariantCultureIgnoreCase) >= 0)
                        {
                            if (sis.SetMasterPage != SettingsThemeElement.SetObjectThemeValue.False)
                            {
                                AMP = sis.SetMasterPage;
                                mSelection = sis.Selection;
                                mPrompt = sis.Prompt;
                                mView = sis.View;
                                mTransaction = sis.Transaction;
                            }
                            if (sis.SetTheme != SettingsThemeElement.SetObjectThemeValue.False)
                            {
                                ATema = sis.SetTheme;
                                tTema = sis.Theme;
                            }
                            break;
                        }
                    }
                }
            }

            // Define a mesma Categoria da transação ao objetos gerados pelo pattern
            if (wwInstance.Transaction != null && wwInstance.Transaction.Transaction != null)
            {
                foreach (Artech.Udm.Framework.Entity cat in wwInstance.Transaction.Transaction.Categories)
                {
                    foreach (KBObject obj in instanceObjects.GeneratedObjects)
                    {
                        obj.AddCategory(cat);
                    }
                }
            }

            // Set master page for objects.
            SetObjectsMasterPage("s", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.Selection), mSelection, tTema,ATema,AMP);
            SetObjectsMasterPage("p", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.Prompt), mPrompt, tTema, ATema, AMP);
            SetObjectsMasterPage("", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.View), mView, tTema, ATema, AMP);
            SetObjectsMasterPage("", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.TransactionBC), mTransaction, tTema, ATema, AMP);
            SetObjectsMasterPage("", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.TransactionBCTab), mTransaction, tTema, ATema, AMP);
            SetObjectsMasterPage("", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.TabGrid), mTransaction, tTema, ATema, AMP);
            SetObjectsMasterPage("", settings.Grid.AutomaticRefresh, wwInstance, instanceObjects.GetGroup(HPatternObject.TabGridTrn), mTransaction, tTema, ATema, AMP);

            if (wwInstance.Transaction != null && wwInstance.Transaction.WebBC)
            {
                if (settings.Template.WebPanelBCDefault == false && wwInstance.UpdateWebPanelBC == HPatternInstance.UpdateWebPanelBCValue.Default)
                {

                    InstanceObjectsGroup group2 = null;
                    if (wwInstance.Transaction.Form.Tabs.Count > 0)
                    {
                        group2 = instanceObjects.GetGroup(HPatternObject.TransactionBCTab);
                        foreach (WebPanel web2 in group2.GetObjects<WebPanel>())
                        {

                            web2.Rules.IsDefault = true;
                            web2.Events.IsDefault = true;
                            web2.Conditions.IsDefault = true;
                            web2.Variables.IsDefault = true;
                            web2.WebForm.IsDefault = true;
                            web2.Rules.IsDefault = false;
                            web2.Events.IsDefault = false;
                            web2.Conditions.IsDefault = false;
                            web2.Variables.IsDefault = false;
                            web2.WebForm.IsDefault = false;
                            //web2.Save();
                        }
                    }
                    else
                    {
                        group2 = instanceObjects.GetGroup(HPatternObject.TransactionBC);
                        foreach (WebPanel web2 in group2.GetObjects<WebPanel>())
                        {
                            web2.Rules.IsDefault = true;
                            web2.Events.IsDefault = true;
                            web2.Conditions.IsDefault = true;
                            web2.Variables.IsDefault = true;
                            web2.WebForm.IsDefault = true;
                            //web2.Save();
                            web2.Rules.IsDefault = false;
                            web2.Events.IsDefault = false;
                            web2.Conditions.IsDefault = false;
                            web2.Variables.IsDefault = false;
                            web2.WebForm.IsDefault = false;
                            //web2.Save();
                        }
                    }

                    if (wwInstance.Levels[0].View != null)
                    {
                        ViewElement v = wwInstance.Levels[0].View;
                        if (v.Tabs.Count > 0)
                        {
                            group2 = instanceObjects.GetGroup(HPatternObject.TabGrid);
                            foreach (WebPanel web2 in group2.GetObjects<WebPanel>())
                            {
                                web2.Rules.IsDefault = true;
                                web2.Events.IsDefault = true;
                                web2.Conditions.IsDefault = true;
                                web2.Variables.IsDefault = true;
                                web2.WebForm.IsDefault = true;
                                //web2.Save();
                                web2.Rules.IsDefault = false;
                                web2.Events.IsDefault = false;
                                web2.Conditions.IsDefault = false;
                                web2.Variables.IsDefault = false;
                                web2.WebForm.IsDefault = false;
                                //web2.Save();
                            }
                        }
                    }
                }
            }

            if (wwInstance.DocumentationEnabled)
            {
                foreach (KBObject obj in instanceObjects.GeneratedObjects)
                {
                    if (obj is WebPanel)
                    {
                        WebPanel obja = obj as WebPanel;
                        ChangeDocumentation(obja.Documentation, obj, wwInstance,settings);
                    }
                    if (obj is Procedure)
                    {
                        ChangeDocumentation((obj as Procedure).Documentation, obj, wwInstance, settings);
                    }
                    if (obj is DataProvider)
                    {
                        ChangeDocumentation((obj as DataProvider).Documentation, obj, wwInstance, settings);
                    }
                    if (obj is SDT)
                    {
                        ChangeDocumentation((obj as SDT).Documentation, obj, wwInstance, settings);
                    }

                }
            }

            if (Messages.Debug())
            {
                CommonServices.Output.AddLine(String.Format(">>> BeforeSaveObjects End {0}", DateTime.Now.ToString()));
            }
        }
Exemplo n.º 30
0
 public override void PostConvertInstance(PatternInstance instance, OldInstanceFile instanceFile)
 {
     int iLevel = 1;
     foreach (PatternInstanceElement levelElement in instance.PatternPart.RootElement.SelectElements("level"))
         levelElement.Attributes["id"] = String.Format("{0}:{1}", instance.Parent.Guid, iLevel++);
 }
Exemplo n.º 31
0
        public static HPatternInstance FastLoadCache(PatternInstance instance)
        {
            if (instance == null)
                throw new ArgumentNullException("instance");

            HPatternInstance cachedWWInstance = instance.GetPropertyValue<HPatternInstance>(k_CacheProperty);
            if (cachedWWInstance != null)
                return cachedWWInstance;

            HPatternInstance wwInstance = new HPatternInstance(instance);
            return wwInstance;
        }
Exemplo n.º 32
0
        public override bool Validate(PatternInstance instance, OutputMessages output)
        {
            bool hasErrors = false;
            foreach (PatternInstanceElement actionElement in instance.PatternPart.SelectElements("//actions/action"))
            {
                PatternInstanceElement container = actionElement.Parent.Parent;
                Debug.Assert(container != null && (container.Type == InstanceElements.Transaction || container.Type == InstanceElements.Selection || container.Type == InstanceElements.Tab || container.Type == InstanceElements.WebPanelRoot || container.Type == InstanceElements.Prompt));

                if (container != null)
                {
                    bool cannotHaveInGrid = (container.Type == InstanceElements.Tab && container.Attributes.GetPropertyValue<string>(InstanceAttributes.Tab.Type) == TabElement.TypeValue.Tabular);
                    bool isInGrid = actionElement.Attributes.GetPropertyValue<bool>(InstanceAttributes.Action.InGrid);

                    if (isInGrid && cannotHaveInGrid)
                    {
                        output.Add(new OutputError(Messages.FormatValidationErrorActionCannotBeInGrid(actionElement.ToString()), new PatternElementPosition(actionElement)));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is Transaction)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/transaction") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó Transaction"));
                        hasErrors = true;
                    } else if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó WebPanel na Transação"));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is WebPanel)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó WebPanel"));
                        hasErrors = true;
                    }
                    else if (instance.PatternPart.SelectSingleElement("instance/transaction") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó Transaction no WebPanel"));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement tabElement in instance.PatternPart.SelectElements("tab"))
                {
                    string nome = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Name);
                    string desc = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Description);
                    if (!Variable.IsValidName(nome))
                    {
                        output.Add(new OutputError(String.Format("Caracter inválido no nome da Aba: '{0}', Descrição: {1} ",nome,desc)));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {
                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            if (!hasErrors)
            {

                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridColumnPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {

                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetColumnPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Column Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            // TODO não permtir textblock no form com o nome internalname duplicado

            return !hasErrors;
        }
Exemplo n.º 33
0
        public override void AfterImportResources(PatternInstance instance)
        {
            base.AfterImportResources(instance);

            // Important: RELOAD the settings, cached version probably had invalid references.
            HPatternSettings.ResetCache(instance.Model);

            // Set the default theme for the Knowledge Base.
            HPatternSettings settings = HPatternSettings.Get(instance.Model);
            if (settings.Theme.Theme != null)
            {
                KBModel model = instance.KB.DesignModel.Environment.TargetModel;
                model.SetPropertyValue(Properties.MODEL.DefaultTheme, new KBObjectReference(settings.Theme.Theme));
                model.Save();
            }
        }
Exemplo n.º 34
0
 public ParserFactory(PatternInstance instance, InstanceObject io, ManualResetEvent doneEvent)
 {
     mInstance = instance;
     mIo = io;
     mDoneEvent = doneEvent;
 }
Exemplo n.º 35
0
        public static void getFactory(PatternInstance instance, InstanceObjects instanceObjects)
        {
            /*
            int mTot = 0;
            foreach (InstanceObject io in instanceObjects)
            {
                mTot++;
            }
            ManualResetEvent[] doneEvents = new ManualResetEvent[mTot];

            int i = 0;
            foreach (InstanceObject io in instanceObjects)
            {
                doneEvents[i] = new ManualResetEvent(false);
                ParserFactory pf = new ParserFactory(instance, io, doneEvents[i]);
                ThreadPool.QueueUserWorkItem(pf.MergeObject, i);
                i++;

            }
            WaitHandle.WaitAll(doneEvents);
            */
            foreach (InstanceObject io in instanceObjects)
            {
                ParserFactory pf = new ParserFactory(instance, io, null);
                pf.MergeObject(null);
            }
        }