예제 #1
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            var             client = new StorageClient();
            ImageDownloader down   = new ImageDownloader(client);

            this.Window = new UIWindow(UIScreen.MainScreen.Bounds);
            MovieSettings ApiConnection                  = new MovieSettings();
            DownloadImage download                       = new DownloadImage(down);
            MovieService  ApiService                     = new MovieService(download);
            var           MovieSearchController          = new MovieController(ApiConnection, ApiService);
            var           MovieSearchNavigationControler = new UINavigationController(MovieSearchController);
            var           MovieRatedController           = new RatedController(ApiConnection, ApiService);
            var           MovieRatedNavigationController = new UINavigationController(MovieRatedController);


            var movieTabController = new MovieTabController()
            {
                ViewControllers = new UIViewController[] { MovieSearchNavigationControler, MovieRatedNavigationController }
            };

            this.Window.RootViewController = movieTabController;

            this.Window.MakeKeyAndVisible();
            return(true);
        }
예제 #2
0
 private void OnDestroy()
 {
     if (this == _instance)
     {
         _instance = null;
     }
 }
예제 #3
0
        public IMDBResultsList(IList <ImdbResult> results, String title)
        {
            _results = results;
            InitializeComponent();
            Text = "IMDB results - " + title;
            var il    = new ImageList();
            var count = 0;

            listView1.View           = View.Tile;
            il.ImageSize             = new Size(32, 32);
            listView1.LargeImageList = il;
            foreach (var imdbResult in results)
            {
                ListViewItem item;
                if (imdbResult.PicUrl != "/images/b.gif" && !String.IsNullOrEmpty(imdbResult.PicUrl))
                {
                    var pic = new DownloadImage(imdbResult.PicUrl);
                    pic.Download();
                    il.Images.Add(pic.GetImage());
                    item = new ListViewItem(new[] { imdbResult.Title, imdbResult.Year, imdbResult.IMDBIDUrl })
                    {
                        ImageIndex = count++
                    };
                }
                else
                {
                    il.Images.Add(Properties.Resources.no_image);
                    item = new ListViewItem(new[] { imdbResult.Title, imdbResult.Year, imdbResult.IMDBIDUrl })
                    {
                        ImageIndex = count++
                    };
                }
                listView1.Items.Add(item);
            }
        }
예제 #4
0
        private void loadPicture(object sender, DoWorkEventArgs e)
        {
            var    worker = sender as BackgroundWorker;
            var    hw     = new HtmlWeb();
            var    doc    = hw.Load(_url).DocumentNode.WriteContentTo();
            var    p      = doc.IndexOf("<img src=\"http://ia.media-IMDB.com");
            var    pp     = doc.IndexOf("<img src=\"http://ia.media-imdb.com");
            string picURL = null;

            if (p != -1)
            {
                picURL = doc.Remove(0, p + 10);
            }
            else if (pp != -1)
            {
                picURL = doc.Remove(0, pp + 10);
            }
            if (picURL != null)
            {
                picURL = picURL.Remove(picURL.IndexOf("\""));
                var pic = new DownloadImage(picURL);
                pic.Download();
                pictureBox1.Image    = pic.GetImage();
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            worker.ReportProgress(100);
        }
예제 #5
0
    private void Awake()
    {
        //Initialize Singleton
        if (_instance != null && _instance != this)
        {
            Destroy(GetComponent <DownloadImage>());
        }
        else
        {
            _instance = this;
        }

        //Initialize Cache Directory Path
        dirPath = Application.persistentDataPath + "/CacheImages/";
        if (!Directory.Exists(dirPath))
        {
            Directory.CreateDirectory(dirPath);
        }

        //Clear Cache after 7 days
        SetStartDate();
        if (GetDaysPassed() > 7)
        {
            DeleteFolder();
            ResetStartDate();
        }
    }
예제 #6
0
        private ImageList GetImageList(Film film)
        {
            var nil = new ImageList {
                ImageSize = new Size(32, 32)
            };

            for (int i = 0; i < _il.Images.Count; i++)
            {
                if (i == _previousIndex)
                {
                    if (film.PicURL != "/images/b.gif" && !string.IsNullOrEmpty(film.PicURL))
                    {
                        var pic = new DownloadImage(film.PicURL);
                        pic.Download();
                        nil.Images.Add(pic.GetImage() ?? Properties.Resources.no_image);
                    }
                    else
                    {
                        nil.Images.Add(Properties.Resources.no_image);
                    }
                }
                else
                {
                    nil.Images.Add(_il.Images[i]);
                }
            }
            return(nil);
        }
예제 #7
0
        public string CretaeWxCode()
        {
            var responseData = new ResponseData();

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = this.CurrentUserInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1;

                if (wapentity == null || wapentity.ApplicationId == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData.ToJSON());
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                     , wapentity.AppSecret.Trim()
                                                     , "1", MaxWQRCod
                                                     , this.CurrentUserInfo);

                if (string.IsNullOrEmpty(imageUrl))
                {
                    responseData.success = false;
                    responseData.msg     = "二维码生成失败!";
                }
                else
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success = true;
                responseData.msg     = "二维码生成成功!";
                var rp = new ReposeData()
                {
                    imageUrl  = imageUrl,
                    MaxWQRCod = MaxWQRCod
                };
                responseData.data = rp;
                return(responseData.ToJSON());
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }
        }
예제 #8
0
        //TODO: Should probably be extracted to a separate class

        /// <summary>
        /// Process the first most important Unprocessed Report
        /// </summary>
        /// <param name="eur">
        /// Class: EUReported record
        /// </param>
        private void ProcessUnReported(EUReported eur)
        {
            Imogen.Controllers.Reporting.CurrentInternalReport.Reset();
            DownloadImage di = new DownloadImage();

            Log("Loading Processing of New Report"); // This could be a partial report so check the other tables as well !!
            CurrentInternalReport.PageUrlHash = eur.PageUrlHash;
            CurrentInternalReport.PageUrl     = eur.PageUrl;
            CurrentInternalReport.SrcUrlHash  = eur.SrcUrlHash;
            CurrentInternalReport.SrcUrl      = eur.SrcUrl;


            CurrentInternalReport.LinkUrlHash     = eur.LinkUrlHash;
            CurrentInternalReport.LinkUrl         = eur.LinkUrl;
            CurrentInternalReport.ReportNumber    = eur.id;
            CurrentInternalReport.ReportedOn      = eur.CreatedOn;
            CurrentInternalReport.SrcUrlFilename  = utils.GetPossibleFileName(eur.SrcUrl);
            CurrentInternalReport.LinkUrlFilename = utils.GetPossibleFileName(eur.LinkUrl);

            Log("Downloading Image");
            string imgPath = di.Download(eur.SrcUrl);

            if (imgPath != null)
            {
                Log("Download Completed", LogType.Success);
                frmProfileImage.ShowImage(imgPath);
                currentFilePath = imgPath;
                CurrentInternalReport.ImagePath = imgPath;
            }
            else
            {
                Log("Download Failed", LogType.Error);
            }

            // Shows the Src Image and Metadata
            Log("Opening Restricted Web Browser for Src Url");
            try
            {
                if (frmRWB == null)
                {
                    frmRWB.Show(dockPanel, DockState.Document);
                }
                frmRWB.ShowSrcUrl(eur.SrcUrl);
                if (frmMetadata == null)
                {
                    frmMetadata.Show(dockPanel, DockState.DockRight);
                }
                frmMetadata.GetMetaData(currentFilePath);
            }
            catch (Exception ex)
            {
                Log(ex.Message, LogType.Error);
                throw;
            }
        }
