示例#1
0
        private void Connect(bool logicApps)
        {
            ApiConnection apiConnection = new ApiConnection(aPIConnections, logicApps);

            try
            {
                _client = apiConnection.GetClient();
                if (logicApps)
                {
                    logicAppConn = apiConnection.laConn;
                }
                else
                {
                    flowConn = apiConnection.flowConn;
                }
            }
            catch (AdalServiceException adalExec)
            {
                LogError("Adal Error", adalExec.GetBaseException());

                if (adalExec.ErrorCode == "authentication_canceled")
                {
                    return;
                }

                ShowError(adalExec, "Error in connecting, please check details");
            }
            catch (Exception e)
            {
                LogError("Error getting connection", e.Message);
                ShowError(e, "Error in connecting, please check entered details");
                return;
            }
        }
示例#2
0
        public HttpClient GetClient()
        {
            if (ShowDialog() == DialogResult.OK)
            {
                if (LogicApp)
                {
                    laConn = apiConns.LogicAppConns.FirstOrDefault(la => la.Id == (int)lblLAName.Tag);
                    if (laConn == null)
                    {
                        laConn = new LogicAppConn();
                    }

                    laConn.Id             = (int)lblLAName.Tag;
                    laConn.SubscriptionId = txtSubscriptionId.Text;
                    laConn.TenantId       = txtLATenant.Text;
                    laConn.ReturnURL      = txtLAReturnURL.Text;
                    laConn.AppId          = txtLAApp.Text;
                    laConn.UseDev         = chkLADev.Checked;
                    laConn.Name           = txtLAName.Text;
                    var laIndex = apiConns.LogicAppConns.IndexOf(laConn);
                    if (laIndex == -1)
                    {
                        apiConns.LogicAppConns.Add(laConn);
                    }
                    else
                    {
                        apiConns.LogicAppConns[laIndex] = laConn;
                    }
                }
                else
                {
                    flowConn = apiConns.FlowConns.FirstOrDefault(flw => flw.Id == (int)lblName.Tag);
                    if (flowConn == null)
                    {
                        flowConn = new FlowConn();
                    }

                    flowConn.Id          = (int)lblName.Tag;
                    flowConn.Environment = txtEnvironment.Text;
                    flowConn.TenantId    = txtTenant.Text;
                    flowConn.ReturnURL   = txtReturnURL.Text;
                    flowConn.AppId       = txtAppId.Text;
                    flowConn.UseDev      = chkUseDevApp.Checked;
                    flowConn.Name        = txtName.Text;
                    var flwIndex = apiConns.FlowConns.IndexOf(flowConn);
                    if (flwIndex == -1)
                    {
                        apiConns.FlowConns.Add(flowConn);
                    }
                    else
                    {
                        apiConns.FlowConns[flwIndex] = flowConn;
                    }
                }
                return(Connect());
            }

            return(null);
        }
示例#3
0
 public override bool Equals(object obj)
 {
     if ((obj == null) || !this.GetType().Equals(obj.GetType()))
     {
         return(false);
     }
     else
     {
         LogicAppConn p = (LogicAppConn)obj;
         return(Id == p.Id);
     }
 }
示例#4
0
        private void btnRemoveLA_Click(object sender, EventArgs e)
        {
            if (cboLAConns.SelectedItem == null)
            {
                return;
            }

            LogicAppConn removeLA = (LogicAppConn)cboLAConns.SelectedItem;

            if (MessageBox.Show("Remove the Logic App Connection '" + removeLA.Name + "' ?",
                                "Remove LA Connection", MessageBoxButtons.YesNo) !=
                DialogResult.Yes)
            {
                return;
            }
            cboLAConns.Items.Clear();

            apiConns.LogicAppConns.Remove(removeLA);
            if (apiConns.LogicAppConns.Any())
            {
                cboLAConns.Items.AddRange(apiConns.LogicAppConns.ToArray());
                cboLAConns.SelectedIndex = 0;
            }
            else
            {
                cboLAConns.ResetText();
                txtSubscriptionId.Text = subscriptionText;
                txtLATenant.Text       = tenantText;
                txtLAApp.Text          = appText;
                txtLAReturnURL.Text    = returnText;
                chkLADev.Checked       = false;
                txtLAName.Text         = labelText;
                cboLAConns.Enabled     = false;
                panelLogicApp.Controls.OfType <TextBox>().ToList().ForEach(txt => txt.Enabled = false);

                chkLADev.Enabled = false;
            }
        }