Esempio n. 1
0
    public static IPromise<IEditorProxy> FromConn(ConnectionData conn)
    {
      Func<ConnectionData, IPromise<IEditorProxy>> factory;
      if (_factories.TryGetValue(conn.Type, out factory))
      {
        return factory.Invoke(conn);
      }
      else
      {
        switch (conn.Type)
        {
          case ConnectionType.Innovator:
            return conn.ArasLogin(true)
              .Convert(c => (IEditorProxy)new Editor.ArasEditorProxy(c, conn.ConnectionName)
              {
                ConnData = conn
              });
          case ConnectionType.Soap:
            var service = new Innovator.Client.Connection.DefaultHttpService();
            return service.Execute("GET", conn.Url, null, null, true, null)
              .Convert(r =>
              {
                ServiceDescription descrip;
                using (var reader = new StreamReader(r.AsStream))
                using (var xml = XmlReader.Create(reader))
                {
                  descrip = ServiceDescription.Read(xml);
                }

                return (IEditorProxy)new Editor.SoapEditorProxy(conn, descrip
                  , Editor.XmlSchemas.SchemasFromDescrip(descrip));
              });
          case ConnectionType.SqlServer:
            return Promises.Resolved<IEditorProxy>(new Editor.SqlEditorProxy(conn));
          case ConnectionType.Sharepoint:
            return new Editor.SharepointEditorProxy(conn).Initialize().ToPromise();
        }
        return Promises.Rejected<IEditorProxy>(new NotSupportedException("Unsupported connection type"));
      }
    }
    public Innovator.Client.IPromise<IResultObject> Process(ICommand request, bool async)
    {
      var soapCmd = request as SoapCommand;
      if (soapCmd == null)
        throw new InvalidOperationException("The request must be of type 'SoapCommand'");

      var http = new Innovator.Client.Connection.DefaultHttpService();
      return http.Execute("POST", _baseUrl, null, _cred, true, r =>
      {
        r.SetHeader("SOAPAction", "\"" + _actionUrls[soapCmd.Action] + "\"");
        r.SetContent(w => w.Write(soapCmd.Query), "text/xml;charset=UTF-8");
      }).Convert(r => (IResultObject)new SoapResult(r.AsStream));
    }