using GenerateCode_GEBrilliantFactory.Model;
using GenerateCode_WeiBen_WMS.Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
namespace GenerateCode_GEBrilliantFactory
{
///
/// 公共类
///
public class CommonHelper
{
///
/// 是否忽略该列
///
///
///
public static bool IsIgnore(string columnName)
{
if (columnName.ToUpper() == SystemCommonVar.c_ExtraProperties.ToUpper()
|| columnName.ToUpper() == SystemCommonVar.c_ConcurrencyStamp.ToUpper()
)
{
return true;
}
return false;
}
///
/// 通用替换字符串
///
///
///
public static void CommonReplaceStr(GenerateCodeParam param, ref string str)
{
str = str.Replace("$NameSpacePath$", param.NameSpacePath);//命名空间
str = str.Replace("$ChinaComment$", param.ChinaComment);//中文注释
str = str.Replace("$EntityName$", param.EntityName);//实体类名
str = str.Replace("$Modulelogo$", param.Modulelogo);//模块简写
}
///
/// 首字母小写
///
///
///
public static string FirstLowercase(string str)
{
if (string.IsNullOrEmpty(str))
{
return str;
}
str = str.Substring(0, 1).ToLower() + str.Substring(1);
return str;
}
///
/// 获取存储过程名
///
///
///
public static ProcName GetProcName(string moduleName)
{
string procPrefix = "uspWip_";
ProcName procName = new ProcName()
{
AddProc = procPrefix + "Add" + moduleName,
UpdateProc = procPrefix + "Update" + moduleName,
GetSingleProc = procPrefix + "GetSingle" + moduleName,
ListProc = procPrefix + "Get" + moduleName + "List",
PageListProc = procPrefix + "Get" + moduleName + "PageList",
};
return procName;
}
///
/// 回车符
///
public const string enterStr = "\n";
///
/// 单个回车符的字符串
///
///
///
public static string GetSinleEnterStr(string content)
{
return content + enterStr;
}
///
/// 两个回车符的字符串
///
///
///
public static string GetDoubleEnterStr(string content)
{
return content + enterStr + enterStr;
}
///
/// 当前时间字符串
///
///
public static string GetCurDate()
{
return DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day
+ " "
+ DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
}
///
/// 首字母大写
///
///
///
public static string TitleToUpper(string str)
{
if (string.IsNullOrWhiteSpace(str))
return string.Empty;
char[] s = str.ToCharArray();
char c = s[0];
if ('a' <= c && c <= 'z')
c = (char)(c & ~0x20);
s[0] = c;
return new string(s);
}
///
/// 首字母小写
///
///
///
public static string TitleToLower(string str)
{
if (string.IsNullOrWhiteSpace(str))
return string.Empty;
char[] s = str.ToCharArray();
char c = s[0];
if ('A' <= c && c <= 'Z')
c = char.ToLower(c);
s[0] = c;
return new string(s);
}
///
/// 获取数据库连接字符串列表
///
///
public static List GetDataSources()
{
List list = new List();
ConnectionStringSettingsCollection conn = ConfigurationManager.ConnectionStrings;
foreach (ConnectionStringSettings item in conn)
{
if (item.Name == "LocalSqlServer")
continue;
ListItem listItem = new ListItem()
{
Text = item.Name,
Value = item.ConnectionString
};
list.Add(listItem);
}
return list;
}
///
/// 获取数据库类型列表
///
///
public static List GetDataBase()
{
List list = new List();
ListItem listItem = new ListItem()
{
Text = DataBaseEnum.MySql.ToString(),
Value = DataBaseEnum.MySql.ToString()
};
list.Add(listItem);
listItem = new ListItem()
{
Text = DataBaseEnum.SqlServer.ToString(),
Value = DataBaseEnum.SqlServer.ToString()
};
list.Add(listItem);
return list;
}
}
///
/// 文件类型
///
public enum FileType
{
///
/// 实体类文件
///
Model = 0,
///
/// DAO文件
///
DAO = 1,
///
/// IBLL文件
///
IBLL = 2,
///
/// BLL文件
///
BLL = 3,
///
/// Controller文件
///
Controller = 4,
///
/// JS文件
///
JS = 5,
///
/// 列表页面
///
CSHTML_List = 6,
///
/// XML文件
///
XML = 7,
///
/// 详情页面
///
CSHTML_Detail = 8,
///
/// 存储过程文件
///
Proc = 9,
///
/// DAL 文件
///
DAL = 10,
///
/// InputModel
///
InputModel = 11,
///
/// WCF接口文件
///
WCF_InterFace = 12,
///
/// WCF接口实现文件
///
WCF_InterFaceRealize = 13,
///
/// InsertSQL
///
SQL_Insert = 14,
///
/// VUE方法配置
///
VUE_FunConfig = 15,
///
/// VUE文件
///
VUEFile = 16,
///
/// 新增实体参数类
///
AddModelParam = 17,
///
/// OutputModel
///
OutputModel = 18,
}
}