Exemplo n.º 1
0
        public void UpdateUserDelegationTest()
        {
            //新增或修改
            string             userID     = UuidHelper.NewUuidString();
            string             duserID    = UuidHelper.NewUuidString();
            WfClientDelegation delegation = DelegationHelper.PrepareDelegation();

            delegation.SourceUserID = userID;
            WfClientProcessDescriptorServiceProxy.Instance.UpdateUserDelegation(delegation);//新增加
            int count = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(delegation.SourceUserID).Count;

            Assert.AreEqual(1, count);

            delegation.DestinationUserID = duserID;                                          //修改被委托人信息
            WfClientProcessDescriptorServiceProxy.Instance.UpdateUserDelegation(delegation); //新增加
            count = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(delegation.SourceUserID).Count;
            Assert.AreEqual(2, count);

            delegation.StartTime = System.DateTime.Now.Date;
            WfClientProcessDescriptorServiceProxy.Instance.UpdateUserDelegation(delegation);//更新
            count = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(delegation.SourceUserID).Count;
            Assert.AreEqual(2, count);

            WfClientDelegationCollection list        = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(delegation.SourceUserID);
            WfClientDelegation           delegation2 = list.Find(w => w.DestinationUserID == duserID);

            //传递过程,客户端扩展的属性会丢失
            delegation.ApplicationName = string.Empty;
            delegation.TenantCode      = string.Empty;
            delegation.ProgramName     = string.Empty;

            delegation.AreSame(delegation2);
        }
        public void DeleteUserDelegation(WfClientDelegation delegation)
        {
            OperationContext.Current.FillContextToOguServiceContext();
            WfDelegation server = null;

            WfClientDelegationConverter.Instance.ClientToServer(delegation, ref server);

            WfDelegationAdapter.Instance.Delete(server);
        }
Exemplo n.º 3
0
        public void ServerToClientTest()
        {
            WfDelegation server = PrepareServerDelegation();

            WfClientDelegation client = null;

            WfClientDelegationConverter.Instance.ServerToClient(server, ref client);

            client.AreSame(server);
        }
Exemplo n.º 4
0
        public void ClientToServerTest()
        {
            WfClientDelegation client = PrepareClientDelegation();

            WfDelegation server = null;

            WfClientDelegationConverter.Instance.ClientToServer(client, ref server);

            client.AreSame(server);
        }
Exemplo n.º 5
0
        public static void AreSame(this WfClientDelegation expected, WfDelegation actual)
        {
            Assert.AreEqual(expected.SourceUserID, actual.SourceUserID);
            Assert.AreEqual(expected.SourceUserName, actual.SourceUserName);
            Assert.AreEqual(expected.DestinationUserID, actual.DestinationUserID);
            Assert.AreEqual(expected.DestinationUserName, actual.DestinationUserName);
            Assert.AreEqual(expected.StartTime, actual.StartTime);
            Assert.AreEqual(expected.EndTime, actual.EndTime);
            Assert.AreEqual(expected.Enabled, actual.Enabled);

            Assert.AreEqual(expected.ApplicationName, expected.ApplicationName);
            Assert.AreEqual(expected.ProgramName, expected.ProgramName);
            Assert.AreEqual(expected.TenantCode, expected.TenantCode);
        }
Exemplo n.º 6
0
        public void SimpleDelegationSerializationTest()
        {
            WfClientJsonConverterHelper.Instance.RegisterConverters();

            WfClientDelegation client = PrepareClientDelegation();

            string data = JSONSerializerExecute.Serialize(client);

            Console.WriteLine(data);

            WfClientDelegation deserializedDelegation = JSONSerializerExecute.Deserialize <WfClientDelegation>(data);

            client.AreSame(deserializedDelegation);
        }
        public List <WfClientDelegation> ServerToClient(WfDelegationCollection server)
        {
            List <WfClientDelegation> client = new List <WfClientDelegation>();

            foreach (WfDelegation opinion in server)
            {
                WfClientDelegation clientOpinion = null;

                ServerToClient(opinion, ref clientOpinion);

                client.Add(clientOpinion);
            }

            return(client);
        }
        public WfDelegation ClientToServer(WfClientDelegation client, ref WfDelegation server)
        {
            client.NullCheck("client");

            if (server == null)
                server = new WfDelegation();

            server.SourceUserID = client.SourceUserID;
            server.DestinationUserID = client.DestinationUserID;
            server.DestinationUserName = client.DestinationUserName;
            server.SourceUserName = client.SourceUserName;
            server.StartTime = client.StartTime;
            server.EndTime = client.EndTime;
            server.Enabled = client.Enabled;

            return server;
        }
        public WfClientDelegation ServerToClient(WfDelegation server, ref WfClientDelegation client)
        {
            server.NullCheck("server");

            if (client == null)
                client = new WfClientDelegation();

            client.SourceUserID = server.SourceUserID;
            client.DestinationUserID = server.DestinationUserID;
            client.DestinationUserName = server.DestinationUserName;
            client.SourceUserName = server.SourceUserName;
            client.StartTime = server.StartTime;
            client.EndTime = server.EndTime;
            client.Enabled = server.Enabled;

            return client;
        }
