예제 #1
0
 /// <summary>
 /// Uninstalls application.
 /// </summary>
 public void Uninstall()
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName  = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Uninstall;
         var thread = new Thread(InstallThread);
         thread.Start(param);
     }
 }
예제 #2
0
        private bool Install(InstallThreadParam param)
        {
            if (_context.IsValidContext() == true)
            {
                bool result    = false;
                bool debugMode = true;
                if (license)
                {
                    debugMode = false;
                }
                if (param.operation == XapInstallOperationType.Install)
                {
                    result = _context.Install(debugMode);
                }
                else if (param.operation == XapInstallOperationType.Update)
                {
                    result = _context.Update(debugMode);
                }
                else
                {
                    result = _context.Uninstall();
                }

                if (result && param.report)
                {
                    while (true)
                    {
                        ApplicationEvent evt = _context.WaitForEvent();
                        if (StateChanged != null)
                        {
                            XapInstallEventArgs e = new XapInstallEventArgs();
                            e.application = _context;
                            e.fileName    = param.fileName;
                            e.progress    = evt.progress;
                            e.state       = evt.state;
                            e.error       = evt.error;
                            Deployment.Current.Dispatcher.BeginInvoke(delegate() { StateChanged(this, e); });
                        }
                        if ((evt.state == InstallationState.AppInstallCompleted && param.operation == XapInstallOperationType.Install) ||
                            (evt.state == InstallationState.AppUpdateCompleted && param.operation == XapInstallOperationType.Update) ||
                            (evt.state == InstallationState.AppRemoveCompleted && param.operation == XapInstallOperationType.Uninstall))
                        {
                            break;
                        }
                    }
                }
                return(result);
            }
            return(false);
        }
예제 #3
0
 /// <summary>
 /// Add to ringtone list
 /// </summary>
 /// <returns>true on success, false on failure</returns>
 public bool AddToRingtoneList(int start, int end)
 {
     try
     {
         var itp = new InstallThreadParam();
         itp.onlyAdd = true;
         itp.start   = start;
         itp.end     = end;
         var thread = new Thread(InstallThread);
         thread.Start(itp);
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
예제 #4
0
 /// <summary>
 /// Updates current XAP with application data saving.
 /// </summary>
 public void Update(bool report = true, bool async = true)
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName  = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Update;
         param.report    = report;
         if (async)
         {
             var thread = new Thread(InstallThread);
             thread.Start(param);
         }
         else
         {
             InstallThread(param);
         }
     }
 }
예제 #5
0
 /// <summary>
 /// Installs current XAP.
 /// </summary>
 public bool Install(bool report = true, bool async = true)
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName  = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Install;
         param.report    = report;
         if (async)
         {
             var thread = new Thread(InstallThread);
             thread.Start(param);
             return(true);
         }
         else
         {
             return(Install(param));
         }
     }
     return(false);
 }
예제 #6
0
        private bool Install(InstallThreadParam param)
        {
            if (_context.IsValidContext() == true)
            {
                bool result = false;
                bool debugMode = true;
                if (license)
                    debugMode = false;
                if (param.operation == XapInstallOperationType.Install)
                    result = _context.Install(debugMode);
                else if (param.operation == XapInstallOperationType.Update)
                    result = _context.Update(debugMode);
                else
                    result = _context.Uninstall();

                if (result && param.report)
                {
                    while (true)
                    {
                        ApplicationEvent evt = _context.WaitForEvent();
                        if (StateChanged != null)
                        {
                            XapInstallEventArgs e = new XapInstallEventArgs();
                            e.application = _context;
                            e.fileName = param.fileName;
                            e.progress = evt.progress;
                            e.state = evt.state;
                            e.error = evt.error;
                            Deployment.Current.Dispatcher.BeginInvoke(delegate() { StateChanged(this, e); });
                        }
                        if ((evt.state == InstallationState.AppInstallCompleted && param.operation == XapInstallOperationType.Install) ||
                            (evt.state == InstallationState.AppUpdateCompleted && param.operation == XapInstallOperationType.Update) ||
                            (evt.state == InstallationState.AppRemoveCompleted && param.operation == XapInstallOperationType.Uninstall))
                        {
                            break;
                        }
                    }
                }
                return result;
            }
            return false;
        }
예제 #7
0
 /// <summary>
 /// Updates current XAP with application data saving.
 /// </summary>
 public void Update(bool report = true, bool async = true)
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Update;
         param.report = report;
         if (async)
         {
             var thread = new Thread(InstallThread);
             thread.Start(param);
         }
         else
         {
             InstallThread(param);
         }
     }
 }
예제 #8
0
 /// <summary>
 /// Uninstalls application.
 /// </summary>
 public void Uninstall(bool report = true)
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Uninstall;
         param.report = report;
         var thread = new Thread(InstallThread);
         thread.Start(param);
     }
 }
예제 #9
0
 /// <summary>
 /// Installs current XAP.
 /// </summary>
 public bool Install(bool report = true, bool async = true)
 {
     if (_context != null)
     {
         InstallThreadParam param = new InstallThreadParam();
         param.fileName = _fileName;
         param.productId = _productId;
         param.operation = XapInstallOperationType.Install;
         param.report = report;
         if (async)
         {
             var thread = new Thread(InstallThread);
             thread.Start(param);
             return true;
         }
         else
         {
             return Install(param);
         }
     }
     return false;
 }