/// <summary> /// Updates DST in the connected meter. This method does not reconfigure /// DST. Only future dates in 2007 and beyond are updated. /// </summary> /// <param name="DSTFileName">The filename including path for the DST file</param> /// <returns>A DSTUpdateResult</returns> /// // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 06/16/06 mcm 7.30.00 N/A Created // 01/24/07 mrj 8.00.08 Flushed status flags when updating dst // public override DSTUpdateResult UpdateDST(string DSTFileName) { FileStream EDLFileStream; XmlTextReader EDLXMLReader; string defaultEDLFileName; if (m_TOUTables == null) { m_TOUTables = new CentronTables(); } defaultEDLFileName = CRegistryHelper.GetFilePath(CentronII_REPLICA) + CentronII_PROGRAM_FOLDER + DEFAULT_PROGRAM; if (File.Exists(defaultEDLFileName)) { EDLFileStream = new FileStream(defaultEDLFileName, FileMode.Open, FileAccess.Read, FileShare.Read); EDLXMLReader = new XmlTextReader(EDLFileStream); // Load the Defaul EDL File as the file stream to process TOU and DST data m_TOUTables.LoadEDLFile(EDLXMLReader); } if (DSTFileName != null) { ClearDST(); // Key step to clear DST first ImportDST(); DSTDataSet = m_TOUTables.BuildPSEMStreams(2260); } AMIConfigureCentronII configureDevice = new AMIConfigureCentronII(m_PSEM); DSTUpdateResult result = configureDevice.ReconfigureDST(DSTDataSet) ? DSTUpdateResult.SUCCESS : DSTUpdateResult.ERROR; return(result); }
/// <summary> /// Creates an instance of the Holiday Lists /// </summary> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 06/02/06 ach N/A N/A Creation of Class /// 06/19/06 ach N/A N/A Updated ID management for compatability /// with older TOU Schedules public CHolidayLists() { // Local Variables XmlNodeList xmlnodelistTempRoot; m_xmldomColl = new XmlDocument( ); String sPathName = CRegistryHelper.GetDataDirectory(TOU_SCHEDULE) + "\\HolList.dat"; m_xmldomColl.Load(sPathName); // Update the Xml Format UpdateXmlFormat(); // Get The Root of the all the holiday lists xmlnodelistTempRoot = m_xmldomColl.GetElementsByTagName("HolidayData"); m_xmlnodeRoot = xmlnodelistTempRoot[0]; // Get all the Holiday Lists from the Root m_xmlnodelistLists = m_xmldomColl.GetElementsByTagName("HolidayList"); // Remove all apostrophes and quotes from the xml tags foreach (XmlNode list in m_xmlnodelistLists) { m_xmlnodeCurrentList = list; Name = Name; } // Set the first list as the current list by default m_xmlnodeCurrentList = m_xmlnodelistLists[0]; // Set the next ID UpdateNextID(); } //HolidayLists
/// <summary> /// Constructor. /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 05/23/08 jrf 1.50.28 Created // public CXMLOpenWayUserAccessPolicy() : base() { string strFilePath = CRegistryHelper.GetFilePath(REPLICA_REG_KEY) + XML_REPLICA_FILE_NAME; m_EncryptedXMLSettings = new CXMLEncryptedSettings(strFilePath, "", XML_CAPABILITIES_TAG); m_EncryptedXMLSettings.XMLFileName = strFilePath; }
/// <summary> /// Constructor. /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 09/20/10 SCW 1.00.00 Created // public XMLMaxImageActiveFiles() : base() { string strFilePath = CRegistryHelper.GetFilePath(REPLICA_REG_KEY) + XML_REPLICA_FILE_NAME; m_XMLSettings = new CXMLSettings(strFilePath, "", XML_ACTIVE_TAG); m_XMLSettings.XMLFileName = strFilePath; }
/// <summary> /// Constructor /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 08/28/09 RCG 2.30.00 Created public OpenProgramDialog() { InitializeComponent(); m_strProgramDirectory = CRegistryHelper.GetFilePath(REPLICA) + PROGRAM_FOLDER; PopulatePrograms(); }
/// <summary> /// Constructor. /// </summary> /// <param name="strFilePath"> /// XML file path to use. If "" is passed in, then the default is used /// </param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 02/08/08 mrj 1.00.00 Created // public CXMLOpenWayReplicaFileSettings(string strFilePath) : base() { m_XMLSettings = new CXMLSettings(CRegistryHelper.GetFilePath(REPLICA_REG_KEY) + XML_REPLICA_FILE_NAME, "", XML_SETTINGS_TAG); if (null != m_XMLSettings) { m_XMLSettings.XMLFileName = strFilePath; } }
/// <summary> /// Constructor. /// </summary> /// <param name="strFilePath"> /// XML file path to use. If "" is passed in, then the default is used /// </param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 02/08/08 mrj 1.00.00 Created // public CXMLMaxImageSystemSettings(string strFilePath) : base() { m_XMLSettings = new CXMLSettings(CRegistryHelper.GetFilePath(REPLICA_REG_KEY) + XML_OPENWAY_FILE_NAME, "", XML_SETTINGS_TAG); if (null != m_XMLSettings) { m_XMLSettings.XMLFileName = strFilePath; } m_FieldProAllDevices = new CXMLFieldProSettingsAllDevices(m_XMLSettings); m_FieldProLogonOptions = new CXMLFieldProSettingsLogonOptions(m_XMLSettings); }
/// <summary> /// Constructor - Load the DST xml file in the XmlDocument, and begin to /// build the collection of DSTDatePair objects. Will use the Registry Access /// Namespace's CRegistryHelper class and the GetFilePath method to obtain /// FilePath for the DST xml file. /// If there is an error with the XmlDocument then an XmlException will be /// thrown. /// </summary> /// <example> /// <code> /// CDSTSchedule objDST = new CDSTSchedule(); /// </code> /// </example> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 03/03/06 rrr N/A N/A Creation of class public CDSTSchedule() { //Get the file path for the xml file #if (!WindowsCE) m_strFilePath = CRegistryHelper.GetFilePath(REG_DST_FILE_PATH); #else m_strFilePath = CRegistryHelper.GetFilePath(REG_APP_HH_PRO); #endif m_strFilePath = m_strFilePath + DST_FILE; //Create and load the XmlDocument m_xmldomDST = new XmlDocument(); m_xmldomDST.Load(m_strFilePath); BuildDSTDatePairs(); }
/// <summary> /// Reconfigures TOU in the connected meter /// </summary> /// <param name="TOUFileName">The filename including path for the TOU</param> /// <param name="DSTFileName">The filename including path for the DST /// file. If this parameter is emtpy then client only wants to /// reconfigure TOU, not DST. The DSTFileName MUST be included if the /// meter is configured for DST. If the meter is not configured for DST /// and this filename is given, the operation will succeed, but it will /// return a conditional success code.</param> /// <returns>A TOUReconfigResult</returns> /// // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 12/04/10 SCW 9.70.14 Created public override TOUReconfigResult ReconfigureTOU(string TOUFileName, string DSTFileName) { FileStream EDLFileStream; XmlTextReader EDLXMLReader; string defaultEDLFileName; try { if (m_TOUTables == null) { m_TOUTables = new CentronTables(); } defaultEDLFileName = CRegistryHelper.GetFilePath(CentronII_REPLICA) + CentronII_PROGRAM_FOLDER + DEFAULT_PROGRAM; if (File.Exists(defaultEDLFileName)) { EDLFileStream = new FileStream(defaultEDLFileName, FileMode.Open, FileAccess.Read, FileShare.Read); EDLXMLReader = new XmlTextReader(EDLFileStream); // Load the Defaul EDL File as the file stream to process TOU and DST data m_TOUTables.LoadEDLFile(EDLXMLReader); } if (TOUFileName != null) { ClearTOU(); // Key step to clear TOU first ImportTOU(TOUFileName); TOUDataSet = m_TOUTables.BuildPSEMStreams(2090); } } catch (Exception) { throw new ArgumentException("Failure in importing EDL or DST files !!"); } CTable2048Header m_2048Header = new CTable2048Header(m_PSEM); AMIConfigureCentronII configureDevice = new AMIConfigureCentronII(m_PSEM); TOUReconfigResult result = configureDevice.ReconfigureTOU(TOUDataSet, m_2048Header.CalendarOffset, m_2048Header.TOUOffset) ? TOUReconfigResult.SUCCESS : TOUReconfigResult.ERROR; return(result); }
/// <summary> /// Constructor /// </summary> /// <param name="strName"> /// The identifier for the current test run. This is used to identify which probe the test is /// being run on and is for informational purposes. /// </param> /// <param name="strPort">The port to use for the test.</param> /// <param name="uiBaudRate">The baud rate to use for the test.</param> /// <param name="probeType">The optical probe type for the test.</param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 08/28/09 RCG 2.30.00 Created public ValidationWorker(string strName, string strPort, uint uiBaudRate, OpticalProbeTypes probeType) { m_bCancelled = false; m_strName = strName; m_strResultDir = Settings.Default.ResultsDir + "\\"; m_strPort = strPort; m_uiBaudRate = uiBaudRate; m_ProbeType = probeType; m_Comm = new SerialCommDesktop(); m_Comm.OpticalProbe = m_ProbeType; m_Comm.BaudRate = m_uiBaudRate; m_strProgramFile = Settings.Default.ProgramFile; m_strValidationTestsFile = CRegistryHelper.GetFilePath(REG_REPLICA) + TEST_FILE; if (Directory.Exists(m_strResultDir) == false) { Directory.CreateDirectory(m_strResultDir); } }
/// <summary> /// Validates the HAN keys /// </summary> // Revision History // MM/DD/YY Who Version ID Number Description // -------- --- ------- -- ------ ------------------------------------------- // 09/17/09 RCG 2.30.00 Created // 09/19/14 jrf 4.00.63 WR 534158 Modified way test details are set. // 05/23/17 CFB 4.72.00 WR 741323 Removed validation of HAN link key as it is no longer used in the meter private void ValidateHANKeys() { string NetworkKey = (string)CRegistryHelper.GetApplicationValue("GasPro", "Key"); string LinkKey = (string)CRegistryHelper.GetApplicationValue("GasPro", "GlobalLinkKey"); ProcedureResultCodes ValidationResult = ProcedureResultCodes.COMPLETED; string Details = ""; if (IsAborted == false) { //Network Key validation ValidationResult = m_AmiDevice.ValidateHANSecurityKeys(NetworkKey, CENTRON_AMI.HANKeys.NetworkKey); Details = GetSecurityValidationDetails(ValidationResult); if (ProcedureResultCodes.INVALID_PARAM == ValidationResult) { Details += ", " + TestResources.KeyNotConsistentWithRegistry; } AddTestDetail(TestResources.HANNetworkKey, GetResultString(ProcedureResultCodes.COMPLETED == ValidationResult), Details); } }
/// <summary> /// Reads the encrypted key from the registry and decrypts the byte array. /// This version of GetSecurityKey can get either of the HAN security keys. /// </summary> /// <param name="IncludeSeqNbr">Whether or not to include the sequence /// number at the start of the key</param> /// <param name="KeyName">The name of the key to fetch - either the /// network key or the global link key /// </param> /// <returns>the decrypted key as a byte array</returns> // // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 03/11/08 AF 1.50.04 Created // 10/02/09 AF 2.30.05 Added Compare() parameter for compiler warning // 11/25/09 AF 2.30.22 Changed String.Compare() to quiet compiler warning // 06/12/12 RCG 2.70.77 Changed to use the Secured Encryption Keys protected byte[] GetSecurityKey(bool IncludeSeqNbr, string KeyName) { byte[] DecryptedKeyWithSeqNumber = new byte[17]; byte[] DecryptedKey; string EncryptedKey = (string)CRegistryHelper.GetApplicationValue("GasPro", KeyName); DecryptedKey = DecryptHANKey(EncryptedKey); // By definition the sequence number is the first byte of the key DecryptedKeyWithSeqNumber[0] = DecryptedKey[0]; Array.Copy(DecryptedKey, 0, DecryptedKeyWithSeqNumber, 1, DecryptedKey.Length); if (IncludeSeqNbr) { return(DecryptedKeyWithSeqNumber); } else { return(DecryptedKey); } }
} //CTOUScheduleFileCollection(string) /// <summary> /// Used to refresh the collection of TOU Schedules /// </summary> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 02/15/06 rrr N/A N/A Creation of class // 04/10/07 mrj 8.00.27 2860 If this is an SCS device then check that // any SCS device is supported. // private void Refresh(string strDevice) { //Local variables XmlDocument xmldomSchedule = null; XmlNodeList xmlnodelistDevices = null; CTOUScheduleFile objSchedule = null; DirectoryInfo objDir = null; bool blnCorrectID = false; string strTOUID = null; int intTOUID = 0; string strName = null; string strFilePath = null; //Get the directory for the TOU Schdule files m_strDataDirectory = CRegistryHelper.GetDataDirectory(CALENDAR_EDITOR); //Throw an error if the directory comes back null if (null == m_strDataDirectory) { throw new Exception("The directory for TOU Schedules does not exist"); } //Create a directory info object based on the directory objDir = new DirectoryInfo(m_strDataDirectory); //Go through the list of xml files in the directory foreach (FileInfo objFile in objDir.GetFiles("*.xml")) { blnCorrectID = true; //Check the first 4 characters of the name to make sure they are digits strTOUID = objFile.Name.Substring(0, 4); for (int intCount = 0; intCount < 4; intCount++) { if (!Char.IsDigit(strTOUID, intCount)) { blnCorrectID = false; } } //Check that there is a least one char after the TOU ID if (!(strTOUID.Length < (objFile.Name.Length - objFile.Extension.Length))) { blnCorrectID = false; } //if the collection needs to be filtered if (null != strDevice) { blnCorrectID = false; //Create a new XmlDocument and load the file xmldomSchedule = new XmlDocument(); xmldomSchedule.Load(objFile.FullName); //Get the SupportedDevice nodes from the xml document and check for the //given device name xmlnodelistDevices = xmldomSchedule.GetElementsByTagName( "SupportedDevice"); for (int intCount = 0; intCount < xmlnodelistDevices.Count && blnCorrectID == false; intCount++) { if (strDevice == xmlnodelistDevices[intCount].InnerText) { blnCorrectID = true; } else if (strDevice == SENTINEL_ADVANCED) { // If the device has reported itself as a SENTINEL advanced schedule, then it should support the // SENTINEL - Basic as well. if (SENTINEL_BASIC == xmlnodelistDevices[intCount].InnerText) { blnCorrectID = true; } } else if (((CENTRON_POLY_DEVICE == strDevice) || (CENTRON_POLY_DEVICE_OBSOLETE == strDevice)) && ((CENTRON_POLY_DEVICE == xmlnodelistDevices[intCount].InnerText) || (CENTRON_POLY_DEVICE_OBSOLETE == xmlnodelistDevices[intCount].InnerText))) { // Depending on the version of the msxml DOM object the file was // saved with, the CENTRON (V&I) string can have 2 formats. // Support both blnCorrectID = true; } else if (strDevice == VECTRON || strDevice == CENTRON || strDevice == FULCRUM || strDevice == QUANTUM || strDevice == MT200) { //This is an SCS device so make sure any of these are supported if (xmlnodelistDevices[intCount].InnerText == VECTRON || xmlnodelistDevices[intCount].InnerText == CENTRON || xmlnodelistDevices[intCount].InnerText == FULCRUM || xmlnodelistDevices[intCount].InnerText == QUANTUM || xmlnodelistDevices[intCount].InnerText == MT200) { //The device type is an SCS device and at least one of the //SCS devices are supported so we can continue blnCorrectID = true; } } } } //If the first 4 chars are digits then get the info for the //CTOUScheduleFile class if (blnCorrectID) { intTOUID = int.Parse(strTOUID); strName = objFile.Name.Substring(4, objFile.Name.Length - 4); strName = strName.Remove(strName.Length - objFile.Extension.Length, objFile.Extension.Length); strFilePath = objFile.FullName; //Create a new CTOUScheduleFile from the File info object objSchedule = new CTOUScheduleFile(intTOUID, strName, strFilePath); //Add the CTOUScheduleFile to the collection InnerList.Add(objSchedule); } } } //Refresh()
/// <summary> /// This method reverse engineers multiple custom schedules from a given device server. /// </summary> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 10/06/08 jrf 9.50 Created // 12/12/08 jrf 9.50.26 124330 Set a max number of multiple custom schedules // to look for to avoid entering an infinite loop. // 124361 Added code to handle slots with no schedules configured. // 01/07/09 jrf 9.50.29 125402 Switched comparison statements in the last while loop. // The comparison checking if the index is valid needed to // come before the comparison the comparison accessing the // list. // private void ReverseEngineerMultipleCustomSchedules() { string strFilePath = CRegistryHelper.GetFilePath(PEDATA) + PEDATA + XML_EXT; int iMCSIndex = 0; int iMCSNumber = 0; object objType = MULT_CUSTOM_SCHED_DATA; object objSubType = iMCSIndex; object objFileName = strFilePath; object objStartDate = null; object objStopDate = null; CCustomSchedule BillingSchedule; DateCollection BillingDates = new DateCollection(); DateTime dtStartDate; string strMIFName = Path.GetFileNameWithoutExtension(FileName); bool blnCustomScheduleFound = true; FileStream Stream; StreamWriter Writer; XmlReader Reader; short sDisplayProgress = 0; while (iMCSIndex < MAX_MULTIPLE_CUSTOM_SCHEDULES) { //Set the PEData file to a default empty format Stream = new FileStream(strFilePath, FileMode.Create); Writer = new StreamWriter(Stream); Writer.Write(MCS_PEDATA); Writer.Close(); Stream.Close(); //Get the multiple custom schedule data out of the device server VirtualDevice.GetXMLData(objType, objSubType, objFileName, sDisplayProgress, ref objStartDate, ref objStopDate); Reader = XmlReader.Create(strFilePath); //if we don't have a year node then no custom schedule //was retreived blnCustomScheduleFound = Reader.ReadToFollowing(YEAR); if (true == blnCustomScheduleFound) { //Clear out dates for the previous schedule BillingDates.Clear(); //Read each starting time and add them to the billing schedule while (true == Reader.ReadToFollowing(START_TIME)) { string strDate = Reader.ReadElementContentAsString(); dtStartDate = (DateTime)Convert.ChangeType(strDate, typeof(DateTime), CultureInfo.InvariantCulture); BillingDates.Add(dtStartDate); } //Convert to a 1 based index for the name iMCSNumber = iMCSIndex + 1; BillingSchedule = new CCustomSchedule(); BillingSchedule.AddDates(BillingDates); BillingSchedule.Name = strMIFName + "_" + iMCSNumber.ToString(CultureInfo.InvariantCulture); BillingSchedule.Description = m_rmStrings.GetString("REVERSE_ENGINEERED_FROM") + Path.GetFileName(FileName); m_lstMultipleCustomSchedules.Add(BillingSchedule); } else { //Keep the place for an empty slot. We may have other schedules //configured after this. m_lstMultipleCustomSchedules.Add(null); } Reader.Close(); iMCSIndex++; objSubType = iMCSIndex; } //Remove null schedules from the end iMCSIndex--; while (iMCSIndex >= 0 && null == m_lstMultipleCustomSchedules[iMCSIndex]) { m_lstMultipleCustomSchedules.RemoveAt(iMCSIndex); iMCSIndex--; } }
/// <summary> /// Constructor /// </summary> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 06/14/07 RDB N/A Created public ProtocolFileCollection() : base() { m_strDirectory = CRegistryHelper.GetFilePath("Replica") + @"Protocol Files"; Refresh(); }//end ProtocolFileCollection
}//GetHolidays /// <summary> /// This method saves the current list to file. /// </summary> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 06/02/06 ach N/A N/A Added save ability for lists public void Save() { String sPathName = CRegistryHelper.GetDataDirectory(TOU_SCHEDULE) + "\\HolList.dat"; m_xmldomColl.Save(sPathName); }//Save