/// <summary> /// 返回增值(%) /// </summary> /// <param name="interval"></param> /// <returns></returns> public override double?GetIncrease(int days) { DateTime time = LastDay.AddDays(-days); DateTime realTime = time; int addDays = -1; while (!HistoryDic.Keys.Contains(realTime)) { realTime = time.AddDays(addDays); addDays = addDays < 0 ? -addDays : -addDays - 1; if (addDays > 30) { return(null); //超过范围 返回空 } } double?value = HistoryDic[LastDay]; double?hisValue = HistoryDic[realTime]; if (days < 5) { hisValue = HistoryDic.Values.Take(days + 1).Last(); // 五天内按连续天数取 } double?result = 100 * (value - hisValue) / hisValue; return(Math.Round((double)result, 2)); }
public IHttpActionResult PutLastDay(int id, LastDay lastDay) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lastDay.ID) { return(BadRequest()); } db.Entry(lastDay).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LastDayExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult LastDayLookup(string emailAddress) { if (String.IsNullOrWhiteSpace(emailAddress)) { ModelState.AddModelError("EmailAddress", "Email Address Required"); return(View()); } ModelState.Clear(); LastDay lastDay = LastDay.Create(emailAddress); if (lastDay == null) { ModelState.AddModelError("EmailAddress", "User Lookup Error"); return(View(new { EmailAddress = emailAddress })); } if (UserRole.IsContingentAdmin(User) && !UserRole.IsEmployeeAdmin(User) && lastDay.IsContingent == false) { ModelState.AddModelError("EmailAddress", "Invalid Contingent"); return(View(new { EmailAddress = emailAddress })); } return(View("LastDayRequest", lastDay)); }
public IHttpActionResult SendLastDayServiceRequest(LastDay lastDay) { try { ServiceRequest serviceRequest = ServiceRequest.LastDay(lastDay, db); if (serviceRequest != null) { Mailer mailer = new Mailer(MessageTemplate.ServiceRequest, false); if (lastDay.ITaaS == true) { mailer = new Mailer(MessageTemplate.ITAASRequest, false); } mailer.SetFromAddress(lastDay.ManagersEmail); mailer.SendMessage("ServiceRequest", serviceRequest, serviceRequest.Subject); return(StatusCode(HttpStatusCode.NoContent)); } return(BadRequest()); } catch (Exception) { return(BadRequest()); } }
internal static ServiceRequest LastDay(LastDay lastDay, SNAPContext db) { try { ServiceRequest serviceRequest = new ServiceRequest(); serviceRequest.Name = lastDay.Name; serviceRequest.Title = lastDay.Title; serviceRequest.Department = lastDay.Department; serviceRequest.Manager = lastDay.Manager; serviceRequest.Office = lastDay.Office; serviceRequest.Notes = String.Format("{0}\n{1}", lastDay.PublicNotes, lastDay.PrivateNotes); Country country = db.Countries.Where(x => x.ISO2 == lastDay.Country).First(); string workerType = "#FTE"; if (lastDay.IsContingent == true) { workerType = "#CONT"; } string region = country.ISO2; if (lastDay.ITaaS == true) { region = "ITAAS"; } serviceRequest.Subject = String.Format("AM.{0} SNAP Last Day | {1} | {2} | {3}", region, serviceRequest.Name, Convert.ToDateTime(lastDay.EndDate).ToString("MMMM dd, yyyy"), workerType); if (lastDay.Immediate == true) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Immediate"); } if (db.Offices.Any(o => o.Name == lastDay.Office) == false) { serviceRequest.Subject = String.Format("{0} {1}", serviceRequest.Subject, "#Remote"); } return(serviceRequest); } catch (Exception) { return(null); } }
public IHttpActionResult PutGSCUser(int id, [FromBody] LastDay lastDay) { GSCUser gscUser = db.GSCUsers.Find(id); if (gscUser == null) { return(NotFound()); } gscUser.Decommission(db); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult DeleteLastDay(int id) { LastDay lastDay = db.LastDays.Find(id); if (lastDay == null) { return(NotFound()); } db.LastDays.Remove(lastDay); db.SaveChanges(); return(Ok(lastDay)); }
public ActionResult LastDayFix(LastDay lastDay) { if (ModelState.IsValid) { lastDay.ErrorLog = null; db.Entry(lastDay).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("LastDayErrors")); } return(View(lastDay)); }
public ActionResult LastDayFix(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LastDay lastDay = db.LastDays.Find(id); if (lastDay == null) { return(HttpNotFound()); } return(View(lastDay)); }
public ActionResult Edit(int id, LastDay lastDay) { lastDay.ValidateManager(ModelState); lastDay.SetRequestersEmail(User); if (ModelState.IsValid) { LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "Update"); if (TryValidateModel(lastDayNotice) == true) { if (lastDay.Immediate == true && (lastDay.Decommissioned == false || lastDay.ServiceRequest == false)) { lastDay.Decommission(); } if (lastDay.Suppress == false) { Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true); if (lastDay.IsContingent == true) { mailer = new Mailer(MessageTemplate.LastDayContingent, true); } mailer.SetFromAddress(lastDay.RequestersEmail); mailer.AddRecipient(lastDay.ManagersEmail); if (lastDay.ITaaS == true) { mailer.AddITaaSNotificationGroup(); } mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject); } db.Entry(lastDay).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } return(View(lastDay)); }
public LastDayNotice(LastDay lastDay, string noticeType) { string prefix = "Last Day"; if (lastDay.IsContingent == true) { prefix = "Assignment End"; } switch (noticeType) { case "Update": Heading = String.Format("{0} Notice Update", prefix); break; case "Cancel": Heading = String.Format("{0} Cancellation", prefix); break; default: case "New": Heading = String.Format("{0} Notice", prefix); break; } Name = lastDay.Name; Type = lastDay.WorkerType; Code = lastDay.Code; EndDate = Convert.ToDateTime(lastDay.EndDate).ToString("MMMM dd, yyyy"); Title = lastDay.Title; Department = lastDay.Department; Manager = lastDay.Manager; Office = lastDay.Office; Notes = lastDay.PublicNotes; if (lastDay.StartDate != null) { StartDate = Convert.ToDateTime(lastDay.StartDate).ToString("MMMM dd, yyyy"); } Subject = String.Format("{0} | {1} | {2}", Heading, Name, EndDate); }
public ActionResult DeleteConfirmed(int id) { LastDay lastDay = db.LastDays.Find(id); LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "Cancel"); if (TryValidateModel(lastDayNotice) == true) { if (lastDay.Suppress == false) { Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true); if (lastDay.IsContingent == true) { mailer = new Mailer(MessageTemplate.LastDayContingent, true); } mailer.SetFromAddress(lastDay.RequestersEmail); mailer.AddRecipient(lastDay.ManagersEmail); if (lastDay.ITaaS == true) { mailer.AddITaaSNotificationGroup(); } mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject); } db.LastDays.Remove(lastDay); db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); return(View()); }
private async void SampleValues(object State) { try { ushort A0 = this.arduino.analogRead("A0"); PinState D8 = this.arduino.digitalRead(8); if (this.windowA0[0].HasValue) { this.sumA0 -= this.windowA0[0].Value; this.nrA0--; } Array.Copy(this.windowA0, 1, this.windowA0, 0, windowSize - 1); this.windowA0[windowSize - 1] = A0; this.sumA0 += A0; this.nrA0++; double AvgA0 = ((double)this.sumA0) / this.nrA0; int? v; if (this.nrA0 >= windowSize - 2) { int NrLt = 0; int NrGt = 0; foreach (int?Value in this.windowA0) { if (Value.HasValue) { if (Value.Value < AvgA0) { NrLt++; } else if (Value.Value > AvgA0) { NrGt++; } } } if (NrLt == 1 || NrGt == 1) { v = this.windowA0[spikePos]; if (v.HasValue) { if ((NrLt == 1 && v.Value < AvgA0) || (NrGt == 1 && v.Value > AvgA0)) { this.sumA0 -= v.Value; this.nrA0--; this.windowA0[spikePos] = null; AvgA0 = ((double)this.sumA0) / this.nrA0; Log.Informational("Spike removed.", new KeyValuePair <string, object>("A0", v.Value)); } } } } int i, n; for (AvgA0 = i = n = 0; i < spikePos; i++) { if ((v = this.windowA0[i]).HasValue) { n++; AvgA0 += v.Value; } } if (n > 0) { AvgA0 /= n; double Light = (100.0 * AvgA0) / 1024; this.lastLight = Light; MainPage.Instance.LightUpdated(Light, 2, "%"); this.sumLight += Light; this.sumMotion += (D8 == PinState.HIGH ? 1 : 0); this.nrTerms++; DateTime Timestamp = DateTime.Now; if (!this.minLight.HasValue || Light < this.minLight.Value) { this.minLight = Light; this.minLightAt = Timestamp; } if (!this.maxLight.HasValue || Light > this.maxLight.Value) { this.maxLight = Light; this.maxLightAt = Timestamp; } if (!this.lastMinute.HasValue) { this.lastMinute = Timestamp.Minute; } else if (this.lastMinute.Value != Timestamp.Minute) { this.lastMinute = Timestamp.Minute; LastMinute Rec = new LastMinute() { Timestamp = Timestamp, Light = Light, Motion = D8, MinLight = this.minLight, MinLightAt = this.minLightAt, MaxLight = this.maxLight, MaxLightAt = this.maxLightAt, AvgLight = (this.nrTerms == 0 ? (double?)null : this.sumLight / this.nrTerms), AvgMotion = (this.nrTerms == 0 ? (double?)null : (this.sumMotion * 100.0) / this.nrTerms) }; await Database.Insert(Rec); this.minLight = null; this.minLightAt = DateTime.MinValue; this.maxLight = null; this.maxLightAt = DateTime.MinValue; this.sumLight = 0; this.sumMotion = 0; this.nrTerms = 0; foreach (LastMinute Rec2 in await Database.Find <LastMinute>(new FilterFieldLesserThan("Timestamp", Timestamp.AddMinutes(-100)))) { await Database.Delete(Rec2); } if (Timestamp.Minute == 0) { DateTime From = new DateTime(Timestamp.Year, Timestamp.Month, Timestamp.Day, Timestamp.Hour, 0, 0).AddHours(-1); DateTime To = From.AddHours(1); int NLight = 0; int NMotion = 0; LastHour HourRec = new LastHour() { Timestamp = Timestamp, Light = Light, Motion = D8, MinLight = Rec.MinLight, MinLightAt = Rec.MinLightAt, MaxLight = Rec.MaxLight, MaxLightAt = Rec.MaxLightAt, AvgLight = 0, AvgMotion = 0 }; foreach (LastMinute Rec2 in await Database.Find <LastMinute>(0, 60, new FilterAnd( new FilterFieldLesserThan("Timestamp", To), new FilterFieldGreaterOrEqualTo("Timestamp", From)))) { if (Rec2.AvgLight.HasValue) { HourRec.AvgLight += Rec2.AvgLight.Value; NLight++; } if (Rec2.AvgMotion.HasValue) { HourRec.AvgMotion += Rec2.AvgMotion.Value; NMotion++; } if (Rec2.MinLight < HourRec.MinLight) { HourRec.MinLight = Rec2.MinLight; HourRec.MinLightAt = Rec.MinLightAt; } if (Rec2.MaxLight < HourRec.MaxLight) { HourRec.MaxLight = Rec2.MaxLight; HourRec.MaxLightAt = Rec.MaxLightAt; } } if (NLight == 0) { HourRec.AvgLight = null; } else { HourRec.AvgLight /= NLight; } if (NMotion == 0) { HourRec.AvgMotion = null; } else { HourRec.AvgMotion /= NMotion; } await Database.Insert(HourRec); foreach (LastHour Rec2 in await Database.Find <LastHour>(new FilterFieldLesserThan("Timestamp", Timestamp.AddHours(-100)))) { await Database.Delete(Rec2); } if (Timestamp.Hour == 0) { From = new DateTime(Timestamp.Year, Timestamp.Month, Timestamp.Day, 0, 0, 0).AddDays(-1); To = From.AddDays(1); NLight = 0; NMotion = 0; LastDay DayRec = new LastDay() { Timestamp = Timestamp, Light = Light, Motion = D8, MinLight = HourRec.MinLight, MinLightAt = HourRec.MinLightAt, MaxLight = HourRec.MaxLight, MaxLightAt = HourRec.MaxLightAt, AvgLight = 0, AvgMotion = 0 }; foreach (LastHour Rec2 in await Database.Find <LastHour>(0, 24, new FilterAnd( new FilterFieldLesserThan("Timestamp", To), new FilterFieldGreaterOrEqualTo("Timestamp", From)))) { if (Rec2.AvgLight.HasValue) { DayRec.AvgLight += Rec2.AvgLight.Value; NLight++; } if (Rec2.AvgMotion.HasValue) { DayRec.AvgMotion += Rec2.AvgMotion.Value; NMotion++; } if (Rec2.MinLight < DayRec.MinLight) { DayRec.MinLight = Rec2.MinLight; DayRec.MinLightAt = Rec.MinLightAt; } if (Rec2.MaxLight < DayRec.MaxLight) { DayRec.MaxLight = Rec2.MaxLight; DayRec.MaxLightAt = Rec.MaxLightAt; } } if (NLight == 0) { DayRec.AvgLight = null; } else { DayRec.AvgLight /= NLight; } if (NMotion == 0) { DayRec.AvgMotion = null; } else { DayRec.AvgMotion /= NMotion; } await Database.Insert(DayRec); foreach (LastDay Rec2 in await Database.Find <LastDay>(new FilterFieldLesserThan("Timestamp", Timestamp.AddDays(-100)))) { await Database.Delete(Rec2); } } } } } } catch (Exception ex) { Log.Critical(ex); } }
/// <summary> /// Registriert diese Aufzeichnung in einer Planungsinstanz. /// </summary> /// <param name="scheduler">Die zu verwendende Planungsinstanz.</param> /// <param name="job">Der zugehörige Auftrag.</param> /// <param name="devices">Die Liste der Geräte, auf denen die Aufzeichnung ausgeführt werden darf.</param> /// <param name="findSource">Dient zum Prüfen einer Quelle.</param> /// <param name="disabled">Alle deaktivierten Aufträge.</param> /// <param name="context">Die aktuelle Planungsumgebung.</param> /// <exception cref="ArgumentNullException">Es wurden nicht alle Parameter angegeben.</exception> public void AddToScheduler(RecordingScheduler scheduler, VCRJob job, IScheduleResource[] devices, Func <SourceSelection, SourceSelection> findSource, Func <Guid, bool> disabled, PlanContext context) { // Validate if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } if (job == null) { throw new ArgumentNullException(nameof(job)); } if (findSource == null) { throw new ArgumentNullException(nameof(findSource)); } // Let VCR.NET choose a profile to do the work if (job.AutomaticResourceSelection) { devices = null; } // Create the source selection var persistedSource = Source ?? job.Source; var selection = findSource(persistedSource); // Station no longer available if (selection == null) { if (persistedSource != null) { selection = new SourceSelection { DisplayName = persistedSource.DisplayName, ProfileName = persistedSource.ProfileName, Location = persistedSource.Location, Group = persistedSource.Group, Source = new Station { TransportStream = persistedSource.Source?.TransportStream ?? 0, Network = persistedSource.Source?.Network ?? 0, Service = persistedSource.Source?.Service ?? 0, Name = persistedSource.DisplayName, }, } } } ; // See if we are allowed to process var identifier = UniqueID.Value; if (disabled != null) { if (disabled(identifier)) { return; } } // Load all var name = string.IsNullOrEmpty(Name) ? job.Name : $"{job.Name} ({Name})"; var source = ProfileScheduleResource.CreateSource(selection); var duration = TimeSpan.FromMinutes(Duration); var noStartBefore = NoStartBefore; var start = FirstStart; // Check repetition var repeat = CreateRepeatPattern(); if (repeat == null) { // Only if not being recorded if (!noStartBefore.HasValue) { scheduler.Add(RecordingDefinition.Create(this, name, identifier, devices, source, start, duration)); } } else { // See if we have to adjust the start day if (noStartBefore.HasValue) { // Attach to the limit - actually we shift it a bit further assuming that we did have no large exception towards the past and the duration is moderate var startAfter = noStartBefore.Value.AddHours(12); var startAfterDay = startAfter.ToLocalTime().Date; // Localize the start time var startTime = start.ToLocalTime().TimeOfDay; // First adjust start = (startAfterDay + startTime).ToUniversalTime(); // One more day if (start < startAfter) { start = (startAfterDay.AddDays(1) + startTime).ToUniversalTime(); } } // Read the rest var exceptions = Exceptions.Select(e => e.ToPlanException(duration)).ToArray(); var endDay = LastDay.GetValueOrDefault(MaxMovableDay); // A bit more complex if (start.Date <= endDay.Date) { scheduler.Add(RecordingDefinition.Create(this, name, identifier, devices, source, start, duration, endDay, repeat), exceptions); } } }
public MySqlFunctionManager(bool allowFuncDefChange) { this.allowFuncDefChange = allowFuncDefChange; parsingStrateg["CAST"] = FunctionParsingStrategy.Cast; parsingStrateg["POSITION"] = FunctionParsingStrategy.Position; parsingStrateg["SUBSTR"] = FunctionParsingStrategy.Substring; parsingStrateg["SUBSTRING"] = FunctionParsingStrategy.Substring; parsingStrateg["TRIM"] = FunctionParsingStrategy.Trim; parsingStrateg["AVG"] = FunctionParsingStrategy.Avg; parsingStrateg["COUNT"] = FunctionParsingStrategy.Count; parsingStrateg["GROUP_CONCAT"] = FunctionParsingStrategy.GroupConcat; parsingStrateg["MAX"] = FunctionParsingStrategy.Max; parsingStrateg["MIN"] = FunctionParsingStrategy.Min; parsingStrateg["SUM"] = FunctionParsingStrategy.Sum; parsingStrateg["ROW"] = FunctionParsingStrategy.Row; parsingStrateg["CHAR"] = FunctionParsingStrategy.Char; parsingStrateg["CONVERT"] = FunctionParsingStrategy.Convert; parsingStrateg["EXTRACT"] = FunctionParsingStrategy.Extract; parsingStrateg["TIMESTAMPADD"] = FunctionParsingStrategy.Timestampadd; parsingStrateg["TIMESTAMPDIFF"] = FunctionParsingStrategy.Timestampdiff; parsingStrateg["GET_FORMAT"] = FunctionParsingStrategy.GetFormat; functionPrototype["ABS"] = new Abs(null); functionPrototype["ACOS"] = new Acos(null); functionPrototype["ADDDATE"] = new Adddate(null); functionPrototype["ADDTIME"] = new Addtime(null); functionPrototype["AES_DECRYPT"] = new AesDecrypt(null); functionPrototype["AES_ENCRYPT"] = new AesEncrypt(null); functionPrototype["ANALYSE"] = new Analyse(null); functionPrototype["ASCII"] = new Ascii(null); functionPrototype["ASIN"] = new Asin(null); functionPrototype["ATAN2"] = new Atan2(null); functionPrototype["ATAN"] = new Atan(null); functionPrototype["BENCHMARK"] = new Benchmark(null); functionPrototype["BIN"] = new Bin(null); functionPrototype["BIT_AND"] = new BitAnd(null); functionPrototype["BIT_COUNT"] = new BitCount(null); functionPrototype["BIT_LENGTH"] = new BitLength(null); functionPrototype["BIT_OR"] = new BitOR(null); functionPrototype["BIT_XOR"] = new BitXor(null); functionPrototype["CEIL"] = new Ceiling(null); functionPrototype["CEILING"] = new Ceiling(null); functionPrototype["CHAR_LENGTH"] = new CharLength(null); functionPrototype["CHARACTER_LENGTH"] = new CharLength(null); functionPrototype["CHARSET"] = new Charset(null); functionPrototype["COALESCE"] = new Coalesce(null); functionPrototype["COERCIBILITY"] = new Coercibility(null); functionPrototype["COLLATION"] = new Collation(null); functionPrototype["COMPRESS"] = new Compress(null); functionPrototype["CONCAT_WS"] = new ConcatWs(null); functionPrototype["CONCAT"] = new Concat(null); functionPrototype["CONNECTION_ID"] = new ConnectionId(null); functionPrototype["CONV"] = new Conv(null); functionPrototype["CONVERT_TZ"] = new ConvertTz(null); functionPrototype["COS"] = new Cos(null); functionPrototype["COT"] = new Cot(null); functionPrototype["CRC32"] = new Crc32(null); functionPrototype["CURDATE"] = new Curdate(); functionPrototype["CURRENT_DATE"] = new Curdate(); functionPrototype["CURRENT_TIME"] = new Curtime(); functionPrototype["CURTIME"] = new Curtime(); functionPrototype["CURRENT_TIMESTAMP"] = new Now(); functionPrototype["CURRENT_USER"] = new CurrentUser(); functionPrototype["CURTIME"] = new Curtime(); functionPrototype["DATABASE"] = new Database(null); functionPrototype["DATE_ADD"] = new DateAdd(null); functionPrototype["DATE_FORMAT"] = new DateFormat(null); functionPrototype["DATE_SUB"] = new DateSub(null); functionPrototype["DATE"] = new Date(null); functionPrototype["DATEDIFF"] = new Datediff(null); functionPrototype["DAY"] = new Dayofmonth(null); functionPrototype["DAYOFMONTH"] = new Dayofmonth(null); functionPrototype["DAYNAME"] = new Dayname(null); functionPrototype["DAYOFWEEK"] = new Dayofweek(null); functionPrototype["DAYOFYEAR"] = new Dayofyear(null); functionPrototype["DECODE"] = new Decode(null); functionPrototype["DEFAULT"] = new Default(null); functionPrototype["DEGREES"] = new Degrees(null); functionPrototype["DES_DECRYPT"] = new DesDecrypt(null); functionPrototype["DES_ENCRYPT"] = new DesEncrypt(null); functionPrototype["ELT"] = new Elt(null); functionPrototype["ENCODE"] = new Encode(null); functionPrototype["ENCRYPT"] = new Encrypt(null); functionPrototype["EXP"] = new Exp(null); functionPrototype["EXPORT_SET"] = new ExportSet(null); // functionPrototype.put("EXTRACT", new Extract(null)); functionPrototype["EXTRACTVALUE"] = new ExtractValue(null); functionPrototype["FIELD"] = new Field(null); functionPrototype["FIND_IN_SET"] = new FindInSet(null); functionPrototype["FLOOR"] = new Floor(null); functionPrototype["FORMAT"] = new Format(null); functionPrototype["FOUND_ROWS"] = new FoundRows(null); functionPrototype["FROM_DAYS"] = new FromDays(null); functionPrototype["FROM_UNIXTIME"] = new FromUnixtime(null); // functionPrototype.put("GET_FORMAT", new GetFormat(null)); functionPrototype["GET_LOCK"] = new GetLock(null); functionPrototype["GREATEST"] = new Greatest(null); functionPrototype["HEX"] = new Hex(null); functionPrototype["HOUR"] = new Hour(null); functionPrototype["IF"] = new IF(null); functionPrototype["IFNULL"] = new IFNull(null); functionPrototype["INET_ATON"] = new InetAton(null); functionPrototype["INET_NTOA"] = new InetNtoa(null); functionPrototype["INSERT"] = new Insert(null); functionPrototype["INSTR"] = new Instr(null); functionPrototype["INTERVAL"] = new Interval(null); functionPrototype["IS_FREE_LOCK"] = new IsFreeLock(null); functionPrototype["IS_USED_LOCK"] = new IsUsedLock(null); functionPrototype["ISNULL"] = new IsNull(null); functionPrototype["LAST_DAY"] = new LastDay(null); functionPrototype["LAST_INSERT_ID"] = new LastInsertId(null); functionPrototype["LCASE"] = new Lower(null); functionPrototype["LEAST"] = new Least(null); functionPrototype["LEFT"] = new Left(null); functionPrototype["LENGTH"] = new Length(null); functionPrototype["LN"] = new Log(null); // Ln(X) equals Log(X) functionPrototype["LOAD_FILE"] = new LoadFile(null); functionPrototype["LOCALTIME"] = new Now(); functionPrototype["LOCALTIMESTAMP"] = new Now(); functionPrototype["LOCATE"] = new Locate(null); functionPrototype["LOG10"] = new Log10(null); functionPrototype["LOG2"] = new Log2(null); functionPrototype["LOG"] = new Log(null); functionPrototype["LOWER"] = new Lower(null); functionPrototype["LPAD"] = new Lpad(null); functionPrototype["LTRIM"] = new Ltrim(null); functionPrototype["MAKE_SET"] = new MakeSet(null); functionPrototype["MAKEDATE"] = new Makedate(null); functionPrototype["MAKETIME"] = new Maketime(null); functionPrototype["MASTER_POS_WAIT"] = new MasterPosWait(null); functionPrototype["MD5"] = new Md5(null); functionPrototype["MICROSECOND"] = new Microsecond(null); functionPrototype["MID"] = new Substring(null); functionPrototype["MINUTE"] = new Minute(null); functionPrototype["MONTH"] = new Month(null); functionPrototype["MONTHNAME"] = new Monthname(null); functionPrototype["NAME_CONST"] = new NameConst(null); functionPrototype["NOW"] = new Now(); functionPrototype["NULLIF"] = new NullIF(null); functionPrototype["OCT"] = new Oct(null); functionPrototype["OCTET_LENGTH"] = new Length(null); functionPrototype["OLD_PASSWORD"] = new OldPassword(null); functionPrototype["ORD"] = new Ord(null); functionPrototype["PASSWORD"] = new Password(null); functionPrototype["PERIOD_ADD"] = new PeriodAdd(null); functionPrototype["PERIOD_DIFF"] = new PeriodDiff(null); functionPrototype["PI"] = new PI(null); functionPrototype["POW"] = new Pow(null); functionPrototype["POWER"] = new Pow(null); functionPrototype["QUARTER"] = new Quarter(null); functionPrototype["QUOTE"] = new Quote(null); functionPrototype["RADIANS"] = new Radians(null); functionPrototype["RAND"] = new Rand(null); functionPrototype["RELEASE_LOCK"] = new ReleaseLock(null); functionPrototype["REPEAT"] = new Repeat(null); functionPrototype["REPLACE"] = new Replace(null); functionPrototype["REVERSE"] = new Reverse(null); functionPrototype["RIGHT"] = new Right(null); functionPrototype["ROUND"] = new Round(null); functionPrototype["ROW_COUNT"] = new RowCount(null); functionPrototype["RPAD"] = new Rpad(null); functionPrototype["RTRIM"] = new Rtrim(null); functionPrototype["SCHEMA"] = new Database(null); functionPrototype["SEC_TO_TIME"] = new SecToTime(null); functionPrototype["SECOND"] = new Second(null); functionPrototype["SESSION_USER"] = new User(null); functionPrototype["SHA1"] = new Sha1(null); functionPrototype["SHA"] = new Sha1(null); functionPrototype["SHA2"] = new Sha2(null); functionPrototype["SIGN"] = new Sign(null); functionPrototype["SIN"] = new Sin(null); functionPrototype["SLEEP"] = new Sleep(null); functionPrototype["SOUNDEX"] = new Soundex(null); functionPrototype["SPACE"] = new Space(null); functionPrototype["SQRT"] = new Sqrt(null); functionPrototype["STD"] = new Std(null); functionPrototype["STDDEV_POP"] = new StdDevPop(null); functionPrototype["STDDEV_SAMP"] = new StdDevSamp(null); functionPrototype["STDDEV"] = new StdDev(null); functionPrototype["STR_TO_DATE"] = new StrToDate(null); functionPrototype["STRCMP"] = new Strcmp(null); functionPrototype["SUBDATE"] = new Subdate(null); functionPrototype["SUBSTRING_INDEX"] = new SubstringIndex(null); functionPrototype["SUBTIME"] = new Subtime(null); functionPrototype["SYSDATE"] = new Sysdate(null); functionPrototype["SYSTEM_USER"] = new User(null); functionPrototype["TAN"] = new Tan(null); functionPrototype["TIME_FORMAT"] = new TimeFormat(null); functionPrototype["TIME_TO_SEC"] = new TimeToSec(null); functionPrototype["TIME"] = new Time(null); functionPrototype["TIMEDIFF"] = new Timediff(null); functionPrototype["TIMESTAMP"] = new Timestamp(null); // functionPrototype.put("TIMESTAMPADD", new Timestampadd(null)); // functionPrototype.put("TIMESTAMPDIFF", new Timestampdiff(null)); functionPrototype["TO_DAYS"] = new ToDays(null); functionPrototype["TO_SECONDS"] = new ToSeconds(null); functionPrototype["TRUNCATE"] = new Truncate(null); functionPrototype["UCASE"] = new Upper(null); functionPrototype["UNCOMPRESS"] = new Uncompress(null); functionPrototype["UNCOMPRESSED_LENGTH"] = new UncompressedLength(null); functionPrototype["UNHEX"] = new Unhex(null); functionPrototype["UNIX_TIMESTAMP"] = new UnixTimestamp(null); functionPrototype["UPDATEXML"] = new UpdateXml(null); functionPrototype["UPPER"] = new Upper(null); functionPrototype["USER"] = new User(null); functionPrototype["UTC_DATE"] = new UtcDate(null); functionPrototype["UTC_TIME"] = new UtcTime(null); functionPrototype["UTC_TIMESTAMP"] = new UtcTimestamp(null); functionPrototype["UUID_SHORT"] = new UuidShort(null); functionPrototype["UUID"] = new Uuid(null); functionPrototype["VALUES"] = new Values(null); functionPrototype["VAR_POP"] = new VarPop(null); functionPrototype["VAR_SAMP"] = new VarSamp(null); functionPrototype["VARIANCE"] = new Variance(null); functionPrototype["VERSION"] = new Version(null); functionPrototype["WEEK"] = new Week(null); functionPrototype["WEEKDAY"] = new Weekday(null); functionPrototype["WEEKOFYEAR"] = new Weekofyear(null); functionPrototype["YEAR"] = new Year(null); functionPrototype["YEARWEEK"] = new Yearweek(null); }
public ActionResult LastDayRequest(LastDay lastDay) { lastDay.Validate(ModelState, User); //if (db.LastDays.Any(x => x.EmailAddress == lastDay.EmailAddress)) //{ // ModelState.AddModelError("Request", "Last Day Already Requested"); //} if (ModelState.IsValid) { LastDayNotice lastDayNotice = new LastDayNotice(lastDay, "New"); if (TryValidateModel(lastDayNotice) == true) { if (lastDay.Immediate == true) { lastDay.Decommission(); } else { if (db.GSCUsers.Any(x => x.GUID == lastDay.GUID && x.Active == true)) { foreach (GSCUser gscUser in db.GSCUsers.Where(x => x.GUID == lastDay.GUID && x.Active == true)) { var gscClient = db.GSCClients.Find(gscUser.GSCClientID); gscUser.GSCClient = gscClient; gscUser.EndDate = lastDay.EndDate; gscUser.MailExternalCompany(); } } } if (lastDay.Suppress == false) { Mailer mailer = new Mailer(MessageTemplate.LastDayEmployee, true); if (lastDay.IsContingent == true) { mailer = new Mailer(MessageTemplate.LastDayContingent, true); } mailer.SetFromAddress(lastDay.RequestersEmail); mailer.AddRecipient(lastDay.ManagersEmail); if (lastDay.ITaaS == true) { mailer.AddITaaSNotificationGroup(); } mailer.SendMessage("LastDayNotice", lastDayNotice, lastDayNotice.Subject); } db.LastDays.Add(lastDay); db.SaveChanges(); return(RedirectToAction("Index")); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } return(View(lastDay)); }