コード例 #1
0
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            //Search Supplier
            dataAccess data = new dataAccess();

            table = new DataTable();

            if (Search.Text.Equals("") || Search.Text.Equals(null))
            {
                MessageBox.Show("Search Field is Empty , Enter the Search Field Value");
            }
            else
            {
                table = data.getSupplier(int.Parse(Search.Text));
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        SupplierID.Text  = row["SupplierID"].ToString();
                        CompanyName.Text = row["CompanyName"].ToString();
                        Address.Text     = row["Address"].ToString();
                        City.Text        = row["City"].ToString();
                        Region.Text      = row["Region"].ToString();
                        Postal.Text      = row["PostalCode"].ToString();
                        Country.Text     = row["Country"].ToString();
                        Email.Text       = row["Email"].ToString();
                        Phone.Text       = row["Phone"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show("Employee Not Found !!");
                }
            }
        }
コード例 #2
0
        private void SuppEdit_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data = new dataAccess();
            suppliers  supp = new suppliers();

            if (SupplierID.Text == "" || CompanyName.Text == "" || Address.Text == "" || City.Text == "" || Region.Text == "" ||
                Postal.Text == "" || Country.Text == "" || Email.Text == "" || Phone.Text == "")
            {
                MessageBox.Show("All Fields are required");
            }
            else
            {
                supp.Address     = Address.Text;
                supp.City        = City.Text;
                supp.CompanyName = CompanyName.Text;
                supp.Country     = Country.Text;
                supp.Email       = Email.Text;
                supp.Phone       = long.Parse(Phone.Text);
                supp.PostalCode  = int.Parse(Postal.Text);
                supp.Region      = Region.Text;
                supp.SupplierID  = int.Parse(SupplierID.Text);

                data.editSuppliers(supp);
                MessageBox.Show("Suppliers" + supp.CompanyName + " Modified Successfully");
            }
        }
コード例 #3
0
        protected string popExperience(string experience)
        {
            dataAccess database = new dataAccess();
            DataTable  expTbl   = database.getTable("SELECT * FROM jobsdb_Experience");

            int arraySize = expTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlWorkExperience.Items.Clear();
            ddlWorkExperience.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Select Experience";
            item[0].Value = "";
            ddlWorkExperience.Items.Add(item[0]);
            for (int i = 0; i < expTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = expTbl.Rows[i]["Years"].ToString() + " years";
                item[i + 1].Value = expTbl.Rows[i]["Years"].ToString();
                ddlWorkExperience.Items.Add(item[i + 1]);
            }
            return(experience);
        }
コード例 #4
0
        public static string GetCredentialSelector()
        {
            dataAccess dc   = new dataAccess();
            string     sSql = null;
            string     sErr = null;

            StringBuilder sb = new StringBuilder();

            // return either the shared sShared==0  which include descriptions
            // or local sShared==1 just the username


            sSql = "select credential_id, username, domain, shared_cred_desc from asset_credential where shared_or_local = 0 order by username";
            DataTable dt = new DataTable();

            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                return(sErr);
            }
            else
            {
                sb.Append("<table id='tblCredentialSelector' width='99%'><thead><tr><th class='col_header'>Username</th><th class='col_header'>Domain</th><th class='col_header'>Description</th></th></thead><tbody>");

                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("<tr class='select_credential' credential_id='" + dr["credential_id"].ToString() + "'><td tag='selectablecrd' class='row'>" + dr["username"].ToString() + "</td><td tag='selectablecrd' class='row'>" + dr["domain"].ToString() + "</td><td class='row'>" + dr["shared_cred_desc"].ToString() + "</td></tr>");
                }
            }
            sb.Append("</tbody></table>");



            return(sb.ToString());
        }
コード例 #5
0
        protected string popEducation(string education)
        {
            dataAccess database = new dataAccess();
            DataTable  eduTbl   = database.getTable("SELECT * FROM jobsdb_Education");

            int arraySize = eduTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlEducation.Items.Clear();
            ddlEducation.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Select Education Level";
            item[0].Value = "";
            ddlEducation.Items.Add(item[0]);
            for (int i = 0; i < eduTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = eduTbl.Rows[i]["EducationLevel"].ToString();
                item[i + 1].Value = eduTbl.Rows[i]["ID"].ToString();
                ddlEducation.Items.Add(item[i + 1]);
            }
            return(education);
        }
コード例 #6
0
        protected string popCountry(string countryID, string country)
        {
            dataAccess database   = new dataAccess();
            DataTable  countryTbl = database.getTable("SELECT * FROM jobsdb_Country ORDER BY Country");

            int arraySize = countryTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlCountry.Items.Clear();
            ddlCountry.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Select Country";
            item[0].Value = "";
            ddlCountry.Items.Add(item[0]);
            for (int i = 0; i < countryTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = countryTbl.Rows[i]["Country"].ToString();
                item[i + 1].Value = countryTbl.Rows[i]["ID"].ToString();
                ddlCountry.Items.Add(item[i + 1]);
            }
            if (country != "Zambia")
            {
                ddlLocation.Enabled = false;
                ddlRegion.Enabled   = false;
            }
            return(countryID);
        }
コード例 #7
0
        protected string popNationality(string nationality)
        {
            dataAccess database = new dataAccess();
            DataTable  natTbl   = database.getTable("SELECT * FROM jobsdb_Nationality");

            int arraySize = natTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlNationality.Items.Clear();
            ddlNationality.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Select Nationality";
            item[0].Value = "";
            ddlNationality.Items.Add(item[0]);
            for (int i = 0; i < natTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = natTbl.Rows[i]["Nationality"].ToString();
                item[i + 1].Value = natTbl.Rows[i]["ID"].ToString();
                ddlNationality.Items.Add(item[i + 1]);
            }
            return(nationality);
        }
コード例 #8
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            bool       flag         = false;
            Format     format       = new Format();
            dataAccess database     = new dataAccess();
            string     updateString = "UPDATE jobsdb_JobSeeker SET FirstName = '" + format.capitalizeStart(txtFName.Text.ToString()) +
                                      "', LastName = '" + format.capitalizeStart(txtLName.Text.ToString()) +
                                      "', Country ='" + ddlCountry.SelectedValue +
                                      "', Region ='" + ddlRegion.SelectedValue +
                                      "', Location ='" + ddlLocation.SelectedValue +
                                      "', ContactNumber ='" + txtContactNumber.Text.ToString() +
                                      "', Nationality ='" + ddlNationality.SelectedValue.ToString() +
                                      "', ID_Passport ='" + txtIDPassport.Text.ToString() +
                                      "', JobCategory ='" + ddlDesiredCategory.SelectedValue.ToString() +
                                      "', Experience ='" + ddlWorkExperience.SelectedValue.ToString() +
                                      "', Education ='" + ddlEducation.SelectedValue.ToString() +
                                      "', Status ='" + ddlStatus.SelectedValue.ToString() +
                                      "' WHERE (Email = '" + User.Identity.Name + "')";

            flag = database.updateData(updateString);
            if (flag)
            {
                lblMessage.Text      = "Successfully updated details";
                lblMessage.ForeColor = System.Drawing.Color.Green;
                LoadLabels();
            }
            else
            {
                lblMessage.Text      = "Failed to update details";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
コード例 #9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data = new dataAccess();

            if (username.Text == "" || password.Password.ToString() == "")
            {
                MessageBox.Show("Enter Fields");
            }
            else
            {
                string status = data.GetLogin(username.Text, password.Password.ToString());
                user = username.Text;

                if (status.Equals("Supervisor"))
                {
                    supervisor spv = new supervisor();
                    spv.ShowDialog();
                    Window.GetWindow(this).Close();
                }
                else if (status.Equals("Admin"))
                {
                    Application.Current.Windows.OfType <MainWindow>().FirstOrDefault().Content = new AdminOptions();
                }
                else if (status.Equals("Cashier"))
                {
                    Application.Current.Windows.OfType <MainWindow>().FirstOrDefault().Content = new SalePage();
                }
                else if (status.Equals("NotFound"))
                {
                    MessageBox.Show("Unrecorgnized Username or Password !! , Contact your administrator");
                }
            }
        }
コード例 #10
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {

            if (ProductID.Text == "" || ProductName.Text == "" || QuantityPerUnit.Text == "" || CategoryID.Text == "" ||
                UnitPrice.Text == "" || UnitInStock.Text == "" || ReorderLevel.Text == "" || SupplierID.Text == "" ||
                Discontinued.Text == "")
            {
                MessageBox.Show("All Fields are required to be filled");
            }
            else
            {
                dataAccess data = new dataAccess();
                products prod = new products();
                prod.BarCode = long.Parse(ProductID.Text);
                prod.ProductName = ProductName.Text;
                prod.QuantityPerUnit = int.Parse(QuantityPerUnit.Text);
                prod.ReorderLevel = int.Parse(ReorderLevel.Text);
                prod.UnitInStock = int.Parse(UnitInStock.Text);
                prod.UnitPrice = double.Parse(UnitPrice.Text);
                prod.Discontinued = Discontinued.Text;

                data.editProducts(prod);
                MessageBox.Show("Product " + prod.ProductName + " Modified Successfully");
            }
        }
コード例 #11
0
        public static string LoadDomain(string sDomain)
        {
            dataAccess dc       = new dataAccess();
            string     sSql     = null;
            string     sErr     = null;
            string     sAddress = "";

            sSql = "select address " +
                   "from ldap_domain " +
                   "where ldap_domain = '" + sDomain + "'";

            StringBuilder sbAssetValues = new StringBuilder();

            if (!dc.sqlGetSingleString(ref sAddress, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (sAddress != "")
                {
                    // Return the asset object as a JSON
                    sbAssetValues.Append("{");
                    sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sDomain", sDomain);
                    sbAssetValues.AppendFormat("\"{0}\" : \"{1}\"", "sAddress", sAddress);
                    sbAssetValues.Append("}");
                }
                else
                {
                    sbAssetValues.Append("{}");
                }
            }

            return(sbAssetValues.ToString());
        }
コード例 #12
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //empSearch
            dataAccess data = new dataAccess();

            table = new DataTable();

            if (Search.Text == "" || Search.Text == null)
            {
                MessageBox.Show("Search Field required");
            }
            else
            {
                table = data.getEmployee(int.Parse(Search.Text));
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        EmployeeNumber.Text = row["EmployeeNumber"].ToString();
                        EmployeeName.Text   = row["EmployeeName"].ToString();
                        EmployeeID.Text     = row["EmployeeID"].ToString();
                        Address.Text        = row["Address"].ToString();
                        Email.Text          = row["Email"].ToString();
                        PositionID.Text     = row["PositionID"].ToString();
                        Username.Text       = row["Username"].ToString();
                        Password.Password   = row["Password"].ToString();
                        ReportTo.Text       = row["ReportTo"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show("Employee Not Found !!");
                }
            }
        }
