Esempio n. 1
0
        static void Main(string[] args)
        {
            logger.Info("-------------Starting NAV Download-------------");

            DownloadLogVo downloadLogVo = new DownloadLogVo();

            downloadLogVo.ID = DownloadLog.Add();

            if (downloadLogVo.ID > 0)
            {
                HttpDownLoad dn = new HttpDownLoad();
                DownloadTask dt = new DownloadTask(TaskType.MutualFund);
                if (dn.ExecuteDownLoadTask(dt, downloadLogVo))
                {
                    NAVUpload navUpload = new NAVUpload();
                    navUpload.CopyDataToWERPTempTable();
                    navUpload.UpdateWERPSchemeCode();
                    downloadLogVo.RejectedSchemesCount = navUpload.MoveRejectedRecords(downloadLogVo.ID);
                    DownloadLog.Update(downloadLogVo);
                    downloadLogVo.UpdatedSchemesCount      = navUpload.UpdateSnapshot();
                    downloadLogVo.Is_WERP_Snapshot_Updated = true;
                    DownloadLog.Update(downloadLogVo);
                    //navUpload.UpdateHistoryTable();
                }
            }
            logger.Info("-------------NAV Update Ends-------------");
        }
Esempio n. 2
0
        public override JobStatus Start(JobParams JP, out string ErrorMsg)
        {
            ErrorMsg = "";
            logger.Info("-------------Starting NAV Download-------------");

            DownloadLogVo downloadLogVo = new DownloadLogVo();

            downloadLogVo.ID = DownloadLog.Add();

            if (downloadLogVo.ID > 0)
            {
                HttpDownLoad dn = new HttpDownLoad();
                DownloadTask dt = new DownloadTask(TaskType.MutualFund);
                if (dn.ExecuteDownLoadTask(dt, downloadLogVo))
                {
                    NAVUpload navUpload = new NAVUpload();
                    navUpload.CopyDataToWERPTempTable();
                    navUpload.UpdateWERPSchemeCode();
                    downloadLogVo.RejectedSchemesCount = navUpload.MoveRejectedRecords(downloadLogVo.ID);
                    DownloadLog.Update(downloadLogVo);
                    downloadLogVo.UpdatedSchemesCount      = navUpload.UpdateSnapshot();
                    downloadLogVo.Is_WERP_Snapshot_Updated = true;
                    DownloadLog.Update(downloadLogVo);
                    //navUpload.UpdateHistoryTable();
                }
            }
            logger.Info("-------------NAV Update Ends-------------");

            return(JobStatus.SuccessFull);
        }
Esempio n. 3
0
            public static DownloadLog GetDownloadData(string gardenID, string className, int rev)
            {
                DownloadLog log = null;
                var         rq  = WebRequest.Create("http://cz.aixyh.com/chuangzhi/api/ReportAction_getTyList") as HttpWebRequest;

                rq.Method      = "POST";
                rq.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36";
                rq.ContentType = "application/x-www-form-urlencoded";
                var data = Encoding.UTF8.GetBytes(string.Format("gardenID={0}&className={1}&lastupttime={2}", gardenID, className, rev));

                using (var rqStream = rq.GetRequestStream())
                {
                    rqStream.Write(data, 0, data.Length);
                }
                using (var rs = rq.GetResponse() as HttpWebResponse)
                {
                    using (var reader = new StreamReader(rs.GetResponseStream()))
                    {
                        var content = reader.ReadToEnd();
                        log     = JsonConvert.DeserializeObject <DownloadLog>(content);
                        log.Raw = content;
                        if (log.result != null)
                        {
                            log.lastupttime = log.result.lastupttime;
                        }
                    }
                }

                return(log);
            }
Esempio n. 4
0
        /// <summary>
        /// 添加下载记录
        /// </summary>
        public async Task <DownloadLog> CreateDownloadLogAsync(DownloadLog model)
        {
            model.Init();
            await DownloadLogRepository.AddAsync(model);

            return(model);
        }
