private List<DbVersion> getXmlUpdates()
        {
            var res = new List<DbVersion>();
            XmlDocument doc = new XmlDocument();
            string xmlPath = Path.Combine(Config.SettingsPath, this.ComponentFullName);
            xmlPath = HttpContext.Current.Request.MapPath(xmlPath = Path.Combine(xmlPath, "updates.xml"));

            if (System.IO.File.Exists(xmlPath))
            {
                doc.Load(xmlPath);
                XmlNodeList updateNodes = doc.SelectNodes("//updates/item");
                foreach (XmlNode node in updateNodes)
                {
                    var dbVersionItem = new DbVersion();
                    dbVersionItem.ComponentFullName = this.ComponentFullName;
                    dbVersionItem.VersionId = getIntValue(node, "id");
                    dbVersionItem.VersionDate = getDateValue(node, "date");
                    dbVersionItem.VersionDev = getStringValue(node, "dev");
                    dbVersionItem.VersionNotes = getStringValue(node, "notes");
                    dbVersionItem.SqlContent = node.InnerText;

                    if (dbVersionItem.VersionId > 0)
                    {
                        res.Add(dbVersionItem);
                    }
                }

            }
            return res;
        }
        public bool ApplyPendingUpdates(out string logResult)
        {
            bool res = true;
            DbProviderFactory myProv = Database.ProviderFactory;
            DbTransaction myTrans = null;
            DbConnection myConn = myProv.CreateConnection();
            DbDataReader myRd = null;
            DbCommand myCmd = myConn.CreateCommand();
            string sSql = "";
            string qryResult = "";

            var fromVersion = new DbVersion();
            var toVersion = new DbVersion();
            logResult = "Updating " + this.ComponentFullName
                + " @from version: [[fromVersion]]"
                + " @to version: [[toVersion]]"
                + " @res: [[res]]"
                + " @summary: [[summary]]";

            try
            {
                //retrieve sql
                int updatesCount = this.UpdatesListPending.Count;
                if (updatesCount > 0)
                {
                    fromVersion = this.UpdatesListPending[0];
                    toVersion = this.UpdatesListPending[updatesCount - 1];

                    foreach (var item in this.UpdatesListPending)
                    {
                        sSql += item.SqlContent;
                    }
                }
            }
            catch (Exception ex)
            {
                res = false;
                qryResult = "err retrieving sql - " + ex.ToString();
            }

            if (res && !string.IsNullOrEmpty(sSql))
            {
                try
                {
                    //execute sql with transation
                    myConn.ConnectionString = Database.ConnString;
                    myConn.Open();
                    myCmd.Connection = myConn;

                    myTrans = myConn.BeginTransaction();
                    myCmd.Transaction = myTrans;

                    sSql = Database.ParseSql(sSql);
                    qryResult = Database.ExecuteQuery(myRd, myCmd, sSql);

                    myTrans.Commit();
                    myTrans.Dispose();
                    myConn.Dispose();
                    res = true;
                }
                catch (Exception ex)
                {
                    res = false;
                    myTrans.Rollback();
                    myTrans.Dispose();
                    myConn.Dispose();

                    qryResult = ex.ToString();
                }

                if (res)
                {
                    //update last version log in local db
                    if (dbVersionMan.GetByKey(toVersion.VersionId).VersionId == 0)
                        dbVersionMan.Insert(toVersion);
                    else
                        dbVersionMan.Update(toVersion);
                }
            }

            logResult = logResult
                .Replace("[[fromVersion]]", fromVersion.VersionId.ToString())
                .Replace("[[toVersion]]", toVersion.VersionId.ToString())
                .Replace("[[res]]", res.ToString())
                .Replace("[[summary]]", qryResult);

            LogProvider.Write(fakeModule, logResult,
                (res ? TracerItemType.Info : TracerItemType.Error));

            return res;
        }