コード例 #13
0
        protected string popRegion(string region)
        {
            dataAccess database = new dataAccess();
            DataTable  RegTbl   = null;

            if (region != "" || region != string.Empty)
            {
                RegTbl = database.getTable("SELECT * FROM jobsdb_Region ORDER BY Region");
            }
            else
            {
                RegTbl = database.getTable("SELECT * FROM jobsdb_Region");
                region = "";
            }

            int arraySize = RegTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlRegion.Items.Clear();
            ddlRegion.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Any Region";
            item[0].Value = "";
            ddlRegion.Items.Add(item[0]);
            for (int i = 0; i < RegTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = RegTbl.Rows[i]["Region"].ToString();
                item[i + 1].Value = RegTbl.Rows[i]["ID"].ToString();
                ddlRegion.Items.Add(item[i + 1]);
            }
            return(region);
        }
コード例 #14
0
        public static bool UserHasHistory(string sUserID)
        {
            dataAccess dc       = new dataAccess();
            string     sSql     = "";
            string     sErr     = "";
            int        iResults = 0;

            // history in user_session.
            sSql = "select count(*) from user_session where user_id = '" + sUserID + "'";
            if (!dc.sqlGetSingleInteger(ref iResults, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            if (iResults > 0)
            {
                return(true);
            }

            // history in user_security_log
            sSql = "select count(*) from user_security_log where user_id = '" + sUserID + "'";
            if (!dc.sqlGetSingleInteger(ref iResults, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            if (iResults > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #15
0
        protected string popLocation(string location, string regionID)
        {
            dataAccess Location = new dataAccess();
            DataTable  LocTbl   = Location.getTable("SELECT * FROM jobsdb_Location WHERE Region = '" + regionID + "' ORDER BY Location");

            int arraySize = LocTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlLocation.Items.Clear();
            ddlLocation.Enabled = true;
            ddlRegion.Enabled   = true;
            //rfvLocation.Enabled = true;


            //Populate ddlLocation with locations from jobsdb_Location specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Any Location";
            item[0].Value = "";
            ddlLocation.Items.Add(item[0]);
            for (int i = 0; i < LocTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = LocTbl.Rows[i]["Location"].ToString();
                item[i + 1].Value = LocTbl.Rows[i]["ID"].ToString();
                ddlLocation.Items.Add(item[i + 1]);
            }
            return(location);
        }
コード例 #16
0
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data  = new dataAccess();
            categories cat   = new categories();
            DataTable  table = new DataTable();

            if (Search.Text == null || Search.Text == "")
            {
                MessageBox.Show("Category Number required");
            }
            else
            {
                cat.CategoryID = int.Parse(Search.Text);
                table          = data.getCategory(cat);

                if (table.Rows.Count < 0)
                {
                    MessageBox.Show("Your Searched Category type does not exist !!");
                }
                else
                {
                    foreach (DataRow row in table.Rows)
                    {
                        CategoryNumber.Text      = row["CategoryID"].ToString();
                        CategoryName.Text        = row["CategoryName"].ToString();
                        CategoryDescription.Text = row["Description"].ToString();
                    }
                }
            }
        }
コード例 #17
0
        private void EmpEdit_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data = new dataAccess();
            employees  emp  = new employees();

            if (EmployeeNumber.Text == "")
            {
                MessageBox.Show("Cannot Edit without employee number");
            }
            else if (EmployeeNumber.Text == "" || EmployeeID.Text == "" || EmployeeName.Text == "" || Email.Text == "" ||
                     Address.Text == "" || ReportTo.Text == "" || Username.Text == "" || PositionID.Text == "" ||
                     Password.Password.ToString() == "")
            {
                MessageBox.Show("All Fields are required to be filled");
            }
            else
            {
                emp.EmployeeID     = long.Parse(EmployeeID.Text);
                emp.EmployeeNumber = int.Parse(EmployeeNumber.Text);
                emp.EmployeeName   = EmployeeName.Text;
                emp.Address        = Address.Text;
                emp.Email          = Email.Text;
                emp.Username       = Username.Text;
                emp.Password       = Password.Password.ToString();
                emp.PositionID     = int.Parse(PositionID.Text);
                emp.ReportTo       = ReportTo.Text;

                data.editEmployee(emp);
                MessageBox.Show("Employee Editted");
            }
        }
コード例 #18
0
        protected void btnExtendAdvert_Click(object sender, EventArgs e)
        {
            dataAccess database   = new dataAccess();
            advertiser post       = new advertiser();
            string     totalUnits = post.GetUnitCountByEmail(User.Identity.Name);

            int    unitAmount = 0;
            double addDate    = 0;

            if (ddlAdvertLength.SelectedValue.ToString() == "15")
            {
                addDate    = 15;
                unitAmount = 1;
            }
            else if (ddlAdvertLength.SelectedValue.ToString() == "30")
            {
                addDate    = 30;
                unitAmount = 2;
            }
            DateTime expiryDate = post.GetExpireDateByJobPostID(GridView1.SelectedValue.ToString());

            bool flag = post.DepleteUnitsByEmail(unitAmount, User.Identity.Name);

            //Redirect user to success page
            if (flag)
            {
                database.updateData("UPDATE jobsdb_JobPost SET ExpireDate ='" + string.Format("{0:yyyy/MM/dd}", expiryDate.AddDays(addDate)) + "' WHERE ID='" + GridView1.SelectedValue.ToString() + "'");
                Response.Redirect("PostSuccessfull.aspx?PostID=" + GridView1.SelectedValue.ToString() + "&type=e&amt=" + unitAmount.ToString() + "&units=" + totalUnits);
            }
            else
            {
                Response.Redirect("PostFailed.aspx");
            }
        }
コード例 #19
0
        public static string DeleteKeyPair(string sKeypairID)
        {
            dataAccess dc   = new dataAccess();
            string     sSQL = null;
            string     sErr = "";

            try
            {
                sSQL = "delete from cloud_account_keypair where keypair_id = '" + sKeypairID + "'";
                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                if (sErr != "")
                {
                    throw new Exception(sErr);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return("");
        }
コード例 #20
0
ファイル: EditDetails.aspx.cs プロジェクト: jsquare89/zamjobs
        protected string popCategory(string advertiserCategory)
        {
            dataAccess database = new dataAccess();
            DataTable  CatTbl   = database.getTable("SELECT * FROM jobsdb_JobCategory ORDER BY Category");

            int arraySize = CatTbl.Rows.Count + 1;

            ListItem[] item = new ListItem[arraySize];
            ddlCategory.Items.Clear();
            ddlCategory.Enabled = true;

            //Populate ddlRegion with Regions from jobsdb_Region specific to the Region
            item[0]       = new ListItem();
            item[0].Text  = "Select Category";
            item[0].Value = "";
            ddlCategory.Items.Add(item[0]);
            for (int i = 0; i < CatTbl.Rows.Count; i++)
            {
                item[i + 1]       = new ListItem();
                item[i + 1].Text  = CatTbl.Rows[i]["Category"].ToString();
                item[i + 1].Value = CatTbl.Rows[i]["ID"].ToString();
                ddlCategory.Items.Add(item[i + 1]);
            }
            return(advertiserCategory);
        }
コード例 #21
0
        private void Search_Click(object sender, RoutedEventArgs e)
        {

            dataAccess data = new dataAccess();
            table = new DataTable();

            if (Search.Text == "" || Search.Text == null)
            {
                MessageBox.Show("Search Field required");
            }
            else
            {
                table = data.getThatProduct(long.Parse(Search.Text));
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        ProductID.Text = row["BarCode"].ToString();
                        ProductName.Text = row["ProductName"].ToString();
                        QuantityPerUnit.Text = row["QuantityPerUnit"].ToString();
                        CategoryID.Text = row["CategoryID"].ToString();
                        UnitPrice.Text = row["UnitPrice"].ToString();
                        UnitInStock.Text = row["UnitInStock"].ToString();
                        ReorderLevel.Text = row["ReorderLevel"].ToString();
                        SupplierID.Text = row["SupplierID"].ToString();
                        Discontinued.Text = row["Discontinued"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show("Product Not Found !!");
                }
            }
        }
コード例 #22
0
        public static string LoadAccount(string sID)
        {
            dataAccess dc   = new dataAccess();
            string     sSql = null;
            string     sErr = null;

            string sAccountName   = null;
            string sAccountNumber = null;
            string sProvider      = null;
            string sIsDefault     = null;
            string sAutoManage    = null;
            string sLoginID       = null;
            string sLoginPassword = null;


            sSql = "select account_id, account_name, account_number, provider, login_id, is_default, auto_manage_security" +
                   " from cloud_account where account_id = '" + sID + "'";

            StringBuilder sb = new StringBuilder();
            DataRow       dr = null;

            if (!dc.sqlGetDataRow(ref dr, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (dr != null)
                {
                    sAccountName   = (object.ReferenceEquals(dr["account_name"], DBNull.Value) ? "" : dr["account_name"].ToString());
                    sAccountNumber = (object.ReferenceEquals(dr["account_number"], DBNull.Value) ? "" : dr["account_number"].ToString());
                    sProvider      = (object.ReferenceEquals(dr["provider"], DBNull.Value) ? "" : dr["provider"].ToString());
                    sIsDefault     = (object.ReferenceEquals(dr["is_default"], DBNull.Value) ? "0" : (dc.IsTrue(dr["is_default"].ToString()) ? "1" : "0"));
                    sAutoManage    = (object.ReferenceEquals(dr["auto_manage_security"], DBNull.Value) ? "" : dr["auto_manage_security"].ToString());
                    sLoginID       = (object.ReferenceEquals(dr["login_id"], DBNull.Value) ? "" : dr["login_id"].ToString());
                    sLoginPassword = "******";

                    // Return the object as a JSON

                    sb.Append("{");
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountName", sAccountName);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountNumber", sAccountNumber);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sProvider", sProvider);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sIsDefault", sIsDefault);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAutoManage", sAutoManage);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sLoginID", sLoginID);
                    sb.AppendFormat("\"{0}\" : \"{1}\"", "sLoginPassword", sLoginPassword);
                    sb.Append("}");
                }
                else
                {
                    sb.Append("{}");
                }
            }

            return(sb.ToString());
        }
コード例 #23
0
        public DangNhapBAL(string datasource, string uid, string pwd)
        {
            dao = new dataAccess();

            this.uid = uid;
            this.pwd = pwd;

            isLogined = CheckLogin(datasource, uid, pwd);
        }
コード例 #24
0
        public static string DeleteAccounts(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui   = new acUI.acUI();
            string    sSql = null;
            string    sErr = "";

            if (sDeleteArray.Length < 36)
            {
                return("");
            }

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();

            // get a list of ids that will be deleted for the log
            sSql = "select account_id, account_name, provider, login_id from cloud_account where account_id in (" + sDeleteArray + ")";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                sSql = "delete from cloud_account where account_id in (" + sDeleteArray + ")";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.CloudAccount, dr["account_id"].ToString(), dr["account_name"].ToString(), dr["provider"].ToString() + " Account for LoginID [" + dr["login_id"].ToString() + "] Deleted");
            }

            return(sErr);
        }
コード例 #25
0
        public static string DeleteCredentials(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui   = new acUI.acUI();
            string    sSql = null;
            string    sErr = "";

            if (sDeleteArray.Length < 36)
            {
                return("");
            }

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();

            // get a list of credential_ids that will be deleted for the log
            sSql = "select credential_name,credential_id from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                   "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }


            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                //delete asset_credential
                sSql = "delete from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                       "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.Credential, dr["credential_id"].ToString(), dr["credential_name"].ToString(), "Credential Deleted");
            }


            return(sErr);
        }
