Example #1
0
        public string[] SplitRow(string filePath, string regexSpliter)
        {
            ArrayList list;
            Regex     regex;

            string[] result;
            try
            {
                if (!regexSpliter.Equals(""))
                {
                    list  = new ArrayList();
                    regex = new Regex(regexSpliter);

                    result = regex.Split(filePath);
                }
                else
                {
                    result = new string[] { filePath };
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, typeof(FileParser), "SplitRow", ModuleLog.LogType.ERROR, true);
                ModuleLog.Write(filePath + "\r\n" + regexSpliter, typeof(FileParser), "SplitRow", ModuleLog.LogType.DEBUG);
                result = null;
            }
            return(result);
        }
Example #2
0
        private void CopyAllFiles(string arrayObjectName, string destination)
        {
            string          destinationPath;
            ArrayObject     arrayObject     = new ArrayObject(varObjectStructList);
            VarObjectStruct varObjectStruct = arrayObject.GetObjectFromName(arrayObjectName);
            Array           fileList        = varObjectStruct.ToArray();

            Common.MakeAllSubFolders(destination);
            destination = Common.SetSlashOnEndOfDirectory(destination);

            for (int i = 0; i < fileList.Length; i++)
            {
                if (!File.Exists(fileList.GetValue(i).ToString()))
                {
                    ModuleLog.Write(string.Format("File dont exists\r\n{0}", fileList.GetValue(i).ToString()), this, "CopyAllFiles", ModuleLog.LogType.WARNING);
                }
                else
                {
                    destinationPath = destination + Common.ExtractFileFromPath(fileList.GetValue(i).ToString());
                    ModuleLog.Write(new string[] { "Source: " + fileList.GetValue(i).ToString(), "Destination: " + destinationPath }, this, "CopyAllFiles", ModuleLog.LogType.DEBUG);

                    File.Copy(fileList.GetValue(i).ToString(), destinationPath, true);
                }
            }
        }
        private string ActiveObject(Tag2 active)
        {
            string result = null;

            try
            {
                // {=active.fetch.[deep_index].[column_index]}
                if (active.Child.Name == "counter")
                {
                    result = this.rowCollectionMenager.ActiveObjectInstance.RowCounter.ToString();
                }
                else
                {
                    int depth = int.Parse(active.Child.Child.Name);
                    depth--;
                    string objectName = rowCollectionMenager.ActiveObjectInstance[depth];
                    if (objectName != null)
                    {
                        RowCollection rowCollection = rowCollectionMenager[objectName];

                        if (active.Child.Name == "fetch")
                        {
                            int columnIndex = int.Parse(active.Child.Child.Child.Name);
                            columnIndex--;
                            RowCollectionRow objectRow = rowCollection.Rows[rowCollection.Rows.Curent];
                            if (objectRow != null)
                            {
                                result = objectRow[columnIndex].Value;
                            }
                            else
                            {
                                // active object is out of scope
                                result = "";
                            }
                        }
                        else if (active.Child.Name == "index")
                        {
                            result = (rowCollection.Rows.Curent + 1).ToString();;
                        }
                        else
                        {
                            ModuleLog.Write(new string[] { constError_CommandNotFound, active.InputText }, this, "ActiveObject", ModuleLog.LogType.ERROR);
                            result = constError_SyntaxError;
                        }
                    }
                    else
                    {
                        // active object is out of scope
                        result = "";
                    }
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { constError_ExecutingBlock, active.InputText }, this, "ActiveObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "ActiveObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return(result);
        }
        private string MD5Object(object obj, string objectValue)
        {
            string result = null;
            Tag    tag    = new Tag("md5", objectValue);

            try
            {
                if (tag.Tags.Name == "text")
                {
                    result = MD5.MD5FromText(tag.Tags.Value);
                }
                else if (tag.Tags.Name == "file")
                {
                    result = MD5.MD5FromFile(tag.Tags.Value);
                }
                else
                {
                    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "MD5Object", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "MD5Object", ModuleLog.LogType.ERROR);
                ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "MD5Object", ModuleLog.LogType.DEBUG);
                result = constError_SyntaxError;
            }
            return(result);
        }
        public InputDataSource(RowCollectionMenager rowCollectionMenager, SettingsMenager2 settingsMenager2)
        {
            InitializeComponent();
            this.rowCollectionMenager  = rowCollectionMenager;
            this.settingsMenager2      = settingsMenager2;
            cbDataSource.SelectedIndex = 0;

            try
            {
                ///
                ///   ovo extraktirati u metodu ili u klasu od data object menagera nekoga
                ///
                ///
                string   dataObjectPath = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder, GenericTemplate.constDataObjectsFolder);
                string   fileName;
                string[] fileList = Directory.GetFiles(dataObjectPath, "*.xml");

                foreach (string item in fileList)
                {
                    fileName = Common.ExtractFileFromPath(item);
                    fileName = fileName.Replace(".xml", "");
                    lbDataObjectList.Items.Add(fileName);
                }

                LoadSettingsFromSettingsMenager();
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "InputDataSource", ModuleLog.LogType.ERROR);
            }
        }
        private string XMLObject(object obj, string objectValue)
        {
            string result = null;
            Tag    tag    = new Tag("xml", objectValue);

            try
            {
                if (tag.Tags.Name == "xpath")
                {
                    if (tag.Tags.Tags.Name == "attribute")
                    {
                        //{=xml.xpath.attribute.atributeToGet.xpathText}
                        result = XMLParser.XMLObject.GetXPathAttributeValue(tag.Tags.Tags.Tags.Value, tag.Tags.Tags.Tags.Name);
                    }
                }
                else
                {
                    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "XMLObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "XMLObject", ModuleLog.LogType.ERROR);
                ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "XMLObject", ModuleLog.LogType.DEBUG);
                result = constError_SyntaxError;
            }
            return(result);
        }
        private void ProccessTemplateFolder(string path, TreeNode rootNode)
        {
            TreeNode      treeNode;
            DirectoryInfo directory;

            FileInfo[] fileList;
            string     fileName;

            try
            {
                directory = new DirectoryInfo(path);
                foreach (DirectoryInfo directoriInfo in directory.GetDirectories())
                {
                    treeNode      = new TreeNode(directoriInfo.Name, 0, 0);
                    treeNode.Name = "folder";
                    rootNode.Nodes.Add(treeNode);
                    ProccessTemplateFolder(directoriInfo.FullName, treeNode);
                }

                fileList = directory.GetFiles("*.xml");
                foreach (FileInfo file in fileList)
                {
                    fileName      = file.Name.Replace(".xml", "");
                    treeNode      = new TreeNode(fileName, 1, 1);
                    treeNode.Name = "file";
                    rootNode.Nodes.Add(treeNode);
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "ProccessTemplateFolder", ModuleLog.LogType.ERROR);
            }
        }
        public bool Copy(TreeNode source, TreeNode destination)
        {
            string sourcePath;
            string destinationPath;
            string fileName;
            bool   result = false;

            try
            {
                sourcePath      = GetNodeRealPath(source);
                fileName        = Common.ExtractFileFromPath(sourcePath);
                destinationPath = Common.BuildPath(GetNodeRealFolder(destination)) + fileName;

                ModuleLog.Write(new string[] { "Source: " + sourcePath, "Destination: " + destinationPath }, this, "Copy", ModuleLog.LogType.DEBUG);
                File.Copy(sourcePath, destinationPath);
                File.Delete(sourcePath);
                result = true;
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "Copy", ModuleLog.LogType.ERROR);
            }

            return(result);
        }
        public void Delete()
        {
            string folderPath;
            string filePath;

            try
            {
                folderPath = GetNodeRealFolder(treeView.SelectedNode);
                filePath   = GetNodeRealPath(treeView.SelectedNode);

                if (ActiveNodeType == FolderType.Folder)
                {
                    // folder/categori is selected
                    ModuleLog.Write("Deleting: " + folderPath, this, "Delete", ModuleLog.LogType.DEBUG);
                    Directory.Delete(folderPath, true);
                }
                else if (ActiveNodeType == FolderType.File)
                {
                    // file/template is selected
                    ModuleLog.Write("Deleting: " + filePath, this, "Delete", ModuleLog.LogType.DEBUG);
                    File.Delete(filePath);
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "Delete", ModuleLog.LogType.ERROR);
            }
        }
