Beispiel #1
0
 public void Save(string file, Stream stream)
 {
     var item = new ArchiveItem();
     if (this.zip.FindFirst(file, ref item))
     {
         this.zip.DeleteFiles(file);
     }
     this.zip.AddFromStream(file, stream);
 }
Beispiel #2
0
        /// <summary>
        /// 文章列表
        /// </summary>
        public ActionResult List(string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0, int pageIndex = 1)
        {
            PagingDataSet<BlogThread> blogs = null;
            IUser currentUser = UserContext.CurrentUser;
            string title = string.Empty;

            switch (listType)
            {
                case ListType.Archive:
                    ArchivePeriod archivePeriod = ArchivePeriod.Year;
                    if (month > 0)
                    {
                        archivePeriod = ArchivePeriod.Month;
                    }

                    ArchiveItem archiveItem = new ArchiveItem();
                    archiveItem.Year = year;
                    archiveItem.Month = month;

                    if (currentUser != null && currentUser.UserName == spaceKey)
                    {
                        blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, archivePeriod, archiveItem, 20, pageIndex);
                    }
                    else
                    {
                        blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, archivePeriod, archiveItem, 20, pageIndex);
                    }

                    title = "归档:" + year + "年";
                    if (month > 0)
                    {
                        title += month + "月";
                    }

                    break;

                case ListType.Category:
                    if (currentUser != null && currentUser.UserName == spaceKey)
                    {
                        blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, categoryId, null, false, 20, pageIndex);
                    }
                    else
                    {
                        blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, categoryId, null, false, 20, pageIndex);
                    }

                    Category category = categoryService.Get(categoryId);
                    title = "分类:" + category.CategoryName;

                    break;

                case ListType.Tag:
                    if (currentUser != null && currentUser.UserName == spaceKey)
                    {
                        blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, tag, false, 20, pageIndex);
                    }
                    else
                    {
                        blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, tag, false, 20, pageIndex);
                    }

                    title = "标签:" + tag;

                    break;

                default:
                    break;
            }

            ViewData["title"] = title;
            pageResourceManager.InsertTitlePart(title);

            return View(blogs);
        }
Beispiel #3
0
        /// <summary>
        /// 日志列表
        /// </summary>
        public ActionResult List(string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0, int pageIndex = 1)
        {
            PagingDataSet <BlogThread> blogs = null;
            IUser  currentUser = UserContext.CurrentUser;
            string title       = string.Empty;

            switch (listType)
            {
            case ListType.Archive:
                ArchivePeriod archivePeriod = ArchivePeriod.Year;
                if (month > 0)
                {
                    archivePeriod = ArchivePeriod.Month;
                }

                ArchiveItem archiveItem = new ArchiveItem();
                archiveItem.Year  = year;
                archiveItem.Month = month;

                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, archivePeriod, archiveItem, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, archivePeriod, archiveItem, 20, pageIndex);
                }

                title = "归档:" + year + "年";
                if (month > 0)
                {
                    title += month + "月";
                }

                break;

            case ListType.Category:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, categoryId, null, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, categoryId, null, false, 20, pageIndex);
                }

                Category category = categoryService.Get(categoryId);
                title = "分类:" + category.CategoryName;

                break;

            case ListType.Tag:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, tag, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, tag, false, 20, pageIndex);
                }

                title = "标签:" + tag;

                break;

            default:
                break;
            }

            ViewData["title"] = title;
            pageResourceManager.InsertTitlePart(title);

            return(View(blogs));
        }
 public void LoadArchiveData()
 {
     archiveItem = JsonTools.GetJsonObject <ArchiveItem>("ArchiveData");
     GlobalPlayerData.Instance.LoadGoldNumData(archiveItem.GoldNum);
 }
Beispiel #5
0
 public void UpdateWatermark(ArchiveItem item, ArchiveEvent ev)
 {
     _watermark = new Watermark(item, ev);
     _storage.SaveWatermarkForPartition(_partitionId, _watermark);
 }
 /* ----------------------------------------------------------------- */
 ///
 /// SetAttributes
 ///
 /// <summary>
 /// Sets attributes, creation time, last written time, and last
 /// accessed time to the extracted file or directory.
 /// </summary>
 ///
 /// <param name="item">Information of the archived item.</param>
 /// <param name="root">Path of the root directory.</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void SetAttributes(this ArchiveItem item, string root) =>
 SetAttributes(item, root, new IO());
 /* ----------------------------------------------------------------- */
 ///
 /// CreateDirectory
 ///
 /// <summary>
 /// Creates the directory.
 /// </summary>
 ///
 /// <param name="item">Information of an archived item.</param>
 /// <param name="root">Path of the root directory.</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void CreateDirectory(this ArchiveItem item, string root) =>
 CreateDirectory(item, root, new IO());
Beispiel #8
0
 private void InitPos(ArchiveItem item)
 {
     m_Transform.position = new Vector3((float)item.PosX, (float)item.PosY, (float)item.PosZ);
     m_Transform.rotation = Quaternion.Euler((float)item.RotX, (float)item.RotY, (float)item.RotZ);
 }
Beispiel #9
0
        async void RemoveArchiveItem(ArchiveItemsPage obj, ArchiveItem item)
        {
            await ArchiveStore.DeleteItemAsync(item.Id);

            Items.Remove(item);
        }
