示例#1
0
        public SignableTimeRecord(TimeRecord record, IEnumerable<TimeRecordEntry> entries)
            : base(record)
        {
            Salary = record.Salary;

            Entries = new List<SignableTimeRecordEntry>();

            foreach (var entry in entries)
            {
                var signableEntries = new SignableTimeRecordEntry(entry);
                Entries.Add(signableEntries);
            }
        }
示例#2
0
    public override bool Init(int index, SkyScrollPanel mySkyScrollPanel)
    {
        base.Init (index, mySkyScrollPanel);
        ElementButtonConfig config = ((ElementButtonConfig)(MySkyScrollPanel.Config));
        gameObject.name = "ElementButton" + index;
        b = gameObject.transform.parent.Find (gameObject.name).GetComponent<Button> ();
        mytext = gameObject.transform.Find ("Text").GetComponent<Text> ();
        isSpecial = config.ConfigInfs [index].IsSpecial;
        if (((ElementButtonConfig)(MySkyScrollPanel.Config)).ConfigInfs [index].sprite == null)
            mytext.text = config.ConfigInfs [index].desc;
        else
            b.image.sprite = config.ConfigInfs [index].sprite;
        b.onClick.AddListener (() => ElementButtonConfig.ChoiseEvent (config.ConfigInfs [index].buttonConfigType));

        if (isSpecial) {
            timeRecord = new TimeRecord ("test", SkyTime.MINUTE * 10, false);
        }
        return true;
    }
示例#3
0
 public void AddTimeRecord(TimeRecord record)
 {
     Db.Insert(record, "TimeRecords");
 }
示例#4
0
 /// <summary>
 /// Setup the test.
 /// </summary>
 public TimeRecordModelTests()
 {
     instance = new TimeRecord();
 }