Example #10
0
        public TagsStorage LoadTags()
        {
            TagsStorage rootNode = null;
            XmlDocument xmlDoc;

            if (File.Exists(this.path))
            {
                xmlDoc = new XmlDocument();
                try
                {
                    rootNode = new TagsStorage("{=", TagsStorage.TagType.Object);
                    xmlDoc.Load(path);
                    LoadXMLChild(rootNode, xmlDoc.SelectSingleNode("tags"));
                }
                catch (XmlException ex)
                {
                    ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR);
                }
                catch (Exception ex)
                {
                    ModuleLog.Write(ex, this, "LoadTags", ModuleLog.LogType.ERROR);
                }
            }
            return(rootNode);
        }
        public GenericTemplate()
        {
            ModuleLog.CreateStaticInstance();


            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            //Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
        }
        /// <summary>
        /// RowCollection object
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        private string DataObjectGetValue(Tag2 tag)
        {
            string        result = null;
            int           columntID;
            RowCollection rowCollection = rowCollectionMenager[tag.Name];

            try
            {
                // {=objectname.row.column}
                // {=objectname.column}
                // Column index is zero base, but user need to treat it like non zero base else it is error
                if (rowCollection != null)
                {
                    if (tag.Child.Name == "fetch")
                    {
                        columntID = int.Parse(tag.Child.Child.Name);
                        columntID--;
                        result = rowCollection.Rows.FetchColumn(columntID);
                    }
                    else if (tag.Child.Name == "fetchNext")
                    {
                        columntID = int.Parse(tag.Child.Child.Name);
                        columntID--;
                        result = rowCollection.Rows.FetchNextColumn(columntID);
                    }
                    else if (tag.Child.Name == "search")
                    {
                        // {=object.searchRegex.searchOnColumn.returnColumn."<regex>"}
                        columntID = int.Parse(tag.Child.Child.Name);
                        columntID--;
                        int columnID2 = int.Parse(tag.Child.Child.Child.Name);
                        columnID2--;
                        RowCollectionRow row = rowCollection.Rows.SearchRow(tag.Child.Child.Child.Child.Name, columntID);

                        if (row != null)
                        {
                            result = row[columnID2].Value;
                        }
                        else
                        {
                            result = "";
                        }
                    }
                }
                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;
            }
            return(result);
        }
Example #13
0
        public StitchMonitorModule(CrossStitchCore core, NodeConfiguration configuration)
        {
            _messageBus    = core.MessageBus;
            _configuration = configuration;
            var data = new DataHelperClient(core.MessageBus);
            var log  = new ModuleLog(_messageBus, Name);

            _heartbeatService = new StitchHeartbeatService(data, log, new HeartbeatSender(_messageBus));
        }
Example #14
0
        private int AnalyzeRightImage(Bitmap bitmap)
        {
            Color color;

            int endPixel = 0;

            byte deviation = 10;
            byte r         = 0;
            byte g         = 0;
            byte b         = 0;

            bool flag = false;

            // analyze top image
            for (int x = bitmap.Width - 1; x > bitmap.Width / 2; x--)
            {
                // increment j for 10% of image width
                for (int y = 0; y < bitmap.Height; y += ((bitmap.Height * 10) / 100))
                {
                    // get color object from x,y
                    color = bitmap.GetPixel(x, y);

                    if (Deviation(r, color.R, deviation) && Deviation(g, color.G, deviation) && Deviation(b, color.B, deviation))
                    {
                        r = color.R;
                        g = color.G;
                        b = color.B;
                        // new color is similar to new coler
                    }
                    else
                    {
                        if (x < bitmap.Width - 1)
                        {
                            endPixel = x;
                            flag     = true;
                            ModuleLog.Write(new string[] { "Deviation: " + deviation, "Old RGB:" + r + ":" + g + ":" + b, "New RGB: " + color.R + ":" + color.G + ":" + color.B }, this, "AnalyzeRightImage", ModuleLog.LogType.DEBUG);
                            break;
                        }
                        else
                        {
                            // set default colors
                            r = color.R;
                            g = color.G;
                            b = color.B;
                        }
                    }
                }

                if (flag)
                {
                    break;
                }
            }

            return(endPixel);
        }
        private string DateObject(string objectValue)
        {
            string text = "";

            // {=date.now}
            if (objectValue == "now")
            {
                text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            else if (objectValue == "date")
            {
                text = DateTime.Now.ToString("yyyy-MM-dd");
            }
            else if (objectValue == "time")
            {
                text = DateTime.Now.ToString("HH:mm:ss");
            }
            else if (objectValue == "year")
            {
                text = DateTime.Now.ToString("yyyy");
            }
            else if (objectValue == "month")
            {
                text = DateTime.Now.ToString("mm");
            }
            else if (objectValue == "day")
            {
                text = DateTime.Now.ToString("dd");
            }
            else if (objectValue == "hour")
            {
                text = DateTime.Now.ToString("HH");
            }
            else if (objectValue == "minute")
            {
                text = DateTime.Now.ToString("mm");
            }
            else if (objectValue == "second")
            {
                text = DateTime.Now.ToString("ss");
            }
            else
            {
                try
                {
                    text = DateTime.Today.ToString(objectValue);
                }
                catch
                {
                    ModuleLog.Write(string.Concat(constError_SyntaxError, " (", objectValue, ")"), this, "DateObject", ModuleLog.LogType.ERROR);
                    text = constError_SyntaxError;
                }
            }
            return(text);
        }
Example #16
0
        public StitchMonitorModule(CrossStitchCore core, NodeConfiguration configuration)
        {
            _configuration = configuration;
            var log             = new ModuleLog(core.MessageBus, Name);
            var calculator      = new StitchHealthCalculator(configuration.MissedHeartbeatsThreshold);
            var heartbeatSender = new HeartbeatSender(core.MessageBus);
            var healthNotifier  = new StitchHealthNotifier(core.MessageBus);

            _heartbeatService = new StitchHeartbeatService(log, heartbeatSender, healthNotifier, calculator);
            _subscriptions    = new SubscriptionCollection(core.MessageBus);
        }
 private void tsbSave_Click(object sender, EventArgs e)
 {
     try
     {
         templatesMenager.Save();
     }
     catch (Exception ex)
     {
         ModuleLog.Write(ex, this, "tsbSave_Click", ModuleLog.LogType.ERROR);
     }
 }
Example #18
0
 private void bWork_Click(object sender, EventArgs e)
 {
     try
     {
         cmsMenu.Show((Control)sender, new Point(0, ((Control)sender).Height));
     }
     catch (Exception exc)
     {
         ModuleLog.Write(exc, this, "bWork_Click", ModuleLog.LogType.ERROR);
     }
 }
Example #19
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);
        }
