コード例 #1
0
        public List <Statistic> GetStatisticDisplayData(string value, string value1)
        {
            DataTable dt = null;

            var distinctFieldValues = GetData(value, value1);

            foreach (var key in distinctFieldValues)
            {
                var dataView = AllDataRows.DefaultView;
                if (key != "All")
                {
                    dataView.RowFilter = groupOn + " = '" + key + "'";
                }

                dt = dataView.ToTable();

                var statData = ScheduleDataManager.GetStatisticData(dt, ScheduleDataModel.DataColumns.ScheduleTimeSpentConstant, ApplicationCommon.ScheduleStatisticUnknown);

                statData.CountPercentage = (statData.Count / totalCount) * 100;

                statData.TotalPercentage = (statData.Total / totalHoursWorkedForGroup) * 100;

                lstStat.Add(statData);
            }
            Statistic summaryStat = new Statistic();

            summaryStat = GetSummaryLine(lstStat);
            if (summaryStat != null)
            {
                summaryStat.Name = "Summary";
                lstStat.Add(summaryStat);
            }
            return(lstStat);
        }
コード例 #2
0
        public void SetScheduleEmailTemplate(bool isPreview)
        {
            var stream = System.Web.HttpContext.Current.Server.MapPath("~/Templates/" + "ScheduleEmailTemplate.html");

            using (var reader = new StreamReader(stream))
            {
                ScheduleEmailTemplate = reader.ReadToEnd();
            }

            if (!isPreview)
            {
                ScheduleEmailTemplate = ScheduleEmailTemplate.Replace("##CellTableBorder##", "none");
                ScheduleEmailTemplate = ScheduleEmailTemplate.Replace("##CellTableWidth##", "0");
            }
            else
            {
                ScheduleEmailTemplate = ScheduleEmailTemplate.Replace("##CellTableBorder##", "solid");
                ScheduleEmailTemplate = ScheduleEmailTemplate.Replace("##CellTableWidth##", "1");
            }

            var dt = ScheduleDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            foreach (DataRow row in dt.Rows)
            {
                var scheduleId = Convert.ToInt32(row[0]);
                SendMail(scheduleId, ScheduleEmailTemplate, txtEmailAddress.Text, txtCCAddress.Text, ConfigurationManager.AppSettings["fromEmail"], isPreview, SessionVariables.RequestProfile);
                if (isPreview)
                {
                    break;
                }
            }
        }
コード例 #3
0
        private void SetupDropdown()
        {
            var isTesting = SessionVariables.IsTesting;

            var scheduleData = ScheduleDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(scheduleData, drpScheduleList, ScheduleDataModel.DataColumns.ScheduleId,
                                  ScheduleDataModel.DataColumns.ScheduleId);

            var categoryData = ScheduleDetailActivityCategoryDataManager.GetList(SessionVariables.RequestProfile);

            UIHelper.LoadDropDown(categoryData, drpScheduleDetailActivityCategoryList, ScheduleDetailActivityCategoryDataModel.DataColumns.Name,
                                  ScheduleDetailActivityCategoryDataModel.DataColumns.ScheduleDetailActivityCategoryId);

            if (isTesting)
            {
                drpScheduleList.AutoPostBack = true;
                drpScheduleDetailActivityCategoryList.AutoPostBack = true;

                if (drpScheduleList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtScheduleId.Text.Trim()))
                    {
                        drpScheduleList.SelectedValue = txtScheduleId.Text;
                    }
                    else
                    {
                        txtScheduleId.Text = drpScheduleList.SelectedItem.Value;
                    }
                }

                if (drpScheduleDetailActivityCategoryList.Items.Count > 0)
                {
                    if (!string.IsNullOrEmpty(txtScheduleDetailActivityCategoryId.Text.Trim()))
                    {
                        drpScheduleDetailActivityCategoryList.SelectedValue = txtScheduleDetailActivityCategoryId.Text;
                    }
                    else
                    {
                        txtScheduleDetailActivityCategoryId.Text = drpScheduleDetailActivityCategoryList.SelectedItem.Value;
                    }
                }

                txtScheduleDetailActivityCategoryId.Visible = true;
                txtScheduleId.Visible = true;
            }
            else
            {
                if (!string.IsNullOrEmpty(txtScheduleId.Text.Trim()))
                {
                    drpScheduleList.SelectedValue = txtScheduleId.Text;
                }

                if (!string.IsNullOrEmpty(txtScheduleDetailActivityCategoryId.Text.Trim()))
                {
                    drpScheduleDetailActivityCategoryList.SelectedValue = txtScheduleDetailActivityCategoryId.Text;
                }
            }
        }
コード例 #4
0
        protected override DataTable GetEntityData(int?entityKey)
        {
            var scheduledata = new ScheduleDataModel();

            scheduledata.ScheduleId = entityKey;
            var results = ScheduleDataManager.Search(scheduledata, SessionVariables.RequestProfile);

            return(results);
        }
コード例 #5
0
        private DataTable GetData()
        {
            // TODO: on all export pages
            var data = new ScheduleDataModel();

            var dt = ScheduleDataManager.Search(data, SessionVariables.RequestProfile);

            return(dt);
        }
