Exemple #1
0
        public virtual IActionResult ExportCsvFile([FromBody] ExportCsv exportSettings, [FromHeader][Required] string Authorization)
        {
            if (!ModelState.IsValid)
            {
                var error = ModelState.SelectMany(x => x.Value.Errors).First();
                if (error.ErrorMessage != null && error.ErrorMessage != String.Empty)
                {
                    return(BadRequest(error.ErrorMessage));
                }
                else if (error.Exception?.Message != null)
                {
                    return(BadRequest("Faulty input"));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            if (Authorization != settings.testToken)
            {
                return(BadRequest("Not allowed"));
            }
            string errorMessage   = "";
            string dataStreamInfo = "";

            try
            {
                ExportCsvResult res              = new ExportCsvResult();
                string          filename         = System.Guid.NewGuid().ToString() + ".csv";
                string          filenameWithPath = "." + Path.DirectorySeparatorChar + "wwwroot" + Path.DirectorySeparatorChar + filename;


                DatabaseInterface.DBObservation dBo = new DatabaseInterface.DBObservation();
                if (!dBo.FindDataStreamId(int.Parse(exportSettings.ThingId), exportSettings.ObservationType, ref errorMessage, ref dataStreamInfo))
                {
                    return(BadRequest("Internal Server Error:" + errorMessage));
                }
                // PArse out the ID
                string tmp = dataStreamInfo.Substring(dataStreamInfo.IndexOf("(") + 1);
                tmp = tmp.Substring(0, tmp.IndexOf(")"));
                string url = "http://monappdwp3.monica-cloud.eu:8088/gost_wdom/" + tmp + "?from=" + exportSettings.StartTime.ToString("o") + "&to=" + exportSettings.EndTime.ToString("o");
                try
                {
                    WebClient wc = new WebClient();
                    wc.DownloadFile(url, filenameWithPath);
                }
                catch (WebException we)
                {
                    // add some kind of error processing

                    BadRequest("Internal Server Error:" + we.ToString());
                }
                res.Path = filename;
                return(new ObjectResult(res));
            }
            catch (Exception e)
            {
                return(BadRequest("Internal Server Error:" + e.Message));
            }
        }
Exemple #2
0
 public void ExportCsvs(string csvRoot)
 {
     foreach (var kvp in tables)
     {
         ExportCsv.Export(kvp.Value, csvRoot);
     }
 }
        public void BRequest(Configurations config, int bonusId)
        {
            ExportCsv exportValues = new ExportCsv();
            //String bonusParams = $"game={Configurations.gameName}&key={Configurations.TokenKey}" +
            //   $"&bonus={Configurations.BonusKey}&param=0&ts={Configurations.TimeStamp}&platform=web";

            String bonusParams = "";

            var bonusCompleted = false;


            int    counter = 1;
            String bonusValue;
            int    type = Convert.ToInt32(config.GameType);

            do
            {
                switch (type)
                {
                case 0:     // cascading
                    bonusValue  = "0";
                    bonusParams = $"game={config.gameName}&key={config.TokenKey}" +
                                  $"&bonus={bonusValue}&param={bonusValue}&ts={config.TimeStamp}&platform=web";


                    break;

                case 1:

                    var param = counter.ToString();
                    var mode  = counter.ToString();

                    if (bonusId == 3 || bonusId == 4)
                    {
                        counter++;
                    }

                    bonusParams = $"game={config.gameName}&key={config.TokenKey}" +
                                  $"&bonus={config.TokenKey}&param={param}&mode={mode}&ts={config.TimeStamp}&platform=web";

                    break;

                case 2:
                    bonusParams = $"game={config.gameName}&key={config.TokenKey}" +
                                  $"&bonus={config.TokenKey}&param=0&&ts={config.TimeStamp}&platform=web";

                    break;
                }

                var actualResult = SlotRequest <BonusResult>(Configurations.BonusEndpoint, bonusParams);
                if (config.Export)
                {
                    exportValues.ExportCSV(config, actualResult.TxnId.ToString(), "Bonus Request",
                                           config.Bet, actualResult.TotalBet.ToString(), actualResult.TotalWin.ToString());
                }
                Console.WriteLine("Bonus Ongoing");

                bonusCompleted = actualResult.BonusCompleted;
            } while (!bonusCompleted);
        }
        private void btnExport_Click(object sender, EventArgs e)
        {
            //Configuration file header y declare variable;
            string headerCsv, path = string.Empty;

            headerCsv = "Nombre,Apellido,Cedula,Carnet,Tipo de personal,Tipo usuario,Estado,Activo";

            //open dialog and get pathDirectory
            path = Util.OpenSaveFileDialog();

            if (path != null && !string.IsNullOrWhiteSpace(path))
            {
                ExportCsv exportCsv = new ExportCsv(path);
                exportCsv.WriteFileHeader(headerCsv);
                var dataToExport = audiovisualEntities.Users.ToList();
                foreach (User data in dataToExport)
                {
                    //Data to insert into body
                    string linea = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                                 data.FirstName,
                                                 data.LastName,
                                                 data.IdentificationCard,
                                                 data.Carnet,
                                                 data.PersonalType.Description,
                                                 data.UsersType.Description,
                                                 data.UsersState.Description,
                                                 data.Enabled);

                    exportCsv.WriteFileLine(linea);
                }
            }
            ;
        }
        private void btnExport_Click(object sender, EventArgs e)
        {
            //Configuration file header y declare variable;
            string headerCsv, path = string.Empty;

            headerCsv = "Nombre,Apellido,Cedula,Turno de trabajo,Fecha de contratación,Estado,Activo";

            //open dialog and get pathDirectory
            path = Util.OpenSaveFileDialog();

            if (path != null && !string.IsNullOrWhiteSpace(path))
            {
                ExportCsv exportCsv = new ExportCsv(path);
                exportCsv.WriteFileHeader(headerCsv);
                var dataToExport = audiovisualEntities.Employees.ToList();
                foreach (Employee data in dataToExport)
                {
                    //Data to insert into body
                    string linea = string.Format("{0},{1},{2},{4},{5},{6}",
                                                 data.FirstName,
                                                 data.LastName,
                                                 data.IdentificationCard,
                                                 data.Workshift,
                                                 data.HiredDate,
                                                 data.EmployeesState.Description,
                                                 data.Enabled
                                                 );

                    exportCsv.WriteFileLine(linea);
                }
            }
            ;
        }
        private void btnExport_Click(object sender, EventArgs e)
        {
            //Configuration file header y declare variable;
            string headerCsv, path = string.Empty;

            headerCsv = "Descripcion,Serial,Tag Servicio,Modelo,Marca,Tecnologia Conexion,Estado,Activo";

            //open dialog and get pathDirectory
            path = Util.OpenSaveFileDialog();

            if (path != null && !string.IsNullOrWhiteSpace(path))
            {
                ExportCsv exportCsv = new ExportCsv(path);
                exportCsv.WriteFileHeader(headerCsv);
                var dataToExport = audiovisualEntities.Equiments.ToList();
                foreach (Model.Equiment data in dataToExport)
                {
                    //Data to insert into body
                    string linea = string.Format("{0},{1},{2},{3},{4},{5},{6}",
                                                 data.Description,
                                                 data.Serial,
                                                 data.ServiceTag,
                                                 data.Model.Description,
                                                 data.Brand.Description,
                                                 data.TechnologiesConnection.Description,
                                                 data.EquimentsState.Description
                                                 );

                    exportCsv.WriteFileLine(linea);
                }
            }
            ;
        }
Exemple #7
0
        public static void WriteCsVintoFile <T>(string filepath, ref List <T> list, ref bool blHeader)
        {
            if (list.Count > 0)
            {
                //MasterPageBase[] objaray=  listmasterpagebase.ToArray();
                string strCsv = ExportCsv.ToCsv(",", list, ref blHeader);

                AppendTextintoFile(filepath, strCsv);
            }

            list.TrimExcess();
            list = null;
        }
Exemple #8
0
        //�Private�Methods�(1)�

        private static ExportStrategy GetExportStrategyObject(ExportingOption exportOption)
        {
            ExportStrategy obj;

            switch (exportOption)
            {
            case ExportingOption.Csv:
                obj = new ExportCsv();
                break;

            default: throw new ArgumentException("Invalid export type specified = " + exportOption);
            }

            return(obj);
        }
        /// <summary>
        /// Fonction appelé lorsque on souhaite exporter la base de donénes
        /// </summary>
        private void Exporter_Click(object sender, EventArgs e)
        {
            //On verifie que l'utilisateur a selectionné un dossier
            if (this.label1.Text != null && this.label1.Text != "")
            {
                //On recupere le dossier selectionnée et on appel la fonction ExporterCsv
                ExportCsv CsvExport = new ExportCsv();
                int       ResultatExport;

                this.progressBar1.Increment(50);

                ResultatExport = CsvExport.ExporterCsv(this.label1.Text);

                this.progressBar1.Increment(100);

                // Message affiché à la fin de l'importation
                this.textStatus.Text = "Le fichier a été exporté avec succés";
            }
        }
Exemple #10
0
 // Function onclick of button export CSV
 private void exportCsv_Click(object sender, EventArgs e)
 {
     ExportCsv.writeCsv(this.ViewModel.VMMain.Client, this.ViewModel.VMMain.UIMainForm);
 }