예제 #1
0
        /// <summary>
        /// Parse an argument string array into an installation request and wait on a calling process if there was one
        /// </summary>
        /// <param name="argString"></param>
        /// <returns></returns>
        public static InstallationRequest ParseArgsAndWait(string[] argString)
        {
            var request = new InstallationRequest();

            var args = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (var pair in argString)
            {
                var nameValue = pair.Split('=');
                if (nameValue.Length == 2)
                {
                    args[nameValue[0]] = nameValue[1];
                }
            }
            request.Archive = args.GetValueOrDefault("archive", null);

            request.Product              = args.GetValueOrDefault("product", null) ?? ConfigurationManager.AppSettings["product"] ?? "server";
            request.PackageClass         = (PackageVersionClass)Enum.Parse(typeof(PackageVersionClass), args.GetValueOrDefault("class", null) ?? ConfigurationManager.AppSettings["class"] ?? "Release");
            request.Version              = new Version(args.GetValueOrDefault("version", "4.0"));
            request.ServiceName          = args.GetValueOrDefault("service", string.Empty);
            request.ProgramDataPath      = args.GetValueOrDefault("installpath", null);
            request.TargetExecutablePath = args.GetValueOrDefault("startpath", null);
            request.SystemPath           = args.GetValueOrDefault("systempath", null);

            Trace.TraceInformation("Request: {0}", JsonSerializer.SerializeToString(request));

            var callerId = args.GetValueOrDefault("caller", null);

            if (callerId != null)
            {
                Trace.TraceInformation("Waiting for process {0} to exit", callerId);

                // Wait for our caller to exit
                try
                {
                    var process = Process.GetProcessById(Convert.ToInt32(callerId));
                    process.WaitForExit();
                }
                catch (ArgumentException)
                {
                    // wasn't running
                }

                request.Operation = InstallOperation.Update;
            }
            else
            {
                request.Operation = InstallOperation.Install;
            }

            return(request);
        }
예제 #2
0
        /// <summary>
        /// Parse an argument string array into an installation request and wait on a calling process if there was one
        /// </summary>
        /// <param name="argString"></param>
        /// <returns></returns>
        public static InstallationRequest ParseArgsAndWait(string[] argString)
        {
            var request = new InstallationRequest();

            var args = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (var pair in argString)
            {
                var nameValue = pair.Split('=');
                if (nameValue.Length == 2)
                {
                    args[nameValue[0]] = nameValue[1];
                }
            }
            request.Archive      = args.GetValueOrDefault("archive", null);
            request.InstallPismo = args.GetValueOrDefault("pismo", "true") == "true";

            request.Product      = args.GetValueOrDefault("product", null) ?? ConfigurationManager.AppSettings["product"] ?? "server";
            request.PackageClass = (PackageVersionClass)Enum.Parse(typeof(PackageVersionClass), args.GetValueOrDefault("class", null) ?? ConfigurationManager.AppSettings["class"] ?? "Release");
            request.Version      = new Version(args.GetValueOrDefault("version", "4.0"));

            var callerId = args.GetValueOrDefault("caller", null);

            if (callerId != null)
            {
                // Wait for our caller to exit
                try
                {
                    var process = Process.GetProcessById(Convert.ToInt32(callerId));
                    process.WaitForExit();
                }
                catch (ArgumentException)
                {
                    // wasn't running
                }

                request.Operation = InstallOperation.Update;
            }
            else
            {
                request.Operation = InstallOperation.Install;
            }

            return(request);
        }