コード例 #26
0
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            dataAccess database     = new dataAccess();
            advertiser purchaseUnts = new advertiser();
            Int64      ID           = 0;
            string     insertString = "INSERT INTO jobsdb_UnitOrder (Employer, UnitQty, UnitAmount, Date, Paid, Credited, Active) VALUES ('" + purchaseUnts.getCompanyID(User.Identity.Name) +
                                      "','" + txtTotalUnits.Text.ToString() + "','" + unitAmount + "',GETDATE(),'N','N','Y'); SELECT SCOPE_IDENTITY()";

            ID = database.insertData_ReturnID(insertString);

            Response.Redirect("Order.aspx?OrderID=" + ID);
        }
コード例 #27
0
ファイル: cloudEdit.aspx.cs プロジェクト: you8/cato
        public static string DeleteClouds(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of ids that will be deleted for the log
            sSql = "select cloud_id, cloud_name, provider from clouds where cloud_id in (" + sDeleteArray + ")";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
                throw new Exception(sErr);

            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                sSql = "delete from clouds where cloud_id in (" + sDeleteArray + ")";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                    throw new Exception(sErr);

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            //reget the cloud providers class in the session
            ui.SetCloudProviders(ref sErr);
            if (!string.IsNullOrEmpty(sErr))
                throw new Exception("Error: Unable to load Cloud Providers XML." + sErr);

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.Cloud, dr["cloud_id"].ToString(), dr["cloud_name"].ToString(), dr["provider"].ToString() + " Cloud Deleted.");
            }

            return sErr;
        }
コード例 #28
0
ファイル: CreateAdmin.aspx.cs プロジェクト: jsquare89/zamjobs
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            dataAccess database = new dataAccess();
            Format     format   = new Format();
            DataTable  dt       = database.getTable("SELECT Email from aspnet_Membership WHERE Email = '" + txtEmail.Text.ToLower() + "'");

            if (dt.Rows.Count == 0) // Check for existing email in database. If not zero email exists. Display invalid email
            {
                bool   flag       = false;
                string fname      = format.capitalizeStart(txtFName.Text.ToString());
                string lname      = format.capitalizeStart(txtLName.Text.ToString());
                string contactNum = txtContactNum.Text.ToString();
                string passportID = txtPassportID.Text.ToString();
                string email      = txtEmail.Text.ToString();
                string address    = txtPhysicalAddress.Text.ToString();
                string password   = txtPassword.Text.ToString();


                string insertString = "INSERT INTO jobsdb_Administrator (FirstName, LastName, ContactNumber,Email, PhysicalAddress, PassportID, Active) VALUES ('" + fname + "','" + lname + "','" + contactNum + "','" + email + "','" + address + "','" + passportID + "','True')";
                try
                {
                    flag = database.insertData(insertString);
                    if (flag)
                    {
                        //Creste user with Email and Password given
                        Membership.CreateUser(email, password, email);

                        //Assign user admin role
                        Roles.AddUserToRole(email, ConfigurationSettings.AppSettings["AdminRoleName"]);
                    }
                }
                catch (Exception)
                {
                }

                if (flag)
                {
                    Response.Redirect("RegistrationSuccessful.aspx");
                }
                else
                {
                    Response.Redirect("RegistrationUnsuccessful.aspx");
                }
            }
            else
            {
                lblMessage.Text      = "Email already exists. Please use another";
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
コード例 #29
0
        public static string DeleteCredentials(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of credential_ids that will be deleted for the log
            sSql = "select credential_name,credential_id from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                    "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            try
            {

                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                //delete asset_credential
                sSql = "delete from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                        "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.Credential, dr["credential_id"].ToString(), dr["credential_name"].ToString(), "Credential Deleted");
            }

            return sErr;
        }
コード例 #30
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data  = new dataAccess();
            DataTable  table = new DataTable();

            table = data.getInvoices();
            if (table.Rows.Count < 0)
            {
                MessageBox.Show("History");
            }
            else
            {
                historyGrid.ItemsSource = table.DefaultView;
            }
        }
コード例 #31
0
        public string GetEducation(string education)
        {
            string educationName = "";

            if (education != "" && education != null)
            {
                dataAccess database = new dataAccess();
                DataTable  conTbl   = database.getTable("SELECT EducationLevel FROM jobsdb_Education WHERE ID='" + education + "'");
                educationName = conTbl.Rows[0]["EducationLevel"].ToString();
            }
            else
            {
                educationName = "Any Education";
            }
            return(educationName);
        }
コード例 #32
0
 public void displayAdvertiserLogo()
 {
     try
     {
         dataAccess            database    = new dataAccess();
         string                queryString = Request.QueryString["imageID"].ToString();
         System.Data.DataTable logos       = database.getTable("SELECT Logo FROM jobsdb_Employer Where ID='" + queryString + "'");
         Byte[]                buffer      = (Byte[])logos.Rows[0]["logo"];
         Response.Clear();
         Response.ContentType = "Image/jpeg";
         Response.BinaryWrite(buffer);
     }
     catch (NullReferenceException)
     {
     }
 }
コード例 #33
0
        public static string DeleteAccounts(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of ids that will be deleted for the log
            sSql = "select account_id, account_name, provider, login_id from cloud_account where account_id in (" + sDeleteArray + ")";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
                throw new Exception(sErr);

            try
            {

                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                sSql = "delete from cloud_account where account_id in (" + sDeleteArray + ")";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                    throw new Exception(sErr);

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.CloudAccount, dr["account_id"].ToString(), dr["account_name"].ToString(), dr["provider"].ToString() + " Account for LoginID [" + dr["login_id"].ToString() + "] Deleted");
            }

            return sErr;
        }
コード例 #34
0
        public XDocument GetRegistry(string sObjectID, ref string sErr)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sXML = "";

                string sSQL = "select registry_xml from object_registry where object_id = '" + sObjectID + "'";
                if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
                    throw new Exception("Error: Could not look up Registry XML." + sErr);

               if (!string.IsNullOrEmpty(sXML))
                {
                    XDocument xd = XDocument.Parse(sXML);
                    if (xd == null)
                    {
                        throw new Exception("Error: Unable to parse XML.");
                    }

                    return xd;
                }
                else
                {
                    //if the object_id is a guid, it's an object registry... add one if it's not there.
                    if (ui.IsGUID(sObjectID))
                    {
                        sSQL = "insert into object_registry values ('" + sObjectID + "', '<registry />')";
                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                            throw new Exception("Error: Could not create Registry." + sErr);

                        XDocument xd = XDocument.Parse("<registry />");
                        return xd;
                    }
                    else
                        throw new Exception("Error: Could not look up Registry XML.");

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #35
0
        public void wmSaveTaskUserSetting(string sTaskID, string sSettingKey, string sSettingValue)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {
                    //1) get the settings
                    //2) update/add the appropriate value
                    //3) update the settings to the db

                    string sSettingXML = "";
                    string sErr = "";
                    string sSQL = "select settings_xml from users where user_id = '" + sUserID + "'";

                    if (!dc.sqlGetSingleString(ref sSettingXML, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to get settings for user." + sErr);
                    }

                    if (sSettingXML == "")
                        sSettingXML = "<settings><debug><tasks></tasks></debug></settings>";

                    XDocument xDoc = XDocument.Parse(sSettingXML);
                    if (xDoc == null) throw new Exception("XML settings data for user is invalid.");

                    //we have to analyze the doc and see if the appropriate section exists.
                    //if not, we need to construct it
                    if (xDoc.Element("settings").Descendants("debug").Count() == 0)
                        xDoc.Element("settings").Add(new XElement("debug"));

                    if (xDoc.Element("settings").Element("debug").Descendants("tasks").Count() == 0)
                        xDoc.Element("settings").Element("debug").Add(new XElement("tasks"));

                    XElement xTasks = xDoc.Element("settings").Element("debug").Element("tasks");

                    //to search by attribute we must get back an array and we shouldn't have an array anyway
                    //so to be safe and clean, delete all matches and just add back the one we want
                    xTasks.Descendants("task").Where(
                        x => (string)x.Attribute("task_id") == sTaskID).Remove();

                    //add it
                    XElement xTask = new XElement("task");
                    xTask.Add(new XAttribute("task_id", sTaskID));
                    xTask.Add(new XAttribute(sSettingKey, sSettingValue));

                    xTasks.Add(xTask);

                    sSQL = "update users set settings_xml = '" + xDoc.ToString(SaveOptions.DisableFormatting) + "'" +
                        " where user_id = '" + sUserID + "'";
                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    {
                        throw new Exception("Unable to save Task User Setting." + sErr);
                    }

                    return;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task [" + sTaskID + "] or unable to get current user.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #36
0
        public static string SaveAccount(string sMode, string sAccountID, string sAccountName, string sAccountNumber, string sProvider, 
			string sLoginID, string sLoginPassword, string sLoginPasswordConfirm, string sIsDefault, string sAutoManageSecurity)
        {
            // for logging
            string sOriginalName = "";

            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = "";
            string sErr = "";

            //if we are editing get the original values
            if (sMode == "edit")
            {
            }

            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                // update the user fields.
                if (sMode == "edit")
                {
                    sSql = "select account_name from cloud_account " +
                           "where account_id = '" + sAccountID + "'";
                    if (!dc.sqlGetSingleString(ref sOriginalName, sSql, ref sErr))
                        throw new Exception("Error getting original account name:" + sErr);

                    // only update the passwword if it has changed
                    string sNewPassword = "";
                    if (sLoginPassword != "($%#d@x!&")
                    {
                        sNewPassword = "******" + dc.EnCrypt(sLoginPassword) + "'";
                    }

                    sSql = "update cloud_account set" +
                        " account_name = '" + sAccountName + "'," +
                        " account_number = '" + sAccountNumber + "'," +
                        " provider = '" + sProvider + "'," +
                        " is_default = '" + sIsDefault + "'," +
                        " auto_manage_security = '" + sAutoManageSecurity + "'," +
                        " login_id = '" + sLoginID + "'" +
                        sNewPassword +
                        " where account_id = '" + sAccountID + "'";

                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception("Error updating account: " + sErr);

                    ui.WriteObjectChangeLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, sOriginalName, sAccountName);}
                else
                {
                    //now, for some reason we were having issues with the initial startup of apache
                    //not able to perform the very first database hit.
                    //this line serves as an inital db hit, but we aren't trapping it or showing the error
                    dc.TestDBConnection(ref sErr);

                    //if there are no rows yet, make this one the default even if the box isn't checked.
                    if (sIsDefault == "0")
                    {
                        int iExists = -1;

                        sSql = "select count(*) as cnt from cloud_account";
                        if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                        {
                            System.Threading.Thread.Sleep(300);
                            if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                            {
                                System.Threading.Thread.Sleep(300);
                                if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
                                    throw new Exception("Unable to count Cloud Accounts: " + sErr);
                            }
                        }

                        if (iExists == 0)
                            sIsDefault = "1";
                    }

                    sAccountID = ui.NewGUID();
                    sSql = "insert into cloud_account (account_id, account_name, account_number, provider, is_default, login_id, login_password, auto_manage_security)" +
                    " values ('" + sAccountID + "'," +
                    "'" + sAccountName + "'," +
                    "'" + sAccountNumber + "'," +
                    "'" + sProvider + "'," +
                    "'" + sIsDefault + "'," +
                    "'" + sLoginID + "'," +
                    "'" + dc.EnCrypt(sLoginPassword) + "'," +
                    "'" + sAutoManageSecurity + "')";

                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception("Error creating account: " + sErr);

                    ui.WriteObjectAddLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, "Account Created");
                }

                //if "default" was selected, unset all the others
                if (dc.IsTrue(sIsDefault))
                {
                    oTrans.Command.CommandText = "update cloud_account set is_default = 0 where account_id <> '" + sAccountID + "'";
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception("Error updating defaults: " + sErr);
                }

                oTrans.Commit();

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                    throw new Exception("Error refreshing accounts in session: " + sErr);
            }
            catch (Exception ex)
            {
                throw new Exception("Error: General Exception: " + ex.Message);
            }

            // no errors to here, so return an empty string
            return "{'account_id':'" + sAccountID + "', 'account_name':'" + sAccountName + "', 'provider':'" + sProvider + "'}";
        }
