Ejemplo n.º 1
0
        public void AddRow(RowCollectionRow row)
        {
            // Return RowCollection object to write new row, if is null then make new RowCollection object
            RowCollection rowCollection = GetRowCollectionObjectFromCellNumber(row.ColumnCount, true);

            rowCollection.Rows.Add(row);
        }
Ejemplo n.º 2
0
 public void Add(RowCollectionRow row)
 {
     row.rowCollection = this.rowCollection;
     row.Index         = rowList.Count;
     rowList.Add(row);
     this.rowCollection.LabelName    = "Columns count:" + row.ColumnCount + ", Row count: " + rowList.Count.ToString();
     this.rowCollection.tbEndAt.Text = rowList.Count.ToString();
     this.rowCollection.SetSettings();
 }
Ejemplo n.º 3
0
            public RowCollectionRow FetchNext()
            {
                RowCollectionRow row           = null;
                RowCollection    rowCollection = null;

                this.rowCollectionMenager.ActiveObjectInstance[this.rowCollection.DepthIndex] = this.ToString();

                //#1 child logic code
                if (this.rowCollection.HasChildrenControls == true)
                {
                    // reset curent row index for this instance
                    if (this.rowCollection.curentRowIndex == -1)
                    {
                        this.rowCollection.curentRowIndex = this.rowCollection.startAt;
                    }

                    rowCollection = (RowCollection)this.rowCollection.FetchCurentChild();
                    //if (rowCollection == null)
                    //{
                    //    rowCollection = (RowCollection)this.FetchNextChild();
                    //}
                    row = this.FetchNext();
                }
                //#1
                else
                {
                    //#2 test
                    if (this.rowCollection.curentRowIndex == -1)
                    {
                        this.rowCollection.curentRowIndex = this.rowCollection.startAt;
                    }
                    else
                    {
                        this.rowCollection.curentRowIndex = this.rowCollection.curentRowIndex + this.rowCollection.increment;
                    }
                    //#2

                    if ((this.rowCollection.curentRowIndex >= this.rowCollection.startAt && this.rowCollection.startAt <= this.rowCollection.endAt) || (this.rowCollection.curentRowIndex <= this.rowCollection.startAt && this.rowCollection.startAt > this.rowCollection.endAt))
                    {
                        if ((this.rowCollection.curentRowIndex <= this.rowCollection.endAt && this.rowCollection.startAt <= this.rowCollection.endAt) || (this.rowCollection.curentRowIndex >= this.rowCollection.endAt && this.rowCollection.startAt > this.rowCollection.endAt))
                        {
                            row = this[this.rowCollection.curentRowIndex];
                        }
                    }
                    //this.curentRowIndex = this.curentRowIndex + this.increment;
                }
                return(row);
            }
