public List <FieldVersionDetail> GetFieldVersionDetails(string selectedPlatform, string selectedVersion, int index)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();
            string      selectedFileType = selectedPlatform;

            DataTable dtFileColumns = new DataTable();

            dtFileColumns.Columns.Add("ColumnName");
            dtFileColumns.Columns.Add("ColumnLength");

            VersionDeterminationMethods valueMethod = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);

            List <FileTypeVersion.Version> list = fc.Files.Find(p => p.Method == valueMethod && p.fileType == selectedFileType).Versions;

            FileTypeVersion.Version version = list[index];

            bool exist = version.Columns.Count != 0;
            List <FieldVersionDetail> retList = new List <FieldVersionDetail>();

            if (exist)
            {
                foreach (var v in list[index].Columns)
                {
                    FieldVersionDetail obj = new FieldVersionDetail();
                    obj.FieldName   = v.ColumnName;
                    obj.FieldLength = v.ColumnLength;

                    retList.Add(obj);
                }
            }
            return(retList);
        }
        /* Field versions */
        public List <FieldVersion> GetFieldVersions(string selectedPlatform)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();

            string selectedFileType  = selectedPlatform;
            List <FieldVersion> list = new List <FieldVersion>();

            if (fc.Files.Exists(p => p.fileType == selectedFileType))
            {
                var versionsList = fc.Files.Find(p => p.fileType == selectedFileType).Versions;
                var version      = versionsList.FindAll(p => p.VersionName != "");

                foreach (var v in versionsList)
                {
                    FieldVersion obj = new FieldVersion(); //
                    obj.Version  = v.VersionName;
                    obj.Format   = v.VersionFileNameFormat;
                    obj.DateFrom = v.VersionStartDate;
                    obj.DateTo   = v.VersionEndDate;

                    list.Add(obj);
                }
            }
            return(list);
        }
        public async Task <FileColumns> GetAllFileColumns()
        {
            try {
                FileColumns fileColumns = new FileColumns();

                return(fileColumns);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public List <string> GetInputList(string platform, string version)
        {
            FileColumns   fc    = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();
            var           input = fc.Files.Find(p => p.fileType == platform).Versions.Find(g => g.VersionName == version).Columns;
            List <string> list  = new List <string>();

            list.Add("None");
            foreach (var i in input)
            {
                list.Add(i.ColumnName);
            }
            return(list);
        }
        public void InsertFieldVersion(string selectedPlatform, string selectedVersion, string version, string format, string dateFrom, string dateTo)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();


            var fileType = selectedPlatform;
            var method   = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);
            List <FileTypeVersion.Version> versionList = new List <FileTypeVersion.Version>();
            bool exist             = fc.Files.Exists(p => p.fileType == fileType && p.Method == method);
            bool fileTypeHasMethod = fc.Files.Exists(p => p.fileType == fileType && p.Method != method);

            if (exist)
            {
                versionList = fc.Files.Find(p => p.fileType == fileType && p.Method == method).Versions;
            }
            else
            {
                versionList = new List <FileTypeVersion.Version>();
            }
            FileTypeVersion.Version v = new FileTypeVersion.Version();
            v.VersionName           = version;
            v.VersionStartDate      = dateFrom;
            v.VersionEndDate        = dateTo;
            v.VersionFileNameFormat = format;
            versionList.Add(v);
            if (!exist)
            {
                FileTypeVersion newFileTypeVersion = new FileTypeVersion();
                newFileTypeVersion.fileType = fileType;
                newFileTypeVersion.Method   = method;
                newFileTypeVersion.Versions = versionList;
                fc.Files.Add(newFileTypeVersion);
            }
            string logString = "FileType:" + fileType + "|" +
                               "VersionMethod:" + method + "|" +
                               "VersionName:" + v.VersionName + "|" +
                               "VersionStartDate:" + v.VersionStartDate + "|" +
                               "VersionEndDate:" + v.VersionEndDate + "|" +
                               "VersionFileNameFormat:" + v.VersionFileNameFormat + "|";

            //   WriteLog("INSERT", "MED Configuration", "FileColumns.Version", System.Security.Principal.WindowsIdentity.GetCurrent().Name, logString, "");
            FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.SaveConfiguration(fc.GetType(), fc);
        }
        public void DeleteFieldVersionDetail(string selectedPlatform, string selectedVersion, int index, int detailIndex)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();
            string      selectedFileType            = selectedPlatform;
            VersionDeterminationMethods valueMethod = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);
            var version = fc.Files.Find(p => p.Method == valueMethod && p.fileType == selectedFileType).Versions[index];
            var columns = version.Columns;

            string logString = "FileType:" + selectedPlatform + "|" +
                               "VersionMethod:" + selectedVersion + "|" +
                               "VersionName:" + version.VersionName + "|" +
                               "ColumnName:" + columns[index].ColumnName + "|" +
                               "ColumnLength:" + columns[index].ColumnLength;

            WriteLog("DELETE", "MED Configuration", "FileControl.Column", System.Security.Principal.WindowsIdentity.GetCurrent().Name, logString, "");

            columns.RemoveAt(detailIndex);

            FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.SaveConfiguration(fc.GetType(), fc);
        }
        public bool CheckDateOverlap(string selectedPlatform, string selectedVersion, DateTime dateFrom, DateTime dateTo)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();

            var fileType = selectedPlatform;
            var method   = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);
            List <FileTypeVersion.Version> versionList = new List <FileTypeVersion.Version>();
            bool exist = fc.Files.Exists(p => p.fileType == fileType && p.Method == method);

            if (exist)
            {
                versionList = fc.Files.Find(p => p.fileType == fileType && p.Method == method).Versions;

                if (!IsDateValid(dateFrom, dateTo, versionList))
                {
                    return(false); //Došlo je do preklapanja intervala!
                }
            }
            return(true);
        }
        // da li postoji druga verzija definisana pored selektovane za unos
        public int CheckIfVersionExist(string selectedPlatform, string selectedVersion)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();

            var fileType = selectedPlatform;
            var method   = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);
            List <FileTypeVersion.Version> versionList = new List <FileTypeVersion.Version>();

            bool exist             = fc.Files.Exists(p => p.fileType == fileType && p.Method == method);
            bool fileTypeHasMethod = fc.Files.Exists(p => p.fileType == fileType && p.Method != method);

            if (fileTypeHasMethod == true)
            {
                return(1); //file has different method defined
            }
            if (exist == true)
            {
                return(2); //file has the same method defined
            }
            return(0);     //method is not defined
        }
        public void DeleteFieldVersion(int index, string selectedPlatform, string selectedVersion)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();
            string      selectedFileType            = selectedPlatform;
            VersionDeterminationMethods valueMethod = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);

            var versions = fc.Files.Find(p => p.Method == valueMethod && p.fileType == selectedFileType).Versions;
            var file     = fc.Files.Find(p => p.Method == valueMethod && p.fileType == selectedFileType && p.Versions == versions);

            string logString = "FileType:" + selectedPlatform + "|" +
                               "VersionMethod:" + selectedVersion + "|" +
                               "VersionName:" + versions[index].VersionName + "|" +
                               "VersionFileNameFormat:" + versions[index].VersionFileNameFormat + "|" +
                               "VersionStartDate:" + versions[index].VersionStartDate + "|" +
                               "VersionEndDate:" + versions[index].VersionEndDate;

            WriteLog("DELETE", "MED Configuration", "FileControl.Version", System.Security.Principal.WindowsIdentity.GetCurrent().Name, logString, "");

            fc.Files.Remove(file);

            FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.SaveConfiguration(fc.GetType(), fc);
        }
        public void InsertFieldVersionDetail(string selectedPlatform, string selectedVersion, int index, string name, string length)
        {
            FileColumns fc = FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.GetNotCashedConfiguration <FileColumns>();

            string selectedFileType = selectedPlatform;
            VersionDeterminationMethods valueMethod = (VersionDeterminationMethods)Enum.Parse(typeof(VersionDeterminationMethods), selectedVersion);

            FileTypeVersion.Version ver = fc.Files.Find(p => p.Method == valueMethod && p.fileType == selectedFileType).Versions[index];

            Column col = new Column();

            col.ColumnName   = name;
            col.ColumnLength = length;

            ver.Columns.Add(col);
            FORIS.Interbilling.NTS.Mediation.Configurations.Configuration.SaveConfiguration(fc.GetType(), fc);

            string logString = "VersionName:" + ver.VersionName + "|" +
                               "ColumnName:" + col.ColumnName + "|" +
                               "ColumLenght:" + col.ColumnLength;

            WriteLog("INSERT", "MED Configuration", "FileColumns.Columns", System.Security.Principal.WindowsIdentity.GetCurrent().Name, logString, "");
        }
예제 #11
0
        public DataTable StandardiseFile(string csvStringData)
        {
            DataTable dtCsv     = new DataTable();
            Regex     CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");


            //split full file text into rows
            string[] rows = csvStringData.Split('\n');
            for (int i = 0; i < rows.Count() - 1; i++)
            {
                //split each row with comma to get individual values
                string[] rowValues = CSVParser.Split(rows[i].Trim());
                {
                    if (i == 0) // Header
                    {
                        for (int j = 0; j < rowValues.Count(); j++)
                        {
                            string columnName = rowValues[j].Trim();
                            switch (columnName)
                            {
                            case "Province/State":
                            {
                                columnName = FileColumns.Province_State;
                                break;
                            }

                            case "Country/Region":
                            {
                                columnName = FileColumns.Country_Region;
                                break;
                            }

                            case "Last Update":
                            {
                                columnName = FileColumns.Last_Update;
                                break;
                            }

                            case "Confirmed":
                            {
                                columnName = FileColumns.Confirmed;
                                break;
                            }

                            case "Deaths":
                            {
                                columnName = FileColumns.Deaths;
                                break;
                            }

                            case "Recovered":
                            {
                                columnName = FileColumns.Recovered;
                                break;
                            }

                            case "Lat":
                            {
                                columnName = FileColumns.Latitude;
                                break;
                            }

                            case "Long_":
                            {
                                columnName = FileColumns.Longitude;
                                break;
                            }
                            }

                            dtCsv.Columns.Add(columnName); //add headers
                        }
                    }
                    else
                    {
                        DataRow dr = dtCsv.NewRow();
                        for (int k = 0; k < rowValues.Count(); k++)
                        {
                            var value = rowValues[k].ToString()
                                        .TrimAndNullIfEmpty();
                            dr[k] = value;
                        }
                        dtCsv.Rows.Add(dr); //add other rows
                    }
                }
            }


            // column adjust
            if (dtCsv.Columns.Contains("Latitude") == false)
            {
                dtCsv.Columns.Add("Latitude");
            }
            if (dtCsv.Columns.Contains("Longitude") == false)
            {
                dtCsv.Columns.Add("Longitude");
            }
            var finalColumnList = FileColumns.GetColumnNamesAsArray();
            var extraColumns    = dtCsv.Columns.Cast <DataColumn>()
                                  .Where(x => finalColumnList.Contains(x.ColumnName) == false)
                                  .Select(column => column.ColumnName)
                                  .ToList();

            // remove un-needed columns
            extraColumns.ForEach(dtCsv.Columns.Remove);

            return(dtCsv);
        }