Example #1
0
        private static ScriptStructure[] ConvertScriptTBToScriptStructure(List <ScriptTB> ScriptTBArr)
        {
            List <ScriptStructure> ScriptStructureList = new List <ScriptStructure>();

            foreach (ScriptTB ThisScript in ScriptTBArr)
            {
                ScriptStructure NewSturcture = new ScriptStructure();
                NewSturcture.TargetID           = ThisScript.TargetID;
                NewSturcture.BlockID            = ThisScript.BlockID;
                NewSturcture.BlockName          = ThisScript.BlockName;
                NewSturcture.CommandCounter     = ThisScript.CommandCounter.Value;
                NewSturcture.CommandName        = ThisScript.CommandName;
                NewSturcture.DelayTime          = ThisScript.DelayTime;
                NewSturcture.DeviceCategory     = TTCSHelper.DeviceCategoryStrConverter(ThisScript.DeviceCategory);
                NewSturcture.DeviceName         = TTCSHelper.DeviceNameStrConverter(ThisScript.DeviceName);
                NewSturcture.ExecutionNumber    = ThisScript.ExecutionNumber;
                NewSturcture.ExecutionTimeEnd   = ThisScript.ExecutionTimeEnd;
                NewSturcture.ExecutionTimeStart = ThisScript.ExecutionTimeStart;
                NewSturcture.Owner = ThisScript.Owner;

                NewSturcture.Parameter = new List <Object>();
                String[] ValueStr = ThisScript.Parameter.Split(new char[] { ',' });
                foreach (String ThisValue in ValueStr)
                {
                    NewSturcture.Parameter.Add(ThisValue);
                }
                ;

                NewSturcture.ScriptState = TTCSHelper.ScriptStateStrConverter(ThisScript.ScriptState);
                NewSturcture.StationName = TTCSHelper.StationStrConveter(ThisScript.StationName);

                ScriptStructureList.Add(NewSturcture);
            }

            return(ScriptStructureList.ToArray());
        }
Example #2
0
        private static Boolean VerifyScript(STATIONNAME StationName, List <ScriptStructureNew> ScriptCollection, out String Message)
        {
            foreach (ScriptStructureNew ThisScript in ScriptCollection)
            {
                //DUMMY ONLY
                //ThisScript.TargetID = "XXXXXX";

                if (String.IsNullOrEmpty(ThisScript.ScriptID))
                {
                    Message = "Invalid ScriptID can't be null or empty value. Please check.";
                    return(false);
                }

                if (String.IsNullOrEmpty(ThisScript.BlockID))
                {
                    Message = "Invalid BlockID can't be null or empty value at Script ID : " + ThisScript.ScriptID + ". Please check.";
                    return(false);
                }

                STATIONNAME ScriptStationName = TTCSHelper.StationStrConveter(ThisScript.StationName);

                if (StationName == STATIONNAME.NULL)
                {
                    Message = "Invalid station same at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                if (StationName != ScriptStationName)
                {
                    Message = "Invalid station name not match in folder at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                DEVICENAME DeviceName = TTCSHelper.DeviceNameStrConverter(ThisScript.DeviceName);
                if (DeviceName == DEVICENAME.NULL)
                {
                    Message = "Invalid device name at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                DEVICECATEGORY DeviceCategory = TTCSHelper.ConvertDeviceNameToDeviceCategory(StationName, DeviceName);
                if (DeviceCategory == DEVICECATEGORY.NULL)
                {
                    Message = "Invalid devicecategory at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                Object CommandName = TTCSHelper.CommandNameConverter(DeviceCategory, ThisScript.CommandName);
                if (CommandName == null)
                {
                    Message = "Invalid command name at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                Int64 StartDateLong = 0;
                if (!Int64.TryParse(ThisScript.ExecutionTimeStart, out StartDateLong))
                {
                    Message = "Invalid start datetime at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                Int64 EndDateLong = 0;
                if (!Int64.TryParse(ThisScript.ExecutionTimeEnd, out EndDateLong))
                {
                    Message = "Invalid end datetime at script ID : " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                int Life = 0;
                if (!int.TryParse(ThisScript.Life, out Life))
                {
                    Message = "Invalid life time at " + ThisScript.BlockID + ". Please check spelling.";
                    return(false);
                }

                if (String.IsNullOrEmpty(ThisScript.TargetID))
                {
                    Message = "Invalid TargetID can't be null or empty value at Script ID : " + ThisScript.BlockID + ". Please check.";
                    return(false);
                }

                if (String.IsNullOrEmpty(ThisScript.Owner))
                {
                    Message = "Invalid Owner can't be null or empty value at Script ID : " + ThisScript.BlockID + ". Please check.";
                    return(false);
                }

                ReturnKnowType CommandResult = CommandDefinition.VerifyCommand(StationName, DeviceCategory, CommandName, ThisScript.Parameters.ToArray());
                if (CommandResult.ReturnType == ReturnStatus.FAILED)
                {
                    Message = "Invalid parameter at script ID : " + ThisScript.ScriptID + " at Command " + CommandName + ". With: " + CommandResult.ReturnMessage + ". Please check spelling.";
                    return(false);
                }
            }

            Message = "All script verified.";
            return(true);
        }