private void BindStep1() { tbTitle.Text = String.Empty; ddlManager.Attributes.Add("onchange", "SaveManagerId();"); ddPriority.DataValueField = "PriorityId"; ddPriority.DataTextField = "PriorityName"; ddPriority.DataSource = ToDo.GetListPriorities(); ddPriority.DataBind(); ddProject.DataTextField = "Title"; ddProject.DataValueField = "ProjectId"; s4OnlyForMe.Text = LocRM.GetString("s4OnlyForMe"); chbMustBeConfirmed.Text = LocRM.GetString("s4MustBeConfirmed"); switch (sUnit) { case "Entry": s2ToDoManager.Style.Add("display", "none"); ddEntryType.DataTextField = "TypeName"; ddEntryType.DataValueField = "TypeId"; ddEntryType.DataSource = CalendarEntry.GetListEventTypes(); ddEntryType.DataBind(); CommonHelper.SafeSelect(ddEntryType, "2"); ddProject.DataSource = CalendarEntry.GetListProjects(Security.CurrentUser.UserID); s4AssignTeam.Text = LocRM.GetString("s4AssignParticipants"); s1ToDoProperties.Visible = false; // DateTimeCommentForToDo.Visible = false; dtcStartDate.SelectedDate = UserDateTime.UserNow; dtcEndDate.SelectedDate = dtcStartDate.SelectedDate.AddMinutes(30); CommonHelper.SafeSelect(ddPriority, PortalConfig.CEntryDefaultValuePriorityField); divPriority.Visible = PortalConfig.CommonCEntryAllowEditPriorityField; break; case "ToDo": s2ToDoManager.Style.Add("display", "inline"); ddToDoCompletionType.DataTextField = "CompletionTypeName"; ddToDoCompletionType.DataValueField = "CompletionTypeId"; ddToDoCompletionType.DataSource = ToDo.GetListCompletionTypes(); ddProject.DataSource = Project.GetListActiveProjectsByManager(); ddToDoCompletionType.DataBind(); s4AssignTeam.Text = LocRM.GetString("s4AssignResources"); s1EntryProperties.Visible = false; break; } ddProject.DataBind(); ListItem liDefault = new ListItem(LocRM.GetString("s4NotSet"), "-1"); ddProject.Items.Insert(0, liDefault); ArrayList alManagers = new ArrayList(); using (IDataReader rManagers = SecureGroup.GetListAllUsersInGroup((int)InternalSecureGroups.ProjectManager, false)) { while (rManagers.Read()) { ListItem li = new ListItem(rManagers["LastName"].ToString() + " " + rManagers["FirstName"].ToString(), rManagers["UserId"].ToString()); alManagers.Add(li); } } if (Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager)) { for (int i = 0; i < alManagers.Count; i++) { ddlManager.Items.Add((ListItem)alManagers[i]); } Util.CommonHelper.SafeSelect(ddlManager, Security.CurrentUser.UserID.ToString()); } else { lblManager.Visible = true; ddlManager.Enabled = false; ddlManager.Visible = false; lblManager.Text = CommonHelper.GetUserStatusUL((Security.CurrentUser.UserID)); txtManagerId.Value = Security.CurrentUser.UserID.ToString(); } }
public static string LoadDictionaries(string Locale, int ObjectType) { /************************************************************************/ /* * <Dictionaries> * -- Common * -- Current user * <CurrentUser> * </CurrentUser> * <PortalConfig> * </PortalConfig> * <Priority> * <Item> * <Value/> * <Data/> * </Item> * </Priority> * * -- For Incident * <IncidentType> * ... * </IncidentType> * <Severity> * ... * </Severity> * * <IncidentOrganization> * ... * </IncidentOrganization> * * <IncidentContact> * ... * </IncidentContact> * * <IncidentBox> * ... * </IncidentBox> * * -- For Event * <EventType> * ... * </EventType> * * <Organizers> * </Organizers> * * <EventOrganization> * ... * </EventOrganization> * * <EventContact> * ... * </EventContact> * * -- For ToDo * <CompletionType> * ... * </CompletionType> * * <ToDoOrganization> * ... * </ToDoOrganization> * * <ToDoContact> * ... * </ToDoContact> * * -- For Task * <CompletionType> * ... * </CompletionType> * * -- For Project * <ProjectType> * ... * </ProjectType> * * <ProjectOrganization> * ... * </ProjectOrganization> * * <ProjectContact> * ... * </ProjectContact> * * <ProjectManager> * <User> * <UserId> * <FirstName> * <LastName> * </User> * ... * </ProjectManager> * * <ExecuteveManager> * <User> * <UserId> * <FirstName> * <LastName> * </User> * ... * </ExecuteveManager> * * <ProjectStatus> * ... * </ProjectStatus> * * <ProjectCalendar> * ... * </ProjectCalendar> * * <ProjectTemplate> * ... * </ProjectTemplate> * * <ProjectPriority> * ... * </ProjectPriority> * * <ProjectPortfolio> * ... * </ProjectPortfolio> * * <ProjectPhase> * ... * </ProjectPhase> * -- For List * <ListStatus> * ... * </ListStatus> * <ListType> * ... * </ListType> * <ListTemplate> * ... * </ListTemplate> * </Dictionaries> * * /************************************************************************/ int LanguageId = WebServicesHelper.GetLanguageIdByLocale(Locale); XmlDocument xmlDictionariesList = new XmlDocument(); xmlDictionariesList.LoadXml("<Dictionaries></Dictionaries>"); XmlNode xmlDictionariesNode = xmlDictionariesList.SelectSingleNode("Dictionaries"); // Step 1. Build Common Dictionaryes [2/9/2004] // Step 1.0 Current User information XmlNode xmlCurrentUserNode = xmlDictionariesList.CreateElement("CurrentUser"); InsertXMLItem(xmlCurrentUserNode, "UserId", Security.CurrentUser.UserID.ToString()); InsertXMLItem(xmlCurrentUserNode, "FirstName", Security.CurrentUser.FirstName); InsertXMLItem(xmlCurrentUserNode, "LastName", Security.CurrentUser.LastName); InsertXMLItem(xmlCurrentUserNode, "Email", Security.CurrentUser.Email); InsertXMLItem(xmlCurrentUserNode, "IsAdmin", Security.IsUserInGroup(InternalSecureGroups.Administrator).ToString()); InsertXMLItem(xmlCurrentUserNode, "IsPM", Security.IsUserInGroup(InternalSecureGroups.ProjectManager).ToString()); InsertXMLItem(xmlCurrentUserNode, "IsPPM", Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager).ToString()); InsertXMLItem(xmlCurrentUserNode, "IsHDM", Security.IsUserInGroup(InternalSecureGroups.HelpDeskManager).ToString()); InsertXMLItem(xmlCurrentUserNode, "TimeOffset", User.GetCurrentBias(Security.CurrentUser.TimeZoneId).ToString()); xmlDictionariesNode.AppendChild(xmlCurrentUserNode); // OZ: Portal Config 2008-07-18 XmlNode xmlPortalConfigNode = xmlDictionariesList.CreateElement("PortalConfig"); InsertXMLItem(xmlPortalConfigNode, "WorkTimeStart", PortalConfig.WorkTimeStart); InsertXMLItem(xmlPortalConfigNode, "WorkTimeFinish", PortalConfig.WorkTimeFinish); xmlDictionariesNode.AppendChild(xmlPortalConfigNode); // Step 1.1. Priority [2/9/2004] XmlNode xmlPriorityNode = xmlDictionariesList.CreateElement("Priority"); using (IDataReader PriorityReader = WebServicesHelper.GetListPriorities(LanguageId)) { while (PriorityReader.Read()) { InsertDictionaryItem(xmlPriorityNode, PriorityReader["PriorityName"].ToString(), PriorityReader["PriorityId"].ToString()); } PriorityReader.Close(); } xmlDictionariesNode.AppendChild(xmlPriorityNode); // Step 2. Build Specific Dictionaries [2/9/2004] switch ((ObjectTypes)ObjectType) { case ObjectTypes.Issue: // [2/9/2004] XmlNode xmlIncidentTypeNode = xmlDictionariesList.CreateElement("IncidentType"); using (IDataReader incidentTypesReader = Incident.GetListIncidentTypes()) { while (incidentTypesReader.Read()) { InsertDictionaryItem(xmlIncidentTypeNode, incidentTypesReader["TypeName"].ToString(), incidentTypesReader["TypeId"].ToString()); } incidentTypesReader.Close(); } xmlDictionariesNode.AppendChild(xmlIncidentTypeNode); // [2/9/2004] XmlNode xmlSeverityTypeNode = xmlDictionariesList.CreateElement("Severity"); using (IDataReader severityTypesReader = Incident.GetListIncidentSeverity()) { while (severityTypesReader.Read()) { InsertDictionaryItem(xmlSeverityTypeNode, severityTypesReader["SeverityName"].ToString(), severityTypesReader["SeverityId"].ToString()); } severityTypesReader.Close(); } xmlDictionariesNode.AppendChild(xmlSeverityTypeNode); // IncidentOrganization [11/21/2006] InsertOrganizationDictionaryItemList(xmlDictionariesNode, "IncidentOrganization"); // IncidentContacts [11/21/2006] InsertContactDictionaryItemList(xmlDictionariesNode, "IncidentContact"); // IncidentBox [12/12/2006] XmlNode xmlIncidentBoxNode = xmlDictionariesList.CreateElement("IncidentBox"); foreach (EMail.IncidentBox box in EMail.IncidentBox.List()) { InsertDictionaryItem(xmlIncidentBoxNode, box.Name, box.IncidentBoxId.ToString()); } xmlDictionariesNode.AppendChild(xmlIncidentBoxNode); break; case ObjectTypes.CalendarEntry: // [2/9/2004] XmlNode xmlEventTypeNode = xmlDictionariesList.CreateElement("EventType"); using (IDataReader eventTypesReader = CalendarEntry.GetListEventTypes()) { while (eventTypesReader.Read()) { InsertDictionaryItem(xmlEventTypeNode, eventTypesReader["TypeName"].ToString(), eventTypesReader["TypeId"].ToString()); } eventTypesReader.Close(); } xmlDictionariesNode.AppendChild(xmlEventTypeNode); // Organizers [5/6/2004] XmlNode xmlEventOrganizersNode = xmlDictionariesList.CreateElement("Organizers"); using (IDataReader eventOrganizersReader = CalendarView.GetListPeopleForCalendar()) { InsertUserInformation(xmlEventOrganizersNode, (int)Security.CurrentUser.UserID); while (eventOrganizersReader.Read()) { if ((int)eventOrganizersReader["Level"] == 1) { InsertUserInformation(xmlEventOrganizersNode, (int)eventOrganizersReader["UserId"]); } //InsertDictionaryItem(xmlEventTypeNode,eventTypesReader["TypeName"].ToString(),eventTypesReader["TypeId"].ToString()); } eventOrganizersReader.Close(); } xmlDictionariesNode.AppendChild(xmlEventOrganizersNode); // EventOrganization [11/21/2006] InsertOrganizationDictionaryItemList(xmlDictionariesNode, "EventOrganization"); // EventContacts [11/21/2006] InsertContactDictionaryItemList(xmlDictionariesNode, "EventContact"); break; case ObjectTypes.Task: // [2/9/2004] XmlNode xmlTaskCompTypeNode = xmlDictionariesList.CreateElement("CompletionType"); using (IDataReader taskCompTypesReader = WebServicesHelper.GetListTaskCompletionTypes(LanguageId)) { while (taskCompTypesReader.Read()) { InsertDictionaryItem(xmlTaskCompTypeNode, taskCompTypesReader["CompletionTypeName"].ToString(), taskCompTypesReader["CompletionTypeId"].ToString()); } taskCompTypesReader.Close(); } xmlDictionariesNode.AppendChild(xmlTaskCompTypeNode); break; case ObjectTypes.ToDo: // [2/9/2004] InsertDictionaryItemList(xmlDictionariesNode, "CompletionType", WebServicesHelper.GetListToDoCompletionTypes(LanguageId), "CompletionTypeName", "CompletionTypeId"); // ToDoOrganization [11/21/2006] InsertOrganizationDictionaryItemList(xmlDictionariesNode, "ToDoOrganization"); // ToDoContacts [11/21/2006] InsertContactDictionaryItemList(xmlDictionariesNode, "ToDoContact"); break; case ObjectTypes.Project: if (!Project.CanCreate()) { throw new AccessDeniedException(); } // ProjectType [3/30/2004] InsertDictionaryItemList(xmlDictionariesNode, "ProjectType", Project.GetListProjectTypes(), "TypeName", "TypeId"); // ProjectClient [3/30/2004] //InsertDictionaryItemList(xmlDictionariesNode,"ProjectClient", Project.GetListClients(),"ClientName", "ClientId"); // ProjectOrganization [11/21/2006] InsertOrganizationDictionaryItemList(xmlDictionariesNode, "ProjectOrganization"); // ProjectContacts [11/21/2006] InsertContactDictionaryItemList(xmlDictionariesNode, "ProjectContact"); // ProjectStatus [3/30/2004] InsertDictionaryItemList(xmlDictionariesNode, "ProjectStatus", WebServicesHelper.GetListProjectStatus(LanguageId), "StatusName", "StatusId"); // ProjectCalendar [3/30/2004] InsertDictionaryItemList(xmlDictionariesNode, "ProjectCalendar", Project.GetListCalendars(0), "CalendarName", "CalendarId"); // ProjectCurrency [3/30/2004] InsertDictionaryItemList(xmlDictionariesNode, "ProjectCurrency", Project.GetListCurrency(), "CurrencySymbol", "CurrencyId"); // ProjectManager [3/30/2004] XmlNode xmlManagersNode = xmlDictionariesList.CreateElement("ProjectManager"); if (Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager)) { using (IDataReader iManagers = SecureGroup.GetListAllUsersInGroup((int)InternalSecureGroups.ProjectManager)) { while (iManagers.Read()) { InsertUserInformation(xmlManagersNode, (int)iManagers["UserId"]); } iManagers.Close(); } } else { InsertUserInformation(xmlManagersNode, Security.CurrentUser.UserID); } xmlDictionariesNode.AppendChild(xmlManagersNode); // ExecutiveManager [3/30/2004] XmlNode xmlExManagersNode = xmlDictionariesList.CreateElement("ExecutiveManager"); using (IDataReader iExManagers = SecureGroup.GetListAllUsersInGroup((int)InternalSecureGroups.ProjectManager)) { while (iExManagers.Read()) { InsertUserInformation(xmlExManagersNode, (int)iExManagers["UserId"]); } iExManagers.Close(); } xmlDictionariesNode.AppendChild(xmlExManagersNode); // Templates [3/17/2005] InsertDictionaryItemList(xmlDictionariesNode, "ProjectTemplate", ProjectTemplate.GetListProjectTemplate(), "TemplateName", "TemplateId"); // Priority [3/17/2005] InsertDictionaryItemList(xmlDictionariesNode, "ProjectPriority", Project.GetListPriorities(), "PriorityName", "PriorityId"); // Portfolio [3/17/2005] InsertDictionaryItemList(xmlDictionariesNode, "ProjectPortfolio", ProjectGroup.GetProjectGroups(), "Title", "ProjectGroupId"); // Phases [3/24/2005] InsertDictionaryItemList(xmlDictionariesNode, "ProjectPhase", Project.GetListProjectPhases(), "PhaseName", "PhaseId"); // TimeTrackingTemplates [2008-10-29] InsertTimeTrackingTemplatesDictionaryItemList(xmlDictionariesNode, "TimeTrackingTemplates"); break; case ObjectTypes.List: /* * // Statuses [04/11/2005] * InsertDictionaryItemList(xmlDictionariesNode, "ListStatus", List.GetListStatus(), "StatusName", "StatusId"); * * // Types [04/11/2005] * InsertDictionaryItemList(xmlDictionariesNode, "ListType", List.GetListType(), "TypeName", "TypeId"); * * // Templates [04/11/2005] // TODO: move to business and use InsertDictionaryItemList instead * XmlNode xmlListTemplateRootNode = xmlDictionariesNode.OwnerDocument.CreateElement("ListTemplate"); * Mediachase.MetaDataPlus.Configurator.MetaClassCollection mcc = Mediachase.MetaDataPlus.Configurator.MetaClass.GetList(Mediachase.IBN.Business.List.ListTemplateRoot, true); * foreach (Mediachase.MetaDataPlus.Configurator.MetaClass mc in mcc) * { * XmlNode xmlDictionaryItemNode = xmlListTemplateRootNode.OwnerDocument.CreateElement("Item"); * XmlNode xmlValueNode = xmlListTemplateRootNode.OwnerDocument.CreateElement("Value"); * XmlNode xmlDataNode = xmlListTemplateRootNode.OwnerDocument.CreateElement("Data"); * * xmlValueNode.InnerText = mc.FriendlyName; * xmlDataNode.InnerText = mc.Id.ToString(); * * xmlDictionaryItemNode.AppendChild(xmlValueNode); * xmlDictionaryItemNode.AppendChild(xmlDataNode); * * xmlListTemplateRootNode.AppendChild(xmlDictionaryItemNode); * } * xmlDictionariesNode.AppendChild(xmlListTemplateRootNode); */ break; } return(xmlDictionariesList.InnerXml); }
private void BindValues() { DateTime dt = DateTime.Today.AddHours(DateTime.UtcNow.Hour + 1); dtcStartDate.SelectedDate = User.GetLocalDate(Security.CurrentUser.TimeZoneId, dt); if (Request["start"] != null) { try { dtcStartDate.SelectedDate = DateTime.Parse(Request["start"]); } catch { } } dtcEndDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(1); if (Request["end"] != null) { try { dtcEndDate.SelectedDate = DateTime.Parse(Request["end"]); } catch { } } if (Request["end"] == null && Request["start"] != null && dtcStartDate.SelectedDate.Hour == 0 && dtcEndDate.SelectedDate.Minute == 0) { dtcStartDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(8); dtcEndDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(1); } if (AutoInvite) { btnSaveAssign.Visible = false; } BindCategories(); ddlPriority.DataSource = CalendarEntry.GetListPriorities(); ddlPriority.DataTextField = "PriorityName"; ddlPriority.DataValueField = "PriorityId"; ddlPriority.DataBind(); ddlType.DataSource = CalendarEntry.GetListEventTypes(); ddlType.DataTextField = "TypeName"; ddlType.DataValueField = "TypeId"; ddlType.DataBind(); CommonHelper.SafeSelect(ddlType, ((int)CalendarEntry.EventType.Meeting).ToString()); if (Configuration.ProjectManagementEnabled) { ucProject.ObjectTypeId = (int)ObjectTypes.Project; ucProject.ObjectId = -1; if (ProjID != 0) { ucProject.ObjectId = ProjID; } } else { trProject.Visible = false; } if (EventID != 0) { using (IDataReader reader = CalendarEntry.GetEvent(EventID)) { if (reader.Read()) { DateTime StartDate = (DateTime)reader["StartDate"]; DateTime EndDate = (DateTime)reader["FinishDate"]; dtcStartDate.SelectedDate = StartDate; dtcEndDate.SelectedDate = EndDate; txtTitle.Text = HttpUtility.HtmlDecode(reader["Title"].ToString()); txtLocation.Text = HttpUtility.HtmlDecode(reader["Location"].ToString()); if (reader["Description"] != DBNull.Value) { txtDescription.Text = HttpUtility.HtmlDecode(reader["Description"].ToString()); } if (reader["ProjectId"] != DBNull.Value) { ucProject.ObjectId = (int)reader["ProjectId"]; } if (reader["PriorityId"] != DBNull.Value) { CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString()); //ListItem lItem = ddlPriority.Items.FindByValue(reader["PriorityId"].ToString()); //if (lItem != null) //{ // ddlPriority.ClearSelection(); // lItem.Selected = true; //} } if (reader["TypeId"] != DBNull.Value) { CommonHelper.SafeSelect(ddlType, reader["TypeId"].ToString()); //ListItem lItem = ddlType.Items.FindByValue(reader["TypeId"].ToString()); //if (lItem != null) //{ // ddlType.ClearSelection(); // lItem.Selected = true; //} } if ((int)reader["HasRecurrence"] == 1) { dtcStartDate.Enabled = false; dtcEndDate.Enabled = false; } if (reader["OrgUid"] != DBNull.Value) { ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["OrgUid"].ToString()); } else if (reader["ContactUid"] != DBNull.Value) { ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["ContactUid"].ToString()); } CommonHelper.SafeSelect(ManagerList, reader["ManagerId"].ToString()); } } using (IDataReader reader = CalendarEntry.GetListCategories(EventID)) { while (reader.Read()) { for (int i = 0; i < lbCategory.Items.Count; i++) { CommonHelper.SafeMultipleSelect(lbCategory, reader["CategoryId"].ToString()); //ListItem lItem = lbCategory.Items.FindByText(reader["CategoryName"].ToString()); //if (lItem != null) lItem.Selected = true; } } } EditControl.ObjectId = EventID; EditControl.BindData(); } else //CREATE { CommonHelper.SafeSelect(ddlPriority, PortalConfig.CEntryDefaultValuePriorityField); ArrayList list = Common.StringToArrayList(PortalConfig.CEntryDefaultValueGeneralCategoriesField); foreach (int i in list) { CommonHelper.SafeMultipleSelect(lbCategory, i.ToString()); } PrimaryKeyId org_id = PrimaryKeyId.Empty; PrimaryKeyId contact_id = PrimaryKeyId.Empty; Common.GetDefaultClient(PortalConfig.CEntryDefaultValueClientField, out contact_id, out org_id); if (contact_id != PrimaryKeyId.Empty) { ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = contact_id; } else if (org_id != PrimaryKeyId.Empty) { ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = org_id; } CommonHelper.SafeSelect(ManagerList, Security.CurrentUser.UserID.ToString()); } }