/// <summary>
        /// Enregistrer le workflow
        /// </summary>
        /// <param name="path"></param>
        private void Save(String path)
        {
            if (String.IsNullOrEmpty(path))
            {
                return;
            }

            FileName = path;
            _designer.Save(path);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called to save the current workflow.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnSave(object sender, ExecutedRoutedEventArgs e)
 {
     if (ReferenceEquals(ViewModel.WorkflowFile, NewFilePlaceholder))
     {
         OnSaveAs(sender, e);
     }
     else
     {
         _designer.Save(ViewModel.WorkflowFile);
     }
 }
Exemplo n.º 3
0
        private void MenuItem_Click_SaveAs(object sender, RoutedEventArgs e)
        {
            var saveDialog = new SaveFileDialog();

            if (saveDialog.ShowDialog(this).Value)
            {
                _workflowFilePathName = saveDialog.FileName;
                _workflowDesigner.Save(_workflowFilePathName);
                MessageBox.Show("Save Ok");
                Title = $"Workflow Designer - {_workflowFilePathName}";
            }
        }
Exemplo n.º 4
0
 private void SaveProgram()
 {
     if (!string.IsNullOrEmpty(_currentProgramFilePath))
     {
         _wd.Save(_currentProgramFilePath);
         _isCurrentProgramStored = true;
         StoreCurrentProgramName();
     }
     else
     {
         SaveProgramAs();
     }
 }
Exemplo n.º 5
0
        public void Save()
        {
            var filePath = _currentWorkflowFile;

            Dispatcher.Invoke(new Action(() =>
            {
                FileInfo fi = null;
                try
                {
                    fi = new FileInfo(filePath);
                }
                catch (ArgumentException) { }
                catch (PathTooLongException) { }
                catch (NotSupportedException) { }

                if (ReferenceEquals(fi, null))
                {
                    Debug.WriteLine("Filename invalid: " + filePath);
                }
                else
                {
                    filePath = Path.ChangeExtension(filePath, ".xaml");
                    _wfDesigner.Save(filePath);
                    FilePath = filePath;
                    IsDirty  = false;
                }
            }));
        }
        private void SaveWorkflow(string filePath)
        {
            WorkflowDesigner.Save(filePath);

            FilePath = filePath;
            IsSaved  = true;
            IsDirty  = false;
            Title    = Path.GetFileName(filePath);
        }
Exemplo n.º 7
0
        private void OnSaveClick(object sender, System.Windows.RoutedEventArgs e)
        {
            var dlg = new SaveFileDialog();

            if (dlg.ShowDialog().Value)
            {
                _designer.Save(dlg.FileName);
            }
        }
Exemplo n.º 8
0
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            string tempFile = System.IO.Path.GetTempFileName();

            _workflowDesigner.Save(tempFile);
            _fileTypeDto.Workflow = System.IO.File.ReadAllBytes(tempFile);

            try
            {
                using (var context = new SqlDbContext())
                {
                    if (_fileTypeDto.Id == 0)
                    {
                        context.FileTypes.Add(_fileTypeDto);
                        var saveResult = await context.SaveChangesAsync();

                        if (saveResult == 1)
                        {
                            (Application.Current.MainWindow as MainWindow).ShowAlert(new Telerik.Windows.Controls.RadDesktopAlert()
                            {
                                Width = 400, Header = "Success", Content = "Save operation completed.", ShowDuration = 3000
                            });
                        }
                        _mainCollection.Add(_fileTypeDto);
                    }
                    else
                    {
                        context.Entry(_fileTypeDto).State = EntityState.Modified;
                        var saveResult = await context.SaveChangesAsync();

                        if (saveResult == 1)
                        {
                            (Application.Current.MainWindow as MainWindow).ShowAlert(new Telerik.Windows.Controls.RadDesktopAlert()
                            {
                                Width = 400, Header = "Success", Content = "Save operation completed.", ShowDuration = 3000
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 9
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter = "Xaml (*.xaml)|*.xaml";
            if (saveFileDialog.ShowDialog() == true)
            {
                wd.Save(saveFileDialog.FileName);
            }
        }
Exemplo n.º 10
0
        //object obj = new object();
        private void ReloadDesigner(int action = 0)
        {
            //lock (obj)
            //{
            SelectHelper.StartSimulation = false;
            if (string.IsNullOrEmpty(currentFile))
            {
                return;
            }

            if (action == 1)
            {
                if (File.Exists(currentFile))
                {
                    File.Delete(currentFile);
                }
            }

            if (!string.IsNullOrEmpty(currentFile))
            {
                if (SelectHelper.WorkflowDictionary.ContainsKey(currentFile))
                {
                    WorkflowDesigner _wfDesigner = SelectHelper.WorkflowDictionary[currentFile];
                    if (action == 1)
                    {
                        _wfDesigner.Save(currentFile);
                    }

                    _wfDesigner = new WorkflowDesigner();
                    _wfDesigner.Context.Services.GetService <DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));
                    _wfDesigner.Context.Services.GetService <DesignerConfigurationService>().LoadingFromUntrustedSourceEnabled = true;

                    //associates all of the basic activities with their designers
                    new DesignerMetadata().Register();
                    _wfDesigner.Load(currentFile);

                    if (SelectHelper.WorkflowDictionary.ContainsKey(currentFile))
                    {
                        SelectHelper.WorkflowDictionary[currentFile] = _wfDesigner;
                    }

                    if (currentFile == SelectHelper._currentworkflowfile)
                    {
                        _wfDesigner.View.UpdateLayout();
                        _wfDesigner.OutlineView.UpdateLayout();
                        System.Windows.Controls.Border WfDesignerBorder = (System.Windows.Controls.Border)SelectHelper.Border;
                        WfDesignerBorder.Child = _wfDesigner.View;
                        SelectHelper._wfPropertyBorder.Child = _wfDesigner.PropertyInspectorView;
                        SelectHelper._wfOutlineBorder.Child  = _wfDesigner.OutlineView;
                    }
                }
            }
            //}
        }
Exemplo n.º 11
0
        }  //end

        //保存流程
        void saveWorkflowToFile()
        {
            {
                if (workflowFilePathName == "tempRun.xaml")
                {
                    Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
                    if (saveFileDialog.ShowDialog(this).Value)
                    {
                        designer.Save(saveFileDialog.FileName);
                        workflowFilePathName = saveFileDialog.FileName;
                        this.Title           = "流程设计器  -   " + workflowFilePathName;
                    }
                }
                else
                {
                    designer.Save(workflowFilePathName);
                }

                loadWorkflowFromFile(workflowFilePathName);
            }
        }
        public MainWindowViewModel(DockingManager dm, WorkflowDesigner wf)
        {
            SaveCommand = new DelegateCommand((o) =>
            {
                var of    = new SaveFileDialog();
                of.Filter = "Workflow File (*.wf;*.xaml)|*.wf;*.xaml";

                if (of.ShowDialog().Value)
                {
                    wf.Save(of.FileName);
                }
            }, (o) => true);

            LoadCommand = new DelegateCommand((o) =>
            {
                var of    = new OpenFileDialog();
                of.Filter = "Workflow File (*.wf;*.xaml)|*.wf;*.xaml";

                if (of.ShowDialog().Value)
                {
                    wf.Load(of.FileName);
                }
            }, (o) => true);
        }
        //Run the Workflow with the tracking participant
        public void RunWorkflow()
        {
            WorkflowDesigner.Save(WorkflowFilePath);
            WorkflowDesigner.Flush();

            AddWorkflowDesigner();

            WorkflowInvoker instance = new WorkflowInvoker(GetRuntimeExecutionRoot());

            resumeRuntimeFromHost = new AutoResetEvent(false);

            Dictionary <string, Activity> activityIdToWfElementMap = BuildActivityIdToWfElementMap(wfElementToSourceLocationMap);

            #region Set up the Custom Tracking
            const String all = "*";
            SimulatorTrackingParticipant simTracker = new SimulatorTrackingParticipant()
            {
                TrackingProfile = new TrackingProfile()
                {
                    Name    = "CustomTrackingProfile",
                    Queries =
                    {
                        new CustomTrackingQuery()
                        {
                            Name         = all,
                            ActivityName = all
                        },
                        new WorkflowInstanceQuery()
                        {
                            // Limit workflow instance tracking records for started and completed workflow states
                            States ={ WorkflowInstanceStates.Started,              WorkflowInstanceStates.Completed, WorkflowInstanceStates.Idle },
                        },
                        new ActivityStateQuery()
                        {
                            // Subscribe for track records from all activities for all states
                            ActivityName = all,
                            States       = { all },

                            // Extract workflow variables and arguments as a part of the activity tracking record
                            // VariableName = "*" allows for extraction of all variables in the scope
                            // of the activity
                            Variables =
                            {
                                { all }
                            }
                        }
                    }
                }
            };

            simTracker.ActivityIdToWorkflowElementMap = activityIdToWfElementMap;

            #endregion

            //As the tracking events are received
            simTracker.TrackingRecordReceived += (trackingParticpant, trackingEventArgs) =>
            {
                if (trackingEventArgs.Activity != null)
                {
                    System.Diagnostics.Debug.WriteLine(
                        String.Format("<+=+=+=+> Activity Tracking Record Received for ActivityId: {0}, record: {1} ",
                                      trackingEventArgs.Activity.Id,
                                      trackingEventArgs.Record
                                      )
                        );

                    ShowDebug(wfElementToSourceLocationMap[trackingEventArgs.Activity]);

                    this.Dispatcher.Invoke(DispatcherPriority.SystemIdle, (Action)(() =>
                    {
                        //Textbox Updates
                        tx.AppendText(trackingEventArgs.Activity.Id + " " + trackingEventArgs.Activity.DisplayName + " " + ((ActivityStateRecord)trackingEventArgs.Record).State + "\n");
                        tx.AppendText("Instance ID: " + ((ActivityStateRecord)trackingEventArgs.Record).InstanceId + "\n");
                        tx.AppendText("Activity: " + ((ActivityStateRecord)trackingEventArgs.Record).Activity.Name + "\n");
                        tx.AppendText("Level: " + ((ActivityStateRecord)trackingEventArgs.Record).Level + "\n");
                        tx.AppendText("Time: " + ((ActivityStateRecord)trackingEventArgs.Record).EventTime + "\n");
                        tx.AppendText("******************\n");
                        //  textLineToSourceLocationMap.Add(i, wfElementToSourceLocationMap[trackingEventArgs.Activity]);
                        //  i = i + 2;

                        //Add a sleep so that the debug adornments are visible to the user
                        System.Threading.Thread.Sleep(500);
                    }));
                }
            };

            instance.Extensions.Add(simTracker);
            ThreadPool.QueueUserWorkItem(new WaitCallback((context) =>
            {
                //Start the Runtime
                instance.Invoke();// new TimeSpan(1,0,0));

                //This is to remove the final debug adornment
                this.Dispatcher.Invoke(DispatcherPriority.Render
                                       , (Action)(() =>
                {
                    this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(WorkflowFilePath, 1, 1, 1, 10);
                }));
            }));
        }
Exemplo n.º 14
0
 private void ExportXAML(string fileName)
 {
     wd.Save(fileName);
 }