private int GetTaskTime() { int minutes = 0; if (TaskId > 0) { using (IDataReader reader = Task.GetTask(TaskId, false)) { if (reader.Read()) { minutes = (int)reader["TaskTime"]; } } } if (IncidentId > 0) { using (IDataReader reader = Incident.GetIncident(IncidentId, false)) { if (reader.Read()) { minutes = (int)reader["TaskTime"]; } } } if (DocumentId > 0) { using (IDataReader reader = Document.GetDocument(DocumentId, false)) { if (reader.Read()) { minutes = (int)reader["TaskTime"]; } } } if (EventId > 0) { using (IDataReader reader = CalendarEntry.GetEvent(EventId, false)) { if (reader.Read()) { minutes = (int)reader["TaskTime"]; } } } if (ToDoId > 0) { using (IDataReader reader = Mediachase.IBN.Business.ToDo.GetToDo(ToDoId, false)) { if (reader.Read()) { minutes = (int)reader["TaskTime"]; } } } return(minutes); }
private void BindGroups() { ddGroups.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Common", "FavoritesGroup").ToString(), "0")); int ProjectId = -1; using (IDataReader reader = CalendarEntry.GetEvent(EventID, false)) { if (reader.Read()) { if (reader["ProjectId"] != DBNull.Value) { ProjectId = (int)reader["ProjectId"]; } } } if (ProjectId > 0) { int pID = -ProjectId; ddGroups.Items.Add(new ListItem(LocRM.GetString("ProjectTeam"), pID.ToString())); } DataTable dt = SecureGroup.GetListGroupsAsTreeDataTable(); foreach (DataRow row in dt.Rows) { ddGroups.Items.Add(new ListItem(HttpUtility.HtmlEncode(CommonHelper.GetResFileString(row["GroupName"].ToString())), row["GroupId"].ToString())); } /* * using (IDataReader reader = SecureGroup.GetListGroupsAsTree()) * { * while (reader.Read()) * { * string GroupName = CommonHelper.GetResFileString(reader["GroupName"].ToString()); * string GroupId = reader["GroupId"].ToString(); * int Level = (int)reader["Level"]; * for (int i = 1; i < Level; i++) * GroupName = " " + GroupName; * ListItem item = new ListItem(GroupName, GroupId); * * ddGroups.Items.Add(item); * } * } */ ListItem li = ddGroups.SelectedItem; if (li != null) { BindGroupUsers(int.Parse(li.Value)); } }
private void DefineParentProjectId() { if (ProjectId > 0) { ParentProjectId = ProjectId; } else if (TaskId > 0) { ParentProjectId = Task.GetProject(TaskId); } else if (IncidentId > 0) { using (IDataReader reader = Incident.GetIncident(IncidentId)) { if (reader.Read() && reader["ProjectId"] != DBNull.Value) { ParentProjectId = (int)reader["ProjectId"]; } } } else if (DocumentId > 0) { using (IDataReader reader = Document.GetDocument(DocumentId)) { if (reader.Read() && reader["ProjectId"] != DBNull.Value) { ParentProjectId = (int)reader["ProjectId"]; } } } else if (EventId > 0) { using (IDataReader reader = CalendarEntry.GetEvent(EventId)) { if (reader.Read() && reader["ProjectId"] != DBNull.Value) { ParentProjectId = (int)reader["ProjectId"]; } } } else if (ToDoId > 0) { using (IDataReader reader = ToDo.GetToDo(ToDoId)) { if (reader.Read() && reader["ProjectId"] != DBNull.Value) { ParentProjectId = (int)reader["ProjectId"]; } } } }
private void BinddgMembers() { dt = CalendarEntry.GetListEventResourcesDataTable(EventID); bool isinres = false; int _UserID = 0; using (IDataReader rdr = CalendarEntry.GetEvent(EventID)) { if (rdr.Read()) { _UserID = (int)rdr["ManagerId"]; } } foreach (DataRow dr in dt.Rows) { if ((int)dr["PrincipalId"] == _UserID) { isinres = true; } } if (!isinres) { DataRow dr = dt.NewRow(); dr["PrincipalId"] = _UserID; dr["IsGroup"] = false; dr["MustBeConfirmed"] = false; dr["ResponsePending"] = false; dt.Rows.InsertAt(dr, 0); } dgMembers.DataSource = dt; dgMembers.DataBind(); }
private void GetEventData() { int UserID = 0; using (IDataReader rdr = CalendarEntry.GetEvent(EventID)) { if (rdr.Read()) { UserID = (int)rdr["ManagerId"]; } } DataTable dt = CalendarEntry.GetListEventResourcesDataTable(EventID); bool isinres = false; foreach (DataRow dr in dt.Rows) { if ((int)dr["PrincipalId"] == UserID) { isinres = true; } } if (!isinres) { DataRow dr = dt.NewRow(); dr["PrincipalId"] = UserID; dr["IsGroup"] = false; dr["MustBeConfirmed"] = false; dr["ResponsePending"] = false; dt.Rows.InsertAt(dr, 0); } ViewState["Participants"] = dt; }
private void BindValues() { using (IDataReader reader = CalendarEntry.GetRecurrence(EventId)) { if (reader.Read()) { lblNoRecurrence.Visible = false; ShowRecurrence.Visible = true; DateTime dt = DateTime.MinValue.AddMinutes((int)reader["StartTime"]); txtStartTime.Text = dt.ToShortTimeString(); dt = DateTime.MinValue.AddMinutes((int)reader["EndTime"]); txtEndTime.Text = dt.ToShortTimeString(); Pattern = (byte)reader["Pattern"]; SubPattern = (byte)reader["SubPattern"]; Frequency = (byte)reader["Frequency"]; bWeekdays = (byte)reader["Weekdays"]; MonthDay = (byte)reader["DayOfMonth"]; bWeekNumber = (byte)reader["WeekNumber"]; MonthNumber = (byte)reader["MonthNumber"]; EndAfter = (int)reader["EndAfter"]; Label lblControl = (Label)this.FindControl("txtInfo" + Pattern + SubPattern); if (lblControl != null) { lblControl.Visible = true; } if (EndAfter != 0) { lblEnd.Text = LocRM.GetString("Endafter") + ":"; txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences"); } else { using (IDataReader rdr = CalendarEntry.GetEvent(EventId)) { if (rdr.Read()) { lblEnd.Text = LocRM.GetString("Endby") + ":"; txtEnd.Text = ((DateTime)rdr["FinishDate"]).ToShortDateString(); } } } if (reader["TimeZoneId"] != DBNull.Value) { TimeSpan Offset = new TimeSpan(0, -User.GetTimeZoneBias((int)reader["TimeZoneId"]), 0); txtTimeZone.Text = "GMT "; if (Offset.TotalMinutes != 0) { string str = ""; str += (Offset.TotalMinutes > 0) ? "+" : "-"; if (Math.Abs(Offset.Hours) < 10) { str += "0"; } str += Math.Abs(Offset.Hours).ToString() + ":"; if (Math.Abs(Offset.Minutes) < 10) { str += "0"; } str += Math.Abs(Offset.Minutes).ToString(); txtTimeZone.Text += str; } } } else { lblNoRecurrence.Text = "<br> " + LocRM.GetString("NotSet") + "<br> "; lblNoRecurrence.Visible = true; ShowRecurrence.Visible = false; } } DataBind(); }
private void BindData() { try { using (IDataReader rdr = CalendarEntry.GetEvent(EventID)) { /// EventId, ProjectId, ProjectTitle, CreatorId, ManagerId, /// Title, Description, Location, CreationDate, StartDate, /// FinishDate, PriorityId, PriorityName, TypeId, TypeName, ReminderInterval, HasRecurrence if (rdr.Read()) { lblTitle.Text = (string)rdr["Title"]; if (Configuration.ProjectManagementEnabled) { if (rdr["ProjectId"] != DBNull.Value) { if (Project.CanRead((int)rdr["ProjectId"])) { lblProject.Text = "<a href='../Projects/ProjectView.aspx?ProjectID=" + (int)rdr["ProjectId"] + "'>" + (string)rdr["ProjectTitle"] + "</a>"; } else { lblProject.Text = (string)rdr["ProjectTitle"]; } } else { lblProject.Text = LocRM.GetString("tNotSet"); } } else { tdPrjLabel.Visible = false; tdPrjName.Visible = false; } lblLocation.Text = (string)rdr["Location"]; lblPriority.Text = (string)rdr["PriorityName"]; lblType.Text = (string)rdr["TypeName"]; lblManager.Text = CommonHelper.GetUserStatus((int)rdr["ManagerId"]); lblCreated.Text = CommonHelper.GetUserStatus((int)rdr["CreatorId"]) + " " + ((DateTime)rdr["CreationDate"]).ToShortDateString() + " " + ((DateTime)rdr["CreationDate"]).ToShortTimeString(); TargetStartDate = (DateTime)rdr["StartDate"]; TargetFinishDate = (DateTime)rdr["FinishDate"]; lblStartDate.Text = TargetStartDate.ToShortDateString() + " " + TargetStartDate.ToShortTimeString(); lblEndDate.Text = TargetFinishDate.ToShortDateString() + " " + TargetFinishDate.ToShortTimeString(); lblDescription.Text = CommonHelper.parsetext((string)rdr["Description"], false); HasRecurrence = ((int)rdr["HasRecurrence"] == 1); lblClient.Text = Util.CommonHelper.GetClientLink(this.Page, rdr["OrgUid"], rdr["ContactUid"], rdr["ClientName"]); } else { Response.Redirect("../Common/NotExistingID.aspx?EventID=1"); } } } catch (AccessDeniedException) { Response.Redirect("~/Common/NotExistingID.aspx?AD=1"); } using (IDataReader rdr = CalendarEntry.GetListCategories(EventID)) { string categories = ""; while (rdr.Read()) { if (categories != "") { categories += ", "; } categories += (string)rdr["CategoryName"]; } lblCategory.Text = categories; } tdPriority.Visible = tdPriority2.Visible = PortalConfig.CommonCEntryAllowViewPriorityField; tdCategories.Visible = tdCategories2.Visible = PortalConfig.CommonCEntryAllowViewGeneralCategoriesField; tdClient.Visible = tdClient2.Visible = PortalConfig.CommonCEntryAllowViewClientField; trCategoriesClient.Visible = tdCategories.Visible || tdClient.Visible; }
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()); } }
internal static void UpdateTimeline(int eventId, DateTime startDate, DateTime finishDate, bool checkAccess) { if (checkAccess) { VerifyCanUpdate(eventId); } int TimeZoneId = Security.CurrentUser.TimeZoneId; startDate = DBCommon.GetUTCDate(TimeZoneId, startDate); finishDate = DBCommon.GetUTCDate(TimeZoneId, finishDate); int projectId = -1; bool hasRecurrence = false; using (IDataReader reader = CalendarEntry.GetEvent(eventId, false)) { if (reader.Read()) { if (reader["ProjectId"] != DBNull.Value) { projectId = (int)reader["ProjectId"]; } hasRecurrence = ((int)reader["HasRecurrence"] == 1); } } // O.R. [2009-12-18] Dates for recurrent events should be chnaged in recurrence editing. if (hasRecurrence) { return; } TimeSpan ts = finishDate.Subtract(startDate); int taskTime = (int)ts.TotalMinutes; using (DbTransaction tran = DbTransaction.Begin()) { int retVal = DbCalendarEntry2.UpdateTimeline(eventId, startDate, finishDate, taskTime); if (retVal > 0) { SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_Timeline, eventId); if (!hasRecurrence) { if (retVal == 1 || retVal == 3) { Schedule.UpdateDateTypeValue(DateTypes.CalendarEntry_StartDate, eventId, startDate); } if (retVal == 2 || retVal == 3) { Schedule.UpdateDateTypeValue(DateTypes.CalendarEntry_FinishDate, eventId, finishDate); } } else { // O.R.[2009-09-29]: Recalculate events dates for scheduling Schedule.DeleteDateTypeValue(DateTypes.CalendarEntry_StartDate, eventId); Schedule.DeleteDateTypeValue(DateTypes.CalendarEntry_FinishDate, eventId); int ReminderInterval; Hashtable ret = CalendarEntry.GetEventInstances(eventId, out ReminderInterval); foreach (DateTime dtStart in ret.Keys) { DateTime dtEnd = (DateTime)ret[dtStart]; if (dtStart > DateTime.UtcNow && dtEnd > DateTime.UtcNow) { DbSchedule2.AddNewDateTypeValue((int)DateTypes.CalendarEntry_StartDate, eventId, dtStart); DbSchedule2.AddNewDateTypeValue((int)DateTypes.CalendarEntry_FinishDate, eventId, dtEnd); } } } // O.R: Recalculating project TaskTime if (projectId > 0) { TimeTracking.RecalculateProjectTaskTime(projectId); } } CalendarEntry.RecalculateState(eventId); tran.Commit(); } }
private void BindData() { /// EventId, ProjectId, ProjectTitle, CreatorId, ManagerId, /// Title, Description, Location, CreationDate, StartDate, /// FinishDate, PriorityId, PriorityName, TypeId, TypeName, ReminderInterval, HasRecurrence try { using (IDataReader rdr = CalendarEntry.GetEvent(EventID)) { if (rdr.Read()) { if (rdr["ProjectId"] != DBNull.Value) { if (Project.CanRead((int)rdr["ProjectId"])) { lblTitle.Text = String.Format("<a href='../Projects/ProjectView.aspx?ProjectId={0}'>{1}</a>", rdr["ProjectId"].ToString(), rdr["ProjectTitle"].ToString()); } else { lblTitle.Text = rdr["ProjectTitle"].ToString(); } lblTitle.Text += " > "; } lblTitle.Text += rdr["Title"].ToString(); if (rdr["Description"] != DBNull.Value) { string txt = CommonHelper.parsetext(rdr["Description"].ToString(), false); if (PortalConfig.ShortInfoDescriptionLength > 0 && txt.Length > PortalConfig.ShortInfoDescriptionLength) { txt = txt.Substring(0, PortalConfig.ShortInfoDescriptionLength) + "..."; } lblDescription.Text = txt; } lblType.Text = rdr["TypeName"].ToString(); lblPriority.Text = rdr["PriorityName"].ToString() + " " + LocRM.GetString("Priority").ToLower(); lblPriority.ForeColor = Util.CommonHelper.GetPriorityColor((int)rdr["PriorityId"]); lblPriority.Visible = PortalConfig.CommonCEntryAllowViewPriorityField; lblState.ForeColor = Util.CommonHelper.GetStateColor((int)rdr["StateId"]); lblState.Text = rdr["StateName"].ToString(); lblStartDate.Text = ((DateTime)rdr["StartDate"]).ToShortDateString() + " " + ((DateTime)rdr["StartDate"]).ToShortTimeString(); lblEndDate.Text = ((DateTime)rdr["FinishDate"]).ToShortDateString() + " " + ((DateTime)rdr["FinishDate"]).ToShortTimeString(); if ((int)rdr["HasRecurrence"] == 1) { TimeSpan Offset = new TimeSpan(0, -User.GetTimeZoneBias(Security.CurrentUser.TimeZoneId), 0); lblTimeZone.Text = "(GMT "; if (Offset.TotalMinutes != 0) { string str = ""; str += (Offset.TotalMinutes > 0) ? "+" : "-"; if (Math.Abs(Offset.Hours) < 10) { str += "0"; } str += Math.Abs(Offset.Hours).ToString() + ":"; if (Math.Abs(Offset.Minutes) < 10) { str += "0"; } str += Math.Abs(Offset.Minutes).ToString(); lblTimeZone.Text += str + ")"; } } } else { Response.Redirect("../Common/NotExistingID.aspx?EventID=1"); } } } catch (AccessDeniedException) { Response.Redirect("~/Common/NotExistingID.aspx?AD=1"); } }