Exemple #1
0
        private void GenerateActivities(string connectionString)
        {
            var db = new Data1.CloudCoreDB(connectionString);

            var activities = from am in db.Cloudcoremodel_ActivityModel
                             join sub in db.Cloudcoremodel_SubProcess on am.SubProcessId  equals sub.SubProcessId
                             join pr in db.Cloudcoremodel_ProcessRevision on am.ProcessRevisionId equals pr.ProcessRevisionId
                             where pr.ProcessRevisionId == Id || pr.ProcessModelId == 0
                             select new
                             {
                                 Id = am.ActivityModelId,
                                 Title = am.ActivityName,
                                 SubProcessId = sub.SubProcessId,
                                 SubProcessName = sub.SubProcessName,
                                 Startable = am.Startable,
                                 ActivityTypeId = am.ActivityTypeId,
                                 Decision = (from f in db.Cloudcoremodel_FlowModel
                                             where f.FromActivityModelId == am.ActivityModelId
                                             select am.ActivityModelId).Count() > 1
                             };

            foreach (var activity in activities)
            {
                var subProcess = SubProcesses.Where(r => r.Id == activity.SubProcessId).SingleOrDefault();
                if (subProcess == null)
                {
                    subProcess = new SubProcess()
                    {
                        Id = activity.SubProcessId,
                        Parent = this,
                        Title = activity.SubProcessName

                    };
                    SubProcesses.Add(subProcess);
                }

                IActivity act;

                switch (activity.ActivityTypeId)
                {
                    case 0:
                        act = new CloudCore_User_Activity();
                        break;
                    case 1:
                        act = new Custom_User_Activity();
                        break;
                    case 2:
                        act = new Database_Custom_Activity();
                        break;
                    case 3:
                        act = new Database_Parked_Activity();
                        break;
                    case 4:
                        act = new Flow_Rule();
                        break;
                    case 5:
                        act = new Cloud_Custom_Activity();
                        break;
                    case 6:
                        act = new Database_Costing();
                        break;
                    case 7:
                        act = new Cloud_Costing();
                        break;
                    case 8:
                        act = new Database_Batch_Start();
                        break;
                    case 9:
                        act = new Cloud_Batch_Start();
                        break;
                    case 10:
                        act = new Cloud_Batch_Wait();
                        break;
                    case 11:
                        act = new Cloud_Parked_Activity();
                        break;
                    case 12:
                        act = new SMS_Activity();
                        break;
                    case 13:
                        act = new Email_Activity();
                        break;
                    case 14:
                        act = new Corticon_Business_Rule();
                        break;
                    case 99:
                        act = new StopActivity();
                        break;
                    default:
                        act = new CloudCore_User_Activity();
                        break;
                }

                act.Title = activity.Title;
                act.Id = activity.Id;
                act.Parent = subProcess;

                if (activity.Startable)
                    act.AddProperty(ActivityProperties.Startable);


                subProcess.Activities.Add(act);
            }
        }
Exemple #2
0
        void DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                var workerArgs = e.Argument as WorkerArgs;
                var worker = sender as BackgroundWorker;
                if (worker == null || workerArgs == null)
                    return;

                var progress = workerArgs.StepSize;
                e.Result = false;

                worker.ReportProgress(progress);

                foreach (var process in workerArgs.DrawItem.Process)
                {
                    foreach (var task in process.SubProcesses.Where(t => t.Id != 0))
                    {
                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        DropTask(_stencil, _vapp, task);
                        worker.ReportProgress(++progress);
                    }

                    var allActivities = (from t in process.SubProcesses
                                         select t.Activities).SelectMany(x => x);

                    foreach (var connector in process.Connectors)
                    {
                        if (worker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        worker.ReportProgress(++progress);

                        var fromActivity = allActivities.Single(a => a.Id == connector.FromActivityId);

                        if (connector.ToActivityId == 0)
                        {
                            var stopActivity = new StopActivity()
                                                   {
                                                       Id = 0,
                                                       Parent = fromActivity.Parent,
                                                   };
                            stopActivity.Shape = fromActivity.Shape.ContainingPage.Drop(_stencil.Masters[stopActivity.TemplateShapeName], 0, 0);

                            if (fromActivity.Parent.Shape != null)
                                fromActivity.Parent.Shape.ContainerProperties.AddMember(stopActivity.Shape, Visio.VisMemberAddOptions.visMemberAddExpandContainer);

                            ConnectNodePair(fromActivity, stopActivity, _vapp, _stencil, connector);

                        }
                        else
                        {
                            var fromAct = allActivities.SingleOrDefault(a => a.Id == connector.FromActivityId);
                            var ToAct = allActivities.SingleOrDefault(a => a.Id == connector.ToActivityId);

                            if (fromAct == null || ToAct == null)
                                continue;

                            ConnectNodePair(fromAct, ToAct, _vapp, _stencil, connector);
                        }
                    }
                }

                SetPageLayoutAndRouting(_vapp.ActivePage);

                _vapp.Visible = true;
                e.Result = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                ReleaseVisio();
            }
        }