Ejemplo n.º 1
0
        public void Post(DomainActionBase action)
        {
            if (this.isEnabled == false)
            {
                return;
            }

            var message = string.Empty;

            this.current = action;
            action.ID    = this.id++;

            var s = XmlSerializerUtility.GetSerializer(action.GetType());

            var ns = new XmlSerializerNamespaces();

            ns.Add(string.Empty, string.Empty);
            ns.Add("fn", action.GetType().AssemblyQualifiedName);

            using (var sw = new Utf8StringWriter())
                using (var writer = XmlWriter.Create(sw, writerSettings))
                {
                    DataContractSerializerUtility.Write(writer, action);
                    writer.Close();
                    message = sw.ToString();
                }

            this.postedWriter.WriteLine(message);
        }
Ejemplo n.º 2
0
        public static void GenerateDefaultUserInfos(string repositoryPath)
        {
            var filename      = UserContext.GenerateUsersFilePath(repositoryPath);
            var designedInfo  = new SignatureDate(Authentication.SystemID, DateTime.UtcNow);
            var administrator = new UserSerializationInfo()
            {
                ID               = Authentication.AdminID,
                Name             = Authentication.AdminName,
                CategoryName     = string.Empty,
                Authority        = Authority.Admin,
                Password         = Authentication.AdminID.Encrypt(),
                CreationInfo     = designedInfo,
                ModificationInfo = designedInfo,
                BanInfo          = (BanSerializationInfo)BanInfo.Empty,
            };

#if DEBUG
            var users = new List <UserSerializationInfo>
            {
                administrator
            };
            for (var i = 0; i < 0; i++)
            {
                var admin = new UserSerializationInfo()
                {
                    ID               = "admin" + i,
                    Name             = "관리자" + i,
                    CategoryName     = "Administrators",
                    Authority        = Authority.Admin,
                    Password         = "******".Encrypt(),
                    CreationInfo     = designedInfo,
                    ModificationInfo = designedInfo,
                    BanInfo          = (BanSerializationInfo)BanInfo.Empty,
                };

                var member = new UserSerializationInfo()
                {
                    ID               = "member" + i,
                    Name             = "구성원" + i,
                    CategoryName     = "Members",
                    Authority        = Authority.Member,
                    Password         = "******".Encrypt(),
                    CreationInfo     = designedInfo,
                    ModificationInfo = designedInfo,
                    BanInfo          = (BanSerializationInfo)BanInfo.Empty,
                };

                var guest = new UserSerializationInfo()
                {
                    ID               = "guest" + i,
                    Name             = "손님" + i,
                    CategoryName     = "Guests",
                    Authority        = Authority.Guest,
                    Password         = "******".Encrypt(),
                    CreationInfo     = designedInfo,
                    ModificationInfo = designedInfo,
                    BanInfo          = (BanSerializationInfo)BanInfo.Empty,
                };

                users.Add(admin);
                users.Add(member);
                users.Add(guest);
            }

            var serializationInfo = new UserContextSerializationInfo()
            {
                Version    = CremaSchema.VersionValue,
                Categories = new string[] { "/Administrators/", "/Members/", "/Guests/" },
                Users      = users.ToArray(),
            };
#else
            var serializationInfo = new UserContextSerializationInfo()
            {
                Version    = CremaSchema.VersionValue,
                Categories = new string[] { },
                Users      = new UserSerializationInfo[] { administrator },
            };
#endif
            //foreach (var item in serializationInfo.Categories)
            //{
            //    var basePath = Path.Combine(Path.GetDirectoryName(filename), "users");
            //    var localPath = PathUtility.ConvertFromUri(basePath + item);
            //    DirectoryUtility.Prepare(localPath);
            //}

            //foreach (var item in serializationInfo.Users)
            //{
            //    var basePath = Path.Combine(Path.GetDirectoryName(filename), "users");
            //    var localPath = PathUtility.ConvertFromUri(basePath + item.CategoryPath + item.ID + ".xml");
            //    FileUtility.WriteAllText(DataContractSerializerUtility.GetString(item), localPath);
            //}

            DataContractSerializerUtility.Write(filename, serializationInfo, true);
        }