Ejemplo n.º 1
0
        public void ProcessSerializeTest()
        {
            IWfProcessDescriptor processDesc = WfProcessTestCommon.CreateSimpleProcessDescriptor();

            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesc;
            IWfProcess process = WfRuntime.StartWorkflow(startupParams);

            ((WfProcess)process).ResourceID = UuidHelper.NewUuidString();

            WfProcessContext context = process.Context;

            context.Add("UCC", "the same");

            XElementFormatter formatter = new XElementFormatter();

            //formatter.OutputShortType = false;

            XElement root = formatter.Serialize(process);

            Console.WriteLine(root.ToString());

            IWfProcess clonedProcess = (IWfProcess)formatter.Deserialize(root);

            Assert.IsNotNull(clonedProcess.Context["UCC"]);
            Assert.AreEqual(process.Context.Count, clonedProcess.Context.Count);
            Assert.AreEqual(process.Context["UCC"], clonedProcess.Context["UCC"]);
        }
Ejemplo n.º 2
0
        public void AddSecretaryToUserExecutorTest()
        {
            SCUser secretary = SCObjectGenerator.PrepareUserObject("罗", "剑", "罗剑" + UuidHelper.NewUuidString());

            SCObjectOperations.Instance.AddUser(secretary, SCOrganization.GetRoot());

            SCUser user1 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user1, SCOrganization.GetRoot());

            SCSecretaryRelation sr = SCObjectOperations.Instance.AddSecretaryToUser(secretary, user1);

            Assert.AreEqual(secretary.SchemaType, sr.ContainerSchemaType);
            Assert.AreEqual(user1.SchemaType, sr.MemberSchemaType);

            SCUser user2 = SCObjectGenerator.PrepareUserObject();

            SCObjectOperations.Instance.AddUser(user2, SCOrganization.GetRoot());

            SCObjectOperations.Instance.AddSecretaryToUser(secretary, user2);

            Assert.IsTrue(user1.CurrentSecretaries.ContainsKey(secretary.ID));
            Assert.IsTrue(user2.CurrentSecretaries.ContainsKey(secretary.ID));

            Assert.IsTrue(secretary.CurrentSecretariesOf.ContainsKey(user1.ID));
            Assert.IsTrue(secretary.CurrentSecretariesOf.ContainsKey(user2.ID));
        }
Ejemplo n.º 3
0
        private void CreateNewObjectBySchemaType(string schemaType)
        {
            this.Data = SchemaExtensions.CreateObject(schemaType);

            this.currentSchemaType.Value = schemaType;
            this.Data.ID = UuidHelper.NewUuidString();
        }
Ejemplo n.º 4
0
        private void Upload(MaterialContent data)
        {
            data.ContentID = UuidHelper.NewUuidString();
            string sql = ORMapping.GetInsertSql(data, TSqlBuilder.Instance);

            DbHelper.RunSql(db => db.ExecuteNonQuery(CommandType.Text, sql), "UAT");
        }
Ejemplo n.º 5
0
        public void SaveAndLoadTenantProcessTest()
        {
            IWfProcessDescriptor processDesp = CreateTestProcessDescriptor();

            string tenantCode = UuidHelper.NewUuidString();

            PrepareTenantContext(tenantCode);

            WfProcessDescriptorManager.SaveDescriptor(processDesp);

            //加载同一个租户的流程定义,如果不存在,会抛出异常
            IWfProcessDescriptor loadedSameTenant = WfProcessDescriptorManager.LoadDescriptor(processDesp.Key);

            Assert.AreEqual(processDesp.Key, loadedSameTenant.Key);

            PrepareTenantContext(UuidHelper.NewUuidString());

            try
            {
                loadedSameTenant = WfProcessDescriptorManager.LoadDescriptor(processDesp.Key);

                throw new ApplicationException("不应该加载到别的租户的流程");
            }
            catch (SystemSupportException)
            {
            }
        }
Ejemplo n.º 6
0
        public User Register(string email, string firstName, string lastName, string password)
        {
            using (var context = GetContext())
            {
                if (context.Users.Any(u => u.Email == email))
                {
                    return(null);
                }

                var saltPassword = PasswordHelper.GenerateRandomPassword(PasswordConstants.UniqueKeyLength, false, false);
                var shaPassword  = HashHelper.Hash(saltPassword + password);

                var newUser = new Data.UserEntity
                {
                    FirstName    = firstName,
                    LastName     = lastName,
                    Password     = shaPassword,
                    PasswordSalt = saltPassword,
                    Created      = DateTime.Now,
                    Status       = UserStatus.Active.Status,
                    UserKey      = UuidHelper.GenerateUniqueKey(PasswordConstants.UniqueKeyLength),
                    Email        = email,
                };

                var userEntity = context.Users.Add(newUser).Entity;
                context.SaveChanges();

                return(_mapper.Map <User>(userEntity));
            }
        }