Esempio n. 1
0
 /// <summary>
 /// 分页查询获取卷宗信息
 /// </summary>
 /// <param name="servDevicePlanQuery"></param>
 /// <param name="pageSize">每页记录数</param>
 /// <param name="pageNumber">当前页码</param>
 /// <param name="totalNumber">共多少条</param>
 /// <returns></returns>
 public List <ArchiveInfo> GetEntities(ServArchiveInfoQuery servArchiveInfoQuery, int pageNumber, int pageSize, out int totalNumber)
 {
     try
     {
         List <ServArchiveInfoModel> archivelist     = new List <ServArchiveInfoModel>();
         List <ArchiveInfo>          archiveInfoList = new List <ArchiveInfo>();
         archivelist = servArchiveInfoDAL.GetEntities(servArchiveInfoQuery, pageNumber, pageSize, out totalNumber);
         ArchiveInfo archiveInfoModel;
         foreach (ServArchiveInfoModel item in archivelist)
         {
             archiveInfoModel                    = new ArchiveInfo();
             archiveInfoModel.id                 = item.id;
             archiveInfoModel.archive_num        = item.archive_num;
             archiveInfoModel.archive_name       = item.archive_name;
             archiveInfoModel.create_time        = item.create_time;
             archiveInfoModel.update_time        = item.update_time;
             archiveInfoModel.archive_decription = item.archive_decription;
             archiveInfoModel.report_person      = item.report_person;
             archiveInfoModel.archive_status     = item.archive_status;
             //获取卷宗类别类型
             var u = baseReportTypeDAL.GetEntity(item.report_type);
             archiveInfoModel.report_name = u == null ? "未知" : u.type_name;
             //创建人
             var a = servPersonInfoDAL.GetPersonInfoBySSOId(item.create_persson_id);
             archiveInfoModel.create_name = a == null ? "未知" : a.alias;
             archiveInfoModel.status_name = Enum.GetName(typeof(EnumClass.ArchiveStatus), item.archive_status);
             archiveInfoList.Add(archiveInfoModel);
         }
         return(archiveInfoList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 public ViewResultBase Details()
 {
     if (!string.IsNullOrEmpty(Request["isTooltip"]))
     {
         Guid id;
         if (Guid.TryParse(Request["id"], out id))
         {
             var data = new ArchiveInfo(base.EntityType.GetData(id));
             return(new PartialViewResult {
                 ViewName = "Partials/Details", ViewData = new ViewDataDictionary(data)
             });
         }
         else
         {
             throw new ValidationException("非法的Guid标识" + Request["id"]);
         }
     }
     else if (!string.IsNullOrEmpty(Request["isInner"]))
     {
         return(new PartialViewResult {
             ViewName = "Partials/Details"
         });
     }
     else
     {
         return(this.View());
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 单个档案放入柜中(后期看情况第二个参数改成档案盒编号)
        /// </summary>
        /// <param name="arv">档案</param>
        /// <param name="arvBox">档案盒</param>
        /// <returns></returns>
        public int InToStorage(ArchiveInfo arv, ArvBox arvBox)
        {
            // 档案查重
            if (arvRepository.CheckExists(q => q.ID == arv.ID))//(q => q.ArvID == arv.ArvID))
            {
                throw new Exception("试图添加档案编号重复的记录");
            }

            // 档案盒查重
            ArvBox box = arvBoxRepository.FindSingle(q => q.ID == arvBox.ID); //(q => q.ArvBoxID == arvBox.ArvBoxID);

            if (box == null)
            {
                // 新的档案盒
                AddNewArvBox(arvBox, false);
                // 关联档案和所属档案盒
                arv.ArvBox = arvBox;
            }
            else
            {
                // 关联档案和所属档案盒(注意不能用arvBox,否则ArvBox表里会多一条记录,arvBox的ArvBoxID和box实体的一样!!!)
                arv.ArvBox = box;
            }

            // 记录保存
            arv.ArvStatus = "在档";
            //arv.ArvStatus = "在库";
            arvRepository.Insert(arv, false);

            // 提交数据库
            return(Context.Commit());
        }
Esempio n. 4
0
            public static bool TryParseConfigEntry(string Text, out ArchiveInfo Info)
            {
                ConfigObject Object = new ConfigObject(Text);

                string Name = Object.GetValue("Name", null);

                if (Name == null)
                {
                    Info = null;
                    return(false);
                }

                string DepotPath = Object.GetValue("DepotPath", null);

                if (DepotPath == null)
                {
                    Info = null;
                    return(false);
                }

                string Target = Object.GetValue("Target", null);

                string Type = Object.GetValue("Type", null) ?? Name;

                Info = new ArchiveInfo(Name, Type, DepotPath, Target);
                return(true);
            }
Esempio n. 5
0
        /// <summary>
        /// 档案入库
        /// </summary>
        /// <param name="arv"></param>
        public int InToStorage(ArchiveInfoDto arvDto)
        {
            ArvBox      arvBox = arvDto.MapTo <ArvBox>();
            ArchiveInfo arv    = arvDto.MapTo <ArchiveInfo>();

            return(baseArvOpService.InToStorage(arv, arvBox));
        }
Esempio n. 6
0
        private async Task <ICollection <ArchiveInfo> > GetAsync(ZipArchive zipArchive)
        {
            ICollection <ArchiveInfo> arquivesInfo = new List <ArchiveInfo>();

            if (zipArchive != null)
            {
                foreach (ZipArchiveEntry zipArchiveEntry in zipArchive.Entries)
                {
                    if (!zipArchiveEntry.Name.Equals("") && !zipArchiveEntry.Name.EndsWith("/"))
                    {
                        int amountLines;

                        using (Stream streamArchive = zipArchiveEntry.Open())
                        {
                            amountLines = await GetAmountLinesAsync(streamArchive);
                        }

                        ArchiveInfo arquiveInfo = new ArchiveInfo
                        {
                            Name        = zipArchiveEntry.Name,
                            Bytes       = zipArchiveEntry.Length,
                            AmountLines = amountLines
                        };

                        arquivesInfo.Add(arquiveInfo);
                    }
                }
            }

            return(arquivesInfo);
        }
Esempio n. 7
0
        public static string ArchiveLink(this HtmlHelper helper, ArchiveInfo archiveInfo)
        {
            string monthName = GetMonthName(archiveInfo.Month);
            string linkText  = String.Format("{0}, {1} ({2})", monthName, archiveInfo.Year, archiveInfo.Count);

            return(helper.RouteLink(linkText, "ArchiveYearMonth", new { year = archiveInfo.Year, month = archiveInfo.Month }).ToHtmlString());
        }
Esempio n. 8
0
        public async Task CreateAsync(string inputPath, string outputPath)
        {
            await using var outputStream = ArchiveStream.Create(outputPath);

            var metadata         = new Metadata.Metadata(inputPath);
            var directoryHeaders = await metadata.GenerateDirectoryHeadersAsync();

            var fileHeaders = await metadata.GenerateFileHeadersAsync();

            var archiveInfo = new ArchiveInfo()
            {
                Header              = ArchiveResource.ArchiveHeader,
                IsEncrypted         = Compressor.Settings.IsEncryptEnable,
                NumberOfDirectories = directoryHeaders.Count,
                NumberOfFiles       = fileHeaders.Count,
            };

            archiveInfo.DirectoriesBlockPosition = archiveInfo.SizeOf;
            outputStream.Seek(archiveInfo.SizeOf, SeekOrigin.Current);

            await outputStream.WriteDirectoriesAsync(directoryHeaders);

            archiveInfo.FilesBlockPosition = outputStream.Position;

            await outputStream.WriteArchiveInfoAsync(archiveInfo);

            outputStream.Position = archiveInfo.FilesBlockPosition;

            await Compressor.CompressAsync(fileHeaders, outputStream);
        }
Esempio n. 9
0
 public static void Pack(this ArchiveInfo o, string sourceDirectory, IList <string> sourceFileNames, IList <string> fileNames, CompressionLevel compLevel, EventHandler <ArchiveProgressEventArgs> progressHandler, IPackStreamContext ipackstreamcontext)
 {
     if (sourceFileNames == null)
     {
         throw new ArgumentNullException("sourceFileNames");
     }
     checked
     {
         if (fileNames == null)
         {
             string[] array = new string[sourceFileNames.Count];
             for (int i = 0; i < sourceFileNames.Count; i++)
             {
                 array[i] = Path.GetFileName(sourceFileNames[i]);
             }
             fileNames = array;
         }
         else if (fileNames.Count != sourceFileNames.Count)
         {
             throw new ArgumentOutOfRangeException("fileNames");
         }
         using (CompressionEngine compressionEngine = new CabEngine())
         {
             compressionEngine.Progress += progressHandler;
             IDictionary <string, string> files = CreateStringDictionary(fileNames, sourceFileNames);
             ArchiveFileStreamContext     archiveFileStreamContext = new ArchiveFileStreamContext(o.FullName, sourceDirectory, files);
             archiveFileStreamContext.EnableOffsetOpen = true;
             compressionEngine.CompressionLevel        = compLevel;
             compressionEngine.Pack(archiveFileStreamContext, fileNames);
         }
     }
 }
Esempio n. 10
0
        private Stream OpenArchive(int index)
        {
            ArchiveInfo info;

            if (!_openArchives.TryGetValue(index, out info))
            {
                var fileName = GetArchiveFileName(index);
                info = new ArchiveInfo(File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read));
                _openArchives.Add(index, info);
            }

            info.Accessors += 1;
            return(info.Stream);
        }
Esempio n. 11
0
        /// <summary>
        /// Inspects the specified backup archive.
        /// </summary>
        /// <param name="archive">The archive.</param>
        /// <returns>Summary of the archive.</returns>
        public static ArchiveInfo Inspect(string archive)
        {
            try
            {
                var arc = new ArchiveInfo();
                var zip = ZipArchive.Open(archive);

                if (zip.Entries.Any(e => e.FilePath == "json"))
                {
                    arc.Settings = true;
                }

                if (zip.Entries.Any(e => e.FilePath.EndsWith("/cover")))
                {
                    arc.Covers = true;
                }

                foreach (var file in zip.Entries.Where(e => e.FilePath.EndsWith("/info")))
                {
                    var dir = Path.GetFileName(Path.GetDirectoryName(file.FilePath));

                    try
                    {
                        using (var fs = file.OpenEntryStream())
                            using (var br = new BinaryReader(fs))
                            {
                                var ver = br.ReadByte();
                                var upd = br.ReadUInt32();

                                var title = br.ReadString();
                                var guide = br.ReadString();

                                arc.Shows.Add(new[] { dir, title, guide });
                            }
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Unable to process " + dir + "/info in backup due to error.", ex);
                    }
                }

                return(arc);
            }
            catch (Exception ex)
            {
                Log.Error("Error while processing archive.", ex);
            }

            return(null);
        }
Esempio n. 12
0
        private void OpenArchive(Stream data, string fname, ArchiveFormat format)
        {
            // Let's open the archive and add it to the stack
            ArchiveReader archive = Archive.Open(data, format);

            ArchiveInfo info = new ArchiveInfo();

            info.Format  = format;
            info.Archive = archive;

            openedArchives.Push(info);
            openedArchiveNames.Add((fname == String.Empty ? "Unnamed" : fname));

            Populate(info);
        }
Esempio n. 13
0
        /// <summary>
        /// 删除档案
        /// </summary>
        /// <param name="arv">实体类型</param>
        /// <returns>操作是否成功</returns>
        public int Delete(ArchiveInfo arv)
        {
            // 不能直接执行Delete(arv)
            // 从dto map出的实体和上下文中捕捉的实体不是同一个,且无法attach,导致报错。
            // 两种解决方式,一是通过主键删除;
            // 另一种就是取消跟踪:Dbset.Where(where).AsNoTracking().FirstOrDefault<T>();

            // 采用实际的主键来删除
            //return arvRepository.Delete(q => q.ArvID == arv.ArvID);

            // Id是实体的自增字段,一般不出现在UI界面,作为删除有时会出错(实际没删除)
            return(arvRepository.Delete(arv.ID));

            //return arvRepository.Delete(arv);
        }
Esempio n. 14
0
        public static Byte[] ExportToCsv(IList <DocumentSeriesItem> items)
        {
            try
            {
                ArchiveInfo             archive    = DocumentSeriesFacade.GetArchiveInfo(items.First().DocumentSeries);
                List <ArchiveAttribute> archiveAtt = archive.Attributes;

                IExportRepository wrapper = new FileSystemRepository();
                wrapper.InitializeExport(items, archiveAtt);
                return(wrapper.StartExport(items.First().DocumentSeries.Id));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 15
0
        private Stream OpenArchive(int index)
        {
            lock (this)
            {
                ArchiveInfo info;
                if (!_openArchives.TryGetValue(index, out info))
                {
                    var fileName = GetArchiveFileName(index);
                    info = new ArchiveInfo(fileName);
                    _openArchives.Add(index, info);
                }

                info.Accessors += 1;
                return(info.GetStream());
            }
        }
Esempio n. 16
0
        /// <summary>

        /// Search a directory or archive and add any files or sub-directories

        /// to the list of candidates currently being resolved

        /// </summary>

        /// <param name="candidates">Candidates currently being resolved</param>
        public void Explode(SubmissionCandidates candidates, string workingDirectory)
        {
            if (IsArchive)
            {
                // Archives in Archives!!
                if (IsArchivedFile)
                {
                    string exportPath = Path.Combine(workingDirectory, HunterConfig.GalileoDefaultDataFolder + Path.DirectorySeparatorChar + "galileo_" + Guid.ToString() + FileExtension);

                    ArchiveInfo.Extract(ReadPath, exportPath);
                    _resolvePath = exportPath;
                }

                if (_fileType == FileTypes.Types.Zip)
                {
                    _archiveInfo     = new ZipArchiveInfo(ReadPath);
                    _archiveChildren = new List <SubmissionCandidate>(10);

                    if (_archiveInfo.IsOpen == false)
                    {
                        // Probably best to do something better than this?
                        throw new Exception("Could not open archive???");
                    }

                    foreach (var fileName in _archiveInfo)
                    {
                        SubmissionCandidate candidate = candidates.Add(fileName, _depth + 1, this);
                        _archiveChildren.Add(candidate);
                    }

                    // We leave _archiveInfo open, because later the files
                    // will want to be inspected and possibly extracted.
                }
            }
            else if (IsDirectory)
            {
                System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(ReadPath);
                foreach (var file in info.EnumerateFiles())
                {
                    candidates.Add(file.FullName, _depth + 1, this);
                }
                foreach (var directory in info.EnumerateDirectories())
                {
                    candidates.Add(directory.FullName, _depth + 1, this);
                }
            }
        }
Esempio n. 17
0
        private void OpenTexture(Stream data, string fname, TextureFormat format)
        {
            TextureViewer viewer = new TextureViewer();

            long oldPosition = data.Position;

            try
            {
                viewer.OpenTexture(data, fname, format);
                viewer.Show();
            }
            catch (TextureNeedsPaletteException)
            {
                ArchiveInfo info = openedArchives.Peek();

                // Seems like we need a palette for this texture. Let's try to find one.
                string textureName      = Path.GetFileNameWithoutExtension(fname) + Texture.GetModule(format).PaletteFileExtension;
                int    paletteFileIndex = -1;

                for (int i = 0; i < info.Archive.Entries.Count; i++)
                {
                    if (info.Archive.Entries[i].Name.ToLower() == textureName.ToLower())
                    {
                        paletteFileIndex = i;
                        break;
                    }
                }

                // Let's see if we found the palette file. And if so, open it up.
                // Due to the nature of how this works, we need to copy the palette data to another stream first
                if (paletteFileIndex != -1)
                {
                    Stream entryData     = info.Archive.OpenEntry(paletteFileIndex);
                    int    paletteLength = (int)entryData.Length;

                    // Get the palette data (we may need to copy over the data to another stream)
                    Stream paletteData = new MemoryStream();
                    PTStream.CopyTo(entryData, paletteData);
                    paletteData.Position = 0;

                    // Now open the texture
                    data.Position = oldPosition;
                    viewer.OpenTexture(data, fname, paletteData, format);
                    viewer.Show();
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 更新档案信息
        /// </summary>
        /// <param name="arv">档案实体</param>
        /// <returns></returns>
        public int UpdateArvInfo(ArchiveInfo arv, ArvBox arvBox = null)
        {
            if ((arvBox != null) && (arvBox.ID != null))                          //ArvBoxID != null))
            {
                ArvBox box = arvBoxRepository.FindSingle(q => q.ID == arvBox.ID); //(q => q.ArvBoxID == arvBox.ArvBoxID);
                if (box == null)
                {
                    // 新的档案盒
                    AddNewArvBox(arvBox, false);
                }

                arv.ArvBoxID = arvBox.ID;// ArvBoxID;
            }

            // 更新数据库记录
            return(arvRepository.Update(arv));
        }
Esempio n. 19
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [{0}posts] where [slug]=@slug";
        //    OleDbParameter[] prams = {
        //                           OleDbHelper.MakeInParam("@slug",OleDbType.VarWChar,200,slug),

        //                            };
        //    return TypeConverter.ObjectToInt(OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));

        //}

        public List <ArchiveInfo> GetArchive()
        {
            string cmdText = string.Format("select format(PostTime, 'yyyymm') as [date] ,  count(*) as [count] from [{0}posts] where [status]=1 and [hidestatus]=0  group by  format(PostTime, 'yyyymm')  order by format(PostTime, 'yyyymm') desc", ConfigHelper.Tableprefix);

            var list = new List <ArchiveInfo>();

            using (OleDbDataReader read = OleDbHelper.ExecuteReader(cmdText))
            {
                while (read.Read())
                {
                    var    archive = new ArchiveInfo();
                    string date    = read["date"].ToString().Substring(0, 4) + "-" + read["date"].ToString().Substring(4, 2);
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = TypeConverter.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return(list);
        }
Esempio n. 20
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [loachs_posts] where [slug]=@slug";
        //    SqlParameter[] prams = {
        //                           SqlHelper.MakeInParam("@slug",SqlDbType.VarChar,200,slug),

        //                            };
        //    return StringHelper.ObjectToInt(SqlHelper.ExecuteScalar(CommandType.Text, cmdText, prams));

        //}

        public List <ArchiveInfo> GetArchive()
        {
            string cmdText = "select convert(varchar(7),createdate,120) as CurrentDate,  count(*) as [count] from [loachs_posts] where [status]=1 and [hidestatus]=0  group by  convert(varchar(7),createdate,120)  order by convert(varchar(7),createdate,120) desc";

            List <ArchiveInfo> list = new List <ArchiveInfo>();

            using (SqlDataReader read = SqlHelper.ExecuteReader(cmdText))
            {
                while (read.Read())
                {
                    ArchiveInfo archive = new ArchiveInfo();
                    string      date    = read["CurrentDate"].ToString();
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = StringHelper.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return(list);
        }
Esempio n. 21
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [{0}posts] where [slug]=@slug";
        //    OleDbParameter[] prams = {
        //                           OleDbHelper.MakeInParam("@slug",OleDbType.VarWChar,200,slug),
        //                            };
        //    return TypeConverter.ObjectToInt(OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));
        //}
        public List<ArchiveInfo> GetArchive()
        {
            string cmdText = string.Format("select format(PostTime, 'yyyymm') as [date] ,  count(*) as [count] from [{0}posts] where [status]=1 and [PostStatus]=0  group by  format(PostTime, 'yyyymm')  order by format(PostTime, 'yyyymm') desc",ConfigHelper.Tableprefix);

            var list = new List<ArchiveInfo>();
            using (OleDbDataReader read = OleDbHelper.ExecuteReader(cmdText))
            {

                while (read.Read())
                {
                    var archive = new ArchiveInfo();
                    string date = read["date"].ToString().Substring(0, 4) + "-" + read["date"].ToString().Substring(4, 2);
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = TypeConverter.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return list;
        }
Esempio n. 22
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [loachs_posts] where [slug]=@slug";
        //    SqliteParameter[] prams = {
        //                           SqliteDbHelper.MakeInParam("@slug",DbType.String,200,slug),

        //                            };
        //    return StringHelper.ObjectToInt(SqliteDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));

        //}

        public List <ArchiveInfo> GetArchive()
        {
            string cmdText = "select strftime('%Y%m',createdate) as [date] ,  count(*) as [count] from [loachs_posts] where [status]=1 and [hidestatus]=0  group by  strftime('%Y%m',createdate)   order by strftime('%Y%m',createdate)  desc";

            List <ArchiveInfo> list = new List <ArchiveInfo>();

            using (SqliteDataReader read = SqliteDbHelper.ExecuteReader(cmdText))
            {
                while (read.Read())
                {
                    ArchiveInfo archive = new ArchiveInfo();
                    string      date    = read["date"].ToString().Substring(0, 4) + "-" + read["date"].ToString().Substring(4, 2);
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = StringHelper.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return(list);
        }
Esempio n. 23
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [loachs_posts] where [slug]=@slug";
        //    OleDbParameter[] prams = {
        //                           OleDbHelper.MakeInParam("@slug",OleDbType.VarWChar,200,slug),
        //                            };
        //    return StringHelper.ObjectToInt(OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));
        //}
        public List<ArchiveInfo> GetArchive()
        {
            string cmdText = "select format(createdate, 'yyyymm') as [date] ,  count(*) as [count] from [loachs_posts] where [status]=1 and [hidestatus]=0  group by  format(createdate, 'yyyymm')  order by format(createdate, 'yyyymm') desc";

            List<ArchiveInfo> list = new List<ArchiveInfo>();
            using (OleDbDataReader read = OleDbHelper.ExecuteReader(cmdText))
            {

                while (read.Read())
                {
                    ArchiveInfo archive = new ArchiveInfo();
                    string date = read["date"].ToString().Substring(0, 4) + "-" + read["date"].ToString().Substring(4, 2);
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = StringHelper.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return list;
        }
Esempio n. 24
0
        ///// <summary>
        ///// 根据别名获取文章ID
        ///// </summary>
        ///// <param name="slug"></param>
        ///// <returns></returns>
        //public int GetPostId(string slug)
        //{
        //    string cmdText = "select [postid] from [loachs_posts] where [slug]=@slug";
        //    SqlParameter[] prams = {
        //                           MSSQLHelper.MakeInParam("@slug",SqlDbType.VarChar,200,slug),

        //                            };
        //    return StringHelper.ObjectToInt(MSSQLHelper.ExecuteScalar(CommandType.Text, cmdText, prams));

        //}

        public List <ArchiveInfo> GetArchive()
        {
            //string cmdText = "select format(createdate, 'yyyymm') as [date] ,  count(*) as [count] from [loachs_posts] where [status]=1 and [hidestatus]=0  group by  format(createdate, 'yyyymm')  order by format(createdate, 'yyyymm') desc";

            string             cmdText = "select convert(varchar(6),createdate, 112) as [date] ,  count(*) as [count] from [loachs_posts] where [status]=1 and [hidestatus]=0  group by convert(varchar(6),createdate, 112)  order by convert(varchar(6),createdate, 112) desc";
            List <ArchiveInfo> list    = new List <ArchiveInfo>();

            using (SqlDataReader read = MSSQLHelper.ExecuteReader(cmdText))
            {
                while (read.Read())
                {
                    ArchiveInfo archive = new ArchiveInfo();
                    string      date    = read["date"].ToString().Substring(0, 4) + "-" + read["date"].ToString().Substring(4, 2);
                    archive.Date = Convert.ToDateTime(date);
                    // archive.Title = read["date"].ToString();
                    archive.Count = StringHelper.ObjectToInt(read["count"]);
                    list.Add(archive);
                }
            }
            return(list);
        }
Esempio n. 25
0
        /// <summary>
        /// Method:         dsCabFile
        /// Description:    This method is used to handle various functions like list a cab file contents,
        ///                 create a cab file from a directory containing files, or even extract files from
        ///                 a cab file.
        /// </summary>
        /// <param name="cabFileName"></param>
        /// <param name="cabFileLocation"></param>
        /// <param name="cabFlag"></param>
        public static void dsCabFile(string cabFileName, string cabFileLocation, int cabFlag)
        {
            if (cabFlag == 0)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("The cabinet file {0} has the following files embedded within it: ", cabFileName);
                CabInfo CabFile = new CabInfo(cabFileName);
                Console.WriteLine("\nCab FileName" + "\t" + "Cab FileSize (KB)");
                foreach (CabFileInfo CabIndvFile in CabFile.GetFiles())
                {
                    Console.WriteLine(CabIndvFile.Name + "\t" + CabIndvFile.Length);
                }
                Console.ResetColor();
            }

            else if (cabFlag == 1)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Cab File {0} is being created. The following files are being added now: \n", cabFileName);
                ArchiveInfo cabFile = CompressedFileType(cabFileName);
                cabFile.Pack(cabFileLocation, true, CompressionLevel.Max, cabProgress);
                Console.WriteLine("\nThe Cab File {0} is successfully created.", cabFileName);
                Console.ResetColor();
            }

            else if (cabFlag == 2)
            {
                Program.copyrightBanner();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Cab File {0} is being extracted. The following files are being extracted now: \n", cabFileName);
                ArchiveInfo cabFile = CompressedFileType(cabFileName);
                cabFile.Unpack(cabFileLocation, cabProgress);
                Console.WriteLine("\nThe cab file {0} is extracted to {1}", cabFileName, cabFileLocation);
                Console.ResetColor();
            }
        }
        public static void TestTruncatedArchive(
            ArchiveInfo archiveInfo, Type expectedExceptionType)
        {
            for (long len = archiveInfo.Length - 1; len >= 0; len--)
            {
                string testArchive = String.Format("{0}.{1:d06}",
                                                   archiveInfo.FullName, len);
                if (File.Exists(testArchive))
                {
                    File.Delete(testArchive);
                }

                archiveInfo.CopyTo(testArchive);
                using (FileStream truncateStream =
                           File.Open(testArchive, FileMode.Open, FileAccess.ReadWrite))
                {
                    truncateStream.SetLength(len);
                }

                ArchiveInfo testArchiveInfo = (ArchiveInfo)archiveInfo.GetType()
                                              .GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { testArchive });

                Exception caughtEx = null;
                try
                {
                    testArchiveInfo.GetFiles();
                }
                catch (Exception ex) { caughtEx = ex; }
                File.Delete(testArchive);

                if (caughtEx != null)
                {
                    Assert.IsInstanceOfType(caughtEx, expectedExceptionType,
                                            String.Format("Caught exception listing archive truncated to {0}/{1} bytes",
                                                          len, archiveInfo.Length));
                }
            }
        }
Esempio n. 27
0
        private void Populate(ArchiveInfo info)
        {
            listView.Items.Clear();

            // Add a blank row if this is not the top archive
            if (openedArchives.Count > 1) // Remember, we just added an entry
            {
                listView.Items.Add(new ListViewItem(new string[] {
                    "..",
                    "Parent Archive",
                }));
                listView.Items[0].Font = new Font(listView.Items[0].Font, FontStyle.Bold);
            }

            for (int i = 0; i < info.Archive.Entries.Count; i++)
            {
                ArchiveEntry entry = info.Archive.Entries[i];

                listView.Items.Add(new ListViewItem(new string[] {
                    (i + 1).ToString(),
                    entry.Name,
                    FormatFileLength(entry.Length),
                    entry.Length.ToString("N0"),
                }));
            }

            // Display information about the archive
            numFilesLabel.Text      = info.Archive.Entries.Count.ToString();
            archiveFormatLabel.Text = Archive.Formats[info.Format].Name;

            archiveNameLabel.Text = openedArchiveNames[0];
            for (int i = 1; i < openedArchiveNames.Count; i++)
            {
                archiveNameLabel.Text += " / " + openedArchiveNames[i];
            }
        }
Esempio n. 28
0
 public ViewResultBase Details()
 {
     if (!string.IsNullOrEmpty(Request["isTooltip"]))
     {
         Guid id;
         if (Guid.TryParse(Request["id"], out id))
         {
             var data = new ArchiveInfo(base.EntityType.GetData(id));
             return new PartialViewResult { ViewName = "Partials/Details", ViewData = new ViewDataDictionary(data) };
         }
         else
         {
             throw new ValidationException("非法的Guid标识" + Request["id"]);
         }
     }
     else if (!string.IsNullOrEmpty(Request["isInner"]))
     {
         return new PartialViewResult { ViewName = "Partials/Details" };
     }
     else
     {
         return this.View();
     }
 }
Esempio n. 29
0
 public static void Main(string[] args)
 {
     try
     {
         if (args.Length == 3 && args[0].ToUpperInvariant() == "/P")
         {
             ArchiveInfo a = GetArchive(args[1]);
             a.Pack(args[2], true, CompressionLevel.Max, ProgressHandler);
         }
         else if (args.Length == 3 && args[0].ToUpperInvariant() == "/U")
         {
             ArchiveInfo a = GetArchive(args[1]);
             a.Unpack(args[2], ProgressHandler);
         }
         else
         {
             Usage(Console.Out);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Esempio n. 30
0
 public static void Pack(this ArchiveInfo o, string sourceDirectory, IList <string> sourceFileNames, IList <string> fileNames, IPackStreamContext ipackstreamcontext)
 {
     o.PackFiles(sourceDirectory, sourceFileNames, fileNames, CompressionLevel.Max, null);
 }
Esempio n. 31
0
        public static void Pack(this ArchiveInfo o, string sourceDirectory, bool includeSubdirectories, CompressionLevel compLevel, EventHandler <ArchiveProgressEventArgs> progressHandler, IPackStreamContext ipackstreamcontext)
        {
            IList <string> relativeFilePathsInDirectoryTree = GetRelativeFilePathsInDirectoryTree(sourceDirectory, includeSubdirectories);

            o.PackFiles(sourceDirectory, relativeFilePathsInDirectoryTree, relativeFilePathsInDirectoryTree, compLevel, progressHandler);
        }
Esempio n. 32
0
 public static void Pack(this ArchiveInfo o, string sourceDirectory, IPackStreamContext ipackstreamcontext)
 {
     o.Pack(sourceDirectory, false, CompressionLevel.Max, null);
 }
Esempio n. 33
0
 public static bool updateArchive(Evercam evercam, string camera_id, string archive_id, int total_frames, ArchiveStatus status)
 {
     try
     {
         ArchiveInfo archiveInfo = new ArchiveInfo();
         archiveInfo.CameraId = camera_id;
         archiveInfo.ID = archive_id;
         archiveInfo.Status = status;
         archiveInfo.Frames = total_frames;
         var res = evercam.UpdateArchive(archiveInfo);
         return true;
     }
     catch (Exception ex) {
         Console.WriteLine(ex.ToString());
         return false;
     }
 }
Esempio n. 34
0
        private void OpenArchive(Stream data, string fname, ArchiveFormat format)
        {
            // Let's open the archive and add it to the stack
            ArchiveReader archive = Archive.Open(data, format);

            ArchiveInfo info = new ArchiveInfo();
            info.Format = format;
            info.Archive = archive;

            openedArchives.Push(info);
            openedArchiveNames.Add((fname == String.Empty ? "Unnamed" : fname));

            Populate(info);
        }
Esempio n. 35
0
        private void Populate(ArchiveInfo info)
        {
            listView.Items.Clear();

            // Add a blank row if this is not the top archive
            if (openedArchives.Count > 1) // Remember, we just added an entry
            {
                listView.Items.Add(new ListViewItem(new string[] {
                    "..",
                    "Parent Archive",
                }));
                listView.Items[0].Font = new Font(listView.Items[0].Font, FontStyle.Bold);
            }

            for (int i = 0; i < info.Archive.Entries.Count; i++)
            {
                ArchiveEntry entry = info.Archive.Entries[i];

                listView.Items.Add(new ListViewItem(new string[] {
                    (i + 1).ToString(),
                    entry.Name,
                    FormatFileLength(entry.Length),
                    entry.Length.ToString("N0"),
                }));
            }

            // Display information about the archive
            numFilesLabel.Text = info.Archive.Entries.Count.ToString();
            archiveFormatLabel.Text = Archive.Formats[info.Format].Name;

            archiveNameLabel.Text = openedArchiveNames[0];
            for (int i = 1; i < openedArchiveNames.Count; i++)
                archiveNameLabel.Text += " / " + openedArchiveNames[i];
        }
Esempio n. 36
0
            public override bool Equals(object Other)
            {
                ArchiveInfo OtherArchive = Other as ArchiveInfo;

                return(OtherArchive != null && Name == OtherArchive.Name && Type == OtherArchive.Type && DepotPath == OtherArchive.DepotPath && Target == OtherArchive.Target && Enumerable.SequenceEqual(ChangeNumberToFileRevision, OtherArchive.ChangeNumberToFileRevision));
            }
        /// <summary>
        /// Inspects the specified backup archive.
        /// </summary>
        /// <param name="archive">The archive.</param>
        /// <returns>Summary of the archive.</returns>
        public static ArchiveInfo Inspect(string archive)
        {
            try
            {
                var arc = new ArchiveInfo();
                var zip = ZipArchive.Open(archive);
                
                if (zip.Entries.Any(e => e.FilePath == "json"))
                {
                    arc.Settings = true;
                }

                if (zip.Entries.Any(e => e.FilePath.EndsWith("/cover")))
                {
                    arc.Covers = true;
                }

                foreach (var file in zip.Entries.Where(e => e.FilePath.EndsWith("/info")))
                {
                    var dir = Path.GetFileName(Path.GetDirectoryName(file.FilePath));

                    try
                    {
                        using (var fs = file.OpenEntryStream())
                        using (var br = new BinaryReader(fs))
                        {
                            var ver = br.ReadByte();
                            var upd = br.ReadUInt32();

                            var title = br.ReadString();
                            var guide = br.ReadString();

                            arc.Shows.Add(new[] { dir, title, guide });
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Warn("Unable to process " + dir + "/info in backup due to error.", ex);
                    }
                }

                return arc;
            }
            catch (Exception ex)
            {
                Log.Error("Error while processing archive.", ex);
            }

            return null;
        }