コード例 #6
0
        public override int?Save(string action)
        {
            var data = new ScheduleDataModel();

            data.ScheduleId       = ScheduleId;
            data.Person           = PersonId.ToString();
            data.ScheduleStateId  = ScheduleStateId;
            data.WorkDate         = WorkDate;
            data.StartTime        = StartTime;
            data.EndTime          = EndTime;
            data.NextWorkDate     = NextWorkDate;
            data.NextWorkTime     = NextWorkTime;
            data.TotalHoursWorked = TotalHoursWorked;
            data.PlannedHours     = PlannedHours;
            data.FromSearchDate   = WorkDate;
            data.ToSearchDate     = WorkDate;

            if (NextWorkDate < WorkDate)
            {
                throw new Exception("Next Work Date should always be greater than Work Date.");
            }
            else if (StartTime > EndTime && EndTime != WorkDate) // JIRA #4097 validation
            {
                throw new Exception("End Time should always be greater than Start Time");
            }
            else
            {
                if (action == "Insert")
                {
                    var dtSchedule = ScheduleDataManager.DoesExist(data, SessionVariables.RequestProfile);

                    if (dtSchedule.Rows.Count == 0)
                    {
                        // create method itself will return newly created schedule Id
                        var scheduleId = ScheduleDataManager.Create(data, SessionVariables.RequestProfile);
                        data.ScheduleId = scheduleId;

                        // add default schedule questions
                        ApplicationContainer.UI.Web.App_Workflow.ScheduleWorkflow.AddScheduleQuestions(scheduleId, SessionVariables.RequestProfile);
                    }
                    else
                    {
                        throw new Exception("Record with given ID already exists.");
                    }
                }
                else
                {
                    data.CreatedDate = CreatedDate;
                    ScheduleDataManager.Update(data, SessionVariables.RequestProfile);
                }
            }

            // not correct ... when doing insert, we didn't get/change the value of ScheduleID ?
            return(data.ScheduleId);
        }
コード例 #7
0
        public DataTable GroupByYear()
        {
            SessionVariables.RequestProfile.AuditId = 200;
            var dt = ScheduleDataManager.GetList(SessionVariables.RequestProfile);

            var workSummary = from eschedule in dt.AsEnumerable()

                              let WorkDate = eschedule.Field <DateTime>("WorkDate")

                                             group eschedule by new { Year = WorkDate.Year } into wsum

                select new

            {
                Year = wsum.Key.Year,

                Duration = wsum.Sum(eschedule => eschedule.Field <decimal>("TotalHoursWorked")),


                AvgStartTime = wsum.Average(eschedule => decimal.Round(Convert.ToDecimal(eschedule.Field <DateTime>("StartTime").Hour + "." + eschedule.Field <DateTime>("StartTime").Minute), 2)),

                AvgEndTime = wsum.Average(eschedule => decimal.Round(Convert.ToDecimal(eschedule.Field <DateTime>("EndTime").Hour + "." + eschedule.Field <DateTime>("EndTime").Minute), 2)),
            };

            var _dt    = new DataTable();
            var values = new object[4];

            _dt.Columns.Add("Year");
            _dt.Columns.Add("Duration");
            _dt.Columns.Add("AverageStartTime");
            _dt.Columns.Add("AverageEndTime");
            foreach (var VARIABLE in workSummary)
            {
                var year      = VARIABLE.GetType().GetProperty("Year").GetValue(VARIABLE, null).ToString();
                var noofhours = VARIABLE.GetType().GetProperty("Duration").GetValue(VARIABLE, null).ToString();
                var starttime = decimal.Round(decimal.Parse(VARIABLE.GetType().GetProperty("AvgStartTime").GetValue(VARIABLE, null).ToString()), 2).ToString();
                var endtime   = decimal.Round(decimal.Parse(VARIABLE.GetType().GetProperty("AvgEndTime").GetValue(VARIABLE, null).ToString()), 2).ToString();

                values[0] = year;
                values[1] = noofhours;
                values[2] = starttime;
                values[3] = endtime;

                _dt.Rows.Add(values);
            }

            _dt.DefaultView.Sort = "Year ASC";
            return(_dt.DefaultView.ToTable());
        }
コード例 #8
0
        public string GroupByPerson()
        {
            SessionVariables.RequestProfile.AuditId = 200;
            var dt = ScheduleDataManager.GetList(SessionVariables.RequestProfile);

            var workSummary = from eschedule in dt.AsEnumerable()

                              group eschedule by new { PersonId = eschedule.Field <int>("PersonId") } into wsum

                select new

            {
                PersonId = wsum.Key.PersonId,

                Duration = wsum.Sum(eschedule => eschedule.Field <decimal>("TotalHoursWorked")),

                //AvgStartTime = decimal.Round(wsum.Average(eschedule => eschedule.Field<decimal>("StartTime")), 2),
                AvgStartTime = wsum.Average(eschedule => decimal.Round(Convert.ToDecimal(eschedule.Field <DateTime>("StartTime").Hour + "." + eschedule.Field <DateTime>("StartTime").Minute), 2)),

                //AvgEndTime = decimal.Round(wsum.Average(eschedule => eschedule.Field<decimal>("EndTime")), 2)
                AvgEndTime = wsum.Average(eschedule => decimal.Round(Convert.ToDecimal(eschedule.Field <DateTime>("EndTime").Hour + "." + eschedule.Field <DateTime>("EndTime").Minute), 2)),
            };

            foreach (var VARIABLE in workSummary)
            {
                var personId  = VARIABLE.GetType().GetProperty("PersonId").GetValue(VARIABLE, null).ToString();
                var noofhours = VARIABLE.GetType().GetProperty("Duration").GetValue(VARIABLE, null).ToString();
                var starttime = VARIABLE.GetType().GetProperty("AvgStartTime").GetValue(VARIABLE, null).ToString();
                var endtime   = VARIABLE.GetType().GetProperty("AvgEndTime").GetValue(VARIABLE, null).ToString();


                if (int.Parse(personId) != 0)
                {
                    var personData = ApplicationUserDataManager.GetList(SessionVariables.RequestProfile);
                    var fullname   = (from DataRow dr in personData.Rows
                                      where (int)dr["ApplicationUserId"] == int.Parse(personId)
                                      select(string) dr["FullName"]).FirstOrDefault();

                    var summary = "Person " + fullname + "'s Total Hours Worked: " + noofhours +
                                  "hours,  Average Start Time: " + starttime +
                                  " hours,  Average End Time: " + endtime +
                                  " hours.";
                    RaiseSearch();

                    return(summary);
                }
            }
            return("");
        }