Beispiel #10
0
        public ArchiveResult CreateArchiveItems(ArchiveItemDTO message, DR_Requester requester)
        {
            ArchiveResult result = new ArchiveResult();

            try
            {
                // افزوده شدن نامه ها به آرشیو بعدا بررسی شود

                if (message.ID != 0)
                {
                    throw new Exception();
                }
                BizTableDrivedEntity bizTableDrivedEntity = new BizTableDrivedEntity();
                if (!bizTableDrivedEntity.DataIsAccessable(requester, message.DatItem.TargetEntityID, new List <SecurityAction>()
                {
                    SecurityAction.ArchiveEdit
                }))
                {
                    throw new Exception("عدم دسترسی ثبت آرشیو");
                }
                using (var context = new MyIdeaDataDBEntities())
                {
                    var dbArchiveItem = new ArchiveItem();
                    if (message.DatItem.DataItemID == 0)
                    {
                        dbArchiveItem.MyDataItemID = bizDataItem.GetOrCreateDataItem(message.DatItem);
                        message.DatItem.DataItemID = dbArchiveItem.MyDataItemID;
                    }
                    else
                    {
                        dbArchiveItem.MyDataItemID = message.DatItem.DataItemID;
                    }
                    //var dataItem = bizDataItem.GetOrCreateDataItem(message.DatItem);
                    //var archiveItemDataItem = new MyDataItem_ArchiveItem();

                    dbArchiveItem.FolderID     = message.FolderID;
                    dbArchiveItem.CreationDate = DateTime.Now;
                    dbArchiveItem.UserID       = requester.Identity;
                    dbArchiveItem.Name         = message.Name;
                    var type = GetArchiveItemType(message);
                    message.FileType       = type.Item2;
                    message.MainType       = type.Item1;
                    dbArchiveItem.FileType = (short)message.FileType;
                    dbArchiveItem.MainType = (short)message.MainType;
                    if (message.AttechedFile != null && message.AttechedFile.Content != null)
                    {
                        dbArchiveItem.FileSize        = message.AttechedFile.Content.Count();
                        dbArchiveItem.FileRepository1 = bizFileRepository.ToFileRepository(context, message.AttechedFile);
                    }
                    SetPossibleThumbnail(context, dbArchiveItem, message.MainType, message.FileType, message.AttechedFile.Content, message.AttechedFile.FileName);
                    //if (!hasThumbnail)
                    //{
                    //    dbArchiveItem.ThumbnailFileRepositoryID = null;
                    //    //    dbArchiveItem.FileRepository1 = null;
                    //}
                    foreach (var tagid in message.TagIDs)
                    {
                        dbArchiveItem.ArchiveItem_Tag.Add(new ArchiveItem_Tag()
                        {
                            TagID = tagid
                        });
                    }
                    context.ArchiveItem.Add(dbArchiveItem);
                    context.SaveChanges();
                    message.ID = dbArchiveItem.ID;

                    result.Result = true;


                    //انتیتی فرمورک قاطی داره رابطه فایل را برای تامبنیل هم میزاره

                    //context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.Result  = false;
                result.Message = ex.Message;
            }
            finally
            {
                var logResult = bizLogManager.AddLog(GetCreateItemDataLog(message, result.Message), requester);
                if (!string.IsNullOrEmpty(logResult))
                {
                    result.Message += (!string.IsNullOrEmpty(result.Message) ? Environment.NewLine : "") + "خطا در ثبت لاگ" + " , " + logResult;
                }
            }
            return(result);
        }
Beispiel #11
0
 private ArchiveItem CreateItem(bool nested, FileInfo info, string ext)
 {
     ArchiveItem item = null;
       if (ext == ".ZIP" || ext == ".JAR" || ext == ".XPI") {
     item = new ArchiveItem(info.FullName, ArchiveFile.FormatZip, nested);
     item.Group = Files.Groups["GroupZip"];
       }
       else
     if (ext == ".7Z") {
       item = new ArchiveItem(info.FullName, ArchiveFile.FormatSevenZip, nested);
       item.Group = Files.Groups["GroupSevenZip"];
     }
     else
       if (ext == ".RAR") {
     item = new ArchiveItem(info.FullName, ArchiveFile.FormatRar, nested);
     item.Group = Files.Groups["GroupRar"];
       }
       else
     if (ext == ".001") {
       item = new ArchiveItem(info.FullName, ArchiveFile.FormatSplit, nested);
       item.Group = Files.Groups["GroupSplit"];
     }
       return item;
 }
Beispiel #12
0
 public Task(Main aOwner, ArchiveItem aItem, FileInfo aFile, Guid aFormat, ThreadIOPriority aPriority)
 {
     file = new ArchiveFile(aFile, aFormat, aPriority);
     item = aItem;
     owner = aOwner;
     file.ExtractFile += OnExtractFile;
     file.ExtractProgress += OnExtractProgress;
     file.PasswordAttempt += OnPasswordAttempt;
 }
        public void When(ArchiveItem c)
        {
            AbstractItem item;
            if (!_state.TryGet(c.Id, out item))
            {
                throw Error("Item {0} was not found", c.Id);
            }
            AbstractStory story;
            if (!_state.TryGetStory(c.StoryId, out story))
            {
                throw Error("Story {0} was not found", c.StoryId);
            }
            var note = item as NoteItem;
            if (note != null)
            {
                Apply(new NoteArchived(note.Id, c.StoryId));
                return;
            }

            var task = item as TaskItem;

            if (task != null)
            {
                Apply(new TaskArchived(task.Id, c.StoryId));
                return;
            }
            throw Error("We can't move item {0} of type {1} around.", c.Id, item.GetType());
        }