private List <PawnDocRegVO> GetDocumentToArchOnlyRecovery(out bool dbCreateError, out bool docGetError)
        {
            List <PawnDocRegVO> list = null;

            dbCreateError = false;
            docGetError   = false;
            int errorCode;

            if (!isRecoveryOnceExecuted)  //check the once executed flag and quit the second time
            {                             //to avoid infinite loop
                isRecoveryOnceExecuted = true;
            }
            else
            {
                return(null);    //return null second time
            }
            if (!DocumentDAO.getInstance().GetDocumentSets(ref list))
            {
                docGetError = true;
                return(null);
            }
            else
            {
                if (!getDBNames(list))
                {
                    dbCreateError = true;
                }
                return(list);
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int docID;
                if (!int.TryParse(Request.QueryString["id"], out docID))
                {
                    throw new Exception("Brak ID w wywołaniu");
                }


                XmlReader xr = new DocumentDAO().GetDataMatrix(docID);

                BarcodeData data;

                XmlSerializer serializer = new XmlSerializer(typeof(BarcodeData));
                data = serializer.Deserialize(xr) as BarcodeData;

                if (data == null)
                {
                    return;
                }

                IDataMatrixService service = new DataMatrixService();
                string             content = service.GetDataMatrixAsHtml(data);

                Response.ClearContent();
                Response.Write(content);
                Response.Flush();
            }
            catch (Exception ex)
            {
                Response.Redirect("~/shared/error.aspx");
            }
        }
Esempio n. 3
0
        public void testRun()
        {
            int    pendCount = 0;
            int    errorCode = 0;
            string errorMsg  = "";

            dao = DocumentDAO.getInstance();

            //List<PawnDocRegVO> vo1 = null;

            log.Info("Calling proc for count");
            try
            {
                //dao.GetDocumentSetsForCount(0,  out pendCount, out errorCode, out errorMsg);
                dao.GetTempGetDocsIDs_ForAdd(ref vo1, 20000, true, 0);
                if (errorCode != 0)
                {
                    execSuccess = false;
                }
                else
                {
                    execSuccess       = true;
                    this.totalRecords = 1000000;
                }
            }
            catch (Exception e)
            {
                log.Error("Exception in TestDocumentDAOThread" + e.Message);
                return;
            }
        }
Esempio n. 4
0
        public string GetDocumentTypeName(string code)
        {
            string text2;
            string text = "";

            try
            {
                if (code == "")
                {
                    return(text);
                }
                EntityData documentTypeByCode = DocumentDAO.GetDocumentTypeByCode(code);
                if (documentTypeByCode.CurrentTable.Rows.Count > 0)
                {
                    text = documentTypeByCode.CurrentRow["TypeName"].ToString();
                }
                documentTypeByCode.Dispose();
                text2 = text;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(text2);
        }
Esempio n. 5
0
        private void Next_Click(object sender, EventArgs e)
        {
            int    errorCode = 0;
            string errorMsg  = "";
            var    dao       = new DocumentProcDAO();

            getLastIndex();
            //resultTable = dao.GetDocuments(startIndex, out totalDoc, out errorCode, out errorMsg);
            List <PawnDocRegVO> docList = null;
            int pendCount = 0;

            this.Enabled = false;
            if (Properties.Settings.Default.TempFetch)
            {
                DocumentDAO.getInstance().GetTempGetDocsIDs_ForAdd(ref docList, 20000, false, startIndex);
            }
            else
            {
                DocumentDAO.getInstance().GetDocumentSets(startIndex, out docList, out pendCount, out errorCode, out errorMsg);
            }

            this.Enabled = true;
            if (errorCode != 0 || totalDoc == 0)
            {
                MessageBox.Show("No Documents found :" + errorMsg);
                return;
            }
            resultTable = CouchConsoleApp.thread.ThreadForDocList.getDataTableFromVO(docList);
            this.resultBindingSource.DataSource = resultTable;

            //enable below for continues looping of proc
            //loopThroughProc();
        }
Esempio n. 6
0
        private void LoadData()
        {
            try
            {
                if (this.txtDocumentTypeCode.Value != "")
                {
                    EntityData entity = DocumentDAO.GetDocumentTypeByCode(this.txtDocumentTypeCode.Value);

                    if (entity.HasRecord())
                    {
                        this.txtTypeName.Value    = entity.GetString("TypeName");
                        this.txtDescription.Value = entity.GetString("Description");
                        this.txtParentCode.Value  = entity.GetString("ParentCode");
                    }
                    else
                    {
                        Response.Write(Rms.Web.JavaScript.Alert(true, "文档类型不存在"));
                        Response.Write(Rms.Web.JavaScript.WinClose(true));
                    }
                    entity.Dispose();
                }

                this.lblParentName.Text = BLL.DocumentRule.Instance().GetDocumentTypeName(this.txtParentCode.Value);
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "显示文档类型错误");
                Response.Write(Rms.Web.JavaScript.Alert(true, "显示文档类型错误"));
            }
        }
