Beispiel #1
0
        /// <summary>
        /// 批量保存数据
        /// </summary>
        /// <param name="dt">数据</param>
        /// <param name="extraInfo">额外参数</param>
        /// <param name="userInfo">用户信息</param>
        public override object SaveImportData(DataTable dt, Dictionary <string, object> extraInfo, UserInfo userInfo)
        {
            string columnName = string.Empty;
            object objExtra   = null;
            Dictionary <string, string> dict = null;
            object objCellValue = null;

            List <string> listAssetsId = new List <string>();
            string        strAssetsId  = string.Empty;

            foreach (DataRow dr in dt.Rows)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    columnName = dc.ColumnName;
                    if (extraInfo.TryGetValue(columnName, out objExtra))
                    {
                        dict = objExtra as Dictionary <string, string>;
                        if (dict != null)
                        {
                            objCellValue = dr[columnName];
                            if (!ExcelImportHelper.ObjectIsNullOrEmpty(objCellValue))
                            {
                                dr[columnName] = dict[objCellValue.ToString()];
                            }
                        }
                    }
                }
            }

            try
            {
                //保存任务数据
                List <TaskUtil> list = dt.ToList <TaskUtil>();
                foreach (var item in list)
                {
                    TaskHelper.SaveTask(item);
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }