示例#1
0
        /// <summary>
        /// Get rectangle of cell on TableLayout.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        internal Rectangle GetCellRectangle(Cell cell)
        {
            if (cell.RowIndex > ParentWorkflow.RowCount - 1 ||
                cell.ColumnIndex > ParentWorkflow.ColumnCount - 1)
            {
                return(Rectangle.Empty);
            }

            int[] rowHeights = ParentWorkflow.GetRowHeights();
            int[] colWidths  = ParentWorkflow.GetColumnWidths();

            Rectangle rect  = Rectangle.Empty;
            int       value = 0;
            int       index = 0;

            for (int i = 0; i < cell.RowIndex; i++)
            {
                value += rowHeights[i];
                index  = i + 1;
            }
            rect.Y      = value;
            rect.Height = rowHeights[index];

            value = 0;
            index = 0;
            for (int i = 0; i < cell.ColumnIndex; i++)
            {
                value += colWidths[i];
                index  = i + 1;
            }
            rect.X     = value;
            rect.Width = colWidths[index];

            return(rect);
        }
示例#2
0
        private void GenerateArrowSpaceForEndPoint(List <WorkflowLineDetail> lineEndPoints)
        {
            for (int i = 0; i < lineEndPoints.Count(); i++)
            {
                WorkflowLineDetail    line      = lineEndPoints[i];
                WorkflowLineDirection direction = line.GetLineDirection();

                Cell cell = GetIndexWorkFlowButtonCell(line.ToCell.RowIndex, line.ToCell.ColumnIndex);

                WorkflowColumnStyle columnStyle = null;
                WorkflowRowStyle    rowStyle    = null;

                switch (direction)
                {
                case WorkflowLineDirection.LEFT:
                    // add space on right side of Button cell.
                    columnStyle       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.DisplayArrow);
                    columnStyle.Width = ARROW_SPACE;

                    ParentWorkflow.InsertColumn(cell.ColumnIndex + 1, columnStyle);
                    break;

                case WorkflowLineDirection.TOP:
                    // add space on bottom side of Button cell.
                    rowStyle        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.DisplayArrow);
                    rowStyle.Height = ARROW_SPACE;

                    ParentWorkflow.InsertRow(cell.RowIndex + 1, rowStyle);
                    break;

                case WorkflowLineDirection.RIGHT:
                    // add space on left side of Button cell.
                    columnStyle       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.DisplayArrow);
                    columnStyle.Width = ARROW_SPACE;

                    ParentWorkflow.InsertColumn(cell.ColumnIndex, columnStyle);
                    break;

                case WorkflowLineDirection.BOTTOM:
                    // add space on top side of Button cell.
                    rowStyle        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.DisplayArrow);
                    rowStyle.Height = ARROW_SPACE;

                    ParentWorkflow.InsertRow(cell.RowIndex, rowStyle);
                    break;
                }
            }
        }
示例#3
0
        public async Task Schedule_child_workflow()
        {
            var    @event   = new ManualResetEvent(false);
            string result   = null;
            var    workflow = new ParentWorkflow();

            workflow.Completed += (s, e) =>
            {
                result = e.Result;
                @event.Set();
            };
            _workflowHost = await HostAsync(workflow, new ChildWorkflow());

            await _domain.StartWorkflow <ParentWorkflow>("input", _taskListName);

            @event.WaitOne();

            Assert.That(result, Is.EqualTo(ActivityResult));
        }