Esempio n. 7
0
        public void Save()
        {
            string content        = Serialize();
            var    document       = new dbDocument();
            var    dao            = new DocumentDAO();
            bool   documentExists = dao.hasDocument(uuid);

            //if( !documentExists )
            //    LogManager.Trace("Creating new Test Adapter Description with uuid of {0}", uuid);
            //else
            //    LogManager.Trace("Saving Test Adapter Description with uuid of {0}", uuid);

            document.contentType         = "text/xml";
            document.documentDescription = "Test Adapter";
            document.documentName        = Identification.ModelName;
            document.documentVersion     = version;
            document.documentSize        = content.Length;
            document.documentTypeId      = (int)dbDocument.DocumentType.TEST_ADAPTER_DESCRIPTION;
            document.documentContent     = Encoding.UTF8.GetBytes(content);
            document.UUID      = Guid.Parse(uuid);
            document.DataState = documentExists ? BASEBean.eDataState.DS_EDIT : BASEBean.eDataState.DS_ADD;
            document.save();

            foreach (IdentificationNumber idNumber in Identification.IdentificationNumbers)
            {
                string type   = Enum.GetName(typeof(IdentificationNumberType), idNumber.type);
                string number = idNumber.number;
                var    asset  = new AssetIdentificationBean();
                asset.assetNumber = number;
                asset.assetType   = type;
                asset.uuid        = Guid.Parse(uuid);
                asset.DetermineDataState();
                asset.save();
            }
        }
Esempio n. 8
0
        private void button4_Click(object sender, EventArgs e)
        {
            int    pendCount = 0;
            int    errorCode = 0;
            string errorMsg  = "";

            //var dao = new DocumentProcDAO();
            startIndex = 0;
            //resultTable = dao.GetDocuments(startIndex, out totalDoc, out errorCode, out errorMsg);
            List <PawnDocRegVO> docList = null;

            this.Enabled = false;
            if (Properties.Settings.Default.TempFetch)
            {
                DocumentDAO.getInstance().GetTempGetDocsIDs_ForAdd(ref docList, 20000, true, 0);
            }
            else
            {
                DocumentDAO.getInstance().GetDocumentSets(0, out docList, out pendCount, out errorCode, out errorMsg);
            }
            this.Enabled = true;
            if (errorCode != 0 || docList == null || docList.Count == 0)
            {
                MessageBox.Show("No Documents found :" + errorMsg);
                return;
            }
            this.resultBindingSource.DataSource = CouchConsoleApp.thread.ThreadForDocList.getDataTableFromVO(docList);
            resultBindingSource.MoveLast();
            DataRowView view = (DataRowView)resultBindingSource.Current;

            startIndex = Utilities.GetIntegerValue(view.Row.ItemArray[0]);
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DocumentDAO dao = new DocumentDAO();

            CustomFormVisibilityDTO formVisibility = dao.GetCustomFormVisibility(DocumentId);

            if (formVisibility != null)
            {
                lblXml.Visible     = formVisibility.LegalActXmlVisible;
                lblHistory.Visible = formVisibility.LegalActHistoryVisible;
            }

            lblHistory.CommandArgument = "~/Dokumenty/AktPrawnyHistoria.aspx?id=" + DocumentId;

            string currentOption = Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.LastIndexOf('/') + 1);

            currentOption = currentOption.Substring(0, currentOption.LastIndexOf('.'));

            switch (currentOption.ToLower())
            {
            case "aktprawnyhistoria":
                currentItem = lblHistory.ID;
                break;

            case "aktprawnyxml":
                currentItem = lblXml.ID;
                break;
            }
        }
