Beispiel #1
0
        /// <summary>
        /// Procesa un mensaje de tipo DDP Update.
        /// Esta funcion utiliza el DDPImportHelper para incorporar la informacion del DDP en formato XML a la base de datos.
        /// </summary>
        /// <param name="msg">Mensaje de DDP Update</param>
        public void ProcessDDPUpdate(DDPUpdateType ddpUpdate)
        {
            DDPUpdate dbupd;

            using (DDPUpdateDataAccess dao = new DDPUpdateDataAccess())
            {
                dbupd = dao.Create(TypeHelper.Map2DB(ddpUpdate), 0);
            }

            if (ddpUpdate.UpdateType != DDPUpdateTypeUpdateType.Item4)
            {
                //Full??
                if (ddpUpdate.UpdateType == DDPUpdateTypeUpdateType.Item3)
                {
                    ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ZipFile(new MemoryStream(ddpUpdate.DDPFile));

                    var ddpVersion = InsertCompleteDDP(ddpUpdate, DateTime.UtcNow.AddYears(-100));

                    log.Info("ProcessDDPUpdate: Starting full");
                    DDPImportHelper importer = new DDPImportHelper();
                    ddpVersion.published_at = importer.Import(zipFile.GetInputStream(0), ddpVersion);
                    zipFile.Close();

                    using (DDPVersionDataAccess ddpverda = new DDPVersionDataAccess())
                    {
                        ddpverda.update(ddpVersion);
                    }
                }
                else
                {
                    //Salvamos como updates pendientes y luego el scheduler procesa (incrementales y regulares)
                    ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ZipFile(new MemoryStream(ddpUpdate.DDPFile));
                    DDPImportHelper importer = new DDPImportHelper();
                    importer.SavePendingUpdates(zipFile.GetInputStream(0), dbupd.Id);
                    log.Info("ProcessDDPUpdate: Saved in pending updates..");
                    zipFile.Close();
                }
            }
            else
            {
                log.Info("ProcessDDPUpdate: Not processing archived or mixed incr/reg ddpupdate");
            }

            log.Info("ProcessDDPUpdate: DDPUpdate finished");
        }
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();
            }
        }