Пример #1
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());
        }
Пример #2
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);
        }
Пример #3
0
        //public Collection<DocumentItemDTO> GetItemsWithOldVersions_beta(int documentId)
        //{
        //    List<DocumentItemDTO> lista = new List<DocumentItemDTO>();

        //    Database db = DatabaseFactory.CreateDatabase();
        //    DocumentItemDTO newItem = null;
        //    using (IDataReader dr = db.ExecuteReader("Dokumenty.pobierzElementyDokumentuZHistoria", documentId))
        //    {
        //        while (dr.Read())
        //        {
        //            if (dr.GetGuid(7) == Guid.Empty)
        //            {
        //                newItem = new DocumentItemDTO(dr.GetGuid(0), dr.GetString(2), dr.GetString(4), dr.GetString(3), dr.GetBoolean(6), dr.GetBoolean(5), dr.GetGuid(7), dr.GetDateTime(1));
        //                lista.Add(newItem);
        //            }
        //            else
        //                newItem.PreviousVersions.Add(new DocumentItemDTO(dr.GetGuid(0), dr.GetString(2), dr.GetString(4), dr.GetString(3), dr.GetBoolean(6), dr.GetBoolean(5), dr.GetGuid(7), dr.GetDateTime(1)));
        //        }
        //    }
        //    return new Collection<DocumentItemDTO>(lista);
        //}

        public Collection <DocumentItemDTO> GetItemsWithOldVersions(int documentId)
        {
            List <DocumentItemDTO> lista       = new List <DocumentItemDTO>();
            List <DocumentItemDTO> listaDzieci = new List <DocumentItemDTO>();
            Database        db              = DatabaseFactory.CreateDatabase();
            DocumentItemDTO newItem         = null;
            Hashtable       hashDocElements = new Hashtable();

            using (IDataReader dr = db.ExecuteReader("Dokumenty.pobierzElementyDokumentuZHistoria", documentId))
            {
                while (dr.Read())
                {
                    newItem = new DocumentItemDTO(dr.GetGuid(0), dr.GetGuid(8), dr.GetString(2), dr.GetString(4), dr.GetString(3), dr.GetBoolean(6), dr.GetBoolean(5), dr.GetGuid(7), dr.GetDateTime(1), (dr["rodzaj"].ToString() == "U"?DocumentItemCategory.Uploaded:DocumentItemCategory.Created));
                    if (newItem.OriginalItemID == Guid.Empty)
                    {
                        lista.Add(newItem);
                    }
                    else
                    {
                        listaDzieci.Add(newItem);
                    }
                }
            }

            IEnumerator listaEnum = lista.GetEnumerator();

            while (listaEnum.MoveNext())
            {
                IEnumerator listaDzieciEnum = listaDzieci.GetEnumerator();
                while (listaDzieciEnum.MoveNext())
                {
                    DocumentItemDTO parent = (DocumentItemDTO)listaEnum.Current;
                    DocumentItemDTO child  = (DocumentItemDTO)listaDzieciEnum.Current;

                    if (child.OriginalItemID == parent.ID)
                    {
                        parent.PreviousVersions.Add(child);
                        listaDzieci.Remove(child);
                        listaDzieciEnum = listaDzieci.GetEnumerator();
                    }
                }
            }

            return(new Collection <DocumentItemDTO>(lista));
        }
Пример #4
0
        protected void listaPlikow_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DocumentItemDTO item = e.Item.DataItem as DocumentItemDTO;

                if (item != null)
                {
                    if (item.Category == DocumentItemCategory.Created)
                    {
                        e.Item.FindControl("Image1").Visible    = false;
                        e.Item.FindControl("Image2").Visible    = false;
                        e.Item.FindControl("Image3").Visible    = true;
                        e.Item.FindControl("imageSave").Visible = false;
                        e.Item.FindControl("openWord").Visible  = true;

                        foreach (Control c in e.Item.FindControl("blok").Controls)
                        {
                            if (c is LinkButton)
                            {
                                if ((c as LinkButton).CommandName == "newVersion")
                                {
                                    c.Visible = false;
                                }
                                if ((c as LinkButton).CommandName == "toggleVersions")
                                {
                                    c.Visible = (item.PreviousVersions.Count > 0);
                                }
                                if ((c as LinkButton).CommandName == "openFile")
                                {
                                    c.Visible = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        e.Item.FindControl("Image1").Visible   = (item.MimeType == "image/tiff");
                        e.Item.FindControl("Image2").Visible   = (item.MimeType != "image/tiff");
                        e.Item.FindControl("Image3").Visible   = false;
                        e.Item.FindControl("openWord").Visible = false;

                        e.Item.FindControl("saveAsPDF").Visible = (item.MimeType == "image/tiff");

                        foreach (Control c in e.Item.FindControl("blok").Controls)
                        {
                            if (c is LinkButton)
                            {
                                if ((c as LinkButton).CommandName == "newVersion")
                                {
                                    c.Visible = (item.OriginalItemID == Guid.Empty);
                                }
                                if ((c as LinkButton).CommandName == "toggleVersions")
                                {
                                    c.Visible = (item.PreviousVersions.Count > 0);
                                }
                                if ((c as LinkButton).CommandName == "openFile")
                                {
                                    c.Visible = (item.Browsable);
                                }
                            }
                        }
                    }
                }
            }
        }