/// <summary> /// SURE_MENU - 获取全部信息 /// </summary> /// <returns>全部信息集合</returns> public static List <SURE_MENU> GET_SURE_MENU() { try { return(DbHelper.Database().FindList <SURE_MENU>()); } catch (Exception ex) { Log4net.log4netCreate(typeof(DEFAULTDAL), log4netPath) .Error("GET_SURE_MENU() ----> " + ex.Message); return(new List <SURE_MENU>()); } }
public void EmployeeCreation() { try { Log4net.LogWriter("EmployeeCreation", "EmpCreation", "SAPEmpCreation Started." + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt"), LogType.LogMode.Debug); SAPEmpCreation(); Log4net.LogWriter("EmployeeCreation", "EmpCreation", "SAPEmpCreation Ended." + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt"), LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("EmployeeCreation", "EmpCreation", ex.Message, LogType.LogMode.Error); } }
/// <summary> /// INSERT_SURE_GENERATED - 新增信息 /// </summary> /// <param name="model">入参</param> /// <returns>是否成功</returns> public static int INSERT_SURE_GENERATED(SURE_GENERATED model) { try { return(DbHelper.Database().Insert <SURE_GENERATED>(model)); } catch (Exception ex) { Log4net.log4netCreate(typeof(SURE_GENERATEDDAL), log4netPath) .Error("INSERT_SURE_GENERATED(SURE_GENERATED model) ----> " + ex.Message); return(0); } }
/// <summary> /// SURE_MENU - 修改信息 /// </summary> /// <param name="model">入参</param> /// <returns>是否成功</returns> public static int UPDATE_SURE_MENU(SURE_MENU model) { try { return(DbHelper.Database().Update <SURE_MENU>(model)); } catch (Exception ex) { Log4net.log4netCreate(typeof(DEFAULTDAL), log4netPath) .Error("UPDATE_SURE_MENU(SURE_MENU model) ----> " + ex.Message); return(0); } }
private void toolMenuUpdatePwd_Click(object sender, EventArgs e) { FrmUpdatePwd pwd = new FrmUpdatePwd(); DialogResult Restart = pwd.ShowDialog(); //密码修改成功,意味着需要重新登录 if (Restart == DialogResult.OK) { Log4net.WriteInfo($"[{Program.CurrentAdmin.LoginId}]成功修改密码"); this.Close();//主线程关闭 //修改密码之后重启 } }
/// <summary> /// SAPPlantUpdation /// </summary> private void SAPPlantUpdation() { long TimeTookticks = DateTime.Now.Ticks; List <string> inputCC = new List <string>(); EMPCreationCore _empCreation = new EMPCreationCore(); try { var SqlConn = new ConcreteConnectionsFactory().GetConnection("IILHome"); SqlConn.Connection("connection"); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPPlantUpdation || Started : " + Tools.TicksToTime(DateTime.Now.Ticks), Entities.LogType.LogMode.Debug); inputCC.Add("T001W"); inputCC.Add(""); inputCC.Add("WERKS|NAME1|VKORG"); Service.SAPFactory.SAPServiceManager _sapservice = new Service.SAPFactory.SAPServiceManager(); var SAPConnect = _sapservice.GetSAPService("datatable"); DataTable dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "GetTableData"); _sapservice = null; SAPConnect = null; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPPlantUpdation || dtService count: " + dtService.Rows.Count.ToString(), Entities.LogType.LogMode.Debug); if (dtService != null && dtService.Rows.Count > 0) { dtService.TableName = "Data"; string CCXML = Tools.ConvertDataTableToXMLString(dtService); _empCreation.UpdateToDb(CCXML, "PlntUpd_T"); } Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPPlantUpdation || Ended : " + Tools.TicksToTime(TimeTookticks), Entities.LogType.LogMode.Debug); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPPlantUpdation || Ended: --------------------------------" + Environment.NewLine + "" + Environment.NewLine, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || Error : " + ex.Message, Entities.LogType.LogMode.Error); } finally { inputCC = null; _empCreation = null; } }
/// <summary> /// 创建生成文件 /// </summary> /// <param name="fileName">路径</param> /// <param name="content">内容</param> private void CreateFile(string fileName, string content) { try { string filePath = Server.MapPath(fileName); FileStream fileStream = System.IO.File.Create(filePath); //创建文件 fileStream.Close(); StreamWriter sw = new StreamWriter(filePath); //创建写入流 sw.Write(content); sw.Flush(); sw.Close(); } catch (Exception ex) { Log4net.log4netCreate(typeof(GeneratedFileController), log4netPath) .Error("CreateFile(string fileName, string content) ---- >" + ex.Message); throw; } }
/// <summary> /// 登录事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { if (txtLoginId.CheckData(@"^\\d+$", "账号输入有误!") * txtLoginPwd.CheckNullOrEmpty() != 0) { SysAdmins sys = new SysAdmins() { LoginId = Convert.ToInt32(txtLoginId.Text.Trim()), LoginPwd = txtLoginPwd.Text.Trim() }; try { sys = adminManager.AdminLogin(sys); Log4net.WriteInfo($"账号[{sys.LoginId}]开始登录"); if (sys != null) { if (sys.AdminStatus == 1) { Log4net.WriteInfo($"[{sys.LoginId}]登录成功!"); Program.CurrentAdmin = sys; this.DialogResult = DialogResult.OK; this.Close(); } else { Log4net.WriteInfo($"[{sys.LoginId}]账号被禁用"); MessageBox.Show("当前管理员账号已被禁用!", "登录提示"); } } else { Log4net.WriteInfo($"[{sys.LoginId}]账号或密码错误登录失败"); } } catch (Exception ex) { Log4net.WriteError($"[{sys.LoginId}]登录发生异常", ex); return; } } }
//根据数据库联动表名 public JsonResult LoginTable(string localDB) { try { string strConnction = string.Concat(new string[] { "SERVER=", CacheGeneral.GetCache("key_localIP").ToString(), ";DATABASE=MASTER;UID=", CacheGeneral.GetCache("key_userAccount").ToString(), ";PWD=", CacheGeneral.GetCache("key_userPwd").ToString() }); string sqlStr = @"SELECT TABLE_NAME FROM " + localDB + ".INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME"; string message = (string)null; ArrayList dataByConAndSql = dbHelper.GetDataByConAndSql(strConnction, sqlStr, out message); return(Json(new { message = "Success", content = JsonConvert.SerializeObject(dataByConAndSql) })); } catch (Exception ex) { Log4net.log4netCreate(typeof(GeneratedFileController), log4netPath) .Error("LoginTable(string localDB) ---- > " + ex.Message); return(Json(new { message = "Fail", content = "表查询错误," + ex.Message })); } }
/// <summary> /// 根据键值对替换值 /// </summary> /// <param name="str">需替换的字符串</param> /// <param name="dri">键值对集合</param> /// <returns>string 替换之后的字符串</returns> private string SplitStr(string str, Dictionary <string, string> dictionary) { try { string resultStr = string.Empty; if (dictionary.Count <= 0) { return(string.Empty); } foreach (var dirItem in dictionary) { str = str.Replace(dirItem.Key, dirItem.Value); resultStr = str; } return(resultStr); } catch (Exception ex) { Log4net.log4netCreate(typeof(GeneratedFileController), log4netPath) .Error("SplitStr(string str, Dictionary<string, string> dictionary) ----> " + ex.Message); return("替换错误 ! "); } }
public bool Update(Log4net item, Session session = null) { //LoggerFactory.CreateLog().Start(); var committed = 0; try { //if (session != null) // _repositoryLog4net.UnitOfWork.SetConnectionDb(session.ConnectionString); if (item == null) { throw new ArgumentNullException("item"); } var validator = EntityValidatorFactory.CreateValidator(); if (validator.IsValid(item)) { // Domain Services? //_repositoryLog4net.Update(Mapper.Map<Dominio.Entidades.Log4net>(item)); _repositoryLog4net.Update(item); committed = _unitOfWorkAsync.SaveChanges(); } else { throw new ApplicationValidationErrorsException(validator.GetInvalidMessages(item)); } } catch (Exception ex) { //LoggerFactory.CreateLog().Error(ex); } //LoggerFactory.CreateLog().Stop(); //_repositoryLog4net.Update(entity); return(committed > 0); }
static DependencyResolver() { Logger = new Log4net(); RoleDao = new RoleDao(Logger); UserDao = new UserDao(Logger, RoleDao); CategoryDao = new CategoryDao(Logger); ProductDao = new ProductDao(Logger, CategoryDao); StoreDao = new StoreDao(Logger); VendorDao = new VendorDao(Logger); StatusDao = new StatusDao(Logger); CommodityUnitDao = new CommodityUnitDao(Logger, ProductDao, StatusDao, StoreDao, VendorDao); RoleBll = new RoleBll(Logger, RoleDao); UserBll = new UserBll(Logger, RoleBll, UserDao); CategoryBll = new CategoryBll(Logger, CategoryDao, CommodityUnitDao); ProductBll = new ProductBll(Logger, CategoryBll, ProductDao, CommodityUnitDao); StoreBll = new StoreBll(Logger, StoreDao, CommodityUnitDao); VendorBll = new VendorBll(Logger, VendorDao, CommodityUnitDao); StatusBll = new StatusBll(Logger, StatusDao, CommodityUnitDao); CommodityUnitBll = new CommodityUnitBll(Logger, CategoryBll, ProductBll, StatusBll, StoreBll, VendorBll, CommodityUnitDao); AuthenticationBll = new AuthenticationBll(UserBll); }
private void SAPEmpCreation() { #region ** String variable declaration ** string strEmpNo = string.Empty; string strSex = string.Empty; string strTitle = string.Empty; string strFather = string.Empty; string strEmpType = string.Empty; string strMaritalStatus = string.Empty; string strDob = string.Empty; string strDoj = string.Empty; string strQuarters = string.Empty; string strBankMode = string.Empty; string strEmpName = string.Empty; string strAddress1 = string.Empty; string strAddress2 = string.Empty; string strAddress3 = string.Empty; string strPostal = string.Empty; string strEmpLocation = string.Empty; string strDesig = string.Empty; string strGrade = string.Empty; string strScale = string.Empty; string strDepartment = string.Empty; string strDoc = string.Empty; #endregion long TimeTookticks = DateTime.Now.Ticks; EMPCreationCore _empCreation = new EMPCreationCore(); DataSet _dsObject = new DataSet(); List <string> inputCC = new List <string>(); DataTable dtService = new DataTable(); try { var SqlConn = new ConcreteConnectionsFactory().GetConnection("IILHome"); SqlConn.Connection("connection"); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Started : " + Tools.TicksToTime(DateTime.Now.Ticks), Entities.LogType.LogMode.Debug); /* ------------ Getting maximum Employee Number from legacy ------------ */ try { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Getting maximum Employee Number from legacy || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.GetOrSetChangesToDB("getMaxEmpId"); _dsObject.Tables[0].TableName = "getMaxEmpId"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Getting maximum Employee Number from legacy || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| Getting maximum Employee Number from legacy || Error : " + ex.Message, Entities.LogType.LogMode.Error); } /* ------------ END : Getting maximum Employee Number from legacy ------------ */ if (Tools.IsNullDataSet(_dsObject)) { inputCC.Add(_dsObject.Tables["getMaxEmpId"].Rows[0]["EmpCount"].ToString()); Service.SAPFactory.SAPServiceManager _sapservice = new Service.SAPFactory.SAPServiceManager(); var SAPConnect = _sapservice.GetSAPService("datatable"); dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "R3EmpCreation"); _sapservice = null; SAPConnect = null; inputCC = null; inputCC = new List <string>(); // New employee detail fetched from SAP will updated into the IIL Home Database if (dtService != null && dtService.Rows.Count > 0) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || R3EmpCreation || Rows : " + dtService.Rows.Count, Entities.LogType.LogMode.Debug); foreach (DataRow dr in dtService.Rows) { DataTable _dtInternalServ = new DataTable(); try { strEmpNo = dr["Empno"].ToString().Substring(2, 6); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || EmpCreation_chkEmpExists: Started || strEmpNo : " + strEmpNo, Entities.LogType.LogMode.Debug); _dtInternalServ = (DataTable)_empCreation.EmpCreation_chkEmpExists(strEmpNo); _dtInternalServ.TableName = "chkEmpExists"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || EmpCreation_chkEmpExists: Ended || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| Checking whether Employee already exists in the legacy || Error : " + ex.Message, Entities.LogType.LogMode.Error); } Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || chkEmpExists || Rows : " + _dtInternalServ.Rows.Count, Entities.LogType.LogMode.Debug); if (_dtInternalServ != null && _dtInternalServ.Rows.Count <= 0) { #region ********** Employee Sex ********** if (Convert.ToInt32(dr["Empsex"].ToString()) == 1) { strSex = "M"; strTitle = "Mr."; } else { strSex = "F"; strTitle = "Miss"; } #endregion ********** Employee Sex ********** #region ********** Fetching employee father name ********** try { inputCC.Add("PA0021"); inputCC.Add("PERNR EQ " + dr["EmpNo"].ToString()); inputCC.Add("SUBTY|FANAM"); _sapservice = new Service.SAPFactory.SAPServiceManager(); SAPConnect = _sapservice.GetSAPService("datatable"); dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "GetTableData"); _sapservice = null; SAPConnect = null; inputCC = null; inputCC = new List <string>(); if (dtService != null && dtService.Rows.Count > 0) { foreach (DataRow dr1 in dtService.Rows) { if (Convert.ToInt32(dr1["SubType"].ToString()) == 11) { strFather = dr1["FatherName"].ToString(); } } } else { // No Details found in SAP; } } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| Employee Father Name from another RFC(from Table) || Error : " + ex.Message, Entities.LogType.LogMode.Error); } #endregion ********** Fetching employee father name ********** #region ********** Employee Type based on Designation ********** if (dr["Designation"] != null && !string.IsNullOrEmpty(dr["Designation"].ToString()) && Tools.ConvertToInt(dr["Designation"].ToString()) == 0) { if ( (dr["Grade"] != null && !string.IsNullOrEmpty(dr["Grade"].ToString())) && (dr["Grade"].ToString() == "O1" || dr["Grade"].ToString() == "A1" || dr["Grade"].ToString() == "A3" || dr["Grade"].ToString() == "E2" || dr["Grade"].ToString() == "O2" || dr["Grade"].ToString() == "A2" || dr["Grade"].ToString() == "E1" || dr["Grade"].ToString() == "E3") ) { strEmpType = "FT-OFF"; } else if (dr["Grade"].ToString().Substring(0, 1).ToUpper() == "T") { strEmpType = "TRAINE"; } else { strEmpType = "FT-MGR"; } } else { _dsObject = null; _dsObject = new DataSet(); try { string strDesgination = (dr["Designation"] != null && !string.IsNullOrEmpty(dr["Designation"].ToString())) ? dr["Designation"].ToString() : string.Empty; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Checking whether Employee already exists in the legacy || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.GetEmpTypeBasedonDesig(strDesgination); _dsObject.Tables[0].TableName = "getEmpTypeBasedonDesig"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Checking whether Employee already exists in the legacy || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| Checking whether Employee already exists in the legacy || Error : " + ex.Message, Entities.LogType.LogMode.Error); } if (_dsObject.Tables["getEmpTypeBasedonDesig"] != null && _dsObject.Tables["getEmpTypeBasedonDesig"].Rows.Count > 0) { strEmpType = _dsObject.Tables["getEmpTypeBasedonDesig"].Rows[0]["sapdesc"].ToString(); } else { if ( (dr["Grade"] != null && !string.IsNullOrEmpty(dr["Grade"].ToString())) && (dr["Grade"].ToString() == "O1" || dr["Grade"].ToString() == "A1" || dr["Grade"].ToString() == "A3" || dr["Grade"].ToString() == "E2" || dr["Grade"].ToString() == "O2" || dr["Grade"].ToString() == "A2" || dr["Grade"].ToString() == "E1" || dr["Grade"].ToString() == "E3") ) { strEmpType = "FT-OFF"; } else if (dr["Grade"].ToString().Substring(0, 1).ToUpper() == "T") { strEmpType = "TRAINE"; } else { strEmpType = "FT-MGR"; } } } #endregion ********** Employee Type based on Designation ********** #region ********** Employee Marital Status ********** if (dr["Marstatus"] != null && dr["Marstatus"].ToString() == "1") { strMaritalStatus = "M"; } else { strMaritalStatus = "N"; } #endregion ********** Employee Marital Status ********** #region ********** Date of Birth ********** string strTempDbMon = (dr["Dateofbirth"] != null && !string.IsNullOrEmpty(dr["Dateofbirth"].ToString())) ? dr["Dateofbirth"].ToString().Substring(5, 2) : string.Empty; string strTempDbDay = (dr["Dateofbirth"] != null && !string.IsNullOrEmpty(dr["Dateofbirth"].ToString())) ? dr["Dateofbirth"].ToString().Substring(8, 2) : string.Empty; if (strTempDbMon.Length == 1) { strTempDbMon = "0" + strTempDbMon; } if (strTempDbDay.Length == 1) { strTempDbDay = "0" + strTempDbDay; } strDob = (dr["Dateofbirth"] != null && !string.IsNullOrEmpty(dr["Dateofbirth"].ToString())) ? dr["Dateofbirth"].ToString().Substring(0, 4) + "-" + strTempDbMon + "-" + strTempDbDay : string.Empty; #endregion ********** Date of Birth ********** #region ********** Date of Joining ********** string strTempDjMon = (dr["Dateofjoining"] != null && !string.IsNullOrEmpty(dr["Dateofjoining"].ToString())) ? dr["Dateofjoining"].ToString().Substring(5, 2) : string.Empty; string strTempDjDay = (dr["Dateofjoining"] != null && !string.IsNullOrEmpty(dr["Dateofjoining"].ToString())) ? dr["Dateofjoining"].ToString().Substring(8, 2) : string.Empty; if (strTempDjMon.Length == 1) { strTempDjMon = "0" + strTempDjMon; } if (strTempDjDay.Length == 1) { strTempDjDay = "0" + strTempDjDay; } strDoj = (dr["Dateofjoining"] != null && !string.IsNullOrEmpty(dr["Dateofjoining"].ToString())) ? dr["Dateofjoining"].ToString().Substring(0, 4) + "-" + strTempDjMon + "-" + strTempDjDay : string.Empty; #endregion ********** Date of Joining ********** #region ********** Date of Confimation ********** if (dr["empsubgroup"] != null && !string.IsNullOrEmpty(dr["empsubgroup"].ToString()) && dr["empsubgroup"].ToString().ToUpper() == "T") { strDoc = ""; } else { strDoc = strDoj; } #endregion ********** Date of Confimation ********** #region ********** Employee Quarters ********** if (dr["EmpQuarters"] != null && !string.IsNullOrEmpty(dr["EmpQuarters"].ToString()) && dr["EmpQuarters"].ToString().ToUpper() == "X") { strQuarters = "1"; } else { strQuarters = "0"; } try { inputCC.Add("PA0021"); inputCC.Add("PERNR EQ " + dr["EmpNo"].ToString()); inputCC.Add("SUBTY|FANAM"); _sapservice = new Service.SAPFactory.SAPServiceManager(); SAPConnect = _sapservice.GetSAPService("datatable"); dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "GetTableData"); _sapservice = null; SAPConnect = null; inputCC = null; inputCC = new List <string>(); if (dtService != null && dtService.Rows.Count > 0) { foreach (DataRow dr2 in dtService.Rows) { if (dr2["Bankmode"] != null && !string.IsNullOrEmpty(dr2["Bankmode"].ToString()) && dr2["Bankmode"].ToString().ToUpper() == "CHEQUE") { strBankMode = "CHQ"; } else if (dr2["Bankmode"] != null && !string.IsNullOrEmpty(dr2["Bankmode"].ToString()) && dr2["Bankmode"].ToString().ToUpper() == "DD") { strBankMode = "DD"; } else { strBankMode = "BANK"; } } } else { //no details found in sap } } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| Employee Bank Mode from another RFC(from Table) || Error : " + ex.Message, Entities.LogType.LogMode.Error); } //AddressDetails strEmpName = Tools.IsNull(dr["Empname"]) ? dr["Empname"].ToString().Replace("'", "") : string.Empty; strAddress1 = Tools.IsNull(dr["Address1"]) ? dr["Address1"].ToString().Replace("'", "") : string.Empty; strAddress2 = Tools.IsNull(dr["Address2"]) ? dr["Address2"].ToString().Replace("'", "") : string.Empty; strAddress3 = Tools.IsNull(dr["Address3"]) ? dr["Address3"].ToString().Replace("'", "") : string.Empty; strPostal = Tools.IsNull(dr["Postal"]) ? dr["Postal"].ToString().Replace("'", "") : string.Empty; //Employee Location if ((Tools.IsNull(dr["EmpPerArea"])) && ((dr["EmpPerArea"].ToString() == "3000") && (dr["EmpPayArea"].ToString() == "IG" || dr["EmpPayArea"].ToString() == "IC"))) { strEmpLocation = "102"; } else if ((Tools.IsNull(dr["EmpPerArea"])) && ((dr["EmpPerArea"].ToString() == "3000") && (dr["EmpPayArea"].ToString() != "IG" || dr["EmpPayArea"].ToString() != "IC"))) { strEmpLocation = dr["EmpSaploc"].ToString().Replace("'", ""); } else if ((Tools.IsNull(dr["EmpPerArea"])) && ((dr["EmpPerArea"].ToString() == "4000") && (dr["EmpPayArea"].ToString() == "IG" || dr["EmpPayArea"].ToString() == "IC"))) { strEmpLocation = "101"; } else if ((Tools.IsNull(dr["EmpPerArea"])) && ((dr["EmpPerArea"].ToString() == "4000") && (dr["EmpPayArea"].ToString() != "IG" || dr["EmpPayArea"].ToString() != "IC"))) { strEmpLocation = dr["EmpSaploc"].ToString().Replace("'", ""); } else if ((Tools.IsNull(dr["EmpPerArea"])) && (dr["EmpPerArea"].ToString() == "5000" && dr["EmpSaploc"].ToString() == "IGAP")) { strEmpLocation = "101"; } else if ((Tools.IsNull(dr["EmpPerArea"])) && (dr["EmpPerArea"].ToString() == "7000")) { strEmpLocation = "104"; } else if ((Tools.IsNull(dr["EmpPerArea"])) && (dr["EmpPerArea"].ToString() == "5000" && dr["EmpSaploc"].ToString() != "IGAP")) { strEmpLocation = dr["EmpSaploc"].ToString(); } else if ((Tools.IsNull(dr["EmpPerArea"])) && ((dr["EmpPerArea"].ToString() == "1100") && (dr["EmpPayArea"].ToString() == "IO"))) { strEmpLocation = "103"; } else if ((Tools.IsNull(dr["EmpPerArea"])) && (dr["EmpPerArea"].ToString().Replace("'", "").Trim().ToUpper() == "1000")) { //added this if from empupdation.else part(is existing) not added from empupdation if ((Tools.IsNull(dr["EmpPerArea"])) && (dr["EmpSaploc"].ToString() == "1003" && dr["EmpPayArea"].ToString() == "IL")) { strEmpLocation = dr["EmpSaploc"].ToString(); } else { _dsObject = null; _dsObject = new DataSet(); try { string EmpPerArea = Tools.IsNull(dr["EmpPerArea"]) ? dr["EmpPerArea"].ToString() : string.Empty; string EmpPerSubArea = Tools.IsNull(dr["EmpPerSubArea"]) ? dr["EmpPerSubArea"].ToString() : string.Empty; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getSAPPerArea || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.GetSAPPerArea(EmpPerArea, EmpPerSubArea); _dsObject.Tables[0].TableName = "getSAPPerArea"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getSAPPerArea || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| USP_EmpCreation_getSAPPerArea || Error : " + ex.Message, Entities.LogType.LogMode.Error); } if (_dsObject != null && _dsObject.Tables["getSAPPerArea"].Rows.Count > 0) { strEmpLocation = _dsObject.Tables["getSAPPerArea"].Rows[0]["Loc_Code"].ToString(); } } } else { _dsObject = null; _dsObject = new DataSet(); try { string EmpPerArea = Tools.IsNull(dr["EmpPerArea"]) ? dr["EmpPerArea"].ToString() : string.Empty; string EmpPerSubArea = Tools.IsNull(dr["EmpPerSubArea"]) ? dr["EmpPerSubArea"].ToString() : string.Empty; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getSAPPerArea || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.GetSAPPerArea(EmpPerArea, EmpPerSubArea); _dsObject.Tables[0].TableName = "getSAPPerArea"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getSAPPerArea || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| USP_EmpCreation_getSAPPerArea || Error : " + ex.Message, Entities.LogType.LogMode.Error); } if (_dsObject != null && _dsObject.Tables["getSAPPerArea"].Rows.Count > 0) { strEmpLocation = _dsObject.Tables["getSAPPerArea"].Rows[0]["Loc_Code"].ToString(); } } _dsObject = null; _dsObject = new DataSet(); strDesig = Tools.IsNull(dr["Designation"]) ? dr["Designation"].ToString().Replace("'", "") : string.Empty; strDepartment = Tools.IsNull(dr["Dept"]) ? dr["Dept"].ToString().Replace("'", "").Substring(4, 4) : string.Empty; strGrade = Tools.IsNull(dr["Grade"]) ? dr["Grade"].ToString().Replace("'", "") : string.Empty; try { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getScaleCode || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.GetScaleCode(strGrade); _dsObject.Tables[0].TableName = "getSAPPerArea"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EmpCreation_getScaleCode || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| USP_EmpCreation_getScaleCode || Error : " + ex.Message, Entities.LogType.LogMode.Error); } if (_dsObject.Tables["getScaleCode"].Rows.Count > 0) { strScale = _dsObject.Tables["getScaleCode"].Rows[0]["Scl_Code"].ToString(); } try { EmpMasterTrans EMTrans = new EmpMasterTrans(); EMTrans.Flag = "I"; EMTrans.EmpId = strEmpNo; EMTrans.Title = strTitle; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EMPLOYEEMASTER_TRANSACTIONS || Started", Entities.LogType.LogMode.Debug); _dsObject = (DataSet)_empCreation.EmployeeMasterTransactions(strGrade); _dsObject.Tables[0].TableName = "getSAPPerArea"; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || USP_EMPLOYEEMASTER_TRANSACTIONS || Ended : " + DateTime.Now.TimeOfDay, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation|| USP_EMPLOYEEMASTER_TRANSACTIONS || Error : " + ex.Message, Entities.LogType.LogMode.Error); } #endregion #region ********** ********** #endregion #region ********** ********** #endregion } } // Making the datatable to null dtService = null; } } Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Ended : " + Tools.TicksToTime(TimeTookticks), Entities.LogType.LogMode.Debug); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Ended: --------------------------------" + Environment.NewLine + "" + Environment.NewLine, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPEmpCreation || Error : " + ex.Message, Entities.LogType.LogMode.Error); } }
public void ApplyChanges(Log4net entity) { _repositoryLog4net.ApplyChanges(entity); }
public Log4netCrudViewModel() { Log4net = new Log4net(); }
protected void Application_Start(object sender, EventArgs e) { Log4net.Info("程序启动"); }
/// <summary> /// 爬虫执行 /// </summary> public void Crawlers() { fileList = new List <Model.FileInfo>(); DateTime beginTime = DateTime.Now; int threadOrder = Convert.ToInt32(Thread.CurrentThread.Name); //线程ID long step = (maxValue - minValue + 1) / threadNumber; long beginValue = minValue + step * (threadOrder - 1); long endValue = beginValue + step; if (threadOrder == threadNumber) { endValue = beginValue + step + ((maxValue - minValue + 1) % threadNumber); } string msgUrl = string.Empty; for (long i = beginValue; i < endValue; i++) { try { string url = $"http://www.46ek.com/view/{listIndex[Convert.ToInt32(i) - 1]}.html"; string result = HTTPGeneral.HTTPCrawler(url, "GET"); string[] regexStrings = regexString.Split(','); Match match = null; for (int j = 0; j < regexStrings.Length; j++) { match = new Regex(regexStrings[j]).Match(result); if (match.Success) { break; } } if (!string.IsNullOrEmpty(match.Value)) { msgUrl = match.Value; //存储404链接 lock (o) { fileList.Add(new Model.FileInfo() { FileID = i.ToString(), //从1开始 FileName = match.Value.Substring(match.Value.LastIndexOf('/') + 1), FileSize = GetFileSize(match.Value), FileUrl = match.Value, SynProgress = "0%", Tag = "等待", SynSpeed = "0KB", DownPath = match.Value, Async = true }); Console.WriteLine(match.Value); Thread.Sleep(1000); } } } catch (Exception ex) { Log4net.log4netCreate(typeof(ThreadCrawler), log4netPath).Error($"爬取地址[{msgUrl}]访问错误,信息: " + ex.Message); Thread.Sleep(1000); continue; } } DateTime endTime = DateTime.Now; TimeSpan timeSpan = endTime - beginTime; string message = "线程ID:" + Thread.CurrentThread.Name + " ----> Start: " + beginValue.ToString() + " -- End:" + endValue.ToString() + ", 耗时:" + timeSpan.TotalMinutes.ToString() + "分钟。"; Console.WriteLine(message); Thread.CurrentThread.Abort(); }
public void Log(string tableID, string className, string paramState, string userID, string roleName, string welfareCentreID, string clientIP) { int pState = 0; if (paramState != "") { pState = Convert.ToInt32(paramState); } #region Log4net对象 var item = new Log4net(); item.LogID = Guid.NewGuid(); item.log_date = DateTime.Now; item.log_WelfareCentreID = new Guid(welfareCentreID); item.log_TableID = tableID; item.log_UserID = new Guid(userID); item.log_UserName = roleName; item.log_State = paramState; switch (pState) { case 1: item.log_StateName = "添加操作."; break; case 2: item.log_StateName = "修改操作."; break; case 3: item.log_StateName = "逻辑操作."; break; case 4: item.log_StateName = "物理操作."; break; case 5: item.log_StateName = "启用操作."; break; case 6: item.log_StateName = "禁用操作."; break; default: item.log_StateName = "操作."; break; } item.log_ClassName = className; item.log_logger = clientIP; item.log_message = "参数-表ID:" + tableID + "用户ID:" + userID + "用户名称:" + roleName + "操作日期:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "养老院ID:" + welfareCentreID; bool IsFlag = AddLog4net(true, item); if (!IsFlag) { MessageLog.WriteLog(new LogParameterModel { ClassName = className, MethodName = paramState, MethodParameters = "添加日志操作.", LogLevel = ELogLevel.Info, Message = "参数-表ID:" + tableID + "用户ID:" + userID + "用户名称:" + roleName + "操作日期:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "养老院ID:" + welfareCentreID, PathPrefix = "/log/ws/logs", LogExt = "txt" }); } #endregion }
public bool AddLog4net(bool IsAdd, Log4net item) { var szServices = new DbHelperEfSql <Log4net>(); return(IsAdd ? szServices.Add(item) : szServices.Update(item, c => c.LogID == item.LogID)); }
/// <summary> /// SAP Cost Center Updation /// </summary> private void SAPCostCenterUpdation() { long TimeTookticks = DateTime.Now.Ticks; List <string> inputCC = new List <string>(); EMPCreationCore _empCreation = new EMPCreationCore(); try { var SqlConn = new ConcreteConnectionsFactory().GetConnection("IILHome"); SqlConn.Connection("connection"); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || Started : " + Tools.TicksToTime(DateTime.Now.Ticks), Entities.LogType.LogMode.Debug); inputCC.Add("CSKT"); inputCC.Add("KOKRS EQ '1000'"); inputCC.Add("KOSTL|KTEXT|LTEXT|MCTXT"); Service.SAPFactory.SAPServiceManager _sapservice = new Service.SAPFactory.SAPServiceManager(); var SAPConnect = _sapservice.GetSAPService("datatable"); DataTable dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "GetTableData"); _sapservice = null; SAPConnect = null; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || dtService count: " + dtService.Rows.Count.ToString(), Entities.LogType.LogMode.Debug); if (dtService != null && dtService.Rows.Count > 0) { DataTable dtfinal = new DataTable("CostCenterUpdation"); DataRow drfinal = dtfinal.NewRow(); dtfinal.Columns.Add("CostCenterId"); dtfinal.Columns.Add("CostCenterDesc"); foreach (DataRow dr in dtService.Rows) { drfinal = dtfinal.NewRow(); if (dr["Text1"].ToString() != "NOT TO USE" || dr["Text2"].ToString() != "NOT TO USE") { drfinal["CostCenterId"] = dr["CostCenterCode"].ToString().Trim(); drfinal["CostCenterDesc"] = dr["CostCenterName"].ToString().Trim(); dtfinal.Rows.Add(drfinal); } } if (dtfinal != null && dtfinal.Rows.Count > 0) { string CCXML = Tools.ConvertDataTableToXMLString(dtfinal); _empCreation.UpdateToDb(CCXML, "CCUpdate"); } } Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || Ended : " + Tools.TicksToTime(TimeTookticks), Entities.LogType.LogMode.Debug); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || Ended: --------------------------------" + Environment.NewLine + "" + Environment.NewLine, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdation || Error : " + ex.Message, Entities.LogType.LogMode.Error); } finally { inputCC = null; _empCreation = null; } }
static void Main(string[] args) { Log4net.Info("test"); int xx = 0; }
/// <summary> /// SAPCostCenterUpdationEmployeeWise /// </summary> private void SAPCostCenterUpdationEmployeeWise() { long TimeTookticks = DateTime.Now.Ticks; List <string> inputCC = new List <string>(); EMPCreationCore _empCreation = new EMPCreationCore(); try { var SqlConn = new ConcreteConnectionsFactory().GetConnection("IILHome"); SqlConn.Connection("connection"); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdationEmployeeWise || Started : " + Tools.TicksToTime(DateTime.Now.Ticks), Entities.LogType.LogMode.Debug); inputCC.Add("COAS"); inputCC.Add("AUART EQ '2000'"); inputCC.Add("AUFNR|KOSTV"); Service.SAPFactory.SAPServiceManager _sapservice = new Service.SAPFactory.SAPServiceManager(); var SAPConnect = _sapservice.GetSAPService("datatable"); DataTable dtService = (DataTable)SAPConnect.ConnectSAPService(inputCC, "GetTableData"); _sapservice = null; SAPConnect = null; Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdationEmployeeWise || dtService count: " + dtService.Rows.Count.ToString(), Entities.LogType.LogMode.Debug); if (dtService != null && dtService.Rows.Count > 0) { DataTable dtfinal = new DataTable("CostCenterUpdationEmployee"); DataRow drfinal = dtfinal.NewRow(); dtfinal.Columns.Add("Empid"); dtfinal.Columns.Add("CostCenter"); foreach (DataRow dr in dtService.Rows) { drfinal = dtfinal.NewRow(); if (dr["IntOrdNo"].ToString() != "NOT TO USE" || dr["IntOrdName"].ToString() != "NOT TO USE") { string EmpidS = dr[0].ToString().Trim(); string TempCostCenter = dr[1].ToString().Trim(); drfinal["Empid"] = EmpidS.Substring(((EmpidS.Length) - 6), 6); if (TempCostCenter != string.Empty) { drfinal["CostCenter"] = TempCostCenter.Substring(((TempCostCenter.Length) - 8), 8); } dtfinal.Rows.Add(drfinal); } } if (dtfinal != null && dtfinal.Rows.Count > 0) { string CCXML = Tools.ConvertDataTableToXMLString(dtfinal); _empCreation.UpdateToDb(CCXML, "UpdateCostCenterSchedules"); } } Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdationEmployeeWise || Ended : " + Tools.TicksToTime(TimeTookticks), Entities.LogType.LogMode.Debug); Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdationEmployeeWise || Ended: --------------------------------" + Environment.NewLine + "" + Environment.NewLine, Entities.LogType.LogMode.Debug); } catch (Exception ex) { Log4net.LogWriter("ScheduleService", "EmpCreation", "SAPCostCenterUpdationEmployeeWise || Error : " + ex.Message, Entities.LogType.LogMode.Error); } finally { inputCC = null; _empCreation = null; } }