Esempio n. 1
0
        private void FormPrincipal_Load(object sender, EventArgs e)
        {
            generalRingUserControl      = new GeneralRingUserControl();
            generalRingUserControl.Dock = DockStyle.Fill;
            try
            {
                jsonHandlerUtils = new JsonHandlerUtils(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension, "STA.Model.ConfigurationParametersModel");

                if (File.Exists(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension + ".aes"))
                {
                    BaseUtils.cypherUtils.FileDecrypt(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension + ".aes", validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension, Properties.Settings.Default.cypherPassword);
                    configurationParametersModel = (ConfigurationParametersModel)jsonHandlerUtils.deserialize();
                    File.Delete(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension);

                    DateTime fechaActual          = DateTime.Now;
                    TimeSpan diferenciaDiasFechas = fechaActual - configurationParametersModel.installedDate;
                    int      diasRestantes        = diferenciaDiasFechas.Days;

                    if (configurationParametersModel.lisenceTime == diasRestantes)
                    {
                        MessageBox.Show("Estimado usuario su periodo de licencia caducó, por favor comuniquese con el proveedor del sistema para renovar.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Application.Exit();
                    }

                    if (!configurationParametersModel.sendedEMail)
                    {
                        if (sendMailUtils.send())
                        {
                            configurationParametersModel = new ConfigurationParametersModel(true);
                            jsonHandlerUtils.serialize(configurationParametersModel);
                            MessageBox.Show("Estimado usuario, hemos registrado la instalación de su producto satisfactoriamente con fecha: " + DateTime.Now + ". Esperamos sea de su agrado y utilidad. Equipo BITDATA.", "Bienvenido", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            if (diasRestantes == 30)
                            {
                                MessageBox.Show("Estimado usuario, no hemos podido registrar la instalación de su producto, por lo que le quedan " + (30 - diasRestantes).ToString() + " días de servicio, por tanto se suspende el uso del sistema hasta que contácte con el proveedor. Muchas gracias y disculpe las molestias", "Notificación", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                                Application.Exit();
                            }
                            else
                            {
                                MessageBox.Show("Estimado usuario, no hemos podido registrar la instalación de su producto, por lo que le quedan " + (30 - diasRestantes).ToString() + "/30 días de servicio, por favor contáctese con el proveedor. Muchas gracias.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        this.groupBoxGeneralSound.Controls.Add(generalRingUserControl);
                        loadData();
                    }
                    else
                    {
                        this.groupBoxGeneralSound.Controls.Add(generalRingUserControl);
                        loadData();
                    }
                }
                else if (sendMailUtils.send())
                {
                    configurationParametersModel = new ConfigurationParametersModel(true);
                    jsonHandlerUtils.serialize(configurationParametersModel);
                    BaseUtils.cypherUtils.FileEncrypt(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension, Properties.Settings.Default.cypherPassword);
                    File.Delete(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension);
                    this.groupBoxGeneralSound.Controls.Add(generalRingUserControl);
                    MessageBox.Show("Estimado usuario, hemos registrado la instalación de su producto satisfactoriamente con fecha: " + DateTime.Now + ". Esperamos sea de su agrado y utilidad. Equipo BITDATA", "Bienvenido", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadData();
                }
                else
                {
                    configurationParametersModel = new ConfigurationParametersModel(false);
                    jsonHandlerUtils.serialize(configurationParametersModel);
                    BaseUtils.cypherUtils.FileEncrypt(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension, Properties.Settings.Default.cypherPassword);
                    File.Delete(validationEntries.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonConfigParamsName + Properties.Settings.Default.jsonExtension);
                    DateTime fechaActual          = DateTime.Now;
                    TimeSpan diferenciaDiasFechas = fechaActual - configurationParametersModel.installedDate;
                    int      diasRestantes        = diferenciaDiasFechas.Days;
                    if (diasRestantes == 30)
                    {
                        MessageBox.Show("Estimado usuario, no hemos podido registrar la instalación de su producto por lo que le quedan " + (30 - diasRestantes).ToString() + " días de servicio, por tanto se suspende el uso del sistema hasta que contácte con el proveedor. Muchas gracias", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        Application.Exit();
                    }
                    else
                    {
                        MessageBox.Show("Estimado usuario, no hemos podido registrar la instalación de su producto por lo que le quedan " + (30 - diasRestantes).ToString() + "/30 días de servicio, por favor contáctese con el proveedor del sistema. Muchas gracias", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception er)
            {
                BaseUtils.log.Error(er);
            }
        }
Esempio n. 2
0
        static void Main()
        {
            MainController.log.Info("App started!");
            Boolean run = true;

            if (!run)
            {
                //crear archivo JSON
                ValidateEntriesUtils validateEntriesUtils = new ValidateEntriesUtils();

                AutomaticRingSystemModel automaticRingSystem = new AutomaticRingSystemModel();
                automaticRingSystem.registrationRequired = true;
                automaticRingSystem.domainHost           = "100.50.40.3";
                automaticRingSystem.domainPort           = 5060;
                for (int i = 0; i < 1; i++)
                {
                    ConnectionCallServerModel connectionCallServer = new ConnectionCallServerModel();
                    connectionCallServer.displayName      = "1230";
                    connectionCallServer.userName         = "******";
                    connectionCallServer.registerName     = "1230";
                    connectionCallServer.registerPassword = "******";

                    HoraryModel horary = new HoraryModel("h" + i, connectionCallServer);
                    for (int a = 0; a < 2; a++)
                    {
                        int            s         = i + a;
                        String         sec       = s < 10 ? "0" : "" + s;
                        SoundFileModel soundFile = new SoundFileModel();
                        String         filename  = "helloworld" + a + ".mp3";
                        soundFile.name       = filename;
                        soundFile.targetPath = validateEntriesUtils.getMyDocumentsPath() + "\\" + Properties.Settings.Default.soundFolderName + "\\" + Properties.Settings.Default.horarySounds + "\\" + filename;
                        CallServerModel callServer = new CallServerModel(a + 1, "23:54:" + sec, 5, soundFile, true, "1300", "llamada " + a);
                        horary.callServerList.Add(callServer);
                    }
                    automaticRingSystem.horaryList.Add(horary);
                }

                string outputJSON       = JsonConvert.SerializeObject(automaticRingSystem);
                String jsonFileFullPath = validateEntriesUtils.getProgramDataPath() + "\\" + Properties.Settings.Default.jsonFileName + Properties.Settings.Default.jsonExtension;
                File.WriteAllText(jsonFileFullPath, outputJSON);

                try
                {
                    MainController.cypherUtils.FileEncrypt(jsonFileFullPath, Properties.Settings.Default.cypherPassword);
                    System.IO.File.Delete(jsonFileFullPath);
                }
                catch (Exception e)
                {
                    MainController.log.Error("Intentando guardar archivo json", e);
                }
                //crear archivo JSON FIN
            }

            if (run)
            {
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
                }
                catch (Exception e)
                {
                    BaseUtils.log.Error(e);
                }
            }
        }