Beispiel #1
0
        public List <EquipmentBillRate> GetBillRateList(int projectId)
        {
            List <EquipmentBillRate> list;
            ProjectEquipmentClass    projClass = ProjectEquipmentClass.GetProjectEquipmentClass(projectId, ClassCode);

            if (!UseOveride && (projClass?.UseOverride ?? false) == false)
            {
                list = EquipmentGroupBillRate.GetBillRatesForGroup(projectId, ClassCode, CategoryCode).Select(r => new EquipmentBillRate {
                    BillCycle = r.BillCycle, BillRate = r.BillRate, IsDefault = r.IsDefault
                }).ToList();
                if (list.Any())     //Link to project * group(class or category)
                {
                    return(list);
                }

                list = EquipmentGroupBillRate.GetBillRatesForGroup(null, ClassCode, CategoryCode).Select(r => new EquipmentBillRate {
                    BillCycle = r.BillCycle, BillRate = r.BillRate, IsDefault = r.IsDefault
                }).ToList();
                if (list.Any())     // Link to Group (class or category)
                {
                    return(list);
                }
            }

            list = EquipmentBillRate.GetBillRatesForEquipment(EqpNum);          // link to Equip
            if (list.Any())
            {
                return(list);
            }

            return(EquipmentDefaultBillRate.GetDefaultBillRates().Select(r => new EquipmentBillRate {
                BillCycle = r.BillCycle, BillRate = r.BillRate, IsDefault = r.IsDefault
            }).ToList());                                                                                                                                                                  // Link to Default
        }
Beispiel #2
0
        public static bool CopyDataFromTemplate(int projectId, DateTime currDate, int currHeaderId)
        {
            var filtered = EquipmentTemplate.GetTemplate(projectId, currDate);

            if (filtered.Count > 0)
            {
                Project project = Project.GetProject(projectId);

                foreach (var src in filtered)
                {
                    Equipment equip    = GetEquipment(src.EqpNum);
                    Employee  employee = (equip.OwnerType == EnumOwnerType.Employee) ? EquipmentAssignment.GetEmployee(equip.EqpNum, currDate) : null;
                    var       pec      = ProjectEquipmentClass.GetProjectEquipmentClass(projectId, src.EquipClassCode);
                    SqlInsert(currHeaderId, src.EqpNum, employee?.EmpNum, null, null, null, null, null, project.Billable, 0, pec.BillCycle, null);
                }
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        public override async System.Threading.Tasks.Task <SyncResult> Receive(Guid token)
        {
            try
            {
                ProjectEquipmentClass.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

                    HttpResponseMessage response = await client.GetAsync($"api/ProjectEquipmentClasses?companyId={CompanyId}");

                    if (response.IsSuccessStatusCode)
                    {
                        UpdateStatus(EnumTableSyncStatus.Receiving);

                        List <ProjectEquipmentClass> list = await response.Content.ReadAsAsync <List <ProjectEquipmentClass> >();

                        list.ForEach(x =>
                        {
                            string sql = $"insert ProjectEquipmentClass(MatchId, companyId, ProjectId, ClassCode, Schedulable, UseOverride, BillRate, BillCycle, InSync) " +
                                         $"values({x.MatchId}, {x.CompanyId}, {x.ProjectId}, '{x.ClassCode}', '{x.Schedulable}', '{x.UseOverride}', {x.BillRate}, '{(char)x.BillCycle}', 1)";
                            MobileCommon.ExecuteNonQuery(sql);
                        });

                        UpdateStatus(EnumTableSyncStatus.CompleteReceive);
                        return(new SyncResult {
                            Successful = true
                        });
                    }
                    throw new Exception($"Response StatusCode={response.StatusCode}");
                }
            }
            catch (Exception e)
            {
                UpdateStatus(EnumTableSyncStatus.ErrorInReceive);
                return(new SyncResult {
                    Successful = false, Task = TableName, Message = e.Message
                });
            }
        }
Beispiel #4
0
        public EnumBillCycle GetDefaultBillCycle(int projectId)
        {
            ProjectEquipmentClass projClass = ProjectEquipmentClass.GetProjectEquipmentClass(projectId, ClassCode);

            return(projClass.BillCycle);
        }
Beispiel #5
0
        public static List <EquipmentTemplate> GetTemplate(int projectId, DateTime currDate)
        {
            var codeList = ProjectEquipmentClass.ListForProject(projectId).Where(x => x.Schedulable == true).Select(x => x.ClassCode);

            return(ListForProject(projectId).Where(x => (x.StartDate == null || x.StartDate < currDate) && (x.EndDate == null || x.EndDate > currDate) && codeList.Contains(x.EquipClassCode)).ToList());
        }