예제 #3
0
        /// <summary>
        /// Initialize our internal variables from an installation request
        /// </summary>
        /// <param name="request"></param>
        protected void Init(InstallationRequest request)
        {
            Operation        = request.Operation;
            Archive          = request.Archive;
            PackageClass     = request.PackageClass;
            RequestedVersion = request.Version ?? new Version("4.0");
            Progress         = request.Progress;
            ReportStatus     = request.ReportStatus;
            MainClient       = request.WebClient;
            ServiceName      = request.ServiceName;
            AppDataFolder    = request.InstallPath ?? Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            switch (request.Product.ToLower())
            {
            case "mbt":
                PackageName    = "MBTheater";
                RootSuffix     = "-Theater";
                TargetExe      = "MediaBrowser.UI.exe";
                FriendlyName   = "Media Browser Theater";
                RootPath       = request.InstallPath ?? Path.Combine(AppDataFolder, "MediaBrowser" + RootSuffix);
                EndInstallPath = Path.Combine(RootPath, "system");
                break;

            case "mbc":
                PackageName    = "MBClassic";
                RootSuffix     = "-Classic";
                TargetExe      = "ehshell.exe";
                TargetArgs     = @"/nostartupanimation /entrypoint:{CE32C570-4BEC-4aeb-AD1D-CF47B91DE0B2}\{FC9ABCCC-36CB-47ac-8BAB-03E8EF5F6F22}";
                FriendlyName   = "Media Browser Classic";
                RootPath       = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix);
                EndInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "ehome");
                break;

            default:
                PackageName    = "MBServer";
                RootSuffix     = "-Server";
                TargetExe      = "MediaBrowser.ServerApplication.exe";
                FriendlyName   = "Media Browser Server";
                RootPath       = request.InstallPath ?? Path.Combine(AppDataFolder, "MediaBrowser" + RootSuffix);
                EndInstallPath = Path.Combine(RootPath, "system");
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Initialize our internal variables from an installation request
        /// </summary>
        /// <param name="request"></param>
        protected void Init(InstallationRequest request)
        {
            Operation        = request.Operation;
            Archive          = request.Archive;
            PackageClass     = request.PackageClass;
            RequestedVersion = request.Version ?? new Version("4.0");
            Progress         = request.Progress;
            ReportStatus     = request.ReportStatus;
            MainClient       = request.WebClient;
            ServiceName      = request.ServiceName;

            switch (request.Product.ToLower())
            {
            case "emby.theater":
                PackageName                      = "emby.theater";
                FriendlyName                     = "Emby Theater";
                ProgramDataPath                  = request.ProgramDataPath ?? GetTheaterProgramDataPath();
                TargetExecutablePath             = request.TargetExecutablePath ?? Path.Combine(ProgramDataPath, "system", "Emby.Theater.exe");
                SystemPath                       = request.SystemPath ?? Path.GetDirectoryName(TargetExecutablePath);
                ExtractRelativeToSystemDirectory = true;
                break;

            case "mbc":
                PackageName          = "MBClassic";
                TargetArgs           = @"/nostartupanimation /entrypoint:{CE32C570-4BEC-4aeb-AD1D-CF47B91DE0B2}\{FC9ABCCC-36CB-47ac-8BAB-03E8EF5F6F22}";
                FriendlyName         = "Emby for WMC";
                ProgramDataPath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + "-Classic");
                TargetExecutablePath = request.TargetExecutablePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "ehome", "ehshell.exe");
                SystemPath           = request.SystemPath ?? Path.Combine(ProgramDataPath, "system");
                break;

            default:
                PackageName          = "MBServer";
                FriendlyName         = "Emby Server";
                ProgramDataPath      = request.ProgramDataPath ?? GetServerProgramDataPath();
                TargetExecutablePath = request.TargetExecutablePath ?? Path.Combine(ProgramDataPath, "system", "MediaBrowser.ServerApplication.exe");
                SystemPath           = request.SystemPath ?? Path.GetDirectoryName(TargetExecutablePath);
                break;
            }
        }
예제 #5
0
 public Installer(InstallationRequest request)
 {
     Init(request);
 }