예제 #9
0
        bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
        {
            if ((int)commandId == OpenLinkInNewTab)
            {
                //browser.ShowDevTools();
                OpenInNewTabContextMenu?.Invoke(this, new NewTabEventArgs(parameters.UnfilteredLinkUrl));
            }
            if ((int)commandId == CloseDevTools)
            {
                browser.CloseDevTools();
            }
            if ((int)commandId == MenuSaveImage)
            {
                DownloadImage?.Invoke(this, new DownloadImageViaContextMenuEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ViewSource)
            {
                ViewPageSource?.Invoke(this, null);
            }
            if ((int)commandId == SaveYouTubeVideo)
            {
                DownloadYouTubeVideo?.Invoke(this, null);   //we have the address, anyway, so don't need to pass it via event args.
            }
            if ((int)commandId == ViewImageExifData)
            {
                ViewImageExif?.Invoke(this, new ExifViewerEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ViewFacebookId)
            {
                ViewFacebookIdNum?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == ViewTwitterId)
            {
                ViewTwitterIdNum?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == CopyImgLocation)
            {
                CopyImageLocation?.Invoke(this, new ExifViewerEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ReverseImageSearch)
            {
                ReverseImgSearch?.Invoke(this, new ExifViewerEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ExtractAllLinks)
            {
                ExtractLinks?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == Bookmark)
            {
                AddPageToBookmarks?.Invoke(this, EventArgs.Empty);
            }

            return(false);
        }
예제 #10
0
        public async Task Given_A_DownloadImage_Should_Execute_Publish_Method()
        {
            // Arrange
            const int expected      = 1;
            var       downloadImage = new DownloadImage();

            // Act
            await _sut.Publish(downloadImage);

            // Assert
            await _cardImageQueue.Received(expected).Publish(Arg.Is(downloadImage));
        }
예제 #11
0
    public void CancelDownload()
    {
        DownloadImage d = E621_Navigation.act.listCoroutines.Where(temp => temp.data.id == id).SingleOrDefault();

        if (d != null)
        {
            StopCoroutine(d.thisCoroutine);
            Destroy(d.objProgress);
            E621_Navigation.act.listCoroutines.Remove(E621_Navigation.act.listCoroutines.Where(temp => temp.data.id == id).Single());
            print("download cancelled");
        }
    }
예제 #12
0
        private void loadPicture(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;

            if (_film.PicURL != null)
            {
                var pic = new DownloadImage(_film.PicURL);
                pic.Download();
                pb_Filmposter.Image    = pic.GetImage();
                pb_Filmposter.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            worker.ReportProgress(100);
        }
예제 #13
0
        public void PopulateList()
        {
            listView1.Groups.Clear();
            listView1.Items.Clear();
            var count = 0;

            listView1.Groups.Add(new ListViewGroup("Films"));
            listView1.Groups.Add(new ListViewGroup("Possible Errors"));
            listView1.Groups.Add(new ListViewGroup("Not Found"));
            listView1.View           = View.Tile;
            _il.ImageSize            = new Size(32, 32);
            listView1.LargeImageList = _il;
            foreach (var film in _filmDic.Values)
            {
                ListViewItem item;
                if (film.PicURL != "/images/b.gif" && !string.IsNullOrEmpty(film.PicURL))
                {
                    var pic = new DownloadImage(film.PicURL);
                    pic.Download();
                    var picture = pic.GetImage();
                    _il.Images.Add(picture ?? Properties.Resources.no_image);
                    item = new ListViewItem(new[] { film.Title, film.ReleaseYear, film.FilmPath })
                    {
                        ImageIndex = count++
                    };
                }
                else
                {
                    _il.Images.Add(Properties.Resources.no_image);
                    item = new ListViewItem(new[] { film.Title, film.ReleaseYear, film.FilmPath })
                    {
                        ImageIndex = count++
                    };
                }
                if (film.PossibleErrors.HasValue)
                {
                    item.Group = film.PossibleErrors.Value ? listView1.Groups[1] : listView1.Groups[0];
                }
                else
                {
                    item.SubItems[0].Text = film.FilmPath;
                    item.SubItems[1].Text = "";
                    item.SubItems[2].Text = film.FilmPath;
                    item.Group            = listView1.Groups[2];
                }
                listView1.Items.Add(item);
            }
        }
예제 #14
0
        public async Task <ArchetypeDataTaskResult <ArchetypeMessage> > Process(ArchetypeMessage archetypeData)
        {
            var articleDataTaskResult = new ArchetypeDataTaskResult <ArchetypeMessage>
            {
                ArchetypeData = archetypeData
            };

            var existingArchetype = await _archetypeService.ArchetypeById(archetypeData.Id);

            if (existingArchetype == null)
            {
                var newArchetype = new Archetype
                {
                    Id      = archetypeData.Id,
                    Name    = archetypeData.Name,
                    Url     = archetypeData.ProfileUrl,
                    Created = DateTime.UtcNow,
                    Updated = archetypeData.Revision
                };

                await _archetypeService.Add(newArchetype);
            }
            else
            {
                existingArchetype.Name    = archetypeData.Name;
                existingArchetype.Url     = archetypeData.ProfileUrl;
                existingArchetype.Updated = archetypeData.Revision;

                await _archetypeService.Update(existingArchetype);
            }

            if (!string.IsNullOrWhiteSpace(archetypeData.ImageUrl))
            {
                var downloadImage = new DownloadImage
                {
                    RemoteImageUrl = new Uri(archetypeData.ImageUrl),
                    ImageFileName  = archetypeData.Id.ToString(),
                };

                await _archetypeImageQueueService.Publish(downloadImage);
            }

            return(articleDataTaskResult);
        }
예제 #15
0
		public static System.Drawing.Image ProductImage(Lfx.Data.Connection dataBase, int productId, DownloadImage downloadImage)
		{
			string CachePath = Lfx.Environment.Folders.CacheFolder;
			string ImageFileName = "product_" + productId.ToString() + ".jpg";
			bool ImageInCache = System.IO.File.Exists(CachePath + ImageFileName);

			if(downloadImage == DownloadImage.Always
				|| (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false)
				|| ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
			{
				//Download image and save to cache
				Lfx.Data.Row ImagenDB = dataBase.Row("articulos_imagenes", "imagen", "id_articulo", productId);

                                if (ImagenDB != null && ImagenDB.Fields["imagen"].Value != null && ((byte[])(ImagenDB.Fields["imagen"].Value)).Length > 5)
				{
					//Guardar imagen en cache
					System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
                                        wr.Write(((byte[])(ImagenDB.Fields["imagen"].Value)));
					wr.Close();

                                        byte[] ByteArr = ((byte[])(ImagenDB.Fields["imagen"].Value));
                                        System.Drawing.Image Img;

                                        using (System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr)) {
                                                Img = System.Drawing.Image.FromStream(loStream);
                                        }
                                        return Img;
				}
				else
				{
					//Devuelve la imagen de la categoría, en lugar de la del artículo
					int CategoriaArticulo = dataBase.FieldInt("SELECT id_categoria FROM articulos WHERE id_articulo=" + productId.ToString());
					return CategoryImage(dataBase, CategoriaArticulo, downloadImage);
				}
			}

			//Serve only from cache
			if(ImageInCache)
			{
				return System.Drawing.Image.FromFile(CachePath + ImageFileName);
			}
			
			return null;
		}
예제 #16
0
        public Task <CardImageCompletion> Publish(DownloadImage downloadImage)
        {
            var cardImageCompletion = new CardImageCompletion();

            try
            {
                var messageBodyBytes = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(downloadImage));

                var factory = new ConnectionFactory()
                {
                    HostName = _rabbitMqConfig.Value.Host
                };
                using (var connection = factory.CreateConnection())
                    using (var channel = connection.CreateModel())
                    {
                        var props = channel.CreateBasicProperties();
                        props.ContentType  = _rabbitMqConfig.Value.ContentType;
                        props.DeliveryMode = _rabbitMqConfig.Value.Exchanges[RabbitMqExchangeConstants.YugiohHeadersImage].PersistentMode;

                        props.Headers = _rabbitMqConfig.Value.Exchanges[RabbitMqExchangeConstants.YugiohHeadersImage].Headers.ToDictionary(k => k.Key, k => (object)k.Value);

                        channel.BasicPublish
                        (
                            RabbitMqExchangeConstants.YugiohHeadersImage,
                            "",
                            props,
                            messageBodyBytes
                        );
                    }

                cardImageCompletion.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                cardImageCompletion.Errors = new List <string> {
                    $"Unable to send image: {downloadImage.RemoteImageUrl} to download queue"
                };
                cardImageCompletion.Exception = ex;
            }

            return(Task.FromResult(cardImageCompletion));
        }
예제 #17
0
        public Task Publish(DownloadImage downloadImage)
        {
            try
            {
                var messageBodyBytes = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(downloadImage));

                var factory = new ConnectionFactory()
                {
                    HostName = _rabbitMqConfig.Value.Host
                };
                using (var connection = factory.CreateConnection())
                    using (var channel = connection.CreateModel())
                    {
                        var props = channel.CreateBasicProperties();
                        props.ContentType  = _rabbitMqConfig.Value.ContentType;
                        props.DeliveryMode = _rabbitMqConfig.Value.Exchanges[RabbitMqExchangeConstants.YugiohHeadersImage].PersistentMode;

                        props.Headers = _rabbitMqConfig.Value
                                        .Exchanges[RabbitMqExchangeConstants.YugiohHeadersImage]
                                        .Queues[RabbitMqQueueConstants.ArchetypeImage]
                                        .Headers.ToDictionary(k => k.Key, k => (object)k.Value);

                        channel.BasicPublish
                        (
                            RabbitMqExchangeConstants.YugiohHeadersImage,
                            "",
                            props,
                            messageBodyBytes
                        );
                    }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(Task.CompletedTask);
        }
예제 #18
0
        public static async Task <ViewProps> SetProperties(ViewProps props)
        {
            RandomShapeAndSizeGenerator generator = new RandomShapeAndSizeGenerator(props);

            if (generator.prop.isCircle)
            {
                if (CheckConnection.iSConnected() == true)
                {
                    var root = RetrieveXml.GetXml("http://www.colourlovers.com/api/colors/random");
                    if (root != null && root.GetElementsByTagName("imageUrl").Count != 0)
                    {
                        generator.prop.imageURL = root.GetElementsByTagName("imageUrl")[0].InnerText;
                        generator.prop.title    = root.GetElementsByTagName("title")[0].InnerText;

                        DownloadImage download = new DownloadImage(generator.prop);
                        generator.prop = await download.downloadAsync();

                        generator.prop.image = getRoundedShape(generator.prop);
                    }
                }
            }
            else
            {
                if (CheckConnection.iSConnected() == true)
                {
                    var root = RetrieveXml.GetXml("http://www.colourlovers.com/api/patterns/random");
                    if (root != null && root.GetElementsByTagName("imageUrl").Count != 0)
                    {
                        generator.prop.imageURL = root.GetElementsByTagName("imageUrl")[0].InnerText;
                        generator.prop.title    = root.GetElementsByTagName("title")[0].InnerText;

                        DownloadImage download = new DownloadImage(generator.prop);
                        generator.prop = await download.downloadAsync();
                    }
                }
            }
            return(generator.prop);
        }
예제 #19
0
 public DownloadImageResult(DownloadImage command, byte[] bytes, HttpStatusCode status)
 {
     Status  = status;
     Bytes   = bytes;
     Command = command;
 }
예제 #20
0
        public WxCode CretaeWxCode()
        {
            var responseData = new WxCode();

            responseData.success = false;
            responseData.msg     = "二维码生成失败!";
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = loggingSessionInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(loggingSessionInfo).GetMaxWQRCod() + 1;

                if (wapentity == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData);
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                try
                {
                    imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                         , wapentity.AppSecret.Trim()
                                                         , "1", MaxWQRCod
                                                         , loggingSessionInfo);
                }
                catch (Exception e)
                {
                    responseData.success = false;
                    responseData.msg     = e.Message;// "二维码生成失败!";
                    return(responseData);
                }

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success   = true;
                responseData.msg       = "";
                responseData.ImageUrl  = imageUrl;
                responseData.MaxWQRCod = MaxWQRCod;


                return(responseData);
            }
            catch (Exception ex)
            {
                //throw new APIException(ex.Message);
                return(responseData);
            }
        }
예제 #21
0
        protected override DownloadQRCodeRD ProcessRequest(DTO.Base.APIRequest <DownloadQRCodeRP> pRequest)
        {
            string content    = string.Empty;
            string customerId = string.Empty;
            var    RD         = new DownloadQRCodeRD();

            try
            {
                #region 解析传入参数
                //解析请求字符串
                var RP = pRequest.Parameters;

                //判断客户ID是否传递

                customerId = CurrentUserInfo.CurrentUser.customer_id;


                #endregion
                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;

                if (string.IsNullOrEmpty(RP.VipDCode.ToString()) || RP.VipDCode == 0)
                {
                    throw new APIException("VipDCode参数不能为空");
                }
                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                if (RP.VipDCode == 9)                 //永久二维码
                {
                    var userQRCodeBll  = new WQRCodeManagerBLL(CurrentUserInfo);
                    var marketEventBll = new MarketEventBLL(CurrentUserInfo);

                    var marketEventEntity = marketEventBll.QueryByEntity(new MarketEventEntity()
                    {
                        EventCode = "CA00002433", CustomerId = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    var userQRCode = userQRCodeBll.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = marketEventEntity.MarketEventID, CustomerId = CurrentUserInfo.ClientID
                    }, null);                                                                                                                                                              //

                    if (userQRCode != null && userQRCode.Length > 0)
                    {
                        RD.imageUrl = userQRCode[0].ImageUrl;
                        return(RD);
                    }

                    //获取当前二维码 最大值
                    iResult    = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1;
                    rpVipDCode = 1;                 //永久

                    #region 获取微信帐号
                    //门店关联的公众号
                    var tueBll    = new TUnitExpandBLL(CurrentUserInfo);
                    var tueEntity = new TUnitExpandEntity();
                    if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId))
                    {
                        tueEntity = tueBll.QueryByEntity(new TUnitExpandEntity()
                        {
                            UnitId = CurrentUserInfo.CurrentUserRole.UnitId
                        }, null).FirstOrDefault();
                    }

                    var server = new WApplicationInterfaceBLL(CurrentUserInfo);
                    var wxObj  = new WApplicationInterfaceEntity();
                    if (tueEntity != null && !string.IsNullOrEmpty(tueEntity.Field1))
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            AppID = tueEntity.Field1, CustomerId = customerId
                        }, null).FirstOrDefault();
                    }
                    else
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            CustomerId = customerId
                        }, null).FirstOrDefault();
                    }

                    if (wxObj == null)
                    {
                        throw new APIException("没有对应公众号");
                    }
                    else
                    {
                        var commonServer = new CommonBLL();

                        imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                             , wxObj.AppSecret
                                                             , rpVipDCode.ToString("")    //二维码类型  0: 临时二维码  1:永久二维码
                                                             , iResult, CurrentUserInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                        if (imageUrl != null && !imageUrl.Equals(""))
                        {
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            string downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                            imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                            //如果名称不为空,就把图片放在一定的背景下面
                            //if (!string.IsNullOrEmpty(RP.Parameters.RetailTraderName))
                            //{
                            //    string apiDomain = ConfigurationManager.AppSettings["website_url"];

                            //    imageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", imageUrl, RP.Parameters.RetailTraderName + "合作二维码");
                            //}
                        }
                    }

                    #endregion

                    if (!string.IsNullOrEmpty(imageUrl))    //永久二维码
                    {
                        #region 创建店员永久二维码匹配表
                        var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo);
                        var userQrType    = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity()
                        {
                            TypeName = "签到"
                        }, null);                                                                                       //"UserQrCode"
                        if (userQrType != null && userQrType.Length > 0)
                        {
                            var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo);
                            var userQrCode    = new WQRCodeManagerEntity();
                            userQrCode.QRCode        = iResult.ToString();//记录传过去的二维码场景值
                            userQrCode.QRCodeTypeId  = userQrType[0].QRCodeTypeId;
                            userQrCode.IsUse         = 1;
                            userQrCode.CustomerId    = CurrentUserInfo.CurrentUser.customer_id;
                            userQrCode.ImageUrl      = imageUrl;
                            userQrCode.ApplicationId = wxObj.ApplicationId;
                            //objectId 为店员ID
                            userQrCode.ObjectId = marketEventEntity.MarketEventID;
                            userQrCodeBll.Create(userQrCode);
                        }
                        #endregion
                    }
                }

                RD.imageUrl = imageUrl;
            }
            catch
            {
                throw new APIException("生成二维码错误");
            }
            return(RD);
        }
