Exemplo n.º 1
0
 internal static void setStatusValue(statusFields fieldName, string newValue)
 {
     try
     {
         string    statusFileFullPath = string.Format("{0}{1}", clsSettings.serviceSettings.logsDirectory, _statusFileName);
         XDocument xDocument          = XDocument.Load(statusFileFullPath);
         xDocument.Element("serviceStatus").SetElementValue(fieldName.ToString(), newValue);
         xDocument.Save(statusFileFullPath);
     }
     catch (System.Exception Ex)
     {
         clsLogProcessing.WriteToEventLog(Ex.Message, EventLogEntryType.Error);
     }
 }
Exemplo n.º 2
0
        private static string getStatusValue(statusFields fieldName)
        {
            string statusFileFullPath = string.Format("{0}{1}", clsSettings.serviceSettings.logsDirectory, _statusFileName);

            if (!File.Exists(statusFileFullPath))
            {
                createStatusLogFile();
                //clsSettings.serviceSettings.currentOperation = ISACFMgr.operationList.waitingForNextExecution;
                //return ISACFMgr.operationList.waitingForNextExecution.ToString();
            }

            switch (fieldName)
            {
            case statusFields.currentOperationName:
                //ISACFMgr.operationList currrentOperation;
                try
                {
                    XDocument xDocument = XDocument.Load(statusFileFullPath);
                    string    qresult   = (from c in xDocument.Descendants(fieldName.ToString())
                                           select c.Value).Single();
                    return(string.IsNullOrEmpty(qresult) ? ISACFMgr.operationList.waitingForNextExecution.ToString() : qresult);
                }
                catch (System.Exception ex)
                {
                    clsLogProcessing.WriteToEventLog(string.Format("Error obteniendo el valor del elemento \"{0}\" del fichero {1}. ERROR: {2}",
                                                                   fieldName.ToString(), statusFileFullPath, ex.Message),
                                                     EventLogEntryType.Error);
                    // Record the error but keep the service operational.
                    return(ISACFMgr.operationList.waitingForNextExecution.ToString());
                }

            case statusFields.downloadedFileLastModifiedDate:
                //downloadedFileLastModifiedDate
                try
                {
                    //clsLogProcessing.WriteToEventLog(string.Format("I'am here... Before the query. fieldName.ToString(): {0}", fieldName.ToString()), EventLogEntryType.Warning);

                    XDocument xDocument = XDocument.Load(statusFileFullPath);
                    string    qresult   = (from c in xDocument.Descendants(fieldName.ToString())
                                           select c.Value).Single();
                    //Retirar esto.
                    //clsLogProcessing.WriteToEventLog(string.Format("qresult: {0}", qresult), EventLogEntryType.Warning);

                    return(qresult);
                }
                catch (System.Exception ex)
                {
                    clsLogProcessing.WriteToEventLog(string.Format("Error obteniendo el valor de \"{0}\" del fichero {1}. ERROR: {2}",
                                                                   fieldName.ToString(), statusFileFullPath, ex.Message),
                                                     EventLogEntryType.Error);
                    return(null);
                }

            case statusFields.downloadedFileETag:
            //ISACFMgr.operationList downloadedFileETag;

            /*
             * try
             * {
             *      XDocument xDocument = XDocument.Load(statusFileFullPath);
             *      string qresult = (from c in xDocument.Descendants(fieldName.ToString())
             *                                                                              select c.Value).Single();
             *      return string.IsNullOrEmpty(qresult) ? string.Empty : qresult;
             * }
             * catch (System.Exception ex)
             * {
             *      clsLogProcessing.WriteToEventLog(string.Format("Error obteniendo el valor del elemento \"{0}\" del fichero {1}. ERROR: {2}",
             *                                                                                                                                                                                                      fieldName.ToString(), statusFileFullPath, ex.Message),
             *                                                                                                                                                                                                      EventLogEntryType.Error);
             *      // Record the error but keep the service operational.
             *      return ISACFMgr.operationList.waitingForNextExecution.ToString();
             * }
             */
            case statusFields.downloadedFileName:
                //ISACFMgr.operationList downloadedFileName;
                try
                {
                    XDocument xDocument = XDocument.Load(statusFileFullPath);
                    string    qresult   = (from c in xDocument.Descendants(fieldName.ToString())
                                           select c.Value).Single();
                    return(string.IsNullOrEmpty(qresult) ? string.Empty : qresult);
                }
                catch (System.Exception ex)
                {
                    clsLogProcessing.WriteToEventLog(string.Format("Error obteniendo el valor del elemento \"{0}\" del fichero {1}. ERROR: {2}",
                                                                   fieldName.ToString(), statusFileFullPath, ex.Message),
                                                     EventLogEntryType.Error);
                    // Record the error but keep the service operational.
                    return(string.Empty);
                }

            default:
                return(null);
            }
        }