示例#4
0
        /// <summary>
        /// Generate Button on TableLayout with space cell type.
        /// </summary>
        /// <param name="buttons"></param>
        private void GenerateButton(WorkflowButtonList buttons)
        {
            if (ButtonList.Count == 0)
            {
                return;
            }

            int maxRow = 0;
            int maxCol = 0;

            // Find max row and column index on button list.
            Cell maxButtonCell = ButtonList.FindMaxRowColumnIndex();

            maxRow = maxButtonCell.RowIndex;
            maxCol = maxButtonCell.ColumnIndex;

            // Find max row and column index on line deatil.
            Cell maxLineCell = LineHeaderList.FindMaxRowColumnIndex();

            maxRow = Math.Max(maxRow, maxLineCell.RowIndex);
            maxCol = Math.Max(maxCol, maxLineCell.ColumnIndex);

            //== Generate Row.
            ParentWorkflow.RowCount = Math.Max(0, ((maxRow + 1) * 2) - 1);
            for (int i = 0; i < ParentWorkflow.RowCount; i++)
            {
                WorkflowRowStyle row = null;
                if (i % 2 == 0)
                {
                    // It's Button.
                    row        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.Button);
                    row.Height = BUTTON_HEIGHT;
                }
                else
                {
                    // It's VSpace.
                    row        = new WorkflowRowStyle(SizeType.Absolute, WorkflowRowType.Space);
                    row.Height = VSPACE_HEIGHT;
                }

                ParentWorkflow.RowStyles.Add(row);
            }

            //== Generate Column
            ParentWorkflow.ColumnCount = Math.Max(0, ((maxCol + 1) * 2) - 1);
            for (int i = 0; i < ParentWorkflow.ColumnCount; i++)
            {
                WorkflowColumnStyle col = null;
                if (i % 2 == 0)
                {
                    // It's Button.
                    col       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.Button);
                    col.Width = BUTTON_WIDTH;
                }
                else
                {
                    // It's HSpace.
                    col       = new WorkflowColumnStyle(SizeType.Absolute, WorkflowColumnType.Space);
                    col.Width = HSPACE_WIDTH;
                }

                ParentWorkflow.ColumnStyles.Add(col);
            }

            //== Put button into cell.
            for (int i = 0; i < ButtonList.Count; i++)
            {
                WorkflowButton     btn        = ButtonList[i];
                WorkflowButtonArgs buttonArgs = new WorkflowButtonArgs();
                buttonArgs.Data = btn.Data;

                // Raise event when button has loading.
                // User can bind event "ButtonLoad" to override our Text and Image.
                ParentWorkflow.OnButtonLoad(buttonArgs);
                btn.Text      = buttonArgs.Text;
                btn.Image     = buttonArgs.Image;
                btn.BackColor = Color.Transparent;

                // Add control into table's cell.
                Cell cell = GetIndexWorkFlowButtonCell(btn.Data.ROW_INDEX, btn.Data.COL_INDEX);
                ParentWorkflow.Controls.Add(btn, cell.ColumnIndex, cell.RowIndex);

                btn.Dock = DockStyle.Fill;
            }
        }
        protected virtual void WriteResult(MeasuredParameter mp, AlertMeasure am)
        {
            DataManager.ConnectionString = AppSettings.GetAbsolute("Easynet.Edge.Core.Workflow.AlertConnectionString");

            //Create the command.
            using (DataManager.Current.OpenConnection())
            {
                AlertMeasures measures = (AlertMeasures)ParentWorkflow.InternalParameters["AlertMeasures"];

                string sql     = "INSERT INTO AlertResults ";
                string columns = "(wf_id,wf_date,wf_parameters,wf_conditionValues,entity_type,Account_id,Channel_id,Account_name,Current_Day,Compare_Day,measure_id,measure_current_value,measure_compare_value,measure_change_ratio";

                columns += GetColumns(mp);
                sql     += columns + " VALUES(";

                int wfID = ParentWorkflow.WorkflowID;
                if (wfID <= 0)
                {
                    if (ParentWorkflow.Parameters.ContainsKey("WorkflowID"))
                    {
                        wfID = Convert.ToInt32(ParentWorkflow.Parameters["WorkflowID"]);
                    }
                }

                string values = String.Empty;
                values  = wfID.ToString() + ",'" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "','" + ParentWorkflow.GetParametersAsString() + "','" + ParentWorkflow.GetConditionValuesAsString() + "'," + Convert.ToInt32(_entityType).ToString() + ",";
                values += mp.AccountID.ToString() + "," + mp.ChannelID.ToString() + ",'" + mp.AccountName + "'," + DayCode.ToDayCode(mp.CurrentDay).ToString() + "," + DayCode.ToDayCode(mp.CompareDate).ToString() + ",";
                values += mp.GetMeasureParameterSQL(am, measures) + ")";

                sql += values;
                SqlCommand alertResults = DataManager.CreateCommand(sql);
                try
                {
                    alertResults.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Log.Write("Failed to write alert result to database.", ex);
                    throw ex;
                }
            }
        }