예제 #22
0
 public Task <CardImageCompletion> Publish(DownloadImage downloadImage)
 {
     return(_cardImageQueue.Publish(downloadImage));
 }
예제 #23
0
        public HttpResponseMessage QRCode(string UnitId, string ObjectID)
        {
            Loggers.Debug(new DebugLogInfo()
            {
                Message = $"[api/Vip/QRCode]接口,参数:\"UnitId:{UnitId}&ObjectID:{ObjectID}\""
            });
            try
            {
                string customerId         = ConfigurationManager.AppSettings["CustomerId"].Trim();
                var    loggingSessionInfo = Default.GetLoggingSession(customerId, ObjectID);
                loggingSessionInfo.Conn = ConfigurationManager.AppSettings["Conn"].Trim();

                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;


                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                string objectid = ObjectID;

                #region 获取微信帐号

                //门店关联的公众号
                var tuBll    = new t_unitBLL(loggingSessionInfo);
                var tuEntity = new t_unitEntity();
                if (!string.IsNullOrEmpty(UnitId))
                {
                    tuEntity =
                        tuBll.QueryByEntity(new t_unitEntity()
                    {
                        unit_id = UnitId
                    }, null)
                        .FirstOrDefault();
                }

                var server = new WApplicationInterfaceBLL(loggingSessionInfo);
                var wxObj  = new WApplicationInterfaceEntity();
                if (tuEntity != null && !string.IsNullOrEmpty(tuEntity.weiXinId))
                {
                    wxObj =
                        server.QueryByEntity(
                            new WApplicationInterfaceEntity {
                        WeiXinID = tuEntity.weiXinId, CustomerId = customerId
                    },
                            null).FirstOrDefault();
                }
                else
                {
                    wxObj =
                        server.QueryByEntity(new WApplicationInterfaceEntity {
                        CustomerId = customerId
                    }, null)
                        .FirstOrDefault();
                }

                if (wxObj == null)
                {
                    throw new APIException("不存在对应的微信帐号")
                          {
                              ErrorCode = 302
                          };
                }
                else
                {
                    var commonServer = new CommonBLL();

                    imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                         , wxObj.AppSecret
                                                         , rpVipDCode.ToString("")       //二维码类型  0: 临时二维码  1:永久二维码
                                                         , iResult, loggingSessionInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                    //"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA==";
                    //"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA==";
                    if (imageUrl != null && !imageUrl.Equals(""))
                    {
                        DownloadImage downloadServer   = new DownloadImage();
                        string        downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                        imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                    }
                }

                #endregion


                #region 创建临时匹配表

                VipDCodeBLL    vipDCodeServer = new VipDCodeBLL(loggingSessionInfo);
                VipDCodeEntity info           = new VipDCodeEntity();
                info.DCodeId              = iResult.ToString(); //记录传过去的二维码场景值****(保存到数据库时没加空格)
                info.CustomerId           = customerId;
                info.UnitId               = UnitId;             //获取会集店
                info.Status               = "0";
                info.IsReturn             = 0;
                info.DCodeType            = 2; // add by donal 2014-9-22 10:02:08
                loggingSessionInfo.UserID = ObjectID;
                info.CreateBy             = ObjectID;
                info.ImageUrl             = imageUrl;
                //info.VipId = RP.UserID;
                info.ObjectId = ObjectID; //分享经销商的vipid
                vipDCodeServer.Create(info);

                #endregion


                var model = new QRCodeResponseModel()
                {
                    IsSucess = true,
                    ImageUrl = imageUrl,
                    paraTmp  = iResult.ToString().Insert(4, " ")
                };

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = $"setSignUp content: {model}"
                });


                return(Request.CreateResponse(HttpStatusCode.OK, model));
            }
            catch (Exception ex)
            {
                var model = new QRCodeResponseModel()
                {
                    IsSucess     = false,
                    ErrorMessage = string.Format("获取二维码出错:{0}", ex.Message)
                };
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("获取二维码出错:{0}", ex.Message)
                });
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, model));
            }
        }
