From: <m_h...@us...> - 2006-08-08 20:56:54
|
Revision: 283 Author: m_hildebrand Date: 2006-08-08 13:56:12 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=283&view=rev Log Message: ----------- Made some changes to logging to allow user and host to be output on each line Moved everything into the TCDB, TCDB.Code, or TCDB.Plugins namespace Modified Paths: -------------- Website/AdminRole.aspx Website/App_Code/Assignments.cs Website/App_Code/Common.cs Website/App_Code/GlobalClass.cs Website/App_Code/InstallerClass.cs Website/App_Code/Notes.cs Website/App_Code/Products.cs Website/App_Code/Right.cs Website/App_Code/SiteMaster.cs Website/App_Code/SiteUserControl.cs Website/App_Code/Statuses.cs Website/App_Code/Users.cs Website/App_Code/Versions.cs Website/App_Themes/Python/Python.skin Website/Global.asax Website/Includes/ActionItems.ascx Website/Includes/ActionItems.ascx.cs Website/Includes/AdminConfig.ascx Website/Includes/AdminConfig.ascx.cs Website/Includes/Administration.ascx Website/Includes/Administration.ascx.cs Website/Includes/AdministrationTree.ascx Website/Includes/AdministrationTree.ascx.cs Website/Includes/Assignments.ascx Website/Includes/Assignments.ascx.cs Website/Includes/AssignmentsTree.ascx Website/Includes/AssignmentsTree.ascx.cs Website/Includes/Authenticate.ascx Website/Includes/Authenticate.ascx.cs Website/Includes/Builds.ascx Website/Includes/Execution.ascx Website/Includes/Features.ascx Website/Includes/FeaturesTree.ascx Website/Includes/FeaturesTree.ascx.cs Website/Includes/Footer.ascx Website/Includes/Footer.ascx.cs Website/Includes/Header.ascx Website/Includes/Header_CurrentInfo.ascx Website/Includes/Header_Menu.ascx Website/Includes/Header_User.ascx Website/Includes/Header_User.ascx.cs Website/Includes/Notes.ascx Website/Includes/Notes.ascx.cs Website/Includes/Objectives.ascx Website/Includes/Platforms.ascx Website/Includes/Products.ascx Website/Includes/Products.ascx.cs Website/Includes/Reports.ascx Website/Includes/Rights.ascx Website/Includes/Rights.ascx.cs Website/Includes/RoleAdmin.ascx Website/Includes/RoleAdmin.ascx.cs Website/Includes/Roles.ascx Website/Includes/Roles.ascx.cs Website/Includes/Tags.ascx Website/Includes/TestCases.ascx Website/Includes/UserConfig.ascx Website/Includes/UserConfig.ascx.cs Website/Includes/UserSettings.ascx Website/Includes/UserSettings.ascx.cs Website/Includes/Users.ascx Website/Includes/Versions.ascx Website/Includes/Versions.ascx.cs Website/Includes/WorkOrders.ascx Website/Plugins/VAS_Execution.ascx Website/Plugins/VAS_Execution.ascx.cs Website/PrivacyPolicy.aspx Website/TCDB.master Added Paths: ----------- Website/App_Code/Plugins/ Website/App_Code/Plugins/AD_Authentication.cs Removed Paths: ------------- Website/App_Code/AD_Authentication.cs Website/Includes/SqlDatabase.ascx Modified: Website/AdminRole.aspx =================================================================== --- Website/AdminRole.aspx 2006-08-08 19:11:55 UTC (rev 282) +++ Website/AdminRole.aspx 2006-08-08 20:56:12 UTC (rev 283) @@ -1,8 +1,7 @@ <%@ Page Language="C#" MasterPageFile="~/TCDB.master" AutoEventWireup="true" Title="TCDB: Administration" %> - -<%@ Import Namespace="TCDB.Common" %> <%@ Register Src="~/Includes/AdministrationTree.ascx" TagPrefix="admin" TagName="Tree" %> <%@ Register Src="~/Includes/RoleAdmin.ascx" TagPrefix="admin" TagName="Role" %> + <asp:Content ID="TreeContent" ContentPlaceHolderID="TreeContentPlaceHolder" runat="Server"> <admin:Tree runat="server" ID="Tree" /> </asp:Content> Deleted: Website/App_Code/AD_Authentication.cs =================================================================== --- Website/App_Code/AD_Authentication.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/AD_Authentication.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -1,121 +0,0 @@ -using System; -using System.Data; -using System.DirectoryServices; -using System.Configuration; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; -using TCDB.Users; -using TCDB.Common; -using log4net; - -namespace AD_Auth -{ - /// <summary> - /// Summary description for AD_Authentication - /// </summary> - public static class AD_Authentication - { - private static ILog m_logg = LogManager.GetLogger("AD_Auth.AD_Authentication"); - - public static bool AD_Authenticate(string strUserName, string strPassword) - { - bool result = false; - - // Get the domain name from the config table - string strDomain = ConfigDB.GetConfigString("ad_domain"); - - m_logg.Debug("Checking AD authentication for [" + strUserName + "] in domain [" + strDomain + "]"); - DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain, strUserName, strPassword); - DirectorySearcher ds = new DirectorySearcher(de); - ds.SearchScope = SearchScope.OneLevel; - try - { - SearchResult sr = ds.FindOne(); - m_logg.Info("User [" + strUserName + "] is authenticated in the domain [" + strDomain + "]"); - if (sr != null) result = true; - } - catch - { - m_logg.Warn("User [" + strUserName + "] could not authenticate to the domain [" + strDomain + "]"); - result = false; - } - - return result; - } - - public static User AD_GetUserInfo(string strUserName, string strPassword) - { - return AD_GetUserInfo(strUserName, strPassword, strUserName); - } - - public static User AD_GetUserInfo(string strUserName, string strPassword, string strFindUser) - { - User user = new User(); - - // Get the domain name from the config table - string strDomain = ConfigDB.GetConfigString("ad_domain"); - - m_logg.Debug("Getting AD information for [" + strUserName + "] in domain [" + strDomain + "]"); - //DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain); - //de.AuthenticationType = AuthenticationTypes.Anonymous; - - DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain, strUserName, strPassword); - DirectorySearcher ds = new DirectorySearcher(de); - ds.SearchScope = SearchScope.Subtree; - ds.Filter = "(&(objectClass=user)(sAMAccountName=" + strFindUser + "))"; - - user.ID = Constants.NEWUSER; - user.AUTOMATION = false; - user.ISAUTHENTICATED = true; - user.USERNAME = strFindUser; - try - { - SearchResult sr = ds.FindOne(); - if (sr != null) - { - ResultPropertyCollection rpc = sr.Properties; - ResultPropertyValueCollection property; - - property = rpc[ConfigDB.GetConfigString("uidnumber_attribute")]; - if (property.Count > 0) - user.ID = Convert.ToInt32(property[0]); - property = rpc[ConfigDB.GetConfigString("firstname_attribute")]; - if (property.Count > 0) - user.FIRSTNAME = property[0].ToString(); - property = rpc[ConfigDB.GetConfigString("lastname_attribute")]; - if (property.Count > 0) - user.LASTNAME = property[0].ToString(); - property = rpc[ConfigDB.GetConfigString("email_attribute")]; - if (property.Count > 0) - user.EMAIL = property[0].ToString(); - property = rpc[ConfigDB.GetConfigString("homephone_attribute")]; - if (property.Count > 0) - user.HOMEPHONE = property[0].ToString(); - property = rpc[ConfigDB.GetConfigString("officephone_attribute")]; - if (property.Count > 0) - user.OFFICEPHONE = property[0].ToString(); - property = rpc[ConfigDB.GetConfigString("cellphone_attribute")]; - if (property.Count > 0) - user.CELLPHONE = property[0].ToString(); - } - } - catch - { - m_logg.Debug("Unable to find any AD information for [" + strFindUser + "] in domain [" + strDomain + "]"); - - } - finally - { - ds.Dispose(); - de.Dispose(); - } - - return user; - } - - } -} Modified: Website/App_Code/Assignments.cs =================================================================== --- Website/App_Code/Assignments.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Assignments.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -8,16 +8,13 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Statuses; -using TCDB.Common; -using TCDB.Users; -using log4net; -namespace TCDB.Assignments + +namespace TCDB.Code { public class AssignmentDB { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.AssignmentDB"); + private static Logger m_logg = new Logger("TCDB.Code.AssignmentDB"); public static List<Assignment> GetAssignmentList(string aType, int finished, int assignedID, string highPriority, Nullable<int> creatorID, Nullable<bool> active) { @@ -86,7 +83,7 @@ public class ActionItemDB : Page { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.ActionItemDB"); + private static Logger m_logg = new Logger("TCDB.Assignments.ActionItemDB"); public static bool SendNewActionItemMail(int id) { @@ -254,7 +251,7 @@ public class WorkOrderDB : Page { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.WorkOrderDB"); + private static Logger m_logg = new Logger("TCDB.Assignments.WorkOrderDB"); public static WorkOrder TCDB_GetWorkOrder(int id) { @@ -287,7 +284,7 @@ public class Assignment { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.Assignment"); + private static Logger m_logg = new Logger("TCDB.Assignments.Assignment"); private int p_id; private string p_name; @@ -473,7 +470,7 @@ public class ActionItem { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.ActionItem"); + private static Logger m_logg = new Logger("TCDB.Assignments.ActionItem"); private int p_id; private string p_name; @@ -548,7 +545,7 @@ public class WorkOrder { - private static ILog m_logg = LogManager.GetLogger("TCDB.Assignments.WorkOrder"); + private static Logger m_logg = new Logger("TCDB.Assignments.WorkOrder"); private int p_id; private string p_name; Modified: Website/App_Code/Common.cs =================================================================== --- Website/App_Code/Common.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Common.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -9,15 +9,129 @@ using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections.Generic; -using TCDB.Users; using log4net; -namespace TCDB.Common +namespace TCDB.Code { + public class Logger : System.Web.HttpApplication + { + private ILog m_logg = null; + private static HttpRequest m_request = null; + private static User m_user = null; + public Logger(string instance) + { + m_logg = LogManager.GetLogger(instance); + } + + public static void CreateLoggerDetails(User user, HttpRequest request) + { + m_user = user; + m_request = request; + } + + public void Fatal(string message) + { + if (m_logg.IsFatalEnabled) + m_logg.Fatal(Prefix() + message); + } + + public void Fatal(string message, Exception ex) + { + if (m_logg.IsFatalEnabled) + m_logg.Fatal(Prefix() + message, ex); + } + + public void Error(string message) + { + if (m_logg.IsErrorEnabled) + m_logg.Error(Prefix() + message); + } + + public void Error(string message, Exception ex) + { + if (m_logg.IsErrorEnabled) + m_logg.Error(Prefix() + message, ex); + } + + public void Warn(string message) + { + if (m_logg.IsWarnEnabled) + m_logg.Warn(Prefix() + message); + } + + public void Warn(string message, Exception ex) + { + if (m_logg.IsWarnEnabled) + m_logg.Warn(Prefix() + message, ex); + } + + public void Info(string message) + { + if (m_logg.IsInfoEnabled) + m_logg.Info(Prefix() + message); + } + + public void Info(string message, Exception ex) + { + if (m_logg.IsInfoEnabled) + m_logg.Info(Prefix() + message, ex); + } + + public void Debug(string message) + { + if (m_logg.IsDebugEnabled) + m_logg.Debug(Prefix() + message); + } + + public void Debug(string message, Exception ex) + { + if (m_logg.IsDebugEnabled) + m_logg.Debug(Prefix() + message, ex); + } + + private string Prefix() + { + string result = ""; + bool u = false; + bool hn = false; + bool ha = false; + + try { + if (m_user != null) u = true; + } + catch {} + + try { + if (m_request.UserHostName != null) hn = true; + } + catch {} + + try { + if (m_request.UserHostAddress != null) + { + if (hn && m_request.UserHostName != m_request.UserHostAddress) + ha = true; + } + } + catch {} + + if (u || hn || ha) result = "["; + if (u) result = result + m_user.ToString(); + if (u && (hn || ha)) result = result + "@"; + if (hn) result = result + m_request.UserHostName; + if (u && hn && ha) result = result + " ("; + if (ha) result = result + m_request.UserHostAddress; + if (u && hn && ha) result = result + ")"; + if (u || hn || ha) result = result + "] "; + + return result; + } + } + public class ConfigDB { - private static ILog m_logg = LogManager.GetLogger("TCDB.Common.ConfigDB"); + private static Logger m_logg = new Logger("TCDB.Code.ConfigDB"); public static Dictionary<String, List<Config>> GetAdminSettings() { @@ -310,7 +424,7 @@ // add group settings.Add("auth", group); - + // ------------------------------------------------ // email group // ------------------------------------------------ @@ -328,7 +442,7 @@ "email", "tc...@yo...main", "Email address that messages sent by TCDB should come from")); - + // smtp_server values = new Dictionary<String, String>(); group.Add(new Config("smtp_server", @@ -453,7 +567,7 @@ "newuser", "true", "Allow new users to register with the site")); - + // newuser_ai_name values = new Dictionary<String, String>(); group.Add(new Config("newuser_ai_name", @@ -741,8 +855,8 @@ "true", "Specify if you want to see Not Started Action Items by default")); - + // filter_show_wo_active values = new Dictionary<String, String>(); group.Add(new Config("filter_show_wo_active", @@ -1148,7 +1262,7 @@ private String p_key; private String p_name; private String p_type; - private Dictionary<String,String> p_values; + private Dictionary<String, String> p_values; private String p_validation; private bool p_userSetting; private int p_order; @@ -1161,7 +1275,7 @@ KEY = ""; NAME = ""; TYPE = ""; - VALUES = new Dictionary<String,String>(); + VALUES = new Dictionary<String, String>(); VALIDATION = ""; USER_SETTING = false; ORDER = 1; @@ -1170,7 +1284,7 @@ DESCRIPTION = ""; } - public Config(String key, String name, String type, Dictionary<String,String> values, String validation, bool userSetting, int order, String group, String defaultValue, String description) + public Config(String key, String name, String type, Dictionary<String, String> values, String validation, bool userSetting, int order, String group, String defaultValue, String description) { KEY = key; NAME = name; @@ -1268,7 +1382,7 @@ public static int ASSIGNMENT_NEW = 3; public static string TCDB_VERSION = "1.0.0 Alpha 3"; - public static bool IS_DEV_ENV = false; + public static bool IS_DEV_ENV = true; public static string RIGHTS_ASSIGNPERMISSION = "assignPermission"; public static string RIGHTS_SITEADMIN = "siteAdmin"; @@ -1278,7 +1392,7 @@ public static class Help { - private static ILog m_logg = LogManager.GetLogger("TCDB.Common.Help"); + private static Logger m_logg = new Logger("TCDB.Common.Help"); //protected void SendMail(int type, int id) public static bool SendMail(string subject, string body, bool html, User to) Modified: Website/App_Code/GlobalClass.cs =================================================================== --- Website/App_Code/GlobalClass.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/GlobalClass.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -4,17 +4,15 @@ using System.Configuration; using log4net; using log4net.Config; -using TCDB.Common; -using TCDB.Users; -namespace TCDB +namespace TCDB.Code { /// <summary> /// Summary description for GlobalClass /// </summary> public class GlobalClass : System.Web.HttpApplication { - public static ILog m_logg = LogManager.GetLogger("TCDB 2006"); + private static Logger m_logg = new Logger("TCDB.GlobalClass"); void Application_Start(object sender, EventArgs e) { @@ -43,7 +41,7 @@ throw new NullReferenceException("log4net configuration could not be completed. \nDo you have your app.config set up properly?", nfe); } - m_logg = LogManager.GetLogger("TCDB"); + m_logg = new Logger("TCDB.GlobalClass"); m_logg.Info("TCDB 2006 started"); // Logging levels @@ -76,12 +74,8 @@ if (User.Identity.IsAuthenticated) { Session["m_user"] = UserDB.GetUserInfo(User.Identity.Name); + m_logg.Debug("Loading information for user [" + Session["m_user"].ToString() + "]"); } } - - void Application_PreRequestHandlerExecute(object sender, EventArgs e) - { - - } } } Modified: Website/App_Code/InstallerClass.cs =================================================================== --- Website/App_Code/InstallerClass.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/InstallerClass.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -60,6 +60,8 @@ } } /* + // TODO: make sure this sets the path of the log file properly, it must be a folder + * that the webserver can write to if (node.Name == "log4net") foreach (XmlNode childNode in node.ChildNodes) { Modified: Website/App_Code/Notes.cs =================================================================== --- Website/App_Code/Notes.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Notes.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -7,24 +7,22 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Users; -using TCDB.Common; -namespace TCDB_Notes +namespace TCDB.Code { /// <summary> /// Summary description for TCDB_Notes /// </summary> - public class TCDB_NoteDB : Page + public class NoteDB : Page { - public static TCDB_Note TCDB_GetNote(int id) + public static Note GetNote(int id) { tcdbDataSet ds = new tcdbDataSet(); tcdbDataSetTableAdapters.db_notesTableAdapter ta = new tcdbDataSetTableAdapters.db_notesTableAdapter(); ta.GetData(null, id); ta.Fill(ds.db_notes, null, id); - TCDB_Note note = null; + Note note = null; DataTableReader dr = ds.CreateDataReader(); if (dr.HasRows && dr.Read()) @@ -34,7 +32,7 @@ string noteField = Help.DB_StringParse(dr["noteField"]); int noteAuthor = Help.DB_IntParse(dr["noteAuthor"]); - note = new TCDB_Note(noteid, dateCreated, noteField, noteAuthor); + note = new Note(noteid, dateCreated, noteField, noteAuthor); } return note; @@ -42,14 +40,14 @@ } - public class TCDB_Note + public class Note { private int p_id; private DateTime p_dateCreated; private string p_noteField; private User p_noteAuthor; - public TCDB_Note(int id, DateTime dateCreated, string noteField, User noteAuthor) + public Note(int id, DateTime dateCreated, string noteField, User noteAuthor) { p_id = id; p_dateCreated = dateCreated; @@ -57,7 +55,7 @@ p_noteAuthor = noteAuthor; } - public TCDB_Note(int id, DateTime dateCreated, string noteField, int noteAuthor) + public Note(int id, DateTime dateCreated, string noteField, int noteAuthor) { p_id = id; p_dateCreated = dateCreated; @@ -65,7 +63,7 @@ p_noteAuthor = UserDB.GetUserInfo(noteAuthor); } - public TCDB_Note() + public Note() { p_id = 0; p_dateCreated = new DateTime(1,1,1); Copied: Website/App_Code/Plugins/AD_Authentication.cs (from rev 280, Website/App_Code/AD_Authentication.cs) =================================================================== --- Website/App_Code/Plugins/AD_Authentication.cs (rev 0) +++ Website/App_Code/Plugins/AD_Authentication.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -0,0 +1,115 @@ +using System; +using System.Data; +using System.DirectoryServices; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using TCDB.Code; + + +namespace TCDB.Plugins.AD +{ + /// <summary> + /// Summary description for AD_Auth + /// </summary> + public static class AD_Auth + { + private static Logger m_logg = new Logger("TCDB.Plugins.AD.AD_Auth"); + + public static bool Authenticate(string strUserName, string strPassword) + { + bool result = false; + + // Get the domain name from the config table + string strDomain = ConfigDB.GetConfigString("ad_domain"); + + try + { + m_logg.Debug("Checking AD authentication for [" + strUserName + "] in domain [" + strDomain + "]"); + DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain, strUserName, strPassword); + DirectorySearcher ds = new DirectorySearcher(de); + ds.SearchScope = SearchScope.OneLevel; + SearchResult sr = ds.FindOne(); + m_logg.Info("User [" + strUserName + "] is authenticated in the domain [" + strDomain + "]"); + if (sr != null) result = true; + } + catch + { + m_logg.Warn("User [" + strUserName + "] could not authenticate to the domain [" + strDomain + "]"); + result = false; + } + + return result; + } + + public static User GetUserInfo(string strUserName, string strPassword) + { + return GetUserInfo(strUserName, strPassword, strUserName); + } + + public static User GetUserInfo(string strUserName, string strPassword, string strFindUser) + { + User user = new User(); + user.ID = Constants.NEWUSER; + user.AUTOMATION = false; + user.ISAUTHENTICATED = true; + user.USERNAME = strFindUser; + + string strDomain = ConfigDB.GetConfigString("ad_domain"); + m_logg.Debug("Retreived domain name [" + strDomain + "] from the database"); + + try + { + m_logg.Debug("Getting AD information for [" + strUserName + "] in domain [" + strDomain + "]"); + DirectoryEntry de = new DirectoryEntry("LDAP://" + strDomain, strUserName, strPassword); + DirectorySearcher ds = new DirectorySearcher(de); + ds.SearchScope = SearchScope.Subtree; + ds.Filter = "(&(objectClass=user)(sAMAccountName=" + strFindUser + "))"; + + SearchResult sr = ds.FindOne(); + if (sr != null) + { + ResultPropertyCollection rpc = sr.Properties; + ResultPropertyValueCollection property; + + property = rpc[ConfigDB.GetConfigString("uidnumber_attribute")]; + if (property.Count > 0) + user.ID = Convert.ToInt32(property[0]); + property = rpc[ConfigDB.GetConfigString("firstname_attribute")]; + if (property.Count > 0) + user.FIRSTNAME = property[0].ToString(); + property = rpc[ConfigDB.GetConfigString("lastname_attribute")]; + if (property.Count > 0) + user.LASTNAME = property[0].ToString(); + property = rpc[ConfigDB.GetConfigString("email_attribute")]; + if (property.Count > 0) + user.EMAIL = property[0].ToString(); + property = rpc[ConfigDB.GetConfigString("homephone_attribute")]; + if (property.Count > 0) + user.HOMEPHONE = property[0].ToString(); + property = rpc[ConfigDB.GetConfigString("officephone_attribute")]; + if (property.Count > 0) + user.OFFICEPHONE = property[0].ToString(); + property = rpc[ConfigDB.GetConfigString("cellphone_attribute")]; + if (property.Count > 0) + user.CELLPHONE = property[0].ToString(); + + ds.Dispose(); + de.Dispose(); + } + } + catch + { + m_logg.Debug("Unable to find any AD information for [" + strFindUser + "] in domain [" + strDomain + "]"); + } + + m_logg.Debug("Returning user object for user [" + user.ToString() + "]"); + return user; + } + + } +} Modified: Website/App_Code/Products.cs =================================================================== --- Website/App_Code/Products.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Products.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -8,10 +8,8 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Users; -using TCDB.Common; -namespace TCDB.Products +namespace TCDB.Code { /// <summary> /// Summary description for TCDB.Products Modified: Website/App_Code/Right.cs =================================================================== --- Website/App_Code/Right.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Right.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -14,13 +14,11 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using TCDB.Assignments; -using TCDB.Common; -using AD_Auth; +using TCDB.Plugins.AD; using System.Web.SessionState; -using log4net; -namespace TCDB.Rights + +namespace TCDB.Code { /// <summary> /// A class containing database interactions for users in the TCDB System @@ -28,7 +26,7 @@ /// </summary> public class RightDB : Page { - private static ILog m_logg = LogManager.GetLogger("TCDB.Rights.RightDB"); + private static Logger m_logg = new Logger("TCDB.Code.RightDB"); public static Right GetRightInfo(String code) { @@ -208,7 +206,7 @@ /// </summary> public class Right { - private static ILog m_logg = LogManager.GetLogger("TCDB.Rights.Right"); + private static Logger m_logg = new Logger("TCDB.Rights.Right"); private int p_id; private string p_name; @@ -289,7 +287,7 @@ /// </summary> public class Role { - private static ILog m_logg = LogManager.GetLogger("TCDB.Rights.Role"); + private static Logger m_logg = new Logger("TCDB.Rights.Role"); private int p_id; private string p_name; Modified: Website/App_Code/SiteMaster.cs =================================================================== --- Website/App_Code/SiteMaster.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/SiteMaster.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -8,92 +8,98 @@ using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Configuration; -using TCDB.Users; -using TCDB.Common; -using log4net; +using TCDB.Code; -/// <summary> -/// Summary description for SiteMaster -/// </summary> -public class SiteMaster : System.Web.UI.MasterPage +namespace TCDB { - protected User m_user; - protected DateTime m_startTime = new DateTime(); - protected static ILog m_logg = LogManager.GetLogger("TCDB.Master"); + /// <summary> + /// Summary description for SiteMaster + /// </summary> + public class SiteMaster : System.Web.UI.MasterPage + { + protected User m_user = null; + protected DateTime m_startTime = new DateTime(); + protected HttpRequest m_request = null; + protected static Logger m_logg = new Logger("TCDB.SiteMaster"); - protected override void OnInit(EventArgs e) - { - if (Page.User.Identity.IsAuthenticated) + protected override void OnInit(EventArgs e) { - m_user = LoadSessionUser(); - m_startTime = LoadStartTime(); + if (Page.User.Identity.IsAuthenticated) + { + m_logg.Debug("[" + Request.UserHostName + " (" + Request.UserHostAddress + ")] " + "Processing authenticated user startup"); + m_request = LoadRequest(); + m_user = LoadSessionUser(); + m_startTime = LoadStartTime(); + } + } - //TimeSpan d = DateTime.Now - m_startTime; - //d.Milliseconds; - }/* - else + public HttpRequest LoadRequest() { - PagesSection ps = (PagesSection)WebConfigurationManager.OpenWebConfiguration("").GetSection("system.web/pages"); - ps.ValidateRequest = false; - }*/ - } + m_logg.Debug("[" + Request.UserHostName + " (" + Request.UserHostAddress + ")] " + "Loading the request details"); + if (m_request != null) + { + m_logg.Debug("Returning an existing request details object"); + return m_request; + } - public DateTime LoadStartTime() - { - if (m_startTime != new DateTime()) - { - return m_startTime; + m_logg.Debug("[" + Request.UserHostName + " (" + Request.UserHostAddress + ")] " + "Returning the current request details"); + return Request; } - return DateTime.Now; - - } + public DateTime LoadStartTime() + { + m_logg.Debug("Loading the request start time"); + if (m_startTime != new DateTime()) + { + m_logg.Debug("Returning an existing time"); + return m_startTime; + } - public User LoadSessionUser() - { - if (m_user != null && m_user.ISAUTHENTICATED) - { - return m_user; + m_logg.Debug("Returning the current time"); + return DateTime.Now; } - m_logg.Debug("Entering the SiteUserControl LoadUser"); - - try + public User LoadSessionUser() { - m_logg.Debug("Pulling the userID from the session data"); - //id = (int)Session["m_user"]; - m_user = (User)Session["m_user"]; - //m_logg.Debug("Found userID [" + id.ToString() + "]"); - m_logg.Debug("Found user [" + m_user.ToString() + "]"); - } - catch - { - m_logg.Debug("Unable to find user object in session data, using the anonymous user instead"); - //id = Constants.ANONYMOUSUSERID; - m_user = UserDB.GetUserInfo(Constants.ANONYMOUSUSERID); - } + m_logg.Debug("Loading the session user"); + if (m_user != null && m_user.ISAUTHENTICATED) + { + m_logg.Debug("Returning an existing user [" + m_user.ToString() + "]"); + return m_user; + } - //m_logg.Debug("Setting up a user object based on userID [" + id.ToString() + "]"); - //m_user = UserDB.GetUserInfo(id); - m_logg.Debug("Got information for user [" + m_user.ToString() + "]"); + try + { + m_logg.Debug("Pulling the user from the session data"); + m_user = (User)Session["m_user"]; + } + catch + { + m_logg.Debug("Error finding user object in session data, using the anonymous user instead"); + m_user = UserDB.GetUserInfo(Constants.ANONYMOUSUSERID); + } - if (m_user.ID != Constants.ANONYMOUSUSERID) - { - m_logg.Debug("User [" + m_user.ToString() + "] is logged in and active, marking as authenticated"); - m_user.ISAUTHENTICATED = true; + if (m_user == null) + { + m_logg.Debug("Unable to find user object in session data, using the anonymous user instead"); + m_user = UserDB.GetUserInfo(Constants.ANONYMOUSUSERID); + } + + m_logg.Debug("Got information for user [" + m_user.ToString() + "]"); + + if (m_user.ID != Constants.ANONYMOUSUSERID) + { + m_logg.Debug("User [" + m_user.ToString() + "] is logged in and active, marking as authenticated"); + m_user.ISAUTHENTICATED = true; + } + else + { + m_logg.Debug("User [" + m_user.ToString() + "] is anonymous, marking as guest"); + m_user.ISAUTHENTICATED = false; + } + + return m_user; } - else - { - m_logg.Debug("User [" + m_user.ToString() + "] is anonymous, marking as guest"); - m_user.ISAUTHENTICATED = false; - } - /* try - { - User g_user; - g_user = (User)Session["g_user"]; - } - catch { }*/ - return m_user; } -} +} \ No newline at end of file Modified: Website/App_Code/SiteUserControl.cs =================================================================== --- Website/App_Code/SiteUserControl.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/SiteUserControl.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -7,36 +7,62 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Users; -using TCDB.Common; -using log4net; +using TCDB.Code; -/// <summary> -/// Summary description for SiteUserControl -/// </summary> -public class SiteUserControl : System.Web.UI.UserControl + +namespace TCDB { - protected static Nullable<bool> active = true; - protected static User m_user = null; - protected static DateTime m_startTime = DateTime.Now; - private static ILog m_logg = LogManager.GetLogger("TCDB.Master"); - - protected override void OnInit(EventArgs e) + /// <summary> + /// Summary description for SiteUserControl + /// </summary> + public class SiteUserControl : System.Web.UI.UserControl { - base.OnInit(e); + protected static Nullable<bool> active = true; + protected static User m_user = null; + protected static DateTime m_startTime = DateTime.Now; + protected static HttpRequest m_request = null; + private static Logger m_logg = new Logger("TCDB.SiteUserControl"); - m_user = ((SiteMaster)(this.Page.Master)).LoadSessionUser(); - m_startTime = ((SiteMaster)(this.Page.Master)).LoadStartTime(); + protected override void OnInit(EventArgs e) + { + base.OnInit(e); - if (m_user.HasRight("dev_access")) - { - active = null; - Session["active"] = null; + Logger.CreateLoggerDetails(m_user, Request); + + try + { + m_logg.Debug("Loading Session user information"); + m_user = ((SiteMaster)(this.Page.Master)).LoadSessionUser(); + } + catch (Exception ex) + { + m_logg.Debug("Unable to load session user information", ex); + } + + Logger.CreateLoggerDetails(m_user, Request); + + try + { + m_logg.Debug("Loading request start time"); + m_startTime = ((SiteMaster)(this.Page.Master)).LoadStartTime(); + } + catch (Exception ex) + { + m_logg.Debug("Unable to load request start time", ex); + } + + if (m_user.HasRight("dev_access")) + { + m_logg.Debug("User has developer access right, setting 'active' to 'null'"); + active = null; + Session["active"] = null; + } + else + { + m_logg.Debug("User does not have developer access right, setting 'active' to 'true'"); + active = true; + Session["active"] = true; + } } - else - { - active = true; - Session["active"] = true; - } } -} +} \ No newline at end of file Modified: Website/App_Code/Statuses.cs =================================================================== --- Website/App_Code/Statuses.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Statuses.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -7,9 +7,8 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Common; -namespace TCDB.Statuses +namespace TCDB.Code { public class StatusDB : Page { Modified: Website/App_Code/Users.cs =================================================================== --- Website/App_Code/Users.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Users.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -14,15 +14,11 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using TCDB.Assignments; -using TCDB.Common; -using AD_Auth; using System.Web.SessionState; -using log4net; -using TCDB.Rights; -using TCDB.Products; +using TCDB.Plugins.AD; -namespace TCDB.Users + +namespace TCDB.Code { /// <summary> /// A class containing database interactions for users in the TCDB System @@ -30,7 +26,7 @@ /// </summary> public class UserDB : Page { - private static ILog m_logg = LogManager.GetLogger("TCDB.Users.UserDB"); + private static Logger m_logg = new Logger("TCDB.Code.UserDB"); /// <summary> /// Attemps to authenticate a user by checking for the user in the database. @@ -50,9 +46,9 @@ { // TODO: Add logic here to determine and use the appropriate // authentication method based on configuration data - + // Using AD authentication - if (!AD_Authentication.AD_Authenticate(strUserName, strPassword)) + if (!AD_Auth.Authenticate(strUserName, strPassword)) { // We can't authenticate, so return the guest user return new User(); @@ -68,7 +64,7 @@ } // Using AD authentication - user = AD_Authentication.AD_GetUserInfo(strUserName, strPassword); + user = AD_Auth.GetUserInfo(strUserName, strPassword); user.ISNEW = true; return user; } @@ -261,7 +257,7 @@ /// </summary> public class User { - private static ILog m_logg = LogManager.GetLogger("TCDB.Users.User"); + private static Logger m_logg = new Logger("TCDB.Users.User"); private int p_id; private string p_username; Modified: Website/App_Code/Versions.cs =================================================================== --- Website/App_Code/Versions.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Code/Versions.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -8,11 +8,8 @@ using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; -using TCDB.Users; -using TCDB.Products; -using TCDB.Common; -namespace TCDB.Versions +namespace TCDB.Code { /// <summary> /// Summary description for TCDB.Versions Modified: Website/App_Themes/Python/Python.skin =================================================================== --- Website/App_Themes/Python/Python.skin 2006-08-08 19:11:55 UTC (rev 282) +++ Website/App_Themes/Python/Python.skin 2006-08-08 20:56:12 UTC (rev 283) @@ -23,6 +23,7 @@ <asp:GridView runat="server" SkinId="assignments" Width="100%" /> <asp:Image runat="server" SkinId="newUserImage" ImageUrl="Images/user_add_48.png" /> <asp:Image runat="server" SkinId="userRoleImage" ImageUrl="Images/user_role_48.png" /> +<asp:Image runat="server" SkinId="newProductImage" ImageUrl="Images/product_add_48.png" /> <asp:Image runat="server" SkinId="priority_high_small" ImageUrl="Images/priority_high_small.png" /> <asp:Image runat="server" SkinId="priority_high_large" ImageUrl="Images/priority_high_large.png" /> <asp:Image runat="server" SkinId="priority_normal_small" ImageUrl="" /> Modified: Website/Global.asax =================================================================== --- Website/Global.asax 2006-08-08 19:11:55 UTC (rev 282) +++ Website/Global.asax 2006-08-08 20:56:12 UTC (rev 283) @@ -1 +1 @@ -<%@ Application Language="C#" Inherits="TCDB.GlobalClass" %> \ No newline at end of file +<%@ Application Language="C#" Inherits="TCDB.Code.GlobalClass" %> \ No newline at end of file Modified: Website/Includes/ActionItems.ascx =================================================================== --- Website/Includes/ActionItems.ascx 2006-08-08 19:11:55 UTC (rev 282) +++ Website/Includes/ActionItems.ascx 2006-08-08 20:56:12 UTC (rev 283) @@ -1,4 +1,4 @@ -<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ActionItems.ascx.cs" Inherits="ActionItems" %> +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ActionItems.ascx.cs" Inherits="TCDB.ActionItems" %> <%@ Register Assembly="eWorld.UI, Version=2.0.0.2148, Culture=neutral, PublicKeyToken=24d65337282035f2" Namespace="eWorld.UI" TagPrefix="ew" %> <%@ Register Assembly="FreeTextBox" Namespace="FreeTextBoxControls" TagPrefix="FTB" %> Modified: Website/Includes/ActionItems.ascx.cs =================================================================== --- Website/Includes/ActionItems.ascx.cs 2006-08-08 19:11:55 UTC (rev 282) +++ Website/Includes/ActionItems.ascx.cs 2006-08-08 20:56:12 UTC (rev 283) @@ -11,479 +11,480 @@ using System.Collections.Generic; using System.Data.SqlClient; using System.Net.Mail; -using TCDB.Assignments; -using TCDB.Common; -using TCDB.Users; -using TCDB.Products; +using TCDB.Code; using eWorld.UI; -using log4net; -public partial class ActionItems : SiteUserControl + +namespace TCDB { - private static ILog m_logg = LogManager.GetLogger("Page:ActionItems"); - private ActionItem ai; - private String item_id = HttpContext.Current.Request.QueryString[Constants.CODE_AI]; - private int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); - private String mode = HttpContext.Current.Request.QueryString["mode"]; - - protected void Page_Load(object sender, EventArgs e) + public partial class ActionItems : SiteUserControl { - if (productID == 0) - productID = Constants.PRODUCT_SITEID; + private static Logger m_logg = new Logger("TCDB.ActionItems"); + private ActionItem ai; + private String item_id = HttpContext.Current.Request.QueryString[Constants.CODE_AI]; + private int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); + private String mode = HttpContext.Current.Request.QueryString["mode"]; - m_logg.Debug("Loading page ActionItems"); - if (item_id == null) + protected void Page_Load(object sender, EventArgs e) { - m_logg.Debug("Unable to locate action item ID in query string"); - if (mode != "new") + if (productID == 0) + productID = Constants.PRODUCT_SITEID; + + m_logg.Debug("Loading page ActionItems"); + if (item_id == null) { - m_logg.Debug("Mode not set, redirecting to Assignments page"); - Response.Redirect("Assignments.aspx?" + Constants.CODE_USER + "=" + m_user.ID); + m_logg.Debug("Unable to locate action item ID in query string"); + if (mode != "new") + { + m_logg.Debug("Mode not set, redirecting to Assignments page"); + Response.Redirect("Assignments.aspx?" + Constants.CODE_USER + "=" + m_user.ID); + } } - } - else - { - ai = ActionItemDB.GetActionItem(Convert.ToInt32(item_id),active); + else + { + ai = ActionItemDB.GetActionItem(Convert.ToInt32(item_id), active); - if (ai != null && - (!m_user.HasRight("view_other_ai", productID) && - !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("view_my_ai", productID)) && - !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("view_created_ai", productID)))) - Response.Redirect("~/Assignments.aspx?"+Constants.CODE_USER+"="+m_user.ID); - } + if (ai != null && + (!m_user.HasRight("view_other_ai", productID) && + !(ai.ASSIGNED.ID == m_user.ID && m_user.HasRight("view_my_ai", productID)) && + !(ai.CREATOR.ID == m_user.ID && m_user.HasRight("view_created_ai", productID)))) + Response.Redirect("~/Assignments.aspx?" + Constants.CODE_USER + "=" + m_user.ID); + } - Session.Add("item_id", item_id); - Session.Add("productID", productID); - Session.Add("tableName", "tcdb_actionItem"); + Session.Add("item_id", item_id); + Session.Add("productID", productID); + Session.Add("tableName", "tcdb_actionItem"); - if (mode == "new" && (m_user.HasRight("create_my_ai") || m_user.HasRight("create_other_ai"))) - ActionItemsView.ChangeMode(FormViewMode.Insert); - } - - protected void updateStatus() - { - RadioButtonList percentList = (RadioButtonList)ActionItemsView.FindControl("percentList"); - DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); - Object dateFinished = ActionItemsView.FindControl("dateFinished"); - Nullable<DateTime> date; - int id = Convert.ToInt32(item_id); - - if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) - { - String finished = ((Label)dateFinished).Text; - - if (finished == "") - date = null; - else - date = Convert.ToDateTime(finished); + if (mode == "new" && (m_user.HasRight("create_my_ai") || m_user.HasRight("create_other_ai"))) + ActionItemsView.ChangeMode(FormViewMode.Insert); } - else - { - date = ((CalendarPopup)dateFinished).SelectedValue; - } - // Update Database - tcdbDataSetTableAdapters.db_actionItemsTableAdapter aiAdapter = new tcdbDataSetTableAdapters.db_actionItemsTableAdapter(); - aiAdapter.upd_actionItemStatus(id, Convert.ToInt32(statusList.SelectedValue), Convert.ToInt32(percentList.SelectedValue), date); - - m_logg.Debug("Action Item updated, preparing to send email"); - if (date == null) - ActionItemDB.SendUpdatedActionItemMail(id, m_user); - else - ActionItemDB.SendCompletedActionItemMail(id, m_user); - Response.Redirect(Request.RawUrl); - - } - protected void dateFinished_DateChanged(object sender, EventArgs e) - { - if (ActionItemsView.CurrentMode != FormViewMode.Insert) + protected void updateStatus() { RadioButtonList percentList = (RadioButtonList)ActionItemsView.FindControl("percentList"); DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); - CalendarPopup dateFinished = (CalendarPopup)sender; + Object dateFinished = ActionItemsView.FindControl("dateFinished"); + Nullable<DateTime> date; + int id = Convert.ToInt32(item_id); - if (dateFinished.SelectedValue != null) + if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) { - dateFinished.ClearDateText = "Clear Date"; - statusList.SelectedValue = statusList.Items.FindByText("Completed").Value; - percentList.SelectedValue = "100"; + String finished = ((Label)dateFinished).Text; + + if (finished == "") + date = null; + else + date = Convert.ToDateTime(finished); } else { - dateFinished.ClearDateText = ""; - if (statusList.SelectedItem.Text == "Completed") - statusList.SelectedValue = statusList.Items.FindByText("Active").Value; - if (percentList.SelectedValue == "100") - percentList.SelectedValue = "75"; + date = ((CalendarPopup)dateFinished).SelectedValue; } - if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) - updateStatus(); - } + // Update Database + tcdbDataSetTableAdapters.db_actionItemsTableAdapter aiAdapter = new tcdbDataSetTableAdapters.db_actionItemsTableAdapter(); + aiAdapter.upd_actionItemStatus(id, Convert.ToInt32(statusList.SelectedValue), Convert.ToInt32(percentList.SelectedValue), date); - // Check for bad state - if (ActionItemsView.CurrentMode == FormViewMode.Edit) - { - FreeTextBoxControls.FreeTextBox ftb = (FreeTextBoxControls.FreeTextBox)ActionItemsView.FindControl("descriptionBox"); - if (ftb.Text == "") - ActionItemsView.DataBind(); + m_logg.Debug("Action Item updated, preparing to send email"); + if (date == null) + ActionItemDB.SendUpdatedActionItemMail(id, m_user); + else + ActionItemDB.SendCompletedActionItemMail(id, m_user); + Response.Redirect(Request.RawUrl); + } - } - protected void percentChanged(object sender, EventArgs e) - { - if (ActionItemsView.CurrentMode != FormViewMode.Insert) + protected void dateFinished_DateChanged(object sender, EventArgs e) { - RadioButtonList percentList = (RadioButtonList)sender; - DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); - - if (percentList.SelectedValue == "100") + if (ActionItemsView.CurrentMode != FormViewMode.Insert) { - statusList.SelectedValue = statusList.Items.FindByText("Completed").Value; + RadioButtonList percentList = (RadioButtonList)ActionItemsView.FindControl("percentList"); + DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); + CalendarPopup dateFinished = (CalendarPopup)sender; - // Set finished Date - if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) + if (dateFinished.SelectedValue != null) { - Label dateFinished = (Label)ActionItemsView.FindControl("dateFinished"); - - if (dateFinished.Text == "") - dateFinished.Text = DateTime.Today.ToShortDateString(); + dateFinished.ClearDateText = "Clear Date"; + statusList.SelectedValue = statusList.Items.FindByText("Completed").Value; + percentList.SelectedValue = "100"; } else { - CalendarPopup dateFinished = (CalendarPopup)ActionItemsView.FindControl("dateFinished"); - - if (dateFinished.SelectedValue == null) - dateFinished.SelectedValue = DateTime.Today; - dateFinished.ClearDateText = "Clear Date"; + dateFinished.ClearDateText = ""; + if (statusList.SelectedItem.Text == "Completed") + statusList.SelectedValue = statusList.Items.FindByText("Active").Value; + if (percentList.SelectedValue == "100") + percentList.SelectedValue = "75"; } - } - else { - if (percentList.SelectedValue == "0") - statusList.SelectedValue = statusList.Items.FindByText("Not Started").Value; - else if (percentList.SelectedValue == "25" || percentList.SelectedValue == "75" || percentList.SelectedValue == "50") - statusList.SelectedValue = statusList.Items.FindByText("Active").Value; - // Unset finished Date if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) - { - Label dateFinished = (Label)ActionItemsView.FindControl("dateFinished"); - dateFinished.Text = ""; - } - else - { - CalendarPopup dateFinished = (CalendarPopup)ActionItemsView.FindControl("dateFinished"); - dateFinished.Clear(); - dateFinished.PostedDate = ""; - dateFinished.ClearDateText = ""; - } + updateStatus(); } - if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) - updateStatus(); - } - // Check for bad state - if (ActionItemsView.CurrentMode == FormViewMode.Edit) - { - FreeTextBoxControls.FreeTextBox ftb = (FreeTextBoxControls.FreeTextBox)ActionItemsView.FindControl("descriptionBox"); - if (ftb.Text == "") - ActionItemsView.DataBind(); + // Check for bad state + if (ActionItemsView.CurrentMode == FormViewMode.Edit) + { + FreeTextBoxControls.FreeTextBox ftb = (FreeTextBoxControls.FreeTextBox)ActionItemsView.FindControl("descriptionBox"); + if (ftb.Text == "") + ActionItemsView.DataBind(); + } } - } - protected void statusChanged(object sender, EventArgs e) - { - if (ActionItemsView.CurrentMode != FormViewMode.Insert) + protected void percentChanged(object sender, EventArgs e) { - RadioButtonList percentList = (RadioButtonList)ActionItemsView.FindControl("percentList"); - DropDownList statusList = (DropDownList)sender; - - if (statusList.SelectedItem.Text == "Completed") + if (ActionItemsView.CurrentMode != FormViewMode.Insert) { - percentList.SelectedValue = "100"; + RadioButtonList percentList = (RadioButtonList)sender; + DropDownList statusList = (DropDownList)ActionItemsView.FindControl("statusList"); - // Set finished Date - if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) + if (percentList.SelectedValue == "100") { - Label dateFinished = (Label)ActionItemsView.FindControl("dateFinished"); + statusList.SelectedValue = statusList.Items.FindByText("Completed").Value; - dateFinished.Text = DateTime.Today.ToShortDateString(); + // Set finished Date + if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) + { + Label dateFinished = (Label)ActionItemsView.FindControl("dateFinished"); + + if (dateFinished.Text == "") + dateFinished.Text = DateTime.Today.ToShortDateString(); + } + else + { + CalendarPopup dateFinished = (CalendarPopup)ActionItemsView.FindControl("dateFinished"); + + if (dateFinished.SelectedValue == null) + dateFinished.SelectedValue = DateTime.Today; + dateFinished.ClearDateText = "Clear Date"; + } } else { - CalendarPopup dateFinished = (CalendarPopup)ActionItemsView.FindControl("dateFinished"); + if (percentList.SelectedValue == "0") + statusList.SelectedValue = statusList.Items.FindByText("Not Started").Value; + else if (percentList.SelectedValue == "25" || percentList.SelectedValue == "75" || percentList.SelectedValue == "50") + statusList.SelectedValue = statusList.Items.FindByText("Active").Value; - dateFinished.SelectedValue = DateTime.Today; - dateFinished.ClearDateText = "Clear Date"; + // Unset finished Date + if (ActionItemsView.CurrentMode == FormViewMode.ReadOnly) + { + Label dateFinished = (Label)ActionItemsView.FindControl("dateFinished"); + dateFinished.Text = ""; + } + else + { + ... [truncated message content] |