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"));
      }
    }
Esempio n. 2
0
    public void SetConnection(ConnectionData connData)
    {
      _conn = null;
      _connData = null;
      btnEditConnection.Text = "No Connection ▼";
      lblConnColor.BackColor = Color.Transparent;

      if (connData.Type != ConnectionType.Innovator)
      {
        MessageBox.Show("Only Innovator connections are supported");
        return;
      }

      _connData = connData;
      btnEditConnection.Text = "Connecting... ▼";
      _conn = connData.ArasLogin(true)
        .UiPromise(this)
        .Done(c =>
        {
          btnEditConnection.Text = connData.ConnectionName + " ▼";
          lblConnColor.BackColor = connData.Color;
        });
    }