예제 #1
0
        /// <summary>
        /// 下载MediaUtils中的单个文件
        /// </summary>
        /// <param name="dir">存放路径</param>
        /// <param name="fileName">文件名</param>
        /// <param name="session"></param>
        /// <returns></returns>
        private static OperationReturn DownloadMediaUtilFile(string dir, string fileName, SessionInfo session)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                string         strSavePath = Path.Combine(dir, fileName);
                DownloadConfig config      = new DownloadConfig();
                config.Method      = session.AppServerInfo.SupportHttps ? 2 : 1;
                config.Host        = session.AppServerInfo.Address;
                config.Port        = session.AppServerInfo.Port;
                config.IsAnonymous = true;
                config.RequestPath = string.Format("{0}/{1}", ConstValue.TEMP_DIR_MEDIAUTILS, fileName);
                config.SavePath    = strSavePath;
                optReturn          = DownloadHelper.DownloadFile(config);
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
            }
            catch (Exception ex)
            {
                optReturn.Result    = false;
                optReturn.Code      = Defines.RET_FAIL;
                optReturn.Message   = ex.Message;
                optReturn.Exception = ex;
            }
            return(optReturn);
        }
예제 #2
0
    public static DownloadHelper StartDownload(MonoBehaviour monoBehavior, List <string> urlList, bool bRemote, List <string> fileSavePathList, DelegateDownloadFinish delFun = null)
    {
        DownloadHelper helper = new DownloadHelper(urlList, bRemote, fileSavePathList, delFun);

        monoBehavior.StartCoroutine(helper.DownloadFile(monoBehavior));
        return(helper);
    }