コード例 #9
0
        public bool UpdateBuildingAnnotationFamily()
        {
            var result = false;

            try
            {
                var scheduleManager    = new ScheduleDataManager(m_app, CalculationTypes.BuildingArea);
                var category           = scheduleManager.GetLPDCategoryBAM();
                var allowableLPD       = scheduleManager.GetAllowableLPDBAM();
                var targetLPD          = scheduleManager.GetTargetLPDBAM();
                var actualLightingLoad = scheduleManager.GetActualLightingLoad();
                var area      = scheduleManager.GetArea();
                var actualLPD = actualLightingLoad / area;
                var reduction = 1 - (actualLPD / allowableLPD);

                using (var trans = new Transaction(m_doc))
                {
                    try
                    {
                        trans.Start("Update Annotation");

                        var annotation = new AnnotationProperties(annotationType, CalculationTypes.BuildingArea)
                        {
                            ASHRAELPDCategory  = category,
                            ASHRAEAllowableLPD = allowableLPD,
                            TargetLPD          = targetLPD,
                            ActualLightingLoad = actualLightingLoad,
                            Area            = area,
                            ActualLPD       = actualLPD,
                            Reduction       = reduction,
                            LPDCalculatedBy = Environment.UserName
                        };

                        trans.Commit();
                    }
                    catch
                    {
                        trans.RollBack();
                    }
                }

                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to update annotation family.\n" + ex.Message, "Update Annotation Family", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(result);
        }
コード例 #10
0
        public void LoadData(int scheduleId, bool showId)
        {
            // clear UI

            Clear();

            var dataQuery = new ScheduleDataModel();

            dataQuery.ScheduleId = scheduleId;

            var items = ScheduleDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (items.Count != 1)
            {
                return;
            }

            var item = items[0];

            ScheduleId        = item.ScheduleId;
            PersonId          = item.PersonId;
            ScheduleStateId   = item.ScheduleStateId;
            WorkDate          = item.WorkDate;
            StartTime         = item.StartTime;
            EndTime           = item.EndTime;
            NextWorkDate      = item.NextWorkDate;
            NextWorkTime      = item.NextWorkTime;
            TotalHoursWorked  = item.TotalHoursWorked;
            PlannedHours      = item.PlannedHours;
            CreatedByAuditId  = item.CreatedByAuditId;
            ModifiedByAuditId = item.ModifiedByAuditId;
            CreatedDate       = item.CreatedDate;
            ModifiedDate      = item.ModifiedDate;

            if (!showId)
            {
                txtScheduleId.Text = item.ScheduleId.ToString();

                // only show Audit History in case of Update page, not for Clone.
                oHistoryList.Setup((int)SystemEntity.Schedule, scheduleId, "Schedule");
            }
            else
            {
                txtScheduleId.Text = String.Empty;
            }

            oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction);
        }
コード例 #11
0
        protected override void Update(Dictionary <string, string> values)
        {
            var data = new ScheduleDataModel();

            if (values.ContainsKey(ScheduleDataModel.DataColumns.ScheduleId))
            {
                data.ScheduleId = int.Parse(values[ScheduleDataModel.DataColumns.ScheduleId].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.PersonId))
            {
                data.PersonId = int.Parse(values[ScheduleDataModel.DataColumns.PersonId].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.WorkDate))
            {
                data.WorkDate = DateTime.Parse(values[ScheduleDataModel.DataColumns.WorkDate].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.StartTime))
            {
                data.StartTime = DateTime.Parse(values[ScheduleDataModel.DataColumns.StartTime].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.EndTime))
            {
                data.EndTime = DateTime.Parse(values[ScheduleDataModel.DataColumns.EndTime].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.TotalHoursWorked))
            {
                data.TotalHoursWorked = decimal.Parse(values[ScheduleDataModel.DataColumns.TotalHoursWorked].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.NextWorkDate))
            {
                data.NextWorkDate = DateTime.Parse(values[ScheduleDataModel.DataColumns.NextWorkDate].ToString());
            }

            if (values.ContainsKey(ScheduleDataModel.DataColumns.NextWorkTime))
            {
                data.NextWorkTime = DateTime.Parse(values[ScheduleDataModel.DataColumns.NextWorkTime].ToString());
            }

            ScheduleDataManager.Update(data, SessionVariables.RequestProfile);
            InlineEditingList.Data = GetData();
        }
