//private static string HtmlDecode(string encoded) //{ // //Ändert z.B. < in < // //return WebUtility.HtmlDecode(encoded); // return WebUtility.UrlDecode(encoded); //} internal static string CheckCredentials(string name, string password) { int id; try { id = MelBoxSql.Tab_Contact.Authentification(name, password); } catch (Exception ex) { throw ex; // Was tun? } if (id > 0) { while (LogedInHash.Count > 10) //Max. 10 Benutzer gleichzetig eingelogged { LogedInHash.Remove(LogedInHash.Keys.GetEnumerator().Current); } string guid = Guid.NewGuid().ToString("N"); MelBoxSql.Contact user = MelBoxSql.Tab_Contact.SelectContact(id); LogedInHash.Add(guid, user); return(guid); } return(string.Empty); }
internal static string FromShiftTable(System.Data.DataTable dt, MelBoxSql.Contact user) { if (user == null) { return(string.Empty); } string html = "<p><input oninput=\"w3.filterHTML('#table1', '.item', this.value)\" class='w3-input' placeholder='Suche nach..'></p>\r\n"; html += "<table class='w3-table w3-bordered'>\n"; //add header row html += "<tr>"; if (user.Id > 0) { html += "<th>Edit</th>"; } //for (int i = 0; i < dt.Columns.Count; i++) html += "<th>Nr</th><th>Name</th><th>Via</th><th>Tag</th><th>Datum</th><th>Zeitraum</th>"; html += "</tr>\n"; List <DateTime> holydays = MelBoxSql.Tab_Shift.Holydays(DateTime.Now); //add rows for (int i = 0; i < dt.Rows.Count; i++) { int.TryParse(dt.Rows[i][0].ToString(), out int shiftId); int.TryParse(dt.Rows[i][1].ToString(), out int shiftContactId); string contactName = dt.Rows[i][2].ToString(); int.TryParse(dt.Rows[i][3].ToString(), out int via); string day = dt.Rows[i][4].ToString(); DateTime.TryParse(dt.Rows[i][5].ToString(), out DateTime date); int.TryParse(dt.Rows[i][6].ToString(), out int start); int.TryParse(dt.Rows[i][7].ToString(), out int end); if (holydays.Contains(date)) //Feiertag? { html += "<tr class='item w3-pale-red'>"; } else if (day == "Sa" || day == "So") //Wochenende ? { html += "<tr class='item w3-sand'>"; } else if (date == DateTime.Now.Date) //heute { html += "<tr class='item w3-pale-green'>"; } else { html += "<tr class='item'>"; } #region Editier-Button if (user.Accesslevel >= Server.Level_Admin || user.Accesslevel >= Server.Level_Reciever && (user.Id == shiftContactId || shiftId == 0)) { string route = shiftId == 0 ? date.ToShortDateString() : shiftId.ToString(); html += "<td>" + "<a href='/shift/" + route + "'><i class='material-icons-outlined'>build</i></a>" + "</td>"; } else { html += "<td> </td>"; } #endregion #region Bereitschafts-Id html += "<td>" + shiftId + "</td>"; #endregion #region Name html += "<td>" + contactName + "</td>"; #endregion #region Sendeweg bool phone = 0 != (via & (int)MelBoxSql.Tab_Contact.Communication.Sms); bool email = 0 != (via & (int)MelBoxSql.Tab_Contact.Communication.Email); html += "<td>"; if (phone) { html += "<span class='material-icons-outlined'>smartphone</span>"; } if (email) { html += "<span class='material-icons-outlined'>email</span>"; } html += "</td>"; #endregion #region Tag html += "<td>" + day + "</td>"; #endregion #region Datum html += "<td>" + date.ToShortDateString() + "</td>"; #endregion #region Beginn double s = Math.Round(start / 0.48); double e = Math.Round(end / 0.48); if (s + e == 0) { s = 50; } string sHour = (start > 0) ? start + " Uhr" : string.Empty; string eHour = (end > 0) ? end + " Uhr" : string.Empty; html += "<td>" + "<div class='w3-row w3-pale-blue' style='min-width:240px'>" + $" <div class='w3-col w3-right-align' style='width:{s - 1}%'>{sHour} </div>" + $" <div class='w3-col w3-teal' style='width:{50 - s}%'> </div>" + $" <div class='w3-col w3-teal w3-border-left' style='width:{e}%'> </div>" + $" <div class='w3-col w3-left-align' style='width:{50 - e}%'> {eHour}</div>" + " </div>" + "</td>"; # endregion html += "</tr>\n"; }
public static async System.Threading.Tasks.Task PageAsync(IHttpContext context, string titel, string body, MelBoxSql.Contact user = null) { Dictionary <string, string> pairs = new Dictionary <string, string> { { "##Titel##", titel }, { "##Quality##", GsmStatus.SignalQuality.ToString() }, { "##Inhalt##", body }, { "##User##", user == null ? string.Empty : user.Name } }; string html = Server.Page(Server.Html_Skeleton, pairs); await context.Response.SendResponseAsync(html).ConfigureAwait(false); }