예제 #1
0
        /// <summary>
        /// List转DataTable
        /// </summary>
        /// <param name="list">列表</param>
        /// <returns></returns>
        public static DataTable ToDataTable(System.Collections.IList list)
        {
            DataTable dataTable = new DataTable();

            if (list.Count > 0)
            {
                System.Reflection.PropertyInfo[] properties = list[0].GetType().GetProperties();
                System.Reflection.PropertyInfo[] array      = properties;
                for (int i = 0; i < array.Length; i++)
                {
                    System.Reflection.PropertyInfo propertyInfo = array[i];
                    if (!DxPublic.IsNullableType(propertyInfo.PropertyType))
                    {
                        dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
                    }
                }
                for (int j = 0; j < list.Count; j++)
                {
                    System.Collections.ArrayList     arrayList = new System.Collections.ArrayList();
                    System.Reflection.PropertyInfo[] array2    = properties;
                    for (int k = 0; k < array2.Length; k++)
                    {
                        System.Reflection.PropertyInfo propertyInfo2 = array2[k];
                        if (!DxPublic.IsNullableType(propertyInfo2.PropertyType))
                        {
                            object value = propertyInfo2.GetValue(list[j], null);
                            arrayList.Add(value);
                        }
                    }
                    object[] values = arrayList.ToArray();
                    dataTable.LoadDataRow(values, true);
                }
            }
            return(dataTable);
        }
예제 #2
0
 /// <summary>
 /// 检件文件夹是否存在,不存在则创建
 /// </summary>
 /// <param name="FileName">文件名</param>
 public static void CheckFolderExistsViaFileName(string FileName)
 {
     System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileName);
     if (fileInfo != null)
     {
         DxPublic.CheckFolderExists(fileInfo.DirectoryName);
     }
 }
예제 #3
0
 /// <summary>
 /// OBJECT类型转时间格式
 /// </summary>
 /// <param name="obj">obj对象</param>
 /// <returns></returns>
 public static DateTime GetObjDateTime(object obj)
 {
     if (DxPublic.IsObjNull(obj))
     {
         return(new System.DateTime(2020, 1, 1));
     }
     return(System.Convert.ToDateTime(obj));
 }
예제 #4
0
        /// <summary>
        /// Obj转成GUID
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns></returns>
        public static System.Guid GetObjGUID(object obj)
        {
            string objectString = DxPublic.GetObjString(obj);

            System.Guid result;
            if (!System.Guid.TryParse(objectString, out result))
            {
                result = System.Guid.Parse("00000000-0000-0000-0000-000000000000");
            }
            return(result);
        }
        /// <summary>
        /// 根据用户ID获取用户权限列表
        /// </summary>
        /// <param name="guidUserId">用户ID</param>
        /// <returns>用户列表</returns>
        public IList <Models.ACL_Role_Function> GetUserFunctionList(Guid sysetemId, Guid userId, Guid departmentId)
        {
            string    sqlText = string.Format(@"select DISTINCT  a.RoleId,a.FunctionId,a.OpCode,b.FuncName 
             from ACL_Role_Function as a inner join ACL_Function as b  on a.FunctionId=b.Id  
			                             inner join ACL_Role as c on a.RoleId=c.Id
			 where  b.SystemId='{0}' and RoleId in ( select distinct  RoleId from ACL_Role_User where UserId='{1}' 
                union select RoleId from ACL_Role_Department where DepartmentId='{2}')", sysetemId, userId, departmentId);
            DataTable dt      = Global._SqlDb.ExecuteDataTable(sqlText);

            return(DxPublic.DataTableToList <Models.ACL_Role_Function>(dt));
        }
예제 #6
0
        /// <summary>
        /// 异常信息提示
        /// </summary>
        /// <param name="ex">异常</param>
        /// <param name="Caption">提示框名称</param>
        public static void ShowExceptionFormat(Exception ex, string Caption = "系统提示")
        {
            string content = string.Format("Message:{0} {1} Source:{2} {1} StackTrace:{3}", new object[]
            {
                ex.Message,
                System.Environment.NewLine,
                ex.Source,
                ex.StackTrace
            });

            DxPublic.ShowMessage(MessageBoxIcon.Hand, content, Caption);
        }
예제 #7
0
        /// <summary>
        /// 获取登录信息
        /// </summary>
        /// <returns name="LoginInfo">登录信息</returns>
        public static vwModels.LoginInfo GetLoginInfo()
        {
            var loginInfo = new vwModels.LoginInfo();

            loginInfo.LoginName = GetValue("LoginName");
            loginInfo.IsRberPwd = Convert.ToBoolean(GetValue("IsRberPwd", "false"));
            if (loginInfo.IsRberPwd)
            {
                loginInfo.LoginPwd = DxPublic.DecryptString(GetValue("LoginPwd"));
            }
            return(loginInfo);
        }
예제 #8
0
 /// <summary>
 /// 设置登录信息
 /// </summary>
 /// <param name="loginInfo">登录信息</param>
 /// <returns></returns>
 public static bool SetLoginInfo(vwModels.LoginInfo loginInfo)
 {
     loginInfo.LoginPwd = DxPublic.EncryptString(loginInfo.LoginPwd);
     if (!loginInfo.IsRberPwd)
     {
         loginInfo.LoginPwd = "";
     }
     if (SetValue("LoginName", loginInfo.LoginName) &&
         SetValue("LoginPwd", loginInfo.LoginPwd) &&
         SetValue("IsRberPwd", loginInfo.IsRberPwd.ToString()))
     {
         return(true);
     }
     return(false);
 }
예제 #9
0
 /// <summary>
 /// 启动更新程序
 /// </summary>
 public static void StartUpdate()
 {
     try
     {
         Process[] processesByName = Process.GetProcessesByName(Global._AppProName);
         Process[] array           = processesByName;
         for (int i = 0; i < array.Length; i++)
         {
             Process process = array[i];
             process.Kill();
         }
         Process.Start(Global._AppUpdateName);
     }
     catch (Exception ex)
     {
         DxPublic.ShowException(ex);
     }
 }
예제 #10
0
        /// <summary>
        /// 程序是否有更新
        /// </summary>
        /// <returns></returns>
        public static bool IsNeedUpdate()
        {
            bool result = false;

            try
            {
                string          FileName = Global._AppUpdateList;
                AutoUpXmlHelper xdoc     = new AutoUpXmlHelper(FileName);
                string          version  = xdoc.GetNodeValue("AutoUpdate/Application/Version");
                result = Global._AppRight.IsUpdateVersion(Global._Session._SystemId, version);
            }
            catch (Exception ex)
            {
                DxPublic.ShowException(ex);
                result = false;
            }
            return(result);
        }
예제 #11
0
 /// <summary>
 /// 获取连接字符串
 /// </summary>
 /// <param name="key">连接字符串键</param>
 /// <returns></returns>
 public static string GetConnectionString(string name)
 {
     try
     {
         var value = ConfigurationManager.ConnectionStrings[name].ConnectionString;
         if (string.IsNullOrEmpty(value))
         {
             throw new Exception($"读取配置文件的连接字符串出错!");
         }
         else
         {
             return(DxPublic.DecryptString(value));
         }
     }
     catch
     {
         return("");
     }
 }
예제 #12
0
        /// <summary>
        /// 读取文件文本信息
        /// </summary>
        /// <param name="FileName">文件名</param>
        /// <returns></returns>
        public static string ReadTextFile(string FileName)
        {
            if (!DxPublic.GetFileExists(FileName))
            {
                throw new System.Exception("文件不存在!!");
            }
            System.IO.StreamReader streamReader = null;
            string result;

            try
            {
                streamReader = new System.IO.StreamReader(FileName, System.Text.Encoding.UTF8);
                result       = streamReader.ReadToEnd();
            }
            finally
            {
                if (streamReader != null)
                {
                    streamReader.Close();
                    streamReader.Dispose();
                }
            }
            return(result);
        }
예제 #13
0
 /// <summary>
 /// 获取连接字符串,存在则修改,不存在则添加
 /// </summary>
 /// <param name="key">连接字符串键</param>
 /// <param name="connString">连接字符串</param>
 /// <returns></returns>
 public static bool SetConnectionString(string name, string connString, string providerName = "System.Data.SqlClient")
 {
     try
     {
         var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         var settings   = configFile.ConnectionStrings.ConnectionStrings;
         connString = DxPublic.EncryptString(connString);
         if (settings[name] == null)
         {
             settings.Add(new ConnectionStringSettings(name, connString, providerName));
         }
         else
         {
             settings[name].ConnectionString = connString;
         }
         configFile.Save(ConfigurationSaveMode.Modified);
         ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception($"定入配置文件出错:{ex.Message}");
     }
 }
예제 #14
0
 /// <summary>
 /// 获取打开的XLS文件名称
 /// </summary>
 /// <param name="DefaultFileName">默认文件名</param>
 /// <returns></returns>
 public static string GetOpenXlsFileName(string DefaultFileName)
 {
     return(DxPublic.GetOpenFileName("EXCEL File(*.xls)|*.xls", DefaultFileName));
 }
예제 #15
0
 /// <summary>
 /// Obj转成大定的String类型
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns></returns>
 public static string GetObjStrUpperTrim(object obj)
 {
     return(DxPublic.GetObjString(obj).Trim().ToUpper());
 }
예제 #16
0
 /// <summary>
 /// 获取系统ID
 /// </summary>
 /// <returns></returns>
 public static Guid GetSystemId()
 {
     return(DxPublic.GetObjGUID(AppSetingHelper.GetValue("SystemId")));
 }