Exemplo n.º 10
0
        public static WfClientDelegationCollection PrepareDelegations(string userID)
        {
            WfClientDelegationCollection delegations = new WfClientDelegationCollection();
            WfClientDelegation           delegation  = PrepareDelegation();

            delegation.SourceUserID   = userID;
            delegation.SourceUserName = "******" + delegation.SourceUserName;
            WfClientProcessDescriptorServiceProxy.Instance.UpdateUserDelegation(delegation);
            delegations.Add(delegation);

            delegation = PrepareDelegation();
            delegation.SourceUserID   = userID;
            delegation.SourceUserName = "******" + delegation.SourceUserName;
            WfClientProcessDescriptorServiceProxy.Instance.UpdateUserDelegation(delegation);
            delegations.Add(delegation);

            return(delegations);
        }
        public WfDelegation ClientToServer(WfClientDelegation client, ref WfDelegation server)
        {
            client.NullCheck("client");

            if (server == null)
            {
                server = new WfDelegation();
            }

            server.SourceUserID        = client.SourceUserID;
            server.DestinationUserID   = client.DestinationUserID;
            server.DestinationUserName = client.DestinationUserName;
            server.SourceUserName      = client.SourceUserName;
            server.StartTime           = client.StartTime;
            server.EndTime             = client.EndTime;
            server.Enabled             = client.Enabled;

            return(server);
        }
        public WfClientDelegation ServerToClient(WfDelegation server, ref WfClientDelegation client)
        {
            server.NullCheck("server");

            if (client == null)
            {
                client = new WfClientDelegation();
            }

            client.SourceUserID        = server.SourceUserID;
            client.DestinationUserID   = server.DestinationUserID;
            client.DestinationUserName = server.DestinationUserName;
            client.SourceUserName      = server.SourceUserName;
            client.StartTime           = server.StartTime;
            client.EndTime             = server.EndTime;
            client.Enabled             = server.Enabled;

            return(client);
        }
Exemplo n.º 13
0
       public static WfClientDelegation PrepareDelegation()
       {
            WfClientDelegation delegation = new WfClientDelegation();

            delegation.SourceUserID = UuidHelper.NewUuidString();
            delegation.DestinationUserID = UuidHelper.NewUuidString();

            delegation.SourceUserName = "******";
            delegation.DestinationUserName = "******";
            delegation.Enabled =true;
            delegation.StartTime = new DateTime(2014, 11, 1, 0, 0, 0, DateTimeKind.Utc);
            delegation.EndTime = new DateTime(2014, 11, 11, 0, 0, 0, DateTimeKind.Local);

            delegation.ApplicationName = "WF ApplicationName";
            delegation.ProgramName = "WF ProgramName";
            delegation.TenantCode = UuidHelper.NewUuidString();

            return delegation;
       }
Exemplo n.º 14
0
        public static WfClientDelegation PrepareDelegation()
        {
            WfClientDelegation delegation = new WfClientDelegation();

            delegation.SourceUserID      = UuidHelper.NewUuidString();
            delegation.DestinationUserID = UuidHelper.NewUuidString();

            delegation.SourceUserName      = "******";
            delegation.DestinationUserName = "******";
            delegation.Enabled             = true;
            delegation.StartTime           = new DateTime(2014, 11, 1, 0, 0, 0, DateTimeKind.Utc);
            delegation.EndTime             = new DateTime(2014, 11, 11, 0, 0, 0, DateTimeKind.Local);

            delegation.ApplicationName = "WF ApplicationName";
            delegation.ProgramName     = "WF ProgramName";
            delegation.TenantCode      = UuidHelper.NewUuidString();

            return(delegation);
        }
Exemplo n.º 15
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            WfClientDelegation opinion = (WfClientDelegation)obj;

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.AddNonDefaultValue("sourceUserID", opinion.SourceUserID);
            dictionary.AddNonDefaultValue("sourceUserName", opinion.SourceUserName);
            dictionary.AddNonDefaultValue("destinationUserID", opinion.DestinationUserID);
            dictionary.AddNonDefaultValue("destinationUserName", opinion.DestinationUserName);
            dictionary.AddNonDefaultValue("startTime", opinion.StartTime);
            dictionary.AddNonDefaultValue("endTime", opinion.EndTime);
            dictionary.AddNonDefaultValue("enabled", opinion.Enabled);

            dictionary.AddNonDefaultValue("applicationName", opinion.ApplicationName);
            dictionary.AddNonDefaultValue("programName", opinion.ProgramName);
            dictionary.AddNonDefaultValue("tenantCode", opinion.TenantCode);

            return(dictionary);
        }
