0
我想弄清楚如何序列化多個對象成一個巨大的XML文件批量寫入到Redis緩存服務器。我知道如何序列化來自每個單獨對象的數據,但我需要將所有對象的所有數據批量化爲單個文件並將其寫入到redis。需要幫助序列化多個對象緩存到redis使用C#
問題: 如何批量序列化的數據的多個變量的多個對象
碼生成每個對象:
private void Initialize()
{
// runs through a list of 600ish skills and creates a call data generator for each skill
foreach (var skill in _skills)
{
IFeedServiceAgent feedService = new FeedServiceAgent();
feedService.Subscribe(skill.SkillNumber.ToString(), skill.CallServer);
CallDataGenerator calldata = new CallDataGenerator(_callDataRepo, feedService);
_callDataGenerators.Add(calldata);
Console.WriteLine("Instance of " + skill.SkillNumber + " From Call Server " + skill.CallServer + " is preparing to start");
}
}
每個發生器產生相同類型的信息,但用於在不同技術人員提供了呼叫系統。大約有600個技能,600個發電機。正在生成
數據示例:
_skillData.OldestCall = e.CmsData.Skill.OldestCall;
_skillData.AgentsStaffed = e.CmsData.Skill.AgentsStaffed;
_skillData.AgentsAuxed = e.CmsData.Skill.AgentsInAux;
_skillData.AgentsAvailable = e.CmsData.Skill.AgentsAvailable;
_skillData.AgentsOnCalls = e.CmsData.Skill.AgentsOnAcdCall;
_skillData.CallsWaitingInQueue = e.CmsData.Skill.InQueueInRing;
_skillData.Asa = e.CmsData.Skill.AnswerTimePerAcdCall;
_skillData.TimeSubmitted = DateTime.Now;
_skillData.EstimatedHoldTimeLow = e.CmsData.Skill.ExpectedWaitTimeLow;
_skillData.EstimatedHoldTimeMedium = e.CmsData.Skill.ExpectedWaitTimeMedium;
_skillData.EstimatedHoldTimeHigh = e.CmsData.Skill.ExpectedWaitTimeHigh;
_agentData.AgentName = item.AgName;
_agentData.AgentExtension = item.Extension;
_agentData.AgentAuxReason = item.AuxReasonDescription;
_agentData.AgentId = item.LoginId;
_agentData.AgentAcdState = item.WorkModeDirectionDescription;
_agentData.AgentTimeInState = DateTime.Now - item.DateTimeUpdated;
_agentData.TimeSubmitted = DateTime.Now;
我考慮創建一個列表並將所有生成器添加到列表中,但它只會發送生成器對象,而不會生成該生成器分配的其他對象,I.E. _agentData或_skillData 我認爲 – michaeltc1989
我應該糾正自己。我知道這是我想要做的,但它不起作用,因爲包含在生成器對象內的對象不會被添加到xml中 – michaeltc1989
對象必須公開到序列化器,否則它們不會被添加到xml中。 – jdweng