Example #20
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     try
     {
         InputDataSource inputDataSource = new InputDataSource(rowCollectionMenager, settingsMenager2);
         inputDataSource.ShowDialog(this);
     }
     catch (Exception ex)
     {
         ModuleLog.Write(ex, this, "btnLoad_Click", ModuleLog.LogType.ERROR);
     }
 }
Example #21
0
        public CrossStitchCore(NodeConfiguration configuration = null)
        {
            Configuration = configuration ?? NodeConfiguration.GetDefault();
            NodeId        = GetNodeId(Configuration);
            Name          = GetFriendlyNodeName(Configuration, NodeId);
            MessageBus    = new Acquaintance.MessageBus();

            CoreModule = new CoreModule(this, MessageBus);
            Modules    = new ModuleCollection();

            Log = new ModuleLog(MessageBus, "Core");
        }
Example #22
0
        public string ProcessTag()
        {
            string result = null;

            try
            {
                if (tag.Child.Name == "copy")
                {
                    // {=file.copy.[source].[destination]}
                    //string source = tag.Child.Child.Name;
                    //string destination = tag.Child.Child.Child.Name;
                    //this.CopyFile(source, destination);
                    result = "";
                }
                else if (tag.Child.Name == "copyall")
                {
                    // {=file.copyall.[ArrayObject].[destination]}
                    //string objectName = tag.Child.Child.Name;
                    //string destination = tag.Child.Child.Child.Name;
                    //this.CopyAllFiles(objectName, destination);
                    result = "";
                }
                else if (tag.Child.Name == "move")
                {
                    // {=dir.move.[source].[destination]}
                    string source      = tag.Child.Child.Name;
                    string destination = tag.Child.Child.Child.Name;
                    Directory.Move(source, destination);
                    result = "";
                }
                else if (tag.Child.Name == "list")
                {
                    // {=file.list.[ArrayObject].[FolderPath]}
                    //this.List(tag.Child.Child.Child.Name, tag.Child.Child.Name);
                    result = "";
                }


                // Error - not tag
                if (result == null)
                {
                    ModuleLog.Write(new string[] { TagsReplace.constError_CommandNotFound, tag.InputText }, this, "ProcessTag", ModuleLog.LogType.ERROR);
                    result = TagsReplace.constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { TagsReplace.constError_ExecutingBlock, tag.InputText }, this, "ProcessTag", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "ProcessTag", ModuleLog.LogType.ERROR);
                result = TagsReplace.constError_SyntaxError;
            }
            return(result);
        }
        private void bLoad_Click(object sender, EventArgs e)
        {
            try
            {
                bLoad.Enabled = false;
                bLoad.Text    = "Loading...";
                if (cbDataSource.SelectedIndex == 0)
                {
                    string dataObjectPath = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder, GenericTemplate.constDataObjectsFolder);
                    string dataObjectName = lbDataObjectList.Items[lbDataObjectList.SelectedIndex].ToString();
                    dataObjectName += ".xml";

                    RowCollectionIO rowCollectionIO = new RowCollectionIO(rowCollectionMenager, dataObjectPath + dataObjectName);
                    rowCollectionIO.Load();
                }
                else if (cbDataSource.SelectedIndex == 1)
                {
                    // Input data from clipboard
                    // new parser will add rows to rowCollection object
                    TextParser textParser = new TextParser(rowCollectionMenager);
                    textParser.AutomaticAddToRowCollectionMenager_ClipboardSource(tbRegexColumnSpliter.Text, tbRegexRowSpliter.Text, cbRegexFirstColumnAsColumnName.Checked);
                }
                else if (cbDataSource.SelectedIndex == 2)
                {
                    // Input data from xml file
                    //XMLParser xmlParser = new XMLParser(rowCollectionMenager, tbSourceFile.Text, int.Parse(tbSourceXMLStartDepth.Text));
                    XMLParser2 xmlParser = new XMLParser2(rowCollectionMenager, tbSourceFile.Text, tbXPath.Text);
                }
                else if (cbDataSource.SelectedIndex == 5)
                {
                    FolderParser folderParser = new FolderParser(rowCollectionMenager);
                    folderParser.AutomaticAddToRowCollectionMenager_FolderSource(tbFolderInputPath.Text, tbFolderInputFolderMatcher.Text, tbFolderInputColumnRegex.Text, cbFolderInputLookSubfolders.Checked);
                }
                else if (cbDataSource.SelectedIndex == 6)
                {
                    FileParser folderParser = new FileParser(rowCollectionMenager);
                    folderParser.AutomaticAddToRowCollectionMenager_FileSource(tbFileInputFolder.Text, tbFileInputFolderMatcher.Text, tbFileInputFileMatcher.Text, tbFileInputColumnSpliter.Text, cbFileInputSubfolders.Checked);
                }
                else
                {
                    MessageBox.Show("Select data source");
                }

                // save settings
                SaveSettingsToSettingsMenager();
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "btnLoad_Click", ModuleLog.LogType.ERROR);
            }
            this.Close();
        }
