Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
0
        public VarObjectStruct GetObjectFromName(string objectName)
        {
            VarObjectStruct varObjectStruct = null;

            // Is object with 'array name' already set ?
            foreach (VarObjectStruct isVariable in varObjectStructList)
            {
                if (objectName == isVariable.Name)
                {
                    varObjectStruct = isVariable;
                    break;
                }
            }
            return(varObjectStruct);
        }
Exemplo n.º 3
0
        public void Add(string objectName, string value)
        {
            VarObjectStruct varObjectStruct = null;

            // if objectStruct exists return it, else return null
            varObjectStruct = GetObjectFromName(objectName);

            if (varObjectStruct == null)
            {
                // VarObjectStruct entry is object with name and value propertis
                varObjectStruct = new VarObjectStruct(objectName, VarObjectStruct.Type.Array);
                varObjectStruct.Add(value);

                // Add entry to row collection
                varObjectStructList.Add(varObjectStruct);
            }
            else
            {
                varObjectStruct.Add(value);
            }
        }
Exemplo n.º 4
0
        public string ProcessTag()
        {
            string result = null;

            try
            {
                if (tag.Child.Name == "add")
                {
                    //{=array.add.[ArrayName].[Value]}
                    this.Add(tag.Child.Child.Name, tag.Child.Child.Child.Name);
                }
                else if (tag.Child.Name == "addOnce")
                {
                    //{=array.addOnce.[ArrayName].[Value]}
                    this.AddOnce(tag.Child.Child.Name, tag.Child.Child.Child.Name);
                }
                else if (tag.Child.Name == "fetch")
                {
                    // {=array.fetch."[ArrayName]"
                    foreach (VarObjectStruct varObjectStruct in varObjectStructList)
                    {
                        if (varObjectStruct.Name == tag.Child.Child.Name)
                        {
                            result = varObjectStruct.Fetch();
                            //ModuleLog.Write("VarObjectName: " + objectEntry.Name + "\r\nVarObjectValue: " + objectEntry.Value, this, "VarObject", ModuleLog.LogType.DEBUG);
                            break;
                        }
                    }
                }
                else if (tag.Child.Name == "fetchNext")
                {
                    // {=array.fetch."[ArrayName]"
                    foreach (VarObjectStruct varObjectStruct in varObjectStructList)
                    {
                        if (varObjectStruct.Name == tag.Child.Child.Name)
                        {
                            result = varObjectStruct.FetchNext();
                            //ModuleLog.Write("VarObjectName: " + objectEntry.Name + "\r\nVarObjectValue: " + objectEntry.Value, this, "VarObject", ModuleLog.LogType.DEBUG);
                            break;
                        }
                    }
                }
                else if (tag.Child.Name == "empty")
                {
                    // {=array.empty."[ArrayName]"}
                    VarObjectStruct varObjectStruct = GetObjectFromName(tag.Child.Child.Name);
                    varObjectStruct.Empty();
                    result = "";
                }
                else
                {
                    ModuleLog.Write(new string[] { TagsReplace.constError_CommandNotFound, tag.InputText }, this, "ArrayObject", ModuleLog.LogType.ERROR);
                    result = TagsReplace.constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { TagsReplace.constError_ExecutingBlock, tag.InputText }, this, "ArrayObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "ArrayObject", ModuleLog.LogType.ERROR);
                result = TagsReplace.constError_SyntaxError;
            }
            return(result);
        }