Esempio n. 1
0
        /// <summary>
        /// Must be called from the Cloud Master.  Syncs Cloud master with all cloud servers
        /// </summary>
        public static string ServerSync()
        {
            // Get the current data version
            string toVersionString = string.Empty;

            AndroAdminDataAccessFactory.GetSettingsDAO().GetByName("DataVersion", out toVersionString);

            int toVersion = 0;

            if (!int.TryParse(toVersionString, out toVersion))
            {
                return("Internal error");
            }

            // Get all the hosts
            IList <AndroAdminDataAccess.Domain.Host> hosts = AndroAdminDataAccessFactory
                                                             .GetHostDAO()
                                                             .GetAll();

            string errorMessage = string.Empty;

            foreach (AndroAdminDataAccess.Domain.Host host in hosts)
            {
                // 1) Ask the server for it's current data version
                int fromVersion = 0;
                errorMessage = AcsSyncHelper.GetAcsServerDataVersion(host, out fromVersion);

                //todo make the response enumerable
                //yield errorMessage

                if (errorMessage.Length == 0)
                {
                    // 2) Generate a block of XML that contains Add, Delete, Update objects that have changed on Cloud Master after the Cloud Servers version for:
                    string syncXml = string.Empty;

                    errorMessage = AndroAdminSyncHelper.TryGetExportSyncXml(fromVersion, toVersion, out syncXml);
                    if (errorMessage.Length != 0)
                    {
                        return(errorMessage);
                    }

                    // 3) Send sync XML to Cloud Server.  Cloud server returns a list of logs and audit data which have occurred since the last update.
                    errorMessage = AcsSyncHelper.SyncAcsServer(host, syncXml);
                    if (errorMessage.Length != 0)
                    {
                        return(errorMessage);
                    }

                    // 4) Insert logs/audit data into Cloud Master.
                    // Run out of time - future task
                }
            }

            return(errorMessage);
        }
Esempio n. 2
0
        public static string TryGetExportSyncXml(int fromVersion, int masterVersion, out string syncXml)
        {
            SyncModel syncModel = new SyncModel();

            // The current data version
            syncModel.FromDataVersion = fromVersion;
            syncModel.ToDataVersion   = masterVersion;

            // Get the store DAO
            IStoreDAO storeDao = AndroAdminDataAccessFactory.GetStoreDAO();
            // Get the partner DAO
            IPartnerDAO partnerDao = AndroAdminDataAccessFactory.GetPartnerDAO();
            // Get the store payment provider DAO
            IStorePaymentProviderDAO storePaymentProviderDao = AndroAdminDataAccessFactory.GetStorePaymentProviderDAO();

            //get the list of hosts, host types and connections based on version.
            //var a = AndroAdminDataAccessFactory.gethost

            if (SyncHelper.ConnectionStringOverride != null)
            {
                storeDao.ConnectionStringOverride   = SyncHelper.ConnectionStringOverride;
                partnerDao.ConnectionStringOverride = SyncHelper.ConnectionStringOverride;
                storePaymentProviderDao.ConnectionStringOverride = SyncHelper.ConnectionStringOverride;
            }

            AndroAdminSyncHelper.AddInStoreUpdates(storeDao, syncModel, fromVersion);

            AndroAdminSyncHelper.AddInPartnerUpdates(partnerDao, storeDao, syncModel, fromVersion);

            AndroAdminSyncHelper.AddInStorePaymentProviders(storePaymentProviderDao, syncModel, fromVersion);

            AndroAdminSyncHelper.AddInHubTasks(syncModel, fromVersion);

            //Menu updates as pushed on by MyAndromeda.
            AndroAdminSyncHelper.AddinMenuUpdates(syncModel, fromVersion);

            //Host V2 changes
            AndroAdminSyncHelper.AddInHostV2List(syncModel, fromVersion);

            AndroAdminSyncHelper.AddInStoreDevices(syncModel, fromVersion);
            // Serialize the sync model to XML

            ////add delivery areas to sync model
            //AndroAdminSyncHelper.AddDeliveryAreas(syncModel, fromVersion);

            //add postcodeSectors to sync model
            AndroAdminSyncHelper.AddPostCodeSectors(syncModel, fromVersion);

            AndroAdminSyncHelper.AddLoyalty(syncModel, fromVersion);

            syncXml = SerializeHelper.Serialize <SyncModel>(syncModel);

            return(string.Empty);
        }