Exemplo n.º 1
0
 public void AddResponseData(LaGouResponseData data)
 {
     if (data == null)
     {
         return;
     }
     Companies.AddRange(data.Companies.Select(p => new KeyValuePair <int, LaGouCompanyEntity>(p.CompanyId, p)));
     Positions.AddRange(data.Positions.Select(p => new KeyValuePair <long, LaGouPositionEntity>(p.PositionId, p)));
     HrInfos.AddRange(data.HrInfos.Select(p => new KeyValuePair <long, LaGouHrInfoEntity>(p.UserId, p)));
     HrDailyRecords.AddRange(data.HrDailyRecords.Select(p => new KeyValuePair <long, LaGouHrDailyRecordEntity>(p.UserId, p)));
 }
Exemplo n.º 2
0
            public static LaGouResponseData CreateResponseData(string response, out string showId)
            {
                showId = null;
                JToken source  = JsonTool.DeserializeObject <JToken>(response);
                JToken content = source?.Value <JToken>("content");

                if (content == null)
                {
                    return(null);
                }
                showId = content.Value <string>("showId");
                JToken positionResult = content.Value <JToken>("positionResult");
                JArray positions      = positionResult?.Value <JArray>("result");

                if (positions.IsNullOrEmpty())
                {
                    return(null);
                }
                LaGouResponseData result = new LaGouResponseData(positions.Count);
                var hrInfoMap            = content.Value <JToken>("hrInfoMap")?.ToObject <Dictionary <string, JToken> >();

                if (!hrInfoMap.IsNullOrEmpty())
                {
                    foreach (var pos in positions)
                    {
                        var responseItem = CreateResponseItem(pos);
                        if (responseItem != null)
                        {
                            if (responseItem.Position != null)
                            {
                                if (hrInfoMap.TryGetValue(responseItem.Position.PositionId.ToString(), out var temp))
                                {
                                    FillHrInfoEntity(responseItem.HrInfo, (JObject)temp);
                                }
                            }
                            result.AddResponseItem(responseItem);
                        }
                    }
                }
                else
                {
                    foreach (var pos in positions)
                    {
                        var responseItem = CreateResponseItem(pos);
                        if (responseItem != null)
                        {
                            result.AddResponseItem(responseItem);
                        }
                    }
                }
                return(result);
            }