Esempio n. 5
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public ActionResult Download(string guid, string token = "")
        {
            using (ClientProxyFileServer proxy = new ClientProxyFileServer(ProxyEx(Request)))
            {
                //var tokenResult = proxy.CheckToken(token);
                //if (string.IsNullOrEmpty(tokenResult.Data))
                //{
                //    return Content("文件下载授权验证失败,请勿非法操作");
                //}
                var model = proxy.DownloadFile(guid);
                if (model.Data == null)
                {
                    return(Content("没有找到该文件"));
                }
                DownloadLog log = new DownloadLog();

                log.IP         = Request.UserHostAddress;
                log.Browser    = Request.Browser.Browser;
                log.FileGuid   = guid;
                log.FileName   = model.Data.Name;
                log.RecordTime = DateTime.Now;
                proxy.AddDownloadLog(log);
                //执行下载
                string contentType = GetContentTypeByFileName(model.Data.FilePath);
                string name        = model.Data.Name;
                //无后缀的文件处理
                string ext = Path.GetExtension(name);
                if (string.IsNullOrEmpty(ext))
                {
                    ext  = Path.GetExtension(model.Data.FilePath);
                    name = name + ext;
                }
                return(File(model.Data.FilePath, contentType, name));
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> PutDownloadLog(Guid id, DownloadLog downloadLog)
        {
            if (id != downloadLog.Id)
            {
                return(BadRequest());
            }

            _context.Entry(downloadLog).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DownloadLogExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
        public async Task <ActionResult <DownloadLog> > PostDownloadLog(DownloadLog downloadLog)
        {
            _context.DownloadLogs.Add(downloadLog);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDownloadLog", new { id = downloadLog.Id }, downloadLog));
        }
        /// <summary>
        /// Writes the information about the selected files to the local download list.
        /// </summary>
        public void WriteToDownloadLogFile(DownloadLog downloadLog)
        {
            var serializer = new JsonSerializer();

            serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;

            using (var w = new StreamWriter(applicationService.GetDownloadLogFilePath()))
            {
                w.WriteLine("SELECTED FILES: " + downloadLog.TotalDatasetsToDownload);
                w.WriteLine("-------------------------------");
                w.WriteLine();

                w.WriteLine("UPDATED: " + downloadLog.Updated.Count() + " TOTAL SIZE: " + downloadLog.TotalSizeOfDownloadedFiles);
                Log(downloadLog.Updated, w);

                w.WriteLine();

                w.WriteLine("NOT UPDATED: " + downloadLog.NotUpdated.Count());
                Log(downloadLog.NotUpdated, w);

                w.WriteLine();

                w.WriteLine("FAILED: " + downloadLog.Faild.Count());
                Log(downloadLog.Faild, w);
            }
        }
Esempio n. 9
0
        public void AddLog(int appId, String versionNumber)
        {
            DownloadLog log = new DownloadLog {
                app_id = appId, app_version = versionNumber, hits = 1, time_range = GenerateRange()
            };

            _clickDB.ExecuteNonQuery("insert into download_logs values(" + log.app_id + ",'" + log.app_version + "','" + log.time_range + "'," + log.hits + ")");
        }
Esempio n. 10
0
 /// <summary>
 /// 转换为下载记录数据传输对象
 /// </summary>
 /// <param name="entity">下载记录实体</param>
 public static DownloadLogDto ToDto(this DownloadLog entity)
 {
     if (entity == null)
     {
         return(new DownloadLogDto());
     }
     return(entity.MapTo <DownloadLogDto>());
 }
Esempio n. 11
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns>返回:该条数据的主键Id</returns>
        public int Insert(DownloadLog obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "DownloadLog.Insert";

            return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj));
        }
        public async Task LogDownload(int id)
        {
            var downloadLog = new DownloadLog
            {
                Date       = DateTime.UtcNow,
                DownloadId = id
            };

            await _downloadLogRepository.Log(downloadLog);
        }
Esempio n. 13
0
        /// <summary>
        /// To get logs with task id
        /// </summary>
        /// <param name="taskId">
        /// it is a task id
        /// </param>
        /// <returns>
        /// a string
        /// </returns>
        public string GetLog(int taskId)
        {
            var downloadLog = new DownloadLog();

            downloadLog.BusinessCredentials = new BusinessInfo {
                LicenseKey = AgentSetting.LicenseId
            };
            downloadLog.TaskId = taskId;
            downloadLog.Request(null);
            return(downloadLog.GetTheCallResult());
        }
Esempio n. 14
0
        public string DownloadProcessLog(string downloadPath)
        {
            LogHelpers.Write(string.Format("Click \"Download log\" button."));
            DownloadLog.ClickJS();
            Waits.WaitDownloadDocument();
            //check if there is some window or something
            var directory = new DirectoryInfo(downloadPath);
            var myFile    = directory.GetFiles().Where(f => !f.Attributes.HasFlag(FileAttributes.Hidden)).OrderByDescending(f => f.LastWriteTime).First();

            return(myFile.FullName);
        }
Esempio n. 15
0
        public async Task Log(DownloadLog downloadLog)
        {
            await _context.DownloadLogs.AddAsync(downloadLog);

            var download = await _context.Downloads.FindAsync(downloadLog.DownloadId);

            download.AmountOfDownloads += 1;
            _context.Downloads.Update(download);

            await _context.SaveChangesAsync();
        }
Esempio n. 16
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>返回:ture 成功,false 失败</returns>
        public bool Update(DownloadLog obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "DownloadLog.Update";
            int    result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj);

            return(result > 0 ? true : false);
        }
