Exemplo n.º 1
0
        //runs everything.
        public MainWindow()
        {
            InitializeComponent();
            _writer = null;

            //state variables
            _logging       = false;
            _email_logging = false;
            _log_path      = GetDefaultDirectory();

            //create the page objects
            CreatePages();
            ContentFrame.Navigate(_student_id_page);

            //sets up timers to go at particular times
            //start of cougtech and end of cougtech working hours
            startDayTimer           = new System.Windows.Threading.DispatcherTimer(); // Timer to automatically start logging at 8:00 am
            startDayTimer.Interval  = TimeUntilNextTimer(startTime);
            startDayTimer.IsEnabled = true;
            startDayTimer.Tick     += new EventHandler(AutoStartLog);

            endDayTimer           = new System.Windows.Threading.DispatcherTimer(); // Timer to automatically end logging at 5:00 pm
            endDayTimer.Interval  = TimeUntilNextTimer(endTime);
            endDayTimer.IsEnabled = true;
            endDayTimer.Tick     += new EventHandler(AutoEndLog);

            ContentFrame.Navigated  += ContentFrame_Navigated;
            ContentFrame.Navigating += ContentFrame_Navigating;
        }
Exemplo n.º 2
0
        public void Row_Default()
        {
            var res = CSVWriter.Write(m_Row);
            var str = m_Header + m_Data;

            Aver.AreEqual(str, res);
        }
Exemplo n.º 3
0
        private void Button4_Click(object sender, EventArgs e)
        {
            saveFileDialog1.ShowDialog();
            CSVWriter writer = new CSVWriter();

            writer.WriteListToFile(data, saveFileDialog1.FileName);
        }
Exemplo n.º 4
0
        public static string ToString(Table table, TableContainType tableContainType)
        {
            java.io.StringWriter stringWriter = new java.io.StringWriter();
            try
            {
                technology.tabula.writers.Writer writer = null;
                switch (tableContainType)
                {
                case TableContainType.CSV:
                    writer = new CSVWriter();
                    break;

                case TableContainType.Json:
                    writer = new JSONWriter();
                    break;

                case TableContainType.TSV:
                    writer = new TSVWriter();
                    break;

                default:
                    writer = new JSONWriter();
                    break;
                }

                writer.write(stringWriter, table);
            }
            catch
            {
                return(string.Empty);
            }
            return(stringWriter.toString());
        }
        /// <summary>
        ///   Generate random matrix of projections
        /// </summary>
        private void BtnGenerateHashClick(object sender, EventArgs e)
        {
            string path  = "randomvars.csv";
            Hash   hash  = new Hash();
            int    rows  = (int)_nudRows.Value;
            int    bands = (int)_nudBands.Value;

            int[][] hashes = hash.GetRandomMatrix(rows, bands,
                                                  (int)_nudStartPerm.Value, (int)_nudEndPerm.Value);

            object[][] toWrite = new object[bands][];
            for (int i = 0; i < bands; i++)
            {
                toWrite[i] = new object[rows];
                for (int j = 0; j < rows; j++)
                {
                    toWrite[i][j] = hashes[i][j];
                }
            }
            using (SaveFileDialog sfd = new SaveFileDialog {
                FileName = path, Filter = Resources.FileFilterCSV
            })
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    path = Path.GetFullPath(sfd.FileName);
                    CSVWriter writer = new CSVWriter(path);
                    writer.Write(toWrite);
                }
            }
        }
Exemplo n.º 6
0
        public void SetFormatTest()
        {
            CSVFormat format = createFormat();

            CSVWriter csvw = new CSVWriter();

            // Make sure there are no formats to start with
            int actual = csvw.Formats.Count();

            Assert.IsTrue(actual == 0, $"Error: {actual} was returned when 0 were expected");

            // Add some formats
            for (int expected = 1; expected <= 10; expected++)
            {
                csvw.SetFormat(expected - 1, format);

                actual = csvw.Formats.Count();
                Assert.IsTrue(actual == expected, $"Error: {actual} was returned when {expected} were expected");
            }

            // Now set a format
            int rnd = RandomInt(0, 9);

            csvw.SetFormat(rnd, null);

            Assert.IsTrue(csvw.Formats[rnd] == null, $"Error: Format [{rnd}] returned a non-null value when NULL was expected");
        }
Exemplo n.º 7
0
 /// <summary>
 /// アプリ起動時に一回だけ実行される関数
 /// 基本的には変数の初期化処理を行う
 /// </summary>
 void Start()
 {
     player          = GameObject.Find("Player");
     pos             = GetComponent <Transform>().position;
     defaultPos      = player.transform.position;
     defaultRot      = player.transform.localEulerAngles;
     checkpointflag  = false;
     meDirection     = BACK;
     moveObjList     = new List <GameObject>();
     moveList        = new List <string>();
     CSV             = GameObject.Find("CSVWriter").GetComponent <CSVWriter>(); //GameObject CSVWriterを探し出してアタッチする
     panelController = GameObject.Find("edit").GetComponent <panelController>();
     floarController = GameObject.Find("floar").GetComponent <floorController>();
     seList          = GetComponents <AudioSource>();
     //ashioto = seList[0];
     //awa = seList[1];
     ifCheckFlg     = false;
     pauseScript    = player.GetComponent <PauseScript>();
     moveFlg        = false;
     panelList      = new List <GameObject>();
     whilePanelList = new List <GameObject>();
     ifActionMap    = null;
     panelIndex     = 0;
     moveCount      = 0F;
     whileCount     = 0;
     whileIndex     = 0;
     stage          = SceneManager.GetActiveScene().name;
     CSV.WriteCSV(stage + "," + 0);
     switching = false;
 }
        public void TestWriteLine()
        {
            var encoding = new UTF8Encoding(false); // UTF-8 BOM must die !!

            var bean = new SampleBean()
            {
                Column1  = "value1",
                Column2  = "value\nvalue,value\"",
                MyNumber = 1234
            };

            using (var stream = new MemoryStream())
                using (var instance = new CSVWriter <SampleBean>(stream, encoding))
                {
                    instance.WriteLine(bean);

                    instance.Flush();

                    var result = encoding.GetString(stream.ToArray());

                    var expected = "value1,\"value\nvalue,value\"\"\",1234\r\n";

                    Check.That(result).IsEqualTo(expected);
                }
        }
Exemplo n.º 9
0
 public void RunGamut()
 {
     EventQueue.Subscribe(EventQueue.EventType.BroadcastGeneration, Ticker);
     ExtractTestTitles();
     CSVWriter.WriteHeader(testTitles);
     BeginTestingSession(false);
 }