Exemplo n.º 16
0
        public void DeleteUserDelegationTest()
        {
            string userID = UuidHelper.NewUuidString();
            WfClientDelegationCollection delegations  = DelegationHelper.PrepareDelegations(userID);
            WfClientDelegationCollection delegations2 = DelegationHelper.PrepareDelegations(userID);

            delegations2.ForEach(action => delegations.Add(action));//同一委托人构建多条委托数据

            int count = delegations.Count;

            Assert.IsTrue(count > 2);
            WfClientDelegation delegation = delegations[0];

            WfClientProcessDescriptorServiceProxy.Instance.DeleteUserDelegation(delegation);
            int tmpCount = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(userID).Count;

            Assert.AreEqual(count - 1, tmpCount);

            WfClientProcessDescriptorServiceProxy.Instance.DeleteUserDelegation(userID);
            tmpCount = WfClientProcessDescriptorServiceProxy.Instance.LoadUserDelegations(userID).Count;
            Assert.AreEqual(0, tmpCount);
        }
        public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientDelegation delegation = new WfClientDelegation();

            delegation.SourceUserID = dictionary.GetValue("sourceUserID", string.Empty);
            delegation.SourceUserName = dictionary.GetValue("sourceUserName", string.Empty);
            delegation.DestinationUserID = dictionary.GetValue("destinationUserID", string.Empty);
            delegation.DestinationUserName = dictionary.GetValue("destinationUserName", string.Empty);

            delegation.StartTime = dictionary.GetValue("startTime", DateTime.MinValue);
            delegation.StartTime = delegation.StartTime.ToLocalTime();

            delegation.EndTime = dictionary.GetValue("endTime", DateTime.MinValue);
            delegation.EndTime = delegation.EndTime.ToLocalTime();

            delegation.Enabled = dictionary.GetValue("enabled", false);

            delegation.ApplicationName = dictionary.GetValue("applicationName", string.Empty);
            delegation.ProgramName = dictionary.GetValue("programName", string.Empty);
            delegation.TenantCode = dictionary.GetValue("tenantCode", string.Empty);

            return delegation;
        }
Exemplo n.º 18
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            WfClientDelegation delegation = new WfClientDelegation();

            delegation.SourceUserID        = dictionary.GetValue("sourceUserID", string.Empty);
            delegation.SourceUserName      = dictionary.GetValue("sourceUserName", string.Empty);
            delegation.DestinationUserID   = dictionary.GetValue("destinationUserID", string.Empty);
            delegation.DestinationUserName = dictionary.GetValue("destinationUserName", string.Empty);

            delegation.StartTime = dictionary.GetValue("startTime", DateTime.MinValue);
            delegation.StartTime = delegation.StartTime.ToLocalTime();

            delegation.EndTime = dictionary.GetValue("endTime", DateTime.MinValue);
            delegation.EndTime = delegation.EndTime.ToLocalTime();

            delegation.Enabled = dictionary.GetValue("enabled", false);

            delegation.ApplicationName = dictionary.GetValue("applicationName", string.Empty);
            delegation.ProgramName     = dictionary.GetValue("programName", string.Empty);
            delegation.TenantCode      = dictionary.GetValue("tenantCode", string.Empty);

            return(delegation);
        }
        public void DeleteUserDelegation(WfClientDelegation delegation)
        {
            OperationContext.Current.FillContextToOguServiceContext();
            WfDelegation server = null;
            WfClientDelegationConverter.Instance.ClientToServer(delegation, ref server);

            WfDelegationAdapter.Instance.Delete(server);
        }
 /// <summary>
 /// 删除委托信息
 /// </summary>
 /// <param name="delegation"></param>
 public void DeleteUserDelegation(WfClientDelegation delegation)
 {
     this.SingleCall(action => action.DeleteUserDelegation(delegation));
 }
        public static void AreSame(this WfClientDelegation expected, WfClientDelegation actual)
        {
            Assert.AreEqual(expected.SourceUserID, actual.SourceUserID);
            Assert.AreEqual(expected.SourceUserName, actual.SourceUserName);
            Assert.AreEqual(expected.DestinationUserID, actual.DestinationUserID);
            Assert.AreEqual(expected.DestinationUserName, actual.DestinationUserName);

            Assert.AreEqual(expected.StartTime.ToLocalTime(), actual.StartTime);
            Assert.AreEqual(expected.EndTime.ToLocalTime(), actual.EndTime);

            Assert.AreEqual(expected.Enabled, actual.Enabled);

            Assert.AreEqual(expected.ApplicationName, actual.ApplicationName);
            Assert.AreEqual(expected.ProgramName, actual.ProgramName);
            Assert.AreEqual(expected.TenantCode, actual.TenantCode);
        }