Beispiel #1
0
        public void SavePendingUpdates(Stream stream, int ddpUpdateId)
        {
            XmlDocument newdoc = new XmlDocument();

            newdoc.Load(stream);

            //---------------------------------------------------
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(newdoc.NameTable);

            nsmanager.AddNamespace("lr", "http://gisis.imo.org/XML/LRIT/ddp/2008");
            //---------------------------------------------------

            XmlNode root = newdoc.SelectSingleNode("/lr:DataDistributionPlan-IncrementalUpdate", nsmanager);

            var pendingUpdates = new List <PendingDDPUpdate>();

            //Recorrer inmediata si hubiese
            foreach (XmlNode inmediate in newdoc.SelectNodes("/lr:DataDistributionPlan-IncrementalUpdate/lr:Immediate", nsmanager))
            {
                var update = new PendingDDPUpdate();
                update.baseVersion        = inmediate.Attributes["baseImmediateVersionNum"].Value;
                update.ddpUpdateId        = ddpUpdateId;
                update.implementationTime = DateTime.Parse(inmediate.Attributes["targetImplementationAt"].Value);
                update.targetVersion      = inmediate.Attributes["targetImmediateVersionNum"].Value;
                update.type = 0;

                pendingUpdates.Add(update);
            }

            //Recorrer regulares si hubiese
            foreach (XmlNode inmediate in newdoc.SelectNodes("/lr:DataDistributionPlan-IncrementalUpdate/lr:Regular", nsmanager))
            {
                var update = new PendingDDPUpdate();
                update.baseVersion        = inmediate.Attributes["baseRegularVersionNum"].Value;
                update.ddpUpdateId        = ddpUpdateId;
                update.implementationTime = DateTime.Parse(inmediate.Attributes["targetImplementationAt"].Value);
                update.targetVersion      = inmediate.Attributes["targetRegularVersionNum"].Value;
                update.type = 1;

                pendingUpdates.Add(update);
            }

            PendingUpdateManager.Insert(pendingUpdates);
        }
Beispiel #2
0
        public void ProcessPendingUpdates()
        {
            DDPImportHelper helper = new DDPImportHelper();

            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, TimeSpan.FromMinutes(10)))
            {
                try
                {
                    var ddpvermgr = new DDPVersionManager();

                    var pendings = PendingUpdateManager.GetPendingUpdates();
                    foreach (var pending in pendings)
                    {
                        DDPVersion ver = null;
                        if (pending.type == 0)
                        {
                            ver = ddpvermgr.GetInmediateDDPVersion(pending.targetVersion);
                        }
                        else
                        {
                            ver = ddpvermgr.GetRegularDDPVersion(pending.targetVersion);
                        }

                        if (ver != null)
                        {
                            log.Info(string.Format("ProcessPendingUpdates: version {0} already exists skping ...", pending.targetVersion));
                            continue;
                        }

                        helper.UpdateIncrementalOrRegular(pending);
                    }

                    using (var d = new PendingUpdatesDataAccess())
                    {
                        d.Remove(pendings);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("ProcessPendingUpdates: error!", ex);
                }
                ts.Complete();
            }
        }