コード例 #37
0
        public string wmRerunTask(int iInstanceID, string sClearLog)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (iInstanceID > 0 && ui.IsGUID(sUserID))
                {

                    string sInstance = "";
                    string sErr = "";
                    string sSQL = "";

                    if (dc.IsTrue(sClearLog))
                    {
                        sSQL = "delete from task_instance_log" +
                            " where task_instance = '" + iInstanceID.ToString() + "'";

                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        {
                            throw new Exception("Unable to clear task instance log for [" + iInstanceID.ToString() + "]." + sErr);
                        }
                    }
                    sSQL = "update task_instance set task_status = 'Submitted'," +
                        " submitted_by = '" + sUserID + "'" +
                        " where task_instance = '" + iInstanceID.ToString() + "'";

                    if (!dc.sqlGetSingleString(ref sInstance, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to rerun task instance [" + iInstanceID.ToString() + "]." + sErr);
                    }

                    return sInstance;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task instance [" + iInstanceID.ToString() + "]");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #38
0
        public string wmDeleteTaskParam(string sType, string sID, string sParamID)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();

            string sErr = "";
            string sSQL = "";
            string sTable = "";

            if (sType == "ecosystem")
                sTable = "ecosystem";
            else if (sType == "task")
                sTable = "task";

            if (!string.IsNullOrEmpty(sParamID) && ui.IsGUID(sID))
            {
                // need the name and values for logging
                string sXML = "";

                sSQL = "select parameter_xml" +
                    " from " + sTable +
                    " where " + sType + "_id = '" + sID + "'";

                if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
                    throw new Exception("Unable to get parameter_xml.  " + sErr);

                if (sXML != "")
                {
                    XDocument xd = XDocument.Parse(sXML);
                    if (xd == null) throw new Exception("XML parameter data is invalid.");

                    XElement xName = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/name");
                    string sName = (xName == null ? "" : xName.Value);
                    XElement xValues = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/values");
                    string sValues = (xValues == null ? "" : xValues.ToString());

                    // add security log
                    ui.WriteObjectDeleteLog(Globals.acObjectTypes.Parameter, "", sID, "");

                    if (sType == "task") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sID, "Deleted Parameter:[" + sName + "]", sValues); };
                    if (sType == "ecosystem") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Ecosystem, sID, "Deleted Parameter:[" + sName + "]", sValues); };
                }

                //do the whack
                ft.RemoveNodeFromXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", "//parameter[@id = \"" + sParamID + "\"]");

                return "";
            }
            else
            {
                throw new Exception("Invalid or missing Task or Parameter ID.");
            }
        }
コード例 #39
0
        public static string GetKeyPairs(string sID)
        {
            dataAccess dc = new dataAccess();
            string sSql = null;
            string sErr = null;
            string sHTML = "";

            sSql = "select keypair_id, keypair_name, private_key, passphrase" +
                " from cloud_account_keypair" +
                " where account_id = '" + sID + "'";

            DataTable dt = new DataTable();
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            if (dt.Rows.Count > 0)
            {
                sHTML += "<ul>";
                foreach (DataRow dr in dt.Rows)
                {
                    string sName = dr["keypair_name"].ToString();

                    //DO NOT send these back to the client.
                    string sPK = (object.ReferenceEquals(dr["private_key"], DBNull.Value) ? "false" : "true");
                    string sPP = (object.ReferenceEquals(dr["passphrase"], DBNull.Value) ? "false" : "true");
                    //sLoginPassword = "******";

                    sHTML += "<li class=\"ui-widget-content ui-corner-all keypair\" id=\"kp_" + dr["keypair_id"].ToString() + "\" has_pk=\"" + sPK + "\" has_pp=\"" + sPP + "\">";
                    sHTML += "<span class=\"keypair_label pointer\">" + sName + "</span>";
                    sHTML += "<span class=\"keypair_icons pointer\"><img src=\"../images/icons/fileclose.png\" class=\"keypair_delete_btn\" /></span>";
                    sHTML += "</li>";
                }
                sHTML += "</ul>";
            }
            else
            {
                sHTML += "";
            }

            return sHTML;
        }
