Beispiel #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)));
                }
                return(Promises.Rejected <IEditorProxy>(new NotSupportedException("Unsupported connection type")));
            }
        }
Beispiel #2
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)));

                case ConnectionType.Soap:
                    var http = new HttpClient();
                    return(http.GetStreamAsync(conn.Url).ToPromise()
                           .Convert(r =>
                    {
                        ServiceDescription descrip;
                        using (var reader = new StreamReader(r))
                            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")));
            }
        }
Beispiel #3
0
        public void SetConnection(ConnectionData connData)
        {
            _conn     = null;
            _connData = null;
            btnEditConnection.Text = "No Connection ▼";
            lblConnColor.BackColor = Color.Transparent;

            if (connData.Type != ConnectionType.Innovator)
            {
                Dialog.MessageDialog.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;
            });
        }