예제 #6
0
        private void BwUpdaterWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var installConfig     = new InstallationRequest(InstallationLogic.DEFAULT_INSTALL_DIRECTORY, overwriteTemplatesWithNewest, forceInstallerMode, installQSBCounter, versionNumString, installMpeg4);
            var installationLogic = new InstallationLogic(installConfig);

            installationLogic.ProgressUpdateAvailable += (x, y) =>
            {
                setUpdateStatusUsingUIThread(y.StatusMessage);
            };

            try
            {
                if (!isITpipesAlreadyInstalled())
                {
                    EULA.EULA_Window curEulaWindow = null;

                    curProgramWindow.Dispatcher.Invoke(new Action(() =>
                    {
                        curEulaWindow = new EULA.EULA_Window();

                        curEulaWindow.ShowDialog();
                    }));


                    if (curEulaWindow.EulaWasAccepted)
                    {
                        writeEulaAcceptanceRegKeys(curEulaWindow.NameOfUserAcceptingEULA, EULA.EULA_Window.EULA_PLAINTEXT);
                    }
                    else
                    {
                        setUpdateStatusUsingUIThread("End User License Agreement Not Accepted -- Click Here to Close Installer");
                        curProgramWindow.Dispatcher.Invoke(new Action(() =>
                        {
                            butEngage.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(0xff, 0xC9, 0x11, 0x11));
                            butEngage.IsEnabled  = true;
                            butEngage.Click     -= butEngage_Click;
                            butEngage.Click     += closeUpdater;
                        }));

                        return;
                    }
                }

                if (forceInstallerMode)
                {
                    installConfig.BackupToRestore = getBackupFileToUse();
                    installationLogic.RunAsInstaller();

                    if (installationLogic.bErrorExists == false)
                    {
                        setUpdateStatusUsingUIThread("ITpipes Installation Completed!");
                    }
                    else
                    {
                        setUpdateStatusUsingUIThread("ITPipes Installation Completed. Errors did occur. Please see logs to errors.");
                    }
                }
                else
                {
                    installationLogic.RunAsUpdater();

                    if (installationLogic.bErrorExists == false)
                    {
                        setUpdateStatusUsingUIThread("ITpipes Update Completed!");
                    }
                    else
                    {
                        setUpdateStatusUsingUIThread("ITPipes Update Complete. Errors did occur. Please see log for errors.");
                    }
                }

                curProgramWindow.Dispatcher.Invoke(new Action(() =>
                {
                    butEngage.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0x36, 0xE0, 0x3A));
                    butEngage.IsEnabled  = true;
                    butEngage.Click     -= butEngage_Click;
                    butEngage.Click     += closeUpdater;
                }));

                if (MainWindow.runConfigAfterUpdate)
                {
                    string configPath = Path.Combine(updaterLaunchDirectory, @"Config\ITpipes Config.exe");

                    if (File.Exists(configPath))
                    {
                        Process configProcess = new Process();
                        configProcess.StartInfo.FileName = configPath;

                        configProcess.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                curProgramWindow.Dispatcher.Invoke(new Action(() =>
                {
                    butEngage.Content   += "Error: Installation cancelled";
                    butEngage.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(0xFF, 0xF3, 0x08, 0x08)); //#FFF30808
                    butEngage.IsEnabled  = true;
                    butEngage.Click     -= butEngage_Click;
                    butEngage.Click     += closeUpdater;
                    MessageBox.Show($"Error installing ITpipes: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
                }
                                                              ));
            }
        }
        // Create return history method which return's either error message or success message
        public Tuple <bool, string> CreateInstallHistory(InstallationRequest iHistory)
        {
            var result = Tuple.Create(true, "");

            // validating Meter ID
            var meter = _mrepo.Get(iHistory.MIRN);

            if (meter.MIRN == null)
            {
                return(Tuple.Create(false, "Meter ID " + iHistory.MIRN + " is not found"));
            }

            // validating PayRoll ID
            var user = _urepo.Get(iHistory.PayRollID);

            if (user.PayRollID == null)
            {
                return(Tuple.Create(false, "PayRollID " + iHistory.PayRollID + " is not found"));
            }

            // validating meter status and meter condition
            // Return = 5, then actual meter status must be in Pickup
            if (!(meter.MeterStatus.Equals(DbModels.MeterStatus.Pickup)))
            {
                return(Tuple.Create(false, "Meter ID " + iHistory.MIRN + " is not available for install, current status is " + meter.MeterStatus));
            }

            if (!(meter.MeterCondition.Equals(DbModels.MeterCondition.Active)))
            {
                return(Tuple.Create(false, "Meter ID " + iHistory.MIRN + " is not available for install, current condition is " + meter.MeterCondition));
            }


            // validating not future date
            if (iHistory.TransactionDate > DateTime.UtcNow)
            {
                return(Tuple.Create(false, "Date should not be in the future date"));
            }

            // All validation are passed now converting the viewmodel to installation dbmodel
            var iDbModel = new DbModels.Installation();

            iDbModel.MIRN       = iHistory.MIRN;
            iDbModel.StreetNo   = iHistory.StreetNo;
            iDbModel.StreetName = iHistory.StreetName;
            iDbModel.Suburb     = iHistory.Suburb;
            iDbModel.State      = iHistory.State;
            iDbModel.PostCode   = iHistory.PostCode;
            iDbModel.Status     = DbModels.Status.Active;

            var iResult = _irepo.Add(iDbModel);

            if (iResult > 0)
            {
                //All validation are passed now converting the viewmodel to dbmodel
                var mhDbModel = new DbModels.MeterHistory();
                mhDbModel.MIRN            = iHistory.MIRN;
                mhDbModel.PayRollID       = iHistory.PayRollID;
                mhDbModel.MeterStatus     = DbModels.MeterStatus.Install;
                mhDbModel.Location        = Convert.ToString(iResult);
                mhDbModel.TransactionDate = iHistory.TransactionDate;
                mhDbModel.Comment         = iHistory.Comment;

                // creating meter history record in the DB
                var mhID = Add(mhDbModel);

                if (mhID > 0)
                {
                    return(Tuple.Create(true, mhID.ToString()));
                }
            }
            else
            {
                return(Tuple.Create(false, "Unable to create new Installation record!"));
            }
            return(Tuple.Create(false, "Unable to Install Meter!"));
        }
        public IActionResult InstallMeters(InstallationRequest iRequest)
        {
            // getting MeterID, MeterStatus,street no, street name, suburb, state, postcode

            // check is this request is for install
            if (!(iRequest.MeterStatus.Equals(MeterStatus.Install)))
            {
                ModelState.AddModelError("Error", "Invalid request type for install meters: " + iRequest.MeterStatus);
                return(NotFound());
            }

            // meter ID validation
            var meter = _mrepo.Get(iRequest.MIRN);

            if (meter != null)
            {
                var user = _urepo.Get(iRequest.PayRollID);
                if (user != null)
                {
                    var viewModel = new Models.InstallationRequest();
                    viewModel.MIRN            = meter.MIRN;
                    viewModel.PayRollID       = iRequest.PayRollID;
                    viewModel.MeterStatus     = iRequest.MeterStatus;
                    viewModel.StreetNo        = iRequest.StreetNo;
                    viewModel.StreetName      = iRequest.StreetName;
                    viewModel.Suburb          = iRequest.Suburb;
                    viewModel.State           = iRequest.State;
                    viewModel.PostCode        = iRequest.PostCode;
                    viewModel.Comment         = iRequest.Comment;
                    viewModel.TransactionDate = iRequest.TransactionDate;

                    // creating meter transaction in meter history table
                    var result = _repo.CreateInstallHistory(viewModel);

                    // checking the result from repo
                    // if returns true then update meter status in Meter Table
                    if (result.Item1 == true)
                    {
                        var meterStatusUpdateResult = _mrepo.UpdateMeterStatus(meter.MIRN, iRequest.MeterStatus);
                        if (meterStatusUpdateResult == true)
                        {
                            return(Ok("Meter ID " + iRequest.MIRN + " is successfully installed"));
                        }
                        else
                        {
                            ModelState.AddModelError("Error", "Unable to update meter status");
                            return(NotFound());
                        }
                    }
                    else
                    {
                        //if returns false the show the model state error
                        ModelState.AddModelError("Error", result.Item2);
                    }
                }
                else
                {
                    ModelState.AddModelError("Error", "PayRoll ID" + iRequest.PayRollID + " is not found");
                }
            }
            else
            {
                ModelState.AddModelError("Error", "Meter ID " + iRequest.MIRN + " is not found");
            }
            return(Ok());
        }
예제 #9
0
        private async void Create()
        {
            if (string.IsNullOrEmpty(this.Contenedor))
            {
                DependencyService.Get <ToastMessage>().Show("Debe ingresar un número de contenedor");
                return;
            }

            if (this.Tamano == 0)
            {
                DependencyService.Get <ToastMessage>().Show("Debe ingresar el tamaño del contenedor");
                return;
            }

            if (this.Control == 0)
            {
                DependencyService.Get <ToastMessage>().Show("Debe ingresar el número de puerto");
                return;
            }

            if (string.IsNullOrEmpty(this.Direccion))
            {
                DependencyService.Get <ToastMessage>().Show("Debe ingresar una dirección");
                return;
            }

            if (string.IsNullOrEmpty(this.Observation))
            {
                DependencyService.Get <ToastMessage>().Show("Debe ingresar una observación");
                return;
            }

            this.IsLoading           = true;
            this.InstallationEnabled = false;

            var connection = await this.Api.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsLoading           = false;
                this.InstallationEnabled = true;

                DependencyService.Get <ToastMessage>().Show(connection.Message);
                return;
            }


            var trip = new InstallationRequest
            {
                Placa           = this.Unidad,
                Contenedor      = this.Contenedor,
                Idtamcontenedor = this.Tamano,
                Idpuertocontrol = this.Control,
                Motonave        = this.Embarcacion,
                Eta             = this.Eta,
                FCargue         = this.Cargue,
                FechaDespacho   = this.Despacho,
                DireccionOrigen = this.Direccion,
                Estado          = "",
                Observaciones   = this.Observation
            };

            var data_request = new DataRequest <InstallationRequest>(trip);

            var apiUrl = Application.Current.Resources["APIUrlDev"].ToString();

            var response = await this.Api.CreateTrip(
                apiUrl,
                "/Controller",
                "/AsignacionController.php",
                this.Token,
                this.User,
                data_request);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    response.Message,
                    "Aceptar");

                this.IsLoading           = false;
                this.InstallationEnabled = true;

                return;
            }


            await Application.Current.MainPage.DisplayAlert(
                "Exito",
                response.Message,
                "Aceptar");

            await App.Navigator.PopToRootAsync();
        }