Example #1
0
 public ActivityDefination(ActivityDefination other):base(other) {
     this.Deal = other.Deal;
     this.StartMode = other.StartMode;
     this.StartConstraint = other.StartConstraint;
     this.StartConstraintKind = other.StartConstraintKind;
     this.FinishConstraint = other.FinishConstraint;
     this.FinishConstraintKind = other.FinishConstraintKind;
     this.FinishMode = other.FinishMode;
 }
Example #2
0
 public ActivityInfo(Guid proccessId, ActivityDefination defination):base(proccessId,defination) {
     this.Deal = defination.Deal;
     this.StartMode = defination.StartMode;
     this.FinishMode = defination.FinishMode;
     this.StartConstraintKind = defination.StartConstraintKind;
     this.FinishConstraintKind = defination.FinishConstraintKind;
     this.StartConstraint = defination.StartConstraint;
     this.FinishConstraint = defination.FinishConstraint;
 }
Example #3
0
 public static ActivityDefination FromJson(JObject data, ActivityDefination entity=null) {
     if (entity == null) entity = new ActivityDefination();
     Defination.FromJson(data, entity);
     
     entity.ActivityType = data["ActivityType"].ToString();
     entity.Deal = data["Deal"].ToString();
     entity.StartMode =(ExecutionModes)Enum.Parse(typeof(ExecutionModes), data["StartMode"].ToString());
     entity.FinishMode = (ExecutionModes)Enum.Parse(typeof(ExecutionModes), data["FinishMode"].ToString());
     entity.StartConstraint = data["StartConstraint"].ToString();
     entity.FinishConstraint = data["FinishConstraint"].ToString();
     entity.StartConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["StartConstraintKind"].ToString());
     entity.FinishConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["FinishConstraintKind"].ToString());
     return entity;
 }
Example #4
0
 public override Defination CloneTo(Defination existed = null)
 {
     var entity = existed as ActivityDefination;
     if (entity == null) entity = new ActivityDefination();
     base.CloneTo(entity);
     entity.ActivityType = this.ActivityType;
     entity.Deal = this.Deal;
     entity.StartMode = this.StartMode;
     entity.StartConstraint = this.StartConstraint;
     entity.StartConstraintKind = this.StartConstraintKind;
     entity.FinishConstraint = this.FinishConstraint;
     entity.FinishConstraintKind = this.FinishConstraintKind;
     entity.FinishMode = this.FinishMode;
     return entity;
 }
