public async Task <IActionResult> IndexAsync()
        {
            ViewData["Devices"] = new List <NewDeviceModel>()
            {
                new NewDeviceModel
                {
                    DeviceName          = "Test 1",
                    DeviceId            = "r302r809328r9u23t9hwefoijowe",
                    Status              = "Online",
                    LastActivityUpdated = new DateTime()
                },
                new NewDeviceModel
                {
                    DeviceName          = "Test 1",
                    DeviceId            = "r302r809328r9u23t9hwefoijowe",
                    Status              = "Online",
                    LastActivityUpdated = new DateTime()
                },
                new NewDeviceModel
                {
                    DeviceName          = "Test 1",
                    DeviceId            = "r302r809328r9u23t9hwefoijowe",
                    Status              = "Online",
                    LastActivityUpdated = new DateTime()
                }
            };

            ViewData["Devices"] = await HubService.GetDevices();


            return(View());
        }
Beispiel #2
0
        /// <summary>
        /// 上报爬虫状态
        /// </summary>
        /// <param name="identity">唯一标识</param>
        /// <param name="taskId">任务编号</param>
        /// <param name="status">爬虫状态: 运行、暂停、退出、完成</param>
        /// <param name="left">剩余的目标链接数</param>
        /// <param name="total">总的需要采集的链接数</param>
        /// <param name="success">成功采集的链接数</param>
        /// <param name="error">采集出错的链接数</param>
        /// <param name="avgDownloadSpeed">平均下载一个链接需要的时间(豪秒)</param>
        /// <param name="avgProcessorSpeed">平均解析一个页面需要的时间(豪秒)</param>
        /// <param name="avgPipelineSpeed">数据管道处理一次数据结果需要的时间(豪秒)</param>
        /// <param name="threadNum">爬虫线程数</param>
        public override void Flush(string identity, string taskId, string status, long left, long total, long success, long error, long avgDownloadSpeed, long avgProcessorSpeed, long avgPipelineSpeed, int threadNum)
        {
            base.Flush(identity, taskId, status, left, total, success, error, avgDownloadSpeed, avgProcessorSpeed, avgPipelineSpeed, threadNum);

            if (!Env.HubService)
            {
                return;
            }
            var json = JsonConvert.SerializeObject(new SpiderStatus
            {
                TaskId            = taskId,
                AvgDownloadSpeed  = avgDownloadSpeed,
                AvgPipelineSpeed  = avgPipelineSpeed,
                AvgProcessorSpeed = avgProcessorSpeed,
                Error             = error,
                Identity          = identity,
                Left    = left,
                NodeId  = Env.NodeId,
                Status  = status,
                Success = success,
                Thread  = threadNum,
                Total   = total
            });

            HubService.HttpStatus(json);
        }