コード例 #12
0
        public bool UpdateSpaceAnnotationFamily()
        {
            var result = false;

            try
            {
                var scheduleManager       = new ScheduleDataManager(m_app, CalculationTypes.SpaceBySpace);
                var allowableLightingLoad = scheduleManager.GetAllowableLightingLoad();
                var actualLightingLoad    = scheduleManager.GetActualLightingLoad();
                var savings   = scheduleManager.GetSavings();
                var area      = scheduleManager.GetArea();
                var actualLPD = actualLightingLoad / area;
                var reduction = savings / allowableLightingLoad;

                using (var trans = new Transaction(m_doc))
                {
                    try
                    {
                        trans.Start("Update Annotation");

                        var annotation = new AnnotationProperties(annotationType, CalculationTypes.SpaceBySpace)
                        {
                            TotalAllowableLightingLoad = allowableLightingLoad,
                            TotalActualLightingLoad    = actualLightingLoad,
                            TotalSavingsOverage        = savings,
                            Area            = area,
                            ActualLPD       = actualLPD,
                            Reduction       = reduction,
                            LPDCalculatedBy = Environment.UserName
                        };

                        trans.Commit();
                    }
                    catch
                    {
                        trans.RollBack();
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to update annotation family.\n" + ex.Message, "Update Annotation Family", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(result);
        }
コード例 #13
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         var      notDeletableIds = new List <int>();
         string[] deleteIndexList = DeleteIds.Split(',');
         foreach (string index in deleteIndexList)
         {
             var data = new ScheduleDataModel();
             data.ScheduleId = int.Parse(index);
             if (!ScheduleDataManager.IsDeletable(data, SessionVariables.RequestProfile))
             {
                 notDeletableIds.Add(Convert.ToInt32(data.ScheduleId));
             }
         }
         if (notDeletableIds.Count == 0)
         {
             foreach (string index in deleteIndexList)
             {
                 var data = new ScheduleDataModel();
                 data.ScheduleId = int.Parse(index);
                 ScheduleDataManager.Delete(data, SessionVariables.RequestProfile);
             }
             DeleteAndRedirect();
         }
         else
         {
             var msg = String.Empty;
             foreach (var id in notDeletableIds)
             {
                 if (!string.IsNullOrEmpty(msg))
                 {
                     msg += ", <br/>";
                 }
                 msg += "ScheduleId: " + id + " has detail records";
             }
             Response.Write(msg);
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var UpdatedData = new DataTable();

            UpdatedData = ScheduleDataManager.GetSampleSearch();
            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("myfile.csv"));

            foreach (var col in UpdatedData.Columns)
            {
                sw.Write(col.ToString() + ",");
            }
            sw.WriteLine();

            for (int i = 0; i < UpdatedData.Rows.Count; i++)
            {
                DataRow row = UpdatedData.Rows[i];

                for (int j = 0; j < row.ItemArray.Length; j++)
                {
                    if (row.ItemArray[j] != null && !Convert.IsDBNull(row.ItemArray[j]))
                    {
                        sw.Write(row.ItemArray[j].ToString());
                    }
                    else
                    {
                        sw.Write("");
                    }

                    if (j < row.ItemArray.Length - 1)
                    {
                        sw.Write(",");
                    }
                    else if (i < UpdatedData.Rows.Count)
                    {
                        sw.WriteLine();
                    }
                }
            }
            sw.Close();
        }
コード例 #15
0
        protected override void ShowData(int scheduleId)
        {
            base.ShowData(scheduleId);

            oDetailButtonPanel.SetId = SetId;

            Clear();

            var dataQuery = new ScheduleDataModel();

            dataQuery.ScheduleId = scheduleId;

            var entityList = ScheduleDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile);

            if (entityList.Count == 1)
            {
                foreach (var entityItem in entityList)
                {
                    lblScheduleId.Text        = entityItem.ScheduleId.ToString();
                    lblPersonId.Text          = entityItem.Person.ToString();
                    lblScheduleState.Text     = entityItem.ScheduleStateName.ToString();
                    lblWorkDate.Text          = String.Format("{0:d}", entityItem.WorkDate);
                    lblStartTime.Text         = String.Format("{0:t}", entityItem.StartTime);
                    lblEndTime.Text           = String.Format("{0:t}", entityItem.EndTime);
                    lblNextWorkTime.Text      = String.Format("{0:t}", entityItem.NextWorkTime);
                    lblNextWorkDate.Text      = String.Format("{0:d}", entityItem.NextWorkDate);
                    lblTotalHoursWorked.Text  = entityItem.TotalHoursWorked.ToString();
                    lblPlannedHours.Text      = entityItem.PlannedHours.ToString();
                    lblCreatedByAuditId.Text  = entityItem.CreatedByAuditId.ToString();
                    lblModifiedByAuditId.Text = entityItem.ModifiedByAuditId.ToString();
                    lblCreatedDate.Text       = entityItem.CreatedDate.Value.ToString(SessionVariables.UserDateFormat);
                    lblModifiedDate.Text      = entityItem.ModifiedDate.Value.ToString(SessionVariables.UserDateFormat);

                    oUpdateInfo.LoadText(entityItem.UpdatedDate, entityItem.UpdatedBy, entityItem.LastAction);

                    oHistoryList.Setup(PrimaryEntity, scheduleId, "Schedule");
                }
            }
        }
コード例 #16
0
        public void GetPlannedData(RequestProfile requestProfile)
        {
            var dtNow = DateTime.Now;

            var fromDate = dtNow.AddDays(-30).Date;
            var toDate   = dtNow.Date;

            var data = new ScheduleDataModel();

            data.FromSearchDate = fromDate;
            data.ToSearchDate   = toDate;
            data.Person         = personId.ToString();
            var dt = ScheduleDataManager.Search(data, requestProfile);

            var plannedHrsData = from row in dt.AsEnumerable()
                                 select dt.AsEnumerable().Average(x => Convert.ToDecimal(x[ScheduleDataModel.DataColumns.TotalHoursWorked]));

            var rowItem = from rowPK in plannedHrsData.AsEnumerable() select rowPK;

            var nextPlannedTimeData = dt.AsEnumerable().OrderBy(x => x[ScheduleDataModel.DataColumns.NextWorkTime]).Last();

            var nextPlannedTime = Convert.ToDateTime(nextPlannedTimeData[ScheduleDataModel.DataColumns.NextWorkTime]).ToShortTimeString();

            var nextPlannedHrs = Convert.ToDecimal(nextPlannedTimeData[ScheduleDataModel.DataColumns.PlannedHours]);

            plannedHrs = nextPlannedHrs.ToString() + '/' + rowItem.First().ToString("#0,0.00");

            double totalSec = 0;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                TimeSpan ts = new TimeSpan(Convert.ToDateTime(Convert.ToDateTime(dt.Rows[i][ScheduleDataModel.DataColumns.StartTime]).ToShortTimeString()).Ticks);
                totalSec += ts.TotalSeconds;
            }

            double averageSec = totalSec / dt.Rows.Count;

            plannedTime = nextPlannedTime + '/' + DateTime.MinValue.AddSeconds(averageSec).ToShortTimeString();
        }
