public Boolean CreateCustomerAccount(string username, string password, string cardNumber, string streetAddress, string cityName, string zipCode, string contactNumber)
    {
        localhost.Service serviceObj = new localhost.Service();
        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");

        List<String> valueNames = new List<String>();
        valueNames.Add(username);
        valueNames.Add(password);
        valueNames.Add(cardNumber);
        valueNames.Add(streetAddress);
        valueNames.Add(cityName);
        valueNames.Add(zipCode);
        valueNames.Add(contactNumber);

        bool success = serviceObj.InsertData(11, 32, "CustomerServiceInstance", fieldnames.ToArray(), valueNames.ToArray());
        if (success)
            return true;
        else
            return false;
    }
예제 #2
0
    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;
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (ddl.SelectedIndex >= 0)
        {
            int OrgID = (int)Session["orgID"];
            int index_sel = ddl.SelectedIndex;
            List<string> fieldnames = new List<string>();
            List<string> valueNames = new List<string>();
            Label1.Visible = false;
            Label2.Visible = false;

            localhost.Service serviceObj = new localhost.Service();
            localhost.Table tableObj = listOfTables[index_sel];

            textboxes = new List<TextBox>();
            labels = new List<Label>();
            fieldlist = (List<localhost.Field>)Session["fieldlist"];
            int count = fieldlist.Count;
            Table methodtable = new Table();
            methodtable.Width = 500;
            methodtable.BorderStyle = BorderStyle.Solid;
            methodtable.BorderWidth = 5;
            methodtable.Caption = "Object Fields";
            methodtable.HorizontalAlign = HorizontalAlign.Center;

            for (int i = 0; i < count; i++)
            {
                TableRow tr = new TableRow();

                TableCell tc = new TableCell();
                Label lb = new Label();
                lb.ID = "lb" + i;
                lb.EnableViewState = true;
                lb.Text = fieldlist[i].FieldNameProperty + "::";
                labels.Add(lb);
                tc.Controls.Add(lb);

                TableCell tc2 = new TableCell();
                TextBox tb = new TextBox();
                tb.ID = "tb" + i;
                tb.EnableViewState = true;
                tb.Text = Request.Form[tb.ClientID];
                textboxes.Add(tb);
                tc2.Controls.Add(tb);

                tr.Controls.Add(tc);
                tr.Controls.Add(tc2);

                methodtable.Controls.Add(tr);

            }
            Panel1.Controls.Add(methodtable);

            if (fieldlist != null)
            {
                count = 0;
                foreach (TextBox item in textboxes)
                {
                    valueNames.Add(item.Text);
                }

                foreach (localhost.Field item in fieldlist)
                {
                    fieldnames.Add(count.ToString());
                    count++;
                }

                bool success = serviceObj.InsertData((int)Session["orgID"], tableObj.ObjIDProperty, "", fieldnames.ToArray(), valueNames.ToArray());
                if (success)
                    Label1.Visible = true;
                else
                    Label2.Visible = true;
            }
        }
    }
    private void SaveToDB(Workflow customwrkflw)
    {
        customwrkflw.WfName = txtWorkflowName.Text;

        List<String> fieldnames = new List<String>();
        fieldnames.Add("0");
        fieldnames.Add("1");
        fieldnames.Add("2");
        fieldnames.Add("3");
        List<String> valueNames = new List<String>();
        valueNames.Add(Session["OrgID"].ToString());
        valueNames.Add(customwrkflw.WfName);
        valueNames.Add(customwrkflw.WrkflwMethods);
        valueNames.Add(customwrkflw.WrkflwInputs);

        localhost.Service serviceObj = new localhost.Service();
        bool success = serviceObj.InsertData(11, 31, "Worfkflow-Instance", fieldnames.ToArray(), valueNames.ToArray());
        if (success)
        {
            Label1.Text = "Worflow added successfully";
            Label1.Visible = true;
        }
        else
        {
            Label1.Text = "Operation Unsuccessfull";
            Label1.Visible = true;
        }
    }
    private int CreateServices(string wsdl_text)
    {
        Type service;
        try
        {
            //Try Database Connection
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SAASDB"].ToString());
            try
            {
                conn.Open();
            }
            catch (Exception e)
            {
                //Return Error
                return -1;
            }

            localhost.Service serviceObj = new localhost.Service();

            //Insert into Data Table the services
            int count = 0;
            List<string> fieldnames = new List<string>();
            List<localhost.Field> fieldlist = new List<localhost.Field>();
            localhost.Field[] fields = serviceObj.ReadField(11, 30);
            fieldlist = new List<localhost.Field>(fields);
            foreach (localhost.Field item in fieldlist)
            {
                fieldnames.Add(count.ToString());
                count++;
            }

            Uri uri = new Uri(wsdl_text);
            WebRequest webRequest = WebRequest.Create(uri);
            System.IO.Stream requestStream = webRequest.GetResponse().GetResponseStream();

            // Get a WSDL file describing a service
            ServiceDescription sd = ServiceDescription.Read(requestStream);
            string sdName = sd.Services[0].Name;

            // Initialize a service description servImport
            ServiceDescriptionImporter servImport = new ServiceDescriptionImporter();
            servImport.AddServiceDescription(sd, String.Empty, String.Empty);
            servImport.ProtocolName = "Soap";
            servImport.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;

            CodeNamespace nameSpace = new CodeNamespace();
            CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
            codeCompileUnit.Namespaces.Add(nameSpace);
            // Set Warnings
            ServiceDescriptionImportWarnings warnings = servImport.Import(nameSpace, codeCompileUnit);

            if (warnings == 0)
            {
                StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.CurrentCulture);
                Microsoft.CSharp.CSharpCodeProvider prov = new Microsoft.CSharp.CSharpCodeProvider();
                prov.GenerateCodeFromNamespace(nameSpace, stringWriter, new CodeGeneratorOptions());

                // Compile the assembly with the appropriate references
                string[] assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" };
                CompilerParameters param = new CompilerParameters(assemblyReferences);
                param.GenerateExecutable = false;
                param.GenerateInMemory = true;
                param.TreatWarningsAsErrors = false;
                param.WarningLevel = 4;

                CompilerResults results = new CompilerResults(new TempFileCollection());
                results = prov.CompileAssemblyFromDom(param, codeCompileUnit);
                Assembly assembly = results.CompiledAssembly;
                service = assembly.GetType(sdName);

                string input_params = "";
                string return_type = "";

                MethodInfo[] methodInfo = service.GetMethods();

                foreach (MethodInfo t in methodInfo)
                {
                    List<string> valueNames = new List<string>();
                    if (t.Name == "Discover")
                        break;

                    input_params = "";
                    return_type = "";

                    foreach (ParameterInfo parameter in t.GetParameters())
                    {
                        //paramname.Text = "(" + temp.ParameterType.Name + "  " + temp.Name + ")";
                        input_params = input_params + parameter.Name + ":" + parameter.ParameterType.Name + " ";
                    }

                    //Get The Return type of the Service(Method)
                    return_type = t.ReturnType.ToString();

                    //Insert into Service Object(Methods Table)
                    valueNames.Add(Session["OrgID"].ToString());
                    valueNames.Add(wsdl_text);
                    valueNames.Add(t.Name);
                    valueNames.Add(input_params);
                    valueNames.Add(return_type);
                    bool success = serviceObj.InsertData(11, 30, "WSDL-Instance", fieldnames.ToArray(), valueNames.ToArray());
                    if (success == false)
                    {
                        return -1;
                    }
                }

                return 1;
            }
            else
            {
                return -1;
            }
        }
        catch (Exception ex)
        {
            return -1;
        }
    }