Esempio n. 17
0
        public async Task <ActionResult <DownloadLog> > PostDownloadLog(DownloadLog downloadLog)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _context.DownloadLogs.Add(downloadLog);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDownloadLog", new { id = downloadLog.Id }, downloadLog));
        }
 public int InsertLog(DownloadLog dl)
 {
     try
     {
         using (var conn = _factory.GetConnection())
         {
             return(conn.Insert(dl));
         }
     }
     catch (Exception)
     {
         return(0);
     }
 }
Esempio n. 19
0
        /// <summary>
        /// 匹配下载记录 设置推荐人
        /// </summary>
        private async Task SetDownloadLog(Member model)
        {
            if (model.AgentId.HasValue || string.IsNullOrWhiteSpace(model.IPAddress))
            {
                return;
            }
            DownloadLog downloadLog = await DownloadLogRepository.GetDownloadLogByIp(model.IPAddress);

            if (downloadLog == null)
            {
                return;
            }
            model.FirstTime = downloadLog.CreationTime.HasValue ? downloadLog.CreationTime.SafeValue() : model.FirstTime;
            model.AgentId   = downloadLog.AgentId;
        }
Esempio n. 20
0
        /// <summary>
        /// 添加文件下载记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Result <DownloadLog> AddDownloadLog(DownloadLog model)
        {
            Result <DownloadLog> result = new Result <DownloadLog>();

            try
            {
                dbContext.DownloadLog.Add(model);
                dbContext.SaveChanges();
                result.Data = model;
                result.Flag = EResultFlag.Success;
            }
            catch (Exception ex)
            {
                result.Data      = null;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "AddDownloadLog");
            }
            return(result);
        }
