private IList <JobsInfo> DrRead(SqlDataReader dr) { IList <JobsInfo> JInfoList = new List <JobsInfo>(); while (dr.Read()) { JobsInfo JInfo = new JobsInfo(); JInfo.ID = Convert.ToInt32(dr["ID"]); JInfo.Name = Convert.ToString(dr["Name"]); JInfo.Dept = Convert.ToString(dr["Dept"]); JInfo.Email = Convert.ToString(dr["Email"]); JInfo.Address = Convert.ToString(dr["Address"]); JInfo.Num = Convert.ToString(dr["Num"]); JInfo.Sex = Convert.ToString(dr["Sex"]); JInfo.Experience = Convert.ToString(dr["Experience"]); JInfo.Language = Convert.ToString(dr["Language"]); JInfo.Salary = Convert.ToString(dr["Salary"]); JInfo.Education = Convert.ToString(dr["Education"]); JInfo.ResumeLanguage = Convert.ToString(dr["ResumeLanguage"]); JInfo.Content = Convert.ToString(dr["Content"]); JInfo.Hits = Convert.ToInt32(dr["Hits"]); JInfo.State = Convert.ToBoolean(dr["State"]); JInfo.CreateDate = Convert.ToDateTime(dr["CreateDate"]); JInfoList.Add(JInfo); } dr.Close(); return(JInfoList); }
public int Save(JobsInfo JInfo) { SqlParameter[] MyPar = new SqlParameter[13]; MyPar[0] = new SqlParameter("@ID", SqlDbType.Int, 4); MyPar[0].Value = JInfo.ID; MyPar[1] = new SqlParameter("@Name", SqlDbType.NVarChar, 10); MyPar[1].Value = JInfo.Name; MyPar[2] = new SqlParameter("@Dept", SqlDbType.NVarChar, 10); MyPar[2].Value = JInfo.Dept; MyPar[3] = new SqlParameter("@Email", SqlDbType.NVarChar, 30); MyPar[3].Value = JInfo.Email; MyPar[4] = new SqlParameter("@Address", SqlDbType.NVarChar, 50); MyPar[4].Value = JInfo.Address; MyPar[5] = new SqlParameter("@Num", SqlDbType.NVarChar, 10); MyPar[5].Value = JInfo.Num; MyPar[6] = new SqlParameter("@Sex", SqlDbType.NVarChar, 10); MyPar[6].Value = JInfo.Sex; MyPar[7] = new SqlParameter("@Experience", SqlDbType.NVarChar, 10); MyPar[7].Value = JInfo.Experience; MyPar[8] = new SqlParameter("@Language", SqlDbType.NVarChar, 10); MyPar[8].Value = JInfo.Language; MyPar[9] = new SqlParameter("@Salary", SqlDbType.NVarChar, 10); MyPar[9].Value = JInfo.Salary; MyPar[10] = new SqlParameter("@Education", SqlDbType.NVarChar, 10); MyPar[10].Value = JInfo.Education; MyPar[11] = new SqlParameter("@ResumeLanguage", SqlDbType.NVarChar, 10); MyPar[11].Value = JInfo.ResumeLanguage; MyPar[12] = new SqlParameter("@Content", SqlDbType.NText); MyPar[12].Value = JInfo.Content; string sql = "update [" + Pre + "_Jobs] set [Name]=@Name,[Dept]=@Dept,[Email]=@Email,[Address]=@Address,[Num]=@Num,[Sex]=@Sex,[Experience]=@Experience,[Language]=@Language,[Salary]=@Salary,[Education]=@Education,[ResumeLanguage]=@ResumeLanguage,[Content]=@Content where [ID]=@ID"; return(SqlHelper.ExecuteNonQuery(ConnStr, CommandType.Text, sql, MyPar)); }
public int Add(JobsInfo JInfo) { SqlParameter[] MyPar = new SqlParameter[12]; MyPar[0] = new SqlParameter("@Name", SqlDbType.NVarChar, 10); MyPar[0].Value = JInfo.Name; MyPar[1] = new SqlParameter("@Dept", SqlDbType.NVarChar, 10); MyPar[1].Value = JInfo.Dept; MyPar[2] = new SqlParameter("@Email", SqlDbType.NVarChar, 30); MyPar[2].Value = JInfo.Email; MyPar[3] = new SqlParameter("@Address", SqlDbType.NVarChar, 50); MyPar[3].Value = JInfo.Address; MyPar[4] = new SqlParameter("@Num", SqlDbType.NVarChar, 10); MyPar[4].Value = JInfo.Num; MyPar[5] = new SqlParameter("@Sex", SqlDbType.NVarChar, 10); MyPar[5].Value = JInfo.Sex; MyPar[6] = new SqlParameter("@Experience", SqlDbType.NVarChar, 10); MyPar[6].Value = JInfo.Experience; MyPar[7] = new SqlParameter("@Language", SqlDbType.NVarChar, 10); MyPar[7].Value = JInfo.Language; MyPar[8] = new SqlParameter("@Salary", SqlDbType.NVarChar, 10); MyPar[8].Value = JInfo.Salary; MyPar[9] = new SqlParameter("@Education", SqlDbType.NVarChar, 10); MyPar[9].Value = JInfo.Education; MyPar[10] = new SqlParameter("@ResumeLanguage", SqlDbType.NVarChar, 10); MyPar[10].Value = JInfo.ResumeLanguage; MyPar[11] = new SqlParameter("@Content", SqlDbType.NText); MyPar[11].Value = JInfo.Content; string sql = "insert into [" + Pre + "_Jobs]([Name],[Dept],[Email],[Address],[Num],[Sex],[Experience],[Language],[Salary],[Education],[ResumeLanguage],[Content]) values(@Name,@Dept,@Email,@Address,@Num,@Sex,@Experience,@Language,@Salary,@Education,@ResumeLanguage,@Content)"; return(SqlHelper.ExecuteNonQuery(ConnStr, CommandType.Text, sql, MyPar)); }
public async Task SaveAsync(JobsInfo entity) { try { if (entity == null) { return; } using (var timeLineContext = _contextFactory.GetTimeLineContext()) { var entityModel = await timeLineContext .JobsInfos .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id)); if (entityModel == null) { entityModel = new DA.JobsInfo(); MapForUpdateentity(entity, entityModel); await timeLineContext.JobsInfos.AddAsync(entityModel); } else { MapForUpdateentity(entity, entityModel); } timeLineContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
public List <JobsInfo> GetJobsInfo() { var jobs = GetJobs(); var jobsInfoList = new List <JobsInfo>(); _sf = new StdSchedulerFactory(); _scheduler = _sf.GetScheduler(); foreach (var job in jobs) { var groupToResume = _scheduler.GetJobGroupNames(); var cronExpression = string.Empty; foreach (var group in groupToResume) { var groupMatcher = GroupMatcher <JobKey> .GroupContains(group); var jobKeys = _scheduler.GetJobKeys(groupMatcher); foreach (var jobKey in jobKeys) { var detail = _scheduler.GetJobDetail(jobKey); if (detail.JobType != job.GetType()) { continue; } var triggers = _scheduler.GetTriggersOfJob(jobKey); foreach (var trigger in triggers) { var triggerResume = (ICronTrigger)trigger; if (_scheduler.GetTriggerState(triggerResume.Key) == TriggerState.Paused) { job.IsScheduled = false; } else if (_scheduler.GetTriggerState(triggerResume.Key) == TriggerState.Normal) { job.IsScheduled = true; } cronExpression = triggerResume.CronExpressionString; } } } var jobsInfo = new JobsInfo() { Name = job.Name(), Description = job.Description(), Cron = cronExpression, IsScheduled = job.IsScheduled }; jobsInfoList.Add(jobsInfo); } return(jobsInfoList); }
public async Task <IActionResult> Put([FromBody] JobsInfo value) { try { var entity = _mapper.Map <BL.JobsInfo>(value); var id = _service.SaveAsync(entity); return(Ok(id)); } catch (Exception) { return(BadRequest()); } }
public PageInfo(string name, float weight, string logFile, bool jobActivate, string classCode, bool codeShowWarnings, JobsInfo jobsInfo, ErrorsInfo errorsInfo, List <DisplayInfo> displayList, List <StringInfo> stringList) { Name = name; Weight = weight; LogFile = logFile; JobActivate = jobActivate; ClassCode = classCode; CodeShowWarnings = codeShowWarnings; JobsInfo = jobsInfo; ErrorsInfo = errorsInfo; DisplayList = displayList; StringList = stringList; InfoObject = null; ClassObject = null; }
public virtual JobsInfo GetJobs(HttpServletRequest hsr) { Init(); JobsInfo allJobs = new JobsInfo(); foreach (Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job in appCtx.GetAllJobs().Values) { // getAllJobs only gives you a partial we want a full Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job fullJob = appCtx.GetJob(job.GetID()); if (fullJob == null) { continue; } allJobs.Add(new JobInfo(fullJob, HasAccess(fullJob, hsr))); } return(allJobs); }
public PageInfo(string name, float weight, DisplayModeType displayMode, int textResId, int gaugesPortrait, int gaugesLandscape, string logFile, bool jobActivate, string classCode, bool codeShowWarnings, JobsInfo jobsInfo, ErrorsInfo errorsInfo, List <DisplayInfo> displayList, List <StringInfo> stringList) { Name = name; Weight = weight; DisplayMode = displayMode; TextResId = textResId; GaugesPortrait = gaugesPortrait; GaugesLandscape = gaugesLandscape; LogFile = logFile; JobActivate = jobActivate; ClassCode = classCode; CodeShowWarnings = codeShowWarnings; JobsInfo = jobsInfo; ErrorsInfo = errorsInfo; DisplayList = displayList; StringList = stringList; InfoObject = null; ClassObject = null; }
/// <summary>Simple test some methods of JobHistory</summary> /// <exception cref="System.Exception"/> public virtual void TestJobHistoryMethods() { Log.Info("STARTING testJobHistoryMethods"); try { Configuration configuration = new Configuration(); configuration.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey , typeof(TestJobHistoryParsing.MyResolver), typeof(DNSToSwitchMapping)); RackResolver.Init(configuration); MRApp app = new TestJobHistoryEvents.MRAppWithHistory(1, 1, true, this.GetType(). FullName, true); app.Submit(configuration); Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.GetContext().GetAllJobs().Values .GetEnumerator().Next(); app.WaitForState(job, JobState.Succeeded); JobHistory jobHistory = new JobHistory(); jobHistory.Init(configuration); // Method getAllJobs NUnit.Framework.Assert.AreEqual(1, jobHistory.GetAllJobs().Count); // and with ApplicationId NUnit.Framework.Assert.AreEqual(1, jobHistory.GetAllJobs(app.GetAppID()).Count); JobsInfo jobsinfo = jobHistory.GetPartialJobs(0L, 10L, null, "default", 0L, Runtime .CurrentTimeMillis() + 1, 0L, Runtime.CurrentTimeMillis() + 1, JobState.Succeeded ); NUnit.Framework.Assert.AreEqual(1, jobsinfo.GetJobs().Count); NUnit.Framework.Assert.IsNotNull(jobHistory.GetApplicationAttemptId()); // test Application Id NUnit.Framework.Assert.AreEqual("application_0_0000", jobHistory.GetApplicationID ().ToString()); NUnit.Framework.Assert.AreEqual("Job History Server", jobHistory.GetApplicationName ()); // method does not work NUnit.Framework.Assert.IsNull(jobHistory.GetEventHandler()); // method does not work NUnit.Framework.Assert.IsNull(jobHistory.GetClock()); // method does not work NUnit.Framework.Assert.IsNull(jobHistory.GetClusterInfo()); } finally { Log.Info("FINISHED testJobHistoryMethods"); } }
public void Execute(IJobExecutionContext context) { Log.Info("SetKeywordsCostJob запущен!"); Console.WriteLine("SetKeywordsCostJob was started! " + DateTime.Now); IQueryable <Client> clients = _clientRep.GetAll(); DateTime StartDate = new DateTime(); DateTime FinishDate = new DateTime(); JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.SetKeywordsCostJob); if (JobsInfoQuery != null) { StartDate = JobsInfoQuery.lastactiondate.AddDays(-1); //AddDays(-1) для учета часовых поясов FinishDate = DateTime.Now.ToUniversalTime().AddDays(2); //AddDays(1) для учета часовых поясов } else { if (_visitsRep.GetAll().Count() > 0) { StartDate = DateTime.Parse("2013-04-28"); FinishDate = DateTime.Now.ToUniversalTime().AddDays(2);//AddDays(1) для учета часовых поясов } } foreach (Client item in clients) { Console.WriteLine("SetKeywordsCostJob Клиент " + item.Name + " Время старта: " + DateTime.Now); Execute_KeywordsCost_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Console.WriteLine("SetKeywordsCostJob Клиент " + item.Name + " Время финиша: " + DateTime.Now); } _jobsinfoRep.Add(new JobsInfo() { jobId = Constants.SetKeywordsCostJob, lastactiondate = DateTime.Now.AddDays(-1).ToUniversalTime(), status = true }); _jobsinfoRep.Save(); Console.WriteLine("SetKeywordsCostJob is finished! " + DateTime.Now); }
public PageInfo(string xmlFileName, string name, float weight, DisplayModeType displayMode, int textResId, int gaugesPortrait, int gaugesLandscape, string logFile, string dbName, bool jobActivate, string classCode, bool codeShowWarnings, JobsInfo jobsInfo, ErrorsInfo errorsInfo, List <DisplayInfo> displayList, List <StringInfo> stringList) { XmlFileName = xmlFileName; Name = name; Weight = weight; DisplayMode = displayMode; TextResId = textResId; GaugesPortrait = gaugesPortrait; GaugesLandscape = gaugesLandscape; LogFile = logFile; DbName = dbName; JobActivate = jobActivate; ClassCode = classCode; CodeShowWarnings = codeShowWarnings; JobsInfo = jobsInfo; ErrorsInfo = errorsInfo; DisplayList = displayList; StringList = stringList; string assetFileName = Path.GetFileName(ActivityCommon.AssetFileName) ?? string.Empty; UseCompatIds = string.Compare(dbName, assetFileName, StringComparison.OrdinalIgnoreCase) != 0; CompatIdsUsed = false; if (JobsInfo != null) { foreach (JobInfo jobInfo in JobsInfo.JobList) { jobInfo.UseCompatIds = UseCompatIds; if (UseCompatIds && !string.IsNullOrWhiteSpace(jobInfo.FixedFuncStructId)) { CompatIdsUsed = true; break; } } } InfoObject = null; ClassObject = null; }
public void Execute(IJobExecutionContext context) { try { Console.WriteLine("RemoveMoneyJob is starting....." + DateTime.Now.ToString()); Log.Info("RemoveMoneyJob запущен!"); List<GetBillsecForClientInfo> BillsecForClientInfoList_Curent = new List<GetBillsecForClientInfo>(); List<GetPhonesCountForClientInfo> PhonesCountForClientInfoList_Curent = new List<GetPhonesCountForClientInfo>(); ////выбираем дату последнего успешного запуска Job-а ( Начало ) DateTime lastactiondate = new DateTime(); JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.RemoveMoneyJob); if (JobsInfoQuery != null) lastactiondate = JobsInfoQuery.lastactiondate; // выбираем дату последнего успешного запуска Job-а ( Конец ) else lastactiondate = DateTime.Parse("2013-03-15"); double numbercostforday = 0; DateTime FinishDate = /*GetDateFromFile()[1];*/DateTime.Now.AddHours(-1).ToUniversalTime(); DateTime StartDate = /*GetDateFromFile()[0];*/ lastactiondate; DateTime CurentDate = StartDate; MinutesCost lastminutecostdate = null; NumberCost lastnumbercostdate = null; //StartDate = DateTime.Parse("29.04.2013 23:00:00"); //CurentDate = StartDate; //FinishDate = DateTime.Parse("30.04.2013 00:00:00").AddHours(-1); while (CurentDate <= FinishDate)//условие <= приводит к двойному выполнению Job-а для одного и того же клиента в сутки { string clients = GetClientsForRemoveMoney_(CurentDate/*DateTime.Parse("30.04.2013 0:00:00")*/);//получаем всех клиентов, для которых нужно списать деньги if (!String.IsNullOrEmpty(clients)) { Console.WriteLine("Диапазон между startdate и finishdate: " + StartDate.ToString() + " - " + FinishDate.ToString()); Console.WriteLine("Грабеж!!!!!!!!! Время грабежа: " + CurentDate.ToString() + " Клиенты: " + clients); List<BillSecForClientsInfo> billsecforclientsinfo = Call_GetBillSecForClients(CurentDate, clients); List<ActivedClientsNumbersCountInfo> activedclientsnumberscountinfo = Call_GetActivedClientsNumbers(CurentDate, clients); lastminutecostdate = _minutescostRep.GetAll().Where(t => t.lastupdate <= CurentDate).OrderByDescending(t => t.lastupdate).FirstOrDefault(); lastnumbercostdate = _numbercostRep.GetAll().Where(t => t.lastupdate <= CurentDate).OrderByDescending(t => t.lastupdate).FirstOrDefault(); List<InfoForPaymants> infoforpaymants = new List<InfoForPaymants>(); var commondata = from b in billsecforclientsinfo from a in activedclientsnumberscountinfo where b.date == a.date && b.ClientId == a.ClientId select new { ClientId = b.ClientId, date = b.date, count = a.count, codes_billsec = b.codes_billsec }; var differentdata = from a in activedclientsnumberscountinfo where !billsecforclientsinfo.Any(t => t.ClientId == a.ClientId && t.date == a.date) select a; if (commondata.Count() > 0) foreach (var item in commondata) infoforpaymants.Add(new InfoForPaymants() { codes_billsec = item.codes_billsec, ClientId = item.ClientId, count = item.count, date = item.date }); if (differentdata.Count() > 0) foreach (var item in differentdata) infoforpaymants.Add(new InfoForPaymants() { codes_billsec = null, count = item.count, date = item.date, ClientId = item.ClientId }); int allbillsec = 0;//общее колическво секунд разговоров для клиента для всех кодов if (infoforpaymants.Count() > 0) { foreach (InfoForPaymants item in infoforpaymants) { numbercostforday = _numbercostRep.GetLastNumberCostToThisDate(item.date);//последняя стоимость номера за день if (item.codes_billsec != null) item.sum = Math.Round(GetCommonBillsecCostForAllCodes(item.codes_billsec) + item.count * numbercostforday, 2); else item.sum = Math.Round(item.count * numbercostforday, 2); if (item.codes_billsec != null) allbillsec = item.codes_billsec.Sum(t => t.billsec); Paymant new_paymant = new Paymant() { ClientId = item.ClientId, date = item.date, Type = false, sum = -1 * item.sum, coment = "Снятие денег со счета. Время разговоров: " + allbillsec + " сек; Количество арендуемых номеров: " + item.count + " Время: " + DateTime.Now.ToString() }; _paymantsRep.Add(new_paymant); _paymantsRep.Save(); Client curent_client = _clientRep.Find(item.ClientId); if (curent_client != null) { string message_ = "Уважаемый " + curent_client.Name + ", " + item.date.ToShortDateString() + " с вашего счета было снято " + item.sum + " грн за " + allbillsec + " секунд разговоров и за аренду телефонов в количестве " + item.count + "."; _sendemailjobinfoRep.Add(new SendEmailJobInfo() { attemptcount = 0, date = DateTime.Now.ToUniversalTime(), message = message_, status = false, subject = "CallTracking Info", To = curent_client.Email }); _sendemailjobinfoRep.Save(); } allbillsec = 0; } } } CurentDate = CurentDate.AddHours(1); } // AddOneHourToDatesFromFile(); JobsInfo new_jobs_info = new JobsInfo() { status = true, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.RemoveMoneyJob };//поставить еще jobId! ( также в классе JobsInfo ) _jobsinfoRep.Add(new_jobs_info); _jobsinfoRep.Save(); Log.Info("RemoveMoneyJob успешно выполнен!"); Console.WriteLine("RemoveMoneyJob is finished....." + DateTime.Now.ToString()); } catch (Exception ex) { while (ex.InnerException != null) ex = ex.InnerException; /* JobsInfo new_jobs_info = new JobsInfo() { status = false, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.RemoveMoneyJob, ExceptionText = String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace) };//поставить еще jobId! ( также в классе JobsInfo ) _jobsinfoRep.Add(new_jobs_info); _jobsinfoRep.Save(); Log.Error(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); Console.WriteLine("RemoveMoneyJob is running with error....." + DateTime.Now.ToString()); Console.WriteLine(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace));*/ throw ex; } }
///<Summary> /// Gets the answer ///</Summary> public void Execute(IJobExecutionContext context) { try { using (CallTrackingDBContext _db = new CallTrackingDBContext()) { Log.Info("SetCallInfoJob запущен!"); //получаем дату и время последнего запуска Job-а string date = ""; JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.SetCallInfoJob);//_db.jobsInfo.FirstOrDefault(t => t.job.Id == Constants.SetCallInfoJob); if (JobsInfoQuery !=null) { //date = JobsInfoQuery.lastactiondate.ToString("YYYY-M-dd hh:"); date = JobsInfoQuery.lastactiondate.Year + "-" + JobsInfoQuery.lastactiondate.Month + "-" + JobsInfoQuery.lastactiondate.Day + " " + JobsInfoQuery.lastactiondate.Hour + ":" + JobsInfoQuery.lastactiondate.Minute + ":" + JobsInfoQuery.lastactiondate.Second; } else //если Job не запускался, то делаем работу за весь период { DateTime calldate = DateTime.Parse("2012-05-01"); date = calldate.Year + "-" + calldate.Month + "-" + calldate.Day + " " + calldate.Hour + ":" + calldate.Minute + ":" + calldate.Second; } // using (MySqlConnection objConn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CallTrackingDBContext"].ConnectionString)) { objConn.Open(); MySqlCommand objSetCallInfo = new MySqlCommand("SetCallInfo", objConn); objSetCallInfo.CommandType = CommandType.StoredProcedure; objSetCallInfo.CommandTimeout = int.MaxValue; objSetCallInfo.Parameters.Add("@date_", MySqlDbType.Datetime).Value = DateTime.Parse(date); objSetCallInfo.ExecuteNonQuery(); objConn.Close(); } /*_db.Database.ExecuteSqlCommand(String.Format(@"update Cdr c, Visits v set c.VisitsId=v.Id where c.VisitsId is null and c.calldate>Date('{0}') and c.dcontext='frw_in' and c.dst=v.UserNumber and c.calldate between v.datetime and v.lastupdate", date));// + interval 3 minute */ JobsInfo new_jobs_info = new JobsInfo() { status = true, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.SetCallInfoJob };//поставить еще jobId! ( также в классе JobsInfo ) _jobsinfoRep.Add(new_jobs_info); _jobsinfoRep.Save(); Console.WriteLine("SetCallInfoJob is running....." + DateTime.Now.ToString()); Log.Info("SetCallInfoJob успешно выполнен!"); } } catch (Exception ex) { while (ex.InnerException != null) ex = ex.InnerException; //JobsInfo new_jobs_info = new JobsInfo() { status = false, lastactiondate = DateTime.Now.ToUniversalTime(), ExceptionText = String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace) };//поставить еще jobId! ( также в классе JobsInfo ) // _jobsinfoRep.Add(new_jobs_info); // _jobsinfoRep.Save(); Log.Error(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); Console.WriteLine("SetCallInfoJob is running with error....." + DateTime.Now.ToString()); Console.WriteLine(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); } }
private void MapForUpdateentity(JobsInfo entity, DA.JobsInfo daEntity) { daEntity.Id = entity.Id; }
protected void Page_Load(object sender, EventArgs e) { if (Tools.GetQueryString("action").ToLower() == "add") { string Name = Tools.GetForm("Name"); string Dept = Tools.GetForm("Dept"); string Email = Tools.GetForm("Email"); string Address = Tools.GetForm("Address"); string Num = Tools.GetForm("Num"); string Sex = Tools.GetForm("Sex"); string Experience = Tools.GetForm("Experience"); string Language = Tools.GetForm("Language"); string Salary = Tools.GetForm("Salary"); string Education = Tools.GetForm("Education"); string ResumeLanguage = Tools.GetForm("ResumeLanguage"); string Content = HttpUtility.HtmlDecode(Request.Form["MyEditor"]); if (Name == string.Empty) { ShowWindow(1, "系统提示", "请填写职位名称", null, true); } else if (Dept == string.Empty) { ShowWindow(1, "系统提示", "请填写工作部门", null, true); } else if (Email == string.Empty) { ShowWindow(1, "系统提示", "请填写联系邮箱", null, true); } else if (!Regex.IsMatch(Email, @"^[\w\.-]+@[\w\.-]+\.\w+$")) { ShowWindow(4, "系统提示", "联系邮箱地址无效", null, true); } else if (Address == string.Empty) { ShowWindow(1, "系统提示", "请填写工作地点", null, true); } else if (Num == string.Empty) { ShowWindow(1, "系统提示", "请填写招聘人数", null, true); } else if (Sex == string.Empty) { ShowWindow(1, "系统提示", "请填写性别要求", null, true); } else if (Experience == string.Empty) { ShowWindow(1, "系统提示", "请填写工作年限", null, true); } else if (Language == string.Empty) { ShowWindow(1, "系统提示", "请填写语言要求", null, true); } else if (Salary == string.Empty) { ShowWindow(1, "系统提示", "请填写薪水范围", null, true); } else if (Education == string.Empty) { ShowWindow(1, "系统提示", "请填写学历要求", null, true); } else if (ResumeLanguage == string.Empty) { ShowWindow(1, "系统提示", "请填写简历语言", null, true); } else if (Content == string.Empty) { ShowWindow(1, "系统提示", "请填写职位描述", null, true); } else { JobsInfo JInfo = new JobsInfo(); JInfo.Name = Name; JInfo.Dept = Dept; JInfo.Email = Email; JInfo.Address = Address; JInfo.Num = Num; JInfo.Sex = Sex; JInfo.Experience = Experience; JInfo.Language = Language; JInfo.Salary = Salary; JInfo.Education = Education; JInfo.ResumeLanguage = ResumeLanguage; JInfo.Content = Content; if (new BLL.Jobs.Jobs().Add(JInfo) != 0) { ShowWindow(3, "系统提示", "招聘添加成功,点击 \\\"确定\\\" 按钮返回招聘列表页面", "jobs.aspx", false); } else { ShowWindow(4, "系统提示", "招聘添加失败", null, true); } } } }
public bool ReadXml(string xmlName, out string errorMessage) { errorMessage = null; Clear(); if (string.IsNullOrEmpty(xmlName)) { return(false); } if (!File.Exists(xmlName)) { return(false); } string xmlDir = Path.GetDirectoryName(xmlName); try { string prefix = string.Empty; XmlDocument xdocConfig = XmlDocumentLoader.LoadWithIncludes(xmlName); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdocConfig.NameTable); XPathNavigator xNav = xdocConfig.CreateNavigator(); if (xNav.MoveToFollowing(XPathNodeType.Element)) { IDictionary <string, string> localNamespaces = xNav.GetNamespacesInScope(XmlNamespaceScope.Local); if (localNamespaces.TryGetValue("", out string nameSpace)) { namespaceManager.AddNamespace("carcontrol", nameSpace); prefix = "carcontrol:"; } } XmlAttribute attrib; XmlNode xnodeGlobal = xdocConfig.SelectSingleNode(string.Format("/{0}configuration/{0}global", prefix), namespaceManager); if (xnodeGlobal?.Attributes != null) { attrib = xnodeGlobal.Attributes["ecu_path"]; if (attrib != null) { if (Path.IsPathRooted(attrib.Value)) { _ecuPath = attrib.Value; } else { // ReSharper disable once AssignNullToNotNullAttribute _ecuPath = string.IsNullOrEmpty(xmlDir) ? attrib.Value : Path.Combine(xmlDir, attrib.Value); } } attrib = xnodeGlobal.Attributes["log_path"]; if (attrib != null) { _logPath = attrib.Value; } attrib = xnodeGlobal.Attributes["append_log"]; if (attrib != null) { _appendLog = XmlConvert.ToBoolean(attrib.Value); } attrib = xnodeGlobal.Attributes["manufacturer"]; if (attrib != null) { _manufacturerName = attrib.Value; } attrib = xnodeGlobal.Attributes["interface"]; if (attrib != null) { _interfaceName = attrib.Value; } } if (string.Compare(_manufacturerName, "Audi", StringComparison.OrdinalIgnoreCase) == 0) { _manufacturerType = ActivityCommon.ManufacturerType.Audi; } else if (string.Compare(_manufacturerName, "Seat", StringComparison.OrdinalIgnoreCase) == 0) { _manufacturerType = ActivityCommon.ManufacturerType.Seat; } else if (string.Compare(_manufacturerName, "Skoda", StringComparison.OrdinalIgnoreCase) == 0) { _manufacturerType = ActivityCommon.ManufacturerType.Skoda; } else if (string.Compare(_manufacturerName, "VW", StringComparison.OrdinalIgnoreCase) == 0) { _manufacturerType = ActivityCommon.ManufacturerType.Vw; } else { _manufacturerType = ActivityCommon.ManufacturerType.Bmw; } bool isBmw = _manufacturerType == ActivityCommon.ManufacturerType.Bmw; if (isBmw && string.Compare(_interfaceName, "ENET", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.Enet; } else if (isBmw && string.Compare(_interfaceName, "ELMWIFI", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.ElmWifi; } else if (string.Compare(_interfaceName, "DEEPOBDWIFI", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.DeepObdWifi; } else if (isBmw && string.Compare(_interfaceName, "FTDI", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.Ftdi; } else { _interfaceType = ActivityCommon.InterfaceType.Bluetooth; } XmlNode xnodePages = xdocConfig.SelectSingleNode(string.Format("/{0}configuration/{0}pages", prefix), namespaceManager); if (xnodePages?.Attributes != null) { attrib = xnodePages.Attributes["include_filename"]; if (attrib != null) { _xmlFileNamePages = attrib.Value; } } XmlNodeList xnodesPage = xdocConfig.SelectNodes(string.Format("/{0}configuration/{0}pages/{0}page", prefix), namespaceManager); if (xnodesPage != null) { foreach (XmlNode xnodePage in xnodesPage) { string pageName = string.Empty; string xmlFileName = string.Empty; float pageWeight = -1; int textResId = 0; int gaugesPortrait = GaugesPortraitDefault; int gaugesLandscape = GaugesLandscapeDefault; PageInfo.DisplayModeType displayMode = PageInfo.DisplayModeType.List; string logFile = string.Empty; bool jobActivate = false; if (xnodePage.Attributes != null) { attrib = xnodePage.Attributes["include_filename"]; if (attrib != null) { xmlFileName = attrib.Value; } attrib = xnodePage.Attributes["name"]; if (attrib != null) { pageName = attrib.Value; } attrib = xnodePage.Attributes["weight"]; if (attrib != null) { try { pageWeight = XmlConvert.ToSingle(attrib.Value); } catch { // ignored } } attrib = xnodePage.Attributes["display-mode"]; if (attrib != null) { if (!Enum.TryParse(attrib.Value, true, out displayMode)) { displayMode = PageInfo.DisplayModeType.List; } } attrib = xnodePage.Attributes["fontsize"]; if (attrib != null) { string size = attrib.Value.ToLowerInvariant(); switch (size) { case "small": textResId = Android.Resource.Style.TextAppearanceSmall; break; case "medium": textResId = Android.Resource.Style.TextAppearanceMedium; break; case "large": textResId = Android.Resource.Style.TextAppearanceLarge; break; } } attrib = xnodePage.Attributes["gauges-portrait"]; if (attrib != null) { try { int gauges = XmlConvert.ToInt32(attrib.Value); if (gauges >= 1) { gaugesPortrait = gauges; } } catch { // ignored } } attrib = xnodePage.Attributes["gauges-landscape"]; if (attrib != null) { try { int gauges = XmlConvert.ToInt32(attrib.Value); if (gauges >= 1) { gaugesLandscape = gauges; } } catch { // ignored } } attrib = xnodePage.Attributes["logfile"]; if (attrib != null) { logFile = attrib.Value; } attrib = xnodePage.Attributes["activate"]; if (attrib != null) { try { jobActivate = XmlConvert.ToBoolean(attrib.Value); } catch (Exception) { // ignored } } } JobsInfo jobsInfo = null; ErrorsInfo errorsInfo = null; List <DisplayInfo> displayList = new List <DisplayInfo>(); List <StringInfo> stringList = new List <StringInfo>(); bool logEnabled = false; string classCode = null; bool codeShowWarnings = false; foreach (XmlNode xnodePageChild in xnodePage.ChildNodes) { ReadDisplayNode(xnodePageChild, displayList, null, ref logEnabled); if (string.Compare(xnodePageChild.Name, "strings", StringComparison.OrdinalIgnoreCase) == 0) { string lang = null; if (xnodePageChild.Attributes != null) { attrib = xnodePageChild.Attributes["lang"]; if (attrib != null) { lang = attrib.Value; } } Dictionary <string, string> stringDict = new Dictionary <string, string>(); foreach (XmlNode xnodeString in xnodePageChild.ChildNodes) { string text = xnodeString.InnerText; string name = string.Empty; if (xnodeString.Attributes != null) { attrib = xnodeString.Attributes["name"]; if (attrib != null) { name = attrib.Value; } } if (string.IsNullOrEmpty(name)) { continue; } if (!stringDict.ContainsKey(name)) { stringDict.Add(name, text); } } stringList.Add(new StringInfo(lang, stringDict)); } if (string.Compare(xnodePageChild.Name, "jobs", StringComparison.OrdinalIgnoreCase) == 0) { string sgbd = null; string vagDataFileName = null; string vagUdsFileName = null; List <JobInfo> jobList = new List <JobInfo>(); if (xnodePageChild.Attributes != null) { attrib = xnodePageChild.Attributes["sgbd"]; if (attrib != null) { sgbd = attrib.Value; } attrib = xnodePageChild.Attributes["vag_data_file"]; if (attrib != null) { vagDataFileName = attrib.Value; } attrib = xnodePageChild.Attributes["vag_uds_file"]; if (attrib != null) { vagUdsFileName = attrib.Value; } } foreach (XmlNode xnodeJobsChild in xnodePageChild.ChildNodes) { if (string.Compare(xnodeJobsChild.Name, "job", StringComparison.OrdinalIgnoreCase) == 0) { string jobId = string.Empty; string jobSgbd = string.Empty; string jobName = string.Empty; string jobArgsFirst = string.Empty; string jobArgs = string.Empty; string jobResults = string.Empty; if (xnodeJobsChild.Attributes != null) { attrib = xnodeJobsChild.Attributes["id"]; if (attrib != null) { jobId = attrib.Value; } attrib = xnodeJobsChild.Attributes["sgbd"]; if (attrib != null) { jobSgbd = attrib.Value; } attrib = xnodeJobsChild.Attributes["name"]; if (attrib != null) { jobName = attrib.Value; } attrib = xnodeJobsChild.Attributes["args_first"]; if (attrib != null) { jobArgsFirst = attrib.Value; } attrib = xnodeJobsChild.Attributes["args"]; if (attrib != null) { jobArgs = attrib.Value; } attrib = xnodeJobsChild.Attributes["results"]; if (attrib != null) { jobResults = attrib.Value; } } jobList.Add(new JobInfo(jobId, jobSgbd, jobName, jobArgsFirst, jobArgs, jobResults)); foreach (XmlNode xnodeJobChild in xnodeJobsChild.ChildNodes) { ReadDisplayNode(xnodeJobChild, displayList, (string.IsNullOrEmpty(jobId) ? jobName : jobId) + "#", ref logEnabled); } } } jobsInfo = new JobsInfo(sgbd, vagDataFileName, vagUdsFileName, jobList); } if (string.Compare(xnodePageChild.Name, "read_errors", StringComparison.OrdinalIgnoreCase) == 0) { string sgbdFunctional = string.Empty; attrib = xnodePageChild.Attributes["sgbd_functional"]; if (attrib != null) { sgbdFunctional = attrib.Value; } List <EcuInfo> ecuList = new List <EcuInfo>(); foreach (XmlNode xnodeErrorsChild in xnodePageChild.ChildNodes) { if (string.Compare(xnodeErrorsChild.Name, "ecu", StringComparison.OrdinalIgnoreCase) == 0) { string ecuName = string.Empty; string sgbd = string.Empty; string vagDataFileName = null; string vagUdsFileName = null; string results = "F_UW_KM"; if (xnodeErrorsChild.Attributes != null) { attrib = xnodeErrorsChild.Attributes["name"]; if (attrib != null) { ecuName = attrib.Value; } attrib = xnodeErrorsChild.Attributes["sgbd"]; if (attrib != null) { sgbd = attrib.Value; } attrib = xnodeErrorsChild.Attributes["vag_data_file"]; if (attrib != null) { vagDataFileName = attrib.Value; } attrib = xnodeErrorsChild.Attributes["vag_uds_file"]; if (attrib != null) { vagUdsFileName = attrib.Value; } attrib = xnodeErrorsChild.Attributes["results"]; if (attrib != null) { results = attrib.Value; } } ecuList.Add(new EcuInfo(ecuName, sgbd, vagDataFileName, vagUdsFileName, results)); } } errorsInfo = new ErrorsInfo(sgbdFunctional, ecuList); } if (string.Compare(xnodePageChild.Name, "code", StringComparison.OrdinalIgnoreCase) == 0) { classCode = xnodePageChild.InnerText; attrib = xnodePageChild.Attributes["show_warnings"]; // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (attrib == null) { // for backward compatibility attrib = xnodePageChild.Attributes["show_warnigs"]; } if (attrib != null) { try { codeShowWarnings = XmlConvert.ToBoolean(attrib.Value); } catch (Exception) { // ignored } } } } if (!logEnabled) { logFile = string.Empty; } if (logEnabled) { _logTagsPresent = true; } if (string.IsNullOrEmpty(pageName)) { continue; } if (string.IsNullOrWhiteSpace(classCode)) { classCode = null; } _pageList.Add(new PageInfo(xmlFileName, pageName, pageWeight, displayMode, textResId, gaugesPortrait, gaugesLandscape, logFile, jobActivate, classCode, codeShowWarnings, jobsInfo, errorsInfo, displayList, stringList)); } } return(true); } catch (Exception ex) { errorMessage = string.Empty; string fileName = Path.GetFileName(xmlName); if (!string.IsNullOrEmpty(fileName)) { errorMessage = fileName + ":\r\n"; } errorMessage += EdiabasNet.GetExceptionText(ex) ?? string.Empty; return(false); } }
///<Summary> /// Gets the answer ///</Summary> public void Execute(IJobExecutionContext context) { try { using (CallTrackingDBContext _db = new CallTrackingDBContext()) { Log.Info("SetCallInfoJob запущен!"); //получаем дату и время последнего запуска Job-а string date = ""; JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.SetCallInfoJob);//_db.jobsInfo.FirstOrDefault(t => t.job.Id == Constants.SetCallInfoJob); if (JobsInfoQuery != null) { //date = JobsInfoQuery.lastactiondate.ToString("YYYY-M-dd hh:"); date = JobsInfoQuery.lastactiondate.Year + "-" + JobsInfoQuery.lastactiondate.Month + "-" + JobsInfoQuery.lastactiondate.Day + " " + JobsInfoQuery.lastactiondate.Hour + ":" + JobsInfoQuery.lastactiondate.Minute + ":" + JobsInfoQuery.lastactiondate.Second; } else //если Job не запускался, то делаем работу за весь период { DateTime calldate = DateTime.Parse("2012-05-01"); date = calldate.Year + "-" + calldate.Month + "-" + calldate.Day + " " + calldate.Hour + ":" + calldate.Minute + ":" + calldate.Second; } // using (MySqlConnection objConn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CallTrackingDBContext"].ConnectionString)) { objConn.Open(); MySqlCommand objSetCallInfo = new MySqlCommand("SetCallInfo", objConn); objSetCallInfo.CommandType = CommandType.StoredProcedure; objSetCallInfo.CommandTimeout = int.MaxValue; objSetCallInfo.Parameters.Add("@date_", MySqlDbType.Datetime).Value = DateTime.Parse(date); objSetCallInfo.ExecuteNonQuery(); objConn.Close(); } /*_db.Database.ExecuteSqlCommand(String.Format(@"update Cdr c, Visits v * set c.VisitsId=v.Id * where * c.VisitsId is null * and * c.calldate>Date('{0}') * and * c.dcontext='frw_in' * and * c.dst=v.UserNumber * and * c.calldate between v.datetime and v.lastupdate", date));// + interval 3 minute */ JobsInfo new_jobs_info = new JobsInfo() { status = true, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.SetCallInfoJob }; //поставить еще jobId! ( также в классе JobsInfo ) _jobsinfoRep.Add(new_jobs_info); _jobsinfoRep.Save(); Console.WriteLine("SetCallInfoJob is running....." + DateTime.Now.ToString()); Log.Info("SetCallInfoJob успешно выполнен!"); } } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } //JobsInfo new_jobs_info = new JobsInfo() { status = false, lastactiondate = DateTime.Now.ToUniversalTime(), ExceptionText = String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace) };//поставить еще jobId! ( также в классе JobsInfo ) // _jobsinfoRep.Add(new_jobs_info); // _jobsinfoRep.Save(); Log.Error(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); Console.WriteLine("SetCallInfoJob is running with error....." + DateTime.Now.ToString()); Console.WriteLine(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); } }
public void Execute(IJobExecutionContext context) { try { // Log.Info("GetGoogleAnalyticsDataJob запущен!"); Console.WriteLine("GetGoogleAnalyticsDataJob is started....." + DateTime.Now.ToString()); IQueryable <Client> clients = _clientRep.GetAll(); DateTime StartDate = new DateTime(); DateTime FinishDate = new DateTime(); JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.GetGoogleAnalyticsDataJob); if (JobsInfoQuery != null) { StartDate = /*DateTime.Parse("2013-04-01");*/ JobsInfoQuery.lastactiondate.AddDays(-1); //AddDays(-1) для учета часовых поясов FinishDate = DateTime.Now.ToUniversalTime().AddDays(2); //AddDays(1) для учета часовых поясов } else { if (_visitsRep.GetAll().Count() > 0) { StartDate = DateTime.Parse("2012-05-01"); FinishDate = DateTime.Now.ToUniversalTime().AddDays(2);//AddDays(1) для учета часовых поясов } } foreach (Client item in clients) { Console.WriteLine("GetGoogleAnalyticsDataJob Клиент " + item.Name + " Время старта: " + DateTime.Now); if (item.Id != 6) { if (!(String.IsNullOrEmpty(item.LoginGoogleAnalitics)) && (!String.IsNullOrEmpty(item.PasswordGoogleAnalitics)) && (!String.IsNullOrEmpty(item.ids.ToString())) && (item.ids != 0)) { Execute_NonPaidSearchTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_PaidSearchTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_ReferralTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_DirectTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); } } else { if (StartDate >= DateTime.Parse("2013-05-25")) //для клиента 6 выполняем после 25-го числа { if (!(String.IsNullOrEmpty(item.LoginGoogleAnalitics)) && (!String.IsNullOrEmpty(item.PasswordGoogleAnalitics)) && (!String.IsNullOrEmpty(item.ids.ToString())) && (item.ids != 0)) { Execute_NonPaidSearchTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_PaidSearchTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_ReferralTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); Execute_DirectTraffic_Query(StartDate, FinishDate, item.LoginGoogleAnalitics, item.PasswordGoogleAnalitics, item.ids.ToString(), item.Id); } } } Console.WriteLine("GetGoogleAnalyticsDataJob Клиент " + item.Name + " Время финиша: " + DateTime.Now); } _jobsinfoRep.Add(new JobsInfo() { jobId = Constants.GetGoogleAnalyticsDataJob, lastactiondate = DateTime.Now.AddDays(-1).ToUniversalTime(), status = true }); _jobsinfoRep.Save(); // Log.Info("GetGoogleAnalyticsDataJob успешно выполнен!"); Console.WriteLine("GetGoogleAnalyticsDataJob is finished....." + DateTime.Now.ToString()); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } //Log.Error(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); // Console.WriteLine("GetGoogleAnalyticsDataJob is running with error....." + DateTime.Now.ToString()); // Console.WriteLine(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); throw ex; } }
public int Save(JobsInfo JInfo) { return(dal.Save(JInfo)); }
public void Execute(IJobExecutionContext context) { try { Console.WriteLine("RemoveMoneyJob is starting....." + DateTime.Now.ToString()); Log.Info("RemoveMoneyJob запущен!"); List <GetBillsecForClientInfo> BillsecForClientInfoList_Curent = new List <GetBillsecForClientInfo>(); List <GetPhonesCountForClientInfo> PhonesCountForClientInfoList_Curent = new List <GetPhonesCountForClientInfo>(); ////выбираем дату последнего успешного запуска Job-а ( Начало ) DateTime lastactiondate = new DateTime(); JobsInfo JobsInfoQuery = _jobsinfoRep.GetLastActionDateForJob(Constants.RemoveMoneyJob); if (JobsInfoQuery != null) { lastactiondate = JobsInfoQuery.lastactiondate; } // выбираем дату последнего успешного запуска Job-а ( Конец ) else { lastactiondate = DateTime.Parse("2013-03-15"); } double numbercostforday = 0; DateTime FinishDate = /*GetDateFromFile()[1];*/ DateTime.Now.AddHours(-1).ToUniversalTime(); DateTime StartDate = /*GetDateFromFile()[0];*/ lastactiondate; DateTime CurentDate = StartDate; MinutesCost lastminutecostdate = null; NumberCost lastnumbercostdate = null; //StartDate = DateTime.Parse("29.04.2013 23:00:00"); //CurentDate = StartDate; //FinishDate = DateTime.Parse("30.04.2013 00:00:00").AddHours(-1); while (CurentDate <= FinishDate) //условие <= приводит к двойному выполнению Job-а для одного и того же клиента в сутки { string clients = GetClientsForRemoveMoney_(CurentDate /*DateTime.Parse("30.04.2013 0:00:00")*/); //получаем всех клиентов, для которых нужно списать деньги if (!String.IsNullOrEmpty(clients)) { Console.WriteLine("Диапазон между startdate и finishdate: " + StartDate.ToString() + " - " + FinishDate.ToString()); Console.WriteLine("Грабеж!!!!!!!!! Время грабежа: " + CurentDate.ToString() + " Клиенты: " + clients); List <BillSecForClientsInfo> billsecforclientsinfo = Call_GetBillSecForClients(CurentDate, clients); List <ActivedClientsNumbersCountInfo> activedclientsnumberscountinfo = Call_GetActivedClientsNumbers(CurentDate, clients); lastminutecostdate = _minutescostRep.GetAll().Where(t => t.lastupdate <= CurentDate).OrderByDescending(t => t.lastupdate).FirstOrDefault(); lastnumbercostdate = _numbercostRep.GetAll().Where(t => t.lastupdate <= CurentDate).OrderByDescending(t => t.lastupdate).FirstOrDefault(); List <InfoForPaymants> infoforpaymants = new List <InfoForPaymants>(); var commondata = from b in billsecforclientsinfo from a in activedclientsnumberscountinfo where b.date == a.date && b.ClientId == a.ClientId select new { ClientId = b.ClientId, date = b.date, count = a.count, codes_billsec = b.codes_billsec }; var differentdata = from a in activedclientsnumberscountinfo where !billsecforclientsinfo.Any(t => t.ClientId == a.ClientId && t.date == a.date) select a; if (commondata.Count() > 0) { foreach (var item in commondata) { infoforpaymants.Add(new InfoForPaymants() { codes_billsec = item.codes_billsec, ClientId = item.ClientId, count = item.count, date = item.date }); } } if (differentdata.Count() > 0) { foreach (var item in differentdata) { infoforpaymants.Add(new InfoForPaymants() { codes_billsec = null, count = item.count, date = item.date, ClientId = item.ClientId }); } } int allbillsec = 0; //общее колическво секунд разговоров для клиента для всех кодов if (infoforpaymants.Count() > 0) { foreach (InfoForPaymants item in infoforpaymants) { numbercostforday = _numbercostRep.GetLastNumberCostToThisDate(item.date); //последняя стоимость номера за день if (item.codes_billsec != null) { item.sum = Math.Round(GetCommonBillsecCostForAllCodes(item.codes_billsec) + item.count * numbercostforday, 2); } else { item.sum = Math.Round(item.count * numbercostforday, 2); } if (item.codes_billsec != null) { allbillsec = item.codes_billsec.Sum(t => t.billsec); } Paymant new_paymant = new Paymant() { ClientId = item.ClientId, date = item.date, Type = false, sum = -1 * item.sum, coment = "Снятие денег со счета. Время разговоров: " + allbillsec + " сек; Количество арендуемых номеров: " + item.count + " Время: " + DateTime.Now.ToString() }; _paymantsRep.Add(new_paymant); _paymantsRep.Save(); Client curent_client = _clientRep.Find(item.ClientId); if (curent_client != null) { string message_ = "Уважаемый " + curent_client.Name + ", " + item.date.ToShortDateString() + " с вашего счета было снято " + item.sum + " грн за " + allbillsec + " секунд разговоров и за аренду телефонов в количестве " + item.count + "."; _sendemailjobinfoRep.Add(new SendEmailJobInfo() { attemptcount = 0, date = DateTime.Now.ToUniversalTime(), message = message_, status = false, subject = "CallTracking Info", To = curent_client.Email }); _sendemailjobinfoRep.Save(); } allbillsec = 0; } } } CurentDate = CurentDate.AddHours(1); } // AddOneHourToDatesFromFile(); JobsInfo new_jobs_info = new JobsInfo() { status = true, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.RemoveMoneyJob }; //поставить еще jobId! ( также в классе JobsInfo ) _jobsinfoRep.Add(new_jobs_info); _jobsinfoRep.Save(); Log.Info("RemoveMoneyJob успешно выполнен!"); Console.WriteLine("RemoveMoneyJob is finished....." + DateTime.Now.ToString()); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } /* JobsInfo new_jobs_info = new JobsInfo() { status = false, lastactiondate = DateTime.Now.ToUniversalTime(), jobId = Constants.RemoveMoneyJob, ExceptionText = String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace) };//поставить еще jobId! ( также в классе JobsInfo ) * _jobsinfoRep.Add(new_jobs_info); * _jobsinfoRep.Save(); * * Log.Error(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace)); * Console.WriteLine("RemoveMoneyJob is running with error....." + DateTime.Now.ToString()); * Console.WriteLine(String.Format(@"Message: {0}, Source: {1}, TargetSite: {2}, Trace: {3} ", ex.Message, ex.Source, ex.TargetSite, ex.StackTrace));*/ throw ex; } }
public static JobsInfo GetPartialJobs(ICollection <Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job > jobs, long offset, long count, string user, string queue, long sBegin, long sEnd , long fBegin, long fEnd, JobState jobState) { JobsInfo allJobs = new JobsInfo(); if (sBegin == null || sBegin < 0) { sBegin = 0l; } if (sEnd == null) { sEnd = long.MaxValue; } if (fBegin == null || fBegin < 0) { fBegin = 0l; } if (fEnd == null) { fEnd = long.MaxValue; } if (offset == null || offset < 0) { offset = 0l; } if (count == null) { count = long.MaxValue; } if (offset > jobs.Count) { return(allJobs); } long at = 0; long end = offset + count - 1; if (end < 0) { // due to overflow end = long.MaxValue; } foreach (Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job in jobs) { if (at > end) { break; } // can't really validate queue is a valid one since queues could change if (queue != null && !queue.IsEmpty()) { if (!job.GetQueueName().Equals(queue)) { continue; } } if (user != null && !user.IsEmpty()) { if (!job.GetUserName().Equals(user)) { continue; } } JobReport report = job.GetReport(); if (report.GetStartTime() < sBegin || report.GetStartTime() > sEnd) { continue; } if (report.GetFinishTime() < fBegin || report.GetFinishTime() > fEnd) { continue; } if (jobState != null && jobState != report.GetJobState()) { continue; } at++; if ((at - 1) < offset) { continue; } JobInfo jobInfo = new JobInfo(job); allJobs.Add(jobInfo); } return(allJobs); }
public bool ReadXml(string xmlName) { _pageList.Clear(); if (string.IsNullOrEmpty(xmlName)) { return(false); } if (!File.Exists(xmlName)) { return(false); } string xmlDir = Path.GetDirectoryName(xmlName); _ecuPath = string.Empty; _logPath = string.Empty; _interfaceName = string.Empty; try { string prefix = string.Empty; XmlDocument xdocConfig = XmlDocumentLoader.LoadWithIncludes(xmlName); XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdocConfig.NameTable); XPathNavigator xNav = xdocConfig.CreateNavigator(); if (xNav.MoveToFollowing(XPathNodeType.Element)) { IDictionary <string, string> localNamespaces = xNav.GetNamespacesInScope(XmlNamespaceScope.Local); string nameSpace; if (localNamespaces.TryGetValue("", out nameSpace)) { namespaceManager.AddNamespace("carcontrol", nameSpace); prefix = "carcontrol:"; } } XmlAttribute attrib; XmlNode xnodeGlobal = xdocConfig.SelectSingleNode(string.Format("/{0}configuration/{0}global", prefix), namespaceManager); if (xnodeGlobal?.Attributes != null) { attrib = xnodeGlobal.Attributes["ecu_path"]; if (attrib != null) { if (Path.IsPathRooted(attrib.Value)) { _ecuPath = attrib.Value; } else { _ecuPath = string.IsNullOrEmpty(xmlDir) ? attrib.Value : Path.Combine(xmlDir, attrib.Value); } } attrib = xnodeGlobal.Attributes["log_path"]; if (attrib != null) { _logPath = attrib.Value; } attrib = xnodeGlobal.Attributes["append_log"]; if (attrib != null) { _appendLog = XmlConvert.ToBoolean(attrib.Value); } attrib = xnodeGlobal.Attributes["interface"]; if (attrib != null) { _interfaceName = attrib.Value; } } if (string.Compare(_interfaceName, "ENET", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.Enet; } else if (string.Compare(_interfaceName, "FTDI", StringComparison.OrdinalIgnoreCase) == 0) { _interfaceType = ActivityCommon.InterfaceType.Ftdi; } else { _interfaceType = ActivityCommon.InterfaceType.Bluetooth; } XmlNodeList xnodePages = xdocConfig.SelectNodes(string.Format("/{0}configuration/{0}pages/{0}page", prefix), namespaceManager); if (xnodePages != null) { foreach (XmlNode xnodePage in xnodePages) { string pageName = string.Empty; float pageWeight = -1; string logFile = string.Empty; bool jobActivate = false; if (xnodePage.Attributes != null) { attrib = xnodePage.Attributes["name"]; if (attrib != null) { pageName = attrib.Value; } attrib = xnodePage.Attributes["weight"]; if (attrib != null) { try { pageWeight = XmlConvert.ToSingle(attrib.Value); } catch { // ignored } } attrib = xnodePage.Attributes["logfile"]; if (attrib != null) { logFile = attrib.Value; } attrib = xnodePage.Attributes["activate"]; if (attrib != null) { jobActivate = XmlConvert.ToBoolean(attrib.Value); } } JobsInfo jobsInfo = null; ErrorsInfo errorsInfo = null; List <DisplayInfo> displayList = new List <DisplayInfo>(); List <StringInfo> stringList = new List <StringInfo>(); bool logEnabled = false; string classCode = null; bool codeShowWarnings = false; foreach (XmlNode xnodePageChild in xnodePage.ChildNodes) { ReadDisplayNode(xnodePageChild, displayList, null, ref logEnabled); if (string.Compare(xnodePageChild.Name, "strings", StringComparison.OrdinalIgnoreCase) == 0) { string lang = null; if (xnodePageChild.Attributes != null) { attrib = xnodePageChild.Attributes["lang"]; if (attrib != null) { lang = attrib.Value; } } Dictionary <string, string> stringDict = new Dictionary <string, string>(); foreach (XmlNode xnodeString in xnodePageChild.ChildNodes) { string text = xnodeString.InnerText; string name = string.Empty; if (xnodeString.Attributes != null) { attrib = xnodeString.Attributes["name"]; if (attrib != null) { name = attrib.Value; } } if (string.IsNullOrEmpty(name)) { continue; } if (!stringDict.ContainsKey(name)) { stringDict.Add(name, text); } } stringList.Add(new StringInfo(lang, stringDict)); } if (string.Compare(xnodePageChild.Name, "jobs", StringComparison.OrdinalIgnoreCase) == 0) { string sgbd = null; List <JobInfo> jobList = new List <JobInfo>(); if (xnodePageChild.Attributes != null) { attrib = xnodePageChild.Attributes["sgbd"]; if (attrib != null) { sgbd = attrib.Value; } } foreach (XmlNode xnodeJobsChild in xnodePageChild.ChildNodes) { if (string.Compare(xnodeJobsChild.Name, "job", StringComparison.OrdinalIgnoreCase) == 0) { string jobName = string.Empty; string jobArgsFirst = string.Empty; string jobArgs = string.Empty; string jobResults = string.Empty; if (xnodeJobsChild.Attributes != null) { attrib = xnodeJobsChild.Attributes["name"]; if (attrib != null) { jobName = attrib.Value; } attrib = xnodeJobsChild.Attributes["args_first"]; if (attrib != null) { jobArgsFirst = attrib.Value; } attrib = xnodeJobsChild.Attributes["args"]; if (attrib != null) { jobArgs = attrib.Value; } attrib = xnodeJobsChild.Attributes["results"]; if (attrib != null) { jobResults = attrib.Value; } } jobList.Add(new JobInfo(jobName, jobArgsFirst, jobArgs, jobResults)); foreach (XmlNode xnodeJobChild in xnodeJobsChild.ChildNodes) { ReadDisplayNode(xnodeJobChild, displayList, jobName + "#", ref logEnabled); } } } jobsInfo = new JobsInfo(sgbd, jobList); } if (string.Compare(xnodePageChild.Name, "read_errors", StringComparison.OrdinalIgnoreCase) == 0) { List <EcuInfo> ecuList = new List <EcuInfo>(); foreach (XmlNode xnodeErrorsChild in xnodePageChild.ChildNodes) { if (string.Compare(xnodeErrorsChild.Name, "ecu", StringComparison.OrdinalIgnoreCase) == 0) { string ecuName = string.Empty; string sgbd = string.Empty; string results = "F_UW_KM"; if (xnodeErrorsChild.Attributes != null) { attrib = xnodeErrorsChild.Attributes["name"]; if (attrib != null) { ecuName = attrib.Value; } attrib = xnodeErrorsChild.Attributes["sgbd"]; if (attrib != null) { sgbd = attrib.Value; } attrib = xnodeErrorsChild.Attributes["results"]; if (attrib != null) { results = attrib.Value; } } ecuList.Add(new EcuInfo(ecuName, sgbd, results)); } } errorsInfo = new ErrorsInfo(ecuList); } if (string.Compare(xnodePageChild.Name, "code", StringComparison.OrdinalIgnoreCase) == 0) { classCode = xnodePageChild.InnerText; attrib = xnodePageChild.Attributes["show_warnigs"]; if (attrib != null) { codeShowWarnings = XmlConvert.ToBoolean(attrib.Value); } } } if (!logEnabled) { logFile = string.Empty; } if (string.IsNullOrEmpty(pageName)) { continue; } if (string.IsNullOrWhiteSpace(classCode)) { classCode = null; } _pageList.Add(new PageInfo(pageName, pageWeight, logFile, jobActivate, classCode, codeShowWarnings, jobsInfo, errorsInfo, displayList, stringList)); } } return(true); } catch (Exception) { return(false); } }
public int Add(JobsInfo JInfo) { return(dal.Add(JInfo)); }