예제 #1
0
        public static bool CheckedUserRight(UserLevel level, WebbDBTypes webbDBtype)
        {
            if ((int)level.Rights == 31)
            {
                return(true);
            }

            if (level.Rights == ProductRight.None)
            {
                return(false);
            }

            string[] rights = level.Rights.ToString().ToLower().Split(',');

            string dbtype = webbDBtype.ToString().ToLower().Trim();

            foreach (string right in rights)
            {
                if (dbtype.IndexOf(right.Trim()) >= 0)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public static string[] ReadDataConfig(WebbDBTypes webbType, string sourceFile)
        {
            if (!File.Exists(sourceFile))
            {
                return(null);
            }

            DataSet ds = new DataSet();

            try
            {
                ds.ReadXml(sourceFile);

                DataTable dt = ds.Tables[0];

                DataRow[] dataRows = dt.Select("Product='Product:" + webbType.ToString() + "'");

                if (dataRows.Length == 0)
                {
                    return(null);
                }

                DataRow dr = dataRows[0];

                if (dr == null || dt.Columns.Count != 10)
                {
                    return(null);
                }

                string [] strConfigs = new string[dt.Columns.Count];

                strConfigs[0] = "Path:" + string.Empty;

                for (int i = 1; i < dt.Columns.Count; i++)
                {
                    strConfigs[i] = dr[i].ToString();
                }

                ds.Dispose();

                return(strConfigs);
            }
            catch (Exception ex)
            {
                ds.Dispose();

                MessageBox.Show(ex.Message);

                return(null);
            }
        }
예제 #3
0
        public static void WriteDataConfig(WebbDBTypes webbType, string TargetPath)
        {
            Webb.Reports.DataProvider.WebbDataProvider PublicDataProvider = Webb.Reports.DataProvider.VideoPlayBackManager.PublicDBProvider;

            string[] configs = PublicDataProvider.DBSourceConfig.CreateConfigStrings(string.Empty);

            DataSet ds = new DataSet("ConfigDataSet");

            DataTable configTable;

            DataRow productRow;

            bool isNewRow = true;

            #region Get the row which contains the product

            if (File.Exists(TargetPath))
            {
                try
                {
                    ds.ReadXml(TargetPath);

                    configTable = ds.Tables[0];

                    DataRow[] dataRows = configTable.Select("Product='Product:" + webbType.ToString() + "'");

                    if (dataRows.Length == 0)
                    {
                        productRow = configTable.NewRow();

                        isNewRow = true;
                    }
                    else
                    {
                        productRow = dataRows[0];

                        isNewRow = false;
                    }
                }
                catch
                {
                    ds = new DataSet();

                    configTable = AddColumn(null);

                    ds.Tables.Add(configTable);

                    productRow = configTable.NewRow();

                    isNewRow = true;
                }
            }
            else
            {
                configTable = AddColumn(null);

                ds.Tables.Add(configTable);

                productRow = configTable.NewRow();

                isNewRow = true;
            }

            #endregion

            try
            {
                for (int i = 0; i < configTable.Columns.Count; i++)
                {
                    productRow[i] = configs[i];
                }

                if (isNewRow)
                {
                    configTable.Rows.Add(productRow);
                }

                ds.AcceptChanges();

                ds.WriteXml(TargetPath);

                ds.Dispose();
            }
            catch (Exception ex)
            {
                ds.Dispose();

                MessageBox.Show(ex.Message);
            }
        }