Esempio n. 21
0
 public static IList<StudentInfo> GetDownloadData(string gardenID, int rev, out DownloadLog log)
 {
     log = null;
     var result = Student.GetStudentList(gardenID, rev);
     var list = new List<StudentInfo>();
     if (!string.IsNullOrEmpty(result))
     {
         log = JsonConvert.DeserializeObject<DownloadLog>(result);
         log.Raw = result;
         if (log != null)
         {
             if (log.result != null && log.result.list != null)
             {
                 foreach (var student in log.result.list)
                     list.Add(StudentInfo.CheckAndGet(student));
             }
         }
     }
     return list;
 }
        /// <summary>
        /// Writes the information about the selected files to the local download list.
        /// </summary>
        public void WriteToDownloadLogFile(DownloadLog downloadLog)
        {
            var serializer = new JsonSerializer();

            serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;
            try
            {
                using (var w = new StreamWriter(ApplicationService.GetDownloadLogFilePath(_configFile.LogDirectory)))
                {
                    w.WriteLine("SELECTED DATASETS: " + downloadLog.TotalDatasetsToDownload);
                    w.WriteLine("-------------------------------");
                    w.WriteLine();

                    w.WriteLine("FILES UPDATED: " + downloadLog.Updated.Count());

                    DownloadLog(downloadLog.Updated, w);

                    w.WriteLine();

                    w.WriteLine("FILES NOT UPDATED: " + downloadLog.NotUpdated.Count());
                    DownloadLog(downloadLog.NotUpdated, w);

                    w.WriteLine();

                    w.WriteLine("FAILED: " + downloadLog.Faild.Count());
                    DownloadLog(downloadLog.Faild, w);

                    Log.Debug("Write to download log file");
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Write to download log file");
            }
        }
Esempio n. 23
0
        public void DownloadDoc(int docId, string valkey)
        {
            CancelLayout();
            CancelView();
            try {
                DocService   ds        = Context.GetService <DocService>();
                U_UserInfo   logonUser = base.GetUser();
                DDocInfo     doc       = ds.DDocInfoBll.Get(docId);
                FileStream   myFile    = null;
                BinaryReader br        = null;
                try
                {
                    #region  载文档前需要经过一系列的权限判断
                    #endregion
                    myFile = new FileStream(doc.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    br     = new BinaryReader(myFile);


                    Context.Response.AppendHeader("Accept-Ranges", "bytes");
                    HttpContext.Current.Response.Buffer = false;
                    //Response.Buffer = false;
                    Int64 fileLength = myFile.Length;
                    Int64 startBytes = 0;

                    Double pack    = 10240;  //10K bytes
                    int    dlSpeed = 512000; //下载速度
                    Int32  sleep   = (Int32)Math.Floor(1000 * pack / dlSpeed) + 1;

                    //if (Request.Headers["Range"] != null)
                    //{
                    //    Response.StatusCode = 206;
                    //    String[] range = Request.Headers["Range"].Split(new Char[] { '=', '-' });
                    //    startBytes = ConvertUtility.ToInt64(range[1]);
                    //}

                    HttpContext.Current.Response.AddHeader("Content-Length", (fileLength - startBytes).ToString());

                    HttpContext.Current.Response.AddHeader("Connection", "Keep-Alive");
                    HttpContext.Current.Response.ContentType = "application/octet-stream";
                    HttpContext.Current.Response.AddHeader(
                        "Content-Disposition",
                        "attachment;filename=" + HttpUtility.UrlEncode(doc.FileName, System.Text.Encoding.UTF8)
                        + "." + doc.DocType
                        );

                    br.BaseStream.Seek(startBytes, SeekOrigin.Begin);
                    Int32 maxCount = (Int32)Math.Floor((fileLength - startBytes) / pack) + 1;

                    for (Int32 i = 0; i < maxCount; i++)
                    {
                        if (Response.IsClientConnected)
                        {
                            Response.BinaryWrite(br.ReadBytes(Convert.ToInt32(pack)));
                            System.Threading.Thread.Sleep(sleep);
                        }
                        else
                        {
                            break;
                        }
                    }
                    //下载成功,写入一条下载日志
                    if (doc.Price == 0 && doc.UserId != logonUser.UserId)
                    {
                        //先判断是否已经写入过下载日志了
                        bool isExistLog = ds.DownloadLogBll.IsExistDownLog(logonUser.UserId, doc.DocId);
                        if (!isExistLog)
                        {
                            DownloadLog downLog = new DownloadLog()
                            {
                                CreateTime = DateTime.Now,
                                DocId      = doc.DocId,
                                UserId     = logonUser.UserId
                            };
                            ds.DownloadLogBll.Insert(downLog);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.Log4Net.Error("file DownloadFile " + ex.ToString());
                    //DoAlert("异常错误 03");
                }
                finally
                {
                    if (br != null)
                    {
                        br.Close();
                    }
                    if (myFile != null)
                    {
                        myFile.Close();
                    }
                }
            }
            catch (Exception ex) {
                Utils.Log4Net.Error(ex);
            }
        }
Esempio n. 24
0
 public static IList<TeacherInfo> GetDownloadData(string gardenID, int rev, out DownloadLog log)
 {
     log = null;
     var result = chuangzhiapi.model.Teacher.GetTeacherList(gardenID, rev);
     var list = new List<TeacherInfo>();
     if (!string.IsNullOrEmpty(result))
     {
         log = JsonConvert.DeserializeObject<DownloadLog>(result);
         log.Raw = result;
         if (log != null)
         {
             if (log.result != null && log.result.list != null)
             {
                 foreach (var teacher in log.result.list)
                 {
                     var @checked = TeacherInfo.CheckAndGet(teacher);
                     if (@checked.IsValid)
                         list.Add(@checked);
                 }
             }
         }
     }
     return list;
 }
 public Result <DownloadLog> AddDownloadLog(DownloadLog model)
 {
     return(base.Channel.AddDownloadLog(model));
 }
Esempio n. 26
0
            public static IList <TeacherInfo> GetDownloadData(string gardenID, int rev, out DownloadLog log)
            {
                log = null;
                var result = chuangzhiapi.model.Teacher.GetTeacherList(gardenID, rev);
                var list   = new List <TeacherInfo>();

                if (!string.IsNullOrEmpty(result))
                {
                    log     = JsonConvert.DeserializeObject <DownloadLog>(result);
                    log.Raw = result;
                    if (log != null)
                    {
                        if (log.result != null && log.result.list != null)
                        {
                            foreach (var teacher in log.result.list)
                            {
                                var @checked = TeacherInfo.CheckAndGet(teacher);
                                if (@checked.IsValid)
                                {
                                    list.Add(@checked);
                                }
                            }
                        }
                    }
                }
                return(list);
            }
Esempio n. 27
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(DownloadLog obj)
 {
     return(dal.Update(obj));
 }
Esempio n. 28
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(DownloadLog obj)
 {
     return(dal.Insert(obj));
 }
Esempio n. 29
0
 /// <summary>
 /// 修改下载记录
 /// </summary>
 public async Task UpdateDownloadLog(DownloadLog model)
 {
     throw new NotImplementedException();
 }
Esempio n. 30
0
            public static IList <StudentInfo> GetDownloadData(string gardenID, int rev, out DownloadLog log)
            {
                log = null;
                var result = Student.GetStudentList(gardenID, rev);
                var list   = new List <StudentInfo>();

                if (!string.IsNullOrEmpty(result))
                {
                    log     = JsonConvert.DeserializeObject <DownloadLog>(result);
                    log.Raw = result;
                    if (log != null)
                    {
                        if (log.result != null && log.result.list != null)
                        {
                            foreach (var student in log.result.list)
                            {
                                list.Add(StudentInfo.CheckAndGet(student));
                            }
                        }
                    }
                }
                return(list);
            }