Beispiel #1
0
        /// <summary>
        /// This method reverse engineers the active custom schedule from the given
        /// MIF file.
        /// </summary>
        /// <returns>The reverse engineered custom schedule.</returns>
        //  Revision History
        //  MM/DD/YY Who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------------
        //  10/08/08 jrf 9.50           Created.
        //
        private void ReverseEngineerCustomSchedule()
        {
            object objValue         = null;
            short  sResponse        = DEVICE_SERVER_SUCCESS;
            short  sDisplayProgress = 0;

            DateTime[]     adtBillingDates;
            DateCollection colBillingDates = new DateCollection();

            if (false == m_bHasHHFBeenRead)
            {
                sResponse = (short)OpenHHF();
            }

            if (DEVICE_SERVER_SUCCESS == sResponse)
            {
                //Get the array of billing dates
                sResponse = VirtualDevice.GetValue(BILLING_SCHEDULE_ITEMS, ref objValue, sDisplayProgress);
            }

            if (DEVICE_SERVER_SUCCESS == sResponse && null != objValue)
            {
                adtBillingDates = (DateTime[])Convert.ChangeType(objValue, typeof(DateTime[]), CultureInfo.InvariantCulture);

                //Populate a date collection
                foreach (DateTime dtDate in adtBillingDates)
                {
                    colBillingDates.Add(dtDate);
                }

                //Add dates to the new schedule
                m_CustomSchedule = new CCustomSchedule();

                m_CustomSchedule.AddDates(colBillingDates);
            }
        }
Beispiel #2
0
        /// <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--;
            }
        }