예제 #3
0
        public void ExportToExcel(HttpContext context)
        {
            MemberQuery dataQuery  = this.GetDataQuery(context);
            string      safeIDList = Globals.GetSafeIDList(base.GetParameter(context, "Ids", false), ',', true);
            IList <PointMemberModel> pointMembersNoPage = MemberHelper.GetPointMembersNoPage(dataQuery, safeIDList);
            StringBuilder            stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>用户积分</th>");
            stringBuilder.Append("<th>历史积分</th>");
            stringBuilder.Append("<th>会员等级</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (PointMemberModel item in pointMembersNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Points, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.HistoryPoint, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.GradeName, true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "MemberPointList" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (currentAv != null)
            {
                currentAv.Actress     = txtActress.Text.Replace("[", "").Replace("]", "");
                currentAv.Category    = txtCategory.Text.Replace("[", "").Replace("]", "");
                currentAv.Company     = txtCompany.Text.Replace("[", "").Replace("]", "");
                currentAv.Publisher   = txtPublisher.Text.Replace("[", "").Replace("]", "");
                currentAv.ReleaseDate = DateTime.Parse(txtDate.Text);

                if (currentAv.ReleaseDate == DateTime.MinValue)
                {
                    currentAv.ReleaseDate = new DateTime(2050, 1, 1);
                }

                if (!File.Exists(imgFolder + currentAv.ID + currentAv.Name + ".jpg"))
                {
                    DownloadHelper.DownloadFile(currentAv.PictureURL, imgFolder + currentAv.ID + currentAv.Name + ".jpg");
                }

                if (!JavDataBaseManager.HasAv(currentAv.ID, currentAv.Name))
                {
                    JavDataBaseManager.InsertAV(currentAv);
                }

                tx.Text           = currentAv.ID.ToUpper();
                this.DialogResult = DialogResult.Yes;
                this.Close();
            }
        }
예제 #5
0
        public void ExportToExcel(HttpContext context)
        {
            int value = base.GetIntParam(context, "UserId", false).Value;
            IList <PointDetailInfo> userPointsNoPage = MemberHelper.GetUserPointsNoPage(value, base.GetIntParam(context, "TradeType", true).ToString());
            StringBuilder           stringBuilder    = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>积分来源</th>");
            stringBuilder.Append("<th>积分变化</th>");
            stringBuilder.Append("<th>可用积分余额</th>");
            stringBuilder.Append("<th>备注</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (PointDetailInfo item in userPointsNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.TradeTypeName, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.Increased > 0) ? ("+" + item.Increased) : ("-" + item.Reduced), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Points, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Remark, true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "PointDetail" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #6
0
        public async Task LoadOrUpdate()
        {
            Task updateTask = null;

            lock (_lock)
            {
                if (_updateTask == null)
                {
                    updateTask = _updateTask = Task.Run(async() =>
                    {
                        try
                        {
                            try
                            {
                                //this resource contains species stats that we need
                                await DownloadHelper.DownloadFile(
                                    @"https://raw.githubusercontent.com/cadon/ARKStatsExtractor/master/ARKBreedingStats/json/values.json",
                                    _speciesstatsFileName,
                                    true,
                                    TimeSpan.FromDays(1)
                                    );
                            }
                            catch { /*ignore exceptions */ }


                            //even if download failed try with local file if it exists
                            if (File.Exists(_speciesstatsFileName))
                            {
                                using (var reader = new StreamReader(_speciesstatsFileName))
                                {
                                    var json = await reader.ReadToEndAsync();
                                    var data = JsonConvert.DeserializeObject <ArkSpeciesStatsData>(json);
                                    if (data != null)
                                    {
                                        Data = data;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogException($"Error when attempting to read {_speciesstatsFileName}", ex, typeof(ArkSpeciesStats), LogLevel.ERROR, ExceptionLevel.Ignored);
                        }
                        finally
                        {
                            lock (_lock)
                            {
                                _updateTask = null;
                            }
                        }
                    });
                }
                else
                {
                    updateTask = _updateTask;
                }
            }

            await updateTask;
        }
예제 #7
0
        private OperationReturn DownloadImage(string file)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                string requestPath = Path.Combine(ConstValue.TEMP_DIR_MEDIADATA, file);
                string savePath    = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstValue.TEMP_DIR_MEDIADATA,
                                                  file);
                DownloadConfig config = new DownloadConfig();
                config.Method      = 1;
                config.Host        = "192.168.6.15";
                config.Port        = 8081;
                config.IsAnonymous = true;
                config.RequestPath = requestPath;
                config.SavePath    = savePath;
                config.IsReplace   = true;
                optReturn          = DownloadHelper.DownloadFile(config);
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                optReturn.Data = savePath;
            }
            catch (Exception ex)
            {
                optReturn.Result    = false;
                optReturn.Code      = Defines.RET_FAIL;
                optReturn.Message   = ex.Message;
                optReturn.Exception = ex;
            }
            return(optReturn);
        }
예제 #8
0
        public void ExportToExcel(HttpContext context)
        {
            BalanceStatisticsQuery          dataQuery = this.GetDataQuery(context);
            IList <SupplierSettlementModel> balanceStatisticsExportData = BalanceHelper.GetBalanceStatisticsExportData(dataQuery);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("<th>联系电话</th>");
            stringBuilder.Append("<th>可提现金额</th>");
            stringBuilder.Append("<th>已冻结提现</th>");
            stringBuilder.Append("<th>已提现总额</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (SupplierSettlementModel item in balanceStatisticsExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SupplierName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Tel, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.CanDrawRequestBalance.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.FrozenBalance.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.BalanceOut.F2ToString("f2"), false));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SupplierSettlement" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #9
0
        /// <summary>
        /// 流下载
        /// </summary>
        /// <param name="context">HttpContext</param>
        /// <remarks>作者:dfq 时间:2016-05-18</remarks>
        private void Dowmload(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string path = context.Request["FilePath"];
            string name = context.Request["FileName"];

            DownloadHelper.DownloadFile(path, name);
        }
예제 #10
0
        public void ExportToExcel(HttpContext context)
        {
            StoresQuery         dataQuery       = this.GetDataQuery(context);
            IList <StoresModel> storeExportData = ManagerHelper.GetStoreExportData(dataQuery);
            StringBuilder       stringBuilder   = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>门店名称</th>");
            stringBuilder.Append("<th>抽佣比例</th>");
            stringBuilder.Append("<th>用户名</th>");
            stringBuilder.Append("<th>联系人</th>");
            stringBuilder.Append("<th>联系电话</th>");
            stringBuilder.Append("<th>所在区域</th>");
            stringBuilder.Append("<th>详细地址</th>");
            stringBuilder.Append("<th>门店标签</th>");
            stringBuilder.Append("<th>配送方式</th>");
            stringBuilder.Append("<th>营业时间</th>");
            stringBuilder.Append("<th>门店LOGO</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();
            DateTime      dateTime;

            foreach (StoresModel item in storeExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.StoreName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.CommissionRate + "%", false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ContactMan, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Tel, false));
                string fullRegion = RegionHelper.GetFullRegion(item.RegionId, " ", true, 0);
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(fullRegion, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(fullRegion + " " + item.Address, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.TagsName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.DeliveryTypes, true));
                StringBuilder stringBuilder3 = stringBuilder2;
                dateTime = item.OpenStartDate;
                string str = dateTime.ToString("HH:mm:ss");
                dateTime = item.OpenEndDate;
                stringBuilder3.Append(ExcelHelper.GetXLSFieldsTD(str + "-" + dateTime.ToString("HH:mm:ss"), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(Globals.FullPath(item.StoreImages), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            HttpResponse  response       = context.Response;
            StringBuilder stringBuilder4 = stringWriter.GetStringBuilder();

            dateTime = DateTime.Now;
            DownloadHelper.DownloadFile(response, stringBuilder4, "StoreList" + dateTime.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #11
0
        public void ExportToExcel(HttpContext context)
        {
            ReturnsApplyQuery returnsApplyQuery = new ReturnsApplyQuery();

            returnsApplyQuery.ReturnIds    = context.Request["Ids"].ToNullString();
            returnsApplyQuery.SupplierId   = 0;
            returnsApplyQuery.OrderId      = Globals.UrlDecode(context.Request["OrderId"]);
            returnsApplyQuery.HandleStatus = base.GetIntParam(context, "HandleStatus", true);
            returnsApplyQuery.SortBy       = "ApplyForTime";
            returnsApplyQuery.SortOrder    = SortAction.Desc;
            IList <ReturnInfo> returnApplysNoPage = OrderHelper.GetReturnApplysNoPage(returnsApplyQuery);
            StringBuilder      stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>编号</th>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>匹配门店</th>");
            stringBuilder.Append("<th>处理状态</th>");
            stringBuilder.Append("<th>退款/退货原因</th>");
            stringBuilder.Append("<th>退款商品</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>处理时间</th>");
            stringBuilder.Append("<th>退款途径</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (ReturnInfo item in returnApplysNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReturnId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ApplyForTime, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.StoreId.HasValue && item.StoreId.Value > 0) ? DepotHelper.GetStoreNameByStoreId(item.StoreId.Value) : "平台店", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.HandleStatus, 0), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReturnReason, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ShopName + "(" + item.Quantity + ")", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundAmount, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(this.GetHandleTime(item), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.RefundType, 0), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "ReturnApplys" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #12
0
        private void MessageList_OpenFile(object sender, EventArgs e)
        {
            FileListItem fileItem = (FileListItem)sender;

            if (fileItem.File.Data == null)
            {
                EventHandler <FileDownloadedEventArgs> eventDelegate = null;

                eventDelegate = (s, args) =>
                {
                    if (fileItem.File.Downloaded)
                    {
                        if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool"))
                        {
                            Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool");
                        }

                        if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name))
                        {
                            DownloadHelper.DownloadFile(fileItem.File, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool");

                            while (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name))
                            {
                            }
                        }

                        Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name);

                        _parent.DownloadClient.FileDownloaded -= eventDelegate;
                    }
                };
                _parent.DownloadClient.FileDownloaded += eventDelegate;
                _parent.DownloadClient.DownloadQueue.Add(fileItem.File);
            }
            else
            {
                if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool"))
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool");
                }

                if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name))
                {
                    DownloadHelper.DownloadFile(fileItem.File, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool");

                    while (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name))
                    {
                    }
                }

                Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/CRMTool/" + fileItem.File.Name);
            }
        }
예제 #13
0
        public void ExportToExcel(HttpContext context)
        {
            MemberQuery dataQuery = this.GetDataQuery(context);
            IList <Hidistro.Entities.Members.ReferralInfo> referralExportData = MemberHelper.GetReferralExportData(dataQuery);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>分销员</th>");
            stringBuilder.Append("<th>真实姓名</th>");
            stringBuilder.Append("<th>电话号码</th>");
            stringBuilder.Append("<th>邮箱</th>");
            stringBuilder.Append("<th>店铺名称</th>");
            stringBuilder.Append("<th>分销员等级</th>");
            stringBuilder.Append("<th>直接下级数</th>");
            stringBuilder.Append("<th>直接下级成交额</th>");
            stringBuilder.Append("<th>累计获得佣金</th>");
            stringBuilder.Append("<th>成为分销员时间</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();
            DateTime      dateTime;

            foreach (Hidistro.Entities.Members.ReferralInfo item in referralExportData)
            {
                ReferralExtInfo referralExtInfo = MemberProcessor.GetReferralExtInfo(item.RequetReason);
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(string.IsNullOrEmpty(referralExtInfo.RealName) ? item.RealName : referralExtInfo.RealName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(string.IsNullOrEmpty(referralExtInfo.CellPhone) ? item.CellPhone : referralExtInfo.CellPhone, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(string.IsNullOrEmpty(referralExtInfo.Email) ? item.Email : referralExtInfo.Email, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ShopName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.GradeName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SubNumber, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.LowerSaleTotal.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserAllSplittin.F2ToString("f2"), false));
                StringBuilder stringBuilder3 = stringBuilder2;
                dateTime = item.AuditDate.Value;
                stringBuilder3.Append(ExcelHelper.GetXLSFieldsTD(dateTime.ToString("yyyy-MM-dd HH:mm:ss"), false));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            HttpResponse  response       = context.Response;
            StringBuilder stringBuilder4 = stringWriter.GetStringBuilder();

            dateTime = DateTime.Now;
            DownloadHelper.DownloadFile(response, stringBuilder4, "ReferralList_" + dateTime.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #14
0
 private static bool LoadLinks()
 {
     if (!File.Exists(linksFile))
     {
         DownloadHelper.DownloadFile("PokemonGo.RocketAPI.Console/Resources", Program.path, linksFileName);
     }
     if (File.Exists(linksFile))
     {
         links = JsonConvert.DeserializeObject <Components.HRefLink[]>(File.ReadAllText(linksFile));
         return(true);
     }
     return(false);
 }
예제 #15
0
 private void FiddlerApplicationBeforeRequest(Session oSession)
 {
     if (oSession.url.EndsWith(".mp4") || oSession.url.EndsWith(".avi") ||
         oSession.url.EndsWith("wmv"))
     {
         if (!String.IsNullOrEmpty(_videoList[_currentVideoIndex].DownloadUrl))
         {
             return;
         }
         _view.WebBrowser.Stop();
         _videoList[_currentVideoIndex].DownloadUrl   = "http://" + oSession.url;
         _videoList[_currentVideoIndex].FileExtension = Path.GetExtension(oSession.url).Substring(1);
         _downloadHelper.DownloadFile(_videoList[_currentVideoIndex]);
     }
 }
예제 #16
0
        public static void DownloadActreeAvator()
        {
            int  index        = 1;
            bool contiune     = true;
            var  folderPrefix = @"G:\Github\AllInOneAV\Setting\avator\";
            var  url          = "https://www.javbus.com/actresses/";
            var  cc           = JavBusDownloadHelper.GetJavBusCookie();

            while (contiune)
            {
                var content = HtmlManager.GetHtmlContentViaUrl(url + index++, "utf-8", false, cc);

                if (content.Success)
                {
                    HtmlDocument htmlDocument = new HtmlDocument();
                    htmlDocument.LoadHtml(content.Content);

                    string xpath   = "//a[@class='avatar-box text-center']";
                    string imgPath = "/img";

                    HtmlNodeCollection nodes = htmlDocument.DocumentNode.SelectNodes(xpath);

                    foreach (var node in nodes)
                    {
                        var img = node.ChildNodes[1].ChildNodes[1];

                        var src   = img.Attributes["src"].Value;
                        var title = img.Attributes["title"].Value;

                        if (!string.IsNullOrEmpty(src) && !string.IsNullOrEmpty(title))
                        {
                            var tempFolder = folderPrefix + title[0] + "\\";
                            if (!Directory.Exists(tempFolder))
                            {
                                Directory.CreateDirectory(tempFolder);
                            }

                            DownloadHelper.DownloadFile(src, tempFolder + title + ".jpg");
                            Console.WriteLine($"下载第 {index - 1} 页,{title} 的头像");
                        }
                    }
                }
                else
                {
                    contiune = false;
                }
            }
        }
예제 #17
0
        public void DownloadFile()
        {
            string localPath = DownloadHelper.DownloadFile(
                "http://www.blah.com/hello/world/test.bmp",
                "C:/local/directory",
                new MockDownloader());

            Assert.AreEqual("C:/local/directory/test.bmp", localPath);

            string localPath2 = DownloadHelper.DownloadFile(
                "http://www.blah.com/hello/world/test.bmp",
                "C:/local/directory/",
                new MockDownloader());

            Assert.AreEqual("C:/local/directory/test.bmp", localPath2);
        }
예제 #18
0
        public static string SaveMagnetToTorrent(string magurl, string webUrl, string saveFolder, string fileName)
        {
            string ret = (saveFolder.EndsWith("\\") || saveFolder.EndsWith("/")) ? saveFolder + fileName : saveFolder + "\\" + fileName;

            if (string.IsNullOrEmpty(magurl) || (!magurl.StartsWith("magnet:?xt=") && magurl.Length != 40))
            {
                return(ret);
            }

            try
            {
                if (!Directory.Exists(saveFolder))
                {
                    Directory.CreateDirectory(saveFolder);
                    Thread.Sleep(50);
                }
                else
                {
                    if (File.Exists(ret))
                    {
                        File.Delete(ret);
                        Thread.Sleep(50);
                    }
                }

                File.Create(ret).Close();


                if (magurl.Length == 40)
                {
                    DownloadHelper.DownloadFile(webUrl + magurl + ".torrent", ret);
                }
                else
                {
                    var hash = magurl.Substring(magurl.IndexOf("btih:") + "btih:".Length);
                    hash = hash.Substring(0, hash.IndexOf("&"));

                    DownloadHelper.DownloadFile(webUrl + hash + ".torrent", ret);
                }
            }
            catch (Exception ee)
            {
                ret = "";
            }

            return(ret);
        }
예제 #19
0
        public Guid Use(ApiCall call)
        {
            string SiteName = call.GetValue("SiteName");

            if (!Data.GlobalDb.WebSites.CheckNameAvailable(SiteName, call.Context.User.CurrentOrgId))
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("SiteName is taken", call.Context));
            }

            string RootDomain = call.GetValue("RootDomain");
            string SubDomain  = call.GetValue("SubDomain");

            string FullDomain = RootDomain;

            if (!string.IsNullOrEmpty(SubDomain))
            {
                if (FullDomain.StartsWith("."))
                {
                    FullDomain = SubDomain + FullDomain;
                }
                else
                {
                    FullDomain = SubDomain + "." + FullDomain;
                }
            }

            string downloadcode = call.GetValue("DownloadCode");

            string url = UrlHelper.Combine(AppSettings.ThemeUrl, "/_api/download/package/" + downloadcode);

            if (call.Context.User != null)
            {
                url += "?userid=" + call.Context.User.Id.ToString();
            }

            var download = DownloadHelper.DownloadFile(url, "zip");

            if (download == null)
            {
                throw new Exception(Data.Language.Hardcoded.GetValue("template package not found", call.Context));
            }

            MemoryStream memory  = new MemoryStream(download);
            var          newsite = ImportExport.ImportZip(memory, call.Context.User.CurrentOrgId, SiteName, FullDomain, call.Context.User.Id);

            return(newsite.Id);
        }
예제 #20
0
        public void ExportToExcel(HttpContext context)
        {
            RefundApplyQuery dataQuery = this.GetDataQuery(context);

            dataQuery.RefundIds = context.Request["Ids"].ToNullString();
            IList <RefundModel> refundApplysNoPage = OrderHelper.GetRefundApplysNoPage(dataQuery);
            StringBuilder       stringBuilder      = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>编号</th>");
            stringBuilder.Append("<th>会员名</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>供应商</th>");
            stringBuilder.Append("<th>处理状态</th>");
            stringBuilder.Append("<th>退款原因</th>");
            stringBuilder.Append("<th>退款金额</th>");
            stringBuilder.Append("<th>处理时间</th>");
            stringBuilder.Append("<th>退款途径</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (RefundModel item in refundApplysNoPage)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ApplyForTime, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD((item.SupplierId > 0) ? SupplierHelper.GetSupplierName(item.SupplierId) : "平台店", true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.HandleStatus, 0), true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundReason, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.RefundAmount, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.GetDealTime, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(EnumDescription.GetEnumDescription((Enum)(object)item.RefundType, 0), true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SupplierRefundApplys" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #21
0
        private void MessageList_DownloadFile(object sender, EventArgs e)
        {
            FileListItem fileItem = (FileListItem)sender;

            if (fileItem.File.Data == null)
            {
                EventHandler <FileDownloadedEventArgs> eventDelegate = null;

                eventDelegate = (s, args) =>
                {
                    if (fileItem.File.Downloaded)
                    {
                        if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool"))
                        {
                            Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool");
                        }

                        DownloadHelper.DownloadFile(fileItem.File, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool");

                        _parent.RaiseNotification(new NotificationModel("", "", null,
                                                                        DateTime.Now, false, true)
                        {
                            Text = "Plik został pobrany"
                        });
                    }
                };
                _parent.DownloadClient.FileDownloaded += eventDelegate;
                _parent.DownloadClient.DownloadQueue.Add(fileItem.File);
            }
            else
            {
                if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool"))
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool");
                }

                DownloadHelper.DownloadFile(fileItem.File, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/CRMTool");

                _parent.RaiseNotification(new NotificationModel("", "", null,
                                                                DateTime.Now, false, true)
                {
                    Text = "Plik został pobrany"
                });
            }
        }
예제 #22
0
        private void loadAdditionalPokeData()
        {
            const string remotepath = "PokemonGo.RocketAPI.Console/PokeData";
            const string localpath  = "Configs";
            const string filename   = "AdditionalPokeData.json";

            try {
                DownloadHelper.DownloadFile(remotepath, localpath, filename);
                var localpath_with_filename = Path.Combine(localpath, filename);
                if (File.Exists(localpath_with_filename))
                {
                    var jsonData = File.ReadAllText(localpath_with_filename);
                    additionalPokeData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <AdditionalPokeData> >(jsonData);
                }
            } catch (Exception ex1) {
                Logger.ExceptionInfo(ex1.ToString());
            }
        }
        public void HistoryExportToExcel(HttpContext context)
        {
            int value = base.GetIntParam(context, "UserId", false).Value;
            BalanceDrawRequestQuery        balanceDrawRequestQuery = this.GetBalanceDrawRequestQuery(context);
            IList <CommissionRequestModel> splittinDrawsExportData = MemberHelper.GetSplittinDrawsExportData(balanceDrawRequestQuery, balanceDrawRequestQuery.AuditStatus);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>分销员</th>");
            stringBuilder.Append("<th>申请时间</th>");
            stringBuilder.Append("<th>提现金额</th>");
            stringBuilder.Append("<th>操作人</th>");
            stringBuilder.Append("<th>备注</th>");
            stringBuilder.Append("<th>提现账号信息</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();
            DateTime      dateTime;

            foreach (CommissionRequestModel item in splittinDrawsExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReferralUserName, true));
                StringBuilder stringBuilder3 = stringBuilder2;
                dateTime = item.RequestDate;
                stringBuilder3.Append(ExcelHelper.GetXLSFieldsTD(dateTime.ToString("yyyy-MM-dd HH:mm:ss"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Amount.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ManagerUserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Remark, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.AccountInfo, true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            HttpResponse  response       = context.Response;
            StringBuilder stringBuilder4 = stringWriter.GetStringBuilder();

            dateTime = DateTime.Now;
            DownloadHelper.DownloadFile(response, stringBuilder4, "SplittinDraws" + dateTime.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #24
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (av != null)
            {
                if (!JavDataBaseManager.HasAv(av.URL))
                {
                    JavDataBaseManager.InsertAV(av);
                }

                string result = "";
                if (!File.Exists(imgFolder + av.ID + av.Name + ".jpg"))
                {
                    result = DownloadHelper.DownloadFile(av.PictureURL, imgFolder + av.ID + av.Name + ".jpg");
                }

                this.DialogResult = DialogResult.Yes;
                this.Close();
            }
        }
예제 #25
0
        public void ExportToExcel(HttpContext context)
        {
            int                    value               = base.GetIntParam(context, "UserId", false).Value;
            MemberQuery            dataQuery           = this.GetDataQuery(context);
            IList <SubMemberModel> subMemberExportData = MemberHelper.GetSubMemberExportData(dataQuery, value);
            StringBuilder          stringBuilder       = new StringBuilder();
            MemberInfo             user = Users.GetUser(value);

            if (user != null)
            {
                stringBuilder.Append("<table border='1'>");
                stringBuilder.Append("<thead><tr>");
                stringBuilder.Append("<th>分销员</th>");
                stringBuilder.Append("<th>下级会员</th>");
                stringBuilder.Append("<th>注册时间</th>");
                stringBuilder.Append("<th>累计消费金额</th>");
                stringBuilder.Append("<th>获得佣金(含未结)</th>");
                stringBuilder.Append("</tr></thead>");
                StringBuilder stringBuilder2 = new StringBuilder();
                DateTime      dateTime;
                foreach (SubMemberModel item in subMemberExportData)
                {
                    stringBuilder2.Append("<tr>");
                    stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(user.UserName, false));
                    stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SubUserName, false));
                    StringBuilder stringBuilder3 = stringBuilder2;
                    dateTime = item.RegisterTime;
                    stringBuilder3.Append(ExcelHelper.GetXLSFieldsTD(dateTime.ToString("yyyy-MM-dd HH:mm:ss"), false));
                    stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ConsumeTotal.F2ToString("f2"), false));
                    stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.CommissionTotal.F2ToString("f2"), false));
                    stringBuilder2.Append("</tr>");
                }
                stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
                StringWriter stringWriter = new StringWriter();
                stringWriter.Write(stringBuilder);
                HttpResponse  response       = context.Response;
                StringBuilder stringBuilder4 = stringWriter.GetStringBuilder();
                dateTime = DateTime.Now;
                DownloadHelper.DownloadFile(response, stringBuilder4, "ReferralLowers" + dateTime.ToString("yyyyMMddhhmmss") + ".xls");
                stringWriter.Close();
                context.Response.End();
            }
        }
예제 #26
0
        private async Task <TValue> DownloadResource <TValue>(string url, string path, bool skipDownload = false) where TValue : class
        {
            try
            {
                if (!skipDownload)
                {
                    try
                    {
                        //this resource contains species stats that we need
                        await DownloadHelper.DownloadFile(
                            url,
                            path,
                            true,
                            TimeSpan.FromDays(1)
                            );
                    }
                    catch (Exception ex)
                    {
                        /*ignore exceptions */
                        Logging.LogException($"Error downloading {url}", ex, typeof(ArkSpeciesStats), LogLevel.WARN, ExceptionLevel.Ignored);
                    }
                }

                //even if download failed try with local file if it exists
                if (File.Exists(path))
                {
                    using (var reader = new StreamReader(path))
                    {
                        var json = await reader.ReadToEndAsync();

                        var data = JsonConvert.DeserializeObject <TValue>(json);
                        return(data);
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.LogException($"Error when attempting to read {path}", ex, typeof(ArkSpeciesStats), LogLevel.ERROR, ExceptionLevel.Ignored);
            }

            return(null);
        }
예제 #27
0
        private async void btnDownload_Click(object sender, EventArgs e)
        {
            InputDialog dialog = new InputDialog("Enter the direct URL to the mod:", "Download URL");

            dialog.ShowDialog();
            if (dialog.DialogResult == DialogResult.OK)
            {
                try
                {
                    string url = dialog.InputText;
                    await downloadHelper.DownloadFile(tfDirectory, url);

                    await Task.Delay(5000);
                } catch (Exception ex)
                {
                    MessageBox.Show("The mod couldn't be downloaded:\n" + ex.Message, "Download failed");
                }

                ReloadModlist();
            }
        }
예제 #28
0
 void DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (ReleaseFile file in _diff)
     {
         try
         {
             DownloadHelper.DownloadFile(
                 _tempDir,
                 _remoteRelease.ReleaseUrl + "/" + _remoteRelease.ReleaseVersion,
                 file.FileName,
                 _worker,
                 _totalSize,
                 ref _downloadedSize);
         }
         catch
         {
             e.Result = file.FileName;
             throw;
         }
     }
 }
예제 #29
0
        public void ExportToExcel(HttpContext context)
        {
            SupplierQuery dataQuery = this.GetDataQuery(context);
            IList <SupplierExportModel> supplierExportData = SupplierHelper.GetSupplierExportData(dataQuery);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>用户名</th>");
            stringBuilder.Append("<th>供应商名称</th>");
            stringBuilder.Append("<th>联系人</th>");
            stringBuilder.Append("<th>联系电话</th>");
            stringBuilder.Append("<th>上架商品数</th>");
            stringBuilder.Append("<th>订单数</th>");
            stringBuilder.Append("<th>状态</th>");
            stringBuilder.Append("<th>详细地址</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (SupplierExportModel item in supplierExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.UserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SupplierName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ContactMan, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Tel, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ProductNums, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderNums, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.StatusText, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(RegionHelper.GetFullRegion(item.RegionId, " ", true, 0) + " " + item.Address, true));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SupplierList" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }
예제 #30
0
        public void ExportToExcel(HttpContext context)
        {
            BalanceDetailQuery            dataQuery = this.GetDataQuery(context);
            IList <CommissionDetailModel> splittinDetailsExportData = MemberHelper.GetSplittinDetailsExportData(dataQuery);
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<table border='1'>");
            stringBuilder.Append("<thead><tr>");
            stringBuilder.Append("<th>分销员</th>");
            stringBuilder.Append("<th>订单编号</th>");
            stringBuilder.Append("<th>会员</th>");
            stringBuilder.Append("<th>支付时间</th>");
            stringBuilder.Append("<th>佣金结算时间</th>");
            stringBuilder.Append("<th>订单金额</th>");
            stringBuilder.Append("<th>佣金</th>");
            stringBuilder.Append("<th>佣金类型</th>");
            stringBuilder.Append("</tr></thead>");
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (CommissionDetailModel item in splittinDetailsExportData)
            {
                stringBuilder2.Append("<tr>");
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.ReferalUserName, true));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderId, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.FromUserName, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.TradeDateStr, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.FinishDateStr, false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.OrderTotal.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.Commission.F2ToString("f2"), false));
                stringBuilder2.Append(ExcelHelper.GetXLSFieldsTD(item.SplittingTypeText, false));
                stringBuilder2.Append("</tr>");
            }
            stringBuilder.AppendFormat("<tbody>{0}</tbody></table>", stringBuilder2.ToString());
            StringWriter stringWriter = new StringWriter();

            stringWriter.Write(stringBuilder);
            DownloadHelper.DownloadFile(context.Response, stringWriter.GetStringBuilder(), "SplittinDetail" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
            stringWriter.Close();
            context.Response.End();
        }