コード例 #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
        private void btnRemove_Click(object sender, EventArgs e)
        {
            if (cboFlowConns.SelectedItem == null)
            {
                return;
            }

            FlowConn removeFlow = (FlowConn)cboFlowConns.SelectedItem;

            if (MessageBox.Show("Remove the Power Automate Connection '" + removeFlow.Name + "' ?",
                                "Remove Flow Connection", MessageBoxButtons.YesNo) !=
                DialogResult.Yes)
            {
                return;
            }
            cboFlowConns.Items.Clear();

            apiConns.FlowConns.Remove(removeFlow);
            if (apiConns.FlowConns.Any())
            {
                cboFlowConns.Items.AddRange(apiConns.FlowConns.ToArray());
                cboFlowConns.SelectedIndex = 0;
            }
            else
            {
                cboFlowConns.ResetText();
                txtEnvironment.Text  = environmentText;
                txtTenant.Text       = tenantText;
                txtAppId.Text        = appText;
                txtReturnURL.Text    = returnText;
                chkUseDevApp.Checked = false;
                txtName.Text         = labelText;
                cboFlowConns.Enabled = false;
                panelFlow.Controls.OfType <TextBox>().ToList().ForEach(txt => txt.Enabled = false);
                chkUseDevApp.Enabled = false;
            }
        }