Beispiel #3
0
        private async void button1_Click(object sender, EventArgs e)
        {
            if (UserProfile.Login == textBox1.Text)
            {
                MessageBox.Show("Вы не можете играть с самим собой:=)", "Странный запрос", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            FreeUserNames = userService.GetFreeUserNames().GetAwaiter().GetResult();

            if (!Levels.DictionaryLevels.TryGetValue(UserProfile.Level.LevelName, out level))
            {
                MessageBox.Show("Возникли проблемы с уровнями. Попробуйте ещё раз!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!FreeUserNames.TryGetValue(textBox1.Text, out choosedUserId))
            {
                MessageBox.Show("Пользователь с таким именем не существует!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                dispose = false;
                var message = string.Format("{0} хочет сыграть с вами на уровне {1}.", UserProfile.Login, UserProfile.Level.RussianName);
                await HubService.SendInvite(textBox1.Text, UserProfile.Level.LevelName, message, this);

                UserProfile.RivalName = textBox1.Text;
                pictureBox1.Image     = Image.FromFile(@"Resources/99px_ru_animacii_20594_kot_krutitsja_kak_kolesiko_zagruzki.gif");
                pictureBox1.Dock      = DockStyle.Fill;
                pictureBox1.Visible   = true;
            }
        }
        public async Task ItemsTresholdReached()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                CountPages++;
                var moviesList = await HubService.GetMoviesAsync(CountPages);

                var previousLastItem = moviesList.Last();
                foreach (var itemMovie in moviesList)
                {
                    itemMovie.poster_path = PathMoviesImage.PathConverter(itemMovie.id.ToString(), itemMovie.poster_path);

                    ItemsMovie.Add(itemMovie);
                }
                Debug.WriteLine($"{ItemsMovie.Count()} {ItemsMovie.Count} ");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #5
0
        private async void timer1_Tick(object sender, EventArgs e)
        {
            timeTimer   = timeTimer.AddSeconds(-1);
            totalTime   = totalTime.AddSeconds(1);
            label3.Text = timeTimer.ToString("m:ss");
            if (timeTimer.Minute == 0 && timeTimer.Second == 0)
            {
                timer1.Stop();
                this.TimeOver = true;
                MessageBox.Show("Время вышло");
                await gameSessionService.CompleteGameSessionForUser(gameSession.Id, UserProfile.Id, totalTime.ToString("m:s"), totalUserPoints);

                await gameSessionService.AddResultToGameSessionUser(gameSession.Id, UserProfile.Id, "Time is over");

                var rivalGameSessionUser = gameSessionService.GetGameSessionUser(gameSession.Id, UserProfile.RivalName);
                if (!rivalGameSessionUser.Finished)
                {
                    MessageBox.Show("Пожалуйста подождите пока ваш соперник не закончит игру.\nВы автоматичски будете переброшенны на страницу результатов!", "Игра окончена", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    pictureBox3.Image   = Image.FromFile(@"Resources/99px_ru_animacii_20594_kot_krutitsja_kak_kolesiko_zagruzki.gif");
                    pictureBox3.Dock    = DockStyle.Fill;
                    pictureBox3.Visible = true;
                }
                else
                {
                    dispose = false;
                    await gameSessionService.CompleteGameSession(gameSession.Id);

                    HubService.RivalFinishedRequest(UserProfile.RivalName);
                    ResultForm resultForm = new ResultForm(totalTime.ToString("m:s"), totalUserPoints, rivalGameSessionUser.TotalTime, rivalGameSessionUser.Points, timeOver: TimeOver);
                    resultForm.Show();
                    this.Close();
                }
            }
        }
        public override async Task LoadAsync()
        {
            SearchInit = true;
            SearchText = null;
            IsBusy     = true;
            ItemsMovie.Clear();

            if (!await StatusConnections.VerifyConnect())
            {
                ItemsMovie.Add(new MoviesModel()
                {
                    title = "Sem conexão..."
                }); IsBusy = false;
                return;
            }
            CountPages = 1;

            var moviesList = await HubService.GetMoviesAsync(CountPages);

            foreach (var itemMovie in moviesList)
            {
                itemMovie.poster_path = PathMoviesImage.PathConverter(itemMovie.id.ToString(), itemMovie.poster_path);
                ItemsMovie.Add(itemMovie);
            }
            OnPropertyChanged(nameof(ItemsMovie));
            IsBusy = false;
        }
        public void record_with_no_pdfs_test()
        {
            var record = new Record().With(r =>
            {
                r.Id        = Helpers.AddCollection("0545c14b-e7fd-472d-8575-5bb75034945f");
                r.Gemini    = Library.Example();
                r.Resources = new List <Resource>
                {
                    new Resource
                    {
                        Name         = "A csv resource",
                        Path         = "C:\\work\\test.csv",
                        PublishedUrl = "http://data.jncc.gov.uk/data/0545c14b-e7fd-472d-8575-5bb75034945f/test.csv"
                    }
                };
            });

            var lambdaClientMock = new Mock <ILambdaClient>();
            var s3ClientMock     = new Mock <IS3Client>();
            var fileHelperMock   = new Mock <IFileHelper>();
            var hubService       = new HubService(env, lambdaClientMock.Object, s3ClientMock.Object, fileHelperMock.Object);

            fileHelperMock.Setup(x => x.IsPdfFile(It.IsAny <string>())).Returns(false);
            fileHelperMock.Setup(x => x.GetFileSizeInBytes(It.IsAny <string>())).Returns(100);
            fileHelperMock.Setup(x => x.GetFileExtensionWithoutDot(It.IsAny <string>())).Returns("csv");
            var lambdaResponse = new InvokeResponse();

            lambdaResponse.StatusCode = 200;
            lambdaClientMock.Setup(x => x.SendToHub(It.IsAny <string>())).Returns(lambdaResponse);

            hubService.Publish(record);

            s3ClientMock.Verify(x => x.SaveToS3(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
            lambdaClientMock.Verify(x => x.SendToHub(It.IsAny <string>()), Times.Once);
        }
Beispiel #8
0
        public HubService GetExpressService(string ServiceCode)
        {
            var service = (from hc in dbContext.HubCarriers
                           join hcs in dbContext.HubCarrierServices on hc.HubCarrierId equals hcs.HubCarrierId
                           join hcsc in dbContext.HubCarrierServiceCountries on hcs.HubCarrierServiceId equals hcsc.HubCarrierServiceId
                           join ccs in dbContext.CustomerHubCarrierServices on hcs.HubCarrierServiceId equals ccs.HubCarrierServiceId
                           where hcs.IsActive == true &&
                           hcs.ServiceCode == ServiceCode
                           select new HubService
            {
                HubCarrierId = hc.HubCarrierId,
                HubCarrierServiceId = hcs.HubCarrierServiceId,
                HubCarrier = hc.Carrier,
                NetworkCode = hcs.NetworkCode,
                HubCarrierDisplay = hc.CarrierService,
                CourierAccountNo = hcs.AccountNumber,
                RateType = hcs.ServiceType,
                RateTypeDisplay = hcs.ServiceTypeDisplay,
                TransitTime = hcs.TransitTime,
                CarrierLogo = hcs.Logo,
                WeightRoundLogic = hcs.WeightRoundLogic
            }
                           ).FirstOrDefault();


            if (service == null)
            {
                service = new HubService();
            }
            return(service);
        }
Beispiel #9
0
        private async void button1_Click(object sender, EventArgs e)
        {
            await HubService.AcceptInvite(userName, true);

            UserProfile.Level     = Levels.DictionaryLevels[levelName];
            UserProfile.RivalName = userName;
            this.Close();
        }
Beispiel #10
0
 public ChatController()
 {
     _GameMan = new GameplayManager();
     _UserGameStoreManager = new UserGameStorageManager();
     _GameSessionManager   = new GameSessionManager();
     _ChatHub        = new HubService();
     _SessionManager = new SessionManager();
 }
        public async Task <IActionResult> RegisterDeviceAsync(NewDeviceModel newDeviceModel)
        {
            if (newDeviceModel != null)
            {
                await HubService.RegisterDevice(newDeviceModel.DeviceId, newDeviceModel.DeviceName);

                return(this.RedirectToAction("Index"));
            }
            return(View());
        }
Beispiel #12
0
        private async void timer1_Tick(object sender, EventArgs e)
        {
            waitingTime++;
            if (waitingTime == 31)
            {
                await HubService.AcceptInvite(userName, false);

                this.Close();
            }
        }
Beispiel #13
0
        private async void button2_Click(object sender, EventArgs e)
        {
            dispose = false;
            await gameSessionService.SurrenderGameSessionUser(gameSession.Id, UserProfile.Login);

            HubService.Surrender(UserProfile.Login, UserProfile.RivalName);
            Menu mainMenu = new Menu();

            mainMenu.Show();
            this.Close();
        }
Beispiel #14
0
        public void SessionChanged(SessionChangedArguments e)
        {
            var unlocked = e.ReasonCode == SessionChangeReasonCode.ConsoleConnect ||
                           e.ReasonCode == SessionChangeReasonCode.RemoteConnect ||
                           e.ReasonCode == SessionChangeReasonCode.SessionLogon ||
                           e.ReasonCode == SessionChangeReasonCode.SessionRemoteControl ||
                           e.ReasonCode == SessionChangeReasonCode.SessionUnlock;

            //changeDescription.Reason == SessionChangeReason.SessionLogon ||
            //         changeDescription.Reason == SessionChangeReason.SessionUnlock;
            SessionManager.Unlocked = unlocked;
            LocalLogger.Log($"{e.ReasonCode}. Unlocked: {unlocked}");
            HubService.LogOnPage($"Session changed to {e.ReasonCode}");
        }
Beispiel #15
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var userAnswer = string.Join("", textBoxModelsList.Where(t => t.TextBox.Visible).Select(t => t.TextBox.Text));
            var correct    = string.Equals(userAnswer, currentRiddle.Answer, StringComparison.InvariantCultureIgnoreCase);
            await answerHistoryService.CreateHistory(gameSession.Id, UserProfile.Id, currentRiddle.Id, userAnswer, correct);

            if (correct)
            {
                currentRiddle    = GetNextRiddle();
                totalUserPoints += pointsForOneRiddle;
                label4.Text      = string.Format("Очки пользователя: {0}", totalUserPoints);
                if (currentRiddle == null)
                {
                    dispose = false;
                    timer1.Stop();
                    await gameSessionService.CompleteGameSessionForUser(gameSession.Id, UserProfile.Id, totalTime.ToString("m:s"), totalUserPoints);

                    var rivalGameSessionUser = gameSessionService.GetGameSessionUser(gameSession.Id, UserProfile.RivalName);
                    if (!rivalGameSessionUser.Finished)
                    {
                        MessageBox.Show("Пожалуйста подождите пока ваш соперник закончит игру.\nВы автоматичски будете переброшенны на страницу результатов!", "Игра окончена", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        pictureBox3.Image   = Image.FromFile(@"Resources/99px_ru_animacii_20594_kot_krutitsja_kak_kolesiko_zagruzki.gif");
                        pictureBox3.Dock    = DockStyle.Fill;
                        pictureBox3.Visible = true;
                    }
                    else
                    {
                        await gameSessionService.CompleteGameSession(gameSession.Id);

                        HubService.RivalFinishedRequest(UserProfile.RivalName);
                        ResultForm resultForm = new ResultForm(totalTime.ToString("m:s"), totalUserPoints, rivalGameSessionUser.TotalTime, rivalGameSessionUser.Points);
                        resultForm.Show();
                        this.Close();
                    }
                }
                else
                {
                    HideAllTextBox();
                    label1.Text = currentRiddle.Text;
                    VisibleNeededTextBox(currentRiddle.Answer);
                    CleanTextBox();
                }
            }
            else
            {
                MessageBox.Show("Ответ неверный!\nПопробуйте ещё раз.", "Ответ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #16
0
        private async void button2_Click(object sender, EventArgs e)
        {
            var haveUnfinishedChame = await userService.HaveUnFinishedGameSession(UserProfile.RivalName);

            if (haveUnfinishedChame == false)
            {
                pictureBox2.Image   = Image.FromFile(@"Resources/99px_ru_animacii_20594_kot_krutitsja_kak_kolesiko_zagruzki.gif");
                pictureBox2.Dock    = DockStyle.Fill;
                pictureBox2.Visible = true;
                var message = String.Format("Игрок {0} хочет сыграть с вами ещё раз на уровне {1}!", UserProfile.Login, UserProfile.Level.RussianName);
                await HubService.SendInvite(UserProfile.RivalName, UserProfile.Level.LevelName, message, this);
            }
            else
            {
                MessageBox.Show(string.Format("{0} уже играет с другим игроком, либо вышел из игры!", UserProfile.RivalName), "Реванш", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #17
0
        public async void AcceptInvite(bool accept)
        {
            if (accept)
            {
                var gameSession = await gameSessionService.CreateGameSession(UserProfile.Id, textBox1.Text, level.Id);

                await HubService.StartGame(textBox1.Text, gameSession.Id);

                Playground playground = new Playground(gameSession);
                playground.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show($"Пользователь {textBox1.Text} отклонил ваше приглашение!", "Приглашения", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pictureBox1.Visible = false;
            }
        }
        public MoviesViewModel()
        {
            Title                  = "Movies List";
            ItemsMovie             = new InfiniteScrollCollection <MoviesModel>();
            ShowMovieDetailCommand = new Command <MoviesModel>(async(x) => await ExecuteMovieDetail(x));
            ItemsMovie             = new InfiniteScrollCollection <MoviesModel>
            {
                OnLoadMore = async() =>
                {
                    if (await StatusConnections.VerifyConnect())
                    {
                        IsBusy = true;
                        if (!string.IsNullOrEmpty(SearchText))
                        {
                            return(null);
                        }
                        CountPages++;
                        var moviesList = await HubService.GetMoviesAsync(CountPages);

                        if (moviesList == null)
                        {
                            return(new InfiniteScrollCollection <MoviesModel>());
                        }
                        foreach (var itemMovie in moviesList)
                        {
                            itemMovie.poster_path = PathMoviesImage.PathConverter(itemMovie.id.ToString(), itemMovie.poster_path);

                            ItemsMovie.Add(itemMovie);
                        }
                        IsBusy = false;
                        return(moviesList);
                    }
                    else
                    {
                        IsBusy = false; return(null);
                    };
                }
            }; IsBusy = false;
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }
            if (!await StatusConnections.VerifyConnect())
            {
                ItemsMovie.Add(new MoviesModel()
                {
                    title = "Sem conexão ativa com a internet..."
                });
                IsBusy = false;
                return;
            }
            IsBusy = true;

            try
            {
                CountPages = 1;
                ItemsMovie.Clear();
                var moviesList = await HubService.GetMoviesAsync(CountPages);

                foreach (var item in moviesList)
                {
                    ItemsMovie.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public override async Task LoadAsync()
        {
            IsBusy      = true;
            MovieDetail = await HubService.GetMoviesDetailAsync(SelectedMovieDetail.id);

            if (MovieDetail == null)
            {
                await Navigation.PopToRootAsync();

                return;
            }
            MovieDetail.backdrop_path = PathMoviesImage.PathConverter(SelectedMovieDetail.id.ToString(), MovieDetail.backdrop_path);
            if (MovieDetail != null && MovieDetail.genres != null)
            {
                Genre.Clear();
                foreach (var item in MovieDetail.genres)
                {
                    Genre.Add(item);
                }
            }
            OnPropertyChanged(nameof(MovieDetail));
            OnPropertyChanged(nameof(Genre));
            IsBusy = false;
        }
Beispiel #21
0
        private async void Playground_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (dispose)
            {
                var dialogResult = MessageBox.Show("Вы действительно хотите закончить текущую игровую сессию и перейти в меню?", "Выход", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogResult == DialogResult.Yes)
                {
                    await gameSessionService.ExitGameSessionUser(gameSession.Id, UserProfile.Id);

                    HubService.RivalExitedGameRequest(UserProfile.RivalName);
                    var menu = new Menu();
                    menu.Show();
                }
                else
                {
                    e.Cancel = true;
                }
            }

            await gameSessionService.CompleteGameSessionForUser(gameSession.Id, UserProfile.Id, totalTime.ToString("m:s"), totalUserPoints);

            await userService.ChangeIsPlayingOfUser(UserProfile.Id, false);
        }
Beispiel #22
0
 public async Task HandleAsync(OperationPending @event, ICorrelationContext context)
 => await HubService.PublishOperationPendingAsync(@event);
        public IntegrtaionResult MapExpressEAMGlobalIntegrationResponse(EAMGlobalResponse eamPostalResponse, List <ExpressPackageModel> Packages, HubService carrier)
        {
            IntegrtaionResult integrtaionResult = new IntegrtaionResult();

            if (eamPostalResponse.Status)
            {
                integrtaionResult.Status = true;
                if (carrier.HubCarrier == FrayteCourierCompany.DomesticA)
                {
                    integrtaionResult.CourierName = FrayteCourierCompany.DomesticA;
                }
                else if (carrier.HubCarrier == FrayteCourierCompany.EAMExpress)
                {
                    integrtaionResult.CourierName = FrayteCourierCompany.EAMExpress;
                }
                integrtaionResult.TrackingNumber       = eamPostalResponse.AWB;
                integrtaionResult.PickupRef            = null;
                integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>();
                int counter = 0;
                for (int i = 0; i < Packages.Count(); i++)
                {
                    for (int j = 0; j < Packages[i].CartonValue; j++)
                    {
                        CourierPieceDetail obj = new CourierPieceDetail();
                        obj.DirectShipmentDetailId = 0;
                        obj.PieceTrackingNumber    = string.Concat(eamPostalResponse.AWB, counter);
                        obj.ImageUrl = eamPostalResponse.LabelUrl;
                        integrtaionResult.PieceTrackingDetails.Add(obj);
                        counter++;
                    }
                }
            }
            else
            {
                integrtaionResult.Error         = new FratyteError();
                integrtaionResult.Error.Service = new List <string>();
                integrtaionResult.Error.Service.AddRange(eamPostalResponse.ERROR);
                integrtaionResult.Status = false;
            }
            return(integrtaionResult);
        }
Beispiel #24
0
 public UserBusiness(HubService hubService)
 {
     _hubService = hubService;
 }
Beispiel #25
0
 public ApiController(HubService hubService)
 {
     _hubService = hubService;
 }
Beispiel #26
0
        private async void button2_Click(object sender, EventArgs e)
        {
            await HubService.AcceptInvite(userName, false);

            this.Close();
        }
Beispiel #27
0
 public async Task HandleAsync(OperationRejected @event, ICorrelationContext context)
 => await HubService.PublishOperationRejectedAsync(@event);
Beispiel #28
0
 public RouteSearchDelayService()
 {
     _hubService = new HubService(HubNames.DELAYS_HUB);
 }
Beispiel #29
0
 public EventService(HubService hubService)
 {
     this.hubService = hubService;
 }
        public string DownloadExpressEAMImageTOPDF(CourierPieceDetail pieceDetails, int totalPiece, int count, int ExpressShipmentid, HubService Carrier)
        {
            string Image = string.Empty;

            if (pieceDetails.ImageUrl != null)
            {
                string labelName = string.Empty;
                labelName = Carrier.HubCarrier;

                // Create a file to write to.
                if (pieceDetails.ImageUrl.Contains(".html"))
                {
                    Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".html";
                }
                else
                {
                    Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".pdf";
                }

                if (AppSettings.LabelSave == "")
                {
                    if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/"))
                    {
                        var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image;
                        try
                        {
                            bool      status = false;
                            WebClient client = new WebClient();
                            client.UseDefaultCredentials         = true;
                            client.Credentials                   = CredentialCache.DefaultCredentials;
                            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                            SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                            SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                            ServicePointManager.SecurityProtocol = Tls12;
                            client.DownloadFile(pieceDetails.ImageUrl, path1);
                            status = File.Exists(path1);

                            if (status)
                            {
                                return(Image);
                            }
                            else
                            {
                                Image = string.Empty;
                            }
                        }
                        catch (Exception ex)
                        {
                            Image = string.Empty;
                        }
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/");
                        var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image;
                        try
                        {
                            bool      status = false;
                            WebClient client = new WebClient();
                            client.UseDefaultCredentials         = true;
                            client.Credentials                   = CredentialCache.DefaultCredentials;
                            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                            SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                            SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                            ServicePointManager.SecurityProtocol = Tls12;
                            client.DownloadFile(pieceDetails.ImageUrl, path1);
                            status = File.Exists(path1);

                            if (status)
                            {
                                return(Image);
                            }
                            else
                            {
                                Image = string.Empty;
                            }
                        }
                        catch (Exception ex)
                        {
                            Image = string.Empty;
                        }
                    }
                }
                else
                {
                    if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/"))
                    {
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte);
                            var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image;
                            try
                            {
                                bool      status = false;
                                WebClient client = new WebClient();
                                client.UseDefaultCredentials         = true;
                                client.Credentials                   = CredentialCache.DefaultCredentials;
                                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                                SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                                SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                                ServicePointManager.SecurityProtocol = Tls12;
                                client.DownloadFile(pieceDetails.ImageUrl, path1);
                                status = File.Exists(path1);

                                if (status)
                                {
                                    return(Image);
                                }
                                else
                                {
                                    Image = string.Empty;
                                }
                            }
                            catch (Exception ex)
                            {
                                Image = string.Empty;
                            }
                        }
                        else
                        {
                            string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image);
                            File.WriteAllText(path, pieceDetails.ImageByte);
                        }
                    }
                    else
                    {
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid);
                            var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image;
                            try
                            {
                                bool      status = false;
                                WebClient client = new WebClient();
                                client.UseDefaultCredentials         = true;
                                client.Credentials                   = CredentialCache.DefaultCredentials;
                                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                                SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                                SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                                ServicePointManager.SecurityProtocol = Tls12;
                                client.DownloadFile(pieceDetails.ImageUrl, path1);
                                status = File.Exists(path1);

                                if (status)
                                {
                                    return(Image);
                                }
                                else
                                {
                                    Image = string.Empty;
                                }
                            }
                            catch (Exception ex)
                            {
                                Image = string.Empty;
                            }
                        }
                        else
                        {
                            System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid));
                            string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image);
                            try
                            {
                                bool      status = false;
                                WebClient client = new WebClient();
                                client.UseDefaultCredentials         = true;
                                client.Credentials                   = CredentialCache.DefaultCredentials;
                                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                                SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                                SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                                ServicePointManager.SecurityProtocol = Tls12;
                                client.DownloadFile(pieceDetails.ImageUrl, path);
                                status = File.Exists(path);

                                if (status)
                                {
                                    return(Image);
                                }
                                else
                                {
                                    Image = string.Empty;
                                }
                            }
                            catch (Exception ex)
                            {
                                Image = string.Empty;
                            }
                        }
                    }
                }
            }
            return(Image);
        }