示例#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
        }
示例#2
0
        public override async Task <SyncResult> Receive(Guid token)
        {
            try
            {
                EquipmentGroupBillRate.Refresh();
                using (HttpClient client = new HttpClient())
                {
                    client.Init(token);

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

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

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

                        list.ForEach(x =>
                        {
                            string sql = $"insert EquipmentGroupBillRate(CompanyId, ProjectId, GroupCode, GroupType, BillCycle, BillRate, IsDefault, InSync) " +
                                         $"values({x.CompanyId}, {StrEx.ValueOrNull(x.ProjectId)}, '{x.GroupCode}', '{(char)x.GroupType}', '{(char)x.BillCycle}', {x.BillRate}, '{x.IsDefault}', 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
                });
            }
        }