コード例 #17
0
        protected override DataTable GetData()
        {
            try
            {
                SuperKey = ApplicationCommon.GetSuperKey();
                SetId    = ApplicationCommon.GetSetId();

                var selectedrows = new DataTable();
                var scheduledata = new ScheduleDataModel();

                selectedrows = ScheduleDataManager.GetDetails(scheduledata, SessionVariables.RequestProfile).Clone();
                if (!string.IsNullOrEmpty(SuperKey))
                {
                    var systemEntityTypeId = (int)PrimaryEntity;
                    var lstEntityKeys      = ApplicationCommon.GetSuperKeyDetails(systemEntityTypeId, SuperKey);

                    foreach (var entityKey in lstEntityKeys)
                    {
                        scheduledata.ScheduleId = entityKey;
                        var result = ScheduleDataManager.GetDetails(scheduledata, SessionVariables.RequestProfile);
                        selectedrows.ImportRow(result.Rows[0]);
                    }
                }
                else
                {
                    scheduledata.ScheduleId = SetId;
                    var result = ScheduleDataManager.GetDetails(scheduledata, SessionVariables.RequestProfile);
                    selectedrows.ImportRow(result.Rows[0]);
                }
                return(selectedrows);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(null);
        }
コード例 #18
0
        public IEnumerable <string> GetData(string value, string value1)
        {
            var data = new ScheduleDataModel();

            dynamic jData = JsonConvert.DeserializeObject(value);

            data.Person          = jData[0].Value;
            data.ScheduleStateId = jData[1].Value;
            data.ExcludeItems    = jData[2].Value;

            if (!string.IsNullOrEmpty(value1))
            {
                var dates = value1.Split('&');
                if (Boolean.Parse(dates[2]))
                {
                    data.FromSearchDate = DateTimeHelper.FromApplicationDateFormatToDate(dates[0]);
                    data.ToSearchDate   = DateTimeHelper.FromApplicationDateFormatToDate(dates[1]);
                }
            }

            groupOn = jData[3].Value;
            var ds = ScheduleDataManager.SearchView(data, SessionVariables.RequestProfile);

            AllDataRows = ds.Tables[1];

            totalCount = AllDataRows.Rows.Count;

            var series = new decimal[AllDataRows.Rows.Count];
            var i      = 0;

            foreach (DataRow item in AllDataRows.Rows)
            {
                var timeSpent = item[ScheduleDataModel.DataColumns.TotalHoursWorked].ToString();

                var timeSpentValue = 0m;

                Decimal.TryParse(timeSpent, out timeSpentValue);

                series[i++] = timeSpentValue;
            }

            totalHoursWorkedForGroup = series.Sum();
            DataTable dt = null;

            if (string.IsNullOrEmpty(groupOn) || groupOn == "-1" || groupOn == "All")
            {
                if (ds.Tables.Count > 1)
                {
                    var tblKeyDescription = new DataTable();

                    tblKeyDescription.AcceptChanges();
                    tblKeyDescription.Columns.Add("Person");
                    tblKeyDescription.Columns.Add("PersonId");

                    var row = tblKeyDescription.NewRow();
                    row["Person"]   = "All";
                    row["PersonId"] = "All";
                    tblKeyDescription.Rows.Add(row);

                    var dataView = tblKeyDescription.DefaultView;

                    dt = dataView.ToTable();

                    var distinctFieldValues = (from rowDisp in dt.AsEnumerable() select rowDisp.Field <string>("PersonId"))
                                              .Distinct(StringComparer.CurrentCultureIgnoreCase);
                    return(distinctFieldValues);
                }
            }
            else
            {
                var distinctFieldValues = (from row in AllDataRows.AsEnumerable()
                                           .Where(row => row[groupOn].ToString().Trim() != "")
                                           orderby row[groupOn].ToString().Trim() descending
                                           select row[groupOn].ToString().Trim())
                                          .Distinct(StringComparer.CurrentCultureIgnoreCase);


                return(distinctFieldValues);
            }

            var values = from products in ds.Tables[0].AsEnumerable() select products.Field <string>("Person");

            return(values);
        }
コード例 #19
0
        public void FormatMail(DataTable dt1, string mailFormat, string toEmailAddress, string ccEmailAddress, string fromEmailAddress,
                               bool isPreview, RequestProfile requestProfile)
        {
            var mailTemplate = mailFormat;

            decimal totalhrs = 0;

            var stringBuilder = new StringBuilder();
            var strSubject    = new StringBuilder();

            var scheduleDetailData = (from m in dt1.AsEnumerable()
                                      select new
            {
                InTime = m["InTime"],
                OutTime = m["OutTime"],
                Message = m["Message"].ToString(),
                ScheduleDetailActivityCategory = m["ScheduleDetailActivityCategory"].ToString(),
                ScheduleDetailActivityCategoryId = m["ScheduleDetailActivityCategoryId"],
                WorkDate = m["WorkDate"],
                DateDiffHrs = m["DateDiffHrs"],
                Person = m["Person"],
                PersonId = m["PersonId"],
                EmailAddress = m["EmailAddress"],
                ScheduleId = m["ScheduleId"],
                WorkTicket = m["WorkTicket"]
            }).OrderBy(m => m.InTime).ToList();


            var workDate_distinct = (from c in dt1.AsEnumerable()
                                     select new
            {
                WorkDate = c["WorkDate"].ToString(),
                Person = c["Person"],
                ScheduleId = c["ScheduleId"]
            }).Distinct();

            if (!string.IsNullOrEmpty(mailTemplate))
            {
                foreach (var c in workDate_distinct)
                {
                    mailTemplate = mailTemplate.Replace("##PersonName##", c.Person.ToString());
                    mailTemplate = mailTemplate.Replace("##WorkDate##", Convert.ToDateTime(c.WorkDate).ToString("MMMM dd, yyyy"));
                }

                foreach (var item in scheduleDetailData)
                {
                    if (item.DateDiffHrs != null)
                    {
                        totalhrs = totalhrs + Convert.ToDecimal(item.DateDiffHrs);
                    }
                }
                mailTemplate = mailTemplate.Replace("##StartTime##", Convert.ToDateTime(scheduleDetailData.Select(grp => grp.InTime).First()).ToShortTimeString());
                mailTemplate = mailTemplate.Replace("##EndTime##", Convert.ToDateTime(scheduleDetailData.Select(grp => grp.OutTime).Last()).ToShortTimeString());
                mailTemplate = mailTemplate.Replace("##TotalHrs##", totalhrs.ToString("0.00"));

                var bColor = "#d9edf7";
                var i      = 0;

                foreach (var item in scheduleDetailData)
                {
                    var jiraIssue       = JiraDataManager.GetDetails(item.WorkTicket.ToString());
                    var jiraDescription = "N/A";
                    var jiraPriority    = "N/A";
                    var jiraWorkHours   = GetJiraWorkHours(item.WorkTicket.ToString(), Convert.ToDateTime(item.WorkDate), Convert.ToInt32(item.PersonId));
                    personId = Convert.ToInt32(item.PersonId);
                    var minsDuration = ScheduleDataManager.GetMinutes(Convert.ToDouble(item.DateDiffHrs));
                    var jiraURL      = "http://*****:*****@indusvalleyresearch.com";
                }

                var nMail = new MailMessage(fromEmailAddress, strToEmail);
                //string strFromEmail = "*****@*****.**";
                if (ccEmailAddress != string.Empty)
                {
                    MailAddress copy = new MailAddress(ccEmailAddress);
                    nMail.CC.Add(copy);
                }

                foreach (var item in scheduleDetailData)
                {
                    string bccMail = item.EmailAddress.ToString();
                    if (bccMail != string.Empty)
                    {
                        nMail.Bcc.Add(new MailAddress(bccMail));
                    }
                }

                foreach (var c in workDate_distinct)
                {
                    strSubject.Append("EOD Daily Summary Email for " + Convert.ToDateTime(c.WorkDate).ToString("MMMM dd, yyyy") + "(" + totalhrs.ToString("0.00") + " hrs" + ")");
                    strSubject.Append(" - Sent on behalf of " + c.Person);
                }

                nMail.Subject    = strSubject.ToString();
                nMail.Body       = mailTemplate;
                nMail.IsBodyHtml = true;

                var a = new SmtpClient();
                a.Send(nMail);
            }
        }
コード例 #20
0
        protected DataTable GetData()
        {
            var dt = ScheduleDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            return(dt);
        }
コード例 #21
0
        public ResultSet CalculateRNandSDWorkedHours(string emailAddress, int appId)
        {
            var rnTotalHours  = 0.0;
            var srnTotalHours = 0.0;
            var sdTotalHours  = 0;
            var temp          = 0.0;
            var developer     = string.Empty;
            var appUserId     = 0;
            var appUserName   = string.Empty;
            var fromDateTime  = new DateTime();
            var toDateTime    = new DateTime();
            var date          = new ReleaseLogDetailDataModel();

            var dateValue = ReleaseLogDetailDataManager.GetDetails(date, SessionVariables.RequestProfile);
            var dv        = dateValue.DefaultView;

            dv.Sort = "ReleaseDate ASC";

            if (oDateRange.FromDateTime.Equals("") || oDateRange.ToDateTime.Equals(""))
            {
                fromDateTime = Convert.ToDateTime(dv.ToTable().Rows[0][ReleaseLogDetailDataModel.DataColumns.ReleaseDate].ToString());
                toDateTime   = Convert.ToDateTime(dv.ToTable().Rows[dateValue.Rows.Count - 1][ReleaseLogDetailDataModel.DataColumns.ReleaseDate].ToString());
            }
            else
            {
                fromDateTime = Convert.ToDateTime(DateTimeHelper.FromUserDateFormatToApplicationDateFormat(oDateRange.FromDateTime));
                toDateTime   = Convert.ToDateTime(DateTimeHelper.FromUserDateFormatToApplicationDateFormat(oDateRange.ToDateTime));
            }
            var format   = SessionVariables.UserDateFormat;
            var fromDate = fromDateTime.ToString(format);
            var toDate   = toDateTime.ToString(format);


            //var appObj = new ApplicationDataModel();
            //appObj.ApplicationId = appId;
            //var dt3 = Framework.Components.ApplicationUser.ApplicationDataManager.Search(appObj, SessionVariables.RequestProfile);
            //var applicationName = dt3.Rows[0][ApplicationDataModel.DataColumns.Name];

            var obj1 = new ApplicationUserDataModel();

            obj1.EmailAddress = emailAddress;
            SessionVariables.RequestProfile.ApplicationId = 100;
            var dt1 = ApplicationUserDataManager.Search(obj1, SessionVariables.RequestProfile);

            //appUserId = (int)(dt1.Rows[0][ApplicationUserDataModel.DataColumns.ApplicationUserId]);
            appUserName = dt1.Rows[0][ApplicationUserDataModel.DataColumns.FirstName] + " " + dt1.Rows[0][ApplicationUserDataModel.DataColumns.LastName];

            if (dt1.Rows[0][ApplicationUserDataModel.DataColumns.LastName].ToString().Substring(1, 1).Equals("u"))
            {
                developer = (string)(dt1.Rows[0][ApplicationUserDataModel.DataColumns.FirstName].ToString().Substring(0, 1) + dt1.Rows[0][ApplicationUserDataModel.DataColumns.LastName].ToString().Substring(0, 1) + "2");
            }
            else
            {
                developer = (string)(dt1.Rows[0][ApplicationUserDataModel.DataColumns.FirstName].ToString().Substring(0, 1) + dt1.Rows[0][ApplicationUserDataModel.DataColumns.LastName].ToString().Substring(0, 1));
            }


            var tsObj = new ReleaseLogDetailDataModel();

            tsObj.ReleaseDateMin   = Convert.ToDateTime(fromDate);
            tsObj.ReleaseDateMax   = Convert.ToDateTime(toDate);
            tsObj.ApplicationId    = appId;
            tsObj.PrimaryDeveloper = developer;
            var dt4   = ReleaseLogDetailDataManager.Search(tsObj, SessionVariables.RequestProfile);
            var temp1 = 0.0;

            for (var i = 0; i < dt4.Rows.Count; i++)
            {
                if (dt4.Rows[i][ReleaseLogDetailDataModel.DataColumns.PrimaryDeveloper].Equals(developer) || dt4.Rows[i][ReleaseLogDetailDataModel.DataColumns.PrimaryDeveloper].Equals("Admin"))
                {
                    if (!dt4.Rows[i][ReleaseLogDetailDataModel.DataColumns.TimeSpent].Equals("Unknown"))
                    {
                        temp1         = (double)Convert.ToDouble(dt4.Rows[i][ReleaseLogDetailDataModel.DataColumns.TimeSpent]);
                        srnTotalHours = srnTotalHours + temp1;
                    }
                }
            }



            var sObj = new ApplicationUserDataModel();

            sObj.EmailAddress  = emailAddress;
            sObj.ApplicationId = 100047;
            var sDt = ApplicationUserDataManager.Search(sObj, SessionVariables.RequestProfile);

            if (sDt.Rows.Count > 0)
            {
                var obj2 = new ScheduleDataModel();
                obj2.FromSearchDate = Convert.ToDateTime(fromDate);
                obj2.ToSearchDate   = Convert.ToDateTime(toDate);
                obj2.Person         = (sDt.Rows[0][ApplicationUserDataModel.DataColumns.ApplicationUserId]).ToString();
                obj2.ApplicationId  = 100047;
                //SessionVariables.RequestProfile.ApplicationId = 100047;
                var dt2 = ScheduleDataManager.Search(obj2, SessionVariables.RequestProfile);


                for (var i = 0; i < dt2.Rows.Count; i++)
                {
                    temp         = Convert.ToInt32(dt2.Rows[i][ScheduleDataModel.DataColumns.TotalHoursWorked]);
                    sdTotalHours = sdTotalHours + (int)temp;
                }
            }


            var resultSet = new ResultSet(appUserName, ((int)(rnTotalHours + srnTotalHours)).ToString(), string.Format("{0}.00", sdTotalHours));

            return(resultSet);
        }
コード例 #22
0
        protected override DataTable UpdateData()
        {
            var UpdatedData = new DataTable();
            var data        = new ScheduleDataModel();

            UpdatedData = ScheduleDataManager.Search(data, SessionVariables.RequestProfile).Clone();
            for (var i = 0; i < SelectedData.Rows.Count; i++)
            {
                data.ScheduleId =
                    Convert.ToInt32(SelectedData.Rows[i][ScheduleDataModel.DataColumns.ScheduleId].ToString());

                data.PersonId = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.PersonId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.PersonId).ToString())
                                        : int.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.PersonId].ToString());

                data.WorkDate =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.WorkDate))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.WorkDate).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.WorkDate].ToString());

                data.StartTime =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.StartTime))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.StartTime).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.StartTime].ToString());

                data.EndTime =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.EndTime))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.EndTime).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.EndTime].ToString());

                data.TotalHoursWorked =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.TotalHoursWorked))
                                        ? decimal.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.TotalHoursWorked).ToString())
                                        : decimal.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.TotalHoursWorked].ToString());

                data.NextWorkDate =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.NextWorkDate))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.NextWorkDate).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.NextWorkDate].ToString());


                data.NextWorkTime =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.NextWorkTime))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.NextWorkTime).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.NextWorkTime].ToString());

                data.ScheduleStateId = !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.ScheduleStateId))
                                        ? int.Parse(CheckAndGetRepeaterTextBoxValue(ScheduleDataModel.DataColumns.ScheduleStateId).ToString())
                                        : int.Parse(SelectedData.Rows[i][ScheduleDataModel.DataColumns.ScheduleStateId].ToString());

                data.CreatedDate =
                    !string.IsNullOrEmpty(CheckAndGetRepeaterTextBoxValue(BaseDataModel.BaseDataColumns.CreatedDate))
                                        ? DateTime.Parse(CheckAndGetRepeaterTextBoxValue(BaseDataModel.BaseDataColumns.CreatedDate).ToString())
                                        : DateTime.Parse(SelectedData.Rows[i][BaseDataModel.BaseDataColumns.CreatedDate].ToString());

                ScheduleDataManager.Update(data, SessionVariables.RequestProfile);
                data            = new ScheduleDataModel();
                data.ScheduleId = Convert.ToInt32(SelectedData.Rows[i][ScheduleDataModel.DataColumns.ScheduleId].ToString());
                var dt = ScheduleDataManager.Search(data, SessionVariables.RequestProfile);

                if (dt.Rows.Count == 1)
                {
                    UpdatedData.ImportRow(dt.Rows[0]);
                }
            }
            return(UpdatedData);
        }
