コード例 #1
0
        /// <summary>
        /// 从数据库加载指定的映射脚本对象
        /// </summary>
        /// <param name="strMapID"></param>
        /// <returns></returns>
        public Model.MapScript GetSelectMapScript(string strMapID)
        {
            DataSet ds     = GetSelectMapScriptDS(strMapID);
            int     iCount = ds.Tables[0].Rows.Count;

            if (iCount <= 0)
            {
                return(null);
            }
            return(ObjectConvertor.ToObject <Model.MapScript>(ds.Tables[0].Rows[0]));
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SmsSpgate GetModel(string GateNumber)
        {
            DataSet ds     = GetSelectSpgate(GateNumber);
            int     iCount = ds.Tables[0].Rows.Count;

            if (iCount <= 0)
            {
                return(null);
            }
            //转换成实体
            return(ObjectConvertor.ToObject <Model.SmsSpgate>(ds.Tables[0].Rows[0]));
        }
コード例 #3
0
ファイル: SmsUser.cs プロジェクト: wyrover/myhistoryprojects
        public Model.SmsUser GetSelectSmsUser(string strUserID, string strPwd)
        {
            DataSet ds = dal.GetSelectSmsUser(strUserID, strPwd);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ObjectConvertor.ToObject <DataRow, SmsServer.Model.SmsUser>(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: ProductImportor.cs プロジェクト: phiree/NTSBase
        /*
         * 导入结构:
         * 总目录-|
         *        -供应商-|
         *                -图片文件夹
         *                -产品数据.xls
         *
         * 结果目录:
         *  总目录-
         *        --合格数据
         *        --不合格数据
         *               --供应商
         *                   --没有产品信息的图片
         *                   --没有图片的产品.xls
         */
        /// <summary>
        /// 将结果保存到磁盘:
        /// </summary>
        /// <param name="productHasImages"></param>
        public void HandlerCheckResult(string supplierName, IList <Product> productHasImages, IList <Product> productNotHasImages,
                                       IList <Product> productsExistedInDb,
                                       IList <FileInfo> imagesHasProduct, IList <FileInfo> imagesNotHasProduct,
                                       string outputFolder)
        {
            DirectoryInfo       dirRoot  = new DirectoryInfo(outputFolder);
            TransferInDatatable transfer = new TransferInDatatable();

            //如果没有合格数据 则不需要创建
            if (productHasImages.Count > 0)
            {
                DirectoryInfo dirQuanlified               = IOHelper.EnsureDirectory(outputFolder + "合格数据\\");
                DirectoryInfo dirSupplierQuanlified       = IOHelper.EnsureDirectory(dirQuanlified.FullName + supplierName + "\\");
                DirectoryInfo dirSupplierQuanlifiedImages = IOHelper.EnsureDirectory(dirSupplierQuanlified.FullName + supplierName + "\\");
                foreach (Product product in productHasImages)
                {
                    try
                    {
                        FileInfo imageFile = imagesHasProduct.Single(x => StringHelper.ReplaceSpace(Path.GetFileNameWithoutExtension(x.Name))
                                                                     .Equals(StringHelper.ReplaceSpace(product.ModelNumber), StringComparison.OrdinalIgnoreCase));
                        File.Copy(imageFile.FullName, dirSupplierQuanlified.FullName + supplierName + "\\" + imageFile.Name, true);
                        //同时拷贝到网站图片路径
                        if (!string.IsNullOrEmpty(WebProductImagesPath) && outputFolder != WebProductImagesPath)
                        {
                            string newImageName = (product.Name + product.SupplierName + product.ModelNumber).GetHashCode().ToString() + imageFile.Extension;

                            File.Copy(imageFile.FullName, WebProductImagesPath + newImageName, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("图片复制出错:" + dirSupplierQuanlified.FullName + "---" + product.ModelNumber + "---" + ex.Message);
                    }
                }


                DataTable dtProductsHasImage = ObjectConvertor.ToDataTable <Product>(productHasImages);
                transfer.CreateXslFromDataTable(dtProductsHasImage, 1, dirSupplierQuanlified.FullName + "\\" + supplierName + ".xls");
            }

            //没有图片的产品
            string dirPathNotQuanlified         = outputFolder + "不合格数据\\";
            string dirPathSupplierNotQuanlified = dirPathNotQuanlified + supplierName + "\\";

            if (productNotHasImages.Count > 0)
            {
                DirectoryInfo dirSupplierNotQuanlified = IOHelper.EnsureDirectory(dirPathSupplierNotQuanlified);
                DataTable     dtProductsNotHasImage    = ObjectConvertor.ToDataTable <Product>(productNotHasImages);
                transfer.CreateXslFromDataTable(dtProductsNotHasImage, 1, dirSupplierNotQuanlified + "没有图片的数据_" + supplierName + ".xls");
            }
            //没有产品的图片
            if (imagesNotHasProduct.Count > 0)
            {
                string        dirPathSupplierNotQuanlifiedImages = dirPathSupplierNotQuanlified + "多余图片_" + supplierName + "\\";
                DirectoryInfo dirSupplierNotQuanlifiedImages     = IOHelper.EnsureDirectory(dirPathSupplierNotQuanlifiedImages);
                foreach (FileInfo file in imagesNotHasProduct)
                {
                    file.CopyTo(dirSupplierNotQuanlifiedImages + file.Name, true);
                }
            }
            //多余的图片

            //重复数据
            if (productsExistedInDb.Count > 0)
            {
                string        dirPathSupplierRepeated = dirPathSupplierNotQuanlified + "数据库内已存在的数据_" + supplierName + "\\";
                DirectoryInfo dirSupplierRepeated     = IOHelper.EnsureDirectory(dirPathSupplierRepeated);

                DataTable dtProductsRepeated = ObjectConvertor.ToDataTable <Product>(productsExistedInDb);
                transfer.CreateXslFromDataTable(dtProductsRepeated, 1, dirSupplierRepeated.FullName + "\\" + supplierName + ".xls");
            }
        }