Beispiel #1
0
        private void LoadDocumentList()
        {
            lbCategoryList.Items.Clear();
            ListNGSObject list = new ListNGSObject();

            foreach (DocumentTemplateFlow flow in list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C"))
            {
                lbCategoryList.Items.Add(flow.DocumentTemplateFlowName);
            }
        }
Beispiel #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lbCategoryList.SelectedIndex > -1)
     {
         ListNGSObject list = new ListNGSObject();
         foreach (DocumentTemplateFlow flow in list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" &&
                                                                                        t.DocumentTemplateFlowName == lbCategoryList.Items[lbCategoryList.SelectedIndex].ToString()))
         {
             flow.Delete();
             MessageBox.Show("Kategoria została usunięta", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LoadDocumentList();
         }
     }
 }
Beispiel #3
0
        public void LoadTreeDocuments()
        {
            tVDocuments.Nodes.Clear();

            ListNGSObject list = new ListNGSObject();

            documentTemplateList = list.GetDocumentTemplateList();
            documentTemplateFlowAssignmentList = list.GetDocumentTemplateFlowAssignmentList();
            documentTemplateFlowList           = list.GetDocumentTemplateFlowList();

            TreeNode root = new TreeNode("Dokumenty");

            LoadTreeDocuments(root, documentTemplateFlowList.Where(t => t.DocumentTemplateFlowType == "S" || t.DocumentTemplateFlowType == "L").ToList <DocumentTemplateFlow>());

            tVDocuments.ShowNodeToolTips = true;
            tVDocuments.Nodes.Add(root);

            TreeNode rejestrZbiorow = new TreeNode("Rejestr czynności");

            rejestrZbiorow.ContextMenu = GetMenuToRejestrZbiorow();
            tVDocuments.Nodes.Add(rejestrZbiorow);

            TreeNode dziennikLogow = new TreeNode("Dziennik logów");

            dziennikLogow.ContextMenu = GetMenuToDziennikLogow();
            tVDocuments.Nodes.Add(dziennikLogow);

            TreeNode nosnikiDataCare = new TreeNode("Nośniki w DataCare");

            nosnikiDataCare.ContextMenu = GetNosnikiDataCare();
            tVDocuments.Nodes.Add(nosnikiDataCare);

            TreeNode mojeDokumenty = new TreeNode("Moje dokumenty");

            LoadTreeDocuments(mojeDokumenty, documentTemplateFlowList.Where(t => t.DocumentTemplateFlowType == "C").ToList <DocumentTemplateFlow>());

            tVDocuments.Nodes.Add(mojeDokumenty);


            tVDocuments.CollapseAll();
        }