Ejemplo n.º 4
0
        private bool TestAgenstFilters(RowCollectionRow row)
        {
            bool resultAction;
            bool resultActionLastAnd = false;
            bool haveAndLogicalInThisGroup;

            for (int i = 0; i <= 9; i++)
            {
                haveAndLogicalInThisGroup = false;
                foreach (RowCollectionFilterItem filter in filtersItems)
                {
                    if (filter.LogicalGroup == i)
                    {
                        // test action agens value
                        resultAction = TestAgenstFilterAction(filter, row[filter.ColumnID].Value);
                        if (filter.LogicalOperator == RowCollectionFilterItem.LogicalOperatorType.OR)
                        {
                            if (resultAction == true)
                            {
                                return(true);
                            }
                        }
                        else if (filter.LogicalOperator == RowCollectionFilterItem.LogicalOperatorType.AND)
                        {
                            if (haveAndLogicalInThisGroup == true && resultActionLastAnd == false)
                            {
                                break;
                            }
                            haveAndLogicalInThisGroup = true;
                            resultActionLastAnd       = resultAction;
                        }
                    }
                }

                if (haveAndLogicalInThisGroup == true && resultActionLastAnd == true)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Generic method, it will return string value of row object and columnt index
 /// </summary>
 /// <param name="row">Row object</param>
 /// <param name="objectValue">Column index</param>
 /// <returns></returns>
 /// 
 private string DataObjectGetValue(RowCollectionRow row, Tag2 tag)
 {
     string result = null;
     int columntID = 0;
     try
     {
         if (tag.Child.Child == null)
         {
             columntID = int.Parse(tag.Child.Name);
             // Column index is zero base, but user need to treat it like non zero base else it is error
             if (columntID > 0)
             {
                 // Increment column index to 1, zero index base, user will access it by one base
                 columntID--;
                 result = row[columntID].Value;
             }
             else
             {
                 ModuleLog.Write(new string[] { constError_SyntaxError, tag.InputText }, this, "DataObjectGetValue", ModuleLog.LogType.ERROR);
                 result = constError_SyntaxError;
             }
         }
         else
         {
             ModuleLog.Write(new string[] { constError_CommandNotFound, tag.InputText }, this, "DataObjectGetValue", ModuleLog.LogType.ERROR);
             result = constError_SyntaxError;
         }
     }
     catch (Exception ex)
     {
         ModuleLog.Write(new string[] { constError_ExecutingBlock, tag.InputText }, this, "DataObjectGetValue", ModuleLog.LogType.DEBUG);
         ModuleLog.Write(ex, this, "DataObjectGetValue", ModuleLog.LogType.ERROR);
         result = constError_SyntaxError;
     }
     //if (result == null)
     //{
     //    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "DataObjectGetValue", ModuleLog.LogType.ERROR);
     //    result = constError_SyntaxError;
     //}
     return result;
 }
Ejemplo n.º 6
0
 private string StringObject(RowCollectionRow row, Tag2 tag)
 {
     string result = null;
     try
     {
         if (tag.Child.Name == "split")
         {
             // string.split.[index].[split string].[text]
             string[] splitList = tag.Child.Child.Child.Child.Name.Split(new string[] { tag.Child.Child.Child.Name }, StringSplitOptions.RemoveEmptyEntries);
             int index;
             index = int.Parse(tag.Child.Child.Name);
             // if index is in range of array
             if (index < splitList.Length)
             {
                 result = splitList[index];
             }
             else
             {
                 // else return empty string and log waring
                 result = "";
                 ModuleLog.Write("String out of range returning empty string", this, "StringObject", ModuleLog.LogType.WARNING);
             }
         }
         else
         {
             ModuleLog.Write(string.Concat(constError_SyntaxError, " (", tag.InputText, ")"), this, "StringObject", ModuleLog.LogType.ERROR);
             result = constError_SyntaxError;
         }
     }
     catch (Exception ex)
     {
         ModuleLog.Write(string.Concat(constError_SyntaxError, " (", tag.InputText, ")"), this, "StringObject", ModuleLog.LogType.DEBUG);
         ModuleLog.Write(ex, this, "StringObject", ModuleLog.LogType.ERROR);
         result = constError_SyntaxError;
     }
     return result;
 }
Ejemplo n.º 7
0
 public string ReplaceTags(string text, RowCollectionRow row)
 {
     return ReplaceTags(text, row, false);
 }
Ejemplo n.º 8
0
        private string ReplaceSuportedObject(string objectName, string objectValue, RowCollectionRow row)
        {
            //
            //  I N F O - ReplaceTagsFromInToOut will not cut this
            //

            Tag2 tag = new Tag2("{=" + objectName + "." + objectValue);

            if (objectName == "date")
            {
                // Call to datetime object
                return this.DateObject(objectValue);
            }
            else if (objectName == "string")
            {
                // Call to main generic method, other method will call it to get object row value and then format it
                // this one just return pure text value

                //
                //   Ovo sa split je privremeno ovdje stavito
                //
                if (tag.Child.Name.Equals("split"))
                {
                    return StringObject(row, tag);
                }
                else
                {
                    return StringObject(row, objectValue);
                }
            }
            else if (objectName == "nth")
            {
                // Call to main generic method, other method will call it to get object row value and then format it
                // this one just return pure text value
                return NTHObject(row, objectValue);
            }
            else if (objectName == "number")
            {
                // Call to main generic method, other method will call it to get object row value and then format it
                // this one just return pure text value
                return NumberObject(row, objectValue);
            }
            else if (tag.Name == "input")
            {
                // Call to InputObject
                return InputObject(row, tag);
            }
            else if (tag.Name == "var")
            {
                // Call to VarObject
                return VarObject(tag);
            }
            else if (tag.Name == "array")
            {
                // Call to ArrayObject
                ArrayObject arrayObject = new ArrayObject(tag, varObjectList);
                return arrayObject.ProcessTag();
            }
            else if (tag.Name == "format")
            {
                // Call to FormatObject, get and set method
                return FormatObject(tag);
            }
            else if (objectName == "xml")
            {
                // Call to FormatObject, get and set method
                return XMLObject(row, objectValue);
            }
            else if (objectName.StartsWith("random"))
            {
                return RandomObject(objectName, objectValue);
            }
            else if (objectName.StartsWith("md5"))
            {
                return MD5Object(objectName, objectValue);
            }
            else if (tag.Name == "file")
            {
                FileObject fileObject = new FileObject(tag, ref varObjectList);
                return fileObject.ProcessTag();
            }
            else if (tag.Name == "dir")
            {
                DirObject dirObject = new DirObject(tag, ref varObjectList);
                return dirObject.ProcessTag();
            }
            else if (tag.Name == "graphics")
            {
                GraphicsObject fileObject = new GraphicsObject(tag);
                return fileObject.ProcessTag();
            }
            else if (tag.Name == "math")
            {
                MathObject mathObject = new MathObject(tag);
                return mathObject.ProcessTag();
            }
            else
            {
                // objects that dont need be in initialization proccess
                if (isInitialization == false)
                {
                    if (tag.Name == "active")
                    {
                        return ActiveObject(tag);

                    }
                    else if (tag.Name == "data")
                    {
                        // Call to main generic method, other method will call it to get object row value and then format it
                        // this one just return pure text value
                        return DataObjectGetValue(row, tag);
                    }
                    //else if (objectName.StartsWith("data"))
                    //{
                    //    return DataObjectGetValue(objectName, objectValue);
                    //}
                    else
                    {
                        return DataObjectGetValue(tag);
                    }
                }
            }

            return null;
        }
Ejemplo n.º 9
0
 public void Add(RowCollectionRow row)
 {
     row.rowCollection = this.rowCollection;
     row.Index = rowList.Count;
     rowList.Add(row);
     this.rowCollection.LabelName = "Columns count:" + row.ColumnCount + ", Row count: " + rowList.Count.ToString();
     this.rowCollection.tbEndAt.Text = rowList.Count.ToString();
     this.rowCollection.SetSettings();
 }
Ejemplo n.º 10
0
            /// <summary>
            /// Peek next row object, if instance have child then will retrun row object from last child
            /// </summary>
            /// <returns></returns>
            public RowCollectionRow PeekNext()
            {
                RowCollectionRow row           = null;
                RowCollection    rowCollection = null;

                //#1 child logic code
                if (this.rowCollection.HasChildrenControls == true)
                {
                    // reset curent row index for this instance
                    //if (this.curentRowIndex == -1)
                    //{
                    //this.curentRowIndex = this.startAt;
                    //}

                    // Fetch curent child instance
                    rowCollection = (RowCollection)this.rowCollection.FetchCurentChild();
                    // if child is not null then peek next row object
                    if (rowCollection != null)
                    {
                        row = this.PeekNext();
                        if (row == null)
                        {
                            if (this.rowCollection.curentRowIndex + 1 <= this.rowCollection.endAt)
                            {
                                this.rowCollection.curentRowIndex++;
                                this.rowCollection.ResetAllChildCurentRowIndex(-1);
                                rowCollection.curentRowIndex = -1;
                                row = this.PeekNext();
                            }
                            else
                            {
                                //
                                if (this.rowCollection.FetchNextChild() != null)
                                {
                                    this.rowCollection.curentRowIndex = -1; // 0;
                                    row = this.PeekNext();
                                }
                                else
                                {
                                    this.rowCollection.ResetNextChildStatus();
                                    //this.curentRowIndex = -1;
                                    //row = this.PeekNext();
                                }
                            }
                        }
                    }
                }
                //#1
                else
                {
                    int peekCurentRowIndex = this.rowCollection.curentRowIndex;
                    //#2 test
                    if (peekCurentRowIndex == -1)
                    {
                        peekCurentRowIndex = this.rowCollection.startAt;
                    }
                    else
                    {
                        peekCurentRowIndex = peekCurentRowIndex + this.rowCollection.increment;
                    }
                    //#2


                    if ((peekCurentRowIndex >= this.rowCollection.startAt && this.rowCollection.startAt <= this.rowCollection.endAt) || (peekCurentRowIndex <= this.rowCollection.startAt && this.rowCollection.startAt > this.rowCollection.endAt))
                    {
                        if ((peekCurentRowIndex <= this.rowCollection.endAt && this.rowCollection.startAt <= this.rowCollection.endAt) || (peekCurentRowIndex >= this.rowCollection.endAt && this.rowCollection.startAt > this.rowCollection.endAt))
                        {
                            row = this[peekCurentRowIndex];
                        }
                    }
                }
                return(row);
            }
Ejemplo n.º 11
0
        public void GroupBy(object sender, EventArgs args)
        {
            RowCollection newRowCollection;
            TagsReplace   tagReplace;
            Tag           tag;
            InputBox      inputBox;
            DialogResult  dialogResult;
            string        stringOne = "";
            string        stringTwo = "";
            int           counter   = 0;
            int           uniuqeID  = 0;

            object[] tmp;
            string   inputString;

            // load input text from settings
            inputString  = this.rowCollectionMenager.SettingsMenager.LoadSetting("data-object-groupby-tag", "{=data.1}");
            inputBox     = new InputBox("Tag source", "Group by tag source", inputString);
            dialogResult = inputBox.ShowDialog();
            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    newRowCollection            = rowCollectionMenager.CreateRowCollection(2, rowCollectionMenager.GetUniqueRowCollectionName("GroupBy", 2, 0));
                    newRowCollection.Columns[0] = "Value";
                    newRowCollection.Columns[1] = "Count";
                    tmp        = new object[rowCollection.Rows.Count];
                    tagReplace = new TagsReplace(this.rowCollectionMenager);
                    this.rowCollectionMenager.TemperalySaveLoadLockStatus(false);
                    //for (int i = 0; i < rowList.Count; i++)
                    foreach (RowCollectionRow objectRow in rowCollection.Rows)
                    {
                        counter   = 0;
                        stringOne = tagReplace.ReplaceTags(inputBox.InputTekst, objectRow);
                        for (int j = 0; j < tmp.Length; j++)
                        {
                            if (tmp[j] != null)
                            {
                                tag       = (Tag)tmp[j];
                                stringTwo = tag.Name;
                                if (stringOne.Equals(stringTwo))
                                {
                                    counter = int.Parse(tag.Value);
                                    counter++;
                                    tag.Value = counter.ToString();
                                    break;
                                }
                            }
                            else
                            {
                                // exit this loop, all is null object
                                break;
                            }
                        }
                        if (counter == 0)
                        {
                            tag           = new Tag(stringOne, "1");
                            tmp[uniuqeID] = tag;
                            uniuqeID++;
                        }
                    }
                    RowCollectionRow row;
                    foreach (Tag isTag in tmp)
                    {
                        row = new RowCollectionRow(newRowCollection, new string[] { isTag.Name, isTag.Value });

                        newRowCollection.Rows.Add(row);
                    }
                    // save settings
                    this.rowCollectionMenager.SettingsMenager.Items.Add(new DamirM.CommonLibrary.SettingsMenagerStructure2(inputBox.InputTekst, "data-object-groupby-tag", inputBox.InputTekst, "", DamirM.CommonLibrary.SettingsMenager2.Type.Text));
                }
                catch (Exception ex)
                {
                    ModuleLog.Write(ex, this, "GroupBy", ModuleLog.LogType.ERROR);
                }
                finally
                {
                    this.rowCollectionMenager.TemperalySaveLoadLockStatus(true);
                }
            }
        }
Ejemplo n.º 12
0
        private void BrowseFolders(string path)
        {
            RowCollection rowCollection;
            RowCollectionRow objectRow;
            Regex regex;
            Match match;
            string[] folderColumns;
            int counter = 0;
            string[] folderList = Directory.GetDirectories(path);

            // define regex matcher
            regex = new Regex(regexFolderMatcher, RegexOptions.IgnoreCase);
            foreach (string folder in folderList)
            {
                match = regex.Match(folder);

                if (match.Length > 0)
                {
                    ModuleLog.Write(new string[] { "Folder: " + path, "Match: yes" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                    folderColumns = FolderParser.SplitRow(folder, regexSpliterColumn);
                    // new rowcollection
                    rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(2 + folderColumns.Length, true);

                    objectRow = new RowCollectionRow(rowCollection, Common.MargeTwoStringArray(GetDefaultColumns(folder), folderColumns));
                    //rowCollectionMenager.AddRow(objectRow);
                    rowCollection.Rows.Add(objectRow);
                    if (subfolders == true)
                    {
                        BrowseFolders(folder);
                    }
                }
                else
                {
                    // dont import folder but browse childs
                    if (subfolders == true)
                    {
                        ModuleLog.Write(new string[] { "Folder: " + path, "Match: no" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                        BrowseFolders(folder);
                    }
                    else
                    {
                        ModuleLog.Write(new string[] { "Folder: " + path, "Match: skip" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                    }
                }
                if ((counter++ % 1000) == 0)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Izmjene pravite u uredu, provjeriti code
        /// </summary>
        /// <param name="input"></param>
        /// <param name="regexSpliterColumn"></param>
        /// <param name="regexSpliterRow"></param>
        public void AutomaticAddToRowCollectionMenager(string input, string regexSpliterColumn, string regexSpliterRow)
        {
            //int counter = 0;
            //string[] lineList = TextParser.SplitRow(input, regexSpliterRow);

            //foreach (string line in lineList)
            //{
            //    rowCollectionMenager.AddRow(new RowCollectionRow(null, TextParser.SplitRow(line, regexSpliterColumn)));
            //    if ((counter++ % 1000) == 0)
            //    {
            //        System.Windows.Forms.Application.DoEvents();
            //    }
            //}

            RowCollection rowCollection;
            RowCollectionRow row;

            string[] lineList;
            string[] columnList;
            bool firstRowAsColumnName = false;
            int counter = 0;

            // Get array of rows
            lineList = TextParser.SplitRow(input, regexSpliterRow);

            // If row list is null then exit
            if (lineList == null)
            {
                return;
            }

            // Go through all rows
            foreach (string line in lineList)
            {
                // Split row in array of columns
                columnList = TextParser.SplitRow(line, regexSpliterColumn);
                // get rowCollection object
                rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(columnList.Length, false);
                // check if rowCollection is null
                if (rowCollection == null)
                {
                    // create new rowCollecion object
                    //rowCollection = new RowCollection(columnList.Length, RowCollection.const_prefix + columnList.Length.ToString());
                    rowCollection = rowCollectionMenager.CreateRowCollection(columnList.Length);

                    // define column names
                    if (firstRowAsColumnName == true)
                    {
                        for (int i = 0; i < columnList.Length; i++)
                        {
                            rowCollection.Columns[i] = columnList[i];
                        }
                    }
                    else
                    {
                        // create new row object from column array
                        row = new RowCollectionRow(rowCollection, columnList);
                        // add row to rowCollection
                        rowCollection.Rows.Add(row);
                    }
                }
                else
                {
                    // create new row object from column array
                    row = new RowCollectionRow(rowCollection, columnList);
                    // add row to rowCollection
                    rowCollection.Rows.Add(row);
                }
                //rowCollectionMenager.AddRow(new ObjectRow(null, TextParser.SplitRow(line, regexSpliterColumn)));
                if ((counter++ % 1000) == 0)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
        }
Ejemplo n.º 14
0
        private void DestinationObjectData_CompareStrings(string templateHeader, string templateBody, string templateFooter, RowCollectionRow row, int rowID, int rowMax)
        {
            TextParser textParser = new TextParser(outputMenagerSettings.rowCollectionMenager);

            textParser.AutomaticAddToRowCollectionMenager(templateBody, outputMenagerSettings.columnSpliterRegEx, outputMenagerSettings.rowSpliterRegEx);
            //ObjectRow objectRow = new ObjectRow(new string[] { templateBody });

            //outputMenagerSettings.rowCollectionMenager.AddRow(objectRow);
        }
Ejemplo n.º 15
0
        private void DestinationFile(string templateHeader, string templateBody, string templateFooter, RowCollectionRow row, int rowID, int rowMax)
        {
            string filePath;
            string folder;
            string file;
            bool writeHeader = false;
            bool writeFooter = false;

            folder = tagsReplace.ReplaceTags(outputMenagerSettings.sourceFolder, row);
            file = tagsReplace.ReplaceTags(outputMenagerSettings.sourceFileName, row);
            folder = Common.SetSlashOnEndOfDirectory(folder);
            filePath = folder + file;

            if (!Directory.Exists(folder))
            {
                Common.MakeAllSubFolders(folder);
            }

            //fileName = tagsReplace.ReplaceTags(outputMenagerSettings.sourceFileName, row);

            // Is header text length more then 0 caracther
            if (templateHeader.Length > 0)
            {
                // If append is true then only write header if file dont exist
                if (outputMenagerSettings.AppendFile)
                {
                    if (!File.Exists(filePath))
                    {
                        writeHeader = true;
                    }
                }
                else
                {
                    // Append is false, so write header in each file
                    writeHeader = true;
                }
            }
            //
            // Is footer text lenght more then 0 charachter
            if (templateFooter.Length > 0)
            {
                // If append is true then only write header if file dont exist
                if (outputMenagerSettings.AppendFile)
                {
                    // Ovdje se mora dodati provjera koja ce kad se svi redovi izvrte pogledati gdje nije upisao footer
                    // Ova ispod provjera je samo zakrpa u slucaju da je destinacion name staticno a nije varijabla
                    if (rowID + 1 >= rowMax)
                    {
                        writeFooter = true;
                    }
                }
                else
                {
                    // Append is false, so write header in each file
                    writeFooter = true;
                }
            }

            // If stream writer last file path is not current path make new stream writer object
            if (!outputMenagerSettings.AppendFile || (sw_filePath != filePath) || sw == null)
            {
                // Close last sw object and open new
                if (sw != null)
                {
                    sw.Close();
                }
                sw = new StreamWriter(filePath, outputMenagerSettings.AppendFile, outputMenagerSettings.Encoding);
                sw_filePath = filePath;
            }

            if (writeHeader)
            {
                // If header is true then write header
                sw.WriteLine(templateHeader);
            }

            // Write body

            //////////////// TO DO WriteLine bug
            if (rowID + 1 >= rowMax)
            {
                sw.Write(templateBody);
                //ModuleLog.Write("Write", this, "DestinationFile", ModuleLog.LogType.DEBUG);
            }
            else
            {
                sw.Write(templateBody);
                //ModuleLog.Write("WriteLine", this, "DestinationFile", ModuleLog.LogType.DEBUG);
            }

            if (writeFooter)
            {
                // If header is true then write header
                sw.WriteLine(templateFooter);
            }
        }
Ejemplo n.º 16
0
        private void ProcessXML(XmlNodeList xmlNodeList, UberTools.Modules.GenericTemplate.RowCollectionNS.RowCollection parentRowCollection)
        {
            RowCollection rowCollection = null;
            RowCollectionRow objectRow;
            string rowCollectionName = null;
            foreach (XmlNode node in xmlNodeList)
            {
                if (node.NodeType == XmlNodeType.Element)
                {

                    rowCollectionName = FindXPath(node);
                    rowCollection = rowCollectionMenager[rowCollectionName];
                    if (rowCollection == null)
                    {
                        rowCollection = rowCollectionMenager.CreateRowCollection(node.Attributes.Count, rowCollectionName);
                    }

                    // check if parent row collection is not null, only first call is null
                    if (parentRowCollection != null)
                    {
                        // add this row collection to parent chilld list
                        parentRowCollection.AddChild(rowCollection);
                    }

                    // make new instance of ObjectRow object
                    objectRow = new RowCollectionRow(rowCollection, GetAllAttribites(node));
                    // if node have inner text
                    if (node.InnerText != "")
                    {
                        // add extra columnt to objectRow object
                        objectRow.AddColl(new RowCollectionColumn(node.InnerText));
                    }
                    // add new row to row collection
                    rowCollection.Rows.Add(objectRow);

                    //ModuleLog.Write(GetAllAttribites(node), this, "ProcessXML", ModuleLog.LogType.INFO);

                    // recurse chilld
                    ProcessXML(node.ChildNodes, rowCollection);
                }
            }
        }
        private bool TestAgenstFilters(RowCollectionRow row)
        {
            bool resultAction;
            bool resultActionLastAnd = false;
            bool haveAndLogicalInThisGroup;

            for (int i = 0; i <= 9; i++)
            {
                haveAndLogicalInThisGroup = false;
                foreach (RowCollectionFilterItem filter in filtersItems)
                {
                    if (filter.LogicalGroup == i)
                    {
                        // test action agens value
                        resultAction = TestAgenstFilterAction(filter, row[filter.ColumnID].Value);
                        if (filter.LogicalOperator == RowCollectionFilterItem.LogicalOperatorType.OR)
                        {
                            if (resultAction == true)
                            {
                                return true;
                            }
                        }
                        else if (filter.LogicalOperator == RowCollectionFilterItem.LogicalOperatorType.AND)
                        {
                            if (haveAndLogicalInThisGroup == true && resultActionLastAnd == false)
                            {
                                break;
                            }
                            haveAndLogicalInThisGroup = true;
                            resultActionLastAnd = resultAction;
                        }

                    }
                }

                if (haveAndLogicalInThisGroup == true && resultActionLastAnd == true)
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 18
0
        private string InputObject(RowCollectionRow row, Tag2 tag)
        {
            string result = null;

            InputBox inputBox;
            try
            {
                if (tag.Child.Name == "repeat")
                {
                    //
                    // NOTE this need to be like $input.once object
                    //
                    //{=input.repeat.[Value]}
                    inputBox = new InputBox("Write text", tag.Child.Name, "Replace tag with text...");
                    inputBox.ShowDialog(System.Windows.Forms.Application.OpenForms[0]);
                    result = inputBox.InputTekst;
                }
                else if (tag.Child.Name == "once")
                {
                    result = inputObject.ProcessTag(tag);
                    if (result == null)
                    {
                        result = constError_SyntaxError;
                    }
                }
                else
                {
                    ModuleLog.Write(new string[] { constError_CommandNotFound, tag.InputText }, this, "InputObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { constError_ExecutingBlock, tag.InputText }, this, "InputObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "InputObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return result;
        }
Ejemplo n.º 19
0
        public void Load()
        {
            RowCollection    rowCollection;
            RowCollectionRow rowCollectionRow;
            XmlDocument      xmlDocument;
            XmlNodeList      xmlNodeList;
            XmlNode          xmlNode;

            string name;
            int    columnCount;

            string[] columnNames;
            string[] columnValues;


            try
            {
                ModuleLog.Write(new string[] { "Loading data object...", this.path }, this, "Load", ModuleLog.LogType.DEBUG);

                xmlDocument = new XmlDocument();
                xmlDocument.Load(this.path);

                // Get data object name
                xmlNode = xmlDocument.SelectSingleNode(XPATH_SELECT_NAME);
                name    = xmlNode.InnerText;

                // Get columns count
                xmlNode     = xmlDocument.SelectSingleNode(XPATH_SELECT_COLUMNS_INFO);
                columnCount = int.Parse(xmlNode.Attributes["count"].Value);
                columnNames = new string[columnCount];

                // create new rowCollection
                rowCollection = this.rowCollectionMenager.GetRowCollectionObjectFromCellNumber(columnCount, true);


                // get column names
                xmlNodeList = xmlDocument.SelectNodes(XPATH_SELECT_COLUMNS);
                for (int i = 0; i < xmlNodeList.Count; i++)
                {
                    rowCollection.Columns[i] = xmlNodeList[i].InnerText;
                }


                // select all rows
                xmlNodeList  = xmlDocument.SelectNodes(XPATH_SELECT_ROWS);
                columnValues = new string[columnCount];
                foreach (XmlNode xmlRow in xmlNodeList)
                {
                    // select all columns values from this row
                    for (int i = 0; i < xmlRow.ChildNodes.Count; i++)
                    {
                        columnValues[i] = xmlRow.ChildNodes[i].InnerText;
                    }
                    rowCollectionRow = new RowCollectionRow(rowCollection, columnValues);

                    rowCollection.Rows.Add(rowCollectionRow);
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "Load", ModuleLog.LogType.ERROR);
            }
        }
Ejemplo n.º 20
0
        private string NTHObject(RowCollectionRow row, string objectValue)
        {
            string result = null;
            Tag tag = new Tag("nth", objectValue);

            try
            {
                if (tag.Tags.Name == "swapzarez")
                {
                    //{=nth.swapzarez.text}
                    result = tag.Tags.Value.Replace(",", "<;>");
                }
                else if (tag.Tags.Name == "max160")
                {
                    //{=nth.max160.text}
                    if (tag.Tags.Value.Length > 160)
                    {
                        result = "- - - W A R N I N G (text length " + tag.Tags.Value.Length + " )  - - -";
                        ModuleLog.Write(result, this, "NTHObject", ModuleLog.LogType.WARNING);
                        ModuleLog.Write(tag.Tags.Value, this, "NTHObject", ModuleLog.LogType.DEBUG);
                    }
                    else
                    {
                        result = tag.Tags.Value;
                    }
                }
                else
                {
                    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "NTHObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch
            {
                ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "NTHObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return result;
        }
Ejemplo n.º 21
0
        public void Load()
        {
            RowCollection rowCollection;
            RowCollectionRow rowCollectionRow;
            XmlDocument xmlDocument;
            XmlNodeList xmlNodeList;
            XmlNode xmlNode;

            string name;
            int columnCount;
            string[] columnNames;
            string[] columnValues;

            try
            {
                ModuleLog.Write(new string[] { "Loading data object...", this.path }, this, "Load", ModuleLog.LogType.DEBUG);

                xmlDocument = new XmlDocument();
                xmlDocument.Load(this.path);

                // Get data object name
                xmlNode = xmlDocument.SelectSingleNode(XPATH_SELECT_NAME);
                name = xmlNode.InnerText;

                // Get columns count
                xmlNode = xmlDocument.SelectSingleNode(XPATH_SELECT_COLUMNS_INFO);
                columnCount = int.Parse(xmlNode.Attributes["count"].Value);
                columnNames = new string[columnCount];

                // create new rowCollection
                rowCollection = this.rowCollectionMenager.GetRowCollectionObjectFromCellNumber(columnCount, true);

                // get column names
                xmlNodeList = xmlDocument.SelectNodes(XPATH_SELECT_COLUMNS);
                for (int i = 0; i < xmlNodeList.Count; i++)
                {
                    rowCollection.Columns[i] = xmlNodeList[i].InnerText;
                }

                // select all rows
                xmlNodeList = xmlDocument.SelectNodes(XPATH_SELECT_ROWS);
                columnValues = new string[columnCount];
                foreach (XmlNode xmlRow in xmlNodeList)
                {
                    // select all columns values from this row
                    for (int i = 0; i < xmlRow.ChildNodes.Count; i++)
                    {
                        columnValues[i] = xmlRow.ChildNodes[i].InnerText;
                    }
                    rowCollectionRow = new RowCollectionRow(rowCollection, columnValues);

                    rowCollection.Rows.Add(rowCollectionRow);
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "Load", ModuleLog.LogType.ERROR);
            }
        }
Ejemplo n.º 22
0
 private string NumberObject(RowCollectionRow row, string objectValue)
 {
     string result = null;
     Tag tag = new Tag("number", objectValue);
     try
     {
         if (tag.Value == "getvalue")
         {
             //{=number.getvalue}
             result = numberObject_counter.ToString();
         }
         else
         {
             if (tag.Tags.Name == "increment")
             {
                 //{=number.increment.startNumber.incrementBy}
                 if (numberObject_counter == constNumberObject_counter_defaultValue)
                 {
                     ModuleLog.Write(tag.Tags.Tags.Name, this, "NumberObject", ModuleLog.LogType.INFO);
                     numberObject_counter = int.Parse(tag.Tags.Tags.Name);
                 }
                 else
                 {
                     int number_to_increment = 0;
                     number_to_increment = int.Parse(tag.Tags.Tags.Value);
                     numberObject_counter = numberObject_counter + number_to_increment;
                 }
                 result = numberObject_counter.ToString();
             }
             else
             {
                 ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "NumberObject", ModuleLog.LogType.WARNING);
                 result = constError_SyntaxError;
             }
         }
     }
     catch (Exception ex)
     {
         ModuleLog.Write(ex, this, "--NumberObject", ModuleLog.LogType.ERROR);
         ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "--NumberObject", ModuleLog.LogType.DEBUG);
         result = constError_SyntaxError;
     }
     return result;
 }
Ejemplo n.º 23
0
        private string ReplaceTagsFromInToOut(string text, RowCollectionRow row)
        {
            string result = null;
            string objectName = "";
            string objectValue = "";
            //string oldText = "";
            // Define all regex match with patern
            //Regex regexMain = new Regex(@"\{=[\w]+\.[^{}]+\}");

            // Test regex expresion added for escape function
            // za right je nije(?!mal)
            Regex regexMain = new Regex(@"(?<![^\\]\\)\{=[\w]+\.(?!.*(?<![^\\]\\){=.*(?<!\\)}).*?(?<!\\)\}",RegexOptions.Singleline);
            Regex regex;
            // Get all matches
            MatchCollection matchList;
            // do loop is needed if tags are nested
            do
            {
                matchList = regexMain.Matches(text);
                foreach (Match match in matchList)
                {
                    // Define regex string that will extract object name
                    regex = new Regex(@"\{=|\..+\}",RegexOptions.Singleline);
                    // get that object name and save it
                    objectName = regex.Replace(match.Value, "");
                    // Define regex string that will extract object value
                    //regex = new Regex(@"{=[\w]+\.|}+");
                    regex = new Regex(@"(?<!\\)\{=[\w]+\.|(?<!\\)\}");
                    // get that object value
                    objectValue = regex.Replace(match.Value, "");
                    // Call suported object name and replace tags in text
                    result = this.ReplaceSuportedObject(objectName, objectValue, row);
                    if (result != null)
                    {
                        text = ReplaceOnce(text, match.Value, result);
                    }
                    else
                    {
                        // No suported object found
                        text = text.Replace(match.Value, match.Value.Replace("{=", "(=ubertools_replace_string)"));
                        // dont loog this
                        if (isInitialization == false)
                        {
                            ModuleLog.Write(text, this, "ReplaceTagsFromInToOut", ModuleLog.LogType.DEBUG);
                        }
                    }
                }
            } while (matchList.Count > 0);
            text = text.Replace("(=ubertools_replace_string)", "{=");

            return text;
        }
Ejemplo n.º 24
0
        private string StringObject(RowCollectionRow row, string objectValue)
        {
            string result = null;
            Tag tag = new Tag("string", objectValue);

            try
            {
                if (tag.Tags.Name == "trim")
                {
                    result = tag.Tags.Value.Trim();
                }
                else if (tag.Tags.Name == "substring")
                {
                    // {=string.substring.4.2.neki text}
                    int start;
                    int lenght;
                    start = int.Parse(tag.Tags.Tags.Name);
                    lenght = int.Parse(tag.Tags.Tags.Tags.Name);
                    // if index is in range of string length
                    if ((start + lenght) < tag.Tags.Tags.Tags.Value.Length)
                    {
                        result = tag.Tags.Tags.Tags.Value.Substring(start, lenght);
                    }
                    else
                    {
                        // else return empty string and log waring
                        result = "";
                        ModuleLog.Write("String out of range returning empty string", this, "StringObject", ModuleLog.LogType.WARNING);
                    }
                }
                else if (tag.Tags.Name == "indexof")
                {
                    // {=string.indexof. .damir marijanovic}
                    result = tag.Tags.Tags.Value.IndexOf(tag.Tags.Tags.Name).ToString();
                }
                else if (tag.Tags.Name == "toupper")
                {
                    result = tag.Tags.Value.ToUpper();
                }
                else if (tag.Tags.Name == "tolower")
                {
                    result = tag.Tags.Value.ToLower();
                }
                else if (tag.Tags.Name == "replace")
                {
                    // {=string.replace.old.new.text}
                    result = tag.Tags.Tags.Tags.Value.Replace(tag.Tags.Tags.ToString(), tag.Tags.Tags.Tags.ToString());
                }
                else if (tag.Tags.Name == "split")
                {
                    // string.split.[index].[split string].[text]
                    string[] splitList = tag.Tags.Tags.Tags.Value.Split(new string[] { tag.Tags.Tags.Tags.Name }, StringSplitOptions.RemoveEmptyEntries);
                    int index;
                    index = int.Parse(tag.Tags.Tags.Name);
                    // if index is in range of array
                    if (index < splitList.Length)
                    {
                        result = splitList[index];
                    }
                    else
                    {
                        // else return empty string and log waring
                        result = "";
                        ModuleLog.Write("String out of range returning empty string", this, "StringObject", ModuleLog.LogType.WARNING);
                    }
                }
                else
                {
                    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "StringObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch(Exception ex)
            {
                ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "StringObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "StringObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return result;
        }
Ejemplo n.º 25
0
        public string ReplaceTags(string text, RowCollectionRow row, bool isInitialization)
        {
            int indexOfFirst = 0;
            int indexOfLast = 0;
            int indexOfLastNoTag = 0;
            int tagCounter = 0;
            bool tagSearchActive = false;
            string result = "";
            string processedText = "";

            this.isInitialization = isInitialization;

            for (int i = 0; i < text.Length; i++)
            {
                // Find first tag, {
                if (text[i] == '{')
                {
                        if (!Tag2.IsExcaped(text, i))
                        {
                            // if start tag is complete, is like {=
                            if ((text.Length > 2 && i < text.Length - 2) && text[i + 1] == '=')
                            {
                                // increment tag counter
                                tagCounter++;
                                // if this is first tag that is find then save indexOf
                                if (tagSearchActive == false)
                                {
                                    indexOfFirst = i;
                                    // indicate thats tag search is active, from now if tagCounter is 0 then cut tag and call ReplaceTagsFromInToOut(x, x)
                                    tagSearchActive = true;
                                    // start tag find next for
                                    continue;
                                }
                            }
                        }
                    //}
                }

                // Find last tag
                if (text[i] == '}')
                {
                    // Check if is not excaped
                    if (!Tag2.IsExcaped(text, i))
                    {
                        // Decrement tag counter and set indexOfLast
                        tagCounter--;
                        indexOfLast = i;
                    }
                }

                // if tagCounter is less then zero then throw error
                if (tagCounter < 0)
                {
                    throw new Exception("Template syntax error at end of " + Environment.NewLine + text.Substring(indexOfFirst, indexOfLast - indexOfFirst));
                }

                // Check is tag search is active and tagCounter value is zero, if is zero then call ReplaceTagsFromInToOut(x, x)
                if (tagSearchActive)
                {
                    // if tagCounter is zero then call ReplaceTagsFromInToOut(x, x)
                    if (tagCounter == 0)
                    {
                        // call function to parse tags extracted
                        result = ReplaceTagsFromInToOut(text.Substring(indexOfFirst, (indexOfLast - indexOfFirst) + 1), row);
                        // copy no tag text
                        processedText += text.Substring(indexOfLastNoTag, indexOfFirst - indexOfLastNoTag);
                        indexOfLastNoTag = indexOfLast + 1;
                        // replace extracted tags block with result from function with 2 (0, 1) (2 - 1) = 1 <= 1 , 1 + 1 = 2, (2 - 1)  - 1 1
                        //processedText += string.Concat(text.Substring(0, indexOfFirst), result, text.Length - 1 >= indexOfLast ? text.Substring(indexOfLast + 1, (text.Length - 1) - indexOfLast) : "");
                        processedText += result;
                        // reset varables
                        tagSearchActive = false;
                    }
                }

            }

            // Copy text after last tag
            if (indexOfLastNoTag < text.Length)
            {
                processedText += text.Substring(indexOfLastNoTag, text.Length - indexOfLastNoTag);
            }

            // if tagCounter is not zero then throw error
            if (tagCounter > 0)
            {
                throw new Exception("Template syntax error at start of " + Environment.NewLine + text.Substring(indexOfFirst, text.Length - indexOfFirst));
            }

            // Do all unexcape
            //processedText = processedText.Replace("\\\\", "\\");
            processedText = Tag2.UnEscape(processedText);

            // log if change is made
            if (text != processedText)
            {
                ModuleLog.Write(processedText, this, "ReplaceTags", ModuleLog.LogType.DEBUG);
            }
            return processedText;
        }
Ejemplo n.º 26
0
        private void ImportFiles(string folderPath)
        {
            RowCollection rowCollection;
            Regex regex;
            Match match;
            RowCollectionRow objectRow;
            string[] fileColumns;
            string[] fileList = Directory.GetFiles(folderPath);

            regex = new Regex(regexFileMatcher, RegexOptions.IgnoreCase);

            foreach (string file in fileList)
            {
                match = regex.Match(file);

                if (match.Length > 0)
                {
                    fileColumns =  SplitRow(file, regexSpliterColumn);
                    rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(3 + fileColumns.Length, true);
                    objectRow = new RowCollectionRow(rowCollection, Common.MargeTwoStringArray(GetDefaultColumns(file),fileColumns));
                    rowCollection.Rows.Add(objectRow);
                }
            }
        }