Example #5
0
        void TestDefinationAccess(IDefinationRepository rep) {
            #region package
            PackageDefination pack1 = new PackageDefination()
            {
                Alias = "Test1",
                Name = "Test Package1",
                Description = "Just for test package=1"
            };

            rep.SavePackageDefination(pack1);
            PackageDefination pack2 = new PackageDefination() {
                Alias ="Test2",
                Name = "Test Package2",
                Description = "Just for test package=2"
            };
            pack2.Extras["author"] = "yiy";
            rep.SavePackageDefination(pack2);
            var packs = rep.ListPackages();
            Assert.Equal(2,packs.Count);
            Assert.Equal("Test1",packs[0].Alias);
            Assert.Equal("Test2",packs[1].Alias);

            var pack = rep.GetPackageDefination("test2");
            Assert.Equal("Test2",pack.Alias);
            Assert.Equal("Test Package2",pack.Name);
            Assert.Equal("Just for test package=2",pack.Description);
            Assert.Equal(1,pack.Extras.Count);
            Assert.Equal("yiy",pack.Extras["author"]);
            #endregion

            #region proccess
            var proccess = new ProccessDefination();
            proccess.Alias = "test2/proccess1";
            proccess.Name = "Proccess1";
            proccess.StartAlias = "test2/proccess1/PR";
            proccess.FinishAlias = "test2/proccess1/PO";

            rep.SaveProccessDefination(proccess);

            var pro = rep.GetProccessDefination("test2/proccess1");
            Assert.Equal("test2/proccess1",pro.Alias);
            Assert.Equal("Proccess1",pro.Name);
            Assert.Equal("test2/proccess1/PR", pro.StartAlias);
            Assert.Equal("test2/proccess1/PO", pro.FinishAlias);


            #endregion

            #region activity
            var prActivity = new ActivityDefination();
            prActivity.Alias = "test2/proccess1/PR";
            prActivity.Name = "PR";
            prActivity.InstanceType = "Activity";
            prActivity.StartMode = ExecutionModes.Automatic;
            prActivity.StartConstraintKind = ConstraintKinds.Code;
            prActivity.StartConstraint = "return true";
            prActivity.FinishMode = ExecutionModes.Manual;
            prActivity.FinishConstraintKind = ConstraintKinds.Class;
            prActivity.FinishConstraint = "Finish";
            

            rep.SaveActivityDefination(prActivity);

            var activity = rep.GetActivityDefination("test2/proccess1/PR");
            Assert.Equal("test2/proccess1/PR", activity.Alias);
            Assert.Equal("PR", activity.Name);
            Assert.Equal("test2/proccess1", activity.ProccessAlias);
            Assert.Equal("Activity", activity.InstanceType);
            Assert.Equal(ExecutionModes.Automatic, activity.StartMode);
            Assert.Equal(ConstraintKinds.Code, activity.StartConstraintKind);
            Assert.Equal("return true", activity.StartConstraint);
            Assert.Equal(ExecutionModes.Manual, activity.FinishMode);
            Assert.Equal(ConstraintKinds.Class, activity.FinishConstraintKind);
            Assert.Equal("Finish", activity.FinishConstraint);
            #endregion

            #region transaction
            var trans = new TransactionDefination();
            trans.Alias = "test2/proccess1/PR2PO";
            trans.Name = "PR2PO";
            trans.InstanceType = "Transaction";
            trans.Constraint = "return true;";
            trans.ConstraintKind = ConstraintKinds.Code;
            trans.FromAlias = "test2/proccess1/PR";
            trans.ToAlias = "test2/proccess1/PO";


            rep.SaveTransactionDefination(trans);

            var transaction = rep.GetTransactionDefination("test2/proccess1/PR2PO");
            Assert.Equal("test2/proccess1/PR2PO", transaction.Alias);
            Assert.Equal("PR2PO", transaction.Name);
            Assert.Equal("test2/proccess1", transaction.ProccessAlias);
            Assert.Equal("Transaction", transaction.InstanceType);
            Assert.Equal(ConstraintKinds.Code, transaction.ConstraintKind);
            Assert.Equal("return true;", transaction.Constraint);
            
            Assert.Equal("test2/proccess1/PR", transaction.FromAlias);
            Assert.Equal("test2/proccess1/PO", transaction.ToAlias);
            #endregion

            #region list execution
            var list = rep.ListExecutionDefinations("test2/proccess1");
            Assert.NotNull(list);
            Assert.Equal(2,list.Count);
            Assert.NotNull(list.FirstOrDefault(p=>p.Alias == "test2/proccess1/PR"));
            Assert.NotNull(list.FirstOrDefault(p => p.Alias == "test2/proccess1/PR2PO"));
            #endregion
        }
 public IList<ExecutionDefination> ListExecutionDefinations(string containerAlias)
 {
     var dir = this.Storage.GetDirectory(containerAlias);
     if (dir == null) return null;
     var items = dir.ListItems(true, StorageTypes.File);
     List<ExecutionDefination> result = new List<ExecutionDefination>();
     foreach (var item in items)
     {
         var file = item as IStorageFile;
         if (file == null) continue;
         string jsonText = null;
         JObject data = null;
         if (file.Name.EndsWith(".activity.json"))
         {
             jsonText = file.GetText();
             if (jsonText == null) continue;
             data = new Json.Parser().Parse(jsonText) as JObject;
             if (data == null) continue;
             var def = new ActivityDefination(data);
             result.Add(def);
         }
         else if (file.Name.EndsWith(".transaction.json")) {
             jsonText = file.GetText();
             if (jsonText == null) continue;
             data = new Json.Parser().Parse(jsonText) as JObject;
             if (data == null) continue;
             var def = new TransactionDefination(data);
             result.Add(def);
         }
         
     }
     return result;
 }
 public void SaveActivityDefination(ActivityDefination activityDefination)
 {
     var shortAlias =  CheckExecutionAliases(activityDefination);
     if (string.IsNullOrEmpty(shortAlias)) throw new ArgumentException("ActivityDefination.Alias is not correct. It should be 'packageAlias/proccessId/activityId'. ");
     
     this.Storage.PutText(activityDefination.Alias + ".activity.json", activityDefination.ToJson());
 }