示例#5
0
        /// <summary>
        /// Map data
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="oldObject"></param>
        /// <param name="timeRecord"></param>
        /// <param name="systemId"></param>
        /// <param name="maxTimesheetIndex"></param>
        private static void CopyToTimeRecorded(DbAppContext dbContext, EquipUsage oldObject, ref TimeRecord timeRecord,
                                               string systemId, ref int maxTimesheetIndex)
        {
            try
            {
                if (oldObject.Equip_Id <= 0)
                {
                    return;
                }

                if (oldObject.Project_Id <= 0)
                {
                    return;
                }

                // ***********************************************
                // we only need records from the current fiscal
                // so ignore all others
                // ***********************************************
                DateTime fiscalStart;
                DateTime fiscalEnd;

                if (DateTime.UtcNow.Month == 1 || DateTime.UtcNow.Month == 2 || DateTime.UtcNow.Month == 3)
                {
                    fiscalEnd = new DateTime(DateTime.UtcNow.Year, 3, 31);
                }
                else
                {
                    fiscalEnd = new DateTime(DateTime.UtcNow.AddYears(1).Year, 3, 31);
                }

                if (DateTime.UtcNow.Month == 1 || DateTime.UtcNow.Month == 2 || DateTime.UtcNow.Month == 3)
                {
                    fiscalStart = new DateTime(DateTime.UtcNow.AddYears(-1).Year, 4, 1);
                }
                else
                {
                    fiscalStart = new DateTime(DateTime.UtcNow.Year, 4, 1);
                }

                string tempRecordDate = oldObject.Worked_Dt;

                if (string.IsNullOrEmpty(tempRecordDate))
                {
                    return; // ignore if we don't have a created date
                }

                if (!string.IsNullOrEmpty(tempRecordDate))
                {
                    DateTime?recordDate = ImportUtility.CleanDateTime(tempRecordDate);

                    if (recordDate == null ||
                        recordDate < fiscalStart ||
                        recordDate > fiscalEnd)
                    {
                        return; // ignore this record - it is outside of the current fiscal year
                    }
                }


                // ************************************************
                // get the imported equipment record map
                // ************************************************
                string tempId = oldObject.Equip_Id.ToString();

                ImportMap mapEquip = dbContext.ImportMaps.AsNoTracking()
                                     .FirstOrDefault(x => x.OldKey == tempId &&
                                                     x.OldTable == ImportEquip.OldTable &&
                                                     x.NewTable == ImportEquip.NewTable);

                if (mapEquip == null)
                {
                    throw new DataException(string.Format("Cannot locate Equipment record (Timesheet Equip Id: {0}", tempId));
                }

                // ***********************************************
                // find the equipment record
                // ***********************************************
                Equipment equipment = dbContext.Equipments.AsNoTracking().FirstOrDefault(x => x.Id == mapEquip.NewKey);

                if (equipment == null)
                {
                    throw new ArgumentException(string.Format("Cannot locate Equipment record (Timesheet Equip Id: {0}", tempId));
                }

                // ************************************************
                // get the imported project record map
                // ************************************************
                string tempProjectId = oldObject.Project_Id.ToString();

                ImportMap mapProject = dbContext.ImportMaps.AsNoTracking()
                                       .FirstOrDefault(x => x.OldKey == tempProjectId &&
                                                       x.OldTable == ImportProject.OldTable &&
                                                       x.NewTable == ImportProject.NewTable);

                // ***********************************************
                // find the project record
                // (or create a project (inactive))
                // ***********************************************
                Models.Project project;

                if (mapProject != null)
                {
                    project = dbContext.Projects.AsNoTracking().FirstOrDefault(x => x.Id == mapProject.NewKey);

                    if (project == null)
                    {
                        throw new ArgumentException(string.Format("Cannot locate Project record (Timesheet Equip Id: {0}", tempId));
                    }
                }
                else
                {
                    // create new project
                    project = new Models.Project
                    {
                        Information            = "Created to support Time Record import from BCBid",
                        Status                 = "Complete",
                        Name                   = "Legacy BCBid Project",
                        AppCreateUserid        = systemId,
                        AppCreateTimestamp     = DateTime.UtcNow,
                        AppLastUpdateUserid    = systemId,
                        AppLastUpdateTimestamp = DateTime.UtcNow
                    };

                    dbContext.Projects.Add(project);

                    // save now so we can access it for other time records
                    dbContext.SaveChanges();

                    // add mapping record
                    ImportUtility.AddImportMapForProgress(dbContext, ImportProject.OldTable, tempProjectId, project.Id, ImportProject.NewTable);
                    dbContext.SaveChanges();
                }

                // ***********************************************
                // find or create the rental agreement
                // ***********************************************
                DateTime?enteredDate = ImportUtility.CleanDateTime(oldObject.Entered_Dt);  // use for the agreement

                RentalAgreement agreement = dbContext.RentalAgreements.AsNoTracking()
                                            .FirstOrDefault(x => x.EquipmentId == equipment.Id &&
                                                            x.ProjectId == project.Id);

                if (agreement == null)
                {
                    // create a new agreement record
                    agreement = new RentalAgreement
                    {
                        EquipmentId            = equipment.Id,
                        ProjectId              = project.Id,
                        Note                   = "Created to support Time Record import from BCBid",
                        Number                 = "Legacy BCBid Agreement",
                        DatedOn                = enteredDate,
                        AppCreateUserid        = systemId,
                        AppCreateTimestamp     = DateTime.UtcNow,
                        AppLastUpdateUserid    = systemId,
                        AppLastUpdateTimestamp = DateTime.UtcNow
                    };

                    if (project.RentalAgreements == null)
                    {
                        project.RentalAgreements = new List <RentalAgreement>();
                    }

                    project.RentalAgreements.Add(agreement);

                    // save now so we can access it for other time records
                    dbContext.SaveChangesForImport();
                }

                // ***********************************************
                // create time record
                // ***********************************************
                timeRecord = new TimeRecord {
                    Id = ++maxTimesheetIndex
                };

                // ***********************************************
                // set time record attributes
                // ***********************************************
                DateTime?workedDate = ImportUtility.CleanDateTime(oldObject.Worked_Dt);

                if (workedDate != null)
                {
                    timeRecord.WorkedDate = (DateTime)workedDate;
                }
                else
                {
                    throw new DataException(string.Format("Worked Date cannot be null (TimesheetIndex: {0}", maxTimesheetIndex));
                }

                // get hours worked
                float?tempHoursWorked = ImportUtility.GetFloatValue(oldObject.Hours);

                if (tempHoursWorked != null)
                {
                    timeRecord.Hours = tempHoursWorked;
                }
                else
                {
                    throw new DataException(string.Format("Hours cannot be null (TimesheetIndex: {0}", maxTimesheetIndex));
                }

                if (enteredDate != null)
                {
                    timeRecord.EnteredDate = (DateTime)enteredDate;
                }
                else
                {
                    throw new DataException(string.Format("Entered Date cannot be null (TimesheetIndex: {0}", maxTimesheetIndex));
                }

                // ***********************************************
                // create time record
                // ***********************************************
                timeRecord.AppCreateUserid        = systemId;
                timeRecord.AppCreateTimestamp     = DateTime.UtcNow;
                timeRecord.AppLastUpdateUserid    = systemId;
                timeRecord.AppLastUpdateTimestamp = DateTime.UtcNow;

                if (agreement.TimeRecords == null)
                {
                    agreement.TimeRecords = new List <TimeRecord>();
                }

                agreement.TimeRecords.Add(timeRecord);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("***Error*** - Worked Date: " + oldObject.Worked_Dt);
                Debug.WriteLine("***Error*** - Master TimeRecord Index: " + maxTimesheetIndex);
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
示例#6
0
        public static TimeRecordEntryViewModel Create(IRepository repository, IUserBLL userBLL, ITimeRecordBLL timeRecordBLL, TimeRecord timeRecord, ITimeRecordCalendarGenerator calendarGenerator)
        {
            var viewModel = new TimeRecordEntryViewModel
                                {
                                    TimeRecord = timeRecord,
                                    TotalHours =
                                        repository.OfType<TimeRecordEntry>()
                                            .Queryable
                                            .Where(x => x.Record.Id == timeRecord.Id)
                                            .Sum(x => x.Hours),
                                    CalendarDays = calendarGenerator.GenerateCalendar(timeRecord),
                                    Projects = userBLL.GetAllProjectsByUser(repository.OfType<Project>()).ToList(),
                                    FundTypes = userBLL.GetUser().FundTypes,
                                    ActivityCategories =
                                        repository.OfType<ActivityCategory>()
                                        .Queryable
                                        .Where(c => c.IsActive)
                                        .OrderBy(c => c.Name)
                                        .ToList(),
                                    AdjustmentEntries =
                                        repository.OfType<TimeRecordEntry>()
                                        .Queryable
                                        .Where(x => x.Record.Id == timeRecord.Id && x.AdjustmentDate != null)
                                        .OrderBy(x => x.AdjustmentDate)
                                        .ToList()
                                };

            return viewModel;
        }
示例#7
0
 public virtual IActionResult RentalagreementsIdTimeRecordsPost([FromRoute] int id, [FromBody] TimeRecord item)
 {
     return(_service.RentalAgreementsIdTimeRecordsPostAsync(id, item));
 }
示例#8
0
 public virtual IActionResult ProjectsIdTimeRecordsPost([FromRoute] int id, [FromBody] TimeRecord item)
 {
     return(_service.ProjectsIdTimeRecordsPostAsync(id, item));
 }
示例#9
0
 //[Obsolete("This can be replaced by casting the DayOfWeek enum as an int")]
 //private static int ConvertDayOfWeek(string day)
 //{
 //    switch (day)
 //    {
 //        case "Sunday":
 //            return 0;
 //        case "Monday":
 //            return 1;
 //        case "Tuesday":
 //            return 2;
 //        case "Wednesday":
 //            return 3;
 //        case "Thursday":
 //            return 4;
 //        case "Friday":
 //            return 5;
 //        case "Saturday":
 //            return 6;
 //        default:
 //            return 0;
 //    }
 //}
 /// <summary>
 /// Given a time sheet, it populates the day with the proper entries
 /// </summary>
 /// <param name="timeRecord"></param>
 public void Populate(TimeRecord timeRecord)
 {
     // Iterate through the timesheet entries
     foreach (TimeRecordEntry tes in timeRecord.Entries)
     {
         // Add the entry if it is not an adjustment
         if (tes.AdjustmentDate == null)
           AddEntry(tes);
     }
 }
 public TimeRecordViewModel(TimeRecord timeRecord)
 {
     TimeRecordModel = timeRecord;
 }
 /// <summary>
 /// Initializes a new instance of the TimeRecordModel class that wraps a Todo object.
 /// </summary>
 public TimeRecordViewModel(Guid todoId, string todoName)
 {
     TimeRecordModel = new TimeRecord(todoId, todoName);
 }
示例#12
0
        /// <summary>
        /// 原始库单站电压数据查询
        /// </summary>
        /// <param name="fromTime"></param>
        /// <param name="toTime"></param>
        /// <param name="stationIds"></param>
        /// <returns></returns>
        public static QueryResult ListHourVoltage(DateTime fromTime, DateTime toTime, string id)
        {
            //查询为空
            if (id == null)
            {
                return(new QueryResult());
            }
            //传递得参数
            Dictionary <string, object> param = new Dictionary <string, object>();
            //TODO添加datatime转string timeStart timeEnd

            //查询条件
            Dictionary <string, string> paramInner = new Dictionary <string, string>();

            paramInner["stationid"] = id;
            paramInner["strttime"]  = fromTime.ToString();
            paramInner["endtime"]   = toTime.ToString();
            //返回结果
            QueryResult          result      = new QueryResult();
            List <VoltageDbData> voltageList = new List <VoltageDbData>();
            //string suffix = "/subcenter/getSubcenter";
            string url = suffix + "/voltage/getVoltageBS";
            //string url = "http://127.0.0.1:8088/voltage/getVoltageBS";
            string jsonStr = HttpHelper.SerializeDictionaryToJsonString(paramInner);

            param["voltage"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                voltageList = (List <VoltageDbData>)HttpHelper.JsonDeserialize <List <VoltageDbData> >(resultJson, new List <VoltageDbData>());
            }
            catch (Exception e)
            {
                Debug.WriteLine("查询电压信息失败");
                throw e;
            }
            //处理数据
            Station    station = StationService.GetStationByRawId(id);
            TimeRecord record  = new TimeRecord {
                stationId = station.id, stationName = station.stationName, stationType = station.stationType
            };
            List <TimeVoltage> tvoltages = new List <TimeVoltage>();

            foreach (VoltageDbData voltage in voltageList)
            {
                TimeVoltage timeVoltage = new TimeVoltage(voltage.datatime, voltage.data);
                timeVoltage.time    = voltage.datatime;
                timeVoltage.voltage = voltage.data.HasValue ? voltage.data.Value : 0;
                tvoltages.Add(timeVoltage);
            }
            record.tvoltages = tvoltages;
            record.tvoltages = record.tvoltages.OrderByDescending(r => r.time).ToList();
            result.records.Add(record);
            return(result);
            ////获取数据
            ////List<VoltageDbData> voltageRecord = ListRawHourVoltage(fromTime, toTime, id);

            //QueryResult result = new QueryResult();
            //Station station = StationService.GetStationByRawId(id);
            //TimeRecord record = new TimeRecord { stationId = station.id, stationName = station.stationName, stationType = station.stationType };
            //List<TimeVoltage> tvoltages = new List<TimeVoltage>();

            //LNRRDB ln = new LNRRDB();
            //List<string> tableNameList = TableNameHelper.getTableName("voltage", fromTime, toTime);

            //#region 循环获取所有数据 辣鸡代码,不是gm写的
            //foreach (string tableName in tableNameList)
            //{

            //    switch (tableName)
            //    {
            //        case "voltage20188A":
            //            var voltagerecords20188A = from voltage in ln.voltage20188A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20188A = dataTransfer(voltagerecords20188A);
            //            tvoltages.AddRange(voltages20188A);
            //            break;
            //        case "voltage20188B":
            //            var voltagerecords20188B = from voltage in ln.voltage20188B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20188B = dataTransfer(voltagerecords20188B);
            //            tvoltages.AddRange(voltages20188B);
            //            break;
            //        case "voltage20189A":
            //            var voltagerecords20189A = from voltage in ln.voltage20189A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20189A = dataTransfer(voltagerecords20189A);
            //            tvoltages.AddRange(voltages20189A);
            //            break;
            //        case "voltage20189B":
            //            var voltagerecords20189B = from voltage in ln.voltage20189B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20189B = dataTransfer(voltagerecords20189B);
            //            tvoltages.AddRange(voltages20189B);
            //            break;
            //        case "voltage201810A":
            //            var voltagerecords201810A = from voltage in ln.voltage201810A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201810A = dataTransfer(voltagerecords201810A);
            //            tvoltages.AddRange(voltages201810A);
            //            break;
            //        case "voltage201810B":
            //            var voltagerecords201810B = from voltage in ln.voltage201810B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201810B = dataTransfer(voltagerecords201810B);
            //            tvoltages.AddRange(voltages201810B);
            //            break;
            //        case "voltage201811A":
            //            var voltagerecords201811A = from voltage in ln.voltage201811A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201811A = dataTransfer(voltagerecords201811A);
            //            tvoltages.AddRange(voltages201811A);
            //            break;
            //        case "voltage201811B":
            //            var voltagerecords201811B = from voltage in ln.voltage201811B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201811B = dataTransfer(voltagerecords201811B);
            //            tvoltages.AddRange(voltages201811B);
            //            break;
            //        case "voltage201812A":
            //            var voltagerecords201812A = from voltage in ln.voltage201812A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201812A = dataTransfer(voltagerecords201812A);
            //            tvoltages.AddRange(voltages201812A);
            //            break;
            //        case "voltage201812B":
            //            var voltagerecords201812B = from voltage in ln.voltage201812B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages201812B = dataTransfer(voltagerecords201812B);
            //            tvoltages.AddRange(voltages201812B);
            //            break;

            //        case "voltage20191A":
            //            var voltagerecords20191A = from voltage in ln.voltage20191A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20191A = dataTransfer(voltagerecords20191A);
            //            tvoltages.AddRange(voltages20191A);
            //            break;
            //        case "voltage20191B":
            //            var voltagerecords20191B = from voltage in ln.voltage20191B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20191B = dataTransfer(voltagerecords20191B);
            //            tvoltages.AddRange(voltages20191B);
            //            break;

            //        case "voltage20192A":
            //            var voltagerecords20192A = from voltage in ln.voltage20192A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20192A = dataTransfer(voltagerecords20192A);
            //            tvoltages.AddRange(voltages20192A);
            //            break;
            //        case "voltage20192B":
            //            var voltagerecords20192B = from voltage in ln.voltage20192B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20192B = dataTransfer(voltagerecords20192B);
            //            tvoltages.AddRange(voltages20192B);
            //            break;

            //        case "voltage20193A":
            //            var voltagerecords20193A = from voltage in ln.voltage20193A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20193A = dataTransfer(voltagerecords20193A);
            //            tvoltages.AddRange(voltages20193A);
            //            break;
            //        case "voltage20193B":
            //            var voltagerecords20193B = from voltage in ln.voltage20193B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20193B = dataTransfer(voltagerecords20193B);
            //            tvoltages.AddRange(voltages20193B);
            //            break;

            //        case "voltage20194A":
            //            var voltagerecords20194A = from voltage in ln.voltage20194A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20194A = dataTransfer(voltagerecords20194A);
            //            tvoltages.AddRange(voltages20194A);
            //            break;
            //        case "voltage20194B":
            //            var voltagerecords20194B = from voltage in ln.voltage20194B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20194B = dataTransfer(voltagerecords20194B);
            //            tvoltages.AddRange(voltages20194B);
            //            break;

            //        case "voltage20195A":
            //            var voltagerecords20195A = from voltage in ln.voltage20195A where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20195A = dataTransfer(voltagerecords20195A);
            //            tvoltages.AddRange(voltages20195A);
            //            break;
            //        case "voltage20195B":
            //            var voltagerecords20195B = from voltage in ln.voltage20195B where id == voltage.stationid && voltage.datatime <= toTime && voltage.datatime >= fromTime select voltage;
            //            List<TimeVoltage> voltages20195B = dataTransfer(voltagerecords20195B);
            //            tvoltages.AddRange(voltages20195B);
            //            break;
            //        default:
            //            break;
            //    }
            //}
            //record.tvoltages = tvoltages;
            //#endregion
            ////List<Models.VoltageDbData> singleStationRecord = new List<VoltageDbData>();
            ////singleStationRecord = voltageRecord.Where(r => r.stationid.Equals(id)).OrderByDescending(r => r.datatime).ToList();
            //////数据处理
            ////Station station = StationService.GetStationByRawId(id);
            ////TimeRecord record = new TimeRecord { stationId = station.id, stationName = station.stationName, stationType = station.stationType };
            ////foreach (var r in singleStationRecord)
            ////{
            ////    TimeVoltage tv = new TimeVoltage(r.datatime, r.data);
            ////    record.tvoltages.Add(tv);
            ////}
            //record.tvoltages = record.tvoltages.OrderByDescending(r => r.time).ToList();
            //result.records.Add(record);
            //return result;
        }
示例#13
0
 void Awake()
 {
     tr = GetComponent<TimeRecord>();
 }
        public async Task <ActionResult <TimeRecord> > PostTimeRecord(TimeRecord timeRecord)
        {
            await _timeRecordService.Create(timeRecord);

            return(CreatedAtAction("GetTimeRecord", new { id = timeRecord.TimeRecordID }, timeRecord));
        }
示例#15
0
 public void UpdateTimeRecord(TimeRecord record)
 {
     Db.Update(record, "TimeRecords");
 }
示例#16
0
        /// <summary>
        /// Adding (3) Rental Agreement Rate and (3) Time Records to rental agreement
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="oldObject"></param>
        /// <param name="rentalAgreement"></param>
        /// <param name="systemId"></param>
        static private void addingRate_Time_For_RentaAgreement(DbAppContext dbContext, HETSAPI.Import.EquipUsage oldObject,
                                                               ref Models.RentalAgreement rentalAgreement, string workedDate, string systemId)
        {
            // Adding rental agreement rates and Time_Records: The two are added together becase Time Record reference rental agreement rate.
            Models.RentalAgreementRate rate = new RentalAgreementRate();
            Models.TimeRecord          tRec = new TimeRecord();

            //Adding general properties for RentalAgreement Rate
            DateTime lastUpdateTimestamp = DateTime.UtcNow;

            if (oldObject.Entered_Dt != null)
            {
                lastUpdateTimestamp = DateTime.ParseExact(oldObject.Entered_Dt.Trim().Substring(0, 10), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }
            string lastUpdateUserid = oldObject.Created_By == null ? systemId : ImportUtility.AddUserFromString(dbContext, oldObject.Created_By, systemId).SmUserId;

            //Adding general properties for Time Records
            DateTime workedDateTime;

            if (oldObject.Worked_Dt != null)
            {
                workedDateTime = DateTime.ParseExact(workedDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }
            else
            {
                workedDateTime = DateTime.UtcNow;
            }

            DateTime createdDate;

            if (oldObject.Created_Dt != null)
            {
                createdDate = DateTime.ParseExact(oldObject.Created_Dt.Trim().Substring(0, 10), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            }
            else
            {
                createdDate = DateTime.UtcNow;
            }

            //Adding three rates and hours using a Dictionary
            Dictionary <int, Pair> _f = new Dictionary <int, Pair>();
            float Rate   = (float)Decimal.Parse(oldObject.Rate == null ? "0" : oldObject.Rate, System.Globalization.NumberStyles.Any);
            float Rate2  = (float)Decimal.Parse(oldObject.Rate2 == null ? "0" : oldObject.Rate2, System.Globalization.NumberStyles.Any);
            float Rate3  = (float)Decimal.Parse(oldObject.Rate3 == null ? "0" : oldObject.Rate3, System.Globalization.NumberStyles.Any);
            float Hours  = (float)Decimal.Parse(oldObject.Hours == null ? "0" : oldObject.Hours, System.Globalization.NumberStyles.Any);
            float Hours2 = (float)Decimal.Parse(oldObject.Hours2 == null ? "0" : oldObject.Hours2, System.Globalization.NumberStyles.Any);
            float Hours3 = (float)Decimal.Parse(oldObject.Hours3 == null ? "0" : oldObject.Hours3, System.Globalization.NumberStyles.Any);

            // Add items to dictionary.

            if (Hours != 0.0 || Rate != 0.0)
            {
                _f.Add(1, new Pair(Hours, Rate));
            }
            if (Hours2 != 0.0 || Rate2 != 0.0)
            {
                _f.Add(2, new Pair(Hours2, Rate2));
            }
            if (Hours3 != 0.0 || Rate3 != 0.0)
            {
                _f.Add(3, new Pair(Hours3, Rate3));
            }

            // Use var in foreach loop.
            int ii = 0;

            Models.RentalAgreementRate [] rate_a = new RentalAgreementRate[3];
            Models.TimeRecord []          tRec_a = new TimeRecord[3];
            foreach (var pair in _f)
            {
                Models.RentalAgreementRate exitingRate = rentalAgreement.RentalAgreementRates.FirstOrDefault(x => x.Rate == pair.Value.Rate);
                if (exitingRate == null) //rate does not exist
                {                        //  Adding the new rate
                    rate_a[ii]                     = new RentalAgreementRate();
                    rate_a[ii].Comment             = "Import from BCBid";
                    rate_a[ii].IsAttachment        = false;
                    rate_a[ii].LastUpdateTimestamp = lastUpdateTimestamp;
                    rate_a[ii].LastUpdateUserid    = lastUpdateUserid;
                    rate_a[ii].CreateTimestamp     = createdDate;
                    rate_a[ii].CreateUserid        = lastUpdateUserid;
                    rate_a[ii].Rate                = pair.Value.Rate;
                    rentalAgreement.RentalAgreementRates.Add(rate_a[ii]);
                    //Also add time Record
                    tRec_a[ii]                     = new TimeRecord();
                    tRec_a[ii].EnteredDate         = lastUpdateTimestamp;
                    tRec_a[ii].LastUpdateUserid    = lastUpdateUserid;
                    tRec_a[ii].WorkedDate          = workedDateTime;
                    tRec_a[ii].Hours               = pair.Value.Hours;
                    tRec_a[ii].CreateTimestamp     = createdDate;
                    tRec_a[ii].CreateUserid        = lastUpdateUserid;
                    tRec_a[ii].RentalAgreementRate = rate_a[ii];
                    rentalAgreement.TimeRecords.Add(tRec_a[ii]);
                }
                else
                {   //the rate already existed which is exitingRate, no need to add rate, just add Time Record
                    Models.TimeRecord existingTimeRec = rentalAgreement.TimeRecords.FirstOrDefault(x => x.WorkedDate == workedDateTime);
                    if (existingTimeRec == null)
                    {   //The new Time Record  is added if it does not existm, otherwise, it's already existed.
                        tRec_a[ii]                     = new TimeRecord();
                        tRec_a[ii].EnteredDate         = lastUpdateTimestamp;
                        tRec_a[ii].LastUpdateUserid    = lastUpdateUserid;
                        tRec_a[ii].WorkedDate          = workedDateTime;
                        tRec_a[ii].Hours               = pair.Value.Hours;
                        tRec_a[ii].CreateTimestamp     = createdDate;
                        tRec_a[ii].CreateUserid        = lastUpdateUserid;
                        tRec_a[ii].RentalAgreementRate = exitingRate;
                        rentalAgreement.TimeRecords.Add(tRec_a[ii]);
                    }
                }
                ii++;
            }
            // Ended adding Rental Agreement rates and time records.
        }
示例#17
0
 private void Start()
 {
     timeRecord = GetComponent <TimeRecord>();
     LoadReplay();
 }
示例#18
0
 public void Initialise()
 {
     model = new AlignmentModel(latitude, longitude, elevation);
     model.ClearAlignmentPoints();
     timeRecord = new TimeRecord(this.utcTime, longitude);
 }
示例#19
0
        public void Initialise()
        {
            model = new AlignmentModel(latitude, longitude, elevation)
            {
                IsAlignmentOn = true
            };
            model.ClearAlignmentPoints();
            utcOffset = new TimeSpan();

            // NW
            DateTime   syncTime = new DateTime(2020, 06, 28, 16, 43, 18);
            TimeRecord time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));

            model.AddAlignmentPoint(new double[] { 1.45234227180481, 60.3347473144531 }, new double[] { 144.945062700193, 60.3347473144531 }, new double[] { 149.723756536623, 59.1249432487836 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 43, 48);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 2.86930561065674, 55.9740562438965 }, new double[] { 123.819627432618, 55.9740562438965 }, new double[] { 128.404096999038, 55.283421763509 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 44, 08);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 2.08612251281738, 72.5127334594727 }, new double[] { 135.650906194933, 72.5127334594727 }, new double[] { 143.329091832532, 71.5666812294945 }, time);
            //model.AddAlignmentPoint(new double[]{1.93080902099609, 63.763801574707}, new double[] { 138.060159151908, 63.763801574707 }, new double[] { 143.482011096669, 62.7368181631223 }, new DateTime(2020, 06, 28, 16, 44, 27));
            //// SW

            syncTime = new DateTime(2020, 06, 28, 16, 45, 06);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 7.5975866317749, 31.8432216644287 }, new double[] { 53.2216111482121, 31.8432216644287 }, new double[] { 56.0429603483716, 31.4201609110561 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 45, 43);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 5.93735456466675, 7.40935134887695 }, new double[] { 78.2768689906225, 7.40935134887695 }, new double[] { 81.0690819058243, 7.01751946987766 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 46, 09);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 7.67223644256592, 5.17215204238892 }, new double[] { 52.3623042968102, 5.17215204238892 }, new double[] { 54.9750315780859, 4.46534644056118 }, time);
            // model.AddAlignmentPoint(new double[]{7.32045793533325, 16.5029945373535}, new double[] { 57.7312421342358, 16.5029945373535 }, new double[] { 60.4098738774835, 15.9579469987893 }, new DateTime(2020, 06, 28, 16, 46, 31));
            ////SE

            syncTime = new DateTime(2020, 06, 28, 16, 47, 51);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 13.0530576705933, 10.8525428771973 }, new double[] { 152.075877884869, 169.147457122803 }, new double[] { 152.72162571714, 171.563163746142 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 48, 09);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 12.3489561080933, -0.778456687927246 }, new double[] { 162.71580699319, 180.778456687927 }, new double[] { 163.926678775838, 183.082432087453 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 48, 28);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 13.5954742431641, -0.697973549365997 }, new double[] { 144.097740196623, 180.697973549366 }, new double[] { 144.925319826158, 183.236913318592 }, time);
            // model.AddAlignmentPoint(new double[]{12.9437046051025, 3.28892135620117}, new double[] { 153.945157337934, 176.711078643799 }, new double[] { 154.854211281482, 179.129744501857 }, new DateTime(2020, 06, 28, 16, 48, 45));
            ////NE

            syncTime = new DateTime(2020, 06, 28, 16, 51, 39);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 16.405143737793, 61.4716148376465 }, new double[] { 102.750476080924, 118.528385162354 }, new double[] { 100.26112572701, 120.586627285499 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 52, 00);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 15.4235200881958, 58.8995513916016 }, new double[] { 117.558254360687, 121.100448608398 }, new double[] { 114.734222729235, 122.861582942981 }, time);

            syncTime = new DateTime(2020, 06, 28, 16, 52, 22);
            time     = new TimeRecord(syncTime, TimeUtils.GetLocalSiderealTime(syncTime, utcOffset, longitude));
            model.AddAlignmentPoint(new double[] { 15.9716958999634, 54.6963729858398 }, new double[] { 109.430551501457, 125.30362701416 }, new double[] { 107.541470813369, 127.418045303378 }, time);
            // model.AddAlignmentPoint(new double[]{16.0384006500244, 58.5149154663086}, new double[] { 108.51725186361, 121.485084533691 }, new double[] { 106.174079618103, 123.499884590653 }, new DateTime(2020, 06, 28, 16, 52, 43));
        }
