Rename to VAR.Focus

This commit is contained in:
2015-06-26 02:23:21 +02:00
parent 58d51ee3b7
commit 175fad80e4
52 changed files with 71 additions and 98 deletions

View File

@@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace VAR.Focus.Web.Code
{
public class Bundler
{
#region Declarations
private string _path = null;
private List<string> _files = null;
#endregion
#region Properties
private List<string> Files
{
get
{
if (_files != null) { return _files; }
DirectoryInfo dir = new DirectoryInfo(_path);
FileInfo[] files = dir.GetFiles();
_files = files.OrderBy(file => file.FullName).Select(file2 => file2.FullName).ToList();
return _files;
}
}
#endregion
#region Creator
public Bundler(string path)
{
_path = path;
}
#endregion
#region Public methods
public void WriteResponse(Stream outStream)
{
foreach (string fileName in Files)
{
string fileContent = File.ReadAllText(fileName);
byte[] byteArray = Encoding.UTF8.GetBytes(fileContent);
if (byteArray.Length > 0)
{
outStream.Write(byteArray, 0, byteArray.Length);
byteArray = Encoding.UTF8.GetBytes("\n\n");
outStream.Write(byteArray, 0, byteArray.Length);
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,284 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VAR.Focus.Web.Code.Entities;
namespace VAR.Focus.Web.Code.BusinessLogic
{
public class CardBoard
{
#region Declarations
private List<Card> _cards = new List<Card>();
private int _lastIDCard = 0;
private List<ICardEvent> _cardEvents = new List<ICardEvent>();
private int _lastIDCardEvent = 0;
private int _idBoard = 0;
#endregion
#region Life cycle
public CardBoard(int idBoard)
{
_idBoard = idBoard;
LoadData();
}
#endregion
#region Public methods
public List<Card> Cards_Status()
{
List<Card> activeCards=new List<Card>();
foreach (Card card in _cards)
{
if (card.Active)
{
activeCards.Add(card);
}
}
return activeCards;
}
public List<ICardEvent> Cards_GetEventList(int idCardEvent)
{
List<ICardEvent> listEvents = new List<ICardEvent>();
for (int i = 0, n = _cardEvents.Count; i < n; i++)
{
ICardEvent cardEvent = _cardEvents[i];
if (cardEvent.IDCardEvent > idCardEvent)
{
listEvents.Insert(0, cardEvent);
}
else { break; }
}
return listEvents;
}
public int GetLastIDCardEvent()
{
return _lastIDCardEvent;
}
public int GetLastIDCard()
{
return _lastIDCard;
}
public int Card_Create(string title, string body, int x, int y, string currentUserName)
{
DateTime currentDate = DateTime.UtcNow;
Card card;
lock (_cards)
{
// Create card
_lastIDCard++;
card = new Card()
{
IDCard = _lastIDCard,
Title = title,
Body = body,
X = x,
Y = y,
Active = true,
CreatedBy = currentUserName,
CreatedDate = currentDate,
ModifiedBy = currentUserName,
ModifiedDate = currentDate,
};
_cards.Add(card);
// Create event
_lastIDCardEvent++;
CardCreateEvent cardCreateEvent = new CardCreateEvent()
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Date = currentDate,
Title = card.Title,
Body = card.Body,
X = card.X,
Y = card.Y,
};
_cardEvents.Insert(0, cardCreateEvent);
SaveData();
}
return card.IDCard;
}
public bool Card_Move(int idCard, int x, int y, string currentUserName)
{
DateTime currentDate = DateTime.UtcNow;
lock (_cards)
{
// Move card
Card card = GetByID(idCard);
if (card == null) { return false; }
card.X = x;
card.Y = y;
card.ModifiedBy = currentUserName;
card.ModifiedDate = currentDate;
// Create event
_lastIDCardEvent++;
CardMoveEvent cardMoveEvent = new CardMoveEvent()
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Date = currentDate,
X = card.X,
Y = card.Y,
};
_cardEvents.Insert(0, cardMoveEvent);
SaveData();
}
return true;
}
public bool Card_Edit(int idCard, string title, string body, string currentUserName)
{
DateTime currentDate = DateTime.UtcNow;
lock (_cards)
{
// Edit card
Card card = GetByID(idCard);
if (card == null) { return false; }
card.Title = title;
card.Body = body;
card.ModifiedBy = currentUserName;
card.ModifiedDate = currentDate;
// Create event
_lastIDCardEvent++;
CardEditEvent cardEditEvent = new CardEditEvent()
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Date = currentDate,
Title = card.Title,
Body = card.Body,
};
_cardEvents.Insert(0, cardEditEvent);
SaveData();
}
return true;
}
public bool Card_Delete(int idCard, string currentUserName)
{
DateTime currentDate = DateTime.UtcNow;
lock (_cards)
{
// Delete card
Card card = GetByID(idCard);
if (card == null) { return false; }
card.Active = false;
card.ModifiedBy = currentUserName;
// Create event
_lastIDCardEvent++;
CardDeleteEvent cardDeleteEvent = new CardDeleteEvent()
{
IDCardEvent = _lastIDCardEvent,
IDCard = card.IDCard,
UserName = currentUserName,
Date = currentDate,
};
_cardEvents.Insert(0, cardDeleteEvent);
SaveData();
}
return true;
}
public static List<ICardEvent> ConvertCardsToEvents(List<Card> listCards, int lastIDCardEvent)
{
List<ICardEvent> listEvents = new List<ICardEvent>();
foreach (Card card in listCards)
{
var evt = new CardCreateEvent()
{
IDCardEvent = lastIDCardEvent,
IDCard = card.IDCard,
UserName = card.ModifiedBy,
Date = card.ModifiedDate,
Title = card.Title,
Body = card.Body,
X = card.X,
Y = card.Y,
};
listEvents.Add(evt);
}
return listEvents;
}
#endregion
#region Private methods
private Card GetByID(int idCard)
{
foreach (Card card in _cards)
{
if (card.IDCard == idCard)
{
return card;
}
}
return null;
}
#region Persistence
private const string CardsPersistenceFile = "priv/cardBoard.{0}.json";
private const string EventsPersistenceFile = "priv/cardEvents.{0}.json";
private void LoadData()
{
_cards = Persistence.LoadList<Card>(String.Format(CardsPersistenceFile, _idBoard));
_lastIDCard = 0;
foreach (Card card in _cards)
{
if (card.IDCard > _lastIDCard)
{
_lastIDCard = card.IDCard;
}
}
_cardEvents = Persistence.LoadList<ICardEvent>(String.Format(EventsPersistenceFile, _idBoard),
new List<Type> {
typeof(CardCreateEvent),
typeof(CardMoveEvent),
typeof(CardEditEvent),
typeof(CardDeleteEvent),
});
_lastIDCardEvent = 0;
if (_cardEvents.Count > 0)
{
_lastIDCardEvent = _cardEvents[0].IDCardEvent;
}
}
private void SaveData()
{
Persistence.SaveList(String.Format(CardsPersistenceFile, _idBoard), _cards);
Persistence.SaveList(String.Format(EventsPersistenceFile, _idBoard), _cardEvents);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using VAR.Focus.Web.Code.Entities;
namespace VAR.Focus.Web.Code.BusinessLogic
{
public class MessageBoard
{
#region Declarations
private List<Message> _messages = new List<Message>();
private int _lastIDMessage = 0;
private int _idBoard = 0;
#endregion
#region Life cycle
public MessageBoard(int idBoard)
{
_idBoard = idBoard;
LoadData();
}
#endregion
#region Public methods
public List<Message> Messages_GetList(int idMessage)
{
List<Message> listMessages = new List<Message>();
for (int i = 0, n = _messages.Count; i < n; i++)
{
Message msg = _messages[i];
if (msg.IDMessage > idMessage)
{
listMessages.Insert(0, msg);
}
else { break; }
}
return listMessages;
}
public void Message_Add(string userName, string text)
{
lock (_messages)
{
_lastIDMessage++;
Message msg = new Message();
msg.IDMessage = _lastIDMessage;
msg.UserName = userName;
msg.Text = text;
msg.Date = DateTime.UtcNow;
_messages.Insert(0, msg);
SaveData();
}
}
#endregion
#region Private methods
#region Persistence
private const string PersistenceFile = "priv/messageBoard.{0}.json";
private void LoadData()
{
_messages = Persistence.LoadList<Message>(String.Format(PersistenceFile, _idBoard));
_lastIDMessage = 0;
if (_messages.Count > 0)
{
_lastIDMessage = _messages[0].IDMessage;
}
}
private void SaveData()
{
Persistence.SaveList(String.Format(PersistenceFile, _idBoard), _messages);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Code.BusinessLogic
{
public class Persistence
{
#region Private methods
private static string GetLocalPath(string path)
{
string currentDir = Path.GetDirectoryName((new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
return string.Format("{0}/{1}", Directory.GetParent(currentDir), path);
}
#endregion
#region public methods
public static List<T> LoadList<T>(string file)
{
return LoadList<T>(file, null);
}
public static List<T> LoadList<T>(string file, List<Type> types)
{
List<T> listResult = new List<T>();
JSONParser parser = new JSONParser();
Type typeResult = typeof(T);
if (typeResult.IsInterface == false)
{
parser.KnownTypes.Add(typeof(T));
}
if (types != null)
{
foreach (Type type in types)
{
parser.KnownTypes.Add(type);
}
}
string filePath = GetLocalPath(file);
if (File.Exists(filePath) == false) { return listResult; }
string strJsonUsers = File.ReadAllText(filePath);
object result = parser.Parse(strJsonUsers);
if (result is IEnumerable<object>)
{
foreach (object item in (IEnumerable<object>)result)
{
if (item is T)
{
listResult.Add((T)item);
}
}
}
return listResult;
}
public static bool SaveList(string file, object data)
{
JSONWriter writter = new JSONWriter(true);
string strJsonUsers = writter.Write(data);
File.WriteAllText(GetLocalPath(file), strJsonUsers);
return true;
}
#endregion
}
}

View File

@@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using System.Web;
using VAR.Focus.Web.Code.Entities;
namespace VAR.Focus.Web.Code.BusinessLogic
{
public class Sessions
{
#region declarations
private static Sessions _currentInstance = null;
private List<Session> _sessions = new List<Session>();
private string _cookieName = "ScrummerSID";
private int _cookieExpirationDays = 30;
#endregion
#region Properties
public static Sessions Current
{
get
{
if (_currentInstance == null)
{
_currentInstance = new Sessions();
}
return _currentInstance;
}
set { _currentInstance = value; }
}
public string CookieName
{
get { return _cookieName; }
set { _cookieName = value; }
}
public int CookieExpirationDays
{
get { return _cookieExpirationDays; }
set { _cookieExpirationDays = value; }
}
#endregion
#region Life cycle
public Sessions()
{
LoadData();
}
#endregion
#region Public methods
public void Session_SetCookie(HttpContext context, Session session)
{
HttpCookie cookie = new HttpCookie(_cookieName, session.SessionToken);
cookie.Expires = DateTime.Now.AddDays(_cookieExpirationDays);
context.Response.Cookies.Add(cookie);
}
public bool Session_Init(HttpContext context, string userName)
{
lock (_sessions)
{
var session = new Session();
session.UserName = userName;
session.SessionToken = CryptoUtils.GetCryptoToken();
session.StartDate = DateTime.UtcNow;
_sessions.Add(session);
Session_SetCookie(context, session);
SaveData();
}
return true;
}
public Session Session_GetCurrent(HttpContext context)
{
HttpCookie cookie = context.Request.Cookies[_cookieName];
if (cookie == null) { return null; }
string sessionToken = cookie.Value;
if (string.IsNullOrEmpty(sessionToken)) { return null; }
Session session = Session_GetByToken(sessionToken);
return session;
}
public bool Session_FinalizeCurrent(HttpContext context)
{
lock (_sessions)
{
Session session = Session_GetCurrent(context);
if (session == null) { return false; }
if (_sessions.Remove(session) == false) { return false; }
HttpCookie cookie = new HttpCookie(_cookieName);
cookie.Expires = DateTime.Now.AddDays(-1d);
context.Response.Cookies.Add(cookie);
SaveData();
}
return true;
}
#endregion
#region Private methods
private Session Session_GetByToken(string sessionToken)
{
foreach (Session session in _sessions)
{
if (session.SessionToken == sessionToken)
{
return session;
}
}
return null;
}
#region Persistence
private const string PersistenceFile = "priv/sessions.json";
private void LoadData()
{
_sessions = Persistence.LoadList<Session>(PersistenceFile);
}
private void SaveData()
{
Persistence.SaveList(PersistenceFile, _sessions);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.IO;
using VAR.Focus.Web.Code.Entities;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Code.BusinessLogic
{
public class Users
{
#region declarations
private static Users _currentInstance = null;
private List<User> _users = new List<User>();
#endregion
#region Properties
public static Users Current
{
get
{
if (_currentInstance == null)
{
_currentInstance = new Users();
}
return _currentInstance;
}
set { _currentInstance = value; }
}
#endregion
#region Life cycle
public Users()
{
LoadData();
}
#endregion
#region Public methods
public User User_GetByName(string name)
{
name=name.ToLower();
foreach (User userAux in _users)
{
if (name.CompareTo(userAux.Name.ToLower()) == 0)
{
return userAux;
}
}
return null;
}
public User User_GetByEmail(string email)
{
email = email.ToLower();
foreach (User userAux in _users)
{
if (email.CompareTo(userAux.Email.ToLower()) == 0)
{
return userAux;
}
}
return null;
}
public User User_GetByNameOrEmail(string name, string email)
{
name = name.ToLower();
email = email.ToLower();
foreach (User userAux in _users)
{
if (name.CompareTo(userAux.Name.ToLower()) == 0 ||
email.CompareTo(userAux.Email.ToLower()) == 0)
{
return userAux;
}
}
return null;
}
public User User_Set(string name, string email, string password)
{
User user = null;
bool isNew = false;
lock (_users)
{
user = User_GetByName(name);
if (user == null) { user = User_GetByEmail(name); }
if (user == null) { user = new User(); isNew = true; }
user.Name = name;
user.Email = email;
if (string.IsNullOrEmpty(password) == false)
{
user.PasswordSalt = CryptoUtils.GetCryptoToken();
user.PasswordHash = CryptoUtils.GetHashedPassword(password, user.PasswordSalt);
}
if (isNew) { _users.Add(user); }
SaveData();
}
return user;
}
public bool User_Authenticate(string nameOrMail, string password)
{
User user = User_GetByNameOrEmail(nameOrMail, nameOrMail);
if (user == null) { return false; }
string passwordHash = CryptoUtils.GetHashedPassword(password, user.PasswordSalt);
if (passwordHash != user.PasswordHash) { return false; }
return true;
}
#endregion
#region Private methods
#region Persistence
private const string PersistenceFile = "priv/users.json";
private void LoadData()
{
_users = Persistence.LoadList<User>(PersistenceFile);
}
private void SaveData()
{
Persistence.SaveList(PersistenceFile, _users);
}
#endregion
#endregion
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Security.Cryptography;
using System.Text;
namespace VAR.Focus.Web.Code
{
public class CryptoUtils
{
public static string GetSHA1(string str)
{
SHA1 sha1 = SHA1Managed.Create();
UTF8Encoding encoding = new UTF8Encoding();
byte[] stream = null;
StringBuilder sb = new StringBuilder();
stream = sha1.ComputeHash(encoding.GetBytes(str));
for (int i = 0; i < stream.Length; i++) sb.AppendFormat("{0:x2}", stream[i]);
return sb.ToString();
}
public static string GetRandString(int len)
{
byte[] bytes = new byte[len];
var cryptoRandom = new RNGCryptoServiceProvider();
cryptoRandom.GetBytes(bytes);
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetString(bytes);
}
public static string GetCryptoToken()
{
return CryptoUtils.GetSHA1(CryptoUtils.GetRandString(10));
}
public static string GetHashedPassword(string password, string passwordSalt)
{
return CryptoUtils.GetSHA1(String.Format("{1}{0}{1}", password, passwordSalt));
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VAR.Focus.Web.Code.Entities
{
public class Card
{
public int IDCard { get; set; }
public string Title { get; set; }
public string Body { get; set; }
public int X { get; set; }
public int Y { get; set; }
public bool Active { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedDate { get; set; }
public string ModifiedBy { get; set; }
public DateTime ModifiedDate { get; set; }
}
}

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VAR.Focus.Web.Code.Entities
{
public interface ICardEvent
{
int IDCardEvent { get; set; }
string EventType { get; set; }
int IDCard { get; set; }
string UserName { get; set; }
DateTime Date { get; set; }
}
public class CardCreateEvent : ICardEvent
{
#region ICardEvent
public int IDCardEvent { get; set; }
private string _eventType="CardCreate";
public string EventType { get { return _eventType; } set { _eventType = value; } }
public int IDCard { get; set; }
public string UserName { get; set; }
public DateTime Date { get; set; }
#endregion
public string Title { get; set; }
public string Body { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
public class CardMoveEvent : ICardEvent
{
#region ICardEvent
public int IDCardEvent { get; set; }
private string _eventType = "CardMove";
public string EventType { get { return _eventType; } set { _eventType = value; } }
public int IDCard { get; set; }
public string UserName { get; set; }
public DateTime Date { get; set; }
#endregion
public int X { get; set; }
public int Y { get; set; }
}
public class CardEditEvent : ICardEvent
{
#region ICardEvent
public int IDCardEvent { get; set; }
private string _eventType = "CardEdit";
public string EventType { get { return _eventType; } set { _eventType = value; } }
public int IDCard { get; set; }
public string UserName { get; set; }
public DateTime Date { get; set; }
#endregion
public string Title { get; set; }
public string Body { get; set; }
}
public class CardDeleteEvent : ICardEvent
{
#region ICardEvent
public int IDCardEvent { get; set; }
private string _eventType = "CardDelete";
public string EventType { get { return _eventType; } set { _eventType = value; } }
public int IDCard { get; set; }
public string UserName { get; set; }
public DateTime Date { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,12 @@
using System;
namespace VAR.Focus.Web.Code.Entities
{
public class Message
{
public int IDMessage { get; set; }
public string UserName { get; set; }
public string Text { get; set; }
public DateTime Date { get; set; }
};
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VAR.Focus.Web.Code.Entities
{
public class OperationStatus
{
public bool IsOK { get; set; }
public string Message { get; set; }
public string ReturnValue { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
using System;
namespace VAR.Focus.Web.Code.Entities
{
public class Session
{
public string UserName { get; set; }
public string SessionToken { get; set; }
public DateTime StartDate { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace VAR.Focus.Web.Code.Entities
{
public class User
{
public string Name { get; set; }
public string Email { get; set; }
public string PasswordHash { get; set; }
public string PasswordSalt { get; set; }
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Text;
using System.Web;
using VAR.Focus.Web.Pages;
namespace VAR.Focus.Web.Code
{
public static class GlobalErrorHandler
{
#region Private methods
private static void ShowInternalError(HttpContext context, Exception ex)
{
context.Response.StatusCode = 500;
context.Response.Clear();
StringBuilder sbOutput = new StringBuilder();
sbOutput.Append("<h2>Internal error</h2>");
Exception exAux = ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
sbOutput.AppendFormat("<p><b>Message:</b> {0}</p>", exAux.Message);
sbOutput.AppendFormat("<p><b>StackTrace:</b></p> <pre><code>{0}</code></pre>", exAux.StackTrace);
exAux = exAux.InnerException;
}
// Fill response to 512 bytes to avoid browser "beauty" response of errors.
long fillResponse = 512 - sbOutput.Length;
if (fillResponse > 0)
{
sbOutput.Append("<!--");
for (int i = 0; i < fillResponse; i++)
{
sbOutput.Append("A");
}
sbOutput.Append("-->");
}
context.Response.Write(sbOutput.ToString());
}
#endregion
#region Public methods
public static void HandleError(HttpContext context, Exception ex)
{
try
{
IHttpHandler frmError = new FrmError(ex);
context.Response.Clear();
context.Handler = frmError;
frmError.ProcessRequest(context);
}
catch
{
ShowInternalError(context, ex);
}
}
#endregion
}
}

View File

@@ -0,0 +1,499 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace VAR.Focus.Web.Code.JSON
{
public class JSONParser
{
#region Declarations
private ParserContext ctx;
private bool tainted = false;
private List<Type> _knownTypes = new List<Type>();
#endregion
#region Properties
public bool Tainted
{
get { return tainted; }
}
public List<Type> KnownTypes
{
get { return _knownTypes; }
}
#endregion
#region Private methods
private static Dictionary<Type, PropertyInfo[]> _dictProperties = new Dictionary<Type, PropertyInfo[]>();
private PropertyInfo[] Type_GetProperties(Type type)
{
PropertyInfo[] typeProperties = null;
if (_dictProperties.ContainsKey(type)) { typeProperties = _dictProperties[type]; }
else
{
lock(_dictProperties){
if (_dictProperties.ContainsKey(type)) { typeProperties = _dictProperties[type]; }
else
{
typeProperties = type.GetProperties(BindingFlags.Public | BindingFlags.OptionalParamBinding | BindingFlags.Instance);
_dictProperties.Add(type, typeProperties);
}
}
}
return typeProperties;
}
private float CompareToType(Dictionary<string, object> obj, Type type)
{
PropertyInfo[] typeProperties = Type_GetProperties(type);
int count = 0;
foreach (PropertyInfo prop in typeProperties)
{
if (obj.ContainsKey(prop.Name))
{
count++;
}
}
return ((float)count / (float)typeProperties.Length);
}
private object ConvertToType(Dictionary<string, object> obj, Type type)
{
PropertyInfo[] typeProperties = Type_GetProperties(type);
object newObj = Activator.CreateInstance(type);
foreach (PropertyInfo prop in typeProperties)
{
if (obj.ContainsKey(prop.Name))
{
prop.SetValue(newObj, Convert.ChangeType(obj[prop.Name], prop.PropertyType), null);
}
}
return newObj;
}
private object TryConvertToTypes(Dictionary<string, object> obj)
{
Type bestMatch = null;
float bestMatchFactor = 0.0f;
foreach (Type type in _knownTypes)
{
float matchFactor = CompareToType(obj, type);
if (matchFactor > bestMatchFactor)
{
bestMatch = type;
bestMatchFactor = matchFactor;
}
}
if (bestMatch != null)
{
return ConvertToType(obj, bestMatch);
}
return obj;
}
private int ParseHexShort()
{
int value = 0;
for (int i = 0; i < 4; i++)
{
char c = ctx.Next();
if (Char.IsDigit(c))
{
value = (value << 4) | (c - '0');
}
else
{
c = Char.ToLower(c);
if (c >= 'a' && c <= 'f')
{
value = (value << 4) | ((c - 'a') + 10);
}
}
}
return value;
}
private String ParseQuotedString()
{
StringBuilder scratch = new StringBuilder();
char c = ctx.SkipWhite();
if (c == '"')
{
c = ctx.Next();
}
do
{
if (c == '\\')
{
c = ctx.Next();
if (c == '"')
{
scratch.Append('"');
}
else if (c == '\\')
{
scratch.Append('\\');
}
else if (c == '/')
{
scratch.Append('/');
}
else if (c == 'b')
{
scratch.Append('\b');
}
else if (c == 'f')
{
scratch.Append('\f');
}
else if (c == 'n')
{
scratch.Append('\n');
}
else if (c == 'r')
{
scratch.Append('\r');
}
else if (c == 't')
{
scratch.Append('\t');
}
else if (c == 'u')
{
scratch.Append((char)ParseHexShort());
}
c = ctx.Next();
}
else if (c == '"')
{
break;
}
else
{
scratch.Append(c);
c = ctx.Next();
}
} while (!ctx.AtEnd());
if (c == '"')
{
ctx.Next();
}
return scratch.ToString();
}
private String ParseString()
{
char c = ctx.SkipWhite();
if (c == '"')
{
return ParseQuotedString();
}
StringBuilder scratch = new StringBuilder();
while (!ctx.AtEnd()
&& (Char.IsLetter(c) || Char.IsDigit(c) || c == '_'))
{
scratch.Append(c);
c = ctx.Next();
}
return scratch.ToString();
}
private Object ParseNumber()
{
StringBuilder scratch = new StringBuilder();
bool isFloat = false;
int numberLenght = 0;
char c;
c = ctx.SkipWhite();
// Sign
if (c == '-')
{
scratch.Append('-');
c = ctx.Next();
}
// Integer part
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
// Decimal part
if (c == '.')
{
isFloat = true;
scratch.Append('.');
c = ctx.Next();
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
if (numberLenght == 0)
{
tainted = true;
return null;
}
// Exponential part
if (c == 'e' || c == 'E')
{
isFloat = true;
scratch.Append('E');
c = ctx.Next();
if (c == '+' || c == '-')
{
scratch.Append(c);
}
while (Char.IsDigit(c))
{
scratch.Append(c);
c = ctx.Next();
numberLenght++;
}
}
// Build number object from the parsed string
String s = scratch.ToString();
return isFloat ? (numberLenght < 17) ? (Object)Double.Parse(s)
: Decimal.Parse(s) : (numberLenght < 19) ? (Object)System.Int32.Parse(s)
: (Object)System.Int32.Parse(s);
}
private List<object> ParseArray()
{
char c = ctx.SkipWhite();
List<object> array = new List<object>();
if (c == '[')
{
ctx.Next();
}
do
{
c = ctx.SkipWhite();
if (c == ']')
{
ctx.Next();
break;
}
else if (c == ',')
{
ctx.Next();
}
else
{
array.Add(ParseValue());
}
} while (!ctx.AtEnd());
return array;
}
private Dictionary<string, object> ParseObject()
{
char c = ctx.SkipWhite();
Dictionary<string, object> obj = new Dictionary<string, object>();
if (c == '{')
{
ctx.Next();
c = ctx.SkipWhite();
}
String attributeName;
Object attributeValue;
do
{
attributeName = ParseString();
c = ctx.SkipWhite();
if (c == ':')
{
ctx.Next();
attributeValue = ParseValue();
if (attributeName.Length > 0)
{
obj.Add(attributeName, attributeValue);
}
}
else if (c == ',')
{
ctx.Next();
c = ctx.SkipWhite();
}
else if (c == '}')
{
ctx.Next();
break;
}
else
{
// Unexpected character
tainted = true;
break;
}
} while (!ctx.AtEnd());
if (obj.Count == 0)
{
return null;
}
return obj;
}
private Object ParseValue()
{
Object token = null;
char c = ctx.SkipWhite();
switch (c)
{
case '"':
token = ParseQuotedString();
break;
case '{':
Dictionary<string, object> obj = ParseObject();
token = TryConvertToTypes(obj);
break;
case '[':
token = ParseArray();
break;
default:
if (Char.IsDigit(c) || c == '-')
{
token = ParseNumber();
}
else
{
String aux = ParseString();
if (aux.CompareTo("true") == 0)
{
token = true;
}
else if (aux.CompareTo("false") == 0)
{
token = false;
}
else if (aux.CompareTo("null") == 0)
{
token = null;
}
else
{
// Unexpected string
if (aux.Length == 0)
{
ctx.Next();
}
tainted = true;
token = null;
}
}
break;
}
return token;
}
private String CleanIdentifier(String input)
{
int i;
char c;
i = input.Length - 1;
if (i < 0)
{
return input;
}
c = input[i];
while (Char.IsLetter(c) || Char.IsDigit(c) || c == '_')
{
i--;
if (i < 0)
{
break;
}
c = input[i];
}
return input.Substring(i + 1);
}
#endregion
#region Public methods
public Object Parse(String text)
{
// Get the first object
ctx = new ParserContext(text);
tainted = false;
ctx.Mark();
Object obj = ParseValue();
if (ctx.AtEnd())
{
return obj;
}
// "But wait, there is more!"
int idx = 0;
String name = "";
String strInvalidPrev = "";
Dictionary<string, object> superObject = new Dictionary<string, object>();
do
{
// Add the object to the superObject
if (!tainted && name.Length > 0 && obj != null)
{
if (name.Length == 0)
{
name = String.Format("{0:D2}", idx);
}
superObject.Add(name, obj);
idx++;
name = "";
}
else
{
String strInvalid = ctx.GetMarked();
strInvalid = strInvalid.Trim();
if (strInvalidPrev.Length > 0
&& "=".CompareTo(strInvalid) == 0)
{
name = CleanIdentifier(strInvalidPrev);
}
else
{
name = "";
}
strInvalidPrev = strInvalid;
}
// Check end
if (ctx.AtEnd())
{
break;
}
// Get next object
tainted = false;
ctx.Mark();
obj = ParseValue();
} while (true);
return superObject;
}
#endregion
}
}

View File

@@ -0,0 +1,335 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace VAR.Focus.Web.Code.JSON
{
public class JSONWriter
{
#region Declarations
private bool indent = false;
private bool useTabForIndent = false;
private int indentChars = 4;
private int indentThresold = 3;
#endregion
#region Creator
public JSONWriter() { }
public JSONWriter(int indentChars)
{
this.indent = true;
this.indentChars = indentChars;
this.useTabForIndent = false;
}
public JSONWriter(bool useTabForIndent)
{
this.indent = true;
this.useTabForIndent = useTabForIndent;
}
#endregion
#region Private methods
private bool IsValue(Object obj)
{
if (obj == null)
{
return true;
}
if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64)
|| (obj is String) || (obj is Boolean))
{
return true;
}
return false;
}
private void WriteIndent(StringBuilder sbOutput, int level)
{
if (!indent)
{
return;
}
sbOutput.Append('\n');
if (useTabForIndent)
{
for (int i = 0; i < level; i++) { sbOutput.Append('\t'); }
}
else
{
int n = level * indentChars;
for (int i = 0; i < n; i++) { sbOutput.Append(' '); }
}
}
private void WriteString(StringBuilder sbOutput, String str)
{
sbOutput.Append('"');
char c;
int n = str.Length;
for (int i = 0; i < n; i++)
{
c = str[i];
if (c == '"') { sbOutput.Append("\\\""); }
else if (c == '\\') { sbOutput.Append("\\\\"); }
else if (c == '/') { sbOutput.Append("\\/"); }
else if (c == '\b') { sbOutput.Append("\\b"); }
else if (c == '\f') { sbOutput.Append("\\f"); }
else if (c == '\n') { sbOutput.Append("\\n"); }
else if (c == '\r') { sbOutput.Append("\\r"); }
else if (c == '\t') { sbOutput.Append("\\t"); }
else { sbOutput.Append(c); }
// FIXME: Unicode characters
}
sbOutput.Append('"');
}
private void WriteValue(StringBuilder sbOutput, Object obj, int level, bool useReflection)
{
if (obj == null || obj is DBNull)
{
// NULL
sbOutput.Append("null");
}
else if ((obj is float) || (obj is double) ||
(obj is System.Int16) || (obj is System.Int32) || (obj is System.Int64))
{
// Numbers
sbOutput.Append(obj.ToString());
}
else if (obj is String)
{
// Strings
WriteString(sbOutput, (String)obj);
}
else if (obj is Boolean)
{
// Booleans
sbOutput.Append(((Boolean)obj) ? "true" : "false");
}
else if (obj is DateTime)
{
// DateTime
sbOutput.Append('"');
sbOutput.Append(((DateTime)obj).ToString("yyyy-MM-ddTHH:mm:ssZ"));
sbOutput.Append('"');
}
else if (obj is IDictionary)
{
// Objects
WriteObject(sbOutput, obj, level);
}
else if (obj is IEnumerable)
{
// Array/List
WriteList(sbOutput, obj, level);
}
else
{
if (useReflection)
{
// Reflected object
WriteReflectedObject(sbOutput, obj, level);
}
else
{
WriteString(sbOutput, Convert.ToString(obj));
}
}
}
private void WriteList(StringBuilder sbOutput, Object obj, int level)
{
IEnumerable list = (IEnumerable)obj;
int n = 0;
// Check if it is a leaf object
bool isLeaf = true;
foreach (object childObj in list)
{
if (!IsValue(childObj))
{
isLeaf = false;
}
n++;
}
// Empty
if (n == 0)
{
sbOutput.Append("[ ]");
return;
}
// Write array
bool first = true;
sbOutput.Append("[ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object childObj in list)
{
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteValue(sbOutput, childObj, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" ]");
}
private void WriteObject(StringBuilder sbOutput, Object obj, int level)
{
IDictionary map = (IDictionary)obj;
int n = map.Count;
// Empty
if (map.Count == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (object value in map.Values)
{
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (object key in map.Keys)
{
object value = map[key];
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, Convert.ToString(key));
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, true);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
private void WriteReflectedObject(StringBuilder sbOutput, Object obj, int level)
{
Type type = obj.GetType();
PropertyInfo[] rawProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
List<PropertyInfo> properties = new List<PropertyInfo>();
foreach (PropertyInfo property in rawProperties)
{
if (property.CanRead)
{
properties.Add(property);
}
}
int n = properties.Count;
// Empty
if (n == 0)
{
sbOutput.Append("{ }");
return;
}
// Check if it is a leaf object
bool isLeaf = true;
foreach (PropertyInfo property in properties)
{
object value = property.GetValue(obj, null);
if (!IsValue(value))
{
isLeaf = false;
break;
}
}
// Write object
bool first = true;
sbOutput.Append("{ ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
foreach (PropertyInfo property in properties)
{
object value = null;
MethodInfo getMethod = property.GetGetMethod();
ParameterInfo[] parameters = getMethod.GetParameters();
if (parameters.Length == 0)
{
value = property.GetValue(obj, null);
}
if (!first)
{
sbOutput.Append(", ");
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level + 1);
}
}
first = false;
WriteString(sbOutput, property.Name);
sbOutput.Append(": ");
WriteValue(sbOutput, value, level + 1, false);
}
if (!isLeaf || n > indentThresold)
{
WriteIndent(sbOutput, level);
}
sbOutput.Append(" }");
}
#endregion
#region Public methods
public String Write(Object obj)
{
StringBuilder sbOutput = new StringBuilder();
WriteValue(sbOutput, obj, 0, true);
return sbOutput.ToString();
}
#endregion
}
}

View File

@@ -0,0 +1,84 @@
using System;
namespace VAR.Focus.Web.Code.JSON
{
public class ParserContext
{
#region Declarations
private String text;
private int length;
private int i;
private int markStart;
#endregion
#region Creator
public ParserContext(String text)
{
this.text = text;
this.length = text.Length;
this.i = 0;
this.markStart = 0;
}
#endregion
#region Public methods
public char SkipWhite()
{
while (i < length && Char.IsWhiteSpace(text[i]))
{
i++;
}
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public char Next()
{
i++;
if (AtEnd())
{
return (char)0;
}
return text[i];
}
public bool AtEnd()
{
return i >= length;
}
public void Mark()
{
markStart = this.i;
}
public String GetMarked()
{
if (i < length && markStart < length)
{
return text.Substring(markStart, i);
}
else
{
if (markStart < length)
{
return text.Substring(markStart, length);
}
else
{
return string.Empty;
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,20 @@
using System.Web;
namespace VAR.Focus.Web.Code
{
public class ScriptsBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Scripts/"));
context.Response.ContentType = "text/javascript";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}

View File

@@ -0,0 +1,20 @@
using System.Web;
namespace VAR.Focus.Web.Code
{
public class StylesBundler : IHttpHandler
{
#region IHttpHandler
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext context)
{
Bundler bundler = new Bundler(context.Server.MapPath("~/Styles/"));
context.Response.ContentType = "text/css";
bundler.WriteResponse(context.Response.OutputStream);
}
#endregion
}
}

View File

@@ -0,0 +1,12 @@
using System.Web.UI.WebControls;
namespace VAR.Focus.Web.Controls
{
public class CButton : Button
{
public CButton()
{
CssClass = "button";
}
}
}

View File

@@ -0,0 +1,41 @@
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VAR.Focus.Web.Controls
{
public class CLabel : Label
{
#region Declarations
private string _tagName = "span";
#endregion
#region Properties
public string Tag
{
get { return _tagName; }
set { _tagName = value; }
}
#endregion
#region Life cycle
public override void RenderBeginTag(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(_tagName) == false)
{
this.AddAttributesToRender(writer);
writer.RenderBeginTag(_tagName);
}
else
{
base.RenderBeginTag(writer);
}
}
#endregion
}
}

View File

@@ -0,0 +1,99 @@
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VAR.Focus.Web.Controls
{
public class CTextBox : TextBox, IValidableControl
{
#region Declarations
private const string CssClassBase = "textbox";
private string _cssClassExtra = "";
private bool _allowEmpty = true;
private string _placeHolder = string.Empty;
private bool _markedInvalid = false;
#endregion
#region Properties
public string CssClassExtra
{
get { return _cssClassExtra; }
set { _cssClassExtra = value; }
}
public bool AllowEmpty
{
get { return _allowEmpty; }
set { _allowEmpty = value; }
}
public string PlaceHolder
{
get { return _placeHolder; }
set { _placeHolder = value; }
}
public bool MarkedInvalid
{
get { return _markedInvalid; }
set { _markedInvalid = value; }
}
#endregion
#region Control life cycle
public CTextBox()
{
PreRender += CTextbox_PreRender;
}
void CTextbox_PreRender(object sender, EventArgs e)
{
CssClass = CssClassBase;
if (string.IsNullOrEmpty(_cssClassExtra) == false)
{
CssClass = String.Format("{0} {1}", CssClassBase, _cssClassExtra);
}
if (Page.IsPostBack && (_allowEmpty == false && IsEmpty()) || _markedInvalid)
{
CssClass += " textboxInvalid";
}
Attributes.Add("onchange", "ElementRemoveClass(this, 'textboxInvalid');");
if (string.IsNullOrEmpty(_placeHolder) == false)
{
Attributes.Add("placeholder", _placeHolder);
}
// FIX: The framework deletes textbox values on password mode
if (TextMode == TextBoxMode.Password)
{
Attributes["value"] = Text;
}
}
#endregion
#region Public methods
public bool IsEmpty()
{
return string.IsNullOrEmpty(Text);
}
public bool IsValid()
{
return _allowEmpty || (string.IsNullOrEmpty(Text) == false);
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VAR.Focus.Web.Controls
{
public class CardBoardControl : Control, INamingContainer
{
#region Declarations
private string _serviceUrl = "CardBoardHandler";
private int _idBoard = 0;
private string _userName = string.Empty;
private int _timePoolData = 10000;
private int _timeRefresh = 20;
private int _timeRefreshDisconnected = 5000;
#endregion
#region Properties
public string ServiceUrl
{
get { return _serviceUrl; }
set { _serviceUrl = value; }
}
public int IDBoard
{
get { return _idBoard; }
set { _idBoard = value; }
}
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
public int TimePoolData
{
get { return _timePoolData; }
set { _timePoolData = value; }
}
public int TimeRefresh
{
get { return _timeRefresh; }
set { _timeRefresh = value; }
}
public int TimeRefreshDisconnected
{
get { return _timeRefreshDisconnected; }
set { _timeRefreshDisconnected = value; }
}
#endregion
#region Control Life cycle
public CardBoardControl()
{
Init += ChatControl_Init;
}
void ChatControl_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
string strCfgName = string.Format("{0}_cfg", this.ClientID);
Panel divBoard = new Panel { ID = "divBoard", CssClass = "divBoard" };
Controls.Add(divBoard);
StringBuilder sbCfg = new StringBuilder();
sbCfg.AppendFormat("<script>\n");
sbCfg.AppendFormat("var {0} = {{\n", strCfgName);
sbCfg.AppendFormat(" divBoard: \"{0}\",\n", divBoard.ClientID);
sbCfg.AppendFormat(" IDBoard: {0},\n", _idBoard);
sbCfg.AppendFormat(" UserName: \"{0}\",\n", _userName);
sbCfg.AppendFormat(" IDCardEvent: \"\",\n");
sbCfg.AppendFormat(" ServiceUrl: \"{0}\",\n", _serviceUrl);
sbCfg.AppendFormat(" TimePoolData: {0},\n", _timePoolData);
sbCfg.AppendFormat(" TimeRefresh: {0},\n", _timeRefresh);
sbCfg.AppendFormat(" TimeRefreshDisconnected: {0},\n", _timeRefreshDisconnected);
sbCfg.AppendFormat(" Texts: {{\n");
sbCfg.AppendFormat(" Toolbox: \"Toolbox\",\n");
sbCfg.AppendFormat(" AddCard: \"+ Add card\",\n");
sbCfg.AppendFormat(" Accept: \"Accept\",\n");
sbCfg.AppendFormat(" Cancel: \"Cancel\",\n");
sbCfg.AppendFormat(" ConfirmDelete: \"Are you sure to delete?\",\n");
sbCfg.AppendFormat(" StringEmpty: \"\"\n");
sbCfg.AppendFormat(" }}\n");
sbCfg.AppendFormat("}};\n");
sbCfg.AppendFormat("RunCardBoard({0});\n", strCfgName);
sbCfg.AppendFormat("</script>\n");
LiteralControl liScript = new LiteralControl(sbCfg.ToString());
Controls.Add(liScript);
}
#endregion
}
}

View File

@@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Web;
using VAR.Focus.Web.Code.BusinessLogic;
using VAR.Focus.Web.Code.Entities;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Controls
{
public class CardBoardHandler : IHttpHandler
{
#region Declarations
private static object _monitor = new object();
private static Dictionary<int, CardBoard> _cardBoards = new Dictionary<int, CardBoard>();
#endregion
#region IHttpHandler
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
public void ProcessRequest(HttpContext context)
{
try
{
if (context.Request.RequestType == "GET")
{
if (string.IsNullOrEmpty(GetRequestParm(context, "IDCardEvent")))
{
ProcessInitializationReciver(context);
}
else
{
ProcessEventReciver(context);
}
}
if (context.Request.RequestType == "POST")
{
ProcessEventSender(context);
}
}
catch (Exception ex)
{
ResponseObject(context, new OperationStatus { IsOK = false, Message = ex.Message, });
}
}
#endregion
#region Private methods
private void ProcessInitializationReciver(HttpContext context)
{
int idBoard = Convert.ToInt32(GetRequestParm(context, "IDBoard"));
CardBoard cardBoard;
if (_cardBoards.ContainsKey(idBoard) == false)
{
lock (_cardBoards)
{
if (_cardBoards.ContainsKey(idBoard) == false)
{
cardBoard = new CardBoard(idBoard);
_cardBoards[idBoard] = cardBoard;
}
}
}
if (_cardBoards.ContainsKey(idBoard))
{
cardBoard = _cardBoards[idBoard];
List<Card> listCards = cardBoard.Cards_Status();
List<ICardEvent> listEvents = new List<ICardEvent>();
int lastIDCardEvent = cardBoard.GetLastIDCardEvent();
int lastIDCard = cardBoard.GetLastIDCard();
if (listCards.Count > 0)
{
listEvents = CardBoard.ConvertCardsToEvents(listCards, lastIDCardEvent);
}
else
{
listEvents = new List<ICardEvent>();
}
ResponseObject(context, listEvents);
}
}
private CardBoard GetCardBoard(int idBoard)
{
CardBoard cardBoard = null;
if (_cardBoards.ContainsKey(idBoard) == false)
{
lock (_cardBoards)
{
if (_cardBoards.ContainsKey(idBoard) == false)
{
cardBoard = new CardBoard(idBoard);
_cardBoards[idBoard] = cardBoard;
}
}
}
cardBoard = _cardBoards[idBoard];
return cardBoard;
}
private void ProcessEventReciver(HttpContext context)
{
int idBoard = Convert.ToInt32(GetRequestParm(context, "IDBoard"));
int idCardEvent = Convert.ToInt32(GetRequestParm(context, "IDCardEvent"));
string strTimePoolData = GetRequestParm(context, "TimePoolData");
int timePoolData = Convert.ToInt32(string.IsNullOrEmpty(strTimePoolData) ? "0" : strTimePoolData);
CardBoard cardBoard = GetCardBoard(idBoard);
bool mustWait = (timePoolData > 0);
do
{
List<ICardEvent> listMessages = cardBoard.Cards_GetEventList(idCardEvent);
if (listMessages.Count > 0)
{
mustWait = false;
ResponseObject(context, listMessages);
return;
}
if (mustWait)
{
lock (_monitor) { Monitor.Wait(_monitor, timePoolData); }
}
} while (mustWait);
ResponseObject(context, new List<Message>());
}
private void ProcessEventSender(HttpContext context)
{
Session session = Sessions.Current.Session_GetCurrent(context);
string currentUserName = session.UserName;
string strIDBoard = GetRequestParm(context, "IDBoard");
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
string command = GetRequestParm(context, "Command");
int idCard = 0;
bool done = false;
CardBoard cardBoard = GetCardBoard(idBoard);
lock (cardBoard)
{
if (command == "Create")
{
string title = GetRequestParm(context, "Title");
string body = GetRequestParm(context, "Body");
int x = Convert.ToInt32(GetRequestParm(context, "X"));
int y = Convert.ToInt32(GetRequestParm(context, "Y"));
idCard = cardBoard.Card_Create(title, body, x, y, currentUserName);
done = true;
}
if (command == "Move")
{
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
int x = Convert.ToInt32(GetRequestParm(context, "X"));
int y = Convert.ToInt32(GetRequestParm(context, "Y"));
cardBoard.Card_Move(idCard, x, y, currentUserName);
done = true;
}
if (command == "Edit")
{
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
string title = GetRequestParm(context, "Title");
string body = GetRequestParm(context, "Body");
cardBoard.Card_Edit(idCard, title, body, currentUserName);
done = true;
}
if (command == "Delete")
{
idCard = Convert.ToInt32(GetRequestParm(context, "IDCard"));
cardBoard.Card_Delete(idCard, currentUserName);
done = true;
}
}
if (done)
{
NotifyAll();
ResponseObject(context, new OperationStatus
{
IsOK = true,
Message = "Update successfully",
ReturnValue = Convert.ToString(idCard)
});
}
}
private void NotifyAll()
{
lock (_monitor) { Monitor.PulseAll(_monitor); }
}
private string GetRequestParm(HttpContext context, string parm)
{
foreach (string key in context.Request.Params.AllKeys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Params[key];
}
}
return string.Empty;
}
private void ResponseObject(HttpContext context, object obj)
{
var jsonWritter = new JSONWriter(true);
context.Response.ContentType = "text/json";
string strObject = jsonWritter.Write(obj);
context.Response.Write(strObject);
}
#endregion
}
}

View File

@@ -0,0 +1,164 @@
using System;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VAR.Focus.Web.Controls
{
public class ChatControl : Control, INamingContainer
{
#region Declarations
private string _serviceUrl = "ChatHandler";
private int _idBoard = 0;
private string _userName = string.Empty;
private int _timePoolData = 10000;
private Unit _width = new Unit(500, UnitType.Pixel);
private Unit _height = new Unit(300, UnitType.Pixel);
private Panel _divChatWindow = null;
private Panel _divChatContainer = null;
private Panel _divChatTitleBar = null;
#endregion
#region Properties
public string ServiceUrl
{
get { return _serviceUrl; }
set { _serviceUrl = value; }
}
public int IDBoard
{
get { return _idBoard; }
set { _idBoard = value; }
}
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
public int TimePoolData
{
get { return _timePoolData; }
set { _timePoolData = value; }
}
public Unit Width
{
get { return _width; }
set
{
_width = value;
if (_divChatContainer != null)
{
_divChatContainer.Width = value;
}
}
}
public Unit Height
{
get { return _height; }
set
{
_height = value;
if (_divChatContainer != null)
{
_divChatContainer.Height = value;
}
}
}
#endregion
#region Control Life cycle
public ChatControl()
{
Init += ChatControl_Init;
}
void ChatControl_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
string strCfgName = string.Format("{0}_cfg", this.ClientID);
_divChatWindow = new Panel { ID = "divChatWindow", CssClass = "divChatWindow" };
Controls.Add(_divChatWindow);
_divChatTitleBar = new Panel { ID = "divChatTitleBar", CssClass = "divChatTitleBar" };
_divChatWindow.Controls.Add(_divChatTitleBar);
CLabel lblTitle = new CLabel();
lblTitle.ID = "lblTitle";
_divChatTitleBar.Controls.Add(lblTitle);
_divChatContainer = new Panel { ID = "divChatContainer", CssClass = "divChatContainer" };
_divChatWindow.Controls.Add(_divChatContainer);
_divChatContainer.Width = _width;
_divChatContainer.Height = _height;
var divChat = new Panel { ID = "divChat", CssClass = "divChat" };
_divChatContainer.Controls.Add(divChat);
var divChatControls = new Panel { ID = "divChatControls", CssClass = "divChatControls" };
_divChatContainer.Controls.Add(divChatControls);
var txtText = new TextBox { ID = "txtText", CssClass = "chatTextBox" };
txtText.Attributes.Add("autocomplete", "off");
txtText.Attributes.Add("onkeydown", String.Format("if(event.keyCode==13){{SendChat({0}); return false;}}", strCfgName));
divChatControls.Controls.Add(txtText);
var btnSend = new Button { ID = "btnSend", Text = "Send", CssClass = "chatButton" };
divChatControls.Controls.Add(btnSend);
btnSend.Attributes.Add("onclick", String.Format("SendChat({0}); return false;", strCfgName));
StringBuilder sbCfg = new StringBuilder();
sbCfg.AppendFormat("<script>\n");
sbCfg.AppendFormat("var {0} = {{\n", strCfgName);
sbCfg.AppendFormat(" divChatWindow: \"{0}\",\n", _divChatWindow.ClientID);
sbCfg.AppendFormat(" divChatTitleBar: \"{0}\",\n", _divChatTitleBar.ClientID);
sbCfg.AppendFormat(" lblTitle: \"{0}\",\n", lblTitle.ClientID);
sbCfg.AppendFormat(" divChatContainer: \"{0}\",\n", _divChatContainer.ClientID);
sbCfg.AppendFormat(" divChat: \"{0}\",\n", divChat.ClientID);
sbCfg.AppendFormat(" txtText: \"{0}\",\n", txtText.ClientID);
sbCfg.AppendFormat(" btnSend: \"{0}\",\n", btnSend.ClientID);
sbCfg.AppendFormat(" IDBoard: {0},\n", _idBoard);
sbCfg.AppendFormat(" UserName: \"{0}\",\n", _userName);
sbCfg.AppendFormat(" IDMessage: {0},\n", 0);
sbCfg.AppendFormat(" ServiceUrl: \"{0}\",\n", _serviceUrl);
sbCfg.AppendFormat(" TimePoolData: {0},\n", _timePoolData);
sbCfg.AppendFormat(" Texts: {{\n", _serviceUrl);
sbCfg.AppendFormat(" Chat: \"{0}\",\n", "Chat");
sbCfg.AppendFormat(" Close: \"{0}\",\n", "Close X");
sbCfg.AppendFormat(" NewMessages: \"{0}\",\n", "New messages");
sbCfg.AppendFormat(" Disconnected: \"{0}\",\n", "Disconnected");
sbCfg.AppendFormat(" StringEmpty: \"\"\n");
sbCfg.AppendFormat(" }}\n");
sbCfg.AppendFormat("}};\n");
sbCfg.AppendFormat("RunChat({0});\n", strCfgName);
sbCfg.AppendFormat("</script>\n");
LiteralControl liScript = new LiteralControl(sbCfg.ToString());
Controls.Add(liScript);
}
#endregion
}
}

View File

@@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Web;
using VAR.Focus.Web.Code.BusinessLogic;
using VAR.Focus.Web.Code.Entities;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Controls
{
public class ChatHandler : IHttpHandler
{
#region Declarations
private static object _monitor = new object();
private static Dictionary<int, MessageBoard> _chatBoards = new Dictionary<int, MessageBoard>();
#endregion
#region IHttpHandler
public bool IsReusable
{
get { throw new NotImplementedException(); }
}
public void ProcessRequest(HttpContext context)
{
if (context.Request.RequestType == "GET")
{
ProcessReciver(context);
}
if (context.Request.RequestType == "POST")
{
ProcessSender(context);
}
}
#endregion
#region Private methods
private void ProcessReciver(HttpContext context)
{
int idBoard = Convert.ToInt32(GetRequestParm(context, "IDBoard"));
int idMessage = Convert.ToInt32(GetRequestParm(context, "IDMessage"));
string strTimePoolData = GetRequestParm(context, "TimePoolData");
int timePoolData = Convert.ToInt32(string.IsNullOrEmpty(strTimePoolData) ? "0" : strTimePoolData);
MessageBoard messageBoard;
bool mustWait = (timePoolData > 0);
do
{
if (_chatBoards.ContainsKey(idBoard) == false)
{
lock (_chatBoards)
{
if (_chatBoards.ContainsKey(idBoard) == false)
{
messageBoard = new MessageBoard(idBoard);
_chatBoards[idBoard] = messageBoard;
}
}
}
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
List<Message> listMessages = messageBoard.Messages_GetList(idMessage);
if (listMessages.Count > 0)
{
mustWait = false;
ResponseObject(context, listMessages);
return;
}
}
if (mustWait)
{
lock (_monitor) { Monitor.Wait(_monitor, timePoolData); }
}
} while (mustWait);
ResponseObject(context, new List<Message>());
}
private void ProcessSender(HttpContext context)
{
string text = Convert.ToString(GetRequestParm(context, "Text"));
string strIDBoard = GetRequestParm(context, "IDBoard");
int idBoard = Convert.ToInt32(string.IsNullOrEmpty(strIDBoard) ? "0" : strIDBoard);
string userName = Convert.ToString(GetRequestParm(context, "UserName"));
Session session = Sessions.Current.Session_GetCurrent(context);
if (session.UserName.ToLower() != userName.ToLower())
{
ResponseObject(context, new OperationStatus { IsOK = false, Message = "User mismatch" });
return;
}
lock (_chatBoards)
{
MessageBoard messageBoard;
if (_chatBoards.ContainsKey(idBoard))
{
messageBoard = _chatBoards[idBoard];
}
else
{
messageBoard = new MessageBoard(idBoard);
_chatBoards[idBoard] = messageBoard;
}
messageBoard.Message_Add(userName, text);
lock (_monitor) { Monitor.PulseAll(_monitor); }
}
ResponseObject(context, new OperationStatus { IsOK = true, Message = "Message sent" });
}
private string GetRequestParm(HttpContext context, string parm)
{
foreach (string key in context.Request.Params.AllKeys)
{
if (string.IsNullOrEmpty(key) == false && key.EndsWith(parm))
{
return context.Request.Params[key];
}
}
return string.Empty;
}
private void ResponseObject(HttpContext context, object obj)
{
var jsonWritter = new JSONWriter(true);
context.Response.ContentType = "text/json";
string strObject = jsonWritter.Write(obj);
context.Response.Write(strObject);
}
#endregion
}
}

View File

@@ -0,0 +1,8 @@
namespace VAR.Focus.Web.Controls
{
public interface IValidableControl
{
bool IsValid();
}
}

View File

@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Web;
using VAR.Focus.Web.Code;
namespace VAR.Focus.Web
{
public class GlobalRouter : IHttpHandler
{
#region Handlers
private static Dictionary<string, Type> _handlers = new Dictionary<string, Type>();
private static IHttpHandler GetHandler(string typeName)
{
if (string.IsNullOrEmpty(typeName)) { return null; }
Type type = null;
if (_handlers.ContainsKey(typeName))
{
type = _handlers[typeName];
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
return handler;
}
// Search type on executing assembly
Type[] types;
Assembly asm = Assembly.GetExecutingAssembly();
types = asm.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
// Search type on all loaded assemblies
if (type == null)
{
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly asmAux in asms)
{
types = asmAux.GetTypes();
foreach (Type typeAux in types)
{
if (typeAux.FullName.EndsWith(typeName))
{
type = typeAux;
break;
}
}
if (type != null) { break; }
}
}
// Use found type
if (type != null)
{
IHttpHandler handler = Activator.CreateInstance(type) as IHttpHandler;
if (handler != null)
{
lock (_handlers)
{
if (_handlers.ContainsKey(typeName) == false)
{
_handlers.Add(typeName, type);
}
}
}
return handler;
}
return null;
}
#endregion
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
try
{
RouteRequest(context);
}
catch (Exception ex)
{
GlobalErrorHandler.HandleError(context, ex);
}
}
#endregion
#region Private methods
private void RouteRequest(HttpContext context)
{
string file = Path.GetFileName(context.Request.FilePath);
if (string.IsNullOrEmpty(file))
{
file = Globals.DefaultHandler;
}
IHttpHandler handler = GetHandler(file);
if (handler == null)
{
// TODO: FrmNotFound
throw new Exception("NotFound");
}
// Use handler
context.Response.Clear();
context.Handler = handler;
handler.ProcessRequest(context);
}
#endregion
}
}

12
VAR.Focus.Web/Globals.cs Normal file
View File

@@ -0,0 +1,12 @@
namespace VAR.Focus.Web
{
public static class Globals
{
public const string Title = "Focus";
public const string TitleSeparator = " :: ";
public const string Author = "Valeriano Alfonso Rodriguez";
public const string Copyright = "Copyright (c) 2015 by Valeriano Alfonso, All Right Reserved";
public const string DefaultHandler = "FrmBoard";
}
}

View File

@@ -0,0 +1,67 @@
using System.Web.UI;
using System.Web.UI.WebControls;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class FormUtils
{
public static Control CreateField(string label, Control fieldControl)
{
Panel pnlRow = new Panel();
pnlRow.CssClass = "formRow";
Panel pnlLabelContainer = new Panel();
pnlLabelContainer.CssClass = "formLabel width25pc";
pnlRow.Controls.Add(pnlLabelContainer);
if (string.IsNullOrEmpty(label) == false)
{
CLabel lblField = new CLabel();
lblField.Text = label;
pnlLabelContainer.Controls.Add(lblField);
}
Panel pnlFieldContainer = new Panel();
pnlFieldContainer.CssClass = "formField width75pc";
pnlRow.Controls.Add(pnlFieldContainer);
pnlFieldContainer.Controls.Add(fieldControl);
return pnlRow;
}
public static bool Control_IsValid(Control control)
{
if (control is IValidableControl)
{
if (((IValidableControl)control).IsValid() == false)
{
return false;
}
}
return true;
}
public static bool Controls_AreValid(ControlCollection controls) {
bool valid = true;
foreach (Control control in controls)
{
if (Control_IsValid(control))
{
if (Controls_AreValid(control.Controls) == false)
{
valid = false;
break;
}
}
else
{
valid = false;
break;
}
}
return valid;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class FrmBoard : PageCommon
{
private int _idBoard = 0;
public FrmBoard()
{
Init += FrmBoard_Init;
}
void FrmBoard_Init(object sender, EventArgs e)
{
Title = "Board";
CardBoardControl cardBoardControl = new CardBoardControl();
cardBoardControl.ID = "ctrCardBoard";
cardBoardControl.IDBoard = _idBoard;
cardBoardControl.UserName = CurrentUser.Name;
Controls.Add(cardBoardControl);
ChatControl chatControl = new ChatControl();
chatControl.ID = "ctrChat";
chatControl.IDBoard = _idBoard;
chatControl.UserName = CurrentUser.Name;
Controls.Add(chatControl);
}
}
}

View File

@@ -0,0 +1,25 @@
using System.Web;
using VAR.Focus.Web.Code.JSON;
namespace VAR.Focus.Web.Pages
{
public class FrmEcho : IHttpHandler
{
#region IHttpHandler
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
var jsonWritter = new JSONWriter(true);
context.Response.Write("<pre><code>");
context.Response.Write(jsonWritter.Write(context.Request));
context.Response.Write("</code></pre>");
}
#endregion
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class FrmError : PageCommon
{
#region Declarations
Exception _ex = null;
#endregion
#region Page life cycle
public FrmError(Exception ex)
{
_ex = ex;
Init += FrmError_Init;
}
void FrmError_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region Private methods
private void InitializeControls()
{
Title = "Application Error";
CLabel lblErrorTitle = new CLabel { Text = Title, Tag = "h2" };
Controls.Add(lblErrorTitle);
Exception exAux = _ex;
if (exAux is HttpUnhandledException && exAux.InnerException != null) { exAux = exAux.InnerException; }
while (exAux != null)
{
CLabel lblMessage = new CLabel { Tag = "P" };
lblMessage.Text = String.Format("<b>{0}:</b> {1}", "Message", HttpUtility.HtmlEncode(exAux.Message));
Controls.Add(lblMessage);
CLabel lblStacktraceTitle = new CLabel { Tag = "p" };
lblStacktraceTitle.Text = String.Format("<b>{0}:</b>", "Stacktrace");
Controls.Add(lblStacktraceTitle);
Panel pnlStacktrace = new Panel();
pnlStacktrace.CssClass = "divCode";
Controls.Add(pnlStacktrace);
LiteralControl litStackTrace = new LiteralControl(
String.Format("<pre><code>{0}</code></pre>", HttpUtility.HtmlEncode(exAux.StackTrace)));
pnlStacktrace.Controls.Add(litStackTrace);
exAux = exAux.InnerException;
}
}
#endregion
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Web.UI.WebControls;
using VAR.Focus.Web.Code.BusinessLogic;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class FrmLogin : PageCommon
{
#region Declarations
private CTextBox _txtNameEmail = new CTextBox { ID = "txtNameEmail", CssClassExtra = "width150px", AllowEmpty = false };
private CTextBox _txtPassword = new CTextBox { ID = "txtPassword", CssClassExtra = "width150px", AllowEmpty = false, TextMode = TextBoxMode.Password };
private CButton _btnLogin = new CButton { ID = "btnLogin"};
#endregion
#region Page life cycle
public FrmLogin()
{
MustBeAutenticated = false;
Init += FrmLogin_Init;
}
private void FrmLogin_Init(object sender, EventArgs e)
{
InitializeControls();
}
#endregion
#region UI Events
private void btnLogin_Click(object sender, EventArgs e)
{
if (FormUtils.Controls_AreValid(Controls) == false) { return; }
if (Users.Current.User_Authenticate(_txtNameEmail.Text, _txtPassword.Text) == false)
{
_txtPassword.Text = string.Empty;
return;
}
Sessions.Current.Session_Init(Context, _txtNameEmail.Text);
Response.Redirect(".");
}
#endregion
#region Private methods
private void InitializeControls()
{
Title = "Login";
var lblTitle = new CLabel { Text = "Login", Tag = "h2" };
Controls.Add(lblTitle);
Controls.Add(FormUtils.CreateField("Name/Mail", _txtNameEmail));
_txtNameEmail.PlaceHolder = "Name/Mail";
Controls.Add(FormUtils.CreateField("Password", _txtPassword));
_txtPassword.PlaceHolder = "Password";
Controls.Add(FormUtils.CreateField(String.Empty, _btnLogin));
_btnLogin.Text = "Login";
_btnLogin.Click += btnLogin_Click;
Controls.Add(FormUtils.CreateField(String.Empty, new HyperLink { Text = "Register user", NavigateUrl = "FrmRegister" }));
_txtNameEmail.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword.ClientID));
_txtPassword.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _btnLogin.ClientID));
}
#endregion
}
}

View File

@@ -0,0 +1,130 @@
using System;
using System.Web.UI.WebControls;
using VAR.Focus.Web.Code.BusinessLogic;
using VAR.Focus.Web.Code.Entities;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class FrmRegister : PageCommon
{
#region Declarations
private Panel _pnlRegister = new Panel { ID = "pnlRegister" };
private CTextBox _txtName = new CTextBox { ID = "txtName", CssClassExtra = "width150px", AllowEmpty = false };
private CTextBox _txtEmail = new CTextBox { ID = "txtEmail", CssClassExtra = "width150px", AllowEmpty = false };
private CTextBox _txtPassword1 = new CTextBox { ID = "txtPassword1", CssClass = "width150px", AllowEmpty = false, TextMode = TextBoxMode.Password };
private CTextBox _txtPassword2 = new CTextBox { ID = "txtPassword2", CssClass = "width150px", AllowEmpty = false, TextMode = TextBoxMode.Password };
private CButton _btnRegister = new CButton { ID = "btnRegister" };
private CButton _btnExit = new CButton { ID = "btnExit" };
private Panel _pnlSuccess = new Panel { ID = "pnlSuccess" };
private CLabel _lblSuccess = new CLabel { ID = "lblSuccess" };
private CButton _btnExitSuccess = new CButton { ID = "btnExitSuccess" };
#endregion
#region Page life cycle
public FrmRegister()
{
MustBeAutenticated = false;
Init += FrmRegister_Init;
}
void FrmRegister_Init(object sender, EventArgs e)
{
InitializeComponents();
}
#endregion
#region UI Events
void btnRegister_Click(object sender, EventArgs e)
{
if (FormUtils.Controls_AreValid(Controls) == false) { return; }
// FIXME: Check Email
// Check password
if (_txtPassword1.Text != _txtPassword2.Text)
{
_txtPassword1.MarkedInvalid = true;
_txtPassword2.MarkedInvalid = true;
_txtPassword1.Text = String.Empty;
_txtPassword2.Text = String.Empty;
return;
}
User user = Users.Current.User_Set(_txtName.Text, _txtEmail.Text, _txtPassword1.Text);
_pnlRegister.Visible = false;
_pnlSuccess.Visible = true;
_lblSuccess.Text = String.Format("User {0} created sucessfully", user.Name);
}
void btnExit_Click(object sender, EventArgs e)
{
Response.Redirect(".");
}
#endregion
#region Private methods
private void InitializeComponents()
{
Title = "Register";
var lblTitle = new CLabel { Text = "Register", Tag = "h2" };
Controls.Add(lblTitle);
Controls.Add(_pnlRegister);
_pnlRegister.Controls.Add(FormUtils.CreateField("Name", _txtName));
_txtName.PlaceHolder = "Name";
_pnlRegister.Controls.Add(FormUtils.CreateField("Email", _txtEmail));
_txtEmail.PlaceHolder = "Email";
_pnlRegister.Controls.Add(FormUtils.CreateField("Password", _txtPassword1));
_txtPassword1.PlaceHolder = "Password";
_pnlRegister.Controls.Add(FormUtils.CreateField(String.Empty, _txtPassword2));
_txtPassword2.PlaceHolder = "Password";
_btnRegister.Text = "Register";
_btnRegister.Click += btnRegister_Click;
_btnExit.Text = "Exit";
_btnExit.Click += btnExit_Click;
Panel pnlButtons=new Panel();
pnlButtons.Controls.Add(_btnRegister);
pnlButtons.Controls.Add(_btnExit);
_pnlRegister.Controls.Add(FormUtils.CreateField(String.Empty, pnlButtons));
_txtName.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtEmail.ClientID));
_txtEmail.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword1.ClientID));
_txtPassword1.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword2.ClientID));
_txtPassword2.Attributes.Add("onkeydown", String.Format(
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _btnRegister.ClientID));
Controls.Add(_pnlSuccess);
_pnlSuccess.Visible = false;
_pnlSuccess.Controls.Add(_lblSuccess);
_btnExitSuccess.Text = "Exit";
_btnExitSuccess.Click += btnExit_Click;
_pnlSuccess.Controls.Add(FormUtils.CreateField(String.Empty, _btnExitSuccess));
}
#endregion
}
}

View File

@@ -0,0 +1,161 @@
using System;
using System.Reflection;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using VAR.Focus.Web.Code.BusinessLogic;
using VAR.Focus.Web.Code.Entities;
using VAR.Focus.Web.Controls;
namespace VAR.Focus.Web.Pages
{
public class PageCommon : Page
{
#region Declarations
private HtmlHead _head;
private HtmlGenericControl _body;
private HtmlForm _form;
private Panel _pnlContainer = new Panel();
private CButton _btnPostback = new CButton();
private CButton _btnLogout = new CButton();
private bool _mustBeAutenticated = true;
private User _currentUser = null;
#endregion
#region Properties
public new ControlCollection Controls
{
get { return _pnlContainer.Controls; }
}
public bool MustBeAutenticated
{
get { return _mustBeAutenticated; }
set { _mustBeAutenticated = value; }
}
public User CurrentUser
{
get { return _currentUser; }
}
#endregion
#region Life cycle
public PageCommon()
{
PreInit += PageCommon_PreInit;
Init += PageCommon_Init;
PreRender += PageCommon_PreRender;
}
void PageCommon_PreInit(object sender, EventArgs e)
{
Session session = Sessions.Current.Session_GetCurrent(Context);
if (session != null)
{
_currentUser = Users.Current.User_GetByName(session.UserName);
if (_mustBeAutenticated)
{
Sessions.Current.Session_SetCookie(Context, session);
}
}
if (_currentUser == null && _mustBeAutenticated)
{
Response.Redirect("FrmLogin");
}
}
void PageCommon_Init(object sender, EventArgs e)
{
CreateControls();
}
void PageCommon_PreRender(object sender, EventArgs e)
{
_head.Title = string.IsNullOrEmpty(Title) ? Globals.Title : String.Format("{0}{1}{2}", Globals.Title, Globals.TitleSeparator, Title);
_btnLogout.Visible = (_currentUser != null);
}
#endregion
#region UI Events
void btnLogout_Click(object sender, EventArgs e)
{
Sessions.Current.Session_FinalizeCurrent(Context);
_currentUser = null;
if (_mustBeAutenticated)
{
Response.Redirect("FrmLogin");
}
}
#endregion
#region Private methods
private void CreateControls()
{
Context.Response.Charset = Encoding.UTF8.WebName;
var doctype = new LiteralControl("<!DOCTYPE html>\n");
base.Controls.Add(doctype);
var html = new HtmlGenericControl("html");
base.Controls.Add(html);
_head = new HtmlHead();
html.Controls.Add(_head);
_head.Controls.Add(new HtmlMeta { HttpEquiv = "content-type", Content = "text/html; charset=utf-8" });
_head.Controls.Add(new HtmlMeta { Name = "author", Content = Globals.Author });
_head.Controls.Add(new HtmlMeta { Name = "Copyright", Content = Globals.Copyright });
Assembly asm = Assembly.GetExecutingAssembly();
string version = asm.GetName().Version.ToString();
_head.Controls.Add(new LiteralControl(String.Format("<script type=\"text/javascript\" src=\"ScriptsBundler?t={0}\"></script>\n", version)));
_head.Controls.Add(new LiteralControl(String.Format("<link href=\"StylesBundler?t={0}\" type=\"text/css\" rel=\"stylesheet\"/>\n", version)));
_body = new HtmlGenericControl("body");
html.Controls.Add(_body);
_form = new HtmlForm { ID = "formMain" };
_body.Controls.Add(_form);
var pnlHeader = new Panel { CssClass = "divHeader" };
_form.Controls.Add(pnlHeader);
HyperLink lnkTitle = new HyperLink();
lnkTitle.NavigateUrl = ".";
pnlHeader.Controls.Add(lnkTitle);
var lblTitle = new CLabel { Text = Globals.Title, Tag = "h1" };
lnkTitle.Controls.Add(lblTitle);
_btnPostback.ID = "btnPostback";
_btnPostback.Text = "Postback";
pnlHeader.Controls.Add(_btnPostback);
_btnPostback.Style.Add("display", "none");
var pnlUserInfo = new Panel { CssClass = "divUserInfo" };
pnlHeader.Controls.Add(pnlUserInfo);
_btnLogout.ID = "btnLogout";
_btnLogout.Text = "Logout";
_btnLogout.Click += btnLogout_Click;
_btnLogout.Attributes.Add("onclick", String.Format("return confirm('{0}');", "¿Are you sure to exit?"));
pnlUserInfo.Controls.Add(_btnLogout);
_pnlContainer.CssClass = "divContent";
_form.Controls.Add(_pnlContainer);
}
#endregion
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VAR.Focus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("VAR")]
[assembly: AssemblyProduct("VAR.Focus")]
[assembly: AssemblyCopyright("Copyright © VAR 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4cd25e9d-237f-4a9f-89ac-35e537cf265e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>C:\Users\VAR\source\VAR.Focus\Published</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,70 @@
////////////////////////
// GetElement
//
function GetElement(element) {
if (typeof element == "string") {
element = document.getElementById(element);
}
return element;
}
////////////////////////
// ElementAddClass
//
function ElementAddClass(element, classname) {
element = GetElement(element);
if (!element) { return; }
var cn = element.className;
if (cn.indexOf(classname) != -1) {
return;
}
if (cn != '') {
classname = ' ' + classname;
}
element.className = cn + classname;
}
////////////////////////
// ElementRemoveClass
//
function ElementRemoveClass(element, className) {
element = GetElement(element);
if (!element) { return; }
var regex = new RegExp('(?:^|\\s)' + className + '(?!\\S)');
if (regex.test(element.className)) {
element.className = element.className.replace(regex, '');
}
}
////////////////////////
// ElementToggleClass
//
function ElementToggleClass(element, className) {
element = GetElement(element);
if (!element) { return; }
var regex = new RegExp('(?:^|\\s)' + className + '(?!\\S)');
if (regex.test(element.className)) {
element.className = element.className.replace(regex, '');
return true;
} else {
element.className = element.className + ' ' + className;
return false;
}
}
function escapeHTML(s) {
return s.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}

View File

@@ -0,0 +1,125 @@
function SendRequest(url, data, onData, onError) {
var xhr = new XMLHttpRequest();
if (data) {
url += "?" + GetDataQueryString(data);
}
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.send(null);
}
function GetDataQueryString(data) {
var queryString = "";
for (var property in data) {
if (data.hasOwnProperty(property)) {
var value = data[property];
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(property) + "="
+ fixedEncodeURIComponent(String(value));
}
}
return queryString;
}
function SendData(url, data, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetDataQueryString(data));
}
function GetFormQueryString(idForm) {
var form = document.getElementById(idForm);
var queryString = "";
if (!form)
return null;
function appendVal(name, value) {
queryString += (queryString.length > 0 ? "&" : "")
+ fixedEncodeURIComponent(name) + "="
+ fixedEncodeURIComponent(value ? value : "");
}
var elements = form.elements;
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var elemType = element.type.toUpperCase();
var elemName = element.name;
if (elemName) {
if (
elemType.indexOf("TEXT") != -1 ||
elemType.indexOf("TEXTAREA") != -1 ||
elemType.indexOf("PASSWORD") != -1 ||
elemType.indexOf("BUTTON") != -1 ||
elemType.indexOf("HIDDEN") != -1 ||
elemType.indexOf("SUBMIT") != -1 ||
elemType.indexOf("IMAGE") != -1
) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("CHECKBOX") != -1 && element.checked) {
appendVal(elemName, element.value ? element.value : "On");
} else if (elemType.indexOf("RADIO") != -1 && element.checked) {
appendVal(elemName, element.value);
} else if (elemType.indexOf("SELECT") != -1) {
for (var j = 0; j < element.options.length; j++) {
var option = element.options[j];
if (option.selected) {
appendVal(elemName,
option.value ? option.value : option.text);
}
}
}
}
}
return queryString;
}
function SendForm(url, idForm, onData, onError) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (onData) {
onData(xhr.responseText);
}
} else {
if (onError) {
onError();
}
}
}
}
xhr.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
xhr.send(GetFormQueryString(idForm));
}

View File

@@ -0,0 +1,618 @@
var Toolbox = function (cfg, container) {
this.cfg = cfg;
this.X = 0;
this.Y = 0;
this.container = container;
// Create DOM
this.divToolbox = document.createElement("div");
this.divToolbox.className = "divToolbox";
this.divToolbox.style.left = this.X + "px";
this.divToolbox.style.top = this.Y + "px";
this.divTitle = document.createElement("div");
this.divToolbox.appendChild(this.divTitle);
this.divTitle.className = "divTitle";
this.divTitle.innerHTML = cfg.Texts.Toolbox;
this.btnAdd = document.createElement("button");
this.divToolbox.appendChild(this.btnAdd);
this.btnAdd.className = "btnToolbox";
this.btnAdd.innerHTML = cfg.Texts.AddCard;
this.btnAdd.addEventListener("click", Toolbox.prototype.btnAdd_Click.bind(this), false);
this.divOverlay = document.createElement("div");
this.divToolbox.appendChild(this.divOverlay);
this.divOverlay.className = "divOverlay";
this.container.appendChild(this.divToolbox);
// Bind mouse event handlers
this.bindedMouseDown = Toolbox.prototype.MouseDown.bind(this);
this.bindedMouseMove = Toolbox.prototype.MouseMove.bind(this);
this.bindedMouseUp = Toolbox.prototype.MouseUp.bind(this);
this.divOverlay.addEventListener("mousedown", this.bindedMouseDown, false);
// Bind touch event handlers
this.bindedTouchStart = Toolbox.prototype.TouchStart.bind(this);
this.bindedTouchMove = Toolbox.prototype.TouchMove.bind(this);
this.bindedTouchEnd = Toolbox.prototype.TouchEnd.bind(this);
this.divOverlay.addEventListener("touchstart", this.bindedTouchStart, false);
// temporal variables for dragging, editing and deleting
this.offsetX = 0;
this.offsetY = 0;
};
Toolbox.prototype = {
GetRelativePosToContainer: function (pos) {
var tempElem = this.container;
var relPos = { x: pos.x, y: pos.y };
while (tempElem) {
relPos.x -= tempElem.offsetLeft;
relPos.y -= tempElem.offsetTop;
tempElem = tempElem.offsetParent;
}
return relPos;
},
MouseDown: function (evt) {
evt.preventDefault();
var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY });
this.offsetX = pos.x - this.divToolbox.offsetLeft;
this.offsetY = pos.y - this.divToolbox.offsetTop;
document.addEventListener("mouseup", this.bindedMouseUp, false);
document.addEventListener("mousemove", this.bindedMouseMove, false);
return false;
},
MouseMove: function (evt) {
evt.preventDefault();
var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY });
this.divToolbox.style.left = parseInt(pos.x - this.offsetX) + "px";
this.divToolbox.style.top = parseInt(pos.y - this.offsetY) + "px";
return false;
},
MouseUp: function (evt) {
evt.preventDefault();
document.removeEventListener("mouseup", this.bindedMouseUp, false);
document.removeEventListener("mousemove", this.bindedMouseMove, false);
return false;
},
TouchStart: function (evt) {
evt.preventDefault();
var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
this.offsetX = pos.x - this.divToolbox.offsetLeft;
this.offsetY = pos.y - this.divToolbox.offsetTop;
document.addEventListener("touchend", this.bindedTouchEnd, false);
document.addEventListener("touchcancel", this.bindedTouchEnd, false);
document.addEventListener("touchmove", this.bindedTouchMove, false);
return false;
},
TouchMove: function (evt) {
evt.preventDefault();
var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
this.divToolbox.style.left = parseInt(pos.x - this.offsetX) + "px";
this.divToolbox.style.top = parseInt(pos.y - this.offsetY) + "px";
return false;
},
TouchEnd: function (evt) {
evt.preventDefault();
document.removeEventListener("touchend", this.bindedTouchEnd, false);
document.removeEventListener("touchcancel", this.bindedTouchEnd, false);
document.removeEventListener("touchmove", this.bindedTouchMove, false);
return false;
},
btnAdd_Click: function (evt) {
evt.preventDefault();
var pos = this.GetRelativePosToContainer({ x: 0, y: 0 });
pos.x += this.divToolbox.offsetLeft;
pos.y += this.divToolbox.offsetTop + this.divToolbox.offsetHeight;
var card = new Card(this.cfg, 0, "", "", pos.x, pos.y);
card.InsertInContainer(this.cfg.divBoard);
card.EnterEditionMode();
return false;
}
};
var Card = function (cfg, idCard, title, body, x, y) {
this.cfg = cfg;
this.IDCard = idCard;
this.Title = title;
this.Body = body;
this.X = x;
this.Y = y;
// Create DOM
this.container = null;
this.divCard = document.createElement("div");
this.divCard.className = "divCard";
this.divCard.style.left = x + "px";
this.divCard.style.top = y + "px";
this.divTitle = document.createElement("div");
this.divCard.appendChild(this.divTitle);
this.divTitle.className = "divTitle";
this.divTitle.innerHTML = this.FilterText(title);
this.divBody = document.createElement("div");
this.divCard.appendChild(this.divBody);
this.divBody.className = "divBody";
this.divBody.innerHTML = this.FilterText(body);
this.divOverlay = document.createElement("div");
this.divCard.appendChild(this.divOverlay);
this.divOverlay.className = "divOverlay";
this.btnEdit = document.createElement("button");
this.divCard.appendChild(this.btnEdit);
this.btnEdit.className = "btnCard btnEdit";
this.btnEdit.innerHTML = "E";
this.btnEdit.addEventListener("click", Card.prototype.btnEdit_Click.bind(this), false);
this.btnDelete = document.createElement("button");
this.divCard.appendChild(this.btnDelete);
this.btnDelete.className = "btnCard btnDelete";
this.btnDelete.innerHTML = "X";
this.btnDelete.addEventListener("click", Card.prototype.btnDelete_Click.bind(this), false);
this.txtTitle = document.createElement("input");
this.txtTitle.className = "txtTitle";
this.txtBody = document.createElement("textarea");
this.txtBody.className = "txtBody";
this.btnAcceptEdit = document.createElement("button");
this.btnAcceptEdit.className = "btnCard";
this.btnAcceptEdit.innerHTML = this.cfg.Texts.Accept;
this.btnAcceptEdit.addEventListener("click", Card.prototype.btnAcceptEdit_Click.bind(this), false);
this.btnCancelEdit = document.createElement("button");
this.btnCancelEdit.className = "btnCard";
this.btnCancelEdit.innerHTML = this.cfg.Texts.Cancel;
this.btnCancelEdit.addEventListener("click", Card.prototype.btnCancelEdit_Click.bind(this), false);
// Bind mouse event handlers
this.bindedMouseDown = Card.prototype.MouseDown.bind(this);
this.bindedMouseMove = Card.prototype.MouseMove.bind(this);
this.bindedMouseUp = Card.prototype.MouseUp.bind(this);
this.divOverlay.addEventListener("mousedown", this.bindedMouseDown, false);
// Bind touch event handlers
this.bindedTouchStart = Card.prototype.TouchStart.bind(this);
this.bindedTouchMove = Card.prototype.TouchMove.bind(this);
this.bindedTouchEnd = Card.prototype.TouchEnd.bind(this);
this.divOverlay.addEventListener("touchstart", this.bindedTouchStart, false);
// Temporal variables for dragging, editing and deleting
this.offsetX = 0;
this.offsetY = 0;
this.newX = this.X;
this.newY = this.Y;
this.newTitle = this.Title;
this.newBody = this.Body;
this.Editing = false;
// Selfinsert
this.cfg.Cards.push(this);
this.InsertInContainer(this.cfg.divBoard);
};
Card.prototype = {
FilterText: function (text) {
text = text.split(" ").join(" &nbsp;");
text = text.split("&nbsp; &nbsp;").join("&nbsp;&nbsp;&nbsp;");
text = text.split("\n").join("<br />");
return text;
},
InsertInContainer: function (container) {
this.container = container;
this.container.appendChild(this.divCard);
},
RemoveFromContainer: function(){
this.container.removeChild(this.divCard);
},
Move: function (x, y) {
this.X = x;
this.Y = y;
this.newX = x;
this.newY = y;
this.divCard.style.left = this.X + "px";
this.divCard.style.top = this.Y + "px";
},
Edit: function (title, body) {
if (this.Editing) {
this.ExitEditionMode();
}
this.Title = title;
this.Body = body;
this.newTitle = title;
this.newBody = body;
this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.FilterText(this.Body);
},
Reset: function () {
this.newX = this.X;
this.newY = this.Y;
this.newTitle = this.Title;
this.newBody = this.Body;
this.divCard.style.left = this.X + "px";
this.divCard.style.top = this.Y + "px";
this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.FilterText(this.Body);
},
SetNew: function () {
this.X = this.newX;
this.Y = this.newY;
this.Title = this.newTitle;
this.Body = this.newBody;
this.divCard.style.left = this.X + "px";
this.divCard.style.top = this.Y + "px";
this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.FilterText(this.Body);
},
Hide: function () {
this.divCard.style.display = "none";
},
Show: function () {
this.divCard.style.display = "";
},
OnMove: function () {
if (this.X != this.newX || this.Y != this.newY) {
var card = this;
if (this.cfg.Connected == false) {
card.Reset();
return;
}
var data = {
"IDBoard": this.cfg.IDBoard,
"Command": "Move",
"IDCard": this.IDCard,
"X": this.newX,
"Y": this.newY,
"TimeStamp": new Date().getTime()
};
SendData(this.cfg.ServiceUrl, data,
function (responseText) {
try {
var recvData = JSON.parse(responseText);
if (recvData && recvData instanceof Object && recvData.IsOK == true) {
card.SetNew();
} else {
card.Reset();
}
} catch (e) { }
}, function () {
card.Reset();
});
}
},
OnEdit: function () {
if (this.Title != this.newTitle || this.Body != this.newBody) {
var card = this;
if (this.cfg.Connected == false) {
card.Reset();
return;
}
var data = {
"IDBoard": this.cfg.IDBoard,
"Command": "Edit",
"IDCard": this.IDCard,
"Title": this.newTitle,
"Body": this.newBody,
"TimeStamp": new Date().getTime()
};
SendData(this.cfg.ServiceUrl, data,
function (responseText) {
try {
var recvData = JSON.parse(responseText);
if (recvData && recvData instanceof Object && recvData.IsOK == true) {
card.SetNew();
} else {
card.Reset();
}
} catch (e) { }
}, function () {
card.Reset();
});
}
},
OnDelete: function () {
var card = this;
this.Hide();
if (this.cfg.Connected == false) {
this.Show();
return;
}
if (this.IDCard == 0) {
this.RemoveFromContainer();
this.cfg.RemoveCardByID(card.IDCard);
return;
}
var data = {
"IDBoard": this.cfg.IDBoard,
"Command": "Delete",
"IDCard": this.IDCard,
"TimeStamp": new Date().getTime()
};
SendData(this.cfg.ServiceUrl, data,
function (responseText) {
try {
var recvData = JSON.parse(responseText);
if (recvData && recvData instanceof Object && recvData.IsOK == true) {
card.RemoveFromContainer();
card.cfg.RemoveCardByID(card.IDCard);
} else {
card.Show();
}
} catch (e) { }
}, function () {
card.Show();
});
},
OnCreate: function () {
var card = this;
if (this.cfg.Connected == false) {
card.OnDelete();
return;
}
var data = {
"IDBoard": this.cfg.IDBoard,
"Command": "Create",
"X": this.X,
"Y": this.Y,
"Title": this.Title,
"Body": this.Body,
"TimeStamp": new Date().getTime()
};
SendData(this.cfg.ServiceUrl, data,
function (responseText) {
try {
var recvData = JSON.parse(responseText);
if (recvData && recvData instanceof Object && recvData.IsOK == true) {
//card.IDCard = parseInt(recvData.ReturnValue);
card.OnDelete();
} else {
card.OnDelete();
}
} catch (e) { }
}, function () {
card.OnDelete();
});
},
GetRelativePosToContainer: function (pos) {
var tempElem = this.container;
var relPos = { x: pos.x, y: pos.y };
while (tempElem) {
relPos.x -= tempElem.offsetLeft;
relPos.y -= tempElem.offsetTop;
tempElem = tempElem.offsetParent;
}
return relPos;
},
MouseDown: function (evt) {
var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY });
this.offsetX = pos.x - this.divCard.offsetLeft;
this.offsetY = pos.y - this.divCard.offsetTop;
document.addEventListener("mouseup", this.bindedMouseUp, false);
document.addEventListener("mousemove", this.bindedMouseMove, false);
evt.preventDefault();
return false;
},
MouseMove: function (evt) {
var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY });
this.newX = parseInt(pos.x - this.offsetX);
this.newY = parseInt(pos.y - this.offsetY);
this.divCard.style.left = this.newX + "px";
this.divCard.style.top = this.newY + "px";
evt.preventDefault();
return false;
},
MouseUp: function (evt) {
document.removeEventListener("mouseup", this.bindedMouseUp, false);
document.removeEventListener("mousemove", this.bindedMouseMove, false);
this.OnMove();
evt.preventDefault();
return false;
},
TouchStart: function (evt) {
var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
this.offsetX = pos.x - this.divCard.offsetLeft;
this.offsetY = pos.y - this.divCard.offsetTop;
document.addEventListener("touchend", this.bindedTouchEnd, false);
document.addEventListener("touchcancel", this.bindedTouchEnd, false);
document.addEventListener("touchmove", this.bindedTouchMove, false);
evt.preventDefault();
return false;
},
TouchMove: function (evt) {
var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
this.newX = parseInt(pos.x - this.offsetX);
this.newY = parseInt(pos.y - this.offsetY);
this.divCard.style.left = this.newX + "px";
this.divCard.style.top = this.newY + "px";
evt.preventDefault();
return false;
},
TouchEnd: function (evt) {
document.removeEventListener("touchend", this.bindedTouchEnd, false);
document.removeEventListener("touchcancel", this.bindedTouchEnd, false);
document.removeEventListener("touchmove", this.bindedTouchMove, false);
this.OnMove();
evt.preventDefault();
return false;
},
EnterEditionMode: function(){
this.divTitle.innerHTML = "";
this.txtTitle.value = this.Title;
this.divTitle.appendChild(this.txtTitle);
this.divBody.innerHTML = "";
this.txtBody.value = this.Body;
this.divBody.appendChild(this.txtBody);
this.divBody.appendChild(document.createElement("br"));
this.divBody.appendChild(this.btnAcceptEdit);
this.divBody.appendChild(this.btnCancelEdit);
this.divOverlay.style.display = "none";
this.Editing = true;
},
ExitEditionMode: function(){
this.divTitle.removeChild(this.txtTitle);
this.divBody.removeChild(this.txtBody);
this.divBody.removeChild(this.btnAcceptEdit);
this.divBody.removeChild(this.btnCancelEdit);
this.divOverlay.style.display = "";
this.Editing = false;
},
btnEdit_Click: function (evt) {
evt.preventDefault();
if (this.Editing == false) {
this.EnterEditionMode();
} else {
this.ExitEditionMode();
this.Reset();
}
return false;
},
btnAcceptEdit_Click: function (evt) {
evt.preventDefault();
this.newTitle = this.txtTitle.value;
this.newBody = this.txtBody.value;
this.ExitEditionMode();
this.divTitle.innerHTML = this.FilterText(this.newTitle);
this.divBody.innerHTML = this.FilterText(this.newBody);
if (this.IDCard > 0) {
this.OnEdit();
} else {
this.Title = this.newTitle;
this.Body = this.newBody;
this.OnCreate();
}
return false;
},
btnCancelEdit_Click: function (evt) {
evt.preventDefault();
this.ExitEditionMode();
this.Reset();
if (this.IDCard == 0) {
this.OnDelete();
}
return false;
},
btnDelete_Click: function (evt) {
evt.preventDefault();
if (this.IDCard==0 || confirm(this.cfg.Texts.ConfirmDelete)) {
this.OnDelete();
}
return false;
}
};
function RunCardBoard(cfg) {
cfg.divBoard = GetElement(cfg.divBoard);
cfg.Toolbox = new Toolbox(cfg, cfg.divBoard);
cfg.Connected = false;
cfg.Cards = [];
cfg.GetCardByID = function (idCard) {
for (var i = 0, n = this.Cards.length; i < n; i++) {
var card = this.Cards[i];
if (card.IDCard == idCard) {
return card;
}
}
return null;
};
cfg.RemoveCardByID = function (idCard) {
for (var i = 0, n = this.Cards.length; i < n; i++) {
var card = this.Cards[i];
if (card.IDCard == idCard) {
this.Cards.splice(i, 1);
}
}
return false;
}
var ProcessCardCreateEvent = function(cardEvent){
var card = new Card(cfg, cardEvent.IDCard, cardEvent.Title, cardEvent.Body, cardEvent.X, cardEvent.Y);
};
var ProcessCardMoveEvent = function (cardEvent) {
var card = cfg.GetCardByID(cardEvent.IDCard);
if (card == null) { return; }
card.Move(cardEvent.X, cardEvent.Y);
};
var ProcessCardEditEvent = function (cardEvent) {
var card = cfg.GetCardByID(cardEvent.IDCard);
if (card == null) { return; }
card.Edit(cardEvent.Title, cardEvent.Body);
};
var ProcessCardDeleteEvent = function (cardEvent) {
var card = cfg.GetCardByID(cardEvent.IDCard);
if (card == null) { return; }
card.RemoveFromContainer(cfg.divBoard);
};
var RequestCardEventData = function () {
var ReciveCardEventData = function (responseText) {
cfg.Connected = true;
var recvData = JSON.parse(responseText);
if (recvData && recvData instanceof Array) {
for (var i = 0, n = recvData.length; i < n; i++) {
var cardEvent = recvData[i];
if (cardEvent.IDCardEvent > cfg.IDCardEvent) {
cfg.IDCardEvent = cardEvent.IDCardEvent;
}
if (cardEvent.EventType == "CardCreate") {
ProcessCardCreateEvent(cardEvent);
}
if (cardEvent.EventType == "CardMove") {
ProcessCardMoveEvent(cardEvent);
}
if (cardEvent.EventType == "CardEdit") {
ProcessCardEditEvent(cardEvent);
}
if (cardEvent.EventType == "CardDelete") {
ProcessCardDeleteEvent(cardEvent);
}
}
}
// Reset pool
window.setTimeout(function () {
RequestCardEventData();
}, cfg.TimeRefresh);
};
var ErrorCardEventData = function () {
cfg.Connected = false;
// Retry
window.setTimeout(function () {
RequestCardEventData();
}, cfg.TimeRefreshDisconnected);
};
// Pool data
var data = {
"IDBoard": cfg.IDBoard,
"IDCardEvent": cfg.IDCardEvent,
"TimePoolData": ((cfg.Connected == false) ? "0" : String(cfg.TimePoolData)),
"TimeStamp": new Date().getTime()
};
SendRequest(cfg.ServiceUrl, data, ReciveCardEventData, ErrorCardEventData);
};
RequestCardEventData();
}

View File

@@ -0,0 +1,177 @@
function RunChat(cfg) {
cfg.divChat = GetElement(cfg.divChat);
cfg.divChatContainer = GetElement(cfg.divChatContainer);
cfg.lblTitle = GetElement(cfg.lblTitle);
cfg.txtText = GetElement(cfg.txtText);
cfg.btnSend = GetElement(cfg.btnSend);
cfg.LastUser = null;
cfg.lblTitle.innerHTML = cfg.Texts.Chat;
cfg.lblTitle.className = "titleChatNormal";
cfg.divChatContainer.style.display = "none";
cfg.Minimized = true;
cfg.Connected = null;
cfg.FirstMessages = true;
cfg.ScrollOnRestore = true;
cfg.ScrollPosition = 0;
cfg.lblTitle.onclick = function () {
if (cfg.Minimized) {
cfg.divChatContainer.style.display = "";
if (cfg.Connected) {
cfg.lblTitle.innerHTML = cfg.Texts.Close;
cfg.lblTitle.className = "titleChatNormal";
}
if (cfg.ScrollOnRestore) {
cfg.divChat.scrollTop = cfg.divChat.scrollHeight;
} else {
cfg.divChat.scrollTop = cfg.ScrollPosition;
}
cfg.Minimized = false;
} else {
cfg.ScrollPosition = cfg.divChat.scrollTop;
cfg.ScrollOnRestore = (cfg.divChat.scrollTop > (cfg.divChat.scrollHeight - cfg.divChat.offsetHeight));
cfg.divChatContainer.style.display = "none";
if (cfg.Connected) {
cfg.lblTitle.innerHTML = cfg.Texts.Chat;
cfg.lblTitle.className = "titleChatNormal";
}
cfg.Minimized = true;
}
};
var CreateMessageDOM = function (message, selfMessage, showUserName) {
var divMessageRow = document.createElement("DIV");
if (selfMessage) {
divMessageRow.className = "selfMessageRow";
} else {
divMessageRow.className = "messageRow";
}
var divMessage = document.createElement("DIV");
divMessage.className = "message";
divMessageRow.appendChild(divMessage);
if (showUserName) {
var divUser = document.createElement("DIV");
divUser.className = "user";
divUser.innerHTML = escapeHTML(message.UserName);
divMessage.appendChild(divUser);
}
var text = message.Text;
var divText = document.createElement("DIV");
divText.className = "text";
divText.innerHTML = escapeHTML(text);
divMessage.appendChild(divText);
divMessage.title = new Date(message.Date);
return divMessageRow;
};
var RequestChatData = function () {
var ReciveChatData = function (responseText) {
// Mark as connected
if (cfg.Connected == false) {
if (cfg.Minimized) {
cfg.lblTitle.innerHTML = cfg.Texts.Chat;
} else {
cfg.lblTitle.innerHTML = cfg.Texts.Close;
}
cfg.lblTitle.className = "titleChatNormal";
cfg.txtText.disabled = false;
cfg.btnSend.disabled = false;
}
cfg.Connected = true;
recvMsgs = JSON.parse(responseText);
if (recvMsgs) {
var msgCount = 0;
var scrollChat = false;
if (cfg.Minimized == false && cfg.divChat.scrollTop > (cfg.divChat.scrollHeight - cfg.divChat.offsetHeight)) {
scrollChat = true;
}
var frag = document.createDocumentFragment();
for (var i = 0, n = recvMsgs.length; i < n; i++) {
var msg = recvMsgs[i];
if (cfg.IDMessage < msg.IDMessage) {
cfg.IDMessage = msg.IDMessage;
var elemMessage = CreateMessageDOM(msg,
(msg.UserName == cfg.UserName),
(cfg.LastUser !== msg.UserName));
cfg.LastUser = msg.UserName;
frag.appendChild(elemMessage);
msgCount++;
}
}
cfg.divChat.appendChild(frag);
if (scrollChat) {
cfg.divChat.scrollTop = cfg.divChat.scrollHeight;
}
if (cfg.Minimized && cfg.FirstMessages == false && msgCount > 0) {
cfg.lblTitle.innerHTML = cfg.Texts.NewMessages;
cfg.lblTitle.className = "titleChatAlert";
}
}
cfg.FirstMessages = false;
// Reset pool
window.setTimeout(function () {
RequestChatData();
}, 20);
};
var ErrorChatData = function () {
// Mark as disconnected
cfg.lblTitle.innerHTML = cfg.Texts.Disconnected;
cfg.lblTitle.className = "titleChatDisconnected";
cfg.txtText.disabled = true;
cfg.btnSend.disabled = true;
cfg.Connected = false;
cfg.FirstMessages = false;
// Retry
window.setTimeout(function () {
RequestChatData();
}, 5000);
};
// Pool data
var data = {
"IDBoard": cfg.IDBoard,
"IDMessage": cfg.IDMessage,
"TimePoolData": ((cfg.FirstMessages || cfg.Connected == false) ? "0" : String(cfg.TimePoolData)),
"TimeStamp": new Date().getTime()
};
SendRequest(cfg.ServiceUrl, data, ReciveChatData, ErrorChatData);
};
RequestChatData();
}
function SendChat(cfg) {
cfg.txtText = GetElement(cfg.txtText);
if (cfg.txtText.value.trim() == "") {
return;
}
// Send data
var data = {
"Text": cfg.txtText.value,
"IDBoard": cfg.IDBoard,
"UserName": cfg.UserName,
"TimeStamp": new Date().getTime()
};
SendData(cfg.ServiceUrl, data, null, null);
cfg.txtText.value = "";
cfg.txtText.focus();
}

View File

@@ -0,0 +1,160 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
background-color: grey;
color: black;
}
p {
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h1 {
font-size: 1.7em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h2 {
font-size: 1.5em;
text-align: center;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
h3 {
font-size: 1.2em;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
.divHeader {
display: block;
background-color: black;
}
.divHeader a {
text-decoration: none;
}
.divHeader h1 {
font-size: 30px;
color: yellow;
margin: 0;
text-shadow: none;
}
.divUserInfo{
position: absolute;
top: 0;
right: 0;
}
.divContent {
padding-left: 10px;
padding-right: 10px;
}
.divCode {
background-color: black;
color: green;
font-family: Courier New, Courier, monospace;
text-shadow: none;
overflow: auto;
margin: 5px;
padding: 2px;
box-shadow: 0 0 10px rgb(0,0,0);
}
.formColumn {
display: inline-block;
font-size: 0;
}
.formRow{
display: block;
font-size: 0;
margin: 10px;
}
.formLabel{
display: inline-block;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}
.formLabel span:last-child::after{
content: ':';
}
.formField{
display: inline-block;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
}
.textbox {
background: white;
border: solid 1px rgb(64,64,64);
border-radius: 5px;
line-height: 13px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 11px;
padding: 3px;
box-shadow: inset 0px -2px 5px rgba(255,255,255,1), inset 0px 2px 5px rgba(128,128,128,1);
}
.textbox:focus{
border: solid 1px black;
box-shadow: 0px 0px 10px rgba(255,255,255,0.5), inset 0px -2px 5px rgba(255,255,255,1), inset 0px 2px 5px rgba(0,0,0,0.5);
}
.textboxInvalid{
box-shadow: 0px 0px 10px rgba(255,0,0,0.5), inset 0px -2px 5px rgba(255,255,255,1), inset 0px 2px 5px rgba(0,0,0,0.5);
border: solid 1px rgb(255,0,0);
}
.textboxInvalid:focus{
box-shadow: 0px 0px 10px rgba(255,0,0,0.5), inset 0px -2px 5px rgba(255,255,255,1), inset 0px 2px 5px rgba(0,0,0,0.5);
border: solid 1px black;
}
.button{
padding: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5), inset 0px 2px 5px rgba(255,255,255,1), inset 0px -2px 5px rgba(128,128,128,1);
vertical-align: top;
border-radius: 5px;
border: solid 1px black;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 11px;
text-shadow: 0 1px 1px rgba(255,255,255,0.5);
text-align: center;
cursor: pointer;
background-color: rgb(192,192,192);
margin-left: 5px;
}
.button:first-child{
margin-left: 0;
}
.button:hover{
background-color: rgb(220,220,220);
}
.button:active{
background-color: rgb(220,220,220);
box-shadow: inset 0px 2px 5px rgba(255,255,255,1), inset 0px -2px 5px rgba(128,128,128,1);
}
.width25pc{ width: 25%; }
.width50pc{ width: 50%; }
.width75pc{ width: 75%; }
.width100pc{ width: 100%; }
.width70px {width: 70px; max-width: 100%; }
.width100px {width: 100px; max-width: 100%; }
.width150px {width: 150px; max-width: 100%; }
.width200px {width: 200px; max-width: 100%; }
.width300px {width: 300px; max-width: 100%; }

View File

@@ -0,0 +1,138 @@
.divBoard{
position:relative;
height:100%;
}
.divToolbox{
position: absolute;
background-color: rgb(127,127,255);
box-shadow: 0 0 10px rgba(0,0,0,0.5);
min-width: 150px;
min-height: 50px;
padding: 5px;
border-radius: 2px;
}
.divToolbox .divTitle{
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
font-weight: bold;
text-align: center;
display: block;
height: 20px;
line-height: 20px;
background-color: rgb(0,0,128);
color: rgb(128,128,255);
border-radius: 3px;
margin-bottom: 5px;
}
.divToolbox .divOverlay{
opacity: 0;
background-color: rgb(127,127,255);
position: absolute;
top: 0;
left: 0;
right: 0;
height:30px;
}
.divToolbox .btnToolbox{
margin-top: 5px;
margin-right: 5px;
padding: 2px;
border:solid 1px rgb(0,0,128);
border-radius: 3px;
color: rgb(0,0,128);
background-color: transparent;
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
}
.divToolbox .btnToolbox:hover{
color: rgb(127,127,255);
background-color: rgb(0,0,128);
}
.divCard{
position: absolute;
background-color: rgb(255,255,0);
box-shadow: 0 0 10px rgba(0,0,0,0.5);
min-width: 150px;
max-width: 250px;
min-height: 150px;
max-height: 250px;
padding: 5px;
border-radius: 2px;
overflow: auto;
}
.divCard .divTitle{
padding-bottom: 5px;
padding-right: 44px;
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
font-weight: bold;
text-align: center;
}
.divCard .divBody{
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
}
.divCard .divOverlay{
opacity: 0;
background-color: rgb(255,255,0);
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.divCard .btnCard{
margin-top: 5px;
margin-right: 5px;
padding: 2px;
border:solid 1px black;
border-radius: 3px;
color: black;
background-color: transparent;
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
}
.divCard .btnCard:hover{
color: yellow;
background-color: black;
}
.divCard .btnEdit{
margin:0;
top: 4px;
position:absolute;
width:16px;
right: 24px;
}
.divCard .btnDelete {
margin:0;
top: 4px;
position:absolute;
width:16px;
right: 4px
}
.divCard .txtTitle {
width:100%;
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
background-color: transparent;
border:solid 1px black;
padding: 2px;
}
.divCard .txtBody {
min-height: 150px;
width:100%;
font-family: "Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
font-size: 12px;
background-color: transparent;
border:solid 1px black;
padding: 2px;
}

View File

@@ -0,0 +1,152 @@
.divChatWindow {
box-sizing: border-box;
overflow: hidden;
border: solid 1px black;
padding: 5px;
border-radius: 5px;
background-color: rgb(220,220,220);
box-shadow: 0px 0px 5px black;
position: fixed;
bottom: 0;
right: 0;
}
.divChatTitleBar{
text-align: right;
}
.titleChatNormal{
background-color: rgb(220,220,220);
cursor: pointer;
display: inline-block;
border-radius: 5px;
padding: 5px;
}
@keyframes alert {
0% {background-color: red;}
50% {background-color: rgb(220,220,220);}
100% {background-color: red;}
}
.titleChatAlert{
background-color: red;
animation-name: alert;
animation-duration: 1s;
animation-iteration-count: infinite;
cursor: pointer;
display: inline-block;
border-radius: 5px;
padding: 5px;
}
.titleChatDisconnected{
color: rgb(64,64,64);
background-color: rgb(220,220,220);
cursor: pointer;
display: inline-block;
border-radius: 5px;
padding: 5px;
}
.divChat {
box-sizing: border-box;
overflow: auto;
height: calc(100% - 37px);
margin-bottom: 5px;
border-radius: 5px;
border: solid 1px black;
box-shadow: inset 0px 0px 5px black;
}
.messageRow,
.selfMessageRow {
vertical-align: top;
display: block;
}
.messageRow {
text-align: left;
}
.selfMessageRow {
text-align: right;
}
.message {
box-sizing: border-box;
display: inline-block;
vertical-align: top;
border: solid 1px rgb(32, 32, 32);
background-color: rgb(220,220,220);
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5), inset 0px 2px 5px rgba(255,255,255,0.5), inset 0px -2px 5px rgba(128,128,128,0.5);
margin: 2px;
padding: 5px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
.messageRow .message {
background-color: rgb(220,200,200);
}
.selfMessageRow .message {
background-color: rgb(200,220,200);
}
.message .user {
box-sizing: border-box;
color: rgb(64,64,64);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size: 10px;
font-weight: bold;
}
.message .text {
box-sizing: border-box;
color: rgb(32,32,32);
text-shadow: 0 0 1px rgba(0,0,0,0.3);
font-size: 12px;
}
.divChatControls {
}
.chatTextBox {
box-sizing: border-box;
padding: 5px;
box-shadow: inset 0px 0px 5px black;
width: calc(100% - 52px);
border-radius: 5px;
border: solid 1px black;
margin: 0 2px 0 0;
vertical-align: top;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: left;
}
.chatButton {
box-sizing: border-box;
padding: 5px;
box-shadow: 0px 0px 10px rgba(0,0,0,0.5), inset 0px 2px 5px rgba(255,255,255,1), inset 0px -2px 5px rgba(128,128,128,1);
width: 50px;
vertical-align: top;
border-radius: 5px;
border: solid 1px black;
height: 30px;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
font-size: 12px;
text-align: center;
cursor: pointer;
background-color: rgb(192,192,192);
}
.chatButton:hover {
background-color: rgb(220,220,220);
}
.chatButton:active {
background-color: rgb(220,220,220);
box-shadow: inset 0px 2px 5px rgba(255,255,255,1), inset 0px -2px 5px rgba(128,128,128,1);
}

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7596FD6B-DAF0-4B22-B356-5CF4629F0436}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>VAR.Focus.Web</RootNamespace>
<AssemblyName>VAR.Focus.Web</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Content Include="priv\keep.txt" />
<Content Include="Scripts\01. Base.js" />
<None Include="Properties\PublishProfiles\VAR.Focus.Web.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\02. Ajax.js" />
<Content Include="Scripts\05. Cards.js" />
<Content Include="Scripts\10. Chat.js" />
<Content Include="Styles\01. base.css" />
<Content Include="Styles\05. Cards.css" />
<Content Include="Styles\10. Chat.css" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Code\Bundler.cs" />
<Compile Include="Code\BusinessLogic\CardBoard.cs" />
<Compile Include="Code\BusinessLogic\MessageBoard.cs" />
<Compile Include="Code\BusinessLogic\Persistence.cs" />
<Compile Include="Code\BusinessLogic\Sessions.cs" />
<Compile Include="Code\BusinessLogic\Users.cs" />
<Compile Include="Code\Entities\Card.cs" />
<Compile Include="Code\Entities\CardEvents.cs" />
<Compile Include="Controls\CardBoardControl.cs" />
<Compile Include="Controls\CardBoardHandler.cs" />
<Compile Include="Controls\CButton.cs" />
<Compile Include="Controls\ChatControl.cs" />
<Compile Include="Controls\ChatHandler.cs" />
<Compile Include="Controls\CLabel.cs" />
<Compile Include="Controls\CTextBox.cs" />
<Compile Include="Controls\IValidableControl.cs" />
<Compile Include="Code\CryptoUtils.cs" />
<Compile Include="Code\Entities\Message.cs" />
<Compile Include="Code\Entities\OperationStatus.cs" />
<Compile Include="Code\Entities\Session.cs" />
<Compile Include="Code\Entities\User.cs" />
<Compile Include="Code\GlobalErrorHandler.cs" />
<Compile Include="Code\JSON\ParserContext.cs" />
<Compile Include="Pages\FormUtils.cs" />
<Compile Include="Pages\FrmBoard.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\FrmEcho.cs" />
<Compile Include="Pages\FrmLogin.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\FrmRegister.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\PageCommon.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Code\ScriptsBundler.cs" />
<Compile Include="Code\StylesBundler.cs" />
<Compile Include="GlobalRouter.cs" />
<Compile Include="Code\JSON\JSONParser.cs" />
<Compile Include="Code\JSON\JSONWriter.cs" />
<Compile Include="Pages\FrmError.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Globals.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>51559</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:51555/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
</system.web>
</configuration>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>

18
VAR.Focus.Web/Web.config Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<system.webServer>
<handlers>
<add name="GlobalRouter" path="*" verb="*" type="VAR.Focus.Web.GlobalRouter"/>
</handlers>
</system.webServer>
</configuration>

View File

@@ -0,0 +1 @@