Example #24
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();
                }
            }
        }
        public void Load()
        {
            TreeNode node;
            string   path = "";
            string   templateName;

            try
            {
                node = treeView.SelectedNode;
                if (node.Name.Equals("file"))
                {
                    templateName = node.Text;

                    DialogResult dialogResult = MessageBox.Show("Load template: " + templateName, "Load template", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.OK)
                    {
                        if (node.Parent != null)
                        {
                            path = Common.BuildPath(templateFolder, node.Parent.FullPath);
                        }
                        else
                        {
                            path = Common.BuildPath(templateFolder);
                        }
                        path = path + templateName + ".xml";

                        ModuleLog.Write(new string[] { "Loading template", "Name:" + templateName, "Path: " + path }, this, "Load", ModuleLog.LogType.INFO);

                        // try load with old settgins menager
                        bool result;
                        settingsManager.FilePath = path;
                        settingsManager.GroupOf  = node.Name;
                        result = settingsManager.LoadSettings();

                        if (result == false)
                        {
                            // settings menager 2
                            ModuleLog.Write("Old settings menager fail to load template, will try to load with new settings menager", this, "Load", ModuleLog.LogType.INFO);

                            settingsManager2.LoadFromFile(path);
                        }
                    }
                    activeTemplatePath = path;
                    // save general active template
                    Settings.Setting.Items.Add(new SettingsMenagerStructure2(Settings.SettingName.ActiveTemplateName.ToString(), Settings.SettingName.ActiveTemplateName.ToString(), path, "", SettingsMenager2.Type.Text));
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "Load", ModuleLog.LogType.ERROR);
            }
        }
