Example #1
0
        public int ArchiveImage()
        {
            JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);

            try
            {
                /// حذف
                if (Image == null && State == JFormState.Delete)
                {
                    if (archive.DeleteArchive(_ArchiveCode, DeleteCompeletly))
                    {
                        return(0);
                    }
                    else
                    {
                        return(0);
                    }
                }
                /// جدید
                //if (ArchiveCode == 0)
                {
                    if (this.Image != null && (State == JFormState.Insert || State == JFormState.Update))
                    {
                        _ArchiveCode = archive.ArchiveDocument(ImageFile, this.ClassName, this.ObjectCode, this.Description, true);
                    }
                    return(_ArchiveCode);
                }
                //else
                /// ویرایش
                //if (ArchiveCode > 0 && Changed)
                //{
                //return archive.ArchiveDocument(ImageFile, ArchiveCode, this.Description, DeleteCompeletly, true);
                //}
                return(0);
            }
            finally
            {
                archive.Dispose();
            }
        }
Example #2
0
        /// <summary>
        /// آرشیو فایل
        /// </summary>
        /// <param name="pFile"></param>
        /// <returns></returns>
        private bool _ArchiveFile(JFile pFile)
        {
            JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode, DataBaseClassName, DataBaseObjectCode);

            try
            {
                if (archive.ArchiveDocument(pFile, this.ClassName, this.ObjectCode, "", false) > 0)
                {
                    _LoadDataFromArchive();
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                archive.Dispose();
            }
        }
Example #3
0
        /// <summary>
        /// آرشیو کل لیست
        /// </summary>
        /// <returns></returns>
        public bool ArchiveList()
        {
            try
            {
                if (_DataTable == null)
                {
                    return(true);
                }
                if (_DataTable.Rows.Count > 0)
                {
                    JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode, DataBaseClassName, DataBaseObjectCode);
                    try
                    {
                        //archive.BeginTran();
                        foreach (DataRow row in _DataTable.Rows)
                        {
                            try
                            {
                                if (row.RowState != DataRowState.Deleted && row[JArchiveFields.Action.ToString()] != null)
                                {
                                    /// در صورتی که فایل جدید به لیست اضافه شده
                                    if (row[JArchiveFields.Action.ToString()].ToString() == FileActions.Insert.ToString())
                                    {
                                        JFile file = (JFile)row[JArchiveFields.JFile.ToString()];
                                        archive.ArchiveDocument(file, this.ClassName, this.ObjectCode, row[JArchiveFields.ArchiveDesc.ToString()].ToString(), false);
                                    }
                                    /// در صورتی که توضیحات ویرایش شده
                                    //if (row[JArchiveFields.Action.ToString()].ToString() == FileActions.Update.ToString())
                                    if (row.RowState == DataRowState.Modified)
                                    {
                                        archive.UpdateDescription((int)row[JArchiveFields.Code.ToString()], row[JArchiveFields.ArchiveDesc.ToString()].ToString());
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                JSystem.Except.AddException(ex);
                                return(false);
                            }
                        }
                    }
                    finally
                    {
                        archive.Dispose();
                    }


                    ///حذف آیتمهای حذف شده
                    DeleteAchive();
                    //foreach (int deleted in DeleteCodes)
                    //{
                    //    archive.DeleteArchive(deleted, false);
                    //}
                    /// در صورتی که فایلها آرشیو شدند، اکشنشان از اینزرت خارج شود
                    //if (archive.Commit())
                    {
                        foreach (DataRow row in _DataTable.Rows)
                        {
                            try
                            {
                                if (row.RowState != DataRowState.Deleted && row[JArchiveFields.Action.ToString()] != null)
                                {
                                    row[JArchiveFields.Action.ToString()] = FileActions.NoAction;
                                }
                            }
                            catch (Exception ex)
                            {
                                JSystem.Except.AddException(ex);
                            }
                        }
                        return(true);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
            }
        }