public double apply_discount(int OrgID, double price, int CustomerID) { double discount = 0.0; int CustomerCategoryObjID = 0; int CustomerObjID = 0; localhost.Service serviceObj = new localhost.Service(); localhost.Table[] Tarray = serviceObj.GetTables(OrgID); List<localhost.Table> listOfTables = new List<localhost.Table>(Tarray); for (int i = 0; i < listOfTables.Count; i++) { if (listOfTables[i].TNameProperty == "CustomerCategory") { CustomerCategoryObjID = listOfTables[i].ObjIDProperty; } if (listOfTables[i].TNameProperty == "Customer") { CustomerObjID = listOfTables[i].ObjIDProperty; } } localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(OrgID, CustomerObjID, CustomerID); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; int categoryid = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "CustCategoryID") { categoryid = Convert.ToInt32(valuearr[counter].ToString()); } counter++; } double total = 0; obj = serviceObj.ReadDataWithGUID(OrgID, CustomerCategoryObjID, CustomerID); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "DiscountPercentage") { discount = Convert.ToDouble(valuearr[counter].ToString()); total = price - (price * discount) / 100; } counter++; } return total; }
public Order Displayinfo(int OrgID, int OrderID) { Order order_obj = null; int ObjID = 0; localhost.Service serviceObj = new localhost.Service(); localhost.Table[] Tarray = serviceObj.GetTables(OrgID); List<localhost.Table> listOfTables = new List<localhost.Table>(Tarray); for (int i = 0; i < listOfTables.Count; i++) { if (listOfTables[i].TNameProperty == "Order") { ObjID = listOfTables[i].ObjIDProperty; } } if (ObjID != 0) { localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(OrgID, ObjID, OrderID); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; order_obj = new Order(); for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "OrderDate") { order_obj.OrderDate = Convert.ToDateTime(valuearr[counter].ToString()); } if (arr[j].ToString() == "DateLastUpdated") { order_obj.DateLastUpdated = Convert.ToDateTime(valuearr[counter].ToString()); } if (arr[j].ToString() == "Quantity") { order_obj.Quantity = Convert.ToInt32(valuearr[counter].ToString()); } if (arr[j].ToString() == "OrderStatus") { order_obj.OrderStatus = valuearr[counter].ToString(); } if (arr[j].ToString() == "ProductID") { order_obj.ProductID = Convert.ToInt32(valuearr[counter].ToString()); } counter++; } } return order_obj; }
public double Compute_Total_Price(int OrgID, int ProductID, int Quantity) { double total = 0.0; int BookObjID = 0; localhost.Service serviceObj = new localhost.Service(); localhost.Table[] Tarray = serviceObj.GetTables(OrgID); List<localhost.Table> listOfTables = new List<localhost.Table>(Tarray); for (int i = 0; i < listOfTables.Count; i++) { if (listOfTables[i].TNameProperty == "Book") { BookObjID = listOfTables[i].ObjIDProperty; } } localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(OrgID, BookObjID, ProductID); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "Cost") { double cost = Convert.ToInt32(valuearr[counter].ToString()); total = cost * Quantity; return total; } counter++; } return total; }
public int bill_to_card_displayConfirmation(int OrgID,int CustomerID,int ProductID,int Quantity,double price) { try { bool success = false; Order order_obj = new Order(); int CustomerObjID = 0; int OrderObjID = 0; localhost.Service serviceObj = new localhost.Service(); localhost.Table[] Tarray = serviceObj.GetTables(OrgID); List<localhost.Table> listOfTables = new List<localhost.Table>(Tarray); for (int i = 0; i < listOfTables.Count; i++) { if (listOfTables[i].TNameProperty == "Customer") { CustomerObjID = listOfTables[i].ObjIDProperty; } if (listOfTables[i].TNameProperty == "Order") { OrderObjID = listOfTables[i].ObjIDProperty; } } if (CustomerObjID != 0) { localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(OrgID, CustomerObjID, CustomerID); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "Ship_FirstName") { order_obj.Ship_FirstName = valuearr[counter].ToString(); } if (arr[j].ToString() == "Ship_LastName") { order_obj.Ship_LastName = valuearr[counter].ToString(); } if (arr[j].ToString() == "Ship_phone") { order_obj.Ship_phone = valuearr[counter].ToString(); } if (arr[j].ToString() == "Ship_postalcode") { order_obj.Ship_postalcode = valuearr[counter].ToString(); } if (arr[j].ToString() == "Ship_AddressLine1") { order_obj.Ship_AddressLine1 = valuearr[counter].ToString(); } if (arr[j].ToString() == "Ship_AddressLine2") { order_obj.Ship_AddressLine2 = valuearr[counter].ToString(); } counter++; } order_obj.ProductID = ProductID; order_obj.Quantity = Quantity; order_obj.OrderStatus = "Billed"; order_obj.OrderDate = DateTime.Now; order_obj.DateLastUpdated = DateTime.Now; List<String> fieldnames = new List<String>(); fieldnames.Add("0"); fieldnames.Add("1"); fieldnames.Add("2"); fieldnames.Add("3"); fieldnames.Add("4"); fieldnames.Add("5"); fieldnames.Add("6"); fieldnames.Add("7"); fieldnames.Add("8"); fieldnames.Add("9"); fieldnames.Add("10"); fieldnames.Add("11"); fieldnames.Add("12"); List<String> valueNames = new List<String>(); valueNames.Add(order_obj.ProductID.ToString()); valueNames.Add(order_obj.Quantity.ToString()); valueNames.Add(order_obj.OrderDate.ToString()); valueNames.Add(order_obj.DateLastUpdated.ToString()); valueNames.Add(order_obj.OrderStatus.ToString()); valueNames.Add(order_obj.Ship_FirstName.ToString()); valueNames.Add(order_obj.Ship_LastName.ToString()); valueNames.Add(order_obj.Ship_AddressLine1.ToString()); valueNames.Add(order_obj.Ship_AddressLine2.ToString()); valueNames.Add(order_obj.Ship_phone.ToString()); valueNames.Add(order_obj.Ship_postalcode.ToString()); valueNames.Add(order_obj.Price.ToString()); valueNames.Add(CustomerID.ToString()); int custorderID = 0; success = serviceObj.InsertData(OrgID, OrderObjID, "Order-Instance-" + OrgID.ToString(), fieldnames.ToArray(), valueNames.ToArray()); if (success) { obj = serviceObj.ReadData(OrgID, OrderObjID); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); int countRow = valuearr.Count / array.Count; counter = 0; for (int i = 0; i < countRow; i++) { for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "GUID") { custorderID = Convert.ToInt32(valuearr[counter].ToString()); } counter++; } } return custorderID; } else { return custorderID; } } else { return 0; } } catch (Exception ex) { throw; } }
private void check_if_to_proceed(string curr_methodid) { string output = ""; string inputparam_str = ""; string methodname = ""; string wsdltext = ""; Table curr_table = form1.FindControl(curr_methodid) as Table; localhost.Service serviceObj = new localhost.Service(); localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(11, 30, Int32.Parse(curr_methodid)); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "minput") { inputparam_str = valuearr[counter].ToString(); } if (arr[j].ToString() == "mname") { methodname = valuearr[counter].ToString(); } if (arr[j].ToString() == "wsdl") { wsdltext = valuearr[counter].ToString(); } counter++; } if (inputparam_str != "") { string[] inputp = inputparam_str.Split(' '); object[] param1 = new object[inputp.Length - 1]; for (int ip = 0; ip < inputp.Length - 1; ip++) { string[] p = inputp[ip].Split(':'); try { if (String.Compare(p[1].Substring(0, 6), "System.") != 0) { p[1] = "System." + p[1]; } } catch (Exception eexc) { p[1] = "System." + p[1]; } TextBox txt_box = curr_table.FindControl("arg-" + curr_methodid + "-" + ip.ToString()) as TextBox; param1[ip] = Convert.ChangeType(txt_box.Text, System.Type.GetType(p[1])); } output = InvokeMethod(wsdltext, methodname, param1); } else { output = InvokeMethod(wsdltext, methodname, null); } if (output != null) { int mapped_flag = 0; //Display result in current method result box TextBox resultbox = curr_table.FindControl("result-" + curr_methodid) as TextBox; resultbox.Text = output; //Check if we need to map the output to next method int index = Convert.ToInt32(Session["next_index"]); if (index < method_array.Length) { if (Convert.ToInt32(mapping_array[index]) != 0) { int arg = Convert.ToInt32(mapping_array[index]) - 1; TextBox next_param = curr_table.FindControl("arg-" + curr_table.ToolTip + "-" + arg.ToString()) as TextBox; next_param.Text = output; mapped_flag = 1; } Session["next_index"] = index + 1; } else { Session["next_index"] = 0; } string[] nextp = null; if (Int32.Parse(curr_table.ToolTip) > 0) { obj = serviceObj.ReadDataWithGUID(11, 30, Int32.Parse(curr_table.ToolTip)); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "minput") { inputparam_str = valuearr[counter].ToString(); } if (arr[j].ToString() == "mname") { methodname = valuearr[counter].ToString(); } if (arr[j].ToString() == "wsdl") { wsdltext = valuearr[counter].ToString(); } counter++; } } if (inputparam_str != "") { nextp = inputparam_str.Split(' '); } if (nextp != null && (nextp.Length - 1) == 1 && mapped_flag == 1) { check_if_to_proceed(curr_table.ToolTip); } else if (nextp == null && index != (method_array.Length - 1)) { check_if_to_proceed(curr_table.ToolTip); } } }
private void InvokeWorkFlow(int workflow_id) { int id = 0; int nid = 0; String method_str = null; String ip_mapping_str = null; String workflowname = null; string inputparam_str = null; //Get methods for the workflow ID localhost.Service serviceObj = new localhost.Service(); localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(11,31,workflow_id); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "wfname") { workflowname = valuearr[counter].ToString(); } if (arr[j].ToString() == "wfmethods") { method_str = valuearr[counter].ToString(); method_array = method_str.Split(','); } if (arr[j].ToString() == "wfinputs") { ip_mapping_str = valuearr[counter].ToString(); mapping_array = ip_mapping_str.Split(','); } counter++; } if (Convert.ToInt32(Session["next_index"]) == 0) { Session["next_index"] = 1; } Panel panel1 = new Panel(); panel1.Width = 520; panel1.HorizontalAlign = HorizontalAlign.Center; panel1.BackColor = System.Drawing.Color.Khaki; //panel1.BorderStyle = BorderStyle.Groove; Label wfname = new Label(); wfname.ForeColor = System.Drawing.Color.Black; wfname.Text = workflowname; wfname.Font.Bold = true; panel1.Controls.Add(wfname); form1.Controls.Add(panel1); form1.Controls.Add(new LiteralControl("<br />")); if (method_array != null) { for (int iter_methods = 0; iter_methods < method_array.Length; iter_methods++) { id = Convert.ToInt32(method_array[iter_methods]); if (iter_methods + 1 < method_array.Length) nid = Convert.ToInt32(method_array[iter_methods + 1]); else nid = 0; obj = serviceObj.ReadDataWithGUID(11, 30, id); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); counter = 0; inputparam_str = ""; panel1 = new Panel(); panel1.Width = 520; panel1.BackColor = System.Drawing.Color.Khaki; panel1.BorderStyle = BorderStyle.Dashed; panel1.HorizontalAlign = HorizontalAlign.Center; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "mname") { Label methodname = new Label(); methodname.Font.Bold = true; methodname.Text = "Webservice : " + valuearr[counter].ToString(); panel1.Controls.Add(methodname); } if (arr[j].ToString() == "minput") { inputparam_str = valuearr[counter].ToString(); } counter++; } Table methodtable = new Table(); methodtable.Width = 500; methodtable.Attributes.Add("runat", "Server"); methodtable.ID = id.ToString(); methodtable.ToolTip = nid.ToString(); TableRow tr = new TableRow(); TableCell tc = new TableCell(); methodtable.Controls.Add(tr); if (inputparam_str != "") { int arg_count = 0; string[] inputp = inputparam_str.Split(' '); for (int ip = 0; ip < inputp.Length - 1; ip++) { string[] p = inputp[ip].Split(':'); tr = new TableRow(); tr.Font.Bold = true; tr.Font.Size = 10; tc = new TableCell(); Label paramname = new Label(); paramname.Text = p[0].ToString() + ":" + p[1].ToString(); tc.Controls.Add(paramname); tr.Controls.Add(tc); tc = new TableCell(); TextBox tb = new TextBox(); tb.Attributes.Add("runat", "Server"); tb.Attributes.Add("Tooltip", p[1].ToString()); tb.EnableViewState = true; tb.MaxLength = 128; tb.ID = "arg-" + id + "-" + arg_count; tc.Controls.Add(tb); tr.Controls.Add(tc); arg_count++; methodtable.Controls.Add(tr); } } tr = new TableRow(); tr.Font.Bold = true; TableCell cell = new TableCell(); Button btn = new Button(); btn.Text = "Invoke service"; /*Would like to pass value of i as argument to myFunction*/ btn.CommandArgument = id.ToString(); btn.Command += new CommandEventHandler(processMethodRequest); cell.Controls.Add(btn); tr.Controls.Add(cell); tr.Font.Bold = true; methodtable.Controls.Add(tr); tr = new TableRow(); methodtable.Controls.Add(tr); tr = new TableRow(); tr.Font.Bold = true; tc = new TableCell(); Label result_box = new Label(); result_box.Text = "Result"; tc.Controls.Add(result_box); tr.Controls.Add(tc); tc = new TableCell(); TextBox result_str = new TextBox(); result_str.Attributes.Add("runat", "Server"); result_str.EnableViewState = true; result_str.ID = "result-" + id.ToString(); tc.Controls.Add(result_str); tr.Controls.Add(tc); methodtable.Controls.Add(tr); panel1.Controls.Add(methodtable); form1.Controls.Add(panel1); if (iter_methods + 1 < method_array.Length) { panel1 = new Panel(); panel1.Width = 520; Image image = new Image(); image.ImageUrl = "../images/arrow_solid_down.png"; image.Height = 50; image.Attributes.Add("Style", "padding-left:250px;"); panel1.Controls.Add(image); form1.Controls.Add(panel1); } } } }
protected void Page_Load(object sender, EventArgs e) { PreRender += new EventHandler(CustomizeWorkflow_PreRender); lstipTextBoxes = new List<TextBox>(); lstMethodNames = new List<TextBox>(); if (!Page.IsPostBack) { ShowServices(); } string Methods; string Inputs; string[] MethodIDs = null; string[] Input = null; #region DataSourceBinding //Get methods for the workflow ID localhost.Service serviceObj = new localhost.Service(); localhost.TenantTableInfo obj = serviceObj.ReadDataWithGUID(11, 31, Convert.ToInt32(Session["WfID"])); string[] arr = obj.FieldNamesProperty; List<string> array = new List<string>(arr); string[] values = obj.FieldValuesProperty; List<string> valuearr = new List<string>(values); int counter = 0; defaultwrkflw.WfID = Convert.ToInt32(Session["WfID"]); for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "wfname") { defaultwrkflw.WfName = valuearr[counter].ToString(); } if (arr[j].ToString() == "wfmethods") { Methods = valuearr[counter].ToString(); MethodIDs = Methods.Split(','); } if (arr[j].ToString() == "wfinputs") { Inputs = valuearr[counter].ToString(); Input = Inputs.Split(','); defaultwrkflw.Inputs = Input; } counter++; } foreach (var item in MethodIDs) { defaultwrkflw.Methods.Add(Convert.ToInt32(item)); obj = serviceObj.ReadDataWithGUID(11, 30, Int32.Parse(item)); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); counter = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "minput") { defaultwrkflw.InputParam.Add(valuearr[counter].ToString()); } if (arr[j].ToString() == "mname") { defaultwrkflw.MethodName.Add(valuearr[counter].ToString()); } if (arr[j].ToString() == "moutput") { defaultwrkflw.OutputParam.Add(valuearr[counter].ToString()); } counter++; } } obj = serviceObj.ReadData(11, 30); arr = obj.FieldNamesProperty; array = new List<string>(arr); values = obj.FieldValuesProperty; valuearr = new List<string>(values); int countRow = valuearr.Count / array.Count; counter = 0; int addrow = 0; for (int i = 0; i < countRow; i++) { AvailableServices serv = new AvailableServices(); addrow = 0; for (int j = 0; j < array.Count; j++) { if (arr[j].ToString() == "GUID") { serv.MethodId = Convert.ToInt32(valuearr[counter].ToString()); } if (arr[j].ToString() == "mname") { serv.MethodName = valuearr[counter].ToString(); } if (arr[j].ToString() == "minput") { serv.InputParam = valuearr[counter].ToString(); } if (arr[j].ToString() == "moutput") { serv.OutputParam = valuearr[counter].ToString(); } if (arr[j].ToString() == "ownerid") { if (Convert.ToInt32(valuearr[counter]) == 11 || Convert.ToInt32(valuearr[counter]) == Convert.ToInt32(Session["OrgId"])) { addrow = 1; } } counter++; } if (addrow > 0) { availservice.Add(serv); } } #endregion #region AddControls int methodcounter = 0; Panel2.Controls.Add(new LiteralControl("<br />")); Label work_label = new Label(); work_label.Text = defaultwrkflw.WfName + " Workflow Steps"; work_label.Font.Bold = true; work_label.Font.Size = 20; Panel2.Controls.Add(work_label); Panel2.Controls.Add(new LiteralControl("<br />")); Table methodtable = new Table(); methodtable.BorderStyle = BorderStyle.Solid; methodtable.BorderWidth = 5; methodtable.Font.Bold = true; methodtable.Font.Size = 10; methodtable.Attributes.Add("runat", "Server"); methodtable.ID = defaultwrkflw.Methods[methodcounter].ToString(); TableRow row = new TableHeaderRow(); var cell1 = new TableCell(); cell1.Text = "Service Name"; row.Cells.Add(cell1); cell1 = new TableCell(); cell1.Text = "Ouput Mapping"; row.Cells.Add(cell1); methodtable.Rows.Add(row); counter = 0; foreach (string item in defaultwrkflw.MethodName) { if (!item.Equals("")) { TableRow tr = new TableRow(); TableCell tc = new TableCell(); TableCell tc2 = new TableCell(); TextBox txtMethodName = new TextBox(); txtMethodName.Width = 350; txtMethodName.Text = item; TextBox txtInputParam = new TextBox(); txtInputParam.Text = defaultwrkflw.Inputs[counter++]; txtInputParam.Width = 50; lstipTextBoxes.Add(txtInputParam); lstMethodNames.Add(txtMethodName); tc.Controls.Add(txtMethodName); tc2.Controls.Add(txtInputParam); methodtable.Controls.Add(tr); tr.Controls.Add(tc); tr.Controls.Add(tc2); } } int methodcount = 10 - defaultwrkflw.MethodName.Count; while (methodcount > 0 ) { TableRow tr = new TableRow(); TableCell tc = new TableCell(); TableCell tc2 = new TableCell(); TextBox txtMethodName = new TextBox(); txtMethodName.Width = 350; txtMethodName.Text = ""; TextBox txtInputParam = new TextBox(); txtInputParam.Text = ""; txtInputParam.Width = 50; lstipTextBoxes.Add(txtInputParam); lstMethodNames.Add(txtMethodName); tc.Controls.Add(txtMethodName); tc2.Controls.Add(txtInputParam); methodtable.Controls.Add(tr); tr.Controls.Add(tc); tr.Controls.Add(tc2); methodcount--; } Panel2.Controls.Add(methodtable); #endregion }