public AssetStatusEnum ComputeStatus()
 {
     AssetTypeDesc typeDesc = AssetTypeDesc.FindAssetTypeDesc(typeEnum);
     if (files.Count == 0 || typeDesc == null) {
         status = AssetStatusEnum.Incomplete;
         breakage = "No files in asset definition";
         return status;
     }
     AssetTypeDesc type = AssetTypeDesc.FindAssetTypeDesc(typeEnum);
     AssetFile primaryFile = files[0];
     if (primaryFile.FileTypeEnum != type.PrimaryFileType) {
         status = AssetStatusEnum.Broken;
         breakage = "Primary file is not of the right type";
         return status;
     }
     // Now go through the other types, asking if we have the
     // right numbers of them
     int countRemaining = files.Count - 1;
     int descCount = 0;
     foreach(AssetTypeFileDesc desc in type.FileTypes) {
         descCount++;
         if (descCount == 1)
             continue;    // We've already checked the primary file
         int cnt = CountFilesOfType(desc.FileTypeEnum);
         if (cnt < desc.MinCount) {
             status = AssetStatusEnum.Incomplete;
             breakage = "Not enough files of type " + desc.FileExtension;
             return status;
         }
         if (cnt > desc.MaxCount) {
             status = AssetStatusEnum.Incomplete;
             breakage = "Too many files of type " + desc.FileExtension;
             return status ;
         }
         countRemaining -= cnt;
     }
     if (countRemaining > 0 && typeEnum != AssetTypeEnum.Other) {
         status = AssetStatusEnum.Broken;
         breakage = "There are files of types not allowed for this asset type";
         return status;
     }
     status = AssetStatusEnum.Complete;
     breakage = "";
     return status;
 }
        protected bool ReadXmlFileInternal(XmlReader r, List<string> log)
        {
            //Debug.Assert(root.LocalName == "AssetDefinition");
            while(r.Read()) {
                if (r.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }
                if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                switch (r.Name)
                {
                    case "Name":
                        name = r.ReadElementString();
                        break;
                    case "Description":
                        description = r.ReadElementString();
                        break;
                    case "Category":
                        category = r.ReadElementString();
                        break;
                    case "Type":
                        typeEnum = AssetTypeDesc.AssetTypeEnumFromName(r.ReadElementString());
                        break;
                    case "Status":
                        status = AssetTypeDesc.AssetStatusEnumFromName(r.ReadElementString());
                        break;
                    case "Breakage":
                        breakage = r.ReadElementString();
                        break;
                    case "Files":

                        while (r.Read())
                        {
                            if (r.NodeType == XmlNodeType.Whitespace)
                            {
                                continue;
                            }
                            if (r.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }
                            switch (r.Name)
                            {
                                case "AssetFile":
                                    files.Add(AssetFile.FromXml(r, log));

                                    break;
                            }
                        }
                        break;
                    case "Properties":
                        while (r.Read())
                        {
                            if (r.NodeType == XmlNodeType.Whitespace)
                            {
                                continue;
                            }
                            if (r.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }
                            switch (r.Name)
                            {
                                case "Property":
                                    properties.Add(AssetProperty.FromXml(r));
                                    break;
                            }
                        }
                        break;

                    default:
                        log.Add(string.Format("In AssetDefinition.ReadXmlFileInternal, unknown attribute '{0}'",
                            r.Name));
                        break;
                }
            }
            return true;
        }
 public AssetDefinition()
 {
     name = "";
     description = "";
     category = "";
     typeEnum = AssetTypeEnum.None;
     status = AssetStatusEnum.Incomplete;
     breakage = "";
     files = new List<AssetFile>();
     properties = new List<AssetProperty>();
 }
 public AssetDefinition(string name, AssetTypeEnum typeEnum, AssetFile file)
 {
     this.name = name;
     description = "";
     category = "";
     this.typeEnum = typeEnum;
     status = AssetStatusEnum.Complete;
     breakage = "";
     List<AssetFile> files = new List<AssetFile>();
     files.Add(file);
     this.files = files;
     properties = new List<AssetProperty>();
 }
