Ejemplo n.º 1
0
        private void txtDesc_Leave(object sender, EventArgs e)
        {
            JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);

            try
            {
                if (grdArchive.SelectedRows.Count == 0)
                {
                    return;
                }
                //int Code = (int)grdArchive[JArchiveFields.Code.ToString(), grdArchive.SelectedRows[0].Index].Value;
                //if (grdArchive[JArchiveFields.Action.ToString(), grdArchive.SelectedRows[0].Index].Value == null)
                //  archive.UpdateDescription(Code, txtDesc.Text);
                //else
                if (grdArchive[JArchiveFields.Action.ToString(), grdArchive.SelectedRows[0].Index].Value.ToString() == "" ||
                    grdArchive[JArchiveFields.Action.ToString(), grdArchive.SelectedRows[0].Index].Value == FileActions.NoAction.ToString())
                {
                    grdArchive[JArchiveFields.Action.ToString(), grdArchive.SelectedRows[0].Index].Value = FileActions.Update;
                }
                grdArchive[JArchiveFields.ArchiveDesc.ToString(), grdArchive.SelectedRows[0].Index].Value = txtDesc.Text;

                if (AfterDescriptioEdited != null)
                {
                    AfterDescriptioEdited(sender, e);
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
            finally
            {
                archive.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void _LoadImagesFromArchive()
        {
            JFile content;

            if (_DataTable != null)
            {
                int OldTop = 0;
                foreach (DataRow DR in _DataTable.Rows)
                {
                    /// کد آرشیو انتخاب شده در گرید
                    int Code = DR["ArchiveCode"].GetHashCode();
                    JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);
                    try
                    {
                        //// بازیابی محتوای آرشیو
                        content = archive._RetrieveContent(Code);

                        if (content != null && content.Extension.ToLower() == ".jpg")
                        {
                            CreateThumbLine(content, DR);
                        }
                    }
                    catch (Exception ex)
                    {
                        JSystem.Except.AddException(ex);
                    }
                    finally
                    {
                        archive.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// بازیابی لیست آرشیوها
        /// </summary>
        /// <returns></returns>
        private bool _LoadDataFromArchive()
        {
            JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);

            try
            {
                if (ClassName == null)
                {
                    ClassName = "";
                    return(false);
                }
                _DataTable = archive.Retrieve(this.ClassName, this.ObjectCode, ExtraObject);
                if (_DataTable.Rows.Count > 0)
                {
                    CurrentDataRow = _DataTable.Rows[0];
                }
                _DataTable.Columns.Add(JArchiveFields.Action.ToString());
                _DataTable.Columns.Add(JArchiveFields.JFile.ToString(), (new JFile()).GetType());
                grdArchive.DataSource = _DataTable;
                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                archive.Dispose();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// بازیابی لیست آرشیوها
        /// </summary>
        /// <returns></returns>
        public bool LoadDataFromArchive()
        {
            JArchiveDocument archive = new JArchiveDocument(SubjectCode, PlaceCode);

            try
            {
                if (ClassName == null)
                {
                    ClassName = "";
                }
                archive.GetData(_ArchiveCode);
                JFile image = archive.RetrieveContent(archive.ArchiveCode);
                if (image == null)
                {
                    return(false);
                }
                ClassName  = archive.ClassName;
                ObjectCode = archive.ObjectCode;
                this.Image = System.Drawing.Image.FromStream(image.Stream);
                object tObject = this.Image;
                JSystem.AddObject(ref tObject);

                return(true);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(false);
            }
            finally
            {
                archive.Dispose();
            }
        }
Ejemplo n.º 5
0
        public bool DeleteAllArchive()
        {
            JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);

            try
            {
                return(archive.DeleteArchive(ClassName, ObjectCode, true));
            }
            finally
            {
                archive.Dispose();
            }
        }
Ejemplo n.º 6
0
        private void jdgRequestList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (jdgRequestList.SelectedRows.Count == 0)
            {
                return;
            }
            JFile content;

            try
            {
                int Status = 0;
                if (this.State == JFormState.Update)
                {
                    if (jdgRequestList.DataSource == null)
                    {
                        Status = Convert.ToInt32(jdgRequestList[0, jdgRequestList.SelectedRows[0].Index].Value);
                    }
                    else
                    {
                        Status = Convert.ToInt32(jdgRequestList.CurrentRow.Cells["Status"].Value);
                    }
                }
                if (ClassLibrary.Domains.Employment.JVacationStatus.Confirm == Status)//
                {
                    /// در صورتی که فایل جدیداً به لیست اضافه شده، بازیابی نمیشود، بلکه محتوای فایل از دیتاتیبل خوانده میشود
                    //if (e.RowIndex != -1)
                    /// کد آرشیو انتخاب شده در گرید
                    int Code = Convert.ToInt32(jdgRequestList[JArchiveFields.ArchiveCode.ToString(), jdgRequestList.SelectedRows[0].Index].Value);
                    JArchiveDocument archive = new JArchiveDocument();
                    archive.GetData(Code);
                    try
                    {
                        //// بازیابی محتوای آرشیو
                        content = archive._RetrieveContent(archive.ArchiveCode);
                        content.Open();
                    }
                    catch (Exception ex)
                    {
                        JSystem.Except.AddException(ex);
                    }
                    finally
                    {
                        archive.Dispose();
                    }
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
        }
Ejemplo n.º 7
0
        private void grdArchive_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (grdArchive.SelectedRows.Count == 0)
            {
                return;
            }
            JFile content;

            try
            {
                /// در صورتی که فایل جدیداً به لیست اضافه شده، بازیابی نمیشود، بلکه محتوای فایل از دیتاتیبل خوانده میشود
                if (e.RowIndex != -1)
                {
                    if (grdArchive.CurrentRow.Cells[JArchiveFields.Action.ToString()].Value != null)
                    {
                        if (grdArchive.CurrentRow.Cells[JArchiveFields.Action.ToString()].Value.ToString() == FileActions.Insert.ToString())
                        {
                            content = (JFile)grdArchive.CurrentRow.Cells["JFile"].Value; // (JFile)_DataTable.Rows[e.RowIndex][JArchiveFields.JFile.ToString()];
                            content.Open();
                        }
                        else
                        {
                            /// کد آرشیو انتخاب شده در گرید
                            int Code = (int)grdArchive[JArchiveFields.ArchiveCode.ToString(), grdArchive.SelectedRows[0].Index].Value;
                            JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);
                            try
                            {
                                //// بازیابی محتوای آرشیو
                                content = archive._RetrieveContent(Code);
                                content.Open();
                            }
                            catch (Exception ex)
                            {
                                JSystem.Except.AddException(ex);
                            }
                            finally
                            {
                                archive.Dispose();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
        }
Ejemplo n.º 8
0
        public bool DeleteAchive()
        {
            JArchiveDocument archive = new JArchiveDocument(DataBaseClassName, DataBaseObjectCode);

            try
            {
                for (int i = 0; i < DeleteCodes.Count; i++)
                {
                    if (!archive.DeleteArchive(DeleteCodes[i], false))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            finally
            {
                archive.Dispose();
            }
        }
Ejemplo n.º 9
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();
            }
        }
Ejemplo n.º 10
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();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// وضعیت
        /// </summary>
        //public int Status { get; set; }
        #endregion

        #region method
        /// <summary>
        /// درج
        /// </summary>
        /// <returns></returns>
        public int Insert(DataTable pArchiveList)
        {
            if (JPermission.CheckPermission("ArchivedDocuments.JRequestArchiveFile.Insert"))
            {
                JDataBase tempDb             = new JDataBase();
                JRequestArchiveFileTable JLT = new JRequestArchiveFileTable();
                JRequestArchiveList      tmpRequestArchiveList = new JRequestArchiveList();
                JArchiveDocument         tmpArchiveDocument    = new JArchiveDocument();
                try
                {
                    tempDb.beginTransaction("JRequestArchiveFile");
                    JLT.SetValueProperty(this);
                    Code = JLT.Insert(tempDb);
                    if (Code > 0)
                    {
                        foreach (DataRow dr in pArchiveList.Rows)
                        {
                            tmpRequestArchiveList.RequestCode = Code;
                            tmpRequestArchiveList.ArchiveCode = Convert.ToInt32(dr["ArchiveCode"]);
                            if (dr["Confirm_Post_Code"].ToString() != "")
                            {
                                tmpRequestArchiveList.Confirm_Post_Code = Convert.ToInt32(dr["Confirm_Post_Code"].ToString());
                            }
                            tmpRequestArchiveList.Confirm_Full_Title = dr["Confirm_Full_Title"].ToString();
                            if (dr["Confirm_User_Code"].ToString() != "")
                            {
                                tmpRequestArchiveList.Confirm_User_Code = Convert.ToInt32(dr["Confirm_User_Code"].ToString());
                            }
                            tmpRequestArchiveList.Status = ClassLibrary.Domains.Employment.JVacationStatus.Request;// Convert.ToInt32(dr["Status"].ToString());
                            //if (dr["StartDate"].ToString() != "")
                            //    tmpRequestArchiveList.StartDate = Convert.ToDateTime(dr["StartDate"]);
                            //if (dr["EndDate"].ToString() != "")
                            //    tmpRequestArchiveList.EndDate = Convert.ToDateTime(dr["EndDate"]);
                            //tmpRequestArchiveList.Description = dr["Description"].ToString();
                            if (tmpRequestArchiveList.Insert(tempDb) < 1)
                            {
                                tempDb.Rollback("JRequestArchiveFile");
                                return(0);
                            }
                            tmpArchiveDocument.GetData(tmpRequestArchiveList.ArchiveCode);
                            if (tmpArchiveDocument.PlaceCode == 0)
                            {
                                tempDb.Rollback("JRequestArchiveFile");
                                JMessages.Error("مکان آرشیو این فایل تعیین نشده است ", "");
                                return(0);
                            }
                            if (!(SendConfirm(tempDb, tmpArchiveDocument.PlaceCode)))
                            {
                                tempDb.Rollback("JRequestArchiveFile");
                                JMessages.Error("Send Not Successfuly ", "");
                                return(0);
                            }
                        }
                        if (tempDb.Commit())
                        {
                            return(Code);
                        }
                        else
                        {
                            tempDb.Rollback("JRequestArchiveFile");
                            return(0);
                        }
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch (Exception ex)
                {
                    JSystem.Except.AddException(ex);
                    tempDb.Rollback("JRequestArchiveFile");
                    return(0);
                }
                finally
                {
                    tempDb.Dispose();
                    JLT.Dispose();
                    tmpRequestArchiveList.Dispose();
                    tmpArchiveDocument.Dispose();
                }
            }
            return(0);
        }
Ejemplo n.º 12
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
            {
            }
        }