how do you add the departure date time in the request for C#? here is part of the code
refOrgDest = new BFMV430.OTA_AirLowFareSearchRQOriginDestinationInformation
{
OriginLocation = new BFMV430.OriginDestinationInformationTypeOriginLocation { LocationCode
= refItin.Origin },
DestinationLocation = new BFMV430.OriginDestinationInformationTypeDestinationLocation { LocationCode = refItin.Destination },
RPH = (i + 1).ToString(),
TPA_Extensions = new BFMV430.OTA_AirLowFareSearchRQOriginDestinationInformationTPA_Extensions
{
CabinPref = new BFMV430.CabinPrefType
{
Cabin = (BFMV430.CabinType)Enum.Parse(typeof(BFMV430.CabinType), refResBookType, true),
PreferLevel = BFMV430.PreferLevelType.Preferred,
CabinSpecified = true,
}
},
ItemElementName = BFMV430.ItemChoiceType.DepartureDateTime,
Item = new BFMV430.TravelDateTimeType
{
DepartureWindow = "00002359",
},
};
refOrgDestList.Add(refOrgDest);
also I'm getting this mismatch error when running it
Value of ItemElementName mismatches the type of System.String; you need to set it to prjWService.BFMV430.ItemChoiceType.#DepartureDateTime.
any help would be great.
thanks in advance
Here is a piece of code that could help you, the interesting part is about the date format expected by Sabre for all transaction related to search flight/availability, it means (BMF, ADVShopping, AirLowFare and etc is gonna to use the same date format). (2019-04-14T00:00:00)
__ItemOriginDestination = new AdvacedAirShopping.OTA_AirLowFareSearchRQOriginDestinationInformation
{
RPH = "1",
ItemElementName = AdvacedAirShopping.ItemChoiceType.DepartureDateTime,
Item = _FlightSearch.DepartureDateTime, //"2019-04-14T00:00:00" Here is the format expected by Sabre
OriginLocation = new AdvacedAirShopping.OriginDestinationInformationTypeOriginLocation
{
LocationCode = _FlightSearch.Origin
},
DestinationLocation = new AdvacedAirShopping.OriginDestinationInformationTypeDestinationLocation
{
LocationCode = _FlightSearch.Destination
}
};
Related
I'm using ElarsticSearch 7.7 & NEST 7.7 and on my web page, I'm getting 9 search result documents per page. Even I'm showing the first 9 results on the page, I need to return some property values from all the results for side filtration on the web page.
Eg: if I'm searching "LapTop", my page will show 9 results on the first page. Also, I need to show all the "Manufactures" from all the search results. Not only manufacturers in the first-page result. Then customers can filter by manufacture not only display on the first page.
I have tried GlobalAggregation but it returns categories and manufactures only items in selected page.
public SearchResult Search(SearchType searchType, string searchQuery, int storeId, int pageNumber = 1, int pageSize = 12, IList<SearchFilter> requestFilter = null, decimal? priceFrom = 0, decimal? priceTo = 100000000, string sortBy = null, int totalCount = 0)
{
var queryContainer = new QueryContainer();
var sorts = new List<ISort>();
sorts.Add(new FieldSort { Field = "_score", Order = SortOrder.Descending });
switch (sortBy)
{
case "z-a":
sorts.Add(new FieldSort { Field = Field<ElasticIndexGroupProduct>(p => p.SortValue), Order = SortOrder.Descending });
break;
case "a-z":
sorts.Add(new FieldSort { Field = Field<ElasticIndexGroupProduct>(p => p.SortValue), Order = SortOrder.Ascending });
break;
}
var aggrigations = new AggregationDictionary
{
{"average_per_child", new
AverageAggregation("average_per_child",Field<ElasticIndexGroupProduct>(d => d.Price))},
{"max_per_child", new MaxAggregation("max_per_child",Field<ElasticIndexGroupProduct>(d => d.Price))},
{"min_per_child", new MinAggregation("min_per_child", Field<ElasticIndexGroupProduct>(d => d.Price))},
{
"globle_filter_aggrigation", new GlobalAggregation("globle_filter_aggrigation")
{
Aggregations =new AggregationDictionary
{
{"category_flow", new TermsAggregation("category_flow"){Field = Field<ElasticIndexGroupProduct>(p => p.CategoryFlow)} },
{"manufacturers", new TermsAggregation("manufacturers"){Field = Field<ElasticIndexGroupProduct>(p => p.Manufacturer)} }
}
}
}
};
var searchRequest = new SearchRequest<ElasticIndexGroupProduct>()
{
Profile = true,
From = (pageNumber - 1) * pageSize,
Size = pageSize,
Version = true,
Sort = sorts,
//Scroll = Time.MinusOne,
Aggregations = aggrigations
};
var multiMatch = new QueryStringQuery
{
Query = searchQuery,
Fields = GetSearchFields(searchType),
Boost = 1.1,
Name = "named_query",
DefaultOperator = Operator.Or,
Analyzer = "standard",
QuoteAnalyzer = "keyword",
AllowLeadingWildcard = true,
MaximumDeterminizedStates = 2,
Escape = true,
FuzzyPrefixLength = 2,
FuzzyMaxExpansions = 3,
FuzzyRewrite = MultiTermQueryRewrite.ConstantScore,
Rewrite = MultiTermQueryRewrite.ConstantScore,
Fuzziness = Fuzziness.Auto,
TieBreaker = 1,
AnalyzeWildcard = true,
MinimumShouldMatch = 2,
QuoteFieldSuffix = "'",
Lenient = true,
AutoGenerateSynonymsPhraseQuery = false
};
searchRequest.Query = new BoolQuery
{
Must = new QueryContainer[] { multiMatch },
Filter = new QueryContainer[] { queryContainer }
};
var searchResponse = _client.Search<ElasticIndexGroupProduct>(searchRequest);
var categoryFlowsGlobe = new List<string>();
var allAggregations = searchResponse.Aggregations.Global("globle_filter_aggrigation");
var categories = allAggregations.Terms("category_flow");
foreach (var aggItem in categories.Buckets)
{
if (!categoryFlowsGlobe.Any(x => x == aggItem.Key))
{
categoryFlowsGlobe.Add(aggItem.Key);
}
}
}
This is the exact use case for Post filter - to run a search request that returns hits and aggregations, then to apply filtering to the hits after aggregations have been calculated.
For Manufacturers, these can be retrieved with a terms aggregation in the search request - you can adjust the size on the aggregation if you need to return all manufacturers, otherwise you might decide to return only the top x.
Well, I am preparing a data entry application on the ASP platform, netcore2.1, it's my first application so I have approached it like a laravel project, so with little to no Razor format that could have saved me a lot of time, I get it.
The problem I am facing is there is a method called getAllData, which flies around the database and fetch data for editing of around 60 boxes. I run it repeatedly since I faced many smaller errors and after a few reruns the result just stops coming in. breakpoints show at least some of the data is being prepared to be set to a List but never makes it there. I used nested datareaders to get a single long list. it now will only run once and it's no more detected. There is no error prompt. I am baffled as to why and need help.
Controller Action from JS, same story when running from controller too...
var theId = $("#ProjectId").val();
var theId2 = $("#InvestorId").val();
$.ajax({
url: '/Home/getAllData/',
dataType: "json",
type: "GET",
data: { id: theId, id2: theId2 },
contentType: 'application/json',
async: true,
processData: true,
cache: false,
success: function (response) {
response = JSON.parse(JSON.stringify(response));
if (response[0] == null) {
alertify.error("Nothing is Coming In!! possibly too many tries at setting its values");
} else {
//LOAD THE DATA TO PAGE ELEMENTS
}
it keeps triggering the alertify and a console.log shows an empty array...message reflects my exp.
public List<AllData> getAllData(int id, int id2)
{
SqlConnection con = new SqlConnection(GetConStringTemp.ConString());
string query = "Select --- where ProjectId=" + id + "";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
var temp = new List<AllData>();
var plannedProjectOutput = new List<PlannedServiceViewModel>();
var actualProjectOutput = new List<ActualServiceViewModel>();
var investorAddress = new List<InvestorAddressViewModel>();
//a bunch more vars...
var queryOutput = "Select --- where ProjectId=" + id + "";
var cmdOutput = new SqlCommand(queryOutput, con);
var readerOutput = cmdOutput.ExecuteReader();
while (readerOutput.Read())
{
if (readerOutput.GetBoolean(1) == true)
{
actualProjectOutput.Add(new ActualServiceViewModel
{
TypeOfProduct = readerOutput.IsDBNull(0) ? "" : readerOutput.GetString(0),
ActualQuantity = readerOutput.IsDBNull(2) ? 0 : readerOutput.GetDecimal(2),
ActualUnits = readerOutput.IsDBNull(3) ? "" : readerOutput.GetString(3),
ActualDomestic = readerOutput.IsDBNull(4) ? 0 : readerOutput.GetDecimal(4),
ActualExport = readerOutput.IsDBNull(5) ? 0 : readerOutput.GetDecimal(5)
});
}
else
{
plannedProjectOutput.Add(new PlannedServiceViewModel
{
TypeOfProduct = readerOutput.IsDBNull(0) ? "" : readerOutput.GetString(0),
PlannedQuantity = readerOutput.IsDBNull(2) ? 0 : readerOutput.GetDecimal(2),
PlannedUnits = readerOutput.IsDBNull(3) ? "" : readerOutput.GetString(3),
PlannedDomestic = readerOutput.IsDBNull(4) ? 0 : readerOutput.GetDecimal(4),
PlannedExport = readerOutput.IsDBNull(5) ? 0 : readerOutput.GetDecimal(5)
});
}
}
readerOutput.Close();
// a bunch more definitions too...
while (reader.Read())
{
var cmd2 = new SqlCommand("Select --- from Investor where InvestorId=" + id2 + "", con);
SqlDataReader reader2 = cmd2.ExecuteReader();
while (reader2.Read())
{
if (reader2.GetString(0) == "4")
{
var queryCompany = "Select ---- from Investor where InvestorId=" + id2 + "";
var cmdCompany = new SqlCommand(queryCompany, con);
var readerCompany = cmdCompany.ExecuteReader();
while (readerCompany.Read())
{
var queryReq = "Select ---- where ProjectId=" + id + "";
var cmdReq = new SqlCommand(queryReq, con);
var readerReq = cmdReq.ExecuteReader();
while (readerReq.Read())
{
var queryCostPlanned = "Select ---- ProjectCost where ProjectId=" + id + " AND isActual=0";
var cmdCostPlanned = new SqlCommand(queryCostPlanned, con);
var readerCostPlanned = cmdCostPlanned.ExecuteReader();
while (readerCostPlanned.Read())
{
var queryCostActual = "Select --- from ProjectCost where ProjectId=" + id + " AND isActual=1";
var cmdCostActual = new SqlCommand(queryCostActual, con);
var readerCostActual = cmdCostActual.ExecuteReader();
while (readerCostActual.Read())
{
var queryEmployementPlanned = "Select --- where ProjectId=" + id + " AND isActual=0";
var cmdEmployementPlanned = new SqlCommand(queryEmployementPlanned, con);
var readerEmployementPlanned = cmdEmployementPlanned.ExecuteReader();
while (readerEmployementPlanned.Read())
{
var queryEmployementActual = "Select --- where ProjectId=" + id + " AND isActual=1";
var cmdEmployementActual = new SqlCommand(queryEmployementActual, con);
var readerEmployementActual = cmdEmployementActual.ExecuteReader();
while (readerEmployementActual.Read())
{
temp.Add(new AllData
{
LegalStatus = reader2.IsDBNull(0) ? "" : reader2.GetString(0),
FirstName = readerCompany.IsDBNull(1) ? "" : readerCompany.GetString(1),
FirstNameAmh = readerCompany.IsDBNull(0) ? "" : readerCompany.GetString(0),
TINNumber = readerCompany.IsDBNull(2) ? "" : readerCompany.GetString(2),
UserId = readerCompany.IsDBNull(3) ? "" : readerCompany.GetString(3),
TypeInvestor = readerCompany.IsDBNull(4) ? "" : readerCompany.GetString(4),
BranchPlace = readerCompany.IsDBNull(5) ? "" : readerCompany.GetString(5),
CountryOfOrigin = readerCompany.IsDBNull(6) ? "" : readerCompany.GetString(6),
ProjectName = reader.IsDBNull(1) ? "" : reader.GetString(1),
ProjectDescription = reader.IsDBNull(2) ? "" : reader.GetString(2),
FileNumber = reader.IsDBNull(19) ? "" : reader.GetString(19),
StartDate = reader.IsDBNull(3) ? "" : reader.GetString(3),
OperationDate = reader.IsDBNull(4) ? "" : reader.GetString(4)
// a bunch more assignments
});
}
readerEmployementActual.Close();
}
readerEmployementPlanned.Close();
}
readerCostActual.Close();
}
readerCostPlanned.Close();
}
readerReq.Close();
}
readerCompany.Close();
}
else
{
same with some difference....
}
reader.Close();
con.Close();
AllDatas = temp;
return AllDatas;
}
its a handful, it usually works, it won't if you attempt to get it one too many times,
Thanks
I managed to get the resultset. the way i approached it, while i made all the queries cascade to get a single unified List, I discovered there were some blanks or null returns, but since i coded it with nulls in mind i didn't get why it didn't work in this specific instance. while i still did not find out why, i disassembled the queries from nested datareaders to individual ones and it isolated the faulty query and made others work.
Rule of thumb, don't cascade datareaders if you can, i have them working in some other section of the program but this was the most complex. it will save you a lot of headaches.
I have this piece of code like this:
var options = new DynamoDBOperationConfig
{
ConditionalOperator = ConditionalOperatorValues.Or,
OverrideTableName = nameTable,
ConsistentRead = true
};
new QueryOperationConfig()
{
IndexName = indexName,
Filter = queryFilter,
Select = SelectValues.Count
};
result = context.FromQueryAsync<TEntity>(queryConfig, options).GetRemainingAsync().Result;
as per the documentation, it should return just the count of values that match the filter, at least, the piece of code in the SelectValues class says that
//
// Summary:
// An enumeration of all supported Select values for Query and Scan. Value of Count
// will force service to return the number of items, not the items themselves.
but result is always an empty list; how can i make the count work ?
If you are still looking for the answer, this is the solution:
new QueryOperationConfig()
{
IndexName = indexName,
Filter = queryFilter,
Select = SelectValues.Count,
ConsistentRead = true
};
var table = context.GetTargetTable<TEntity>();
var search = table.Query(queryConfig);
result = search.Count;
Having ConsistentRead set to true will cause it to give you real time updates when the table is updated.
It's not working on Document level...
You can try to do this in low level model.
int count = 0;
Dictionary<string, AttributeValue> lastKey = null;
do
{
var request = new QueryRequest
{
TableName = "tableNmae",
IndexName = "indexName",
KeyConditionExpression = "ID= :v_ID",
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{
":v_ID",
new AttributeValue
{
N = "1"
}
}
},
ConsistentRead = false,
Select = Select.COUNT,
ExclusiveStartKey = lastKey
};
var respone = await tableClient.QueryAsync(request);
count += respone.Count;
lastKey = respone.LastEvaluatedKey;
} while (lastKey != null && lastKey.Count != 0);
So, I'm doing translations for a game, and I have different dictionaries. If a translation doesn't exist in one language, I want to set it to the English translation. Every method I've tried to combine the dictionaries has ended up incredibly inefficient.
Here are some cut down examples
local translation-sr = {
Buttons = {
Confirm = "Потврди";
Submit = "Унеси";
};
Countries = {
Bloxell = "Блоксел";
USA = "Сједињене Америчке Државе";
};
Firearms = {
Manufacturers = {
GenMot = "Џенерални Мотори";
Intratec = "Интратек";
TF = "ТФ Оружје";
};
};
};
local translation-en = {
Buttons = {
Confirm = "Confirm";
Purchase = "Purchase";
Submit = "Submit";
};
Countries = {
Bloxell = "Bloxell";
USA = "United States";
};
Firearms = {
Manufacturers = {
GenMot = "General Motors";
Intratec = "Intratec ";
TF = "TF Armaments";
};
};
Languages = {
Belarusian = "Belarusian";
English = "English";
French = "French";
German = "German";
Italian = "Italian";
Russian = "Russian";
Serbian = "Serbian";
Spanish = "Spanish";
};
};
I guess you want to do something like this
setmetatable(translation_sr.Buttons,{__index=translation_en.Buttons})
for all leaf subtables. You can do this by hand if there are only a few subtables.
I believe you should use a metatable to accomplish what you need.
I assume that you will always index by the English default word. With that true you can do the following.
local function default(t,k)
return k
end
local translation_sr = {
Button = setmetatable({
Confirm = "Потврди",
Submit = "Унеси",
},
{ __index = default }),
Countries = setmetatable({
["Bloxell"] = "Блоксел",
["United States"]= "Сједињене Америчке Државе",
},
{ __index = default }),
Firearms = {
Manufacturers = setmetatable({
["General Motors"] = "Џенерални Мотори",
["Intratec"] = "Интратек",
["TF Armaments"] = "ТФ Оружје",
},
{ __index = default }),
},
}
This function simply returns your key that was not present in the table.
local function default(t,k)
return k
end
With this key being assumed to be the English word you would use as the default the returned value for "Purchase" you would get "Purchase" back from the translation_sr. This method requires no translation_en table
i am creating new record in 'Timecard' table and at the same time i want to create one record in 'TimecardStatusTrack' table using entity framework. i am able to create parent record but while adding child record i am getting exception. the code i have written is like
var fEmpManager = DependencyContainer.GetInstance<IBusinessService<FacilityEmployee>>();
int timecardStatusDidNotWork =
Convert.ToInt32(GeneralCodeId.TimeCardStatusDidNotWork, CultureInfo.InvariantCulture);
Timecard timecard = new Timecard();
TimecardStatusTrack timecardStatus = new TimecardStatusTrack();
try
{
var fEmp = fEmpManager.Where(w => w.JobId == jobId && w.AgencyBiddingProfile.AgencyCandidateId == agencyCandidateId).FirstOrDefault();
timecard.JobId = jobId;
timecard.AgencyCandidateId = agencyCandidateId;
timecard.WeekStartDate = Convert.ToDateTime(weekStartDate, CultureInfo.InvariantCulture);
timecard.WeekEndDate = Convert.ToDateTime(weekEndDate, CultureInfo.InvariantCulture);
timecard.FacilityEmployeeId = fEmp.Id;
timecard.FacilityId = fEmp.FacilityId;
timecard.TimecardStatusGCId = timecardStatusDidNotWork;
timecard.AddUser = SessionManager.AuthorizedInfo.UserId;
timecard.AddDate = DateTime.Now;
timecardStatus.TimecardStatusGCId = timecardStatusDidNotWork;
timecardStatus.AddUser = SessionManager.AuthorizedInfo.UserId;
timecardStatus.AddDate = DateTime.Now;
timecardStatus.UpdatedBy = SessionManager.AuthorizedInfo.UserId;
timecardStatus.Comments = string.Empty;
_ViewTimeCardBusibessService.Create(timecard);
timecard.TimecardStatusTracks.Add(timecardStatus);
_ViewTimeCardBusibessService.Update(timecard);
}
catch (Exception ex)
{
HandleValidationErrors(ex);
}
finally
{
DependencyContainer.ReleaseInstance(fEmpManager);
}