예제 #24
0
        public string gonderiCek(string hasthag)
        {
            try
            {
                Thread.Sleep(500);

                var ileriTusu = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow");

                if (ileriTusu)
                {
                    goto devamEt;
                }

                webDriver.Navigate().GoToUrl("https://www.instagram.com/explore/tags/" + hasthag + "/");

                Thread.Sleep(1000);

tekrar4:
                var beniHatirla = IsElementPresent_byCssSelector("#react-root > section > main > article > div.EZdmt > div > div > div:nth-child(1) > div:nth-child(1) > a > div");

                if (beniHatirla)
                {
                    webDriver.FindElement(By.CssSelector("#react-root > section > main > article > div.EZdmt > div > div > div:nth-child(1) > div:nth-child(1) > a > div")).Click();
                }
                else
                {
                    Thread.Sleep(500);
                    goto tekrar4;
                }

devamEt:

                Thread.Sleep(1000);

                string icerikYazisi = "", resimYolu = "";

                Thread.Sleep(1500);
                var resim1 = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div > div.KL4Bh > img");
                var resim2 = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div > div.eLAPa._23QFA > div.KL4Bh > img");
                var resim3 = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div.pR7Pc > div.Igw0E.IwRSH.eGOV_._4EzTm.O1flK.D8xaz.fm1AK.TxciK.yiMZG > div > div > div > ul > li:nth-child(2) > div > div > div > div.eLAPa._23QFA > div.KL4Bh > img");
                var resim4 = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div.pR7Pc > div.Igw0E.IwRSH.eGOV_._4EzTm.O1flK.D8xaz.fm1AK.TxciK.yiMZG > div > div > div > ul > li:nth-child(3) > div > div > div > div.KL4Bh > img");
                var icerik = IsElementPresent_byCssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div.eo2As > div.EtaWk > ul > div > li > div > div > div.C4VMK > span");
                if (icerik)
                {
                    Thread.Sleep(1000);
                    icerikYazisi = webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div.eo2As > div.EtaWk > ul > div > li > div > div > div.C4VMK > span")).Text;
                }
                if (resim1)
                {
                    Thread.Sleep(500);
                    resimYolu = webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div > div.KL4Bh > img")).GetAttribute("src");
                    webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")).Click();
                }
                else if (resim2)
                {
                    Thread.Sleep(500);
                    resimYolu = webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div > div.eLAPa._23QFA > div.KL4Bh > img")).GetAttribute("src");
                    webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")).Click();
                }
                else if (resim3)
                {
                    Thread.Sleep(500);
                    resimYolu = webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.zZYga > div > article > div._97aPb > div > div.pR7Pc > div.Igw0E.IwRSH.eGOV_._4EzTm.O1flK.D8xaz.fm1AK.TxciK.yiMZG > div > div > div > ul > li:nth-child(2) > div > div > div > div.eLAPa._23QFA > div.KL4Bh > img")).GetAttribute("src");
                    webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")).Click();
                }
                else
                {
                    Thread.Sleep(500);
                    webDriver.FindElement(By.CssSelector("body > div._2dDPU.CkGkG > div.EfHg9 > div > div > a._65Bje.coreSpriteRightPaginationArrow")).Click();
                }

                Thread.Sleep(500);
                DownloadImage ImageDownload = new DownloadImage(resimYolu);
                ImageDownload.Download();
                string resimDosyaYolu = "gonderiler\\resim" + random() + ".png";
                ImageDownload.SaveImage(resimDosyaYolu, ImageFormat.Png);

                dataEKle(resimDosyaYolu, icerikYazisi);
                Thread.Sleep(500);

                return(paylasimOk = "Başarılı");
            }
            catch (Exception)
            {
                return(paylasimOk = "Başarısız");
            }
        }
