Example #1
0
        //生成单个模板的算法所需参数
        public static string GenerateModelHalconParas(int channelNo, int stationNo, int modelNo)
        {
            string ret = string.Empty;

            try
            {
                ProductChannel channel = ProductChannelArray[channelNo];

                if (!string.IsNullOrEmpty(channel.ProductData.ProductName))
                {
                    Station station = channel.ProductData.StationList[stationNo];
                    Model   model   = station.ModeList[modelNo];

                    if (0 != model.GenerateHalconParas(SoftwareInfo.getInstance().AlgorithmNormalParasNum, SoftwareInfo.getInstance().AlgorithmSeniorParasNum, station))
                    {
                        ret += "通道" + channel.ChannelName + "产品" + channel.ProductData.ProductName + "工位" + station.StationNo + "模版" + model.ModelNo
                               + "生成参数错误\r\n";
                    }
                }
            }
            catch (Exception ex)
            {
                string str = "GenerateModelHalconParas  生成模板参数出错:\n" + ex.ToString();
                SoftwareInfo.getInstance().WriteLog("GenerateModelHalconParas:\n" + str);
                ret += "GenerateModelHalconParas  生成模板参数出错";
            }
            return(ret);
        }
        /// <summary>
        /// Creates a new ProductChannel.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <returns>The product channel criterion.</returns>
        public static ProductChannel CreateChannel(ShoppingProductChannel channel)
        {
            ProductChannel retval = CreateChannel();

            retval.channel = channel;
            return(retval);
        }
Example #3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="channel"></param>
        public MeiTuanProductChannel(ShopType shop, ProductChannel channel)
        {
            Channel           = channel;
            Shop              = shop;
            meituanRepository = new MeiTuanRepository();
            hotelRepository   = new HotelRepository(channel);
            MeiTuanConfig config = new MeiTuanConfig();

            if (Shop == ShopType.LingZhong || Shop == ShopType.YinJi || Shop == ShopType.RenXing)
            {
                config = MeiTuanConfigManager.XiWan;
            }
            else if (Shop == ShopType.ShengLv)
            {
                config = MeiTuanConfigManager.ShengLv;
            }
            else if (Shop == ShopType.RenNiXing)
            {
                config = MeiTuanConfigManager.RenNiXing;
            }

            meiTuanApiClient = new MeiTuanApiClient(config);

            logWriter = new LogWriter("Tmall/Validate");
        }
Example #4
0
        /// <summary>
        /// 保存订单
        /// </summary>
        /// <param name="order"></param>
        /// <returns></returns>
        public ServiceResult SaveOrder(ProductChannel channel, TmallOrderDto order)
        {
            var result = new ServiceResult();

            try
            {
                var tbOrder = new tb_hotelorder();
                Mapper.Map(order, tbOrder);
                tbOrder.orderType = 2;
                var excuteRows = SqlSugarContext.BigTreeInstance.Insertable(tbOrder).ExecuteCommand();
                if (excuteRows == 0)
                {
                    excuteRows = SqlSugarContext.BigTreeInstance.Insertable(tbOrder).ExecuteCommand();
                }

                if (excuteRows > 0)
                {
                    return(result.SetSucess("保存订单成功"));
                }
                else
                {
                    return(result.SetSucess("保存订单失败"));
                }
            }
            catch (Exception ex)
            {
                return(result.SetError("保存订单失败:{0}", ex.Message));
            }
        }
Example #5
0
        /// <summary>
        /// 创建渠道
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="shop"></param>
        /// <returns></returns>
        public static IProductChannel CreateChannel(ProductChannel channel, ShopType shop)
        {
            switch (channel)
            {
            case ProductChannel.MT: return(new MeiTuanProductChannel(shop, channel));

            //case ProductChannel.BigTree: return new BigTreeProductChannel(shop);
            case ProductChannel.Ctrip: return(new CtripProductChannel(shop));

            case ProductChannel.DDS: return(new DaDuShiProductChannel(shop, channel));

            default: throw new ArgumentNullException("channel");
            }
        }
Example #6
0
        //private readonly MeiTuanRepository meituanRepository;
        //private readonly HotelRepository hotelRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="shop"></param>
        /// <param name="channel"></param>
        public DaDuShiProductChannel(ShopType shop, ProductChannel channel)
        {
            Channel = channel;
            Shop    = shop;
            DaDuShiConfig config = new DaDuShiConfig();

            if (Shop == ShopType.RenNiXing)
            {
                config = DaDuShiConfigManager.RenNiXing;
            }

            daDuShiApiClient = new DaDuShiApiClient(config);

            logWriter = new LogWriter("Tmall/Validate");
        }