示例#20
0
        /// <summary>
        /// Integration test
        /// </summary>
        public async Task TestBasic()
        {
            string initialName = "InitialName";
            string changedName = "ChangedName";
            // first test the POST.
            var request = new HttpRequestMessage(HttpMethod.Post, "/api/timerecords");

            // create a new object.
            TimeRecord timeRecord = new TimeRecord();

            timeRecord.TimePeriod = initialName;
            string jsonString = timeRecord.ToJson();

            request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");

            var response = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // parse as JSON.
            jsonString = await response.Content.ReadAsStringAsync();

            timeRecord = JsonConvert.DeserializeObject <TimeRecord>(jsonString);
            // get the id
            var id = timeRecord.Id;

            // change the name
            timeRecord.TimePeriod = changedName;

            // now do an update.
            request         = new HttpRequestMessage(HttpMethod.Put, "/api/timerecords/" + id);
            request.Content = new StringContent(timeRecord.ToJson(), Encoding.UTF8, "application/json");
            response        = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // do a get.
            request  = new HttpRequestMessage(HttpMethod.Get, "/api/timerecords/" + id);
            response = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // parse as JSON.
            jsonString = await response.Content.ReadAsStringAsync();

            timeRecord = JsonConvert.DeserializeObject <TimeRecord>(jsonString);

            // verify the change went through.
            Assert.Equal(timeRecord.TimePeriod, changedName);

            // do a delete.
            request  = new HttpRequestMessage(HttpMethod.Post, "/api/timerecords/" + id + "/delete");
            response = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            // should get a 404 if we try a get now.
            request  = new HttpRequestMessage(HttpMethod.Get, "/api/timerecords/" + id);
            response = await _client.SendAsync(request);

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
 public static TimeRecordDto ToDto(this TimeRecord entity)
 {
     return(Mapper.Map <TimeRecordDto>(entity));
 }
示例#22
0
        public static TimeRecordReviewViewModel Create(TimeRecord timeRecord, IRepository repository)
        {
            var timeRecordEntries = repository.OfType<TimeRecordEntry>().Queryable.Where(x => x.Record.Id == timeRecord.Id).OrderBy(x=>x.Date);

            var viewModel = new TimeRecordReviewViewModel
            {
                TimeRecord = timeRecord,
                TimeRecordEntries = timeRecordEntries.ToList()
            };

            return viewModel;
        }
示例#23
0
 void Awake()
 {
     audioSource = GetComponent<AudioSource>();
     tr = GetComponent<TimeRecord>();
 }
示例#24
0
 // Use this for initialization
 void Start()
 {
     myTimeRecord = new TimeRecord ("test", SkyTime.MINUTE * 10, false);
     Debug.Log (myTimeRecord.ToString());
 }
示例#25
0
        /// <summary>
        /// Import Equip(ment) Usage
        /// </summary>
        /// <param name="performContext"></param>
        /// <param name="dbContext"></param>
        /// <param name="fileLocation"></param>
        /// <param name="systemId"></param>
        public static void Import(PerformContext performContext, DbAppContext dbContext, string fileLocation, string systemId)
        {
            // check the start point. If startPoint ==  sigId then it is already completed
            int startPoint = ImportUtility.CheckInterMapForStartPoint(dbContext, OldTableProgress, BcBidImport.SigId, NewTable);

            if (startPoint == BcBidImport.SigId)   // this means the import job completed for all the records in this file
            {
                performContext.WriteLine("*** Importing " + XmlFileName + " is complete from the former process ***");
                return;
            }

            int maxTimesheetIndex = 0;

            if (dbContext.RentalAgreements.Any())
            {
                maxTimesheetIndex = dbContext.RentalAgreements.Max(x => x.Id);
            }

            try
            {
                string rootAttr = "ArrayOf" + OldTable;

                // create Processer progress indicator
                performContext.WriteLine("Processing " + OldTable);
                IProgressBar progress = performContext.WriteProgressBar();
                progress.SetValue(0);

                // create serializer and serialize xml file
                XmlSerializer ser          = new XmlSerializer(typeof(EquipUsage[]), new XmlRootAttribute(rootAttr));
                MemoryStream  memoryStream = ImportUtility.MemoryStreamGenerator(XmlFileName, OldTable, fileLocation, rootAttr);
                EquipUsage[]  legacyItems  = (EquipUsage[])ser.Deserialize(memoryStream);

                int ii = startPoint;

                // skip the portion already processed
                if (startPoint > 0)
                {
                    legacyItems = legacyItems.Skip(ii).ToArray();
                }

                Debug.WriteLine("Importing TimeSheet Data. Total Records: " + legacyItems.Length);

                foreach (EquipUsage item in legacyItems.WithProgress(progress))
                {
                    // see if we have this one already
                    string oldProjectKey  = item.Project_Id.ToString();
                    string oldEquipKey    = item.Project_Id.ToString();
                    string oldCreatedDate = item.Created_Dt;

                    string oldKey = string.Format("{0}-{1}-{2}", oldProjectKey, oldEquipKey, oldCreatedDate);

                    ImportMap importMap = dbContext.ImportMaps.FirstOrDefault(x => x.OldTable == OldTable &&
                                                                              x.OldKey == oldKey);

                    // new entry
                    if (importMap == null && item.Equip_Id > 0)
                    {
                        TimeRecord instance = null;
                        CopyToTimeRecorded(dbContext, item, ref instance, systemId, ref maxTimesheetIndex);

                        if (instance != null)
                        {
                            ImportUtility.AddImportMap(dbContext, OldTable, oldKey, NewTable, instance.Id);
                        }
                    }

                    // save change to database periodically to avoid frequent writing to the database
                    if (ii++ % 1000 == 0)
                    {
                        try
                        {
                            ImportUtility.AddImportMapForProgress(dbContext, OldTableProgress, ii.ToString(), BcBidImport.SigId, NewTable);
                            dbContext.SaveChangesForImport();
                        }
                        catch (Exception e)
                        {
                            performContext.WriteLine("Error saving data " + e.Message);
                        }
                    }
                }

                try
                {
                    performContext.WriteLine("*** Importing " + XmlFileName + " is Done ***");
                    ImportUtility.AddImportMapForProgress(dbContext, OldTableProgress, BcBidImport.SigId.ToString(), BcBidImport.SigId, NewTable);
                    dbContext.SaveChangesForImport();
                }
                catch (Exception e)
                {
                    string temp = string.Format("Error saving data (RentalAgreementIndex: {0}): {1}", maxTimesheetIndex, e.Message);
                    performContext.WriteLine(temp);
                    throw new DataException(temp);
                }
            }
            catch (Exception e)
            {
                performContext.WriteLine("*** ERROR ***");
                performContext.WriteLine(e.ToString());
                throw;
            }
        }