Exemplo n.º 1
0
        private static void CreateProject()
        {
            //AsymmetricEncryption.GenerateRegisterFile("yazhi.pang", "autox");
            var fileContent = File.ReadAllText("yazhi.pang.pem");
            var forSake     = XElement.Parse(fileContent);
            var projectName = forSake.GetAttributeValue("ProjectName");

            if (MongoDBManager.GetInstance().IsProjectExisted(projectName))
            {
                Console.WriteLine("Project already existed, continue?(y/n):");
                if (!Console.ReadKey().KeyChar.Equals('y'))
                {
                    return;
                }
            }
            MongoDBManager.GetInstance().SetProject(projectName);
            var root = forSake.Element("Root");
            var publicAndPrivateKey = root.GetAttributeValue("PublicAndPrivateKey");
            var secret    = root.GetAttributeValue("Secret");
            var decrypted = AsymmetricEncryption.DecryptText(secret, 2048, publicAndPrivateKey);
            var userName  = root.GetAttributeValue("UserName");

            foreach (XElement descendant in forSake.Descendants())
            {
                DBFactory.GetData().Save(descendant);
            }
        }