Exemplo n.º 10
0
        public void Validate_CSV()
        {
            // arrange
            int    total     = 50;
            int    LV        = 30;
            int    LT        = 15;
            int    EE        = 5;
            string directory = "CSV";
            string fileName  = "UserCount.csv";

            // act
            CSVWriter       writer    = new CSVWriter();
            CSVReader       reader    = new CSVReader($"{directory}//{fileName}".ToCsvFilePath());
            PathConstructor path      = new PathConstructor();
            Result          result    = new Result();
            Validator       validator = new Validator(writer, reader, path, result);

            // assert
            try
            {
                validator.ValidateFile(directory, fileName, total, LV, LT, EE);
                Assert.IsTrue(true);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
Exemplo n.º 11
0
        // Update is called once per frame
        void Update()
        {
            if (!hasLoadedValues && fileReader.hasFinished)
            {
                // One time run once it has finished reading the values...
                fileWriter = new CSVWriter(fileReader.GetHeaderTable, fileReader.GetDataTable);
                fileWriter.WriteFile(Path.GetDirectoryName(filePath) + "\\" + Path.GetFileNameWithoutExtension(filePath) + "_Cleaned" + Path.GetExtension(filePath));

                readFile        = true;
                hasLoadedValues = true;
                UnityEngine.Debug.Log("Written to file...\n" + fileReader.getErrors);
            }
            if (hasLoadedValues && !wroteFile && fileWriter.hasFinished)
            {
                //Do something with the data... ie graph it

                /*
                 * if (Counter < AverageValues[ReadingType.Lux].Count) {
                 *  DebugGUI.Graph("Lux", (float)AverageValues[ReadingType.Lux][Counter]);
                 * }
                 * Counter++;
                 */
                wroteFile = true;
                UnityEngine.Debug.Log("All done...\n" + fileWriter.getErrors);
            }
        }
Exemplo n.º 12
0
    // Use this for initialization

    void Start()
    {
        //DEBUG = false;
        DEBUG = true;

        de  = true;
        dtm = 0f;
        //AS = GetComponent<AudioSource>();
        //AudioSource[] Audios = GetComponents<AudioSource>();
        //Musics[Base.MusicNumber] = Audios[Base.MusicNumber];
        //Musics = gameObject.GetComponents<AudioSource>();
        audioSource = gameObject.AddComponent <AudioSource>();
        _isPlaying  = false;
        _timer      = 0;
        try
        {
            _CSVWriter = _CSVWriter.GetComponent <CSVWriter>();
        }
        catch
        {
            Debug.Log("Error! Not find file or music");
            SceneManager.LoadScene("Error");
        }

        note_time = new float[20];
    }
Exemplo n.º 13
0
        public void TestWriteAllObjects()
        {
            IList <string[]> allElements = new List <string[]>();

            string[] line1 = "Name#Phone#Email".Split('#');
            string[] line2 = "Glen#1234#[email protected]".Split('#');
            string[] line3 = "John#5678#[email protected]".Split('#');
            allElements.Add(line1);
            allElements.Add(line2);
            allElements.Add(line3);

            StringWriter sw = new StringWriter();
            CSVWriter    cw = new CSVWriter(sw);

            cw.WriteAll(allElements, false);

            string result = sw.ToString();

            string[] lines = result.Split('\n');

            Assert.AreEqual(4, lines.Length);

            string[] values = lines[1].Split(',');

            Assert.AreEqual("1234", values[1]);
        }
Exemplo n.º 14
0
        private void WriteAndTestRow(object[] input, string output, Dialect dialect, CultureInfo culture = null)
        {
            dialect = dialect ?? new Dialect(
                true, ';', '\"', '\\', true, "\r\n", QuoteStyle.QuoteMinimal, false, false);

            var oldCulture = Thread.CurrentThread.CurrentCulture;

            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                string results;
                using (var writer = new StringWriter())
                {
                    using (var csvWriter = new CSVWriter(dialect, writer, culture))
                    {
                        csvWriter.WriteRow(input);
                    }

                    results = writer.ToString();
                }

                AreEqual(output, results);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = oldCulture;
            }
        }
Exemplo n.º 15
0
 // 1回だけ発生
 void Start()
 {
     // GameMusicオブジェクトを探す
     _audioSource = GameObject.Find("GameMusic").GetComponent <AudioSource>();
     // CSVWriterオブジェクトを探す
     _CSVWriter = GameObject.Find("CSVWriter").GetComponent <CSVWriter>();
 }
    // Read all files
    IEnumerator parseFiles()
    {
        csv = new CSVWriter();

        // Create first column in CSV.
        csv.InsertValue("Test name");
        csv.InsertValue("Data type");
        csv.InsertValue("");
        csv.InsertValue("Average");
        csv.InsertValue("");
        csv.InsertValue("Minimum");
        csv.InsertValue("1st Quartile");
        csv.InsertValue("Median");
        csv.InsertValue("3rd Quartile");
        csv.InsertValue("Maximum");
        csv.InsertValue("");
        csv.InsertValue("Data");
        csv.NextColumn();

        for (int i = 0; i < files.Count; ++i)
        {
            Debug.Log("File " + i + " of " + files.Count + " (" + (100 * i / files.Count) + "%)");
            parseFile(files[i]);
            yield return(null);
        }
        csv.Write(outputFile);

        Debug.Log("Done.");
    }
Exemplo n.º 17
0
        public void Write_ResultsToCSV()
        {
            // arrange
            int           id       = 1;
            int           total    = 50;
            int           LV       = 30;
            int           LT       = 15;
            int           EE       = 5;
            string        fileName = "CSV//UserCountCreatedByTest.csv";
            List <Result> results  = new List <Result>();
            Result        result   = new Result
            {
                Id    = id,
                Total = total,
                LV    = LV,
                LT    = LT,
                EE    = EE
            };

            results.Add(result);
            var expected = results.Find(x => x.EE == 5);

            // act
            CSVReader       reader   = new CSVReader();
            CSVWriter       writer   = new CSVWriter();
            PathConstructor path     = new PathConstructor();
            var             fullPath = path.pathConstructor(fileName);

            writer.WriteToCSVFile(fullPath, results);
            var actualList = reader.GetTotal(fullPath).Item2;
            var actual     = actualList.Find(x => x.EE == 5);

            // assert
            Assert.AreEqual(actual.EE, expected.EE);
        }
Exemplo n.º 18
0
        public override bool Initialize()
        {
            _fileName = settingsItem.DAL_FileName ?? DEFAULT_CSV_FILE;

            _writer = new CSVWriter(_fileName);

            return(File.Exists(_fileName));
        }
Exemplo n.º 19
0
 /// <summary>
 /// Start connecting to Server
 /// </summary>
 public void Connect()
 {
     writer = new CSVWriter();
     Debug.Log("TryConnect");
     this._socket  = new TcpClient();
     receiveBuffer = new byte[dataBufferSize];
     this._socket.BeginConnect(System.Net.IPAddress.Parse(ip), port, ConnectCallback, this._socket); //Start async connection
 }
Exemplo n.º 20
0
        public void CorrectlyParseNullObject()
        {
            var sw = new StringWriter();
            var cw = new CSVWriter(sw, ',', '\'');

            cw.WriteNext(null, false);
            Assert.AreEqual(0, sw.ToString().Length);
        }
Exemplo n.º 21
0
        private string InvokeNoEscapeWriter(string[] fields)
        {
            var sw = new StringWriter();
            var cw = new CSVWriter(sw, ',', '\'', CSVWriter.NoEscapeCharacter);

            cw.WriteNext(fields);
            return(sw.ToString());
        }
Exemplo n.º 22
0
        private string InvokeWriter(string[] fields)
        {
            var sw = new StringWriter();
            var cw = new CSVWriter(sw, ',', '\'');

            cw.WriteNext(fields);
            return(sw.ToString());
        }
Exemplo n.º 23
0
    // Use this for initialization
    void Awake()
    {
        _sendToGoogle = GetComponent <SendToGoogle>();
        _csvWriter    = GetComponent <CSVWriter>();
        //Invoke("Test", 3);

        LoadScores();
    }
Exemplo n.º 24
0
 /// <summary>
 /// Writes time log finished and deallocates the CSVWriter
 /// </summary>
 public void FinishLog()
 {
     _writer.addToCurrent("Log End Time: ");
     _writer.addToCurrent(DateTime.Now.ToShortTimeString());
     _writer.WriteLine();
     //close and dealocate the csv writer
     _writer = null;
 }
Exemplo n.º 25
0
        protected override void ExportCore(Stream stream, TBodyList tList)
        {
            _writer = new CSVWriter(stream);

            OutputDetails(tList);

            _writer.Flush();
        }
Exemplo n.º 26
0
        public void Writee_ValidInput_ReturnsExpectedResult(string[] columns, string expectedLine)
        {
            var fakekWriter = new FakeWriter();
            var csvWriter   = new CSVWriter(fakekWriter);

            csvWriter.Write(columns);
            Assert.AreEqual(expectedLine, fakekWriter.Line);
        }
Exemplo n.º 27
0
        public void Write_NoColumns_ThrowException()
        {
            var csvWriter = new CSVWriter(new FakeWriter());

            var ex = Assert.Throws <ArgumentNullException>(() => csvWriter.Write(null));

            Assert.AreEqual("Please provide at least 1 column\r\nParameter name: columns", ex.Message);
        }
Exemplo n.º 28
0
        public void NullRowOrRowset()
        {
            var res = CSVWriter.Write((Doc)null);

            Aver.IsTrue(res == string.Empty);

            res = CSVWriter.Write((Rowset)null);
            Aver.IsTrue(res == string.Empty);
        }
Exemplo n.º 29
0
        public void Row_ToBuffer()
        {
            var encoding = new UTF8Encoding(false);
            var buffer   = CSVWriter.WriteToBuffer(m_Row, encoding: encoding);

            var test = encoding.GetBytes(m_Header + m_Data);

            Aver.IsTrue(IOUtils.MemBufferEquals(test, buffer));
        }
Exemplo n.º 30
0
 void OnEnable()
 {
     base.OnEnable();
     currentTrial  = -1;            // Start at -1 because we start the trial into ITI which will increment currentTrial
     trialState    = TrialState.Starting;
     timer         = new CountdownTimer(-1);
     recordResults = CSVWriter.NewOutputFile(subject, "axcpt_results");
     recordResults.WriteRow("trial_number,trial_type,stimulus_type,stimulus_name,button_pressed,reaction_time");
 }
Exemplo n.º 31
0
        static string GeneratePPCSV(string fileNameExportPP)
        {
            string fullPath = string.Concat(outputDirectory, fileNameExportPP);

            #region liste des attributs (ie colonnes)
            /*
             * Le contenu de cette liste est composé de nombre et de chaine
             * Le nombre indique que cette colonne affiche le contenu d'un OptionAttribute(champs type texte)
             * la chaine caractère indique qu'il s'agit du traitement d'un RadioButtonListe, ou l'affichage necessite un traitement 
             */
            // rangement des colonnes
            List<object> lstIdOptionAttributeValue = new List<object>() { 
                "CONSEILLER"
                , "ETABLISSEMENT"
                , "idContact"
                , "dateDDC"
                , "Nom"
                , "Prenom"
                , 144
                , "Date de naissance"
                , "Lieu de naissance"
                , 148, 149, 150
                , "Mobile"
                , "Email"
                , "Type adresse1"
                , "Adresse courrier 1"
                , 154
                , "CodePostal"
                , "Ville"
                , "Pays"
                , "isMajor"
                , "Représentant legal"
                , "Nationalite"
                , 156
                , "IsResident"
                , 157
                , "ContactParRecommandation" 
                , "Activité(s) salariée(s)"
                , "Activité(s) autre que salariée"
                , "Sans profession"
                , "Retraite depuis le"
                , 160
                , 161
                , "Mandataire social"
                , "Situation familiale"
                , "Date de l'evenement"
                , "Régime matrimonial"
                , "Donation entre époux"
                , 731
                , 732
                , "Donation enfants / petits enfants"
                , 733
                , 734
                , "Testament"
                , 735
                , 736
                , "Autre libéralité"
                , 737
                , 738
                , 721 // = champs "Notes"
                , 727
                , "Salaires / bonus / retraite"
                , "Dividendes / revenus mobiliers"
                , "Transactions immobilières"
                , "Valeurs mobilères"
                , "Donations / successions"
                , "Autres revenus"
                , 728
                , "Liquidités"
                , "Placements à terme"
                , "Assurance vue"
                , "Valeurs mobilières"
                , "Immoblilier de jouissance"
                , "Immobilier de rapport"
                , "Patrimoine professionnel"
                , "Endettement estimé"
                , "Projet immobilier"
                , "Projet donation"
                , "Projet divers"
            };
            #endregion
                
            CSVWriter csvWriter = new CSVWriter(fullPath, '\t');
            
            #region Première ligne : titre
            List<string> lstColonnes = new List<string>() 
            { 
                "CONSEILLER",
                "ETABLISSEMENT",
                "ID_CONTACT",
                "Date DDC",
                "Nom",
                "Prénom",
                "Nom de jeune fille",
                "Date de naissance",
                "Lieu de naissance",
                "Tél. privé",
                "Fax",
                "Tél. prof",
                "Tél. portable",
                "Adresse e-mail", 
                "Type adresse1",
                "Adresse courrier 1",
                "Adresse courrier 2",
                "Adresse courrier code postal",
                "Adresse courrier Ville",
                "Pays",
                "Majeur",
                "Représentant legal",
                "Nationalité",
                "Autre (si double nationalité)",
                "Résident - Non Résident",
                "Pays de résidence",
                "Contact par recommandation",
                "Activité(s) salariée(s)",
                "Activité(s) autre que salariée",
                "Sans profession",
                "Retraite depuis le",
                "Métier",
                "Secteur d’activité",
                "Mandataire social",
                "Situation familiale",
                "Date de l'evenement",
                "Régime matrimonial",
                "Donation entre époux",
                "Donation entre époux Montant",
                "Donation entre époux Date",
                "Donation enfants / petits enfants",
                "Donation enfants / petits enfants Montant",
                "Donation enfants / petits enfants Date",
                "Testament",
                "Testament Montant",
                "Testament Date",
                "Autre libéralité",
                "Autre libéralité Montant",
                "Autre libéralité Date",
                "Notes",
                "Revenus",
                "Salaires / bonus / retraite",
                "Dividendes / revenus mobiliers",
                "Transactions immobilières",
                "Valeurs mobilères",
                "Donations / successions",
                "Autres revenus",
                "Actif global estimé",
                "Liquidités",
                "Placements à terme",
                "Assurance vue",
                "Valeurs mobilières",
                "Immoblilier de jouissance",
                "Immobilier de rapport",
                "Patrimoine professionnel",
                "Endettement estimé",
                "Projet immobilier",
                "Projet donation",
                "Projet divers"
            };

            csvWriter.WriteLine(lstColonnes);
            #endregion

            //Data
            foreach (Report rep in lstPPReports)
            {
                if (rep.ReportOptionAttributeValue != null)
                {
                    List<ReportOptionAttributeValue> lstReportOptionAttributeValues = rep.ReportOptionAttributeValue.OrderByDescending(roav => roav.DateUpdated).ThenByDescending(roav => roav.DateCreated).ToList();
                    lstColonnes = new List<string>();

                    // génération des colonnes
                    foreach (object idOptionAttr in lstIdOptionAttributeValue)
                    {
                        int idOptionAttribute;
                        int.TryParse(idOptionAttr.ToString(), out idOptionAttribute);
                        string value = string.Empty;

                        // s'il s'agit d'un optionAttribute (input type text)
                        if (idOptionAttribute != 0)
                        {
                            // génération des colonnes dans OptionAttribute
                            value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault().Value : "";
                        }
                        else
                        {
                            #region génération des autres colonnes
                            switch (idOptionAttr.ToString())
                            {
                                case "CONSEILLER": value = rep.CustomerProspect.User1.UserEmail; break;
                                case "Nom": value = rep.CustomerProspect.User.UserName; break;
                                case "Prenom": value = rep.CustomerProspect.User.UserFirstName; break;
                                case "Email": value = rep.CustomerProspect.User.UserEmail; break;
                                case "Mobile": value = rep.CustomerProspect.User.UserMobilePhone; break;
                                case "ETABLISSEMENT": value = rep.CustomerProspect.FirmInstitution.FirmInstitutionName; break;
                                case "idContact": value = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString(); break;
                                case "dateDDC":
                                    value = (rep.CustomerProspect.DateUpdatedLast.HasValue) ? rep.CustomerProspect.DateUpdatedLast.Value.ToString("dd/MM/yyyy") : string.Empty;
                                    break;
                                case "Date de naissance":
                                    //value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 145).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 145).FirstOrDefault().Value : "";
                                    value = (rep.CustomerProspect.DateOfBirth.HasValue) ? rep.CustomerProspect.DateOfBirth.Value.ToString("dd/MM/yyyy") : string.Empty;
                                    //value = FormatDateToMMJJYYYY(value);
                                    break;
                                case "Lieu de naissance": value = rep.CustomerProspect.PlaceOfBirth; break;
                                case "Nationalite": value = rep.CustomerProspect.Nationality; break;                                    
                                case "Type adresse1": value = "Perso"; break;
                                case "Adresse courrier 1": value = rep.CustomerProspect.Adress; break;
                                case "CodePostal": value = rep.CustomerProspect.ZipCode; break;
                                case "Ville": value = rep.CustomerProspect.City; break;

                                //case "Adresse courrier 2": value = ""; break; //Adresse fiscale ?
                                case "Pays": value = ""; break; // TODO
                                case "isMajor": value = rep.CustomerProspect.LegalCapacity; break;
                                case "Représentant legal": value = rep.CustomerProspect.LegalRepresentative; break;
                                case "IsResident": value = rep.CustomerProspect.IsResident.HasValue ? rep.CustomerProspect.IsResident.Value ? "Oui" : "Non" : ""; break;
                                case "ContactParRecommandation":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOptionContactParRecommandation = new List<int>() { 247, 248, 249, 250, 251, 252, 253 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOptionContactParRecommandation.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 247: value = "Famille"; break;
                                                    case 248: value = "Apporteur d’affaires"; break;
                                                    case 249: value = "Avocat"; break;
                                                    case 250: value = "Expert comptable"; break;
                                                    case 251: value = "Notaire"; break;
                                                    case 252: value = "Ami"; break;
                                                    case 253: value = (repOV.ReportOptionAttributeValue.FirstOrDefault() != null ? repOV.ReportOptionAttributeValue.FirstOrDefault().Value : ""); break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Activité(s) salariée(s)":
                                    {
                                        var exist = rep.ReportOptionValue.Where(rov => rov.idOption == 261).FirstOrDefault();
                                        value = (exist == null) ? "Non" : "Oui"; break;
                                    }
                                case "Activité(s) autre que salariée":
                                    {
                                        var exist = rep.ReportOptionValue.Where(rov => rov.idOption == 262).FirstOrDefault();
                                        value = (exist == null) ? "Non" : "Oui"; break;
                                    }
                                case "Sans profession":
                                    {
                                        var exist = rep.ReportOptionValue.Where(rov => rov.idOption == 260).FirstOrDefault();
                                        value = (exist == null) ? "Non" : "Oui"; break;
                                    }
                                case "Retraite depuis le":
                                    {
                                        value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 158).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 158).FirstOrDefault().Value : "";
                                        //value = FormatDateToMMJJYYYY(value);
                                        break;
                                    }

                                case "Mandataire social":
                                    {
                                        var exist = rep.ReportOptionValue.Where(rov => rov.idOption == 264).FirstOrDefault();
                                        value = (exist == null) ? "Non" : "Oui"; break;
                                    }
                                case "Situation familiale":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        { 
                                            List<int> lstIdOptionSituationFamiliale = new List<int>(){278, 279, 280, 281, 282, 283, 284};
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOptionSituationFamiliale.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 278: value = "Marié"; break;
                                                    case 279: value = "PACS"; break;
                                                    case 280: value = "Célibataire"; break;
                                                    case 281: value = "Veuf"; break;
                                                    case 282: value = "Divorcé"; break;
                                                    case 283: value = "Séparé"; break;
                                                    case 284: value = "Concubin"; break;
                                                }
                                            }
                                        }

                                        break;
                                    }
                                case "Date de l'evenement":
                                    {
                                        value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 178).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 178).FirstOrDefault().Value : "";
                                        //value = FormatDateToMMJJYYYY(value);
                                        break;
                                    }
                                case "Régime matrimonial":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOptionContactParRecommandation = new List<int>() { 287, 288, 289, 1148, 1158, 1159, 1160 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOptionContactParRecommandation.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 287: value = "Séparation de biens"; break;
                                                    case 288: value = "Participation aux acquêts"; break;
                                                    case 289: value = "Communauté universelle"; break;
                                                    case 1148: value = "Communauté réduite aux acquêts (régime légal après 1966)"; break;
                                                    case 1158: value = "Communauté meubles et acquêts (régime légal avant 1966)"; break;
                                                    case 1159: value = "Séparation de biens avec société d’acquêts"; break;
                                                    case 1160: value = (repOV.ReportOptionAttributeValue.FirstOrDefault() != null ? repOV.ReportOptionAttributeValue.FirstOrDefault().Value : ""); break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Donation entre époux":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOption = new List<int>() { 1181, 1182 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOption.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 1181: value = "Oui"; break;
                                                    case 1182: value = "Non"; break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Donation enfants / petits enfants":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOption = new List<int>() { 1184, 1185 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOption.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 1184: value = "Oui"; break;
                                                    case 1185: value = "Non"; break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Testament":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOption = new List<int>() { 1187, 1188 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOption.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 1187: value = "Oui"; break;
                                                    case 1188: value = "Non"; break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Autre libéralité":
                                    {
                                        value = "";

                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOption = new List<int>() { 1190, 1191 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOption.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 1190: value = "Oui"; break;
                                                    case 1191: value = "Non"; break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                //case "Notes": value = ""; break; = 721
                                case "Salaires / bonus / retraite":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 194).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Dividendes / revenus mobiliers":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 195).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Transactions immobilières":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 196).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Valeurs mobilères":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 197).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Donations / successions":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 198).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Autres revenus":
                                    {
                                        value = "";
                                        var repOAV = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 199).FirstOrDefault();
                                        if (repOAV != null)
                                        {
                                            value = repOAV.CustomObjectValue.Amount;
                                        }

                                        break;
                                    }
                                case "Liquidités":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 200).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui"; 
                                        value = ReportBL.SumCurrentValue(200, rep);
                                        break;
                                    }
                                case "Placements à terme":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 201).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(201, rep);
                                        break;
                                    }
                                case "Assurance vue":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 202).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(202, rep);
                                        break;
                                    }
                                case "Valeurs mobilières":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 203).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(203, rep);
                                        break;
                                    }
                                case "Immoblilier de jouissance":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 204).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(204, rep);
                                        break;
                                    }
                                case "Immobilier de rapport":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 205).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(205, rep);
                                        break;
                                    }
                                case "Patrimoine professionnel":
                                    {
                                        //var exist = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 206).FirstOrDefault();
                                        //value = (exist == null) ? "Non" : "Oui";
                                        value = ReportBL.SumCurrentValue(206, rep);
                                        break;
                                    }
                                case "Endettement estimé":
                                    {
                                        var optionAttributeValue = lstReportOptionAttributeValues.Where(roav => roav.idOptionAttribute == 729).FirstOrDefault();
                                        //value = (optionAttributeValue == null) ? "Non" : "Oui";
                                        value = (optionAttributeValue == null) ? string.Empty : optionAttributeValue.Value.Replace(",", ".");
                                        break;
                                    }
                                case "Projet immobilier": value = ""; break;
                                case "Projet donation": value = ""; break;
                                case "Projet divers": value = ""; break;
                            }
                            #endregion
                        }
                        // génère la colonne dans le fichier
                        lstColonnes.Add(ReplaceValue(value));
                    }

                    // génére la ligne
                    csvWriter.WriteLine(lstColonnes);
                }
            }

            csvWriter.Dispose();

            return fullPath;
        }
Exemplo n.º 32
0
        /// <summary>
        ///   Generate random matrix of projections
        /// </summary>
        private void BtnGenerateHashClick(object sender, EventArgs e)
        {
            string path = "randomvars.csv";
            Hash hash = new Hash();
            int rows = (int) _nudRows.Value;
            int bands = (int) _nudBands.Value;
            int[][] hashes = hash.GetRandomMatrix(rows, bands,
                (int) _nudStartPerm.Value, (int) _nudEndPerm.Value);

            object[][] toWrite = new object[bands][];
            for (int i = 0; i < bands; i++)
            {
                toWrite[i] = new object[rows];
                for (int j = 0; j < rows; j++)
                    toWrite[i][j] = hashes[i][j];
            }
            using (SaveFileDialog sfd = new SaveFileDialog {FileName = path, Filter = Resources.FileFilterCSV})
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    path = Path.GetFullPath(sfd.FileName);
                    CSVWriter writer = new CSVWriter(path);
                    writer.Write(toWrite);
                }
            }
        }
Exemplo n.º 33
0
        static string GeneratePMCSV(string fileNameExport)
        {
            string fullPath = string.Concat(outputDirectory, fileNameExport);

            #region liste des attributs (ie colonnes)
            // rangement des colonnes
            List<object> lstIdOptionAttributeValue = new List<object>() { 
                "CONSEILLER"
                , "ETABLISSEMENT"
                , "idContact"
                , "dateDDC"
                , "Constante"
                , "RaisonSociale"
                , 382
                , "Type adresse"
                , 390 //Adresse 1
                , 394 //Addresse 2
                , 743 //Adresse  code postal
                , 744 //Adresse  Ville
                , 389 //Pays
                , "Mobile"
                , 745
                , "Date de création"
                , 383
                , 385
                , "Forme juridique"
                , "Société cotée"
                , 397
                , 643
                , "Origine de la relation"
            };
            #endregion

            CSVWriter csvWriter = new CSVWriter(fullPath, '\t');

            //Titre des colonnes
            List<string> lstColonnes = new List<string>()
            {
                "CONSEILLER",
                "ETABLISSEMENT",
                "ID_SOCIETE",
                "Date DDC",
                "Constante",
                "Raison sociale",
                "Signe ou nom commercial",
                "Type adresse",
                "Adresse  1",
                "Adresse  2",
                "Adresse  code postal",
                "Adresse  Ville",
                "Pays",
                "Téléphone",
                "Fax",
                "Date de création",
                "No RCS",
                "N° SIREN",
                "Forme juridique",
                "Société cotée",
                "Secteur d'activité",
                "Groupe",
                "Origine de la relation",
            };

            csvWriter.WriteLine(lstColonnes);

            foreach (Report rep in lstPMReports)
            {
                if (rep.ReportOptionAttributeValue != null)
                {
                    List<ReportOptionAttributeValue> lstReportOptionAttributeValues = rep.ReportOptionAttributeValue.OrderByDescending(roav => roav.DateUpdated).ThenByDescending(roav => roav.DateCreated).ToList();
                    lstColonnes = new List<string>();

                    // génération des colonnes
                    foreach (object idOptionAttr in lstIdOptionAttributeValue)
                    {
                        int idOptionAttribute;
                        int.TryParse(idOptionAttr.ToString(), out idOptionAttribute);
                        string value = string.Empty;

                        // s'il s'agit d'un optionAttribute (input type text)
                        if (idOptionAttribute != 0)
                        {
                            // génération des colonnes dans OptionAttribute
                            value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault().Value : "";
                        }
                        else
                        {
                            #region génération des autres colonnes
                            switch (idOptionAttr.ToString())
                            {
                                case "CONSEILLER": value = rep.CustomerProspect.User1.UserEmail; break;
                                case "ETABLISSEMENT": value = rep.CustomerProspect.FirmInstitution.FirmInstitutionName; break;                                
                                case "idContact": value = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString(); break;
                                case "dateDDC":
                                    value = (rep.CustomerProspect.DateUpdatedLast.HasValue) ? rep.CustomerProspect.DateUpdatedLast.Value.ToString("dd/MM/yyyy") : string.Empty;
                                    break;
                                case "RaisonSociale": value = rep.CustomerProspect.CompanyName; break;
                                case "Mobile": value = rep.CustomerProspect.User.UserMobilePhone; break;
                                case "Constante": value = "Société"; break;
                                case "Type adresse": value = "Siège"; break;
                                case "Date de création":
                                    value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 386).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 386).FirstOrDefault().Value : "";
                                    //value = FormatDateToMMJJYYYY(value);
                                    break;
                                case "Forme juridique":
                                    {
                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOrigineRelation = new List<int>() { 542, 543, 544, 545, 546, 549, 552, 555 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOrigineRelation.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 542: value = "Société Anonyme"; break;
                                                    case 543: value = "Société par actions simplifiée"; break;
                                                    case 544: value = "Société a Responsabilité Limitée"; break;
                                                    case 545: value = "Entreprise Universelle à Responsabilité Limitée"; break;
                                                    case 546: value = "Société Civile"; break;
                                                    case 549: value = "Association"; break;
                                                    case 552: value = (repOV.ReportOptionAttributeValue.FirstOrDefault() != null ? repOV.ReportOptionAttributeValue.FirstOrDefault().Value : ""); break;
                                                    //case 555: value = (repOV.ReportOptionAttributeValue.FirstOrDefault() != null ? repOV.ReportOptionAttributeValue.FirstOrDefault().Value : ""); break; //colonne groupe
                                                }
                                            }
                                        }
                                        break;
                                    }
                                case "Société cotée":
                                    {
                                        var exist = rep.ReportOptionValue.Where(rov => rov.idOption == 565).FirstOrDefault();
                                        if (exist != null)
                                        {
                                            value = "Oui";
                                        }
                                        else
                                        {
                                            exist = rep.ReportOptionValue.Where(rov => rov.idOption == 566).FirstOrDefault();
                                            value = (exist != null) ? "Oui" : "";
                                        }
                                         break;
                                    }
                                case "Origine de la relation":
                                    {
                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOrigineRelation = new List<int>() { 605, 606, 607, 608, 609, 610, 611, 612 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOrigineRelation.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 605: value = "Contact par recommandation"; break;
                                                    case 606: value = "Apporteur d’affaires, avocat, expert comptable, notaire"; break;
                                                    case 607: value = "Connaissance personnelle"; break;
                                                    case 608: value = "Opération marketing"; break;
                                                    case 609: value = "Contact sur un salon"; break;
                                                    case 610: value = "Article de presse"; break;
                                                    case 611: value = "Contact téléphonique"; break;
                                                    case 612: value = (repOV.ReportOptionAttributeValue.FirstOrDefault() != null ? repOV.ReportOptionAttributeValue.FirstOrDefault().Value : ""); break;
                                                }
                                            }
                                        }
                                        break;
                                    }
                            }
                            #endregion
                        }
                        // génère la colonne dans le fichier
                        lstColonnes.Add(ReplaceValue(value));
                    }

                    // génére la ligne
                    csvWriter.WriteLine(lstColonnes);
                }
            }

            csvWriter.Dispose();

            return fullPath;
        }
Exemplo n.º 34
0
        static string GenerateImpotsEtTaxesCSV(string fileNameExport)
        {
            string fullPath = string.Concat(outputDirectory, fileNameExport);

            CSVWriter csvWriter = new CSVWriter(fullPath, '\t');

            //Titre des colonnes
            List<string> lstColonnes = new List<string>()
            {
                "ID_CONTACT",
                "ID_IMPOT",
                "Désignation",
                "Montant"
            };

            csvWriter.WriteLine(lstColonnes);

            foreach (Report rep in lstPPReports)
            {
                if (rep.ReportOptionAttributeValue != null)
                {
                    List<ReportOptionAttributeValue> lstRoptionAttr = rep.ReportOptionAttributeValue.Where(o => o.idOptionAttribute == 216).ToList();
                    int attributCount = lstRoptionAttr.Count();

                    // génération des lignes
                    for (int i = 0; i < attributCount; i++)
                    {

                        ReportOptionAttributeValue reportOptionAttr = lstRoptionAttr[i];                        
                        lstColonnes = new List<string>();

                        string idContact = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString(); // RefExterne ou IdCustomer
                        lstColonnes.Add(idContact); 
                        
                        string idImpot = string.Format("{0}-{1}_{2}_{3}", idContact, reportOptionAttr.OptionAttribute.idOption, reportOptionAttr.idOptionAttribute, i);
                        lstColonnes.Add(idImpot); // ID_IMPOT => IdContact-IdOption_IdOptionAttribute_Ligne

                        string Designation = string.Empty;
                        string Amount = string.Empty;

                        if (i < lstRoptionAttr.Count)
                        {
                            var customData = lstRoptionAttr.GetRange(i, 1).FirstOrDefault();
                            Designation = customData.CustomObjectValue.Designation;
                            Amount = customData.CustomObjectValue.CurrentAmount;
                            
                            if (Amount != null)
                            {
                                Amount = Amount.Replace(",", ".");
                            }
                        }

                        lstColonnes.Add(ReplaceValue(Designation));
                        lstColonnes.Add(Amount);

                        // génére la ligne si la designation ou montant n'est pas vide
                        if (!string.IsNullOrEmpty(Designation) || !string.IsNullOrEmpty(Amount))
                        {
                            csvWriter.WriteLine(lstColonnes);
                        }
                    }
                }
            }

            csvWriter.Dispose();

            return fullPath;
        }