Beispiel #5
0
 public void UpdateRecords(DateTime Timestamp, AssetStatusEnum Status)
 {
     Records.Add(new Record(Timestamp, Status));
 }
 //protected static string[] assetStatusEnumNames = {
 //    "None",
 //    "Complete",
 //    "Incomplete",
 //    "Broken"
 //};
 public static string AssetStatusEnumName(AssetStatusEnum e)
 {
     //return assetStatusEnumNames[(int)e];
     return e.ToString();
 }
Beispiel #7
0
 public AssetClass()
 {
     this.AssetID = NextID;
     this.Status  = AssetStatusEnum.IDLE;
     Records      = new List <Record>();
 }
Beispiel #8
0
 public Record(DateTime Timestamp, AssetStatusEnum Status)
 {
     this.Timestamp = Timestamp;
     this.Status    = Status;
 }
        public static string GetAssetImageUrl(AssetTypesEnum AssetType, AssetStatusEnum AssetStatus)
        {
            switch (AssetType)
            {
            case AssetTypesEnum.DOTcounters:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/Dot_counters_not_working.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/Dot_counters_maint.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/Dot_counters.png");
                }
                break;

            case AssetTypesEnum.EkinRedLightCamera:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/ekin_red_light_camera_not_working.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/ekin_red_light_camera_maint.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/ekin_red_light_camera.png");
                }
                break;

            case AssetTypesEnum.SmartTowers:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/s_tower_cctv_camera_not_working.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/s_tower_cctv_camera_maint.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/s_tower_cctv_camera.png");
                }
                break;

            case AssetTypesEnum.SpeedGuns:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/speed_guns_not_working.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/speed_guns_maint.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/speed_guns.png");
                }
                break;

            case AssetTypesEnum.VitronicMobileRadars:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/assets-not-work.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/assets-not-work.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/assets-marker.png");
                }
                break;

            case AssetTypesEnum.VitronicRadars:
                switch (AssetStatus)
                {
                case AssetStatusEnum.NotWorking:
                    return(@"Images/icons/vitronic_radars_not_working.png");

                case AssetStatusEnum.UnderMaintenance:
                    return(@"Images/icons/vitronic_radars_maint.png");

                case AssetStatusEnum.Working:
                    return(@"Images/icons/vitronic_radars.png");
                }
                break;
            }

            return("");
        }
 public static string AssetStatusEnumName(AssetStatusEnum e)
 {
     return assetStatusEnumNames[(int)e];
 }
        protected bool ReadXmlFileInternal(string path, List<string> log)
        {
            try {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                XmlElement root = doc.DocumentElement;
                //Debug.Assert(root.LocalName == "AssetDefinition");
                XmlElement child = (XmlElement)root.FirstChild;
                while (child != null) {
                    switch (child.LocalName) {
                        case "Name":
                            name = child.InnerText;
                            break;
                        case "Description":
                            description = child.InnerText;
                            break;
                        case "Category":
                            category = child.InnerText;
                            break;
                        case "Type":
                            typeEnum = AssetTypeDesc.AssetTypeEnumFromName(child.InnerText);
                            break;
                        case "Status":
                            status = AssetTypeDesc.AssetStatusEnumFromName(child.InnerText);
                            break;
                        case "Breakage":
                            breakage = child.InnerText;
                            break;
                        case "Files":
                            XmlElement fileElement = (XmlElement)child.FirstChild;
                            while (fileElement != null) {
                                files.Add(AssetFile.FromXml(fileElement, log));
                                fileElement = (XmlElement)fileElement.NextSibling;
                            }
                            break;
                        case "Properties":
                            XmlElement propertyElement = (XmlElement)child.FirstChild;
                            while (propertyElement != null) {
                                properties.Add(AssetProperty.FromXml(propertyElement));
                                propertyElement = (XmlElement)propertyElement.NextSibling;
                            }
                            break;

                        default:
                            log.Add(string.Format("In AssetDefinition.ReadXmlFileInternal, unknown attribute '{0}'",
                                                  child.LocalName));
                            break;
                    }
                    child = (XmlElement)child.NextSibling;
                }
                return true;
            } catch (Exception e) {
                log.Add(string.Format("Error reading asset definition file '{0}': {1}",
                                                  path, e.Message));
                return false;
            }
        }