示例#1
0
        // Wenn durch die Aktivität ein Wert zurückgegeben wird, erfolgt eine Ableitung von CodeActivity<TResult>
        // und der Wert von der Ausführmethode zurückgegeben.
        protected override void Execute(CodeActivityContext context)
        {
            HRONEntities dbcontext = new HRONEntities();

            // Cerco parent WF
            EmplWorkflows ewf = null;

            if (parentWFId.Get(context) != null)
            {
                ewf = dbcontext.EmplWorkflows.Where(w => w.wfID == parentWFId.ToString()).FirstOrDefault();
            }

            WFApprovals approval = new WFApprovals();

            approval.approverWFID       = WFId.Get(context);
            approval.approverActivityID = ActivityId.Get(context);
            approval.body      = body.Get(context);
            approval.mail      = to.Get(context);
            approval.subject   = subject.Get(context);
            approval.starttime = DateTime.Now;
            if (ewf != null)
            {
                approval.Parent = ewf;
            }

            dbcontext.WFApprovals.Add(approval);

            dbcontext.SaveChanges();
        }
        // Wenn durch die Aktivität ein Wert zurückgegeben wird, erfolgt eine Ableitung von CodeActivity<TResult>
        // und der Wert von der Ausführmethode zurückgegeben.
        protected override void Execute(CodeActivityContext context)
        {
            HRONEntities dbcontext = new HRONEntities();

            WFApprovals approval = dbcontext.WFApprovals.Find(new object[] { WFId.Get(context), ActivityId.Get(context) });

            if (approval != null)
            {
                approval.note     = Note.Get(context);
                approval.approved = approved.Get(context);
                approval.endtime  = DateTime.Now;

                dbcontext.SaveChanges();

                result.Set(context, true);
                return;
            }
            result.Set(context, false);
        }