/* Copyright (c) 2015 Xiamen Weixin Software Co., Ltd. All rights reserved
 *
 * Create by huanglc@holworth.com at 2015-04-23 21:52:45
 *
 */

using System;
using System.Text;
using System.Collections.Generic;
using Contract.IService;
using Framework;
using System.Collections;
using Contract.Domain;
using BaseService;
using System.Linq;
namespace ETLBLL
{
    public class EtlCheckMethodService : BaseService.EntityService<Contract.Domain.EtlCheckMethod>, IEtlCheckMethodService
    {
        /// <summary>
        /// 检验是否>=0
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public object[] GEZero(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            object[] returnObject = new object[3];
            if (string.IsNullOrEmpty(obj))
            {
                returnObject[0] = false;
                returnObject[1] = "不能空";
                returnObject[2] = 0;
            }
            else
            {
                decimal a = 0;
                if (decimal.TryParse(obj, out a))
                {
                    if (a >= 0)
                    {
                        returnObject[0] = true;
                        returnObject[1] = "";
                        returnObject[2] = a;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = "小于0";

}

}
                else
                {
                    returnObject[0] = false;
                    returnObject[1] = "不是数值";
                }

}
            return returnObject;
        }
        /// <summary>
        /// 检验日期
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public object[] CheckDateTime(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            object[] returnObject = new object[3];
            if (string.IsNullOrEmpty(obj))
            {
                returnObject[0] = true;
                returnObject[2] = null;
            }
            else
            {
                DateTime a = DateTime.Now;
                if (DateTime.TryParse(obj, out a))
                {
                    returnObject[0] = true;
                    returnObject[2] = a;
                }
                else
                {
                    returnObject[0] = false;
                    returnObject[1] = "不是为日期类型";
                    
                }
            }
            return returnObject;

}
        /// <summary>
        /// 检验数值
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public object[] CheckNumber(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
              object[] returnObject = new object[3];
              if (string.IsNullOrEmpty(obj))
              {
                  returnObject[0] = true;
                  returnObject[1] = "";
                  returnObject[2] = 0;
              }
              else
              {
                  decimal a = 0;
                  if (decimal.TryParse(obj, out a))
                  {
                      returnObject[0] = true;
                      returnObject[2] = a;
                  }
                  else
                  {
                      returnObject[0] = false;
                      returnObject[1] = "不是为数值类型";
                  }
              }
              return returnObject;

}
        public object[] CheckNull(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            object[] returnObject = new object[3];
            returnObject[0] = !string.IsNullOrEmpty(obj);
            returnObject[2] = obj;
            if (string.IsNullOrEmpty(obj))
            {
                returnObject[1] = "不能空";
            }
            return returnObject;
        }
        /// <summary>
        /// 验证范围
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public object[] CheckRange(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            object[] returnObject = new object[3];
            returnObject[2] = obj;
            if (string.IsNullOrEmpty(obj))
            {
                returnObject[1] = "不能空";
                returnObject[0] = false;
            }
            else
            {
                if (obj.CompareTo(column.ExtendParameter) >= 0 && obj.CompareTo(column.ExtendParameter2) <= 0)
                {
                    returnObject[0] = true;
                   
                }
                else
                {
                    returnObject[0] = false;
                    returnObject[1] = string.Format("值不在{0}和{1}之间", column.ExtendParameter, column.ExtendParameter2);
                }
            }
            return returnObject;
        }

public string getColumnPosition(EtlColumn c1)
        {
            string col1 = string.Empty;
            if (c1.MapIndex <= 90)
            {
                col1 = ((char)(c1.MapIndex.Value + 65)).ToString();

}
            else
            {
                col1 = "A" + ((char)(c1.MapIndex.Value + 65 - 26)).ToString();
            }

return col1;
        }
        /// <summary>
        /// 通用验证数值范围的方法
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="etlDataMap"></param>
        /// <returns></returns>
        public object[] CheckGennericNumber(string obj, System.Data.DataTable table, System.Data.DataRow row,
            EtlCheckMethod column, EtlDataMap etlDataMap)
        {

//a>b
            object[] returnObject = new object[] { };
            string para1 = column.ExtendParameter;
            string para2 = column.ExtendParameter2;
            string para3 = column.ExtendParameter3;
            string[] ops = new[] { ">", "<", "=", "!=", ">=", "<=" };
            if (ops.Contains(para2))
            {

if (para2 == ">")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!double.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!double.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) > 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}小于等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }

}
                else if (para2 == "<")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) < 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}大于等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == "=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!double.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!double.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) == 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}不等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }

}
                else if (para2 == "!=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!double.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) > 0 || a.CompareTo(b) < 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == ">=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!double.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!double.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) >= 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}小于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == "<=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    double a = 0;
                    if (!double.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    double b = 0;
                    if (!double.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为数值类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) <= 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}大于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }

}

