Exemplo n.º 1
0
 /// <summary>  Constructor.
 ///
 /// </summary>
 /// <param name="zone">The zone
 ///
 /// </param>
 /// <param name="source">Identifies the source of pending SIF_Response packets to
 /// be processed: <c>RSPTYPE_GENERIC</c> to process files in the default
 /// 'responses' directory, or <c>RSPTYPE_SIFREPORTOBJECT</c> to process
 /// SIF_ReportObject files in the 'responses/reports' directory
 /// </param>
 public ResponseDelivery(IZone zone,
                         ResponseDeliveryType source)
 {
     fZone    = (ZoneImpl)zone;
     fParser  = SifParser.NewInstance();
     fSrc     = source;
     fWorkDir = GetSourceDirectory(source, fZone);
 }
Exemplo n.º 2
0
        /// <summary>   Determines if the specified source directory exists and contains one or more files.</summary>
        /// <param name="source">Identifies the type of pending SIF_Response packets. This flag may
        /// be any <c>SRC_</c> constant defined by this class.
        /// </param>
        /// <returns> <c>true</c> if the source directory exists and contains at least one file
        /// </returns>
        /// <param name="zone"></param>
        public static bool HasPendingPackets(ResponseDeliveryType source,
                                             IZone zone)
        {
            DirectoryInfo dir = new DirectoryInfo(GetSourceDirectory(source, zone));

            if (dir.Exists)
            {
                FileInfo [] contents = dir.GetFiles();
                return(contents.Length > 0);
            }
            return(false);
        }
Exemplo n.º 3
0
        /// <summary>   Determines the full path to the source directory.
        ///
        /// All SIF_Response source directories are located in the agent's work directory.
        /// Generic SIF_Responses are found in a directory named "{agent-home}/work/{zoneId}_{zoneHost}/responses/".
        /// SIF_Responses for SIF_ReportObject requests are found in a directory named
        /// "{agent-home}/work/{zoneId}_{zoneHost}/responses/reports".
        ///
        /// </summary>
        /// <param name="zone">The associated zone
        /// </param>
        /// <param name="source">Identifies the type of pending SIF_Response packets. This flag may
        /// be any <c>SRC_</c> constant defined by this class.
        /// </param>
        /// <returns> The fully-qualified path to the directory where pending response packets
        /// are located for the type of responses identified by <i>source</i>
        /// </returns>
        public static string GetSourceDirectory(ResponseDeliveryType source,
                                                IZone zone)
        {
            StringBuilder workDir = new StringBuilder();

            workDir.Append(zone.Agent.WorkDir);
            if (workDir[workDir.Length - 1] != Path.DirectorySeparatorChar)
            {
                workDir.Append(Path.DirectorySeparatorChar);
            }
            workDir.Append(AdkStringUtils.SafePathString(zone.ZoneId + "_" + zone.ZoneUrl.Host));
            workDir.Append(Path.DirectorySeparatorChar.ToString());
            workDir.Append("responses");
            if (source == ResponseDeliveryType.SIFReportObject)
            {
                workDir.Append(Path.DirectorySeparatorChar.ToString());
                workDir.Append("reports");
            }

            return(workDir.ToString());
        }