Esempio n. 10
0
        public async Task <ActionResult> UpdateDoc(HttpPostedFileBase file, string DocID)
        {
            DocumentDAO docDao = new DocumentDAO();
            DOCUMENT    doc    = new DOCUMENT();

            doc.TOPIC_ID = docDao.GetTopicIDByDoc(DocID);
            doc.ID       = DocID;
            // docDao.DeleteDocument(DocID);
            string     title = docDao.GetTitle(DocID);
            FileStream stream;

            if (file != null)
            {
                // string a = file.FileName;
                //string b = file.ContentType;
                string path = Path.Combine(Server.MapPath("~/Content/tempFile"), file.FileName);
                file.SaveAs(path);
                stream = new FileStream(Path.Combine(path), FileMode.Open);
                await Task.Run(() => Delete(title));

                await Task.Run(() => Upload(stream, file.FileName, path));

                doc.TITLE = file.FileName;
                doc.LINK  = CommonConstants.linkFile;
                if (docDao.UpdateDocument(doc))
                {
                    return(Json(new { status = true, file = new { filename = file.FileName, link = CommonConstants.linkFile } }));
                }
            }
            return(Json(new { status = false }));
        }
Esempio n. 11
0
        //Stream IDownloadFileTask.GetTempFileToPDF(string path, out string mimeType, out string fileName)
        //{
        //    if (!File.Exists(path))
        //        throw new ArgumentException("Nie ma takiego pliku");
        //    FileStream fs = File.OpenRead(path);

        //    Image img = Image.FromStream(fs);

        //    TiffImageSplitter tiff = new TiffImageSplitter();
        //    PdfDocument doc = new PdfDocument();
        //    int pageCount = tiff.getPageCount(img);

        //    for (int i = 0; i < pageCount; i++)
        //    {
        //        PdfPage page = new PdfPage();
        //        Image tiffImg = tiff.getTiffImage(img, i);
        //        XImage ximg = XImage.FromGdiPlusImage(tiffImg);

        //        page.Width = ximg.PointWidth;
        //        page.Height = ximg.PointHeight;
        //        doc.Pages.Add(page);

        //        XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[i]);
        //        xgr.DrawImage(ximg, 0, 0);
        //    }

        //    mimeType = "application/pdf";
        //    fileName = Path.ChangeExtension(Path.GetFileName(path), "pdf");

        //    MemoryStream ms = new MemoryStream();
        //    doc.Save(ms, false);
        //    return ms;

        //}

        Stream IDownloadFileTask.GetFile(Guid imageID, out string mimeType, out string fileName, int pageNumber)
        {
            IItemStorage storage = ItemStorageFactory.Create();
            DocumentDAO  dao     = new DocumentDAO();

            DTO.DocumentItemDTO item = dao.GetItem(imageID);
            if (item == null)
            {
                throw new ArgumentException("Nie ma takiego pliku");
            }
            mimeType = item.MimeType;
            fileName = item.OriginalName;
            if (pageNumber > 0 && mimeType.ToLower() == "image/tiff")
            {
                Image img = new Bitmap(storage.Load(imageID));
                img.SelectActiveFrame(FrameDimension.Page, pageNumber - 1);
                MemoryStream ms = new MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
                return(ms);
            }
            else
            {
                return(storage.Load(imageID));
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            dgvM.DataSource = null;
            var documents = new DocumentDAO().GetDocument(int.Parse(txtCNE.Text));

            dgvM.DataSource = documents;
        }
        private void FrmDocuments_Load(object sender, EventArgs e)
        {
            dgvM.DataSource = null;
            var documents = new DocumentDAO().GetDocuments();

            dgvM.DataSource = documents;
        }
 public static DocumentDAO getInstance()
 {
     if (documentDAO == null)
     {
         documentDAO = new DocumentDAOImplementation();
     }
     return(documentDAO);
 }
Esempio n. 15
0
        private void BindHistory(int docID)
        {
            List <DataMatrixHistoryItem> historyItems = new DocumentDAO().GetDataMatrixHistory(docID);

            historyGrid.DataSource    = historyItems;
            historyGrid.RowDataBound += new GridViewRowEventHandler(historyGrid_RowDataBound);
            historyGrid.DataBind();
        }
Esempio n. 16
0
        protected void zapisz_Click(object sender, EventArgs e)
        {
            DocumentDAO dao = new DocumentDAO();
            FileStream  fs  = File.OpenRead(Pemi.Esoda.Tools.Configuration.PhysicalTemporaryDirectory + "\\" + temporaryFileName);

            if (forceUpdate.Visible && forceUpdate.Checked)
            {
                dao.AddNewVersionOfDocumentItem(IdDokumentu, IdOryginalu, fileDescription.Text, fs, mimeType.Text, fileName.Text, DocumentItemCategory.Uploaded);
                IdOryginalu = Guid.Empty;
            }
            else
            {
                Guid itemId = Guid.Empty;
                dao.AddNewDocumentItem(IdDokumentu, fileName.Text, fileDescription.Text, fs, mimeType.Text, ref itemId, DocumentItemCategory.Uploaded);
                //int docId = dao.AddNewDocument(new Guid(Membership.GetUser().ProviderUserKey.ToString()), md.GetXml());

                DocumentItemDTO docItem = dao.GetItem(itemId);
                string          imie = String.Empty, nazwisko = string.Empty;
                DbDataReader    dr = (DbDataReader)(new UserDAO()).GetEmployee(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                if (dr.Read())
                {
                    imie     = dr["imie"].ToString();
                    nazwisko = dr["nazwisko"].ToString();
                }
                dr.Close();

                List <string> paramList = new List <string>();
                paramList.Add(fileName.Text);
                ActionLogger al = new ActionLogger(new ActionContext(new Guid("9cd585bb-2a06-4c24-b415-aa3f8b00ea5f"), new Guid(Membership.GetUser().ProviderUserKey.ToString()), Membership.GetUser().UserName, Membership.GetUser().Comment, paramList));

                al.AppliesToDocuments.Add(IdDokumentu);
                al.ActionData.Add("idDokumentu", IdDokumentu.ToString());
                al.ActionData.Add("idPracownika", Membership.GetUser().UserName);
                al.ActionData.Add("imie", imie);
                al.ActionData.Add("nazwisko", nazwisko);
                al.ActionData.Add("dataDodania", docItem.CreationDate.ToString());
                al.ActionData.Add("idPliku", docItem.ID.ToString());
                al.ActionData.Add("nazwaPliku", fileName.Text);

                /* Nr systemowy dokumentu logicznego
                 * Id pracownika (login) (który dokonuje operacji do³¹czenia)
                 * imie pracownika
                 * nazwisko pracownika,
                 * Data dolaczenia pliku
                 * Czas dolaczenia pliku
                 * Id systemowe (guid?) dolaczanego pliku
                 * Nazwa do³¹czanego pliku*/


                al.Execute();
            }
            fs.Close();
            DeleteTemporaryFile();

            Response.Redirect("~/Dokumenty/SkladnikiDokumentu.aspx?id=" + CoreObject.GetId(Request).ToString());
        }
Esempio n. 17
0
        /// <summary> Retrieves in this DocumentCollection object all DocumentEntity objects which are related via a  relation of type 'm:n' with the passed in ProductEntity.
        /// All current elements in the collection are removed from the collection.</summary>
        /// <param name="productInstance">ProductEntity object to be used as a filter in the m:n relation</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="pageNumber">The page number to retrieve.</param>
        /// <param name="pageSize">The page size of the page to retrieve.</param>
        /// <returns>true if the retrieval succeeded, false otherwise</returns>
        public virtual bool GetMultiManyToManyUsingProductCollectionViaProductDocument(IEntity productInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, int pageNumber, int pageSize)
        {
            if (!base.SuppressClearInGetMulti)
            {
                this.Clear();
            }
            DocumentDAO dao = DAOFactory.CreateDocumentDAO();

            return(dao.GetMultiUsingProductCollectionViaProductDocument(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, productInstance, pageNumber, pageSize));
        }
Esempio n. 18
0
        private void DisableCategoryAndType(int docId)
        {
            bool isFilled = new DocumentDAO().IsCustomFormFilled(docId);

            if (isFilled)
            {
                this.kategoria.Enabled = false;
                this.rodzaj.Enabled    = false;
            }
        }
        private void btnAddC_Click(object sender, EventArgs e)
        {
            Document doc = new Document(0, txtNom.Text, txtPrenom.Text);

            doc.Etudiant = new EtudiantDAO().GetEtudiantByCNE(txtCNE.Text).FirstOrDefault <Etudiant>();
            DocumentDAO docDAO = new DocumentDAO();
            int         rs     = docDAO.InsertDocument(doc);

            MessageBox.Show("COco");
        }
Esempio n. 20
0
 private DataManager()
 {
     equpmentDAO = new EquipmentDAO();
     signalDAO   = new SignalDAO();
     helpDAO     = new HelpDAO();
     standardUnitMeasurementDAO = new StandardUnitMeasurementDAO();
     lookupTablesDAO            = new LookupTablesDAO();
     documentDAO = new DocumentDAO();
     schemaDAO   = new SchemaDAO();
 }
Esempio n. 21
0
        private int saveGenericDocument(string filePath, string originalFilename, string mimeType, Guid documentGuid, Guid?elementVersionGuid, string description, string desiredName, string ticket)
        {
            DocumentDAO dao    = new DocumentDAO();
            Guid        userID = new MSOIntegrationDAO().GetUseGuidFromTicket(ticket);
            Guid        itemId = Guid.Empty;

            int documentID = dao.GetDocumentIDForGuid(documentGuid);

            if (documentID == 0)
            {
                return(-1);
            }
            FileStream fs = File.OpenRead(filePath);

            try
            {
                if (!elementVersionGuid.HasValue)
                {
                    dao.AddNewDocumentItem(documentID, originalFilename, description, fs, mimeType, ref itemId, DocumentItemCategory.Created);

                    DocumentItemDTO docItem  = dao.GetItem(itemId);
                    string[]        fullname = Membership.GetUser(userID).Comment.Split(' ');

                    string imie     = fullname.Length >= 2 ? fullname[1] : string.Empty;
                    string nazwisko = fullname.Length >= 1 ? fullname[0] : string.Empty;


                    List <string> paramList = new List <string>();
                    paramList.Add(originalFilename);


                    ActionLogger al = new ActionLogger(new ActionContext(new Guid("9cd585bb-2a06-4c24-b415-aa3f8b00ea5f"), userID, Membership.GetUser(userID).UserName, Membership.GetUser(userID).Comment, paramList));

                    al.AppliesToDocuments.Add(documentID);
                    al.ActionData.Add("idDokumentu", documentID.ToString());
                    al.ActionData.Add("idPracownika", Membership.GetUser(userID).UserName);
                    al.ActionData.Add("imie", imie);
                    al.ActionData.Add("nazwisko", nazwisko);
                    al.ActionData.Add("dataDodania", docItem.CreationDate.ToString());
                    al.ActionData.Add("idPliku", docItem.ID.ToString());
                    al.ActionData.Add("nazwaPliku", originalFilename);
                    al.Execute();
                }
                else
                {
                    dao.AddNewVersionOfDocumentItem(documentID, elementVersionGuid.Value, description, fs, mimeType, desiredName, DocumentItemCategory.Created);
                }
            }
            catch
            {
                return(-2);
            }
            return(0);
        }
Esempio n. 22
0
        private void countProc_Click(object sender, EventArgs e)
        {
            List <PawnDocRegVO> vo1 = new List <PawnDocRegVO>();
            DocumentDAO         dao = DocumentDAO.getInstance();
            int    pendCount        = 0;
            int    errorCode        = 0;
            string errorMsg         = "";

            dao.CountProcTest(0, out vo1, out pendCount, out errorCode, out errorMsg);
            dao.GetDocumentSets(0, out vo1, out pendCount, out errorCode, out errorMsg);
        }
Esempio n. 23
0
        public static List <Document> GetDocumentsByType(int documentTypeId)
        {
            DocumentDAO       documentDAO = DataManager.getDocumentDAO();
            var               documents   = new List <Document>();
            List <dbDocument> docs        = documentDAO.GetDocumentsByType(documentTypeId);

            foreach (dbDocument doc in docs)
            {
                documents.Add(new Document(doc));
            }
            return(documents);
        }
Esempio n. 24
0
        public async Task <JsonResult> DeleteDoc(string id)
        {
            DocumentDAO docDao = new DocumentDAO();
            string      title  = docDao.GetTitle(id);

            if (docDao.DeleteDocument(id))
            {
                await Task.Run(() => Delete(title));

                return(Json(new { status = true }));
            }
            return(Json(new { status = false }));
        }
Esempio n. 25
0
        public static string CreateDocumentPlaceHolder(string partNumber, string assetType, string contentType,
                                                       string docType, string description)
        {
            string      refId = null;
            var         asset = new AssetIdentificationBean();
            DocumentDAO dao   = DataManager.getDocumentDAO();

            try
            {
                dao.StartTransaction();
                //Lookup Part Number for document
                string   rootPartNumber = partNumber.Split('#')[0];
                Document document       = GetDocument(rootPartNumber,
                                                      (int)Enum.Parse(typeof(dbDocument.DocumentType), docType));
                if (document == null)
                {
                    document                 = new Document();
                    document.uuid            = Guid.NewGuid().ToString();
                    document.name            = rootPartNumber;
                    document.Item            = ""; //Content
                    document.DocumentContent = Encoding.UTF8.GetBytes(document.Item);
                    document.ContentType     = contentType ?? "";
                    document.Description     = (description.Length > 255?description.Substring(0, 254):description) ?? "";
                    document.DocumentType    =
                        (dbDocument.DocumentType)Enum.Parse(typeof(dbDocument.DocumentType), docType);
                    SaveDocument(document);
                }

                //Add reference id to asset lookup
                asset             = new AssetIdentificationBean();
                asset.uuid        = Guid.Parse(document.uuid);
                asset.assetType   = assetType;
                asset.assetNumber = partNumber;
                asset.DataState   = BASEBean.eDataState.DS_ADD;
                asset.save();
                refId = asset.uuid.ToString();
                dao.CommitTransaction();
                LogManager.Trace("A placeholder document for \"{0}\" has been created.", partNumber);
            }
            catch (Exception e)
            {
                dao.RollbackTransaction();
                LogManager.Error(e, "An Error occurred creating a document for \"{0}\"", partNumber);
            }
            finally
            {
                dao.EndTransaction();
            }
            return(refId);
        }
Esempio n. 26
0
        public AssetIdentificationBean DetermineDataState()
        {
            var dao = new DocumentDAO();

            if (dao.HasAsset(assetType, assetNumber, uuid.ToString()))
            {
                DataState = eDataState.DS_EDIT;
            }
            else
            {
                DataState = eDataState.DS_ADD;
            }
            return(this);
        }
        private void btnDeleteC_Click(object sender, EventArgs e)
        {
            var eDAO = new DocumentDAO();

            eDAO.DeleteDocument(int.Parse(dgvM.CurrentRow.Cells[0].Value.ToString()));
            dgvM.DataSource = null;
            var documents = new DocumentDAO().GetDocuments();

            foreach (var item in documents)
            {
                Console.WriteLine(item);
            }
            dgvM.DataSource = documents;
        }
        private List <PawnDocRegVO> GetDocumentToArchTemp(out bool dbCreateError, out bool docGetError)
        {
            List <PawnDocRegVO> list = null;

            dbCreateError = false;

            //tmp logic
            if (tempSoFarCount > 1000000)
            {
                docGetError = false;
                return(null);
            }

            if (this.archDocIndex == 0)
            {
                //DocumentDAO.getInstance().GetDocumentSets(ref list, fetchCount,true,0);
                docGetError = DocumentDAO.getInstance().GetTempGetDocsIDs(ref list, fetchCount, true, 0);
                if (list != null && list.Count > 0)
                {
                    archDocIndex = (list[list.Count - 1]).DocID;
                }
                // return list;
            }
            else
            {
                //DocumentDAO.getInstance().GetDocumentSets(ref list, fetchCount, false, archDocIndex);
                docGetError = DocumentDAO.getInstance().GetTempGetDocsIDs(ref list, fetchCount, false, archDocIndex);
                if (list != null && list.Count > 0)
                {
                    archDocIndex = (list[list.Count - 1]).DocID;
                }
            }
            if (!getDBNames(list))
            {
                dbCreateError = true;
            }

            //tmp logic
            if (list != null)
            {
                tempSoFarCount += list.Count;
            }
            if (tempSoFarCount > 1000000)
            {
                return(null);
            }
            //tmp logic
            return(list);
        }
Esempio n. 29
0
        Stream IDownloadFileTask.GetTiffToPDF(Guid imageID, out string mimeType, out string fileName)
        {
            IItemStorage storage = ItemStorageFactory.Create();
            DocumentDAO  dao     = new DocumentDAO();

            DTO.DocumentItemDTO item = dao.GetItem(imageID);
            if (item == null)
            {
                throw new ArgumentException("Nie ma takiego pliku");
            }

            if (item.MimeType.ToLower() == "image/tiff")
            {
                Image img = new Bitmap(storage.Load(imageID));

                TiffImageSplitter tiff = new TiffImageSplitter();
                PdfDocument       doc  = new PdfDocument();
                int pageCount          = tiff.getPageCount(img);

                for (int i = 0; i < pageCount; i++)
                {
                    PdfPage page = new PdfPage();

                    Image tiffImg = tiff.getTiffImage(img, i);

                    XImage ximg = XImage.FromGdiPlusImage(tiffImg);

                    page.Width  = ximg.PointWidth;
                    page.Height = ximg.PointHeight;
                    doc.Pages.Add(page);

                    XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[i]);

                    xgr.DrawImage(ximg, 0, 0);
                }

                mimeType = "application/pdf";
                fileName = Path.ChangeExtension(item.OriginalName, "pdf");

                MemoryStream ms = new MemoryStream();
                doc.Save(ms, false);
                return(ms);
            }
            else
            {
                throw new ArgumentException("Podany plik nie jest plikiem TIFF");
            }
        }
Esempio n. 30
0
        private void loadScanPreview()
        {
            DocumentDAO dao = new DocumentDAO();
            Collection <DocumentItemDTO> items = dao.GetItems(DocumentID);

            if (items.Count == 0)
            {
                previewUnavailable();
                return;
            }
            IEnumerable <DocumentItemDTO> scans = items.OrderBy(item => item.Browsable).SkipWhile(item => item.Browsable == false);


            if (scans.Count() == 0)
            {
                previewUnavailable();
                return;
            }

            foreach (DocumentItemDTO item in scans)
            {
                fsGuids.Add(item.ID);
            }

            ImageHelper helper = new ImageHelper(fsGuids[0]);

            helper.AktualnaSzerokosc = 600;
            if (PageNumber > 0 && PageNumber <= helper.LiczbaStron)
            {
                helper.AktualnaStrona = PageNumber;
            }
            else
            if (PageNumber > helper.LiczbaStron)
            {
                PageNumber = helper.LiczbaStron;
            }
            if (helper.LiczbaStron > 1)
            {
                btnNext.Enabled = true;
                btnPrev.Enabled = true;
            }
            else
            {
                btnNext.Enabled = false;
                btnPrev.Enabled = false;
            }
            imagePreview.ImageUrl = helper.UrlObrazka + "?" + Guid.NewGuid().ToString();
        }