コード例 #40
0
        public string wmDatasetTemplateChange(string sStepID, string sTemplateID)
        {
            dataAccess dc = new dataAccess();

            try
            {
                XDocument xGlobals = XDocument.Load(Server.MapPath("~/pages/luDatasetTemplates.xml"));

                if (xGlobals == null)
                {
                    throw new Exception("Could not load templates.");
                }
                else
                {

                    // we have the step_id and the template_id
                    // get the entire <function... section and replace it in the db for this step_id
                    var xFunctionXml = (from node in xGlobals.Descendants("template")
                                        where (string)node.Attribute("template_id") == sTemplateID
                                        select node).Single().Element("function");

                    if (xFunctionXml == null)
                    {
                        // could not find the value, now what?
                        throw new Exception("Template settings null for template id: " + sTemplateID);
                    }
                    else
                    {
                        // now we need the template_id somehow
                        string sSQL = "";
                        string sErr = "";
                        sSQL = "update task_step set function_xml = '" + xFunctionXml.ToString() + "' where step_id = '" + sStepID + "'";

                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        {
                            throw new Exception(sErr);
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return "";
        }
コード例 #41
0
        public string wmCopyTask(string sCopyTaskID, string sTaskCode, string sTaskName)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sErr = null;

            // checks that cant be done on the client side
            // is the name unique?
            string sTaskNameInUse = "";
            if (!dc.sqlGetSingleString(ref sTaskNameInUse, "select task_id from task where task_name = '" + sTaskName.Replace("'", "''") + "' limit 1", ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (!string.IsNullOrEmpty(sTaskNameInUse))
                {
                    return "Task Name [" + sTaskName + "] already in use.  Please choose another name.";
                }
            }

            // checks that cant be done on the client side
            // is the name unique?
            string sTaskCodeInUse = "";
            if (!dc.sqlGetSingleString(ref sTaskCodeInUse, "select task_id from task where task_code = '" + sTaskCode.Replace("'", "''") + "' limit 1", ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (!string.IsNullOrEmpty(sTaskCodeInUse))
                {
                    return "Task Code [" + sTaskCode + "] already in use.  Please choose another code.";
                }
            }

            string sNewTaskGUID = CopyTask(0, sCopyTaskID, sTaskName.Replace("'", "''"), sTaskCode.Replace("'", "''"));

            if (!string.IsNullOrEmpty(sNewTaskGUID))
            {
                ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskGUID, sTaskName, "Copied from " + sCopyTaskID);
            }

            // success, return the new task_id
            return sNewTaskGUID;
        }
コード例 #42
0
        public void wmCopyStepToClipboard(string sStepID)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                if (ui.IsGUID(sStepID))
                {

                    // should also do this whole thing in a transaction.

                    string sUserID = ui.GetSessionUserID();
                    string sErr = "";

                    //stuff gets new ids when copied into the clpboard.
                    //what way when adding, we don't have to loop
                    //(yes, I know we have to loop here, but adding is already a long process
                    //... so we can better afford to do it here than there.)
                    string sNewStepID = ui.NewGUID();

                    //it's a bit hokey, but if a step already exists in the clipboard,
                    //and we are copying that step again,
                    //ALWAYS remove the old one.
                    //we don't want to end up with lots of confusing copies
                    string sSQL = "delete from task_step_clipboard" +
                        " where user_id = '" + sUserID + "'" +
                        " and src_step_id = '" + sStepID + "'";
                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception("Unable to clean clipboard." + sErr);

                    sSQL = " insert into task_step_clipboard" +
                        " (user_id, clip_dt, src_step_id, root_step_id, step_id, function_name, function_xml, step_desc," +
                            " output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml)" +
                        " select '" + sUserID + "', now(), step_id, '" + sNewStepID + "', '" + sNewStepID + "'," +
                            " function_name, function_xml, step_desc," +
                            " output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml" +
                        " from task_step" +
                        " where step_id = '" + sStepID + "'";
                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception("Unable to copy step [" + sStepID + "]." + sErr);

                    //now, if the step we just copied has embedded steps,
                    //we need to get them too, but stick them in the clipboard table
                    //in a hidden fashion. (So they are preserved there, but not visible in the list.)

                    //we are doing it in a recursive call since the nested steps may themselves have nested steps.
                    AlsoCopyEmbeddedStepsToClipboard(sUserID, sStepID, sNewStepID, sNewStepID, ref sErr);

                    return;
                }
                else
                {
                    throw new Exception("Unable to copy step. Missing or invalid step_id.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #43
0
        private void AlsoCopyEmbeddedStepsToClipboard(string sUserID, string sSourceStepID, string sRootStepID, string sNewParentStepID, ref string sErr)
        {
            dataAccess dc = new dataAccess();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
            acUI.acUI ui = new acUI.acUI();

            //get all the steps that have the calling stepid as a parent (codeblock)
            string sSQL = "select step_id" +
                " from task_step" +
                " where codeblock_name = '" + sSourceStepID + "'";

            DataTable dt = new DataTable();
            if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                throw new Exception(sErr);

            foreach (DataRow dr in dt.Rows)
            {
                string sThisStepID = dr["step_id"].ToString();
                string sThisNewID = ui.NewGUID();

                //put them in the table
                sSQL = "delete from task_step_clipboard" +
                    " where user_id = '" + sUserID + "'" +
                    " and src_step_id = '" + sThisStepID + "'";
                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    throw new Exception("Unable to clean embedded steps of [" + sSourceStepID + "]." + sErr);

                sSQL = " insert into task_step_clipboard" +
                " (user_id, clip_dt, src_step_id, root_step_id, step_id, function_name, function_xml, step_desc," +
                " output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml, codeblock_name)" +
                " select '" + sUserID + "', now(), step_id, '" + sRootStepID + "', '" + sThisNewID + "'," +
                " function_name, function_xml, step_desc," +
                " output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml, '" + sNewParentStepID + "'" +
                " from task_step" +
                " where step_id = '" + sThisStepID + "'";

                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    throw new Exception("Unable to copy embedded steps of [" + sSourceStepID + "]." + sErr);

                //we need to update the "action" XML of the parent too...

                /*OK here's the deal..I'm out of time

                 This should not be hardcoded, it should be smart enough to find an XML node with a specific
                 value and update that node.

                 I just don't know enought about xpath to figure it out, and don't have time to do it before
                 I gotta start chilling at tmo.

                 So, I've hardcoded it to the known cases so it will work.

                 Add a new dynamic command type that has embedded steps, and this will probably no longer work.
                 */

                ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
                    " and step_id = '" + sNewParentStepID + "'", "//action[text() = '" + sThisStepID + "']", sThisNewID);

                ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
                    " and step_id = '" + sNewParentStepID + "'", "//else[text() = '" + sThisStepID + "']", sThisNewID);

                ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
                    " and step_id = '" + sNewParentStepID + "'", "//positive_action[text() = '" + sThisStepID + "']", sThisNewID);

                ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
                    " and step_id = '" + sNewParentStepID + "'", "//negative_action[text() = '" + sThisStepID + "']", sThisNewID);

                //END OF HARDCODED HACK

                // and check this one for children too
                AlsoCopyEmbeddedStepsToClipboard(sUserID, sThisStepID, sRootStepID, sThisNewID, ref sErr);
            }
        }
コード例 #44
0
        public string wmRunTask(string sTaskID, string sEcosystemID, string sAccountID, string sAssetID, string sParameterXML, int iDebugLevel)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            uiMethods um = new uiMethods();

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sParameterXML = ui.unpackJSON(sParameterXML).Replace("'", "''");

            //we gotta peek into the XML and encrypt any newly keyed values
            um.PrepareAndEncryptParameterXML(ref sParameterXML);

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {

                    string sInstance = "";
                    string sErr = "";

                    string sSQL = "call addTaskInstance ('" + sTaskID + "','" +
                        sUserID + "',NULL," +
                        iDebugLevel + ",NULL,'" +
                        sParameterXML + "','" +
                        sEcosystemID + "','" +
                        sAccountID + "')";

                    if (!dc.sqlGetSingleString(ref sInstance, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to run task [" + sTaskID + "]." + sErr);
                    }

                    return sInstance;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task [" + sTaskID + "] or asset [" + sAssetID + "] id.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #45
0
        private string CopyTask(int iMode, string sSourceTaskID, string sNewTaskName, string sNewTaskCode)
        {
            //iMode 0=new task, 1=new major version, 2=new minor version
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            string sErr = "";
            string sSQL = "";

            string sNewTaskID = ui.NewGUID();

            int iIsDefault = 0;
            string sTaskName = "";
            double dVersion = 1.000;
            double dMaxVer = 0.000;
            string sOTID = "";

            //do it all in a transaction
            dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

            //figure out the new name and selected version
            oTrans.Command.CommandText = "select task_name, version, original_task_id from task where task_id = '" + sSourceTaskID + "'";
            DataRow dr = null;
            if (!oTrans.ExecGetDataRow(ref dr, ref sErr))
                throw new Exception("Unable to find task for ID [" + sSourceTaskID + "]." + sErr);

            sTaskName = dr["task_name"].ToString();
            dVersion = Convert.ToDouble(dr["version"]);
            sOTID = dr["original_task_id"].ToString();

            //figure out the new version
            switch (iMode)
            {
                case 0:
                    sTaskName = sNewTaskName;
                    iIsDefault = 1;
                    dVersion = 1.000;
                    sOTID = sNewTaskID;

                    break;
                case 1:
                    //gotta get the highest version
                    sSQL = "select max(version) from task where task_id = '" + sOTID + "'";
                    dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
                    if (sErr != "")
                    {
                        oTrans.RollBack();
                        throw new Exception(sErr);
                    }

                    dVersion = dMaxVer + 1;

                    break;
                case 2:
                    sSQL = "select max(version) from task where task_id = '" + sOTID + "'" +
                        " and cast(version as unsigned) = " + Convert.ToInt32(dVersion);
                    dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
                    if (sErr != "")
                    {
                        oTrans.RollBack();
                        throw new Exception(sErr);
                    }

                    dVersion = dMaxVer + 0.001;

                    break;
                default: //a iMode is required
                    throw new Exception("A mode required for this copy operation." + sErr);
            }

            //if we are versioning, AND there are not yet any 'Approved' versions,
            //we set this new version to be the default
            //(that way it's the one that you get taken to when you pick it from a list)
            if (iMode > 0)
            {
                sSQL = "select case when count(*) = 0 then 1 else 0 end" +
                    " from task where original_task_id = '" + sOTID + "'" +
                    " and task_status = 'Approved'";
                dc.sqlGetSingleInteger(ref iIsDefault, sSQL, ref sErr);
                if (sErr != "")
                {
                    oTrans.RollBack();
                    throw new Exception(sErr);
                }
            }

            //start copying
            oTrans.Command.CommandText = "create temporary table _copy_task" +
                " select * from task where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the task_id
            oTrans.Command.CommandText = "update _copy_task set" +
                " task_id = '" + sNewTaskID + "'," +
                " original_task_id = '" + sOTID + "'," +
                " version = '" + dVersion + "'," +
                " task_name = '" + sTaskName + "'," +
                " default_version = " + iIsDefault.ToString() + "," +
                " task_status = 'Development'," +
                " created_dt = now()";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the task_code if necessary
            if (iMode == 0)
            {
                oTrans.Command.CommandText = "update _copy_task set task_code = '" + sNewTaskCode + "'";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            //codeblocks
            oTrans.Command.CommandText = "create temporary table _copy_task_codeblock" +
                " select '" + sNewTaskID + "' as task_id, codeblock_name" +
                " from task_codeblock where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //USING TEMPORARY TABLES... need a place to hold step ids while we manipulate them
            oTrans.Command.CommandText = "create temporary table _step_ids" +
                " select distinct step_id, uuid() as newstep_id" +
                " from task_step where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //steps temp table
            oTrans.Command.CommandText = "create temporary table _copy_task_step" +
                " select step_id, '" + sNewTaskID + "' as task_id, codeblock_name, step_order, commented," +
                " locked, function_name, function_xml, step_desc, output_parse_type, output_row_delimiter," +
                " output_column_delimiter, variable_xml" +
                " from task_step where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the step id
            oTrans.Command.CommandText = "update _copy_task_step a, _step_ids b" +
                " set a.step_id = b.newstep_id" +
                " where a.step_id = b.step_id";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update steps with codeblocks that reference a step (embedded steps)
            oTrans.Command.CommandText = "update _copy_task_step a, _step_ids b" +
                " set a.codeblock_name = b.newstep_id" +
                " where b.step_id = a.codeblock_name";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //spin the steps and update any embedded step id's in the commands
            oTrans.Command.CommandText = "select step_id, newstep_id from _step_ids";
            DataTable dtStepIDs = new DataTable();
            if (!oTrans.ExecGetDataTable(ref dtStepIDs, ref sErr))
                throw new Exception("Unable to get step ids." + sErr);

            foreach (DataRow drStepIDs in dtStepIDs.Rows)
            {
                oTrans.Command.CommandText = "update _copy_task_step" +
                    " set function_xml = replace(lower(function_xml), '" + drStepIDs["step_id"].ToString().ToLower() + "', '" + drStepIDs["newstep_id"].ToString() + "')" +
                    " where function_name in ('if','loop','exists')";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            //finally, put the temp steps table in the real steps table
            oTrans.Command.CommandText = "insert into task select * from _copy_task";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            oTrans.Command.CommandText = "insert into task_codeblock select * from _copy_task_codeblock";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            oTrans.Command.CommandText = "insert into task_step select * from _copy_task_step";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //finally, if we versioned up and we set this one as the new default_version,
            //we need to unset the other row
            if (iMode > 0 && iIsDefault == 1)
            {
                oTrans.Command.CommandText = "update task" +
                    " set default_version = 0" +
                    " where original_task_id = '" + sOTID + "'" +
                    " and task_id <> '" + sNewTaskID + "'";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            oTrans.Commit();

            return sNewTaskID;
        }
コード例 #46
0
        public void wmStopTask(string sInstance)
        {
            dataAccess dc = new dataAccess();

            try
            {
                if (sInstance != "")
                {
                    string sErr = "";
                    string sSQL = "update task_instance set task_status = 'Aborting'" +
                        " where task_instance = '" + sInstance + "'" +
                        " and task_status in ('Processing');";

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    {
                        throw new Exception("Unable to stop task instance [" + sInstance + "]." + sErr);
                    }

                    sSQL = "update task_instance set task_status = 'Cancelled'" +
                        " where task_instance = '" + sInstance + "'" +
                        " and task_status in ('Submitted','Queued')";

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    {
                        throw new Exception("Unable to stop task instance [" + sInstance + "]." + sErr);
                    }

                    return;
                }
                else
                {
                    throw new Exception("Unable to stop task. Missing or invalid task_instance.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #47
0
        public string wmAddStep(string sTaskID, string sCodeblockName, string sItem)
        {
            dataAccess dc = new dataAccess();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();

                string sStepHTML = "";
                string sErr = "";
                string sSQL = "";
                string sNewStepID = "";

                if (!ui.IsGUID(sTaskID))
                    throw new Exception("Unable to add step. Invalid or missing Task ID. [" + sTaskID + "]" + sErr);

                //now, the sItem variable may have a function name (if it's a new command)
                //or it may have a guid (if it's from the clipboard)

                //so, if it's a guid after stripping off the prefix, it's from the clipboard

                //the function has a fn_ or clip_ prefix on it from the HTML.  Strip it off.
                //FIX... test the string to see if it BEGINS with fn_ or clip_
                //IF SO... cut off the beginning... NOT a replace operation.
                if (sItem.StartsWith("fn_")) sItem = sItem.Remove(0, 3);
                if (sItem.StartsWith("clip_")) sItem = sItem.Remove(0, 5);

                //NOTE: !! yes we are adding the step with an order of -1
                //the update event on the client does not know the index at which it was dropped.
                //so, we have to insert it first to get the HTML... but the very next step
                //will serialize and update the entire sortable...
                //immediately replacing this -1 with the correct position

                if (ui.IsGUID(sItem))
                {
                    sNewStepID = sItem;

                    //copy from the clipboard (using the root_step_id to get ALL associated steps)
                    sSQL = "insert into task_step (step_id, task_id, codeblock_name, step_order, step_desc," +
                        " commented, locked, output_parse_type, output_row_delimiter, output_column_delimiter," +
                        " function_name, function_xml, variable_xml)" +
                        " select step_id, '" + sTaskID + "'," +
                        " case when codeblock_name is null then '" + sCodeblockName + "' else codeblock_name end," +
                        "-1,step_desc," +
                        "0,0,output_parse_type,output_row_delimiter,output_column_delimiter," +
                        "function_name,function_xml,variable_xml" +
                        " from task_step_clipboard" +
                        " where user_id = '" + sUserID + "'" +
                        " and root_step_id = '" + sItem + "'";

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception("Unable to add step." + sErr);

                    ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, sItem,
                        "Added Command from Clipboard to Codeblock:" + sCodeblockName);
                }
                else
                {
                    //add a new command
                    sNewStepID = ui.NewGUID();

                    //NOTE: !! yes we are doing some command specific logic here.
                    //Certain commands have different 'default' values for delimiters, etc.
                    //sOPM: 0=none, 1=delimited, 2=parsed
                    string sOPM = "0";

                    switch (sItem)
                    {
                        case "sql_exec":
                            sOPM = "1";
                            break;
                        case "win_cmd":
                            sOPM = "1";
                            break;
                        case "dos_cmd":
                            sOPM = "2";
                            break;
                        case "cmd_line":
                            sOPM = "2";
                            break;
                        case "http":
                            sOPM = "2";
                            break;
                        case "parse_text":
                            sOPM = "2";
                            break;
                        case "read_file":
                            sOPM = "2";
                            break;
                    }

                    sSQL = "insert into task_step (step_id, task_id, codeblock_name, step_order," +
                        " commented, locked, output_parse_type, output_row_delimiter, output_column_delimiter," +
                        " function_name, function_xml)" +
                           " select '" + sNewStepID + "'," +
                           "'" + sTaskID + "'," +
                           (string.IsNullOrEmpty(sCodeblockName) ? "NULL" : "'" + sCodeblockName + "'") + "," +
                           "-1," +
                           "0,0," + sOPM + ",0,0," +
                           "'" + sItem + "'," +
                           " xml_template" +
                           " from lu_task_step_function" +
                           " where function_name = '" + sItem + "' limit 1";

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception("Unable to add step." + sErr);

                    ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, sItem,
                        "Added Command Type:" + sItem + " to Codeblock:" + sCodeblockName);
                }

                if (!string.IsNullOrEmpty(sNewStepID))
                {
                    //now... get the newly inserted step and draw it's HTML
                    DataRow dr = ft.GetSingleStep(sNewStepID, sUserID, ref sErr);
                    if (dr != null && sErr == "")
                        sStepHTML += ft.DrawFullStep(dr);
                    else
                        sStepHTML += "<span class=\"red_text\">" + sErr + "</span>";

                    //return the html
                    return sNewStepID + sStepHTML;
                }
                else
                {
                    throw new Exception("Unable to add step.  No new step_id." + sErr);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #48
0
        public string wmTaskSearch(string sSearchText)
        {
            try
            {
                dataAccess dc = new dataAccess();
                string sErr = "";
                string sWhereString = "";

                if (sSearchText.Length > 0)
                {
                    sWhereString = " and (a.task_name like '%" + sSearchText +
                                   "%' or a.task_desc like '%" + sSearchText +
                                   "%' or a.task_code like '%" + sSearchText + "%' ) ";
                }

                string sSQL = "select a.original_task_id, a.task_id, a.task_name, a.task_code," +
                    " left(a.task_desc, 255) as task_desc, a.version" +
                       " from task a  " +
                       " where default_version = 1" +
                       sWhereString +
                       " order by task_name, default_version desc, version";

                DataTable dt = new DataTable();
                if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                string sHTML = "<hr />";
                if (dt.Rows.Count == 0)
                {
                    sHTML += "No results found";
                }
                else
                {
                    int iRowsToGet = dt.Rows.Count;
                    if (iRowsToGet >= 100)
                    {
                        sHTML += "<div>Search found " + dt.Rows.Count + " results.  Displaying the first 100.</div>";
                        iRowsToGet = 99;
                    }
                    sHTML += "<ul id=\"search_task_ul\" class=\"search_dialog_ul\">";

                    for (int i = 0; i < iRowsToGet; i++)
                    {
                        string sTaskName = dt.Rows[i]["task_name"].ToString().Replace("\"", "\\\"");
                        string sLabel = dt.Rows[i]["task_code"].ToString() + " : " + sTaskName;
                        string sDesc = dt.Rows[i]["task_desc"].ToString().Replace("\"", "").Replace("'", "");

                        sHTML += "<li class=\"ui-widget-content ui-corner-all search_dialog_value\" tag=\"task_picker_row\"" +
                            " original_task_id=\"" + dt.Rows[i]["original_task_id"].ToString() + "\"" +
                            " task_label=\"" + sLabel + "\"" +
                            "\">";
                        sHTML += "<div class=\"step_header_title search_dialog_value_name\">" + sLabel + "</div>";

                        sHTML += "<div class=\"step_header_icons\">";

                        //if there's a description, show a tooltip
                        if (!string.IsNullOrEmpty(sDesc))
                            sHTML += "<img src=\"../images/icons/info.png\" class=\"search_dialog_tooltip trans50\" title=\"" + sDesc + "\" />";

                        sHTML += "</div>";
                        sHTML += "<div class=\"clearfloat\"></div>";
                        sHTML += "</li>";
                    }
                }
                sHTML += "</ul>";

                return sHTML;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #49
0
        public string wmCreateTask(object[] oObj)
        {
            try
            {

                dataAccess dc = new dataAccess();
                acUI.acUI ui = new acUI.acUI();
                string sSql = null;
                string sErr = null;

                // we are passing in 8 elements, if we have 8 go
                //if (oObj.Length != 8) return "Incorrect list of attributes";

                string sTaskName = oObj[0].ToString().Replace("'", "''").Trim();
                string sTaskCode = oObj[1].ToString().Replace("'", "''").Trim();
                string sTaskDesc = oObj[2].ToString().Replace("'", "''").Trim();

                //string sTaskOrder = "";

                //if (oObj.Length > 4)
                //    sTaskOrder = oObj[4].ToString().Trim();

                // checks that cant be done on the client side
                // is the name unique?
                sSql = "select task_id from task " +
                        " where (task_code = '" + sTaskCode + "' or task_name = '" + sTaskName + "')";

                string sValueExists = "";
                if (!dc.sqlGetSingleString(ref sValueExists, sSql, ref sErr))
                {
                    throw new Exception("Unable to check for existing names." + sErr);
                }

                if (sValueExists != "")
                {
                    return "Another Task with that Code or Name exists, please choose another value.";
                }

                // passed client and server validations, create the user
                string sNewID = ui.NewGUID();

                try
                {
                    dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                    // all good, save the new user and redirect to the user edit page.
                    sSql = "insert task" +
                        " (task_id, original_task_id, version, default_version," +
                        " task_name, task_code, task_desc, created_dt)" +
                           " values " +
                           "('" + sNewID + "', '" + sNewID + "', 1.0000, 1, '" +
                           sTaskName + "', '" + sTaskCode + "', '" + sTaskDesc + "', now())";
                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                    {
                        throw new Exception(sErr);
                    }

                    // every task gets a MAIN codeblock... period.
                    sSql = "insert task_codeblock (task_id, codeblock_name)" +
                           " values ('" + sNewID + "', 'MAIN')";
                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                    {
                        throw new Exception(sErr);
                    }

                    oTrans.Commit();
                }
                catch (Exception ex)
                {
                    throw new Exception("Error updating the DB." + ex.Message);
                }

                // add security log
                ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewID, sTaskName, "");

                // success, return the new task_id
                return "task_id=" + sNewID;

            }
            catch (Exception ex)
            {
                throw new Exception("One or more invalid or missing AJAX arguments." + ex.Message);
            }
        }
コード例 #50
0
        public void wmToggleStep(string sStepID, string sVisible)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            sVisible = (sVisible == "1" ? "1" : "0");

            try
            {
                if (ui.IsGUID(sStepID))
                {
                    string sErr = "";
                    dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                    string sUserID = ui.GetSessionUserID();

                    //is there a row?
                    int iRowCount = 0;
                    dc.sqlGetSingleInteger(ref iRowCount, "select count(*) from task_step_user_settings" +
                                " where user_id = '" + sUserID + "'" +
                                " and step_id = '" + sStepID + "'", ref sErr);

                    if (iRowCount == 0)
                    {
                        oTrans.Command.CommandText = "insert into task_step_user_settings" +
                            " (user_id, step_id, visible, breakpoint, skip)" +
                            " values ('" + sUserID + "','" + sStepID + "', " + sVisible + ", 0, 0)";

                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception("Unable to toggle step (0) [" + sStepID + "]." + sErr);
                    }
                    else
                    {
                        oTrans.Command.CommandText = " update task_step_user_settings set visible = '" + sVisible + "'" +
                            " where step_id = '" + sStepID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception("Unable to toggle step (1) [" + sStepID + "]." + sErr);
                    }

                    oTrans.Commit();

                    return;
                }
                else
                {
                    throw new Exception("Unable to toggle step. Missing or invalid step_id.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #51
0
        public void wmDeleteStep(string sStepID)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sErr = "";
                string sSQL = "";

                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                //you have to know which one we are removing
                string sDeletedStepOrder = "0";
                string sTaskID = "";
                string sCodeblock = "";
                string sFunction = "";
                string sFunctionXML = "";

                sSQL = "select task_id, codeblock_name, step_order, function_name, function_xml" +
                    " from task_step where step_id = '" + sStepID + "'";

                DataRow dr = null;
                if (!dc.sqlGetDataRow(ref dr, sSQL, ref sErr))
                    throw new Exception("Unable to get details for step." + sErr);

                if (dr != null)
                {
                    sDeletedStepOrder = dr["step_order"].ToString();
                    sTaskID = dr["task_id"].ToString();
                    sCodeblock = dr["codeblock_name"].ToString();
                    sFunction = dr["function_name"].ToString();
                    sFunctionXML = dr["function_xml"].ToString();

                    //for logging, we'll stick the whole command XML into the log
                    //so we have a complete record of the step that was just deleted.
                    ui.WriteObjectDeleteLog(Globals.acObjectTypes.Task, sTaskID, sFunction,
                        "Codeblock:" + sCodeblock +
                        " Step Order:" + sDeletedStepOrder +
                        " Command Type:" + sFunction +
                        " Details:" + sFunctionXML);
                }

                //"embedded" steps have a codeblock name referencing their "parent" step.
                //if we're deleting a parent, whack all the children
                sSQL = "delete from task_step where codeblock_name = '" + sStepID + "'";
                oTrans.Command.CommandText = sSQL;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception("Unable to delete step." + sErr);

                //step might have user_settings
                sSQL = "delete from task_step_user_settings where step_id = '" + sStepID + "'";
                oTrans.Command.CommandText = sSQL;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception("Unable to delete step user settings." + sErr);

                //now whack the parent
                sSQL = "delete from task_step where step_id = '" + sStepID + "'";
                oTrans.Command.CommandText = sSQL;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception("Unable to delete step." + sErr);

                sSQL = "update task_step set step_order = step_order - 1" +
                    " where task_id = '" + sTaskID + "'" +
                    " and codeblock_name = '" + sCodeblock + "'" +
                    " and step_order > " + sDeletedStepOrder;
                oTrans.Command.CommandText = sSQL;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception("Unable to reorder steps after deletion." + sErr);

                oTrans.Commit();

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #52
0
        public void wmToggleStepCommonSection(string sStepID, string sButton)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                if (ui.IsGUID(sStepID))
                {
                    string sUserID = ui.GetSessionUserID();

                    sButton = (sButton == "" ? "null" : "'" + sButton + "'");

                    string sErr = "";

                    //is there a row?
                    int iRowCount = 0;
                    dc.sqlGetSingleInteger(ref iRowCount, "select count(*) from task_step_user_settings" +
                                " where user_id = '" + sUserID + "'" +
                                " and step_id = '" + sStepID + "'", ref sErr);

                    if (iRowCount == 0)
                    {
                        string sSQL = "insert into task_step_user_settings" +
                            " (user_id, step_id, visible, breakpoint, skip, button)" +
                            " values ('" + sUserID + "','" + sStepID + "', 1, 0, 0, " + sButton + ")";
                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                            throw new Exception("Unable to toggle step button (0) [" + sStepID + "]." + sErr);
                    }
                    else
                    {
                        string sSQL = " update task_step_user_settings set button = " + sButton +
                            " where step_id = '" + sStepID + "';";
                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                            throw new Exception("Unable to toggle step button (1) [" + sStepID + "]." + sErr);
                    }

                    return;
                }
                else
                {
                    throw new Exception("Unable to toggle step button. Missing or invalid step_id or button.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #53
0
        public string wmDeleteTasks(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            string sSql = null;
            string sErr = "";
            string sTaskNames = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            //NOTE: right now this plows ALL versions.  There is an enhancement to possibly 'retire' a task, or
            //only delete certain versions.

            try
            {

                // what about the instance tables?????
                // bugzilla 1290 Tasks that have history (task_instance table) can not be deleted
                // exclude them from the list and return a message noting the task(s) that could not be deleted

                // first we need a list of tasks that will not be deleted
                sSql = "select task_name from task t " +
                        "where t.original_task_id in (" + sDeleteArray.ToString() + ") " +
                        "and t.task_id in (select ti.task_id from tv_task_instance ti where ti.task_id = t.task_id)";

                if (!dc.csvGetList(ref sTaskNames, sSql, ref sErr, true))
                    throw new Exception(sErr);

                // list of tasks that will be deleted
                //we have an array of 'original_task_id'.
                //we need an array or task_id
                //build one.
                sSql = "select t.task_id from task t " +
                    "where t.original_task_id in (" + sDeleteArray.ToString() + ") " +
                    "and t.task_id not in (select ti.task_id from tv_task_instance ti where ti.task_id = t.task_id)";

                string sTaskIDs = "";
                if (!dc.csvGetList(ref sTaskIDs, sSql, ref sErr, true))
                    throw new Exception(sErr);

                // if any tasks can be deleted
                if (sTaskIDs.Length > 1)
                {
                    dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                    //oTrans.Command.CommandText = "delete from task_asset_attribute where task_id in (" + sTaskIDs + ")";
                    //if (!oTrans.ExecUpdate(ref sErr))
                    //    throw new Exception(sErr);

                    oTrans.Command.CommandText = "delete from task_step_user_settings" +
                        " where step_id in" +
                        " (select step_id from task_step where task_id in (" + sTaskIDs + "))";
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception(sErr);

                    oTrans.Command.CommandText = "delete from task_step where task_id in (" + sTaskIDs + ")";
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception(sErr);

                    oTrans.Command.CommandText = "delete from task_codeblock where task_id in (" + sTaskIDs + ")";
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception(sErr);

                    oTrans.Command.CommandText = "delete from task where task_id in (" + sTaskIDs + ")";
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception(sErr);

                    oTrans.Commit();

                    ui.WriteObjectDeleteLog(Globals.acObjectTypes.Task, "Multiple", "Original Task IDs", sDeleteArray.ToString());

                }

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if the sTaskNames contains any names, then send back a message that these were not deleted because of history records.
            if (sTaskNames.Length > 0)
            {
                return "Task(s) (" + sTaskNames + ") have history rows and could not be deleted.";
            }
            else
            {
                return sErr;
            }
        }
コード例 #54
0
        public string wmUpdateStep(string sStepID, string sFunction, string sXPath, string sValue)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sErr = "";
            string sSQL = "";

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sValue = ui.unpackJSON(sValue);

            //if the function type is "_common" that means this is a literal column on the step table.
            if (sFunction == "_common")
            {
                sValue = sValue.Replace("'", "''"); //escape single quotes for the SQL insert
                sSQL = "update task_step set " +
                    sXPath + " = '" + sValue + "'" +
                    " where step_id = '" + sStepID + "';";

                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

            }
            else
            {
                //XML processing
                //get the xml from the step table and update it
                string sXMLTemplate = "";

                sSQL = "select function_xml from task_step where step_id = '" + sStepID + "'";

                if (!dc.sqlGetSingleString(ref sXMLTemplate, sSQL, ref sErr))
                {
                    throw new Exception("Unable to get XML data for step [" + sStepID + "].");
                }

                XDocument xDoc = XDocument.Parse(sXMLTemplate);
                if (xDoc == null)
                    throw new Exception("XML data for step [" + sStepID + "] is invalid.");

                XElement xRoot = xDoc.Element("function");
                if (xRoot == null)
                    throw new Exception("XML data for step [" + sStepID + "] does not contain 'function' root node.");

                try
                {
                    XElement xNode = xRoot.XPathSelectElement(sXPath);
                    if (xNode == null)
                        throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");

                    xNode.SetValue(sValue);
                }
                catch (Exception)
                {
                    try
                    {
                        //here's the deal... given an XPath statement, we simply cannot add a new node if it doesn't exist.
                        //why?  because xpath is a query language.  It doesnt' describe exactly what to add due to wildcards and //foo syntax.

                        //but, what we can do is make an ssumption in our specific case...
                        //that we are only wanting to add because we changed an underlying command XML template, and there are existing commands.

                        //so... we will split the xpath into segments, and traverse upward until we find an actual node.
                        //once we have it, we will need to add elements back down.

                        //string[] nodes = sXPath.Split('/');

                        //foreach (string node in nodes)
                        //{
                        //    //try to select THIS one, and stick it on the backwards stack
                        //    XElement xNode = xRoot.XPathSelectElement("//" + node);
                        //    if (xNode == null)
                        //        throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");

                        //}

                        XElement xFoundNode = null;
                        ArrayList aMissingNodes = new ArrayList();

                        //of course this skips the full path, but we've already determined it's no good.
                        string sWorkXPath = sXPath;
                        while (sWorkXPath.LastIndexOf("/") > -1)
                        {
                            aMissingNodes.Add(sWorkXPath.Substring(sWorkXPath.LastIndexOf("/") + 1));
                            sWorkXPath = sWorkXPath.Substring(0, sWorkXPath.LastIndexOf("/"));

                            xFoundNode = xRoot.XPathSelectElement(sWorkXPath);
                            if (xFoundNode != null)
                            {
                                //Found it! stop looping
                                break;
                            }
                        }

                        //now that we know where to start (xFoundNode), we can use that as a basis for adding
                        foreach (string sNode in aMissingNodes)
                        {
                            xFoundNode.Add(new XElement(sNode));
                        }

                        //now we should be good to stick the value on the final node.
                        XElement xNode = xRoot.XPathSelectElement(sXPath);
                        if (xNode == null)
                            throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");

                        xNode.SetValue(sValue);

                        //xRoot.Add(new XElement(sXPath, sValue));
                        //xRoot.SetElementValue(sXPath, sValue);
                    }
                    catch (Exception)
                    {
                        throw new Exception("Error Saving Step [" + sStepID + "].  Could not find and cannot create the [" + sXPath + "] property in the XML.");
                    }

                }

                sSQL = "update task_step set " +
                    " function_xml = '" + xDoc.ToString(SaveOptions.DisableFormatting).Replace("'", "''") + "'" +
                    " where step_id = '" + sStepID + "';";

                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

            }

            sSQL = "select task_id, codeblock_name, step_order from task_step where step_id = '" + sStepID + "'";
            DataRow dr = null;
            if (!dc.sqlGetDataRow(ref dr, sSQL, ref sErr))
                throw new Exception(sErr);

            if (dr != null)
            {
                ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, dr["task_id"].ToString(), sFunction,
                    "Codeblock:" + dr["codeblock_name"].ToString() +
                    " Step Order:" + dr["step_order"].ToString() +
                    " Command Type:" + sFunction +
                    " Property:" + sXPath +
                    " New Value: " + sValue);
            }

            return "";
        }
コード例 #55
0
        public static string LoadAccount(string sID)
        {
            dataAccess dc = new dataAccess();
            string sSql = null;
            string sErr = null;

            string sAccountName = null;
            string sAccountNumber = null;
            string sProvider = null;
            string sIsDefault = null;
            string sAutoManage = null;
            string sLoginID = null;
            string sLoginPassword = null;

            sSql = "select account_id, account_name, account_number, provider, login_id, is_default, auto_manage_security" +
                " from cloud_account where account_id = '" + sID + "'";

            StringBuilder sb = new StringBuilder();
            DataRow dr = null;
            if (!dc.sqlGetDataRow(ref dr, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (dr != null)
                {
                    sAccountName = (object.ReferenceEquals(dr["account_name"], DBNull.Value) ? "" : dr["account_name"].ToString());
                    sAccountNumber = (object.ReferenceEquals(dr["account_number"], DBNull.Value) ? "" : dr["account_number"].ToString());
                    sProvider = (object.ReferenceEquals(dr["provider"], DBNull.Value) ? "" : dr["provider"].ToString());
                    sIsDefault = (object.ReferenceEquals(dr["is_default"], DBNull.Value) ? "0" : (dc.IsTrue(dr["is_default"].ToString()) ? "1" : "0"));
                    sAutoManage = (object.ReferenceEquals(dr["auto_manage_security"], DBNull.Value) ? "" : dr["auto_manage_security"].ToString());
                    sLoginID = (object.ReferenceEquals(dr["login_id"], DBNull.Value) ? "" : dr["login_id"].ToString());
                    sLoginPassword = "******";

                    // Return the object as a JSON

                    sb.Append("{");
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountName", sAccountName);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountNumber", sAccountNumber);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sProvider", sProvider);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sIsDefault", sIsDefault);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAutoManage", sAutoManage);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sLoginID", sLoginID);
                    sb.AppendFormat("\"{0}\" : \"{1}\"", "sLoginPassword", sLoginPassword);
                    sb.Append("}");

                }
                else
                {
                    sb.Append("{}");
                }

            }

            return sb.ToString();
        }
コード例 #56
0
        public string wmUpdateTaskDetail(string sTaskID, string sColumn, string sValue)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {
                    string sErr = "";
                    string sSQL = "";

                    //we encoded this in javascript before the ajax call.
                    //the safest way to unencode it is to use the same javascript lib.
                    //(sometimes the javascript and .net libs don't translate exactly, google it.)
                    sValue = ui.unpackJSON(sValue);

                    string sOriginalTaskID = "";

                    sSQL = "select original_task_id from task where task_id = '" + sTaskID + "'";

                    if (!dc.sqlGetSingleString(ref sOriginalTaskID, sSQL, ref sErr))
                        throw new Exception("Unable to get original_task_id for [" + sTaskID + "]." + sErr);

                    if (sOriginalTaskID == "")
                        return "Unable to get original_task_id for [" + sTaskID + "].";

                    // bugzilla 1074, check for existing task_code and task_name
                    if (sColumn == "task_code" || sColumn == "task_name")
                    {
                        sSQL = "select task_id from task where " +
                                sColumn.Replace("'", "''") + "='" + sValue.Replace("'", "''") + "'" +
                                " and original_task_id <> '" + sOriginalTaskID + "'";

                        string sValueExists = "";
                        if (!dc.sqlGetSingleString(ref sValueExists, sSQL, ref sErr))
                            throw new Exception("Unable to check for existing names [" + sTaskID + "]." + sErr);

                        if (!string.IsNullOrEmpty(sValueExists))
                            return sValue + " exists, please choose another value.";
                    }

                    if (sColumn == "task_code" || sColumn == "task_name")
                    {
                        //changing the name or code updates ALL VERSIONS
                        string sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
                        sSQL = "update task set " + sSetClause + " where original_task_id = '" + sOriginalTaskID + "'";
                    }
                    else
                    {
                        string sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";

                        //some columns on this table allow nulls... in their case an empty sValue is a null
                        if (sColumn == "concurrent_instances" || sColumn == "queue_depth")
                        {
                            if (sValue.Replace(" ", "").Length == 0)
                                sSetClause = sColumn + " = null";
                            else
                                sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
                        }

                        //some columns are checkboxes, so make sure it is a db appropriate value (1 or 0)
                        //some columns on this table allow nulls... in their case an empty sValue is a null
                        if (sColumn == "concurrent_by_asset")
                        {
                            if (dc.IsTrue(sValue))
                                sSetClause = sColumn + " = 1";
                            else
                                sSetClause = sColumn + " = 0";
                        }

                        sSQL = "update task set " + sSetClause + " where task_id = '" + sTaskID + "'";
                    }

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception("Unable to update task [" + sTaskID + "]." + sErr);

                    ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, sColumn, sValue);
                }
                else
                {
                    throw new Exception("Unable to update task. Missing or invalid task [" + sTaskID + "] id.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            return "";
        }
コード例 #57
0
        public static string SaveKeyPair(string sKeypairID, string sAccountID, string sName, string sPK, string sPP)
        {
            acUI.acUI ui = new acUI.acUI();

            if (string.IsNullOrEmpty(sName))
                return "KeyPair Name is Required.";

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sPK = ui.unpackJSON(sPK);

            bool bUpdatePK = false;
            if (sPK != "-----BEGIN RSA PRIVATE KEY-----\n**********\n-----END RSA PRIVATE KEY-----")
            {

                //we want to make sure it's not just the placeholder, but DOES have the wrapper.
                //and 61 is the lenght of the wrapper with no content... effectively empty
                if (sPK.StartsWith("-----BEGIN RSA PRIVATE KEY-----\n") && sPK.EndsWith("\n-----END RSA PRIVATE KEY-----"))
                {
                    //now, is there truly something in it?
                    string sContent = sPK.Replace("-----BEGIN RSA PRIVATE KEY-----", "").Replace("-----END RSA PRIVATE KEY-----", "").Replace("\n", "");
                    if (sContent.Length > 0)
                        bUpdatePK = true;
                    else
                        return "Private Key contained within:<br />-----BEGIN RSA PRIVATE KEY-----<br />and<br />-----END RSA PRIVATE KEY-----<br />cannot be blank.";
                }
                else
                {
                    return "Private Key must be contained within:<br />-----BEGIN RSA PRIVATE KEY-----<br />and<br />-----END RSA PRIVATE KEY-----";
                }
            }

            bool bUpdatePP = false;
            if (sPP != "!2E4S6789O")
                bUpdatePP = true;

            //all good, keep going

            dataAccess dc = new dataAccess();
            string sSQL = null;
            string sErr = null;

            try
            {
                if (string.IsNullOrEmpty(sKeypairID))
                {
                    //empty id, it's a new one.
                    string sPKClause = "";
                    if (bUpdatePK)
                        sPKClause = "'" + dc.EnCrypt(sPK) + "'";

                    string sPPClause = "null";
                    if (bUpdatePP)
                        sPPClause = "'" + dc.EnCrypt(sPP) + "'";

                    sSQL = "insert into cloud_account_keypair (keypair_id, account_id, keypair_name, private_key, passphrase)" +
                        " values ('" + ui.NewGUID() + "'," +
                        "'" + sAccountID + "'," +
                        "'" + sName.Replace("'", "''") + "'," +
                        sPKClause + "," +
                        sPPClause +
                        ")";
                }
                else
                {
                    string sPKClause = "";
                    if (bUpdatePK)
                        sPKClause = ", private_key = '" + dc.EnCrypt(sPK) + "'";

                    string sPPClause = "";
                    if (bUpdatePP)
                        sPPClause = ", passphrase = '" + dc.EnCrypt(sPP) + "'";

                    sSQL = "update cloud_account_keypair set" +
                        " keypair_name = '" + sName.Replace("'", "''") + "'" +
                        sPKClause + sPPClause +
                        " where keypair_id = '" + sKeypairID + "'";
                }

                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    throw new Exception(sErr);

            }
            catch (Exception ex)
            {

                throw new Exception(ex.Message);
            }

            //// add security log
            //// since this is not handled as a page postback, theres no "Viewstate" settings
            //// so 2 options either we keep an original setting for each value in hid values, or just get them from the db as part of the
            //// update above, since we are already passing in 15 or so fields, lets just get the values at the start and reference them here
            //if (sMode == "edit")
            //{
            //    ui.WriteObjectChangeLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, sOriginalName, sAccountName);
            //}
            //else
            //{
            //    ui.WriteObjectAddLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, "Account Created");
            //}

            // no errors to here, so return an empty string
            return "";
        }
コード例 #58
0
        public string wmUpdateTaskParam(string sType, string sID, string sParamID,
            string sName, string sDesc,
            string sRequired, string sPrompt, string sEncrypt, string sPresentAs, string sValues)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();

            if (!ui.IsGUID(sID))
                throw new Exception("Invalid or missing ID.");

            string sErr = "";
            string sSQL = "";

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sDesc = ui.unpackJSON(sDesc).Trim();

            //normalize and clean the values
            sRequired = (dc.IsTrue(sRequired) ? "true" : "false");
            sPrompt = (dc.IsTrue(sPrompt) ? "true" : "false");
            sEncrypt = (dc.IsTrue(sEncrypt) ? "true" : "false");
            sName = sName.Trim().Replace("'", "''");

            string sTable = "";
            string sXML = "";
            string sParameterXPath = "//parameter[@id = \"" + sParamID + "\"]";  //using this to keep the code below cleaner.

            if (sType == "ecosystem")
                sTable = "ecosystem";
            else if (sType == "task")
                sTable = "task";

            bool bParamAdd = false;
            //bool bParamUpdate = false;

            //if sParamID is empty, we are adding
            if (string.IsNullOrEmpty(sParamID))
            {
                sParamID = "p_" + ui.NewGUID();
                sParameterXPath = "//parameter[@id = \"" + sParamID + "\"]";  //reset this if we had to get a new id

                //does the task already have parameters?
                sSQL = "select parameter_xml from " + sTable + " where " + sType + "_id = '" + sID + "'";
                if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
                    throw new Exception(sErr);

                string sAddXML = "<parameter id=\"" + sParamID + "\" required=\"" + sRequired + "\" prompt=\"" + sPrompt + "\" encrypt=\"" + sEncrypt + "\">" +
                    "<name>" + sName + "</name>" +
                    "<desc>" + sDesc + "</desc>" +
                    "</parameter>";

                if (string.IsNullOrEmpty(sXML))
                {
                    //XML doesn't exist at all, add it to the record
                    sAddXML = "<parameters>" + sAddXML + "</parameters>";

                    sSQL = "update " + sTable + " set " +
                        " parameter_xml = '" + sAddXML + "'" +
                        " where " + sType + "_id = '" + sID + "'";

                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        throw new Exception(sErr);

                    bParamAdd = true;
                }
                else
                {
                    //XML exists, add the node to it
                    ft.AddNodeToXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", "//parameters", sAddXML);
                    bParamAdd = true;
                }
            }
            else
            {
                //update the node values
                ft.SetNodeValueinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath + "/name", sName);
                ft.SetNodeValueinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath + "/desc", sDesc);
                //and the attributes
                ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "required", sRequired);
                ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "prompt", sPrompt);
                ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "encrypt", sEncrypt);

                bParamAdd = false;
            }

            // not clean at all handling both tasks and ecosystems in the same method, but whatever.
            if (bParamAdd)
            {
                if (sType == "task") { ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sID, "Parameter", "Added Parameter:" + sName ); };
                if (sType == "ecosystem") { ui.WriteObjectAddLog(Globals.acObjectTypes.Ecosystem, sID, "Parameter", "Added Parameter:" + sName); };
            }
            else
            {
                // would be a lot of trouble to add the from to, why is it needed you have each value in the log, just scroll back
                // so just add a changed message to the log
                if (sType == "task") { dc.addSecurityLog(ui.GetSessionUserID(), Globals.SecurityLogTypes.Object, Globals.SecurityLogActions.ObjectModify, Globals.acObjectTypes.Task, sID, "Parameter Changed:[" + sName + "]", ref sErr); };
                if (sType == "ecosystem") { dc.addSecurityLog(ui.GetSessionUserID(), Globals.SecurityLogTypes.Object, Globals.SecurityLogActions.ObjectModify, Globals.acObjectTypes.Ecosystem, sID, "Parameter Changed:[" + sName + "]", ref sErr); };
            }

            //update the values
            string[] aValues = sValues.Split('|');
            string sValueXML = "";

            foreach (string sVal in aValues)
            {
                string sReadyValue = "";

                //if encrypt is true we MIGHT want to encrypt this value.
                //but it might simply be a resubmit of an existing value in which case we DON'T
                //if it has oev: as a prefix, it needs no additional work
                if (dc.IsTrue(sEncrypt))
                {
                    if (sVal.IndexOf("oev:") > -1)
                        sReadyValue = sVal.Replace("oev:", "");
                    else
                        sReadyValue = dc.EnCrypt(ui.unpackJSON(sVal));
                } else {
                    sReadyValue = ui.unpackJSON(sVal);
                }

                sValueXML += "<value id=\"pv_" + ui.NewGUID() + "\">" + sReadyValue + "</value>";
            }

            sValueXML = "<values present_as=\"" + sPresentAs + "\">" + sValueXML + "</values>";

            //whack-n-add
            ft.RemoveNodeFromXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath + "/values");
            ft.AddNodeToXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, sValueXML);

            return "";
        }
コード例 #59
0
        public static string DeleteKeyPair(string sKeypairID)
        {
            dataAccess dc = new dataAccess();
            string sSQL = null;
            string sErr = "";

            try
            {
                sSQL = "delete from cloud_account_keypair where keypair_id = '" + sKeypairID + "'";
                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    throw new Exception(sErr);

                if (sErr != "")
                    throw new Exception(sErr);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return "";
        }
コード例 #60
0
        public void wmCopyCodeblockStepsToClipboard(string sTaskID, string sCodeblockName)
        {
            dataAccess dc = new dataAccess();

            try
            {
                if (sCodeblockName != "")
                {
                    string sErr = "";
                    string sSQL = "select step_id" +
                        " from task_step" +
                        " where task_id = '" + sTaskID + "'" +
                        " and codeblock_name = '" + sCodeblockName + "'" +
                        " order by step_order desc";

                    DataTable dt = new DataTable();
                    if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                        throw new Exception(sErr);

                    foreach (DataRow dr in dt.Rows)
                    {
                        wmCopyStepToClipboard(dr["step_id"].ToString());
                    }

                    return;
                }
                else
                {
                    throw new Exception("Unable to copy Codeblock. Missing or invalid codeblock_name.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }