Пример #1
0
        /// <summary>
        /// 根据席位编码,本地文件名称获取相应的配置信息
        /// </summary>
        /// <param name="seatNo"></param>
        /// <param name="sourceFileName"></param>
        /// <returns></returns>
        public static DispatchFile GetDispatchFile(string seatNo, string sourceFileName)
        {
            DispatchFile dispatchFile = null;
            string       name         = Path.GetFileNameWithoutExtension(sourceFileName);

            //Path.GetExtension
            //StringComparison
            var query = from a in _dispatchFileDictionary.Values
                        where a.SeatNo == seatNo && name.IndexOf(a.MatchRule) > 0
                        select a;

            foreach (var item in query)
            {
                DispatchFile tmpDispatchFile = item as DispatchFile;
                if (tmpDispatchFile != null && tmpDispatchFile.MatchType == 4)//matchtype==4为去除数字后全字匹配
                {
                    name = System.Text.RegularExpressions.Regex.Replace(name, @"\d", "");
                    if (name != tmpDispatchFile.MatchRule)
                    {
                        tmpDispatchFile = null;
                    }
                }
                if (tmpDispatchFile != null)
                {
                    dispatchFile = tmpDispatchFile;
                }
            }

            return(dispatchFile);
        }
Пример #2
0
        public void SaveToTXT(DispatchFile dispatchFile, string txtName = "", bool addColumn = false)
        {
            string separator = "@";

            this._txtName = txtName;
            if (string.IsNullOrWhiteSpace(this._txtName))
            {
                //_txtName = string.Format(@"{0}\output\{1}.txt", _fileInfo.DirectoryName, _fileInfo.Name.Substring(0, _fileInfo.Name.IndexOf('.')));
                _txtName = string.Format(@"{0}\output\{1}.txt", _fileInfo.DirectoryName, dispatchFile.FileType);
            }

            SaveDataTableToTXT(dispatchFile, _dataTable, this._txtName, addColumn);
        }
Пример #3
0
        //根据文件名、文件标题、列名等获取数据分发类型
        public static string GetDispatchFileType(string fileName, string fileCaption, string colNames)
        {
            foreach (var dispFile in _dispatchFileDictionary)
            {
                DispatchFile dispatchFile = dispFile.Value;
                if (dispatchFile.MatchRule.Trim() != "")
                {
                    if ((dispatchFile.MatchType == 0 && fileName.Contains(dispatchFile.MatchRule)) ||                 //文件名包含匹配
                        (dispatchFile.MatchType == 1 && string.Compare(dispatchFile.MatchRule, fileCaption, true) == 0) ||  //文件标题匹配
                        (dispatchFile.MatchType == 2 && string.Compare(dispatchFile.MatchRule, colNames, true) == 0)) //文件列名匹配
                    {
                        return(dispFile.Key);
                    }
                }
            }

            return("");
        }