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


C# Location.Save方法代码示例

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


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

示例1: Generate

        internal void Generate(MetaPopulation metaPopulation, DirectoryInfo outputDirectory, string group, Log log)
        {
            var validation = metaPopulation.Validate();
            if (validation.ContainsErrors)
            {
                log.Error(this, "Meta population " + metaPopulation + " has validation errors.");
                return;
            }

            try
            {
                TemplateGroup templateGroup = new TemplateGroupFile(this.fileInfo.FullName, '$', '$');

                templateGroup.ErrorManager = new ErrorManager(new LogAdapter(log));

                var configurationTemplate = templateGroup.GetInstanceOf(TemplateConfiguration);
                configurationTemplate.Add(MetaKey, metaPopulation);
                configurationTemplate.Add(GroupKey, group);

                var configurationXml = new XmlDocument();
                configurationXml.LoadXml(configurationTemplate.Render());

                var location = new Location(outputDirectory);
                foreach (XmlElement generation in configurationXml.DocumentElement.SelectNodes(GenerationKey))
                {
                    var templateName = generation.GetAttribute(TemplateKey);
                    var template = templateGroup.GetInstanceOf(templateName);
                    var output = generation.GetAttribute(OutputKey);

                    template.Add(MetaKey, metaPopulation);
                    template.Add(GroupKey, group);

                    if (generation.HasAttribute(InputKey))
                    {
                        var input = new Guid(generation.GetAttribute(InputKey));
                        var objectType = metaPopulation.Find(input) as IObjectType;
                        if (objectType != null)
                        {
                            template.Add(ObjectTypeKey, objectType);
                        }
                        else
                        {
                            var relationType = metaPopulation.Find(input) as RelationType;
                            if (relationType != null)
                            {
                                template.Add(RelationTypeKey, relationType);
                            }
                            else
                            {
                                var inheritance = metaPopulation.Find(input) as Inheritance;
                                if (inheritance != null)
                                {
                                    template.Add(InheritanceKey, inheritance);
                                }
                                else
                                {
                                    var methodType = metaPopulation.Find(input) as MethodType;
                                    if (methodType != null)
                                    {
                                        template.Add(MethodTypeKey, methodType);
                                    }
                                    else
                                    {
                                        throw new ArgumentException(input + " was not found");
                                    }
                                }
                            }
                        }
                        //TODO: Super Domains
                    }

                    var result = template.Render();
                    location.Save(output, result);
                }
            }
            catch (Exception e)
            {
                log.Error(this, "Generation error : " + e.Message + "\n" + e.StackTrace);
            }
        }
开发者ID:whesius,项目名称:allors,代码行数:80,代码来源:StringTemplate.cs

示例2: BuildRMLocations

        static void BuildRMLocations(List<Position> full)
        {
            TrimApplication.Initialize();

            try
            {
                using (Database db = new Database())
                {
                    //5503
                    Location locUseProfileof = new Location(db, 19509);
                    Location LocHighLevel = new Location(db, 5503);
                    db.Id = "03";
                    db.Connect();
                    FieldDefinition fd = new FieldDefinition(db, 501);
                    //
                    //Classification cla = new Classification(db);
                    
                    foreach (Position p in full)
                    {
                        //if (p.RMUri == 0)
                        //{
                            Location posloc = new Location(db, LocationType.Position);
                            //{
                            posloc.Surname = p.Title + " - " + p.Position_Number.ToString();
                            posloc.SetNotes("Entered by auto process: Source ID: " + p.Position_Number.ToString(), NotesUpdateType.AppendWithNewLine);
                            posloc.AddRelationship(LocHighLevel, LocRelationshipType.MemberOf, false);
                            //bu3loc.SetFieldValue(fd, new UserFieldValue("Business Unit 3"));
                            posloc.IsWithin = true;
                            //posloc.UseProfileOf = locUseProfileof;
                            posloc.Save();
                            p.RMUri = posloc.Uri;
                            Console.WriteLine("Created " + p.Title + " - " + p.Position_Number.ToString());
                            //
                            foreach (User u in p.user.Where(x => x.RMUri == 0))
                            {
                                //if (u.RMUri == 0)
                                //{
                                    try
                                    {
                                        Location userloc = new Location(db, LocationType.Person);
                                        //{
                                        userloc.Surname = u.Surname;
                                        userloc.GivenNames = u.FirstName;
                                        userloc.EmailAddress = u.Email;
                                        userloc.CanLogin = true;
                                        userloc.LogsInAs = u.FirstName[0].ToString() + u.Surname[0].ToString() + u.Employee_Number.ToString();
                                        userloc.AdditionalLogin = u.Email;
                                        string dlogon = lstDomain.Where(x=>x.email==u.Email).First().DomainLogon;
                                        if(dlogon.Length>1)
                                        {
                                        userloc.LogsInAs = "MSC\\"+dlogon;
                                        }
                                        else
                                        {
                                            userloc.LogsInAs = "MSC\\";
                                        }
                                        //userloc.UserType = UserTypes.Contributor;

                                        userloc.SetNotes("Entered by auto process: Source ID: " + u.Employee_Number, NotesUpdateType.AppendWithNewLine);
                                        userloc.AddRelationship(posloc, LocRelationshipType.MemberOf, false);
                                        //bu3loc.SetFieldValue(fd, new UserFieldValue("Business Unit 3"));
                                        userloc.IsWithin = true;
                                        userloc.UseProfileOf = locUseProfileof;
                                        userloc.Save();
                                        u.RMUri = userloc.Uri;
                                        BuildRMpersonalFolders(userloc);
                                        Console.WriteLine("Created " + u.Surname);
                                        //}
                                    }
                                    catch (Exception exp)
                                    {
                                        Console.WriteLine("Error creating person location: " + exp.Message.ToString());
                                    }
                                //}
                                //else
                                //{
                                //    Location userloc = new Location(db, u.RMUri);
                                //    userloc.AddRelationship(posloc, LocRelationshipType.MemberOf, false);
                                //    userloc.Save();
                                //}
                            }
                        //}
                        //else
                        //{
                        //    Location posloc = new Location(db, p.RMUri);
                        //    //posloc.AddRelationship(bu2loc, LocRelationshipType.MemberOf, false);
                        //    posloc.Save();
                        //}
                    }




                    //
                    //Build SCC org
                    //Location lOrg = new Location(db, LocationType.Organization);
                    //lOrg.Surname = "Sunshine Coast Council";
                    //lOrg.IsWithin = true;
                    //lOrg.SetFieldValue(fd, new UserFieldValue("Organisation"));
                    //lOrg.UseProfileOf = locUseProfileof;
//.........这里部分代码省略.........
开发者ID:WyldLynxGitHub,项目名称:SunshineCoastCouncil-master,代码行数:101,代码来源:Program.cs


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