예제 #25
0
 private Control GetImage(Main main, DatabaseRowEntry entry, DatabaseRowEntry.KeyValuePair<string, string> image, int row)
 {
     Picture control = null;
       // First check if we've already downloaded this image.
       string cache = Path.Combine(Path.GetDirectoryName(Properties.Settings.Default.Collection), @"cache");
       if (!File.Exists(cache)) Directory.CreateDirectory(cache);
       cache = Path.Combine(cache, image.Key);
       if (File.Exists(cache))
       {
     control = new Picture(entry) { Image = Image.FromFile(cache), Width = 130, Height = 130, SizeMode = PictureBoxSizeMode.Zoom };
       }
       else
       {
     control = new Picture() { Image = Properties.Resources.loading, Width = 130, Height = 130, SizeMode = PictureBoxSizeMode.CenterImage};
     var imageDownloader = new DownloadImage(main, entry, control, row, image.Value, cache);
     new Thread(new ThreadStart(imageDownloader.Download)).Start();
       }
       return control;
 }
예제 #26
0
        bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
        {
            if ((int)commandId == OpenLinkInNewTab)
            {
                //browser.ShowDevTools();
                OpenInNewTabContextMenu?.Invoke(this, new NewTabEventArgs(parameters.UnfilteredLinkUrl));
            }
            if ((int)commandId == CloseDevTools)
            {
                browser.CloseDevTools();
            }
            if ((int)commandId == MenuSaveImage)
            {
                DownloadImage?.Invoke(this, new DownloadImageViaContextMenuEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ViewSource)
            {
                ViewPageSource?.Invoke(this, null);
            }
            if ((int)commandId == SaveYouTubeVideo)
            {
                DownloadYouTubeVideo?.Invoke(this, null);   //we have the address, anyway, so don't need to pass it via event args.
            }
            if ((int)commandId == ViewImageExifData)
            {
                ViewImageExif?.Invoke(this, new TextEventArgs(parameters.SourceUrl));
            }
            if ((int)commandId == ViewFacebookId)
            {
                ViewFacebookIdNum?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == ViewTwitterId)
            {
                ViewTwitterIdNum?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == CopyImgLocation)
            {
                CopyImageLocation?.Invoke(this, new TextEventArgs(parameters.SourceUrl));
            }

            if ((int)commandId == ReverseImageSearchTineye)
            {
                ReverseImgSearch?.Invoke(this, new TextEventArgs("http://www.tineye.com/search/?url=" + parameters.SourceUrl));
            }
            if ((int)commandId == ReverseImageSearchGoogle)
            {
                ReverseImgSearch?.Invoke(this, new TextEventArgs("https://www.google.com/searchbyimage?&image_url=" + Uri.EscapeUriString(parameters.SourceUrl)));
            }
            if ((int)commandId == ReverseImageSearchYandex)
            {
                ReverseImgSearch?.Invoke(this, new TextEventArgs("https://yandex.com/images/search?url=" + Uri.EscapeUriString(parameters.SourceUrl) + "&rpt=imageview"));
            }

            if ((int)commandId == ExtractAllLinks)
            {
                ExtractLinks?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == Bookmark)
            {
                AddPageToBookmarks?.Invoke(this, EventArgs.Empty);
            }
            if ((int)commandId == SearchSelectedText)
            {
                SearchText?.Invoke(this, new TextEventArgs(parameters.SelectionText));
            }
            if ((int)commandId == SaveText)
            {
                SaveSelectedText?.Invoke(this, new TextEventArgs(parameters.SelectionText));
            }


            return(false);
        }
예제 #27
0
        protected override GetVipDealerSpreadCodeRD ProcessRequest(DTO.Base.APIRequest <GetVipDealerSpreadCodeRP> pRequest)
        {
            var rd                = new GetVipDealerSpreadCodeRD();
            var VipBLL            = new VipBLL(CurrentUserInfo);
            var WQRCodeManagerBLL = new WQRCodeManagerBLL(this.CurrentUserInfo);
            var WQRCodeTypeBLL    = new WQRCodeTypeBLL(this.CurrentUserInfo);

            try
            {
                var UserID = pRequest.UserID;
                //
                string imageUrl   = string.Empty;
                string QRCodeId   = string.Empty;
                string VipName    = string.Empty;
                string HeadImgUrl = string.Empty;
                //分享处理
                if (!string.IsNullOrWhiteSpace(pRequest.Parameters.ShareUserId))
                {
                    UserID = pRequest.Parameters.ShareUserId;
                }
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = this.CurrentUserInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                var VipDealerType = WQRCodeTypeBLL.QueryByEntity(new WQRCodeTypeEntity()
                {
                    TypeCode = "VipDealerCode"
                }, null).FirstOrDefault();
                if (VipDealerType == null)
                {
                    throw new APIException("静态二位经销商类型无此类型!");
                }

                if (!string.IsNullOrWhiteSpace(pRequest.Parameters.QRCodeId))
                {
                    #region 分享出去的二维码
                    var WQRCodeManagerData = WQRCodeManagerBLL.GetByID(pRequest.Parameters.QRCodeId);
                    if (WQRCodeManagerData == null)
                    {
                        throw new APIException("此二维码不存在!");
                    }

                    var VipData = VipBLL.GetByID(WQRCodeManagerData.ObjectId);
                    if (VipData == null)
                    {
                        throw new APIException("此二维码会员不存在!");
                    }

                    //二维码图片地址,ID赋值,会员名称,头像地址赋值
                    imageUrl   = WQRCodeManagerData.ImageUrl;
                    QRCodeId   = WQRCodeManagerData.QRCodeId.ToString();
                    VipName    = VipData.VipName;
                    HeadImgUrl = VipData.HeadImgUrl;
                    #endregion
                }
                else
                {
                    #region 获取去自己静态推广二维码
                    var WQRCodeManagerData = WQRCodeManagerBLL.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = UserID, QRCodeTypeId = VipDealerType.QRCodeTypeId
                    }, null).FirstOrDefault();
                    if (WQRCodeManagerData != null)
                    {
                        //二维码图片地址,ID赋值
                        imageUrl = WQRCodeManagerData.ImageUrl;
                        QRCodeId = WQRCodeManagerData.QRCodeId.ToString();
                    }
                    else
                    {
                        //获取当前二维码 最大值
                        var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1;
                        if (wapentity == null)
                        {
                            throw new APIException("无设置微信公众平台!");
                        }

                        #region 生成二维码
                        JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                        imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                             , wapentity.AppSecret.Trim()
                                                             , "1", MaxWQRCod
                                                             , this.CurrentUserInfo);

                        if (string.IsNullOrEmpty(imageUrl))
                        {
                            throw new APIException("二维码生成失败!");
                        }
                        else
                        {
                            string host = ConfigurationManager.AppSettings["original_url"];
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            //二维码赋值
                            imageUrl = downloadServer.DownloadFile(imageUrl, host);
                            if (!string.IsNullOrEmpty(UserID))
                            {
                                var WQRQrCode = new WQRCodeManagerEntity();
                                WQRQrCode.QRCodeId      = Guid.NewGuid();
                                WQRQrCode.QRCode        = MaxWQRCod.ToString();
                                WQRQrCode.QRCodeTypeId  = VipDealerType.QRCodeTypeId;
                                WQRQrCode.IsUse         = 1;
                                WQRQrCode.CustomerId    = this.CurrentUserInfo.ClientID;
                                WQRQrCode.ImageUrl      = imageUrl;
                                WQRQrCode.ApplicationId = wapentity.ApplicationId;//微信公众号的编号
                                //objectId 为会员ID
                                WQRQrCode.ObjectId = UserID;
                                WQRCodeManagerBLL.Create(WQRQrCode);

                                //二维码ID赋值
                                QRCodeId = WQRQrCode.QRCodeId.ToString();
                            }
                        }
                        #endregion
                    }
                    //会员名称,头像地址
                    var VipData = VipBLL.GetByID(UserID);
                    if (VipData == null)
                    {
                        throw new APIException("会员不存在!");
                    }

                    VipName    = VipData.VipName;
                    HeadImgUrl = VipData.HeadImgUrl;
                    #endregion
                }
                //响应参数赋值
                rd.imageUrl   = imageUrl;
                rd.VipName    = VipName;
                rd.HeadImgUrl = HeadImgUrl;
                rd.QRCodeId   = QRCodeId;
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }

            return(rd);
        }
예제 #28
0
        public void IncomingMessage(CSS.IM.XMPP.protocol.client.Message msg)
        {
            try
            {
                if (msg.Type == MessageType.error)
                {
                    MsgBox.Show(this, "CSS&IM", "离线消息没有发送成功!", MessageBoxButtons.OK);
                    btn_close_Click(null, null);
                    //btn_close_Click(null, null);
                    //if (msg.To.Bare == _connection.MyJID.Bare && msg.From.Bare == to_Jid.Bare)
                    //{
                    //    MsgBox.Show(this, "CSS&IM", "在服务器中没有找到该用户,无法发送消息!", MessageBoxButtons.OK);
                    //    btn_close_Click(null, null);
                    //}
                }

                int m_type = msg.GetTagInt("m_type");

                switch (m_type)
                {
                    case 0://正常消息
                        //RTBRecord.AppendTextAsRtf(msg.From.User + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "\n", new Font(this.Font, FontStyle.Underline | FontStyle.Bold), CSS.IM.Library.ExtRichTextBox.RtfColor.Red, CSS.IM.Library.ExtRichTextBox.RtfColor.White);
                        CSS.IM.UI.Util.Win32.FlashWindow(this.Handle, true);//闪烁

                        #region 显示我自己发送的消息
                        CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                        top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                        top_msg.SetTag("FSize", this.Font.Size);//字体大小
                        top_msg.SetTag("FBold", true);//是否粗体
                        top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                        top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                        top_msg.SetTag("FUnderline", true);//是否下划线

                        Color top_cl = Color.Red;//获取颜色
                        byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                        top_msg.SetTag("CA", top_cby[0]);
                        top_msg.SetTag("CR", top_cby[1]);
                        top_msg.SetTag("CG", top_cby[2]);
                        top_msg.SetTag("CB", top_cby[3]);
                        top_msg.Body = (_NickName != "" ? _NickName : msg.From.User) + "(" + msg.From.User + "):" + DateTime.Now.ToString("HH:mm:ss");
                        top_msg.From = TO_Jid;
                        top_msg.To = TO_Jid;
                        RTBRecord_Show(top_msg, true);
                        #endregion

                        RTBRecord_Show(msg, false);

                        if (IsPlayMsg)
                        {
                            if (CSS.IM.UI.Util.Path.MsgSwitch)
                                CSS.IM.UI.Util.SoundPlayEx.MsgPlay(CSS.IM.UI.Util.Path.MsgPath);
                        }
                        break;
                    case 1://收到对方的请求要过行视频功能服务,初始化本地的视频
                        this.Invoke(AccepVideotInit, new object[] { msg });
                        break;
                    case 2://我发送视频请求后,对方告诉我视频初使化完成,进行自己本地的视频初使化
                        this.Invoke(ReturnAcceptVideoInit, new object[] { msg });
                        break;
                    case 3://对方给我发送视频请求,我初使化本地视频服务,告诉对方,对方也初使化视频服务了,我打开视频功能
                        this.Invoke(AcceptVideoOpen, new object[] { msg });
                        break;
                    case 4://去对方获取截图的功能
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        bool isSend = msg.GetTagBool("isSend");

                        if (isSend)
                        {
                            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                            fmsg.SetTag("m_type", 4);
                            fmsg.Type = MessageType.chat;
                            fmsg.To = TO_Jid;
                            fmsg.SetTag("BPort", ListenBasicUDPPort);
                            fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                            fmsg.SetTag("isSend", false);
                            XmppConn.Send(fmsg);
                        }

                        sendSelfImage();
                        break;
                    case 5://视频释放
                        if (RemotVideoUDPPort != -1)
                        {
                            //avForm.isBtn_hangup = true;
                            if (avForm != null && !avForm.IsDisposed)
                            {
                                avForm.isBtn_hangup = true;
                                avForm.AVClose();
                            }
                            if (ravForm != null && !ravForm.IsDisposed)
                            {
                                ravForm.isBtn_hangup = true;
                                ravForm.AVClose();
                            }
                        }
                        break;
                    case 6://传文件
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));

                        CSS.IM.XMPP.protocol.client.Message lmsg = new CSS.IM.XMPP.protocol.client.Message();
                        lmsg.SetTag("m_type", 7);//告诉对方要发送文件啦
                        lmsg.Type = MessageType.chat;
                        lmsg.To = TO_Jid;
                        lmsg.SetTag("BPort", udpReceiveFile.Port);
                        lmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                        lmsg.SetTag("isSend", false);
                        lmsg.SetTag("File", msg.GetTag("File").ToString());
                        XmppConn.Send(lmsg);
                        break;
                    case 7:
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        this.Invoke(FileSendInitEvent, msg.GetTag("File").ToString());
                        break;
                    case 8://ftp离线文件
                        this.Invoke(GetFtpFileEvent, new object[] { msg});
                        break;
                    case 9://对方拒绝接收主线文件
                        this.AppendSystemRtf("对方"+msg.Body);
                        break;
                    case 10://对方接收离线文件
                        //DownloadImage
                        try
                        {
                            FTPClient ftpClient = new FTPClient(Util.ServerAddress, Util.ftpPath, Util.ftpUser, Util.ftpPswd, Util.ftpPort);
                            ftpClient.FtpPath=msg.GetTag("Path");
                            DownloadImage downloadImage = new DownloadImage();
                            downloadImage.ftpClient = ftpClient;
                            downloadImage.remoteImageName = msg.GetTag("FileName");
                            downloadImage.parent = this;
                            Thread getFileThread = new Thread(downloadImage.Download);
                            getFileThread.Start();
                        }
                        catch (Exception)
                        {

                        }
                        break;
                    case 11://接收到red的视频请求
                        this.Invoke(Red5AccpetEvent, new object[] { msg });
                        break;
                    case 12://接收到red的视频请求
                        this.Invoke(Red5RefuseEvent, new object[] { msg });
                        break;
                    case 13:
                        //red5MsgSend_FormClosing
                        if (red5MsgReceive != null || !red5MsgReceive.IsDisposed)
                        {
                            red5MsgReceive.Close();
                            red5MsgReceive.Dispose();
                            red5MsgReceive = null;
                        }
                        this.AppendSystemRtf("对方" + msg.From.User + "关闭了视频通话");
                        break;
                    case 14:
                        //red5MsgReceive_FormClosing
                        if (red5MsgSend != null || !red5MsgSend.IsDisposed)
                        {
                            red5MsgSend.Close();
                            red5MsgSend.Dispose();
                            red5MsgSend = null;
                        }
                        this.AppendSystemRtf("对方" + msg.From.User + "关闭了视频通话");
                        break;

                }
            }
            catch (Exception)
            {

            }
        }
예제 #29
0
        public static System.Drawing.Image ProductImage(Lfx.Data.IConnection dataBase, int productId, DownloadImage downloadImage)
        {
            string CachePath     = Lfx.Environment.Folders.CacheFolder;
            string ImageFileName = "product_" + productId.ToString() + ".jpg";
            bool   ImageInCache  = System.IO.File.Exists(CachePath + ImageFileName);

            if (downloadImage == DownloadImage.Always ||
                (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false) ||
                ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
            {
                //Download image and save to cache
                Lfx.Data.Row ImagenDB = dataBase.Row("articulos_imagenes", "imagen", "id_articulo", productId);

                if (ImagenDB != null && ImagenDB.Fields["imagen"].Value != null && ((byte[])(ImagenDB.Fields["imagen"].Value)).Length > 5)
                {
                    //Guardar imagen en cache
                    System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
                    wr.Write(((byte[])(ImagenDB.Fields["imagen"].Value)));
                    wr.Close();

                    byte[] ByteArr = ((byte[])(ImagenDB.Fields["imagen"].Value));
                    System.Drawing.Image Img;

                    using (System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr)) {
                        Img = System.Drawing.Image.FromStream(loStream);
                    }
                    return(Img);
                }
                else
                {
                    //Devuelve la imagen de la categoría, en lugar de la del artículo
                    int CategoriaArticulo = dataBase.FieldInt("SELECT id_categoria FROM articulos WHERE id_articulo=" + productId.ToString());
                    return(CategoryImage(dataBase, CategoriaArticulo, downloadImage));
                }
            }

            //Serve only from cache
            if (ImageInCache)
            {
                return(System.Drawing.Image.FromFile(CachePath + ImageFileName));
            }

            return(null);
        }