Example #7
0
 public static IOrderRepository CreateOrderRepository(ShopType shop, ProductChannel channel)
 {
     if (shop == ShopType.ShengLv || shop == ShopType.RenNiXing)
     {
         return(new ShengLvOrderRepository());
     }
     else
     {
         //if (channel == ProductChannel.BigTree)
         //{
         //    return new BigTreeOrderRepository();
         //}
         //else
         //{
         return(new ThirdOrderRepository());
         //}
     }
 }
Example #8
0
        public static bool Save(int channelNo)
        {
            bool ret = true;

            ProductChannel channel = ProductChannelArray[channelNo];

            if (channel.IsEnable)
            {
                //检验model是否真的已经生成
                foreach (var v in channel.ProductData.StationList)
                {
                    foreach (var model in v.ModeList)
                    {
                        if (model.generateModeParas.IsGenerateModel)
                        {
                            model.IsEnable = true;
                        }
                        else
                        {
                            model.IsEnable = false;
                        }
                    }
                }

                string fileName = InfoPath.getInstance().ProductPath + "\\" + channel.ChannelName + "\\" + channel.ProductData.ProductName + "\\product.xml";

                using (Stream fStream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    if (File.Exists(fileName))
                    {
                        System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Product));
                        xmlSerializer.Serialize(fStream, channel.ProductData);
                    }
                    else
                    {
                        Console.WriteLine("暂无此文件:" + fileName);
                        //MessageBox.Show("暂无此文件:" + fileName);
                    }
                }
            }

            return(ret);
        }
Example #9
0
 /// <summary>
 /// Determines whether the specified <see cref="ProductChannel"/> objects
 /// are equal.
 /// </summary>
 /// <param name="x">The first object to compare.</param>
 /// <param name="y">The second object to compare.</param>
 /// <returns>
 /// True if the specified objects are equal; otherwise, false.
 /// </returns>
 private bool Equals(ProductChannel x, ProductChannel y)
 {
     return(x.channelSpecified == y.channelSpecified && x.channel == y.channel);
 }
Example #10
0
 /// <summary>
 /// Gets the hash code for a <see cref="ProductChannel"/>.
 /// </summary>
 /// <param name="obj">The object to calculate hash code for.</param>
 /// <returns>The hash code.</returns>
 private int GetHashCodeInternal(ProductChannel obj)
 {
     return(Tuple.Create <bool, ShoppingProductChannel>(obj.channelSpecified, obj.channel)
            .GetHashCode());
 }
Example #11
0
 public HotelRepository(ProductChannel channel)
 {
     Channel = channel;
 }
Example #12
0
        /// <summary>
        /// 保存订单
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public ServiceResult SaveOrder(ProductChannel channel, TmallOrderDto order)
        {
            var result = new ServiceResult();

            try
            {
                var tbOrder = new TB_hotelcashorder();
                Mapper.Map(order, tbOrder);
                tbOrder.orderCheckoutDate = new DateTime(1990, 1, 1);

                var shop = (ShopType)order.shopType;
                if (channel == ProductChannel.MT)
                {
                    if (shop == ShopType.ShengLv)
                    {
                        tbOrder.orderType = 11;
                    }
                    else if (shop == ShopType.RenNiXing)
                    {
                        tbOrder.orderType = 14;
                    }
                    else
                    {
                        tbOrder.orderType = 13;
                    }
                }
                else if (channel == ProductChannel.Ctrip)
                {
                    if (order.RatePlanCode.Contains("_c"))
                    {
                        tbOrder.orderType = 16;
                    }
                    else
                    {
                        //15 喜玩携程    5辰亿
                        tbOrder.orderType = CtripOrderType();
                    }
                    //if (shop == ShopType.LingZhong)
                    //{
                    //    tbOrder.orderType = 5;
                    //}
                    //else
                    //{
                    //    tbOrder.orderType = 15;
                    //}
                }
                else if (channel == ProductChannel.DDS)
                {
                    //大都市产品
                    tbOrder.orderType = 17;
                }
                else
                {
                    tbOrder.orderType = Int16.Parse(channel.GetDescription());
                }

                tbOrder.serviceTimeount = new DateTime(1990, 1, 1);       // GetDelayTime(dto.checkInDate);
                tbOrder.prePay          = 1;

                if (channel == ProductChannel.Elong)
                {
                    tbOrder.source = "elong";
                }
                else if (channel == ProductChannel.LY)
                {
                    tbOrder.source = "tclj";
                }
                tbOrder.Refuse = 0;   //退款标记

                var isSuccess = sqlSugarClient.Insertable(tbOrder).ExecuteCommand() > 0;
                if (isSuccess)
                {
                    return(result.SetSucess("保存订单成功"));
                }
                else
                {
                    return(result.SetError("保存订单失败"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }