Exemple #1
0
 /// <summary>
 /// Deserializes workflow markup into an FeatureProviderRegistry object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output FeatureProviderRegistry object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out FeatureProviderRegistry obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(FeatureProviderRegistry);
     try {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
Exemple #2
0
 /// <summary>
 /// Deserializes xml markup from file into an FeatureProviderRegistry object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output FeatureProviderRegistry object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out FeatureProviderRegistry obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(FeatureProviderRegistry);
     try {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex) {
         exception = ex;
         return(false);
     }
 }
Exemple #3
0
 public static bool LoadFromFile(string fileName, out FeatureProviderRegistry obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Exemple #4
0
 public static bool Deserialize(string xml, out FeatureProviderRegistry obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }
Exemple #5
0
        public override void Dispose()
        {
            lock (SyncRoot)
            {
                if (m_featureProviders != null)
                    m_featureProviders = null;

                if (m_cachedProviderCapabilities != null)
                    m_cachedProviderCapabilities = null;
            }
        }
Exemple #6
0
        /// <summary>
        /// Restarts the server session, and creates a new session ID
        /// </summary>
        /// <param name="throwException">If set to true, the call throws an exception if the call failed</param>
        /// <returns>True if the creation succeed, false otherwise</returns>
        protected override bool RestartSessionInternal(bool throwException)
        {
            if (m_username == null || m_password == null)
                if (throwException)
                    throw new Exception("Cannot recreate session, because connection was not opened with username and password");
                else
                    return false;

            Uri hosturl = new Uri(m_reqBuilder.HostURI);
            string locale = m_reqBuilder.Locale;
            string oldSessionId = m_reqBuilder.SessionID;

            try
            {
                RequestBuilder reqb = new RequestBuilder(hosturl, locale);
                WebClient wc = new WebClient();
                wc.Credentials = new NetworkCredential(m_username, m_password);
                string req = reqb.CreateSession();

                try
                {
                    reqb.SessionID = System.Text.Encoding.Default.GetString(wc.DownloadData(req));
                    if (reqb.SessionID.IndexOf("<") >= 0)
                        throw new Exception("Invalid server token recieved: " + reqb.SessionID);
                    else
                        CheckAndRaiseSessionChanged(oldSessionId, reqb.SessionID);
                }
                catch (Exception ex)
                {
                    reqb.SessionID = null;
                    bool ok = false;
                    try
                    {
                        //Retry, and append missing path, if applicable
                        if (!hosturl.ToString().EndsWith("/mapagent/mapagent.fcgi"))
                        {
                            string tmp = hosturl.ToString();
                            if (!tmp.EndsWith("/"))
                                tmp += "/";
                            hosturl = new Uri(tmp + "mapagent/mapagent.fcgi");
                            reqb = new RequestBuilder(hosturl, locale);
                            req = reqb.CreateSession();
                            reqb.SessionID = System.Text.Encoding.Default.GetString(wc.DownloadData(req));
                            if (reqb.SessionID.IndexOf("<") >= 0)
                                throw new Exception("Invalid server token recieved: " + reqb.SessionID);
                            ok = true;
                        }
                    }
                    catch {}

                    if (!ok)
                    {
                        if (throwException) //Report original error
                        {
                            if (ex is WebException) //These exceptions, we just want the underlying message. No need for 50 bajillion nested exceptions
                                throw;
                            else //We don't know what this could be so grab everything
                                throw new Exception("Failed to connect, perhaps session is expired?\nExtended error info: " + ex.Message, ex);
                        }
                        else
                            return false;
                    }
                    else
                    {
                        CheckAndRaiseSessionChanged(oldSessionId, reqb.SessionID);
                    }
                }

                //Reset cached items
                lock (SyncRoot)
                {
                    m_siteVersion = new Version(((SiteVersion)DeserializeObject(typeof(SiteVersion), wc.OpenRead(reqb.GetSiteVersion()))).Version);

                    m_featureProviders = null;
                    m_cachedProviderCapabilities = null;
                    m_reqBuilder = reqb;
                }

                return true;
            }
            catch
            {
                if (throwException)
                    throw;
                else
                    return false;
            }
        }
 public static bool LoadFromFile(string fileName, out FeatureProviderRegistry obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an FeatureProviderRegistry object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output FeatureProviderRegistry object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out FeatureProviderRegistry obj, out System.Exception exception) {
     exception = null;
     obj = default(FeatureProviderRegistry);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out FeatureProviderRegistry obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an FeatureProviderRegistry object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output FeatureProviderRegistry object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out FeatureProviderRegistry obj, out System.Exception exception) {
     exception = null;
     obj = default(FeatureProviderRegistry);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }