public async Task <CheckVersionResponse> CheckForUpdates(string branch, long version)
        {
            var request  = new CheckVersionRequest(version, marketplace, branch, platform, key);
            var response = await client.PostAsync(
                updateServerUrl + "CheckVersion",
                new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                string responseBody = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <CheckVersionResponse>(responseBody));
            }

            throw new Exception("Update server returned " + response.StatusCode);
        }
        public void deserialize(InputArchive archive, string tag)
        {
            archive.startRecord(tag);
            MultiHeader h = new MultiHeader();

            ((Record)h).deserialize(archive, tag);

            while (!h.getDone())
            {
                ZooDefs.OpCode opCode = EnumUtil <ZooDefs.OpCode> .DefinedCast(h.get_Type());

                switch (opCode)
                {
                case ZooDefs.OpCode.create:
                    CreateRequest cr = new CreateRequest();
                    ((Record)cr).deserialize(archive, tag);
                    add(Op.create(cr.getPath(), cr.getData(), cr.getAcl(), cr.getFlags()));
                    break;

                case ZooDefs.OpCode.delete:
                    DeleteRequest dr = new DeleteRequest();
                    ((Record)dr).deserialize(archive, tag);
                    add(Op.delete(dr.getPath(), dr.getVersion()));
                    break;

                case ZooDefs.OpCode.setData:
                    SetDataRequest sdr = new SetDataRequest();
                    ((Record)sdr).deserialize(archive, tag);
                    add(Op.setData(sdr.getPath(), sdr.getData(), sdr.getVersion()));
                    break;

                case ZooDefs.OpCode.check:
                    CheckVersionRequest cvr = new CheckVersionRequest();
                    ((Record)cvr).deserialize(archive, tag);
                    add(Op.check(cvr.getPath(), cvr.getVersion()));
                    break;

                default:
                    throw new IOException("Invalid type of op");
                }
                ((Record)h).deserialize(archive, tag);
            }
            archive.endRecord(tag);
        }
示例#3
0
 public void GetAppUpdate(string jid, string version)
 {
     CheckVersionRequest request = new CheckVersionRequest();
     request.jid = jid;
     request.version = version;
     this.connection.Send(PacketType.CHECK_VERSION, request);
 }
示例#4
0
        void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerResult       result    = new WorkerResult();
            InstallerInterface installer = null;

            try
            {
                WorkerArg arg = e.Argument as WorkerArg;
                result.TestConnectionOnly = arg.TestConnectionOnly;
                result.TestStatus         = StackHashErrorIndexDatabaseStatus.Unknown;

                // configure for local access to the service
                if (!_localServiceConfigComplete)
                {
                    _localServiceGuid = ClientLogic.GetLocalServiceGuid();
                    FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);

                    CheckVersionRequest checkVersionRequest = new CheckVersionRequest();
                    checkVersionRequest.ServiceGuid  = _localServiceGuid == Guid.Empty ? null : _localServiceGuid.ToString();
                    checkVersionRequest.ClientData   = GenerateClientData();
                    checkVersionRequest.MajorVersion = fvi.ProductMajorPart;
                    checkVersionRequest.MinorVersion = fvi.ProductMinorPart;
                    CheckVersionResponse checkVersionResponse = ServiceProxy.Services.Admin.CheckVersion(checkVersionRequest);

                    _localServiceConfigComplete = true;
                }

                // always test that the service can access the database

                StackHashSqlConfiguration sqlConfig = new StackHashSqlConfiguration();
                sqlConfig.ConnectionString  = arg.MasterConnectionString;
                sqlConfig.ConnectionTimeout = DefaultSqlConnectionTimeout;
                sqlConfig.EventsPerBlock    = DefaultSqlEventsPerBlock;
                sqlConfig.InitialCatalog    = arg.ProfileName;
                sqlConfig.MaxPoolSize       = DefaultSqlMaxPoolSize;
                sqlConfig.MinPoolSize       = DefaultSqlMinPoolSize;

                TestDatabaseConnectionRequest request = new TestDatabaseConnectionRequest();
                request.ClientData            = GenerateClientData();
                request.ContextId             = -1;
                request.SqlSettings           = sqlConfig;
                request.TestDatabaseExistence = false;
                request.CabFolder             = arg.CabFolder;

                TestDatabaseConnectionResponse response = ServiceProxy.Services.Admin.TestDatabaseConnection(request);
                result.TestStatus             = response.TestResult;
                result.TestLastExceptionText  = response.LastException;
                result.CanAccessCabFolder     = response.IsCabFolderAccessible;
                result.CabFolderExceptionText = response.CabFolderAccessLastException;

                // contine if the test succeeded and we're not just testing
                if ((result.TestStatus == StackHashErrorIndexDatabaseStatus.Success) &&
                    (result.CanAccessCabFolder) &&
                    (!arg.TestConnectionOnly))
                {
                    // make sure NETWORK SERVICE can access the cab folder
                    FolderPermissionHelper.NSAddAccess(arg.CabFolder);

                    if (arg.CreateDatabase)
                    {
                        installer = new InstallerInterface(arg.MasterConnectionString,
                                                           arg.ProfileName,
                                                           arg.CabFolder);

                        installer.Connect();

                        if (!installer.DatabaseExists())
                        {
                            installer.CreateDatabase(arg.UseDefaultLocation);
                        }
                    }

                    DBConfigSettings.Settings.ProfileName      = arg.ProfileName;
                    DBConfigSettings.Settings.ConnectionString = arg.ConnectionString;
                    DBConfigSettings.Settings.ProfileFolder    = arg.CabFolder;
                    DBConfigSettings.Settings.Save();

                    _configurationSucceeded = true;
                }
            }
            catch (Exception ex)
            {
                result.WorkerException = ex;
            }
            finally
            {
                if (installer != null)
                {
                    installer.Disconnect();
                }
            }

            // if a test exception was reported include it in the  WorkerException
            if (!string.IsNullOrEmpty(result.TestLastExceptionText))
            {
                if (result.WorkerException == null)
                {
                    result.WorkerException = new AdminReportException(result.TestLastExceptionText);
                }
                else
                {
                    result.WorkerException = new AdminReportException(result.TestLastExceptionText, result.WorkerException);
                }
            }
            else if (!string.IsNullOrEmpty(result.CabFolderExceptionText))
            {
                if (result.WorkerException == null)
                {
                    result.WorkerException = new AdminReportException(result.CabFolderExceptionText);
                }
                else
                {
                    result.WorkerException = new AdminReportException(result.CabFolderExceptionText, result.WorkerException);
                }
            }

            e.Result = result;
        }