public FactoryServiceImpl(ApplicationClass application) { if (factoryDao == null) { factoryDao = new FactoryDao(application); } }
public void SelectToInfoByDate() { HshldDao dao = FactoryDao.Instance().GetHshldDao(); IList <Hshld> list = dao.SelectToInfoByDate("TEST1", DateTime.Now); Console.WriteLine("Press Any Key..."); }
public String Run(string key, bool insert = true) { parameter.Key = key; base.StartInfo.Arguments = parameter.Key + " " + this.parameterStr; IScrapingStatusDao dao = FactoryDao.GetInstance().GetDao <IScrapingStatusDao>(); ScrapingStatus entity = new ScrapingStatus(); entity.KeyCode = parameter.Key; entity.SCode = parameter.Code; entity.Sid = parameter.Id; entity.StartTime = DateTime.Now; entity.Status = "0"; if (insert) { dao.Insert(entity); } else { dao.Update(entity); } parameter.Starttime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); base.Start(); this.logger.Info("Scraper process Start " + this.parameter.ToString()); return(parameter.Key); }
public void InsertToSignin() { CnctLgDao dao = FactoryDao.Instance().GetCnctLgDao(); dao.InsertToSignin("SY01", "nowonbun"); Console.WriteLine("Press Any Key..."); }
public void Run() { String savePath = new FileInfo(Path.Combine(Environment.CurrentDirectory, ConfigurationManager.AppSettings["SavePath"])).FullName; var categoryList = FactoryDao.GetDao <CategoryDao>().GetAllIncludePost(); CreateRss(savePath, categoryList); }
static void Main() { LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "Path"))).Set("Server").Info("Server Program Start"); FactoryDao.CreateInstance(ConfigSystem.ReadConfig("Config", "DB", "Connection"), ConfigSystem.ReadConfig("Config", "Log", "Path")); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public void Run() { var categoryList = FactoryDao.GetDao <CategoryDao>().GetAllIncludePost(); foreach (var category in categoryList) { CreatePost(categoryList, category); } }
public void InsertToInfo() { HshldDao dao = FactoryDao.Instance().GetHshldDao(); String cd = FactoryMaster.Instance().GetCategoryMaster().GetAll().First().Cd; String tp = FactoryMaster.Instance().GetTypeMaster().GetByCategoryCode(cd).First().TP; dao.InsertToInfo("TEST1", "tester", cd, tp, DateTime.Now.ToString("yyyy-MM-dd"), "TEST", "1"); Console.WriteLine("Press Any Key..."); }
public void SelectForSign() { UsrNfDao dao = FactoryDao.Instance().GetUsrNfDao(); UsrNf ret = dao.SelectForSign("SY01", "nowonbun", "ghkdtsnduq1"); Assert.AreEqual(ret.Nm, "SoonYub Hwang"); ret = dao.SelectForSign("SY01", "nowonbun", "ghkdtsnd"); Assert.AreEqual(ret.Nm, null); }
public void SelectByKey() { GrpNfDao dao = FactoryDao.Instance().GetGrpNfDao(); IList <GrpNf> list = dao.SelectByKey("SY01"); foreach (GrpNf l in list) { Console.WriteLine(l); } Console.WriteLine("Press Any Key..."); }
public ActionResult Login(LoginBean bean) { Usertable user = FactoryDao.GetUsertableDao().SelectId(bean.id, bean.password); if (user == null) { return(Index()); } Session[Define.USER_SESSION_NAME] = user; return(Main()); }
public bool salvarAluno(Aluno aluno) { IDaoAluno dao = FactoryDao.GetDaoAluno(); if (dao.Gravar(aluno)) { return(true); } else { return(false); } }
public void Run() { var categoryList = FactoryDao.GetDao <CategoryDao>().GetAllIncludePost(); foreach (var category in categoryList) { if (category.ISHOME) { continue; } CreateList(categoryList, category); } }
public void TestaGravacao() { IDaoAluno dao = FactoryDao.GetDaoAluno(); Aluno aluno = new Aluno() { Nome = "Ze", Cpf = "2013", DataNascimento = "10/10/1910", Rg = "30211404", Curso = 2 }; Assert.IsTrue(dao.Gravar(aluno)); }
public void TestarAlterar() { IDaoAluno dao = FactoryDao.GetDaoAluno(); Aluno aluno = new Aluno() { Nome = "ze", Cpf = "2015", DataNascimento = "10/10/1987", Rg = "30211404", Curso = 3 }; Assert.IsTrue(dao.Alterar(aluno, "2013", "cpf")); }
public AbstractScrapFlow(ScrapBrowser browser, ScrapParameter param, bool login_mode) { Parameter = param; this.browser = browser; this.commondao = FactoryDao.GetInstance().GetDao <IScrapingCommonDataDao>(); this.packagedao = FactoryDao.GetInstance().GetDao <IScrapingPackageDataDao>(); logger = LoggerBuilder.Init().Set(this.GetType()); //this.browser.InitializeDownLoad(ExcelDownload); this.browser.ProgressChanged += (s, e) => { //logger.Debug("CurrentProgress/MaximumProgress : " + e.CurrentProgress + "/" + e.MaximumProgress); }; }
static void Main(string[] args) { Logger logger = null; try { if (Debug.IsDebug()) { args = new String[] { Debug.GetDebugKey(), Debug.GetDebugParam() }; } if (args.Length != 2) { throw new ScraperException("Parameter Length Error " + args.Length); } logger = LoggerBuilder.Init(LogTemplate.GetLogTemp(ConfigSystem.ReadConfig("Config", "Log", "WritePath") + "\\" + args[0] + ".log")).Set("Server").Info("Client Program Start"); logger.Debug("arg[0] : " + args[0]); logger.Debug("arg[1] : " + args[1]); FactoryDao.CreateInstance(ConfigSystem.ReadConfig("Config", "DB", "Connection"), ConfigSystem.ReadConfig("Config", "Temp", "Path")); IScrapingStatusDao dao = FactoryDao.GetInstance().GetDao <IScrapingStatusDao>(); if (!Debug.IsDebug()) { ScrapingStatus entity = dao.GetEntity(args[0]); if (entity == null) { throw new ScraperException("Nothing entity " + args[0]); } if (entity.Status != "0") { throw new ScraperException("entity status" + args[0]); } entity.Status = "1"; dao.Update(entity); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ScraperContext(args[0], args[1])); } catch (Exception e) { if (logger != null) { logger.Error(e.ToString()); } Exit(); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); XmlConfigurator.Configure(); ILog logger = LogManager.GetLogger("ApplicationStart"); logger.Info("Started up this program."); FactoryDao.CreateInstance(System.Configuration.ConfigurationManager.ConnectionStrings["householdConn"].ConnectionString); FactoryMaster.Instance(); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">User</param> /// <returns>User</returns> public override Entity Execute(Entity param) { string strClass = "CommandUpdateUser"; try { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.Update((User)param); } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem exectuting the command to update users", true); throw new Exception("There was a problem exectuting the command to update users", e); } return(param); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">Exception</param> /// <returns>bool</returns> public override bool Execute(Exception ex) { string strClass = "CommandCreateLog"; try { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, ex.Message, true); } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem creating the log entry", true); throw new Exception("There was a problem creating the log entry", e); } return(true); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">Id</param> /// <returns>Boolean</returns> public override bool Execute(string param) { string strClass = "CommandRemoveUser"; bool result = false; try { IDaoUser daoUser = FactoryDao.GetDaoUser(); result = daoUser.Delete(param); } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem exectuting the command to delete users", true); throw new Exception("There was a problem exectuting the command to delete users", e); } return(result); }
public List <Aluno> buscarAluno(string palavra, string filtro) { IDaoAluno dao = FactoryDao.GetDaoAluno(); try { List <Aluno> lista = dao.Listar(palavra, filtro); if (lista != null) { return(lista); } else { return(null); } } catch (Exception e) { Console.WriteLine(e.Message); } return(null); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">Id</param> /// <returns>User</returns> public override Entity Execute(string param) { string strClass = "CommandGetUser"; Entity user = FactoryEntity.GetUser(); try { IDaoUser daoUser = FactoryDao.GetDaoUser(); DataSet dsUser = daoUser.GetById(param); Command <DataSet, List <Entity> > commandConvertToJSON = FactoryCommand.GetCommandConvertUserIntoJSON(); user = commandConvertToJSON.Execute(dsUser)[0]; } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem exectuting the command to get one user", true); throw new Exception("There was a problem exectuting the command to get one user", e); } return(user); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">Boolean</param> /// <returns>List of Users</returns> public override List <Entity> Execute(bool param) { string strClass = "CommandGetAll"; List <Entity> list = new List <Entity>(); try { IDaoUser daoUser = FactoryDao.GetDaoUser(); DataSet dsUser = daoUser.GetAll(); Command <DataSet, List <Entity> > commandConvertToJSON = FactoryCommand.GetCommandConvertUserIntoJSON(); list = commandConvertToJSON.Execute(dsUser); } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem exectuting the command to get all users", true); throw new Exception("There was a problem exectuting the command to get all users", e); } return(list); }
/// <summary> /// Execution of the Command /// </summary> /// <param name="param">DataSet from DB</param> /// <returns>List of Users</returns> public override List <Entity> Execute(DataSet param) { string strClass = "CommandConvertUserIntoJSON"; List <Entity> list = new List <Entity>(); int result; DateTime resultDT; try { if (param != null) { foreach (DataRow dr in param.Tables["DATA"].Rows) { Entity user = FactoryEntity.GetUser(); ((User)user).Id = (dr["USER_ID"] != null && !String.IsNullOrEmpty(dr["USER_ID"].ToString())) ? (int.TryParse(dr["USER_ID"].ToString(), out result) ? int.Parse(dr["USER_ID"].ToString()) : -1) : -1; ((User)user).Name = (dr["USER_NAME"] != null && !String.IsNullOrEmpty(dr["USER_NAME"].ToString())) ? dr["USER_NAME"].ToString() : ""; ((User)user).Birthdate = (dr["USER_BIRTHDATE"] != null && !String.IsNullOrEmpty(dr["USER_BIRTHDATE"].ToString())) ? (DateTime.TryParse(dr["USER_BIRTHDATE"].ToString(), out resultDT) ? DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Month.ToString() + "-" + DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Day.ToString() + "-" + DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Year.ToString() : "") : ""; list.Add(user); } } } catch (Exception e) { IDaoUser daoUser = FactoryDao.GetDaoUser(); daoUser.CreateLog(strClass, "There was a problem converting the user into a JSON", true); throw new Exception("There was a problem converting the user into a JSON", e); } return(list); }
public void TestarBuscar() { IDaoAluno dao = FactoryDao.GetDaoAluno(); Assert.IsNotNull(dao.Buscar("58495670", "cpf")); }
public void TestarListar() { IDaoAluno dao = FactoryDao.GetDaoAluno(); // Assert.IsTrue(dao.Listar().Count > 0); }
protected void Application_Start() { FactoryDao.CreateInstance(System.Configuration.ConfigurationManager.ConnectionStrings["conn"].ConnectionString); AisSocketServices.GetInstance().Run(); }
private void CreatePost(List <Category> list, Category category) { String templatePost = ConfigurationManager.AppSettings["TemplatePost"]; String savePath = ConfigurationManager.AppSettings["SavePath"]; List <Post> recently = FactoryDao.GetDao <PostDao>().GetRecentlyAll(6); foreach (var post in category.Post.Where(x => !x.ISDELETED).OrderByDescending(x => x.CREATEDATED)) { StringBuilder templatePostStringBuilder = ReadFile(templatePost); String contents = ReadFile(post.FILEPATH).ToString(); templatePostStringBuilder.Replace("#####MAINTITLE#####", ConfigurationManager.AppSettings["MainTitle"]); templatePostStringBuilder.Replace("#####MENU#####", GetMenu(list, category.CATEGORY_CODE)); templatePostStringBuilder.Replace("#####CATEGORY#####", category.CATEGORY_NAME); templatePostStringBuilder.Replace("#####TITLE#####", post.TITLE); templatePostStringBuilder.Replace("#####CREATEDDATE#####", post.CREATEDATED.ToString("yyyy년 MM월 dd일 HH시 mm분")); templatePostStringBuilder.Replace("#####LASTUPDATEDDATE#####", post.LAST_UPDATED.ToString("yyyy년 MM월 dd일 HH시 mm분")); templatePostStringBuilder.Replace("#####CREATEDDATE2#####", post.CREATEDATED.ToString("yyyy-MM-dd HH:mm")); templatePostStringBuilder.Replace("#####LASTUPDATEDDATE2#####", post.LAST_UPDATED.ToString("yyyy-MM-dd HH:mm")); templatePostStringBuilder.Replace("#####KEYWORDS#####", ConfigurationManager.AppSettings["Keywords"]); //templatePostStringBuilder.Replace("#####DESCRIPTION#####", ConfigurationManager.AppSettings["Description"]); templatePostStringBuilder.Replace("#####DESCRIPTION#####", CreateDescription(contents)); templatePostStringBuilder.Replace("#####CANONICAL#####", ConfigurationManager.AppSettings["SiteRoot"]); templatePostStringBuilder.Replace("#####AUTHOR#####", ConfigurationManager.AppSettings["Author"]); templatePostStringBuilder.Replace("#####ALTERNATE#####", ConfigurationManager.AppSettings["SiteRoot"] + "/" + ConfigurationManager.AppSettings["Rss"]); //templatePostStringBuilder.Replace("#####SUMMARY#####", Regex.Replace(contents, @"<[^>]*>", "").Replace(" ", "")); //templatePostStringBuilder.Replace("#####SUMMARY#####", ConfigurationManager.AppSettings["Description"]); templatePostStringBuilder.Replace("#####SUMMARY#####", CreateDescription(contents)); templatePostStringBuilder.Replace("#####URL#####", ConfigurationManager.AppSettings["SiteRoot"] + post.LOCATION); StringBuilder buffer = new StringBuilder(); //buffer.Append(Encoding.UTF8.GetString(post.IMAGE)); //templatePostStringBuilder.Replace("#####IMAGE#####", buffer.ToString()); //buffer.Clear(); //templatePostStringBuilder.Replace("#####IMAGECOMMNET#####", post.IMAGE_COMMENT); templatePostStringBuilder.Replace("#####CONTENTS#####", contents); int state = 0; Post pre = null; Post next = null; foreach (var check in category.Post.Where(x => !x.ISDELETED).OrderByDescending(x => x.CREATEDATED)) { if (check == post || check.IDX == post.IDX) { state = 1; continue; } if (state == 0) { next = check; } if (state == 1) { pre = check; break; } } buffer.Clear(); if (pre != null || next != null) { buffer.Append("<div class='row mt-3 mb-3'>"); buffer.Append("<div class='col-12 d-flex align-items-stretch'>"); buffer.Append("<div class='card my-style-custom'>"); buffer.Append("<div class='my-pre-post-nav'>"); buffer.Append("<div class='row'>"); buffer.Append("#####PREPOST##### "); buffer.Append("#####PRENEXTLINE##### "); buffer.Append("#####NEXTPOST#####"); buffer.Append("</div>"); buffer.Append("</div>"); buffer.Append("</div>"); buffer.Append("</div>"); buffer.Append("</div>"); templatePostStringBuilder.Replace("#####PRENEXT#####", buffer.ToString()); } else { templatePostStringBuilder.Replace("#####PRENEXT#####", ""); } buffer.Clear(); if (pre != null) { buffer.Append("<div class='col-12 mb-1'>"); buffer.Append("<p class='my-pre-list-title' style='margin-bottom:0px;'><a class='prenext-link' href='"); buffer.Append(pre.LOCATION); buffer.Append("'> "); buffer.Append("<span class='my-pre-next-icon'><i class='fa fa-chevron-up'></i>이전글</span>"); buffer.Append(pre.TITLE); buffer.Append("</a>"); buffer.Append("<span class='my-list-date float-right date-type-1 font-7'>"); buffer.Append(pre.CREATEDATED.ToString("yyyy년 MM월 dd일 HH시 mm분")); buffer.Append("에 작성된 글...</span>"); buffer.Append("<span class='my-list-date float-right date-type-2 font-7'>"); buffer.Append(pre.CREATEDATED.ToString("yyyy-MM-dd HH:mm")); buffer.Append(" 작성</span>"); buffer.Append("</p>"); buffer.Append("</div>"); } templatePostStringBuilder.Replace("#####PREPOST#####", buffer.ToString()); buffer.Clear(); if (next != null) { buffer.Append("<div class='col-12 mt-1'>"); buffer.Append("<p class='my-pre-list-title' style='margin-bottom:0px;'><a class='prenext-link' href='"); buffer.Append(next.LOCATION); buffer.Append("'> "); buffer.Append("<span class='my-pre-next-icon'><i class='fa fa-chevron-down'></i>다음글</span>"); buffer.Append(next.TITLE); buffer.Append("</a>"); buffer.Append("<span class='my-list-date float-right date-type-1 font-7'>"); buffer.Append(next.CREATEDATED.ToString("yyyy년 MM월 dd일 HH시 mm분")); buffer.Append("에 작성된 글...</span>"); buffer.Append("<span class='my-list-date float-right date-type-2 font-7'>"); buffer.Append(next.CREATEDATED.ToString("yyyy-MM-dd HH:mm")); buffer.Append(" 작성</span>"); buffer.Append("</p>"); buffer.Append("</div>"); } templatePostStringBuilder.Replace("#####NEXTPOST#####", buffer.ToString()); buffer.Clear(); if (pre != null && next != null) { templatePostStringBuilder.Replace("#####PRENEXTLINE#####", "<div class='col-12 my-blog-line'></div>"); } else { templatePostStringBuilder.Replace("#####PRENEXTLINE#####", ""); } buffer.Clear(); foreach (var p in recently) { if (p == post || p.IDX == post.IDX) { continue; } buffer.Append("<li class='row'>"); buffer.Append("<div class='col-12 mb-0'>"); buffer.Append("<i class='fa fa-caret-right mr-2'></i>"); buffer.Append("<a href='"); buffer.Append(p.LOCATION); buffer.Append("'>["); buffer.Append(p.Category.CATEGORY_NAME); buffer.Append("] "); buffer.Append(p.TITLE); buffer.Append("<span class='my-list-date float-right date-type-1 font-7'>"); buffer.Append(p.CREATEDATED.ToString("yyyy년 MM월 dd일 HH시 mm분")); buffer.Append("에 작성된 글...</span>"); buffer.Append("<span class='my-list-date float-right date-type-2 font-7'>"); buffer.Append(p.CREATEDATED.ToString("yyyy-MM-dd HH:mm")); buffer.Append(" 작성</span>"); buffer.Append("</a>"); buffer.Append("</div>"); buffer.Append("</li>"); } templatePostStringBuilder.Replace("#####RECENTLYPOST#####", buffer.ToString()); WriteFile(savePath + post.LOCATION, templatePostStringBuilder); } }
protected override void Finish() { DebugLog("finish"); SetEventHandler(ScrapState.COMPLETE); // TODO:How do the data insert when login error? if (!(bool)GetData(0)) { InfoLog("login error"); return; } DebugLog("INSERT"); DebugLog(ID); DebugLog(PW); DebugLog(PARAM[0]); //It delete data of table in database. try { List <long> IndexList = FactoryDao.GetScrappingDataDao().GetIndex(PARAM[0], "006"); if (IndexList != null && IndexList.Count > 0) { foreach (long index_ in IndexList) { FactoryDao.GetScrappingDataSubDao().Delete(index_.ToString()); FactoryDao.GetScrappingDataDao().Delete(index_.ToString()); } } } catch (Exception e) { ErrorLog(e.ToString()); } ScrappingData data = new ScrappingData(); data.SiteCode = "006"; data.Id = ID; data.ApplyNum = Convert.ToInt64(PARAM[0]); data.Data01 = ConvertString(GetData(1)); data.Data02 = ConvertString(GetData(2)); data.Data03 = ConvertString(GetData(3)); data.Data04 = ConvertString(GetData(4)); data.Data05 = ConvertString(GetData(5)); data.Data06 = ConvertString(GetData(6)); data.Data07 = ConvertString(GetData(7)); data.Data08 = ConvertString(GetData(8)); data.Data09 = ConvertString(GetData(9)); data.Data10 = ConvertString(GetData(10)); data.Data11 = ConvertString(GetData(11)); data.Data13 = ConvertString(GetData(13)); data.Data14 = ConvertString(GetData(14)); int index = FactoryDao.GetScrappingDataDao().Insert(data, true); DebugLog("index " + index); ScrappingTotalData scraptotal = new ScrappingTotalData(); FactoryDao.GetScrappingTotalDataDao().Delete(PARAM[0], "006"); scraptotal.ApplyNum = Convert.ToInt64(PARAM[0]); scraptotal.Id = ID; scraptotal.SiteCode = "006"; FactoryDao.GetScrappingTotalDataDao().Insert(scraptotal); SetEventHandler(ScrapState.COMPLETE); }