Beispiel #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(tbNewCategory.Text))
            {
                ListNGSObject list = new ListNGSObject();
                if (list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" && t.DocumentTemplateFlowName == tbNewCategory.Text).Count() > 0)
                {
                    MessageBox.Show("Nie można dodac dwóch takich samych kategorii.", "NGSDocument - błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    DocumentTemplateFlow dtf = new DocumentTemplateFlow();
                    dtf.DocumentTemplateFlowGUID = GlobalVariables.GetNewGUID();
                    dtf.DocumentTemplateFlowType = "C";
                    dtf.DocumentTemplateFlowName = tbNewCategory.Text;

                    dtf.Save();

                    MessageBox.Show("Kategoria została dodana.", "Infomracja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tbNewCategory.Text = "";
                    LoadDocumentList();
                }
            }
        }
Beispiel #5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(cbCategory.Text))
            {
                MessageBox.Show("Musisz wybrać kategorię do której ma być przypisany szablon!", "Błąd - import szablonów", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (String.IsNullOrEmpty(tbNazwaSzablonu.Text))
            {
                MessageBox.Show("Musisz podać nazwę szablonu!", "Błąd - import szablonów", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!String.IsNullOrEmpty(tbTemplatePath.Text) && !String.IsNullOrEmpty(cbCategory.Text))
            {
                listOfFields = new Dictionary <string, FieldBeforeAfter>();
                System.IO.StreamReader stream = new System.IO.StreamReader(tbTemplatePath.Text, Encoding.GetEncoding("Windows-1250"));
                htmlDoc.Load(stream);

                string body = htmlDoc.DocumentNode.SelectNodes("//body")[0].InnerText.Replace(Environment.NewLine, " ").Replace("  ", " ");

                string before    = "";
                string after     = "";
                string fieldName = "";
                for (int i = 0; i < body.Length; i++)
                {
                    if (body[i] == '{' && i + 1 < body.Length && body[i + 1] == '#')
                    {
                        if (fieldName != "")
                        {
                            addToList(listOfFields, fieldName, null, after);
                        }

                        fieldName = "";
                        after     = "";
                        for (int j = i + 2; j < body.Length; j++)
                        {
                            if (body[j] == '#' && j + 1 < body.Length && body[j + 1] == '}')
                            {
                                addToList(listOfFields, fieldName, before, null);
                                i      = j + 1;
                                before = "";
                                break;
                            }
                            else
                            {
                                fieldName += body[j];
                            }
                        }
                    }
                    else
                    {
                        before += body[i];
                        if (fieldName != "")
                        {
                            after += body[i];
                        }
                    }
                }
                if (fieldName != "")
                {
                    addToList(listOfFields, fieldName, null, after);
                }

                //label3.Text = "Znaleziona " + listOfFields.Count + " pola w szablone.";
                stream.Close();

                if (cbValidEndDate.Checked == true)
                {
                    bool dateFiledExists = false;
                    foreach (FieldBeforeAfter fba in listOfFields.Values)
                    {
                        if (fba.FieldName == "DataWygasniecia")
                        {
                            dateFiledExists = true;
                        }
                    }

                    if (!dateFiledExists)
                    {
                        MessageBox.Show("Pole {#DataWygasniecia#} nie występuje w szablonie. Proszę odznacz ważność dokumentu lub dodaj do szablonu wymagane pole.", "Import szablonu błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                //IMPORT
                stream = new System.IO.StreamReader(tbTemplatePath.Text, Encoding.GetEncoding("Windows-1250"));
                string newBody = stream.ReadToEnd();
                foreach (FieldBeforeAfter fba in listOfFields.Values)
                {
                    newBody = newBody.Replace("{#" + fba.FieldName + "#}", "<ngs_input name='" + fba.FieldName + "' caption='" + fba.FieldName + "' style=\"background-color: #FFFF00;\">.......</ngs_input>");
                }

                newBody = newBody.Replace("<head>", "<head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\" />");

                DocumentTemplate dt = new DocumentTemplate();
                dt.DocumentHint         = "";
                dt.DocumentName         = tbNazwaSzablonu.Text;
                dt.DocumentTemplateGUID = GlobalVariables.GetNewGUID();
                dt.DocumentText         = newBody;
                dt.DocumentType         = "D";
                dt.DocumentEndDate      = cbValidEndDate.Checked ? "Y" : "N";
                dt.Save();
                stream.Close();

                ListNGSObject list = new ListNGSObject();



                DocumentTemplateFlowAssignment dtfa = new DocumentTemplateFlowAssignment();
                dtfa.DocumentPosition = 1;
                dtfa.DocumentTemplateFlowAssignmentGUID = GlobalVariables.GetNewGUID();
                dtfa.DocumentTemplateGUID     = dt.DocumentTemplateGUID;
                dtfa.DocumentTemplateFlowGUID = list.GetDocumentTemplateFlowList().Where(t => t.DocumentTemplateFlowType == "C" && t.DocumentTemplateFlowName == cbCategory.Text).First().DocumentTemplateFlowGUID;

                dtfa.Save();

                MessageBox.Show("Szablon został zaimportowany", "Informacja - szablon", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //((MainWindow)(this.Parent.Parent)).LoadTreeDocuments();
            }
        }