Example #1
0
        private void LoadInitialControls()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new SenderInvoker(LoadInitialControls));
            }
            else
            {
                pnlLeft.Controls.Clear();
                pnlLeft.Controls.Add(Loader.GetReferenceUserControl("ucMenuReservations"));

                pnlMiddle.Controls.Clear();
                pnlMiddle.Controls.Add(Loader.GetReferenceUserControl("ucConnected"));

                pnlArea.Controls.Clear();
                pnlArea.Controls.Add(Loader.GetReferenceUserControl("ucArea"));

                toolStripButtonQueue.Visible = true;
                Common.SetCurrentArea(Common.Area.Area_A);

                if (Login.IsMySabreBlocked)
                {
                    MyCTSAPI.EnabledBrowser(false);
                }
            }
        }
        /// <summary>
        /// Valida la respuesta de mySabre cuando aparece la respuesta *PAC
        /// </summary>
        private void APIResponseDIN()
        {
            string result        = string.Empty;
            string recordLocator = string.Empty;

            ERR_TicketsEmission.err_ticketsEmission(sabreAnswer);
            if (ERR_TicketsEmission.Status == false)
            {
                ERR_TicketsEmission.ok_ticketsEmission(sabreAnswer);
                if (ERR_TicketsEmission.StatusOk == true)
                {
                    int row = 0;
                    int col = 0;

                    if (sabreAnswer.Contains(Resources.TicketEmission.ValitationLabels.ETR_MESSAGE_PROCESSED) || sabreAnswer.Contains(Resources.TicketEmission.ValitationLabels.ETR_EXCHANGE_PROCESSED))
                    {
                        CommandsAPI2.send_MessageToEmulator(Resources.TicketEmission.Constants.MESSAGE_ISSUE);
                    }

                    CommandsQik.searchResponse(sabreAnswer, Resources.TicketEmission.ValitationLabels.INVOICED, ref row, ref col);
                    if (row != 0 || col != 0)
                    {
                        int rowMessage = row - 2;
                        recordLocator = string.Empty;
                        CommandsQik.CopyResponse(sabreAnswer, ref recordLocator, rowMessage + 1, 9, 6);
                    }
                    Common.BeginManualCommandsTransactions();

                    try
                    {
                        //CommandsAPI2.send_MessageToEmulator(Resources.TicketEmission.Constants.MESSAGE_ISSUE);

                        AddRecordsContainerBL.AddRecordsContainer(recordLocator, Login.Agent, true);
                        send = string.Empty;
                        send = string.Concat(Resources.TicketEmission.Constants.AST,
                                             recordLocator);
                        using (CommandsAPI objCommand = new CommandsAPI())
                        {
                            objCommand.SendReceive(send);
                        }
                        QueueAgent();

                        send = string.Empty;
                        MyCTSAPI.SendReservationLog(Login.Firm, Login.PCC, recordLocator, 1);
                        send = string.Concat(Resources.TicketEmission.Constants.AST,
                                             recordLocator);
                        using (CommandsAPI objCommand = new CommandsAPI())
                        {
                            objCommand.SendReceive(send);
                        }
                        SendValidationTicketCommand();
                    }
                    catch { }
                    //Common.EndManualCommandsTransactions();
                    ExecEndCommandTransaction();
                    //System.Threading.Thread.Sleep(1000);
                    ClearValues();
                    if (ucTicketEmissionBuildCommand.emiting)
                    {
                        SetCSCLog();
                        ucTicketEmissionBuildCommand.emiting = false;
                    }
                }
                else
                {
                    MessageBox.Show("OCURRIO UN ERROR AL IMPRIMIR FACTURA. VERIFIQUE RESPUESTAS", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (ucTicketEmissionBuildCommand.emiting)
                    {
                        SetCSCLog();
                        ucTicketEmissionBuildCommand.emiting = false;
                    }
                    //UC = "sendTicketInvoice";
                    Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_SEND_TICKET_INVOICE);
                }
            }
            else if (ERR_TicketsEmission.StatusSendCommand == true)
            {
                sabreAnswer = string.Empty;

                using (CommandsAPI objCommand = new CommandsAPI())
                {
                    sabreAnswer = objCommand.SendReceive(send);
                }


                ERR_TicketsEmission.ok_ticketsEmission(sabreAnswer);
                if (ERR_TicketsEmission.StatusOk == true)
                {
                    int row = 0;
                    int col = 0;

                    if (sabreAnswer.Contains(Resources.TicketEmission.ValitationLabels.ETR_MESSAGE_PROCESSED) || sabreAnswer.Contains(Resources.TicketEmission.ValitationLabels.ETR_EXCHANGE_PROCESSED))
                    {
                        CommandsAPI2.send_MessageToEmulator(Resources.TicketEmission.Constants.MESSAGE_ISSUE);
                    }

                    CommandsQik.searchResponse(sabreAnswer, Resources.TicketEmission.ValitationLabels.INVOICED, ref row, ref col);
                    if (row != 0 || col != 0)
                    {
                        int rowMessage = row - 2;
                        recordLocator = string.Empty;
                        CommandsQik.CopyResponse(sabreAnswer, ref recordLocator, rowMessage + 1, 9, 6);
                    }
                    Common.BeginManualCommandsTransactions();

                    try
                    {
                        //CommandsAPI2.send_MessageToEmulator(Resources.TicketEmission.Constants.MESSAGE_ISSUE);

                        AddRecordsContainerBL.AddRecordsContainer(recordLocator, Login.Agent, true);
                        send = string.Empty;
                        send = string.Concat(Resources.TicketEmission.Constants.AST,
                                             recordLocator);
                        using (CommandsAPI objCommand = new CommandsAPI())
                        {
                            objCommand.SendReceive(send);
                        }
                        QueueAgent();

                        send = string.Empty;
                        MyCTSAPI.SendReservationLog(Login.Firm, Login.PCC, recordLocator, 1);
                        send = string.Concat(Resources.TicketEmission.Constants.AST,
                                             recordLocator);
                        using (CommandsAPI objCommand = new CommandsAPI())
                        {
                            objCommand.SendReceive(send);
                        }
                        SendValidationTicketCommand();
                        if (ucTicketEmissionBuildCommand.emiting)
                        {
                            SetCSCLog();
                            ucTicketEmissionBuildCommand.emiting = false;
                        }
                    }
                    catch { }
                }
                //Common.EndManualCommandsTransactions();
                ExecEndCommandTransaction();
                //System.Threading.Thread.Sleep(1000);
                ClearValues();
            }
            else
            {
                MessageBox.Show("OCURRIO UN ERROR AL IMPRIMIR FACTURA. VERIFIQUE RESPUESTAS", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (ucTicketEmissionBuildCommand.emiting)
                {
                    SetCSCLog();
                    ucTicketEmissionBuildCommand.emiting = false;
                }
                //UC = "sendTicketInvoice";//
                Loader.AddToPanel(Loader.Zone.Middle, this, Resources.TicketEmission.Constants.UC_SEND_TICKET_INVOICE);
            }
        }
Example #3
0
        private void LoadControl()
        {
            //Carga el nombre del Splash en caso de que ocurra un
            //error para registrarlo en el log
            Common.LogApplicationItem.UserControlName = "Splash";

            #region Datos Usuario
            User   usuarioDto = m_userDto;
            string password   = m_password;
            Login.Firm                   = usuarioDto.Firm;
            Login.passWord               = password;
            Login.PCC                    = usuarioDto.PCC;
            Login.TA                     = usuarioDto.TA;
            Login.UserId                 = usuarioDto.UserId;
            Login.Queue                  = usuarioDto.Queue;
            Login.Mail                   = usuarioDto.UserMail;
            Login.NombreCompleto         = usuarioDto.FamilyName;
            Login.IsMySabreBlocked       = usuarioDto.IsMySabreBlocked;
            Login.Agent                  = usuarioDto.Agent;
            Login.IsFramework35Installed = usuarioDto.IsFramework35Installed;
            Login.ProfileAllAccess       = usuarioDto.ProfileAllAccess;
            Login.ApplicationName        = usuarioDto.ApplicationName;
            Login.OrgId                  = usuarioDto.OrgId;
            UserBL.OrgIdBL               = usuarioDto.OrgId;
            Login.Supervisor             = usuarioDto.Supervisor;
            Login.UpgradeStatus          = usuarioDto.UpgradeStatus;
            //Crear perfil de properties de mySABRE por default
            #endregion


            if (Login.UpgradeStatus.Equals(0) && Login.ByParameters)
            {
                MessageBox.Show("Acción Cancelada. Ejecutar la aplicación MyCTS que se encuentra en el escritorio.");
                CloseApp();
            }
            else if (Login.UpgradeStatus.Equals(0) && !Login.ByParameters)
            {
                GlobalConstants.PATH_SABRE_USER     = string.Format(ConfigurationManager.AppSettings["PATH_MYSABRE_USER"] + "{0}", Login.Firm);
                GlobalConstants.PATH_SABRE_COMPILED = ConfigurationManager.AppSettings["PATH_MYSABRE_COMPILED"];
            }
            else if (Login.UpgradeStatus.Equals(2) && !Login.ByParameters)
            {
                bool exists = File.Exists(Path.Combine(ConfigurationManager.AppSettings["PATH_SABRERED_USER"], @"Profiles\3L64_1571\mysabre.exe"));
                if (!exists)
                {
                    MessageBox.Show("Su usuario no puede trabajar con la versión instalada en este equipo, se empezara a actualizar a MyCTS2");
                    Login.UpgradeStatus = 1;
                    UpdateSRW();
                }
            }

            GlobalConstants.PATH_SABRE_USER     = ConfigurationManager.AppSettings["PATH_SABRERED_USER"];
            GlobalConstants.PATH_SABRE_COMPILED = ConfigurationManager.AppSettings["PATH_SABRERED_COMPILED"];

            try
            {
                SendMessages("Inicializando . . .");

                Parameters.ServerDateTime = MyCTS.Services.Contracts.Productivity.GetCurrentDateTime();
                Parameters.LocalDateTime  = DateTime.Now;

                //Verifica que el usuario tenga framework 3.5 instalado
                if (usuarioDto.InstallFramework35)
                {
                    SilentInstaller.CheckFrameworkVersion();
                }

                DeleteInitialFiles();
                GlobalConstants.FilesDBList = CatalogsBL.GetCatalogsFileNames();
                try
                {
                    MyCTSAPI.EnabledBrowser(true);
                }
                catch {}

                // Actualizar a SRW
                UpdateSRW();

                //Tiempos de respuesta del API para comandos manuales y comandos extendidos
                try
                {
                    Parameters.CurrentTimeAPINormal   = ParameterBL.GetParameterValue("CurrentTimeAPINormal").Values;
                    Parameters.CurrentTimeAPIExtended = ParameterBL.GetParameterValue("CurrentTimeAPIExtended").Values;
                }
                catch
                {
                    Parameters.CurrentTimeAPINormal   = "29";
                    Parameters.CurrentTimeAPIExtended = "240";
                }
                Parameters.TimeExtendedAPI = false;
            }
            catch { }

            #region Verificando configuración . . .

            string[] driversPath  = new string[] { "c:\\", "d:\\" };
            string   strPath      = string.Empty;
            string   strPathTurbo = string.Empty;
            string   strTA        = null;

            try
            {
                SendMessages("Verificando configuración . . .");
                if (string.IsNullOrEmpty(usuarioDto.TA))
                {
                    Login.IsFirstTime = true;
                    foreach (string myDrive in driversPath)
                    {
                        //Obtener la TA de cada maquina.
                        strPath       = myDrive + Resources.Constants.PATH_TA_FILE;
                        strTA         = GetTAUserMachine(strPath);
                        usuarioDto.TA = strTA;
                        if (!string.IsNullOrEmpty(strTA))
                        {
                            break;
                        }
                    }
                }
                //Update la TA
                UserBL.UpdateUser(usuarioDto.ApplicationId, usuarioDto.UserId, usuarioDto.UserName, usuarioDto.LoweredUserName, usuarioDto.UserMail,
                                  DateTime.Now, usuarioDto.Firm, password, usuarioDto.FamilyName, usuarioDto.Agent, usuarioDto.Queue, usuarioDto.PCC, usuarioDto.TA);

                //Obtiene el profile del usuario.
                Profile profileDto = m_userDto.ProfileUser;

                //Cambiar el nombre del archivo de TurboSABRE
                if (profileDto != null)
                {
                    string bannerText = Common.GetProfileElement("BANNER", profileDto.PropertyNames, profileDto.PropertyValuesString);
                    if (string.IsNullOrEmpty(bannerText))
                    {
                        bannerText = Resources.Constants.BANNER_TEXT;
                    }
                    Login.BannerText  = bannerText;
                    Login.UserProfile = profileDto;

                    if (!profileDto.LastUpdatedDate.Equals(DateTime.MinValue))
                    {
                        foreach (string myDrive in driversPath)
                        {
                            //Obtener la TA de cada maquina.
                            strPathTurbo = myDrive + Resources.Constants.PATH_TURBO_FILE;
                            ChangeTurboSABREFile(strPathTurbo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Common.AddMessageToLog(ex);
                MessageBox.Show("No ha sido posible verificar la información del perfil, por favor contacte con el área de soporte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                CloseApp();
            }
            #endregion

            ActualizaVersionDeMyCTS();

            #region Creando datos del perfil . . .
            SendMessages("Cargando datos del perfil . . .");
            try
            {
                SetSettingsUser();
            }
            catch (Exception ex)
            {
                Common.AddMessageToLog(ex);
                MessageBox.Show("No ha sido posible copiar los archivos de configuración, por favor contacte con el área de soporte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                CloseApp();
            }

            #endregion

            #region Cargando archivos de inicio . . .
            SendMessages("Cargando archivos de inicio . . .");
            try
            {
                LoadMissingCatalogs();
            }
            catch (Exception ex)
            {
                Common.AddMessageToLog(ex);
                MessageBox.Show("No ha sido posible descargar la información, por favor contacte con el área de soporte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                CloseApp();
            }
            #endregion

            //Obtiene la contraseña para poder ingresar comandos de forma manual
            Parameter parameter = ParameterBL.GetParameterValue("ManualCommands");
            Parameters.PasswordManualCommands = (parameter != null) ? parameter.Values : string.Empty;

            parameter = ParameterBL.GetParameterValue("SecondsLogs");
            Parameters.SecondsLogs = (parameter != null) ? parameter.Values : "60000";

            parameter = ParameterBL.GetParameterValue("NumCommandsToInsertLogs");
            Parameters.NumCommandsToInsertLogs = (parameter != null) ? parameter.Values : "15";

            CloseThisWin();
        }
        /// <summary>
        /// This will create a Application Reference file on the users desktop
        /// if they do not already have one when the program is loaded.
        /// Check for them running the deployed version before doing this,
        /// so it doesn't kick it when you're running it from Visual Studio.
        /// </summary
        static void CheckForShortcut()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                if (ad.IsFirstRun)  //first time user has run the app since installation or update
                {
                    Assembly code = Assembly.GetExecutingAssembly();

                    string title = string.Empty;
                    if (Attribute.IsDefined(code, typeof(AssemblyTitleAttribute)))
                    {
                        AssemblyTitleAttribute asmTitle =
                            (AssemblyTitleAttribute)Attribute.GetCustomAttribute(code,
                                                                                 typeof(AssemblyTitleAttribute));
                        title = asmTitle.Title;
                    }

                    if (title != string.Empty)
                    {
                        string desktopPath  = string.Empty;
                        string shortcutName = string.Empty;

                        desktopPath  = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\\", title, ".appref-ms");
                        shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", title, "\\", title, ".appref-ms");

                        if (!File.Exists(desktopPath))
                        {
                            FileInfo fShortCut = new FileInfo(shortcutName);
                            if (fShortCut.Exists)
                            {
                                fShortCut.CopyTo(desktopPath, true);
                            }

                            //Si no existe el icono de MyCTS lo coloca en el escritorio y realiza un refresh para mostrarlo
                            MyCTSAPI.RefreshDesktop();
                        }

                        //Copy the fix MyCTS on the programs bar
                        string webBrowserPath      = System.Reflection.Assembly.GetExecutingAssembly().Location;
                        string nameEXE             = System.IO.Path.GetFileName(Application.ExecutablePath);
                        string webBrowserPath_temp = webBrowserPath.Substring(0, webBrowserPath.Length - nameEXE.Length) + "WebBrowser\\UninstallMyCTS.exe";
                        string destino             = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", title, "\\", "UninstallMyCTS.exe");

                        if (File.Exists(destino))
                        {
                            File.Delete(destino);
                        }

                        System.IO.File.Copy(webBrowserPath_temp, destino, true);
                    }
                }
            }

            #region Old Code
            //if (ApplicationDeployment.IsNetworkDeployed)
            //{
            //    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
            //    if (ad.IsFirstRun)  //first time user has run the app since installation or update
            //    {
            //        Assembly code = Assembly.GetExecutingAssembly();
            //        string company = string.Empty;
            //        string description = string.Empty;
            //        if (Attribute.IsDefined(code, typeof(AssemblyCompanyAttribute)))
            //        {
            //            AssemblyCompanyAttribute ascompany =
            //                (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(code,
            //                typeof(AssemblyCompanyAttribute));
            //            company = ascompany.Company;
            //        }
            //        if (Attribute.IsDefined(code, typeof(AssemblyDescriptionAttribute)))
            //        {
            //            AssemblyDescriptionAttribute asdescription =
            //                (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(code,
            //                typeof(AssemblyDescriptionAttribute));
            //            description = asdescription.Description;
            //        }
            //        if (company != string.Empty && description != string.Empty)
            //        {
            //            string desktopPath = string.Empty;
            //            desktopPath = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "\\", description, ".appref-ms");
            //            string shortcutName = string.Empty;
            //            shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", company, "\\", description, ".appref-ms");
            //            //Restart computer
            //            if (System.IO.File.Exists(desktopPath))
            //                MyCTSAPI.Reiniciar();

            //            if (System.IO.File.Exists(shortcutName))
            //                System.IO.File.Copy(shortcutName, desktopPath, true);

            //            //Copy the fix MyCTS on the programs bar
            //            string webBrowserPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            //            string nameEXE = System.IO.Path.GetFileName(Application.ExecutablePath);
            //            string webBrowserPath_temp = webBrowserPath.Substring(0, webBrowserPath.Length - nameEXE.Length) + "WebBrowser\\UninstallMyCTS.exe";
            //            string destino = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", company, "\\", "UninstallMyCTS.exe");

            //            System.IO.File.Copy(webBrowserPath_temp, destino, true);
            //        }
            //    }
            //}
            #endregion
        }