当前位置: 首页>>代码示例>>C#>>正文


C# API.getChecklists方法代码示例

本文整理汇总了C#中API.getChecklists方法的典型用法代码示例。如果您正苦于以下问题:C# API.getChecklists方法的具体用法?C# API.getChecklists怎么用?C# API.getChecklists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API.getChecklists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            string username = "[email protected]";
            string password = "supersecretpassword";
            string server = "https://api.velasystems.com";

            switch (args.Length)
            {
                case 0:
                case 1:
                    Console.WriteLine("You must specify a username, password and optionally the server to connect to");
                    Console.WriteLine(string.Format("APIExample.exe {0} {1} {2}", username, password, server));
                    Environment.Exit(1);
                    break;
                case 2:
                    username = args[0];
                    password = args[1];
                    break;
                case 3:
                    username = args[0];
                    password = args[1];
                    server = args[2];
                    break;
            }

            Console.WriteLine(string.Format("Connecting to BIM 360 Field API service on {0} as {1}", server, username));

            try
            {
                API api = new API(server);

                api.authenticate(username, password);

                Console.WriteLine("Authenticated successfully. Retrieving project list.\n\n");

                List<Project> projects = api.getProjects();

                Console.WriteLine("Project ID\t\t\t\tProject Name");
                Console.WriteLine("----------\t\t\t\t------------");
                foreach (Project project in projects)
                {
                    Console.WriteLine(string.Format("{0}\t{1}", project.project_id, project.name));
                }

                Console.WriteLine("Retrieving list of Checklists for first project\n\n");

                // Set the default project on the API service object and you won't have to pass it each time you make a call.
                // Just DON'T forget to change it if you need to interact with other projects!
                api.DefaultProject = projects[0];

                List<Checklist> checklists = api.getChecklists(null, null, 0, 10000); // Defaults to 25
                Console.WriteLine(string.Format("The project {0} has {1} checklist(s)", api.DefaultProject.name, checklists.Count));

                if (checklists.Count > 0)
                {
                    Console.WriteLine("Checklist ID\t\t\t\tName");
                    Console.WriteLine("------------\t\t\t\t----");

                    foreach (Checklist checklist in checklists)
                    {
                        Console.WriteLine(string.Format("{0}\t{1}", checklist.id, checklist.name));
                    }

                    Console.WriteLine("\n\n");

                    Checklist firstChecklist = api.getChecklist(checklists[0].id);
                    Console.WriteLine(string.Format("The checklist with ID {0} has {1} sections. Please inspect this object to see what else is available!", firstChecklist.id, firstChecklist.sections.Count));
                }
            }
            catch (BIM360FieldAPIException ex)
            {
                Console.WriteLine(string.Format("API service threw an exception: {0} {1}", ex.Code, ex.Message));
            }
            catch (UnauthorizedAccessException ua)
            {
                Console.WriteLine("Failed to authenticate with the supplied credentials.");
            }
        }
开发者ID:BIM360API,项目名称:FieldAPIExample,代码行数:78,代码来源:APIExample.cs


注:本文中的API.getChecklists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。