Ejemplo n.º 1
0
        /// <summary>
        /// Maps the response.
        /// </summary>
        /// <param name="registryResponse"></param>
        /// <returns></returns>
        public static DocumentUploadResult Map(RegistryResponseType registryResponse)
        {
            string message   = null;
            string errorCode = null;
            DocumentUploadResultStatus documentUploadResultStatus = DocumentUploadResultStatus.Failed;

            if (registryResponse.status == ResponseStatusFailure)
            {
                documentUploadResultStatus = DocumentUploadResultStatus.Failed;
                RegistryError registryError = registryResponse.RegistryErrorList?.RegistryError?.SingleOrDefault();
                if (registryError != null)
                {
                    message   = registryError.codeContext;
                    errorCode = registryError.errorCode;
                }
            }
            else if (registryResponse.status == ResponseStatusSuccess)
            {
                documentUploadResultStatus = DocumentUploadResultStatus.Success;
            }

            return(new DocumentUploadResult
            {
                Status = documentUploadResultStatus,
                ErrorCode = errorCode,
                AdditionalInfo = message
            });
        }
Ejemplo n.º 2
0
 private void AssertError(RegistryError error,
                          string errorCode, string codeContext, string location, ErrorSeverity severity)
 {
     Assert.AreEqual(errorCode ?? "", error.ErrorCode ?? "");
     Assert.AreEqual(codeContext ?? "", error.CodeContext ?? "");
     Assert.AreEqual(location ?? "", error.Location ?? "");
     Assert.AreEqual(severity, error.Severity);
 }
Ejemplo n.º 3
0
        public static RegistryError Delete(RegistryKey regKey, string location, string value)
        {
            RegistryError rerr = RegistryError.None;

            try
            {
                regKey = regKey.OpenSubKey(location, true);
                regKey.DeleteValue(value, false);
            }
            catch (Exception e)
            {
                rerr = RegistryError.Error;
                Tracer.Error(e);
            }
            finally
            {
                regKey.Close();
            }

            return(rerr);
        }
Ejemplo n.º 4
0
        public static RegistryError Set(RegistryKey regKey, string location, string key, string value, RegistryValueKind kind)
        {
            RegistryError rerr = RegistryError.None;

            try
            {
                regKey = regKey.OpenSubKey(location, true);
                regKey.SetValue(key, value, kind);
            }
            catch (Exception e)
            {
                rerr = RegistryError.Error;
                Tracer.Error(e);
            }
            finally
            {
                regKey.Close();
            }

            return(rerr);
        }
Ejemplo n.º 5
0
        public static RegistryError Get(RegistryKey regKey, string location, ref string value)
        {
            RegistryError rerr = RegistryError.None;

            try
            {
                regKey = regKey.OpenSubKey(location);
                value  = regKey.GetValue(value).ToString();
            }
            catch (Exception e)
            {
                rerr = RegistryError.Error;
                Tracer.Error(e);
            }
            finally
            {
                if (regKey != null)
                {
                    regKey.Close();
                }
            }

            return(rerr);
        }
Ejemplo n.º 6
0
        private ProvideAndRegisterResponse interrogateWCFResponse(Message wcfOutput)
        {
            //
            //Logger.Debug("begin interrogateWCFResponse");
            ProvideAndRegisterResponse pandRResponse = new ProvideAndRegisterResponse();

            try
            {
                XmlDictionaryReader dictReader = wcfOutput.GetReaderAtBodyContents();
                XmlDocument         resultsDOM = new XmlDocument();
                resultsDOM.Load(dictReader);

                // handle the response status
                pandRResponse.Status = resultsDOM.DocumentElement.Attributes.GetNamedItem("status").InnerXml;

                // add any registry errors
                XmlNode registryErrorList = resultsDOM.DocumentElement.SelectSingleNode("//*[local-name()='RegistryErrorList']");
                if (registryErrorList == null)
                {
                    pandRResponse.RegistryErrorList = null;
                }
                else  // process all of the registry errors
                {
                    XmlNodeList registryErrors = registryErrorList.SelectNodes("//*[local-name()='RegistryError']");
                    pandRResponse.RegistryErrorList = new RegistryErrorList();
                    pandRResponse.RegistryErrorList.RegistryErrors = new List <RegistryError>();
                    RegistryError theRegistryError = null;
                    XmlNode       temp;

                    temp = registryErrorList.Attributes.GetNamedItem("highestSeverity");
                    if (temp != null)
                    {
                        pandRResponse.RegistryErrorList.HighestSeverity = temp.InnerXml;
                    }
                    else  // shouldn't happen....highest should be present
                    {
                        pandRResponse.RegistryErrorList.HighestSeverity = "";
                    } // fi highestSeverity attribute exists

                    foreach (XmlNode aRegError in registryErrors)
                    {
                        theRegistryError = new RegistryError();
                        temp             = aRegError.Attributes.GetNamedItem("errorCode");
                        if (temp != null)
                        {
                            theRegistryError.ErrorCode = temp.InnerXml;
                        }
                        else  // should not happen....error code should be present
                        {
                            theRegistryError.ErrorCode = "";
                        } // fi

                        temp = aRegError.Attributes.GetNamedItem("codeContext");
                        if (temp != null)
                        {
                            theRegistryError.CodeContext = temp.InnerXml;
                        }
                        else
                        {
                            theRegistryError.CodeContext = "";
                        } // fi

                        temp = aRegError.Attributes.GetNamedItem("location");
                        if (temp != null)
                        {
                            theRegistryError.Location = temp.InnerXml;
                        }
                        else
                        {
                            theRegistryError.Location = "";
                        } // fi

                        temp = aRegError.Attributes.GetNamedItem("severity");
                        if (temp != null)
                        {
                            theRegistryError.Severity = temp.InnerXml;
                        }
                        else
                        {
                            theRegistryError.Severity = "";
                        } // fi

                        // highest severity
                        if (string.IsNullOrEmpty(pandRResponse.RegistryErrorList.HighestSeverity))
                        {
                            pandRResponse.RegistryErrorList.HighestSeverity = theRegistryError.Severity;
                        }
                        else
                        {
                            //
                            if (pandRResponse.RegistryErrorList.HighestSeverity != GlobalValues.CONST_SEVERITY_TYPE_ERROR)
                            {
                                pandRResponse.RegistryErrorList.HighestSeverity = theRegistryError.Severity;
                            }
                        }

                        // add to the registry error list
                        pandRResponse.RegistryErrorList.RegistryErrors.Add(theRegistryError);
                    }
                }  // fi some registry errors
            }
            catch (Exception ex)
            {
                //Logger.Error(string.Format("interrogateWCFResponse catches error: {0}; stack: {1}", ex.Message, ex.StackTrace));
                pandRResponse = errorResponse(GlobalValues.CONST_ERROR_CODE_XDSRepositoryError, string.Format("error: {0}; stacktrace{1}", ex.Message, ex.StackTrace));
                //throw;
            }
            //Logger.Debug("end interrogateWCFResponse");
            return(pandRResponse);
        }