//delete param
        public static bool DeleteParam(DataSItem parent, DataParam delParam)
        {
            bool res = false;

            if (IsDocLoaded)
            {
                try
                {
                    XmlNode node =
                        ConfigurationDocument.SelectSingleNode(
                            SettingsHelperManager.QueryOfSelectingParametrOfTheProcedureByPval(parent.Value, delParam.Name));

                    if (node == null)
                    {
                        return(false);
                    }

                    node.ParentNode.RemoveChild(node);

                    if (Save())
                    {
                        res = true;
                        ReadAllProcedures();
                    }
                }
                catch
                {
                }
            }
            return(res);
        }
        public static bool AddProcedure(DataSItem procedure)
        {
            bool res = false;

            if (IsDocLoaded)
            {
                try
                {
                    XmlNode procParent = _doc.DocumentElement.ChildNodes[0];

                    if (procParent != null)
                    {
                        procParent.AppendChild(procedure.ToXmlNode());


                        if (Save())
                        {
                            res = true;
                            ReadAllProcedures();
                        }
                    }
                }
                catch
                {
                    return(false);
                }
            }



            return(res);
        }
        //add param
        public static bool AddParam(DataSItem parent, DataParam newparam)
        {
            bool res = false;

            if (IsDocLoaded)
            {
                try
                {
                    XmlNode procParent =
                        _doc.SelectSingleNode(SettingsHelperManager.QueryOfSelectinProcedureByValue(parent.Value));

                    if (procParent != null)
                    {
                        procParent.AppendChild(newparam.ToXmlNode());


                        if (Save())
                        {
                            res = true;
                            ReadAllProcedures();
                        }
                    }
                }
                catch
                {
                    return(false);
                }
            }

            return(res);
        }
        public static bool ReadAllProcedures()
        {
            bool res = false;

            if (_isDocLoaded)
            {
                try
                {
                    XmlNodeList nodelist = _doc.SelectNodes(SettingsHelperManager.QueryOfListingAllProcedures());

                    if (nodelist != null)
                    {
                        _factory.Procedures.Clear();
                        int asd = 0;
                        foreach (XmlNode node in nodelist)
                        {
                            asd++;
                            DataSItem item = new DataSItem(node);
                            _factory.Procedures.Add(item.Value, item);
                        }


                        res = true;
                    }
                }
                catch
                {
                    return(false);
                }
            }

            return(res);
        }
示例#5
0
        public static DataTable FillTable(string connection, DataSItem item)
        {
            DataTable dt;

            using (_connection = new SqlConnection(connection))
            {
                using (SqlCommand cmd = new SqlCommand(item.Value, _connection))
                {
                    cmd.CommandType = CommandType.Text;
                    SqlParameter prm;
                    foreach (DataParam param in item.Params.Values)
                    {
                        prm = new SqlParameter();
                    }


                    using (_adapter = new SqlDataAdapter(cmd))
                    {
                        using (dt = new DataTable())
                        {
                            _adapter.Fill(dt);
                        }
                    }
                }
            }

            return(dt);
        }
        //update param
        public static bool UpdateParam(DataSItem parent, string oldParamname, DataParam unewparam)
        {
            bool res = false;

            if (IsDocLoaded)
            {
                try
                {
                    string  test = SettingsHelperManager.QueryOfSelectingParametrOfTheProcedureByPval(parent.Value, oldParamname);
                    XmlNode node =
                        ConfigurationDocument.SelectSingleNode(test);
                    if (node == null)
                    {
                        return(false);
                    }
                    //<param name="@action_name" type="4" IsOutput="True" default="asdasd" />
                    node.Attributes["name"].Value      = unewparam.Name;
                    node.Attributes["type"].Value      = ((int)unewparam.Type).ToString();
                    node.Attributes["direction"].Value = ((int)unewparam.Direction).ToString();
                    node.Attributes["default"].Value   = unewparam.Default;


                    if (Save())
                    {
                        res = true;
                        ReadAllProcedures();
                    }
                }
                catch
                {
                    return(false);
                }
            }

            return(res);
        }
        public static bool UpdateProcedure(string oldProcedureVal, DataSItem newProc)
        {
            bool res = false;


            if (IsDocLoaded)
            {
                try
                {
                    string  test = SettingsHelperManager.QueryOfSelectinProcedureByValue(oldProcedureVal);
                    XmlNode node =
                        ConfigurationDocument.SelectSingleNode(test);
                    if (node == null)
                    {
                        return(false);
                    }

                    node.Attributes["name"].Value   = newProc.Name;
                    node.Attributes["value"].Value  = newProc.Value;
                    node.Attributes["constr"].Value = newProc.ConnectionString;


                    if (Save())
                    {
                        res = true;
                        ReadAllProcedures();
                    }
                }
                catch
                {
                    return(false);
                }
            }

            return(res);
        }
 public void SetParent(DataSItem parent)
 {
     Parent = parent;
 }
 public ExecAsyncResult(DataSItem itm) : this(new ExecResult(), itm)
 {
 }
        // public Stopwatch SW { get { return _sw;  } }

        //it can be dictionary ,  data set  , and etc ...


        public ExecAsyncResult(ExecResult res, DataSItem itm)
        {
            Result            = res;
            ExecutedProcedure = itm;
        }