Example #26
0
        public MessageTimerModule(IMessageBus messageBus, int intervalSeconds)
        {
            if (intervalSeconds < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(intervalSeconds), "intervalSeconds must be 1 or higher");
            }

            _intervalSeconds = intervalSeconds;
            //_timer = new Acquaintance.Timers.MessageTimer(delayMs: 5000, intervalMs: intervalSeconds * 1000);
            _messageBus = messageBus;
            _sequence   = 0;
            _log        = new ModuleLog(messageBus, Name);
        }
Example #27
0
        public BackplaneModule(CrossStitchCore core, IClusterBackplane backplane = null, BackplaneConfiguration configuration = null)
        {
            _messageBus = core.MessageBus;
            _log        = new ModuleLog(_messageBus, Name);

            _configuration = configuration ?? BackplaneConfiguration.GetDefault();
            _backplane     = backplane ?? new ZyreBackplane(core, _configuration);

            // Forward messages from the backplane to the IMessageBus
            _backplane.MessageReceived += MessageReceivedHandler;
            _backplane.ClusterMember   += ClusterMemberHandler;
            _backplane.ZoneMember      += ZoneMemberHandler;
        }
Example #28
0
        private void bWriteErrorLog_Click(object sender, EventArgs e)
        {
            ModuleLog.Write("Now will we ganerate error", this, "bWriteErrorLog_Click", ModuleLog.LogType.INFO);

            try
            {
                throw new Exception("I made error :P");
            }
            catch (Exception ex)
            {
                ModuleLog.Write(ex, this, "bWriteErrorLog_Click", ModuleLog.LogType.ERROR);
            }
        }
Example #29
0
 public XMLParser(string path)
 {
     try
     {
         ModuleLog.Write("Loading xml file\r\n" + path, this, "XMLParser", ModuleLog.LogType.DEBUG);
         xmlDoc = new XmlDocument();
         xmlDoc.Load(path);
     }
     catch (Exception ex)
     {
         ModuleLog.Write(ex, this, "XMLParser", ModuleLog.LogType.ERROR);
     }
 }
Example #30
0
        public MasterModule(CrossStitchCore core, NodeConfiguration configuration)
        {
            _configuration = configuration;
            _messageBus    = core.MessageBus;
            _log           = new ModuleLog(core.MessageBus, Name);
            var data = new DataHelperClient(core.MessageBus);

            _data = new MasterDataRepository(core.NodeId, data);
            var stitches = new StitchRequestHandler(core.MessageBus);
            var sender   = new ClusterMessageSender(core.MessageBus);

            _service = new MasterService(core, _log, _data, stitches, sender);
        }