public async Task Register(string url)
        {
            try
            {
                var sc            = new SwaggerClient();
                var apiDefinition = await sc.GetApiDefinition(url);

                _syncContext.Post(delegate(object state)
                {
                    Api = apiDefinition;
                    Url = url;
                    AfterLoaded(url, apiDefinition);
                }, null);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    var httpException = e.InnerException as WebException;
                    if (httpException != null && httpException.Status == WebExceptionStatus.ConnectFailure)
                    {
                        ApiLoadStatusStatic.Status = ApiLoadStatus.ConnectionFailure;
                        _syncContext.Post(delegate(object state)
                        {
                            AfterLoadedError(url);
                        }, null);
                        return;
                    }
                }
                RibbonController.InvalidateRibbon();
            }
        }
Exemple #2
0
        private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
        {
            this.controller = new RibbonController();
            SettingsFactory factory = new SettingsFactory();

            this.settings = factory.GetSettings();
        }
 private void AfterLoaded(string url, OpenApiDocument apiDefinition)
 {
     ExcelAsyncUtil.QueueAsMacro(() =>
     {
         RegisteredFunctions = FunctionRegistrar.RegisterApi(apiDefinition, false);
         ApiKeyCredentials   = Api.Components.SecuritySchemes.Values.Where(ss => ss.Type == SecuritySchemeType.ApiKey).ToDictionary(s => s.Name, s => new ApiKey {
             Key = s.Name, Value = "", In = s.In
         });
     });
     ApiLoadStatusStatic.Status = ApiLoadStatus.Loaded;
     RibbonController.InvalidateRibbon();
 }
Exemple #4
0
        private void SetMenu()
        {
            RibbonPage       generalPage = (RibbonPage)WorkItem.RootWorkItem.UIExtensionSites[ExtensionSiteNames.Ribbon].First();
            RibbonControl    ribbon      = generalPage.Ribbon;
            RibbonController control     = new RibbonController(ribbon, View.ReportPrintControl);

            WorkItem.Items.Add(control.PrintPreviewRibbonPage);
            string groupName = "GeneralPageGroup";

            InitStatus(groupName, generalPage.Groups[0]);
            InitDateRang(groupName, generalPage.Groups[0]);
            InitProject(groupName, generalPage.Groups[0]);
            InitManagerPerson(groupName, generalPage.Groups[0]);
            InitDate(groupName, generalPage.Groups[0]);
            InitSearchButton(groupName, generalPage.Groups[0]);
        }
Exemple #5
0
        private void SetMenu()
        {
            //RibbonPage generalPage = (RibbonPage)WorkItem.RootWorkItem.UIExtensionSites[ExtensionSiteNames.Ribbon].First();
            RibbonControl    ribbon  = this._ribbon;
            RibbonController control = new RibbonController(ribbon, _opportunityReportView.ReportPrintControl);

            ribbon.AutoSizeItems = true;
            string groupName = "GeneralPageGroup";

            InitStatus(groupName, ribbon.Pages[0].Groups[0]);
            InitTechnicianPerson(groupName, ribbon.Pages[0].Groups[0]);
            InitSalePerson(groupName, ribbon.Pages[0].Groups[0]);
            InitDateRang(groupName, ribbon.Pages[0].Groups[0]);
            InitDate(groupName, ribbon.Pages[0].Groups[0]);
            InitSearchButton(groupName, ribbon.Pages[0].Groups[0]);
        }
        public void OnLoggedIn(object source, UserLoggedInArgs e)
        {
            lblStatus.BackColor = System.Drawing.Color.Transparent;
            Status("Logged in successfully.", Color.Green);

            //register the handler for logged on event
            currentUser = null;
            currentUser = e.Person;


            ribbonController            = new RibbonController(this, frmUserRibbon);
            ribbonController.LoggedOut += this.OnLoggedOut;
            AddToContainer(ribbonController, TOP);
            this.pTop.Visible = true;

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   USER INFO
            SetUserInfo();
            ribbonController.AddStatusInfo(this.status);
            //===============================================
            this.menuStripMain.Enabled = true;
            OpenStartMenuView();
        }
Exemple #7
0
        private void BackgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string addMenuLabel = string.Empty;

            try
            {
                BackgroundWorker worker     = sender as BackgroundWorker;
                bool             isExported = false;
                ExitEditMode();
                RibbonMenu ribbonMenu = (RibbonMenu)dynamicMenuAdd;
                addMenuLabel = ribbonMenu.Label;
                IHttpRequest     httpRequest      = GlobalMembers.InstanceGlobalMembers.Container.Resolve <IHttpRequest>();
                RibbonController ribbonController = new RibbonController(httpRequest);
                Excel._Worksheet worksheet        = Globals.ThisAddIn.excelApplication.ActiveSheet;
                int    colCount = worksheet.UsedRange.Columns.Count;
                int    rowCount = worksheet.Cells.Find("*", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlPrevious, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value).Row;
                string moduleId = ExcelHelper.GetObjectIdFromText(dynamicMenuModules);
                Dictionary <string, string> dictLanguage = GlobalMembers.InstanceGlobalMembers.DictionaryLanguageType;
                switch (addMenuLabel)
                {
                case "Fields":
                {
                    ExcelHelper.ClearLogColumnsForAllTheRows(worksheet);
                    for (int i = 4; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            ribbonController.ValidateExcelData(i, colCount, worksheet);
                            ribbonController.BuildAndExportFieldsJson(i, colCount, worksheet, moduleId, userId);
                        }
                        worker.ReportProgress((i * 100) / rowCount);
                    }
                    break;
                }

                case "Descriptions":
                {
                    for (int i = 3; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            if (!isExported)
                            {
                                ribbonController.BuildTranlatedDataJsonAndExport(worksheet, dictLanguage);
                            }
                            isExported = true;
                            worker.ReportProgress((i * 100) / rowCount);
                        }
                    }
                    break;
                }

                case "Dropdowns":
                {
                    for (int i = 3; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            if (!isExported)
                            {
                                ribbonController.BuildDropDownJsonAndExport(worksheet, dictLanguage);
                            }
                            isExported = true;
                            worker.ReportProgress((i * 100) / rowCount);
                        }
                    }
                    break;
                }

                case "Fields And Dropdowns":
                {
                    Excel.Workbook   workbook          = GlobalMembers.InstanceGlobalMembers.ExcelApplication.ActiveWorkbook;
                    Excel.Sheets     sheets            = workbook.Sheets;
                    Excel._Worksheet dropDownWorkSheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.DropDownSheetName, sheets);;
                    for (int i = 4; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            ribbonController.ValidateExcelData(i, colCount, worksheet);
                            ribbonController.BuildAndExportFieldsJson(i, colCount, worksheet, moduleId, userId);
                            if (i == rowCount)
                            {
                                ribbonController.BuildDropDownJsonAndExport(dropDownWorkSheet, dictLanguage);
                            }
                        }
                        worker.ReportProgress((i * 100) / rowCount);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            { throw (ex); }
        }
 public override void OnCreateRibbon(RibbonController controller, Guid environmentCategory, bool firstTime)
 {
     controller.Add <MyRibbon>(environmentCategory, firstTime);
 }
 private void AfterLoadedError(string url)
 {
     ApiLoadStatusStatic.Status = ApiLoadStatus.ConnectionFailure;
     RibbonController.InvalidateRibbon();
 }