return null;
        }

/// <summary>
        /// 验证日期在某两个范围日期之间
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="etlDataMap"></param>
        /// <returns></returns>
        public object[] CheckGennericDateRange(string obj, System.Data.DataTable table, System.Data.DataRow row,
            EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            object[] returnObject = new object[]{};
            string para1 = column.ExtendParameter;
            string para2 = column.ExtendParameter2;

DateTime a = DateTime.Now;

if (!DateTime.TryParse(obj, out a))
            {
                returnObject[0] = false;
                returnObject[1] = "不是日期类型";
                return returnObject;
            }

DateTime v1 = DateTime.Now;
            ; if (!DateTime.TryParse(column.ExtendParameter, out v1))
            {
                returnObject[0] = false;
                returnObject[1] = "第一个扩展参数不是日期类型";
                return returnObject;
            }
            DateTime v2 = DateTime.Now;
            ; if (!DateTime.TryParse(column.ExtendParameter2, out v2))
            {
                returnObject[0] = false;
                returnObject[1] = "二个扩展参数不是日期类型";
                return returnObject;
            }
            if (a.CompareTo(v1) >= 0 && a.CompareTo(v2) <= 0)
            {
                returnObject[0] = true;
                returnObject[2] = a;
                return returnObject;
            }
            else
            {
                returnObject[0] = false;
                returnObject[1] = string.Format("当前日期的范围不在{0}和{1}之间",v1,v2);
                return returnObject;
            }
            return null;
        }

/// <summary>
        /// 通用验证日期范围法
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="etlDataMap"></param>
        /// <returns></returns>
        public object[] CheckGennericDate(string obj, System.Data.DataTable table, System.Data.DataRow row,
            EtlCheckMethod column, EtlDataMap etlDataMap)
        {
            //a>b
            object[] returnObject=new object[]{};
            string para1 = column.ExtendParameter;
            string para2 = column.ExtendParameter2;
            string para3 = column.ExtendParameter3;
            string[] ops = new[] {">", "<", "=", "!=", ">=", "<="};
            if (ops.Contains(para2))
            {
         
                if (para2 == ">")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) > 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}小于等于{2}",colPostion,c1.MapColumn,column.ExtendParameter3);
                        return returnObject;
                    }

}else if (para2 == "<")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) < 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}大于等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == "=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) ==0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}不等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }

}
                else if (para2 == "!=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) > 0||a.CompareTo(b)<0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}等于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == ">=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) >= 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}小于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }
                else if (para2 == "<=")
                {
                    if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
                    {
                        throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter));
                    }
                    var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
                    string colPostion = getColumnPosition(c1);
                    DateTime a = DateTime.Now;
                    if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
                    {
                        returnObject[1] = "不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    DateTime b = DateTime.Now;
                    if (!DateTime.TryParse(column.ExtendParameter3, out b))
                    {
                        returnObject[1] = "column.ExtendParameter3不是为日期类型";
                        returnObject[0] = false;
                        return returnObject;
                    }
                    if (a.CompareTo(b) <= 0)
                    {
                        returnObject[0] = true;
                        returnObject[2] = DateTime.Parse(obj);
                        return returnObject;
                    }
                    else
                    {
                        returnObject[0] = false;
                        returnObject[1] = string.Format("{0}列名为{1}大于{2}", colPostion, c1.MapColumn, column.ExtendParameter3);
                        return returnObject;
                    }
                }

}