예제 #30
0
		public static System.Drawing.Image CategoryImage(Lfx.Data.Connection dataBase, int categoryId, DownloadImage downloadImage)
		{
			string CachePath = Lfx.Environment.Folders.CacheFolder;
			string ImageFileName = "product_category_" + categoryId.ToString() + ".jpg";
			bool ImageInCache = System.IO.File.Exists(CachePath + ImageFileName);

                        if (downloadImage == DownloadImage.Always
                                || (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false)
                                || ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
			{
				//Download image and save to cache
				Lfx.Data.Row ImagenDB = dataBase.Row("articulos_categorias", "imagen", "id_categoria", categoryId);

				if(ImagenDB != null && ImagenDB["imagen"] != null && ((byte[])(ImagenDB["imagen"])).Length > 5)
				{
					//Guardar imagen en cache
					System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
					wr.Write(((byte[])(ImagenDB["imagen"])));
					wr.Close();

					byte[] ByteArr = ((byte[])(ImagenDB["imagen"]));
					System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr);
					return System.Drawing.Image.FromStream(loStream);
				}
				else
				{
					return null;
				}
			}

			//Serve only from cache
			if(ImageInCache)
				return System.Drawing.Image.FromFile(CachePath + ImageFileName);
			
			return null;
		}
 public ImageDownloadResult(DownloadImage imageDownloadCommand, HttpStatusCode statusCode, Stream content)
 {
     Content = content;
     StatusCode = statusCode;
     ImageDownloadCommand = imageDownloadCommand;
 }
예제 #32
0
 public ImageDownloadResult(DownloadImage imageDownloadCommand, HttpStatusCode statusCode) : this(imageDownloadCommand, statusCode, null)
 {
 }
 public ImageDownloadResult(DownloadImage imageDownloadCommand, HttpStatusCode statusCode) : this(imageDownloadCommand, statusCode, null)
 {
 }
예제 #34
0
 public ImageDownloadResult(DownloadImage imageDownloadCommand, HttpStatusCode statusCode, Stream content)
 {
     Content              = content;
     StatusCode           = statusCode;
     ImageDownloadCommand = imageDownloadCommand;
 }
예제 #35
0
        /// <summary>
        /// 获取门店二维码
        /// </summary>
        /// <returns></returns>
        public string SetUnitWXCode()
        {
            #region 参数处理
            string WeiXinId     = Request("WeiXinId");
            string UnitId       = Request("UnitId");
            string WXCode       = Request("WXCode");
            var    responseData = new ResponseData();
            if (WeiXinId == null || WeiXinId.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "公众号不能为空";
                return(responseData.ToJSON());
            }

            //if (UnitId == null || UnitId.Trim().Length == 0)
            //{
            //    responseData.success = false;
            //    responseData.msg = "门店标识不能为空";
            //    return responseData.ToJSON();
            //}
            //if (WXCode == null || WXCode.Equals(""))
            //{
            //    VwUnitPropertyBLL unitServer = new VwUnitPropertyBLL(CurrentUserInfo);
            //    WXCode = unitServer.GetUnitWXCode(UnitId).ToString();
            //}
            #endregion

            #region 获取微信公众号信息
            WApplicationInterfaceBLL server = new WApplicationInterfaceBLL(CurrentUserInfo);
            var wxObj = server.QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = CurrentUserInfo.CurrentUser.customer_id
                ,
                IsDelete = 0
                ,
                ApplicationId = WeiXinId
            }, null);
            if (wxObj == null || wxObj.Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "不存在对应的微信帐号";
                return(responseData.ToJSON().ToString());
            }
            else
            {
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                string imageUrl = commonServer.GetQrcodeUrl(wxObj[0].AppID.ToString().Trim()
                                                            , wxObj[0].AppSecret.Trim()
                                                            , "1"
                                                            , Convert.ToInt32(WXCode), CurrentUserInfo);
                if (imageUrl != null && !imageUrl.Equals(""))
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];

                    try
                    {
                        CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                        imageUrl             = downloadServer.DownloadFile(imageUrl, host);
                        responseData.success = true;
                        responseData.msg     = imageUrl;
                        responseData.status  = WXCode;
                    }
                    catch (Exception ex)
                    {
                        responseData.success = false;
                        responseData.data    = imageUrl;
                        responseData.msg     = ex.ToString();
                        return(responseData.ToJSON().ToString());
                    }
                    return(responseData.ToJSON().ToString());
                }
                else
                {
                    responseData.success = false;
                    responseData.msg     = "图片不存在";
                    return(responseData.ToJSON().ToString());
                }
            }
            #endregion
        }
예제 #36
0
        public static System.Drawing.Image CategoryImage(Lfx.Data.IConnection dataBase, int categoryId, DownloadImage downloadImage)
        {
            string CachePath     = Lfx.Environment.Folders.CacheFolder;
            string ImageFileName = "product_category_" + categoryId.ToString() + ".jpg";
            bool   ImageInCache  = System.IO.File.Exists(CachePath + ImageFileName);

            if (downloadImage == DownloadImage.Always ||
                (downloadImage == DownloadImage.OnlyIfNotInCache && ImageInCache == false) ||
                ((downloadImage == DownloadImage.PreferCacheOnSlowLinks && ImageInCache == false) || Lfx.Workspace.Master.SlowLink == false))
            {
                //Download image and save to cache
                Lfx.Data.Row ImagenDB = dataBase.Row("articulos_categorias", "imagen", "id_categoria", categoryId);

                if (ImagenDB != null && ImagenDB["imagen"] != null && ((byte[])(ImagenDB["imagen"])).Length > 5)
                {
                    //Guardar imagen en cache
                    System.IO.BinaryWriter wr = new System.IO.BinaryWriter(System.IO.File.OpenWrite(CachePath + ImageFileName), System.Text.Encoding.Default);
                    wr.Write(((byte[])(ImagenDB["imagen"])));
                    wr.Close();

                    byte[] ByteArr = ((byte[])(ImagenDB["imagen"]));
                    System.IO.MemoryStream loStream = new System.IO.MemoryStream(ByteArr);
                    return(System.Drawing.Image.FromStream(loStream));
                }
                else
                {
                    return(null);
                }
            }

            //Serve only from cache
            if (ImageInCache)
            {
                return(System.Drawing.Image.FromFile(CachePath + ImageFileName));
            }

            return(null);
        }