protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (Page.IsValid) { if (e.CommandName == "Select") { Users newUser; dbHelper helper = new dbHelper(); newUser = helper.GetUserbyName(TextBoxUser.Text); if (newUser == null) { newUser = new Users(); newUser.UserName = TextBoxUser.Text; newUser.UserType = "local"; newUser.SNUserId = "local" + TextBoxUser.Text; helper.AddToModel(newUser); } Session["user"] = newUser; WebControl wc = e.CommandSource as WebControl; GridViewRow row = wc.NamingContainer as GridViewRow; Session["UseCaseStartTime"] = DateTime.Now; Session["UseCaseNumber"] = row.RowIndex + 1; Session["UseCaseText"] = row.Cells[1].Text; Server.Transfer("Design.aspx"); } } }
private void createActionTable(String actionType, DataTable dt) { dbHelper helper = new dbHelper(); List <ActionInputs> actionsInput; List <ActionOutputs> actionsOutput; List <Actions> actionsType = helper.GetActionsByType(actionType); foreach (Actions itemAction in actionsType) { actionsInput = helper.GetActionInputsForAction(itemAction.ActionId); actionsOutput = helper.GetActionOutputsForAction(itemAction.ActionId); DataRow dr = dt.NewRow(); if (actionsInput.Count > 0) { dr["Input"] = actionsInput[0].InputObject; } else { dr["Input"] = String.Empty; } dr["Name"] = itemAction.ActionName; if (actionsOutput.Count > 0) { dr["Output"] = actionsOutput[0].OutputObject; } else { dr["Output"] = String.Empty; } dt.Rows.Add(dr); } }
protected void ButtonPlay_Click(object sender, EventArgs e) { if (Page.IsValid) { if (dt.Rows.Count > 0) { Flows playflow = SaveFlow(); if (playflow != null) { FlowInstances currentFlow = new FlowInstances(); dbHelper helper = new dbHelper(); DataRow firstRow = dt.Rows[0]; Actions startAction = helper.GetActionById(firstRow["Id"].ToString()); currentFlow.Actions = startAction; currentFlow.CurrentPosition = 1; currentFlow.Users = playflow.Users; currentFlow.Flows = playflow; helper.AddToModel(currentFlow); Session["currentInstance"] = currentFlow; Server.Transfer(currentFlow.Actions.ActionPage); } } } }
protected void ButtonStart_Click(object sender, EventArgs e) { if (Session["currentInstance"] == null) { Server.Transfer("Error.aspx"); } dbHelper helper = new dbHelper(); FlowInstances currentFlow = (FlowInstances)Session["currentInstance"]; Actions next = helper.GetNextAction(currentFlow.Flows.FlowId, currentFlow.CurrentPosition); if (next == null) { Server.Transfer("End.aspx"); } else { FlowInstances flowInstance = helper.GetFlowInstanceById(currentFlow.FlowInstanceId); flowInstance.CurrentPosition++; flowInstance.Actions = next; helper.UpdateChanges(); Session["currentInstance"] = flowInstance; Server.Transfer(flowInstance.Actions.ActionPage); } }
private void InitializeApp() { dbHelper helper = new dbHelper(); ApplicationInfo appInfo = helper.GetAppInfo(); FacebookConnector fbApi = new FacebookConnector(appInfo.ApplicationURL, appInfo.ApplicationId, appInfo.RedirectURL, appInfo.ApplicationSecret, appInfo.PageId, appInfo.ApplicationAT, appInfo.PageOwnerId); Session["fbApi"] = fbApi; }
protected void Button2_Click(object sender, EventArgs e) { dbHelper helper = new dbHelper(); Users currentUser = new Users(); currentUser = helper.GetTestUser(); Session["user"] = currentUser; Server.Transfer("Design.aspx"); }
private void SetActionGrid(String LastNode) { String whereClause = String.Empty; dbHelper helper = new dbHelper(); List <String> nextNodes = helper.GetNextNodes(LastNode); foreach (String itemNode in nextNodes) { whereClause += " it.[ActionId] = '" + itemNode + "' OR"; } whereClause = whereClause.Substring(0, whereClause.Length - 2); SimpleFlowDS.Where = whereClause; }
public String GetActionOutput(String actionId) { dbHelper helper = new dbHelper(); List <ActionOutputs> outputs = helper.GetActionOutputsForAction(actionId); if (outputs.Count > 0) { return(outputs[0].OutputObject); } else { return(String.Empty); } }
private void LoadPreviousActionOptions(String actionId) { dbHelper helper = new dbHelper(); _listActOpt.Clear(); _listActOpt = helper.GetActionOptionsForAction(actionId); ActionOptions itemActOpt; TextBox tx; CheckBox ck; RadioButtonList rd; DropDownList dd; if (MultiViewSpecific.GetActiveView() == ViewPostMessage) { rd = RadioButtonListPostMessage; } else { rd = RadioButtonListPostComment; } foreach (FlowActionOptions itemFlowActOpt in _listFlowActOpt) { if (itemFlowActOpt.FlowPosition == dt.Rows.Count) { itemActOpt = itemFlowActOpt.ActionOptions; if (itemActOpt.ControlName != null) { switch (itemActOpt.Options.OptionType) { case "textbox": tx = (TextBox)FindControl(itemActOpt.ControlName); if (tx != null) { tx.Text = itemFlowActOpt.Value; } break; case "check": ck = (CheckBox)FindControl(itemActOpt.ControlName); if (ck != null) { if (itemFlowActOpt.Value == "true") { ck.Checked = true; } else { ck.Checked = false; } } break; case "radio": if (itemFlowActOpt.Value == "true") { rd.SelectedValue = itemActOpt.ControlName; } if (itemActOpt.ControlName == "MultOptCom" && itemFlowActOpt.Value == "true") { dtOptions.Clear(); foreach (FlowMultiOptions itemFlowMultiOpt in _listFlowMultiOpt) { if (itemFlowMultiOpt.FlowPosition == dt.Rows.Count) { AddToDataTableOptions(itemFlowMultiOpt.OptionValue); } } BindGridOptions(); } break; case "dropdown": dd = (DropDownList)FindControl(itemActOpt.ControlName); if (dd != null) { dd.SelectedValue = itemFlowActOpt.Value; } break; } } } } ViewState["ActionOptions"] = _listActOpt; }
private void LoadActionOptions(String actionId) { dbHelper helper = new dbHelper(); _listActOpt.Clear(); _listActOpt = helper.GetActionOptionsForAction(actionId); TextBox tx; CheckBox ck; RadioButtonList rd; DropDownList dd; if (MultiViewSpecific.GetActiveView() == ViewPostMessage) { rd = RadioButtonListPostMessage; } else { rd = RadioButtonListPostComment; } foreach (ActionOptions itemActOpt in _listActOpt) { if (itemActOpt.ControlName != null) { switch (itemActOpt.Options.OptionType) { case "textbox": tx = (TextBox)FindControl(itemActOpt.ControlName); if (tx != null) { tx.Text = itemActOpt.DefaultValue; } break; case "check": ck = (CheckBox)FindControl(itemActOpt.ControlName); if (ck != null) { if (itemActOpt.DefaultValue == "true") { ck.Checked = true; } else { ck.Checked = false; } } break; case "radio": if (itemActOpt.DefaultValue == "true") { rd.SelectedValue = itemActOpt.ControlName; } break; case "dropdown": dd = (DropDownList)FindControl(itemActOpt.ControlName); if (dd != null) { dd.SelectedValue = itemActOpt.DefaultValue; } break; } } } ViewState["ActionOptions"] = _listActOpt; }
private void SaveActionOptions(int position) { FlowActionOptions fao; FlowActionInputs faIn; FlowActionOutputs faOut; TextBox tx; CheckBox ck; RadioButtonList rd; DropDownList dd; _listFlowActOpt.RemoveAll(f => f.FlowPosition == position); _listFlowActInput.RemoveAll(f => f.FlowPosition == position); _listFlowActOutput.RemoveAll(f => f.FlowPosition == position); if (MultiViewSpecific.GetActiveView() == ViewPostMessage) { rd = RadioButtonListPostMessage; } else { rd = RadioButtonListPostComment; } foreach (ActionOptions itemActOpt in _listActOpt) { if (itemActOpt.ControlName != null) { fao = new FlowActionOptions(); fao.ActionOptions = itemActOpt; fao.FlowPosition = position; switch (itemActOpt.Options.OptionType) { case "textbox": tx = (TextBox)FindControl(itemActOpt.ControlName); if (tx != null) { fao.Value = tx.Text; } break; case "check": ck = (CheckBox)FindControl(itemActOpt.ControlName); if (ck != null) { if (ck.Checked) { fao.Value = "true"; } else { fao.Value = "false"; } } break; case "radio": if (rd.SelectedValue == itemActOpt.ControlName) { fao.Value = "true"; } else { fao.Value = "false"; } if (itemActOpt.ControlName == "MultOptCom" && fao.Value == "true") { FlowMultiOptions fmo; _listFlowMultiOpt.RemoveAll(fm => fm.FlowPosition == position); foreach (DataRow itemMultiOpt in dtOptions.Rows) { fmo = new FlowMultiOptions(); fmo.FlowPosition = position; fmo.OptionValue = itemMultiOpt["Option"].ToString(); _listFlowMultiOpt.Add(fmo); } if (dt.Rows.Count != position) { dtOptions.Clear(); AddToDataTableOptions("Add Options..."); BindGridOptions(); } } break; case "dropdown": dd = (DropDownList)FindControl(itemActOpt.ControlName); if (dd != null) { fao.Value = dd.SelectedValue; } break; } _listFlowActOpt.Add(fao); } } dbHelper helper = new dbHelper(); if (dt.Rows[position - 1].Field <String>("Input") != String.Empty) { List <ActionInputs> inputs = helper.GetActionInputsForAction(dt.Rows[position - 1].Field <String>("Id")); faIn = new FlowActionInputs(); faIn.FlowPosition = position; faIn.ActionInputs = inputs[0]; faIn.Value = dt.Rows[position - 1].Field <String>("Input"); _listFlowActInput.Add(faIn); } if (dt.Rows[position - 1].Field <String>("Output") != String.Empty) { List <ActionOutputs> outputs = helper.GetActionOutputsForAction(dt.Rows[position - 1].Field <String>("Id")); faOut = new FlowActionOutputs(); faOut.FlowPosition = position; faOut.ActionOutputs = outputs[0]; faOut.Value = dt.Rows[position - 1].Field <String>("Output"); _listFlowActOutput.Add(faOut); } }
private Flows SaveFlow() { if (dt.Rows.Count <= 0) { return(null); } dbHelper helper = new dbHelper(); bool isUpdate = true; FlowActionOptions fao; FlowActionInputs faIn; FlowActionOutputs faOut; FlowMultiOptions fmo; ActionOptions actOpt; ActionInputs actInput; ActionOutputs actOutput; Users flowUser = helper.GetUserbyName(_user.UserName); Flows myflow = helper.GetFlowByName(TextBox1.Text, flowUser); if (myflow == null) { myflow = new Flows(); myflow.FlowName = TextBox1.Text; myflow.Users = flowUser; myflow.FlowUseCaseNumber = _useCaseNumber; myflow.FlowStartTime = _useCaseStartTime; myflow.FlowEndTime = DateTime.Now; isUpdate = false; } else { myflow.FlowEndTime = DateTime.Now; helper.DeleteFlowDetailsById(myflow.FlowId); } int rowCount = 0; FlowActions flowAction; Actions curAction; foreach (DataRow gridRow in dt.Rows) { rowCount++; curAction = helper.GetActionById(gridRow["Id"].ToString()); flowAction = new FlowActions(); flowAction.Actions = curAction; flowAction.Position = rowCount; myflow.FlowActions.Add(flowAction); } SaveActionOptions(dt.Rows.Count); foreach (FlowActionOptions itemFlowActOpt in _listFlowActOpt) { fao = new FlowActionOptions(); actOpt = helper.GetActionOptionById(itemFlowActOpt.ActionOptions.ActionOptionId); fao.ActionOptions = actOpt; fao.FlowPosition = itemFlowActOpt.FlowPosition; fao.Value = itemFlowActOpt.Value; myflow.FlowActionOptions.Add(fao); } foreach (FlowActionInputs itemFlowActIn in _listFlowActInput) { faIn = new FlowActionInputs(); actInput = helper.GetActionInputById(itemFlowActIn.ActionInputs.InputId); faIn.ActionInputs = actInput; faIn.FlowPosition = itemFlowActIn.FlowPosition; faIn.Value = itemFlowActIn.Value; myflow.FlowActionInputs.Add(faIn); } foreach (FlowActionOutputs itemFlowActOut in _listFlowActOutput) { faOut = new FlowActionOutputs(); actOutput = helper.GetActionOutputById(itemFlowActOut.ActionOutputs.OutputId); faOut.ActionOutputs = actOutput; faOut.FlowPosition = itemFlowActOut.FlowPosition; faOut.Value = itemFlowActOut.Value; myflow.FlowActionOutputs.Add(faOut); } foreach (FlowMultiOptions itemFlowMultiOpt in _listFlowMultiOpt) { fmo = new FlowMultiOptions(); fmo.FlowPosition = itemFlowMultiOpt.FlowPosition; fmo.OptionValue = itemFlowMultiOpt.OptionValue; myflow.FlowMultiOptions.Add(fmo); } if (isUpdate) { helper.UpdateChanges(); } else { helper.AddToModel(myflow); } return(myflow); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { dt = new DataTable(); MakeDataTable(); String lastNode = null; SetActionGrid(lastNode); dtOptions = new DataTable(); MakeDataTableOptions(); AddToDataTableOptions("Add Options..."); BindGridOptions(); dtImports = new DataTable(); MakeDataTableImports(); _listFlowActOpt = new List <FlowActionOptions>(); _listFlowActInput = new List <FlowActionInputs>(); _listFlowActOutput = new List <FlowActionOutputs>(); _listActOpt = new List <ActionOptions>(); _listFlowMultiOpt = new List <FlowMultiOptions>(); if (!Object.ReferenceEquals(Session["user"], null)) { _user = (Users)Session["user"]; } else { dbHelper helper = new dbHelper(); _user = helper.GetTestUser(); } if (!Object.ReferenceEquals(Session["UseCaseNumber"], null)) { _useCaseNumber = (int)Session["UseCaseNumber"]; } else { _useCaseNumber = 0; } if (!Object.ReferenceEquals(Session["UseCaseStartTime"], null)) { _useCaseStartTime = (DateTime)Session["UseCaseStartTime"]; } else { _useCaseStartTime = DateTime.Now; } if (!Object.ReferenceEquals(Session["UseCaseText"], null)) { LabelUseCaseTooltip.Text = (String)Session["UseCaseText"]; } else { LabelUseCaseTooltip.Text = "Implement a process that meet your needs. Give it a meaningful name when saving."; } //Panel1.Visible = false; } else { dt = (DataTable)ViewState["MainFlow"]; dtOptions = (DataTable)ViewState["TableOptions"]; dtImports = (DataTable)ViewState["DataImports"]; _listFlowActOpt = (List <FlowActionOptions>)ViewState["FlowActionOptions"]; _listFlowActInput = (List <FlowActionInputs>)ViewState["FlowActionInputs"]; _listFlowActOutput = (List <FlowActionOutputs>)ViewState["FlowActionOutputs"]; _listActOpt = (List <ActionOptions>)ViewState["ActionOptions"]; _listFlowMultiOpt = (List <FlowMultiOptions>)ViewState["FlowMultiOptions"]; _user = (Users)Session["user"]; _useCaseNumber = (int)Session["UseCaseNumber"]; _useCaseStartTime = (DateTime)Session["UseCaseStartTime"]; //Panel1.Visible = false; } ViewState["MainFlow"] = dt; ViewState["TableOptions"] = dtOptions; ViewState["DataImports"] = dtImports; ViewState["FlowActionOptions"] = _listFlowActOpt; ViewState["FlowActionInputs"] = _listFlowActInput; ViewState["FlowActionOutputs"] = _listFlowActOutput; ViewState["ActionOptions"] = _listActOpt; ViewState["FlowMultiOptions"] = _listFlowMultiOpt; //String selectedId = GridView1.DataKeys[row.RowIndex].Value.ToString(); Session["user"] = _user; Session["UseCaseNumber"] = _useCaseNumber; Session["UseCaseStartTime"] = _useCaseStartTime; }