return null;
        }

/// <summary>
        /// 验证某个列日期不能大于某列
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="etlDataMap"></param>
        /// <returns></returns>
        public object[] CheckRangeDateTimeColumn(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column,EtlDataMap etlDataMap)
        {
             object[] returnObject = new object[3];
            string errorColumn = string.Empty;
            if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).Count() <= 0)
            {
                throw new Exception(string.Format("不存在映射列{0}",column.ExtendParameter));
            }
            if (etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter2)).Count() <= 0)
            {
                throw new Exception(string.Format("不存在映射列{0}", column.ExtendParameter2));
            }
            var c1 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter)).First();
            var c2 = etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter2)).First();
            DateTime a = DateTime.Now;
            if (!DateTime.TryParse(row[c1.MapIndex.Value].ToString(), out a))
            {
                returnObject[1] = "不是为日期类型";
                returnObject[0] = false;
                return returnObject;
            }
            DateTime v1 = a;
            if (!DateTime.TryParse(row[c2.MapIndex.Value].ToString(), out a))
            {
                returnObject[1] = "不是为日期类型";
                returnObject[0] = false;
                return returnObject;
            }
            DateTime v2 = a;

if (v1.CompareTo(v2) <= 0)
            {
                returnObject[0] = true;
                returnObject[2] = DateTime.Parse(obj);
            }
            else
            {
                returnObject[0] = false;
                string col1 = string.Empty;
                string col2 = string.Empty;

if (c1.MapIndex <= 90)
                {
                   col1 = ((char)(c1.MapIndex.Value + 65)).ToString();

}
                else
                {
                    col1 = "A" + ((char)(c1.MapIndex.Value + 65 - 26)).ToString();
                }

if (c2.MapIndex <= 90)
                {
                    col2 = ((char)(c2.MapIndex.Value + 65)).ToString();

}
                else
                {
                    col2 = "A" + ((char)(c2.MapIndex.Value + 65 - 26)).ToString();
                }
                returnObject[1] = string.Format("{0}大于{1}",col1,col2);
            }
            return returnObject;
        }
        /// <summary>
        /// 判断列不能同时存在
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="table"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="etlDataMap"></param>
        /// <returns></returns>
        public object[] CheckColumnSimpleExist(string obj, System.Data.DataTable table, System.Data.DataRow row, EtlCheckMethod column, EtlDataMap etlDataMap)
        {
           object[] returnObject = new object[3];
           int i= etlDataMap.ColumnList.Where(m => m.MapColumn.Equals(column.ExtendParameter) || m.MapColumn.Equals(column.ExtendParameter2)).Count();
           if (i == 0)
           {
               returnObject[0] = false;
               returnObject[1] = string.Format("{0}、{1}必须存在一列", column.ExtendParameter, column.ExtendParameter2);
           }
           else if (i > 1)
           {
               returnObject[0] = false;
               returnObject[1] = string.Format("{0}、{1}不能同时存在", column.ExtendParameter, column.ExtendParameter2);
           }
           else
           {
               returnObject[0] = true;
               returnObject[2] = obj;
           }
            
            return returnObject;
        }

}
}

