예제 #1
0
파일: AdminGlobal.cs 프로젝트: PavelPZ/REW
    public static void test(StringBuilder sb) {
      var db = driverLow.create();

      sb.AppendLine();
      sb.AppendLine("*************************************************************");
      sb.AppendLine("Admin/Admin.ts");

      db.testDeleteAll();
      var adm = new adminGlobalController();

      var logSrv = new azure.LoginController();
      var packedPsw = LowUtils.packStr("xstdg");

      sb.AppendLine("***** systemAdmin, add, not exist");
      var email = adm.createSystemAdmin("[email protected]", true);
      sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email)));
      email = logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd(email);
      sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email)));
      sb.AppendLine(db.sysRead<Sys_Admin>().strData);

      sb.AppendLine("***** systemAdmin, add, exist");
      email = logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd(email);
      sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email)));
      email = adm.createSystemAdmin("[email protected]", true);
      sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email)));
      sb.AppendLine(db.sysRead<Sys_Admin>().strData);

      sb.AppendLine("***** systemAdmin, remove, exist");
      email = adm.createSystemAdmin("[email protected]", false);
      sb.AppendLine(JsonConvert.SerializeObject(db.userRead<User_Data>(email)));
      sb.AppendLine(db.sysRead<Sys_Admin>().strData);

      sb.AppendLine();
      db.testDeleteAll();

      sb.AppendLine("***** mainCompanyAdmin, add");
      //new azureModel.Company("comp1").insert();
      //new azureModel.User("[email protected]").insert();
      //new azureModel.User("[email protected]").insert();
      adm.createNewCompany("comp1", "[email protected]", true);
      sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));

      sb.AppendLine("***** mainCompanyAdmin, remove");
      adm.createNewCompany("comp1", "[email protected]", false);
      sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));

      sb.AppendLine("***** mainCompanyAdmin, add, add");
      adm.createNewCompany("comp1", "[email protected]", true);
      adm.createNewCompany("comp1", "[email protected]", true);
      sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));

      sb.AppendLine("***** mainCompanyAdmin, add, remove");
      adm.createNewCompany("comp1", "[email protected]", true);
      adm.createNewCompany("comp1", "[email protected]", false);
      sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_User>("comp1").usersObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));
      sb.AppendLine("user" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));

      sb.AppendLine("***** mainCompanyAdmin, getMainCompanyAdmins");
      sb.AppendLine(JsonConvert.SerializeObject(adm.getCompaniesAndTheirAdmins()));
 
    }
예제 #2
0
    public static void test(StringBuilder sb) {
      var db = driverLow.create();

      sb.AppendLine();
      sb.AppendLine("*************************************************************");
      sb.AppendLine("Admin/products.ts");

      db.testDeleteAll();
      var adm = new adminLicenceController();
      var admGlob = new adminGlobalController();

      sb.AppendLine("***** add products");
      admGlob.createNewCompany("comp1", "p&p.p", true);
      adm.createNewProduct("comp1", "/a/b/c/", false, 10, true);
      adm.createNewProduct("comp1", "/a/b/c/", false, 15, true);
      adm.createNewProduct("comp1", "/a/b/c/d/", false, 10, true);
      sb.AppendLine(JsonConvert.SerializeObject(adm.getAllProductsLicInfo("comp1")));
      sb.AppendLine("company." + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1")));

      sb.AppendLine("***** delete products");
      adm.createNewProduct("comp1", "/a/b/c/", null, 10, false);
      adm.createNewProduct("comp1", "/a/b/c/", null, 15, false);
      sb.AppendLine(JsonConvert.SerializeObject(adm.getAllProductsLicInfo("comp1")));

      sb.AppendLine();
      sb.AppendLine("*************************************************************");
      sb.AppendLine("Admin/keyGen.ts, schools/my.ts");

      db.testDeleteAll();

      var logSrv = new azure.LoginController();
      var packedPsw = LowUtils.packStr("xstdg");

      admGlob.createNewCompany("comp1", "a&p.p", true); adm.createNewProduct("comp1", "/a/b/c/", false, 10, true);
      logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd("[email protected]");
      logSrv.CreateLmUserStart(new LMCookieJS { EMail = "[email protected]" }, packedPsw); logSrv.CreateLmUserEnd("[email protected]");

      var keys1 = adm.generateLicenceKeys("comp1", "/a/b/c/", 10, 5);
      sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj));
      sb.AppendLine("keys=" + JsonConvert.SerializeObject(keys1));

      var res = adm.enterLicenceKey("[email protected]", keys1[0].CompShortId, keys1[0].LicId, keys1[0].LicKeyId);
      sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj));
      sb.AppendLine("[email protected]=" + JsonConvert.SerializeObject(db.userRead<User_Company>("[email protected]").companiesObj));
      res = adm.enterLicenceKey("[email protected]", keys1[0].CompShortId, keys1[0].LicId, keys1[0].LicKeyId);
      sb.AppendLine("The same user: "******"[email protected]", keys1[1].CompShortId, keys1[1].LicId, keys1[1].LicKeyId);
      sb.AppendLine("comp1.licenceObj=" + JsonConvert.SerializeObject(db.compRead<Company_Licence>("comp1").licenceObj));
      res = adm.enterLicenceKey("[email protected]", keys1[1].CompShortId, keys1[1].LicId, keys1[1].LicKeyId);
      sb.AppendLine("Other user: " + res.ToString());

    }