Exemplo n.º 35
0
        /// <summary>
        /// Performs LDAP Search and extracts attributes.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="CurrentTime">Locked program timestamp value</param>
        private void ExtractLDAPResults(LogHelper logger, DateTime CurrentTime)
        {
            List<string> AttributesToAdd = new List<string>();
            foreach (PropertyBase item in this.Properties)
                AttributesToAdd.Add(item.Mapping);

            string[] _attrs = AttributesToAdd.ToArray();

            String sFilter = SetQueryFilter(this.BatchAction, CurrentTime);

            SearchRequest searchRequest = new SearchRequest(this.SearchRoot, sFilter, SearchScope.Subtree, _attrs);

            PageResultRequestControl PageResponse = new PageResultRequestControl(this.PageSize);
            SearchOptionsControl SearchOptions = new SearchOptionsControl(System.DirectoryServices.Protocols.SearchOption.DomainScope);

            searchRequest.Controls.Add(PageResponse);
            searchRequest.Controls.Add(SearchOptions);

            logger.LogVerbose(string.Format("Establishing LDAP Connection to: {0}", this.ServerName));
            
            using(LdapConnection connection = CreateLDAPConnection())
            {
                logger.LogVerbose(string.Format("Performing a {0} operation with filter: {1}", this.BatchAction, sFilter));

                while (true)
                {
                    SearchResponse response = null;

                    try
                    {
                        response = connection.SendRequest(searchRequest) as SearchResponse;
                    }
                    catch(Exception ex)
                    {
                        throw new Exception("An error occurred whilst creating the SearchResponse", ex);
                    }

                    int ResponseCount = response.Entries.Count;
                    int CurrentBatchSize;

                    if (ResponseCount != this.PageSize)
                        CurrentBatchSize = ResponseCount;
                    else
                        CurrentBatchSize = this.PageSize;

                    string FilePath = CSVCreateFile(this.CSVDirectoryLocation, _TotalUsers, CurrentBatchSize);
                    

                    foreach (DirectoryControl control in response.Controls)
                    {
                        if (control is PageResultResponseControl)
                        {
                            PageResponse.Cookie = ((PageResultResponseControl)control).Cookie;
                            break;
                        }
                    }

                    // Create CSV file for current batch of users
                    using (CSVWriter BatchFile = new CSVWriter(FilePath))
                    {
                        // Create column headings for CSV file
                        CSVUserEntry heading = new CSVUserEntry();

                        // Iterate over attribute headings
                        foreach (PropertyBase item in this.Properties)
                            heading.Add(item.Name);

                        BatchFile.CSVWriteUser(heading, logger);

                        // Create new CSV row for each user
                        foreach (SearchResultEntry sre in response.Entries)
                        {
                            // Placeholder for CSV entry of current user
                            CSVUserEntry user = new CSVUserEntry();

                            // Exract each user attribute specified in XML file
                            foreach (PropertyBase item in this.Properties)
                            {
                                try
                                {
                                    DirectoryAttribute attr = sre.Attributes[item.Mapping];
                                    string value = string.Empty;
                                    if (null != attr && attr.Count > 0)
                                        value = attr[0].ToString();

                                    if (item.Index == this.UserNameIndex)
                                        user.Add(CreateUserAccountName(value, attr));
                                    else
                                        user.Add(value);
                                }
                                catch (Exception ex)
                                {
                                    if (logger != null)
                                    {
                                        logger.LogException(string.Empty, ex);
                                        _TotalFailures++;
                                    }
                                }
                            }

                            // Write current user to CSV file
                            BatchFile.CSVWriteUser(user, logger);

                            // Increment user count value
                            _TotalUsers++;
                        }
                    }

                    logger.LogVerbose(string.Format("Successfully extracted {0} users to {1} - the total user count is: {2}", CurrentBatchSize, FilePath, _TotalUsers));

                    if (PageResponse.Cookie.Length == 0)
                        break;
                }
            }           
        }
Exemplo n.º 36
0
        static string GenerateDirigeantCSV(string fileNameExport)
        {
            string fullPath = string.Concat(outputDirectory, fileNameExport);

            #region liste des attributs (ie colonnes)
            // rangement des colonnes
            List<object> lstIdOptionAttributeValue = new List<object>() { 
                  "idSociete"
                , "Civilité"
                , "Nom 399 400"
                , 404
                , "Mobile"
                , 746
                , "Email"
                , 748
                , 749
                , 750
            };
            #endregion

            CSVWriter csvWriter = new CSVWriter(fullPath, '\t');

            //Titre des colonnes
            List<string> lstColonnes = new List<string>()
            {
                "ID_SOCIETE",
                "Civilité",
                "Nom",
                "Fonction",
                "Téléphone",
                "Fax",
                "e-mail",
                "Adresse",
                "Code postal",
                "Ville",
            };

            csvWriter.WriteLine(lstColonnes);

            foreach (Report rep in lstPMReports)
            {
                if (rep.ReportOptionAttributeValue != null)
                {
                    List<ReportOptionAttributeValue> lstReportOptionAttributeValues = rep.ReportOptionAttributeValue.OrderByDescending(roav => roav.DateUpdated).ThenByDescending(roav => roav.DateCreated).ToList();
                    #region Dirigeant
                    List<string> lstColonnesDirigeant = new List<string>();

                    // génération des colonnes
                    foreach (object idOptionAttr in lstIdOptionAttributeValue)
                    {
                        int idOptionAttribute;
                        int.TryParse(idOptionAttr.ToString(), out idOptionAttribute);
                        string value = string.Empty;

                        // s'il s'agit d'un optionAttribute (input type text)
                        if (idOptionAttribute != 0)
                        {
                            // génération des colonnes dans OptionAttribute
                            value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == idOptionAttribute).FirstOrDefault().Value : "";
                        }
                        else
                        {
                            #region génération des autres colonnes
                            switch (idOptionAttr.ToString())
                            {
                                case "idSociete": value = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString(); break;
                                case "Civilité":
                                    {
                                        if (rep.ReportOptionValue != null)
                                        {
                                            List<int> lstIdOption = new List<int>() { 577, 578 };
                                            ReportOptionValue repOV = rep.ReportOptionValue.Where(r => lstIdOption.Contains(r.idOption)).FirstOrDefault();

                                            if (repOV != null && repOV.Option != null)
                                            {
                                                switch (repOV.Option.idOption)
                                                {
                                                    case 577: value = "Madame"; break;
                                                    case 578: value = "Monsieur"; break;
                                                }
                                            }
                                        }

                                        break;
                                    }
                                case "Nom 399 400": 
                                    {
                                        value = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 399).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 399).FirstOrDefault().Value : "";
                                        value = string.Format("{0} {1}", value, lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 400).FirstOrDefault() != null ? lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 400).FirstOrDefault().Value : "");
                                        value = (!string.IsNullOrEmpty(value.Trim().TrimEnd())) ? value : string.Format("{0} {1}", rep.CustomerProspect.User.UserName, rep.CustomerProspect.User.UserFirstName);
                                        break; 
                                    }

                                case "Mobile":
                                    {
                                        var mobile = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 401).FirstOrDefault();
                                        value = (mobile != null) ? mobile.Value : string.Empty;
                                        
                                        value = (!string.IsNullOrEmpty(value)) ? value : rep.CustomerProspect.User.UserMobilePhone;
                                        break;
                                    }

                                case "Email":
                                    {
                                        var email = lstReportOptionAttributeValues.Where(oa => oa.idOptionAttribute == 747).FirstOrDefault();
                                        value = (email != null) ? email.Value : string.Empty;
                                        value = (!string.IsNullOrEmpty(value)) ? value : rep.CustomerProspect.User.UserEmail;
                                        break;
                                    }

                            }
                            #endregion
                        }
                        // génère la colonne dans le fichier
                        lstColonnesDirigeant.Add(ReplaceValue(value));
                    }

                    // génére la ligne
                    csvWriter.WriteLine(lstColonnesDirigeant);

                    #endregion 
                
                    #region Personnes habilitées
                    string idCustomer = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString();

                    for(int pers = 407; pers <= 411; pers++)
                    {
                        List<string> lstColonnesPersHabilitees = new List<string>();

                        ReportOptionAttributeValue optionAttr = lstReportOptionAttributeValues.Where(o => o.idOptionAttribute == pers).FirstOrDefault();
                        if (optionAttr != null)
                        {
                            string Title = string.Empty;
                            string Name = string.Empty;
                            string FirstName = string.Empty;
                            string DateOfBirth = string.Empty;
                            string Function = string.Empty;
                            string Nationality = string.Empty;
                            string IsResident = string.Empty;
                            string Country = string.Empty;
                            string IsFATF = string.Empty;
                            string IsOffshore = string.Empty;
                            string IsOwner = string.Empty;
                            string Phone = string.Empty;
                            string Fax = string.Empty;
                            string Email = string.Empty;
                            string Address = string.Empty;
                            string ZipCode = string.Empty;
                            string City = string.Empty;

                            var customData = optionAttr;
                            if (customData != null)
                            {
                                Title = (!string.IsNullOrEmpty(customData.CustomObjectValue.Title)) ? (customData.CustomObjectValue.Title == "1" ? "Madame" : "Monsieur") : string.Empty;
                                Name = customData.CustomObjectValue.Name;
                                FirstName = customData.CustomObjectValue.FirstName;
                                DateOfBirth = customData.CustomObjectValue.DateOfBirth;
                                Function = customData.CustomObjectValue.Function;
                                Nationality = customData.CustomObjectValue.Nationality;
                                IsResident = customData.CustomObjectValue.IsResident;
                                Country = customData.CustomObjectValue.Country;
                                IsFATF = customData.CustomObjectValue.IsFATF;
                                IsOffshore = customData.CustomObjectValue.IsOffshore;
                                IsOwner = customData.CustomObjectValue.IsOwner;
                                Phone = customData.CustomObjectValue.Phone;
                                Fax = customData.CustomObjectValue.Fax;
                                Email = customData.CustomObjectValue.Email;
                                Address = customData.CustomObjectValue.Address;
                                ZipCode = customData.CustomObjectValue.ZipCode;
                                City = customData.CustomObjectValue.City;
                            }

                            lstColonnesPersHabilitees.Add(idCustomer); //id_societe
                            lstColonnesPersHabilitees.Add(Title);
                            lstColonnesPersHabilitees.Add(Name + " " + FirstName);
                            lstColonnesPersHabilitees.Add(ReplaceValue(Function));
                            lstColonnesPersHabilitees.Add(Phone);
                            lstColonnesPersHabilitees.Add(Fax);
                            lstColonnesPersHabilitees.Add(Email);
                            lstColonnesPersHabilitees.Add(ReplaceValue(Address));
                            lstColonnesPersHabilitees.Add(ZipCode);
                            lstColonnesPersHabilitees.Add(City);

                            // génére la ligne pr les personnes habiletée
                            csvWriter.WriteLine(lstColonnesPersHabilitees);
                        }
                    }
                    #endregion
                }
            }

            csvWriter.Dispose();

            return fullPath;
        }
Exemplo n.º 37
0
        static string GenerateCompositionDuFoyerCSV(string fileNameExportPPEnfants, int idOptionAttribute)
        {
            string fullPath = string.Concat(outputDirectory, fileNameExportPPEnfants);

            CSVWriter csvWriter = new CSVWriter(fullPath, '\t');

            //Titre des colonnes
            List<string> lstColonnes = new List<string>()
            {
                "ID_CONTACT",
                "ID_ENFANT",
                "Nom",
                "Prénom",
                "Date de naissance",                
            };

            if (idOptionAttribute == 192) //Enfant
            {
                lstColonnes.Add("A charge fiscalement");
            }
            else //Autres pers
            {
                lstColonnes.Add("Remarque");
            }

            csvWriter.WriteLine(lstColonnes);

            foreach (Report rep in lstPPReports)
            {
                if (rep.ReportOptionAttributeValue != null)
                {
                    List<ReportOptionAttributeValue> lstRoptionAttr = rep.ReportOptionAttributeValue.Where(o => o.idOptionAttribute == idOptionAttribute).ToList();
                    int attributCount = lstRoptionAttr.Count();

                    // génération des lignes
                    for (int i = 0; i < attributCount; i++)
                    {
                        ReportOptionAttributeValue reportOptionAttr = lstRoptionAttr[i];
                        lstColonnes = new List<string>();
                        string idContact  = !string.IsNullOrEmpty(rep.CustomerProspect.RefExt) ? rep.CustomerProspect.RefExt : rep.CustomerProspect.idCustomer.ToString(); // RefExterne ou IdCustomer
                        lstColonnes.Add(idContact); 
                        
                        string idEnfant = string.Format("{0}-{1}_{2}_{3}", idContact, reportOptionAttr.OptionAttribute.idOption, reportOptionAttr.idOptionAttribute, i);
                        lstColonnes.Add(idEnfant); // ID_ENFANT => IdContact-IdOption_IdOptionAttribute_Ligne

                        string Name = string.Empty;
                        string FirstName = string.Empty;
                        string DateOfBirth = string.Empty;
                        string IsTaxContributor = string.Empty;

                        var customData = reportOptionAttr;
                        Name = customData.CustomObjectValue.Name;
                        FirstName = customData.CustomObjectValue.FirstName;
                        //DateOfBirth = FormatDateToMMJJYYYY(customData.CustomObjectValue.DateOfBirth);
                        DateOfBirth = customData.CustomObjectValue.DateOfBirth;
                        IsTaxContributor = customData.CustomObjectValue.IsTaxContributor;
                        IsTaxContributor = (IsTaxContributor == "1") ? "Oui" : "Non";

                        lstColonnes.Add(Name);
                        lstColonnes.Add(FirstName);
                        lstColonnes.Add(DateOfBirth);

                        if (idOptionAttribute == 192) //Enfant
                        {
                            lstColonnes.Add(IsTaxContributor);
                        }
                        else
                        {
                            lstColonnes.Add(ReplaceValue("")); //Remarque ??
                        }

                        // génére la ligne si le nom / prenom n'est pas vide ?
                        if (!string.IsNullOrEmpty(Name) || !string.IsNullOrEmpty(FirstName))
                        {
                            csvWriter.WriteLine(lstColonnes);
                        }
                    }
                }
            }

            csvWriter.Dispose();

            return fullPath;
        }