etl业务验证方法1的更多相关文章

  1. 自定义shiro实现权限验证方法isAccessAllowed

    由于Shiro filterChainDefinitions中 roles默认是and, admin= user,roles[system,general] 比如:roles[system,gener ...

  2. ApachShiro 一个系统 两套验证方法-(后台管理员登录、前台App用户登录)同一接口实现、源码分析

    需求: 在公司新的系统里面博主我使用的是ApachShiro 作为安全框架.作为后端的鉴权以及登录.分配权限等操作 管理员的信息都是存储在管理员表 前台App 用户也需要校验用户名和密码进行登录.但是 ...

  3. 基于 Token 的身份验证方法

    使用基于 Token 的身份验证方法,在服务端不需要存储用户的登录记录.大概的流程是这样的: 客户端使用用户名跟密码请求登录 服务端收到请求,去验证用户名与密码 验证成功后,服务端会签发一个 Toke ...

  4. validate插件深入学习-04自定义验证方法

    自定义验证方法 jQuery.validator.addMethod(name,method,[,message]) name: 方法名 method: function(value,element, ...

  5. 基于 Annotation 拦截的 Spring AOP 权限验证方法

    基于 Annotation 拦截的 Spring AOP 权限验证方法 转自:http://www.ibm.com/developerworks/cn/java/j-lo-springaopfilte ...

  6. MVC5+EF6 简易版CMS(非接口) 第四章:使用业务层方法,以及关联表解决方案

    目录 简易版CMS后台管理系统开发流程 MVC5+EF6 简易版CMS(非接口) 第一章:新建项目 MVC5+EF6 简易版CMS(非接口) 第二章:建数据模型 MVC5+EF6 简易版CMS(非接口 ...

  7. 封装jQuery Validate扩展验证方法

    一.封装自定义验证方法-validate-methods.js /***************************************************************** j ...

  8. 一种M2M业务的架构及实现M2M业务的方法

    http://www.cnblogs.com/coryxie/p/3849764.html 技术领域 [0001] 本发明涉及通信技术领域,尤其涉及一种M2M业务的架构及实现M2M业务的方法. 背景技 ...

  9. jquery validate 自定义验证方法

    query validate有很多验证规则,但是更多的时候,需要根据特定的情况进行自定义验证规则. 这里就来聊一聊jquery validate的自定义验证. jquery validate有一个方法 ...

随机推荐

  1. [BZOJ5330][SDOI2018]反回文串

    luogu bzoj sol 枚举一个长度为\(n\)为回文串,它的所有循环位移都可以产生贡献. 但是这样算重了.重复的地方在于可能多个回文串循环同构,或者可能有的回文串经过小于\(n\)次循环位移后 ...

  2. sourcetree回退到历史节点

    1. 原理 原理,我们都知道Git是基于Git树进行管理的,要想要回滚必须做到如下2点: 本地头节点与远端头节点一样(Git提交代码的前提条件):于本地头节点获取某次历史节点的更改.说的有点抽象,以图 ...

  3. Loararunner录制脚本

    LoadRunner录制 1.启动LoadRunner,用管理员方式打开,选择 “Create/Edit Scripts” 2.从这两个方式任意方式打开脚本页面 3.选择协议,这里我们举例子,用“We ...

  4. 纯php实现中秋博饼游戏(2):掷骰子并输出结果

    这篇是纯php实现中秋博饼游戏系列博文(2) 上文是:纯php实现中秋博饼游戏(1):绘制骰子图案 http://www.cnblogs.com/zqifa/p/php-dice-1.html要纯ph ...

  5. QT4.8.5环境移植到嵌入式平台

    QT4.8.5环境移植到嵌入式平台 参考:Qt移植到ARM Linux教程 http://www.veryarm.com/930.html 清除配置: sudo make confclean 配置: ...

  6. 【android】SDK在线升级

    1.修改本地hosts文件 hosts文件位置:C:\Windows\System32\drivers\etc\hosts 在底部添加:203.208.46.146 dl-ssl.google.com ...

  7. Java 字符串 String

    什么是Java中的字符串 在 Java 中,字符串被作为 String 类型的对象处理. String 类位于 java.lang 包中.默认情况下,该包被自动导入所有的程序. 创建 String 对 ...

  8. ScheduledExecutorService 定时器用法

    1,如果只是想简单的写个定时任务,比如10分钟跑一次,那么ScheduledExecutorService是比较方便的,下面举个简单的例子 import java.util.concurrent.Ex ...

  9. django2.0实现数据详情页展示的流程

    思路整理 1 先在urls.py中,定义路由获取的格式 url(r'^detail/(\d+)/$', views.blog_detail), 2 然后在views.py,定义数据获取的方法 def ...

  10. SpringBoot Session 管理及集群管理

    1.配置session的超时时间 : 在application.prooperties中 server.session.timeout = 600       //以秒为单位,默认最少一分钟 2.配置 ...