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


C# Container.SaveChanges方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            //instruct client side library to insert token as Authorization value into each request
            container = new Container(new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/"));
            var token = GetToken();
            container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token);

            //check if our app package exists
            AppPackage package = null;
            try { package = container.AppPackages.ByKey(PackageName).GetValue(); } catch {}
            string res = null;
            if (package!=null)
                res = Prompts.PromptForKeyword(string.Format("AppPackage '{0}' already exists. What do you want to do? [Recreate/Update/Leave]<Update>", PackageName));
            if (res == "Recreate")
            {
                container.DeleteObject(package);
                container.SaveChanges();
                package = null;
            }       
            if (res!="Leave")
                package = CreateOrUpdatePackage(CreateZip(), package);

            //check if our activity already exist
            Activity activity = null;
            try { activity = container.Activities.ByKey(ActivityName).GetValue(); }
            catch { }
            if (activity != null)
            {
                if (Prompts.PromptForKeyword(string.Format("Activity '{0}' already exists. Do you want to recreate it? [Yes/No]<No>", ActivityName)) == "Yes")
                {
                    container.DeleteObject(activity);
                    container.SaveChanges();
                    activity  = null;
                }
            }
            if (activity == null)
                activity = CreateActivity(package);

            //save outstanding changes if any
            container.SaveChanges();

            //finally submit workitem against our activity
            SubmitWorkItem(activity);

            // demo new features in V2 -- version control
            DemoVersionControl();
        }
开发者ID:CADblokeCADforks,项目名称:autocad.io-custom-activity-apppackage-CSharp,代码行数:47,代码来源:Program.cs

示例2: Delete_Product_link_Family

 private static void Delete_Product_link_Family()
 {
     Container ctx = new Container();
     Console.WriteLine("\t<< delete product..family >>");
     var product = ctx.Products.AsEnumerable().First();
     ctx.LoadProperty(product, "Family");
     ctx.SetLink(product, "Family", null);
     ctx.SaveChanges();
 }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:9,代码来源:Program.cs

示例3: Main

        static void Main(string[] args)
        {
            //instruct client side library to insert token as Authorization value into each request
            var container = new Container(new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/"));
            var token = GetToken();
            container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", token);

            //create a workitem
            var wi = new WorkItem()
            {
                Id = "", //must be set to empty
                Arguments = new Arguments(),
                ActivityId = "PlotToPDF" //PlotToPDF is a predefined activity
            };

            wi.Arguments.InputArguments.Add(new Argument()
                {
                    Name = "HostDwg",// Must match the input parameter in activity
                    Resource = "http://download.autodesk.com/us/samplefiles/acad/blocks_and_tables_-_imperial.dwg",
                    StorageProvider = StorageProvider.Generic //Generic HTTP download (as opposed to A360)
                });
            wi.Arguments.OutputArguments.Add(new Argument()
            {
                Name = "Result", //must match the output parameter in activity
                StorageProvider = StorageProvider.Generic, //Generic HTTP upload (as opposed to A360)
                HttpVerb = HttpVerbType.POST, //use HTTP POST when delivering result
                Resource = null //use storage provided by AutoCAD.IO
            });

            container.AddToWorkItems(wi);
            Console.WriteLine("Submitting workitem...");
            container.SaveChanges();

            //polling loop
            do
            {
                Console.WriteLine("Sleeping for 2 sec...");
                System.Threading.Thread.Sleep(2000);
                container.LoadProperty(wi, "Status"); //http request is made here
                Console.WriteLine("WorkItem status: {0}", wi.Status);
            }
            while (wi.Status == ExecutionStatus.Pending || wi.Status == ExecutionStatus.InProgress);

            //re-query the service so that we can look at the details provided by the service
            container.MergeOption = Microsoft.OData.Client.MergeOption.OverwriteChanges;
            wi = container.WorkItems.ByKey(wi.Id).GetValue();
            
            //Resource property of the output argument "Result" will have the output url
            var url = wi.Arguments.OutputArguments.First(a => a.Name == "Result").Resource;
            DownloadToDocs(url, "AIO.pdf");
            
            //download the status report
            url = wi.StatusDetails.Report;
            DownloadToDocs(url, "AIO-report.txt");
        }
开发者ID:CADblokeCADforks,项目名称:autocad.io-simplest-CSharp,代码行数:55,代码来源:Program.cs

示例4: Delete_ProductFamily

        private static void Delete_ProductFamily()
        {
            Container ctx = new Container();
            Console.WriteLine("\t<< delete productfamily >>");
            //NOTE: WE ARE DOING A GET HERE
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).FirstOrDefault();

            if (family != null)
            {
                //DELETE HERE
                ctx.DeleteObject(family);
                ctx.SaveChanges();
            }
        }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:14,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            const string serviceUri = "http://localhost:33189/OData";
            var container = new Container(new Uri(serviceUri));

            container.Products.ToList().ForEach((p) => { Console.WriteLine("{0} {1} {2}", p.ID, p.Name, p.Price); });

            var pro = new Product { Name = "Client OData", Price = 1024, Category = "IT" };
            container.AddToProducts(pro);

            var response = container.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);

            foreach (var operationResponse in response)
            {
                Console.WriteLine("Response: {0}", operationResponse.StatusCode);
            }


            container.Products.ToList().ForEach((p) => { Console.WriteLine("{0} {1} {2}", p.ID, p.Name, p.Price); });
            Console.Read(); 
        }