コード例 #23
0
        protected override DataTable GetData()
        {
            var dt = ScheduleDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile);

            if (GroupBy.Equals("WorkDate–Day") || SubGroupBy.Equals("WorkDate–Day"))
            {
                dt.Columns.Add("WorkDate–Day", typeof(Int32));

                foreach (DataRow dr in dt.Rows)
                {
                    var workdate = (DateTime)dr[ScheduleDataModel.DataColumns.WorkDate];
                    dr["WorkDate–Day"] = workdate.Day;
                }
            }
            else if (GroupBy.Equals("WorkDate–Month") || SubGroupBy.Equals("WorkDate–Month"))
            {
                dt.Columns.Add("WorkDate–Month", typeof(String));

                foreach (DataRow dr in dt.Rows)
                {
                    var workdate     = (DateTime)dr[ScheduleDataModel.DataColumns.WorkDate];
                    var mfi          = new DateTimeFormatInfo();
                    var strMonthName = mfi.GetAbbreviatedMonthName(workdate.Month).ToString();
                    dr["WorkDate–Month"] = strMonthName;
                }
            }
            else if (GroupBy.Equals("WorkDate–Year") || SubGroupBy.Equals("WorkDate–Year"))
            {
                dt.Columns.Add("WorkDate–Year", typeof(Int32));

                foreach (DataRow dr in dt.Rows)
                {
                    var workdate = (DateTime)dr[ScheduleDataModel.DataColumns.WorkDate];
                    dr["WorkDate–Year"] = workdate.Year;
                }
            }
            else if (GroupBy.Equals("WorkDate–Week") || SubGroupBy.Equals("WorkDate–Week"))
            {
                dt.Columns.Add("WorkDate–Week", typeof(Int32));

                foreach (DataRow dr in dt.Rows)
                {
                    var workdate = (DateTime)dr[ScheduleDataModel.DataColumns.WorkDate];
                    dr["WorkDate–Week"] = workdate.DayOfWeek;
                }
            }
            else if (GroupBy.Equals("WorkDate–Quarter") || SubGroupBy.Equals("WorkDate–Quarter"))
            {
                dt.Columns.Add("WorkDate–Quarter", typeof(String));

                foreach (DataRow dr in dt.Rows)
                {
                    var workdate = (DateTime)dr[ScheduleDataModel.DataColumns.WorkDate];
                    var quarter  = ((workdate.Month - 3) % 12) / 4;

                    switch (quarter)
                    {
                    case 1:
                        dr["WorkDate–Quarter"] = "Q1";
                        break;

                    case 2:
                        dr["WorkDate–Quarter"] = "Q2";
                        break;

                    case 3:
                        dr["WorkDate–Quarter"] = "Q3";
                        break;

                    case 4:
                        dr["WorkDate–Quarter"] = "Q4";
                        break;
                    }
                }
            }

            dt.AcceptChanges();
            return(dt);
        }