开发者ID:HK-Zhang,项目名称:Grains,代码行数:21,代码来源:Program.cs

示例6: Delete_ProductFamily_link_Products

        private static void Delete_ProductFamily_link_Products()
        {
            Container ctx = new Container();
            Console.WriteLine("\n\t<< delete productfamily..products >>");
            var product = ctx.Products.OrderBy(p => p.ID).First(); // OrderBy need to avoid Take throw.
            var family = ctx.ProductFamilies.OrderBy(pf => pf.ID).First();

            Console.WriteLine("\tUnassociating \n\tProduct: Id={0}, Name={1} \n\tTo\n\tProudctFamily: Id={2}, Name={3}",
                product.ID, product.Name, family.ID, family.Name);

            ctx.DeleteLink(family, "Products", product);
            ctx.SaveChanges();
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:13,代码来源:Program.cs

示例7: Delete_ProductFamily

        private static void Delete_ProductFamily()
        {
            Container ctx = new Container();
            Console.WriteLine("\n\t<< delete productfamily >>");
            int key = 4;
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).FirstOrDefault();

            if (family != null)
            {
                Console.WriteLine("\tDeleting ProductFamily with Id={0}, Name={1}", family.ID, family.Name);

                ctx.DeleteObject(family);
                ctx.SaveChanges();
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:19,代码来源:Program.cs

示例8: Put_ProductFamily

        private static void Put_ProductFamily()
        {
            Container ctx = new Container();
            Console.WriteLine("\n\t<< put productfamily >>");
            int key = 4;
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).FirstOrDefault();
            if (family != null)
            {
                Console.WriteLine("\tUpdating ProductFamily with Id={0}, Name={1}", family.ID, family.Name);

                family.Description = "Updated Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:20,代码来源:Program.cs

示例9: Patch_ProductFamily

        private static void Patch_ProductFamily()
        {
            Container ctx = new Container();
            Console.WriteLine("\n\t<< patch productfamily >>");
            int key = 4;
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == key).AsEnumerable().SingleOrDefault();

            if (family != null)
            {
                Console.WriteLine("\tPatching ProductFamily with Id={0}, Name={1}", family.ID, family.Name);

                family.Description = "Patched Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            }
            else
            {
                Console.WriteLine("\tProductFamily with Id '{0}' not found.", key);
            }
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:21,代码来源:Program.cs

示例10: Patch_ProductFamily

        private static void Patch_ProductFamily()
        {
            Container ctx = new Container();
            Console.WriteLine("\t<< patch productfamily >>");
            ProductFamily family = ctx.ProductFamilies.Where(pf => pf.ID == 4).AsEnumerable().SingleOrDefault();
            if (family != null)
            {
                family.Description = "Patched Description";
                ctx.UpdateObject(family);

                ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            }
        }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:13,代码来源:Program.cs

示例11: CreateAppPackage

        static void CreateAppPackage(Container container,
                                     string packId)
        {
            Console.WriteLine("Creating/Updating AppPackage...");

            string zip = CreateZip(packId);

            // First step -- query for the url to upload the AppPackage file
            var url = container.AppPackages.GetUploadUrl().GetValue();

            // Second step -- upload AppPackage file
            UploadObject(url, zip);
            // third step -- after upload, create the AppPackage entity
            AppPackage package = new AppPackage()
            {
                Id = packId,
                RequiredEngineVersion = "20.1",
                Resource = url
            };
            container.AddToAppPackages(package);
            container.SaveChanges();
        }
开发者ID:xiaodongliang,项目名称:adnxddwgsigature,代码行数:22,代码来源:Program.cs

示例12: Put_Product_link_Family

 private static void Put_Product_link_Family()
 {
     Container ctx = new Container();
     Console.WriteLine("\t<< put product..family >>");
     var product = ctx.Products.AsEnumerable().First();
     var family = ctx.ProductFamilies.AsEnumerable().Skip(1).First();
     ctx.SetLink(product, "Family", family);
     ctx.SaveChanges();
 }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:9,代码来源:Program.cs

示例13: CreateActivityForUpdateTB

            static void CreateActivityForUpdateTB(Container container)
            {
                var act = new Activity()
                {
                    Id = actid_updatetb,
                    Version = 1,
                    Instruction = new Instruction()
                    {
                        Script = "_tilemode 1 updateTBFromJson ExtUrl.json "
                    },
                    Parameters = new Parameters()
                    {
                        InputParameters = { 
                             new Parameter() { Name = "HostDwg", LocalFileName = "$(HostDwg)"},
                             new Parameter() { Name = "ExtUrl", LocalFileName = ExternalJsonFile}
                          },
                        OutputParameters = { 
                             new Parameter() { Name = "Result", LocalFileName = resultDWGFile } 
                         }
                    },
                    RequiredEngineVersion = "20.1"
                };

                if (packId != "")
                {
                    act.AppPackages.Add(packId); // reference the custom AppPackage                  
                    Console.WriteLine("add {0} to activity", packId);

                }
                container.AddToActivities(act);
                container.SaveChanges();
            }
开发者ID:xiaodongliang,项目名称:adnxddwgsigature,代码行数:32,代码来源:Program.cs

示例14: Post_ProductFamily_link_Products

 private static void Post_ProductFamily_link_Products()
 {
     Container ctx = new Container();
     Console.WriteLine("\t<< post productfamily..products >>");
     var product = ctx.Products.OrderBy(p => p.ID).First(); // OrderBy need to avoid Take throw.
     var family = ctx.ProductFamilies.OrderBy(pf => pf.ID).First();
     ctx.AddLink(family, "Products", product);
     ctx.SaveChanges();
 }
开发者ID:seattlekiran,项目名称:OdataSample,代码行数:9,代码来源:Program.cs

示例15: VCardServiceDemo

        private static void VCardServiceDemo()
        {
            var ctx = new Container(serviceRoot);
            var person = new Person()
            {
                Card = new BusinessCard { ORG = "New Org", N = "LN2;FN1", FN = "LF2", Title = "New Title" }
            };

            ctx.AddToPeople(person);
            ctx.SaveChanges();
            Console.WriteLine("New person id is {0}", person.Id);

            string fileName = string.Format("person{0}_vcard.vcf", person.Id);
            Console.WriteLine("Download the csv file {0}.", fileName);
            DownloadFile(ctx.People.ByKey(person.Id).GetPath("Card"), fileName, "text/x-vCard");

            Console.WriteLine("Open the file");
            Process.Start(fileName);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:19,代码来源:Program.cs


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