Exemplo n.º 1
0
        internal static List <CCSTemplate> DeSerializeActionFromXML(XmlDocument xmlSourceDoc)
        {
            List <CCSTemplate> actions = new List <CCSTemplate>();
            XmlDocument        xmlDoc  = xmlSourceDoc;

            if (xmlDoc == null)
            {
                return(null);
            }

            try
            {
                XmlNode rootNode = null;
                if (xmlSourceDoc == null)
                {
                    rootNode = xmlDoc.CreateElement("Templates");
                    xmlDoc.AppendChild(rootNode);
                }
                else
                {
                    rootNode = xmlDoc.DocumentElement;
                }

                foreach (XmlNode actionNode in rootNode.ChildNodes)
                {
                    string actionID    = actionNode.Attributes[Constants.ActionField.printID].Value;
                    string actionTitle = actionNode.Attributes[Constants.ActionField.printTitle].Value;
                    string printHeader = actionNode.Attributes[Constants.ActionField.printHeader].Value;
                    string printFooter = actionNode.Attributes[Constants.ActionField.printFooter].Value;
                    if (!string.IsNullOrEmpty(actionID) && !string.IsNullOrEmpty(actionTitle))
                    {
                        CCSTemplate action = new CCSTemplate();
                        action.Id     = actionID;
                        action.Title  = actionTitle;
                        action.Header = printHeader;
                        action.Footer = printFooter;
                        XmlNode expressionsNode = actionNode.FirstChild;
                        foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                        {
                            if (expressionNode.Name == Constants.Field.fldNodeName)
                            {
                                string fieldName  = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                Field  expression = new Field();
                                expression.FieldName = fieldName;
                                action.Fields.Add(expression);
                            }
                        }
                        actions.Add(action);
                    }
                }
            }
            catch { }
            if (actions.Count <= 0)
            {
                actions = null;
            }
            return(actions);
        }
Exemplo n.º 2
0
        private static string SerializeActionToXML(CCSTemplate ccsTemplate, XmlDocument xmlSourceDoc)
        {
            XmlDocument xmlDoc = xmlSourceDoc;

            if (xmlSourceDoc == null)
            {
                xmlDoc = new XmlDocument();
            }

            try
            {
                XmlNode rootNode = null;
                if (xmlSourceDoc == null)
                {
                    rootNode = xmlDoc.CreateElement("Templates");
                    xmlDoc.AppendChild(rootNode);
                }
                else
                {
                    rootNode = xmlDoc.DocumentElement;
                }

                XmlNode actionNode;
                actionNode = xmlDoc.CreateElement("Template");
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printID, ccsTemplate.Id));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printTitle, ccsTemplate.Title));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printHeader, ccsTemplate.Header));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printFooter, ccsTemplate.Footer));
                rootNode.AppendChild(actionNode);

                XmlNode expressionsNode = xmlDoc.CreateElement(Constants.ActionField.printExpressions);
                actionNode.AppendChild(expressionsNode);

                foreach (Field expr in ccsTemplate.Fields)
                {
                    XmlNode expressionNode = XMLHelper.CreateNode(xmlDoc, Constants.Field.fldNodeName, string.Empty);
                    expressionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.Field.fldFieldName, expr.FieldName));
                    expressionsNode.AppendChild(expressionNode);
                }
            }
            catch { }
            return(xmlDoc.InnerXml);
        }
Exemplo n.º 3
0
        private static string SerializeActionToXML(CCSTemplate ccsTemplate, XmlDocument xmlSourceDoc)
        {
            XmlDocument xmlDoc = xmlSourceDoc;
            if (xmlSourceDoc == null)
            {
                xmlDoc = new XmlDocument();
            }

            try
            {
                XmlNode rootNode = null;
                if (xmlSourceDoc == null)
                {
                    rootNode = xmlDoc.CreateElement("Templates");
                    xmlDoc.AppendChild(rootNode);
                }
                else
                {
                    rootNode = xmlDoc.DocumentElement;
                }

                XmlNode actionNode;
                actionNode = xmlDoc.CreateElement("Template");
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printID, ccsTemplate.Id));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printTitle, ccsTemplate.Title));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printHeader, ccsTemplate.Header));
                actionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.ActionField.printFooter, ccsTemplate.Footer));
                rootNode.AppendChild(actionNode);

                XmlNode expressionsNode = xmlDoc.CreateElement(Constants.ActionField.printExpressions);
                actionNode.AppendChild(expressionsNode);

                foreach (Field expr in ccsTemplate.Fields)
                {
                    XmlNode expressionNode = XMLHelper.CreateNode(xmlDoc, Constants.Field.fldNodeName, string.Empty);
                    expressionNode.Attributes.Append(XMLHelper.AppendAttribute(xmlDoc, Constants.Field.fldFieldName, expr.FieldName));
                    expressionsNode.AppendChild(expressionNode);
                }
            }
            catch { }
            return xmlDoc.InnerXml;
        }
Exemplo n.º 4
0
 internal static void UpdateTemplate(CCSTemplate ccsTemplate, SPList list)
 {
     DeleteAction(ccsTemplate.Id, list);
     AddTemplate(ccsTemplate, list);
 }
Exemplo n.º 5
0
        internal static void AddTemplate(CCSTemplate ccsTemplate, SPList list)
        {
            XmlDocument xmlDoc = GetConfigFile(list, Constants.ConfigFile.PrintSettingsFile);

            CreateConfigFile(list, Constants.ConfigFile.PrintSettingsFile, SerializeActionToXML(ccsTemplate, xmlDoc));
        }
Exemplo n.º 6
0
        void TemplatesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string fieldName = string.Empty;
            string fldValues = string.Empty;
            string temp = string.Empty;
            string fld2 = string.Empty;
           string printHead = string.Empty, PrintFoot = string.Empty;
           if (TemplatesList.SelectedItem.Text.Equals("- None -"))
           {
               //this.TemplatesList.Items.Clear();
               this.PopulatePage();
           }
           else if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
            {
                XmlDocument xmlDoc = Helper.GetConfigFile(SPContext.Current.List, Constants.ConfigFile.PrintSettingsFile);
                XmlNode rootNode = null;
                if (xmlDoc == null)
                {
                    rootNode = xmlDoc.CreateElement("Templates");
                    xmlDoc.AppendChild(rootNode);
                }
                else
                {
                    rootNode = xmlDoc.DocumentElement;
                }
                foreach (XmlNode printNode in rootNode.ChildNodes)
                {
                    string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                    string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                    string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                    if (!string.IsNullOrEmpty(templateTitle))
                    {
                        CCSTemplate action = new CCSTemplate();
                        XmlNode expressionsNode = printNode.FirstChild;
                        if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                        {
                            foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                            {
                               
                              if (expressionNode.Name == Constants.Field.fldNodeName)
                                {
                                    try
                                    {
                                        fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                        if (fieldName.Equals(Blankrow))
                                        {
                                            fld2 = "";
                                        }
                                        else if(fieldName.StartsWith("- Section:"))
                                        {
                                            fld2 = fieldName;
                                            }
                                            
                                        else
                                        {
                                            fld2 = SPContext.Current.List.Fields.GetField(fieldName).Title;
                                        }

                                        if (string.IsNullOrEmpty(fld2))
                                        {
                                            fld2 = "&nbsp;";
                                            fldValues = string.Empty;
                                        }
                                        else if(fld2.Contains("- Section"))
                                        {
                                            fldValues=string.Empty;
                                        }
                                        else
                                        {
                                            fldValues = Convert.ToString(currentItem[Convert.ToString(fld2)]);
                                        }
                                    }
                                    catch { }
                                }
                                if (!string.IsNullOrEmpty(fldValues))
                                {
                                    if (fldValues.Equals("0;#"))
                                    {
                                        fldValues = string.Empty;
                                    }
                                    else if (fldValues.Contains(";#"))
                                    {
                                        fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2);
                                    }

                                }
                                if (string.IsNullOrEmpty(fld2) || fld2 == "&nbsp;")
                                {
                                    temp += "<tr>" + "<td colspan='2'>"+"&nbsp"+"</td>"+"</tr>";
                                }
                                else if(fld2.Contains("- Section"))
                                {
                                    fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8);
                                    fld2 = fld2.Substring(0, fld2.IndexOf(" "));
                                    temp+= "<tr>" +"<td colspan='2' class='ms-linksectionheader'>"+"<span class='ms-standardheader'>"+fld2+"</span>"+"</td>"+"</tr>";
                                }


                                else
                                {
                                    temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield' bgcolor='#F0F0F0'>" + fldValues + "</td>" + "</tr>";
                                }
                                printHead = printHeader;
                                PrintFoot = printFooter;
                                string op2 =printHead+"<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>"+PrintFoot;
                                BdyTextBox.Text = op2;
                            }
                        }
                    }
                }
                
            }
        }        
Exemplo n.º 7
0
        internal static List<CCSTemplate> DeSerializeActionFromXML(XmlDocument xmlSourceDoc)
        {
            List<CCSTemplate> actions = new List<CCSTemplate>();
            XmlDocument xmlDoc = xmlSourceDoc;
            if (xmlDoc == null)
            {
                return null;
            }

            try
            {
                XmlNode rootNode = null;
                if (xmlSourceDoc == null)
                {
                    rootNode = xmlDoc.CreateElement("Templates");
                    xmlDoc.AppendChild(rootNode);
                }
                else
                {
                    rootNode = xmlDoc.DocumentElement;
                }

                foreach (XmlNode actionNode in rootNode.ChildNodes)
                {
                    string actionID = actionNode.Attributes[Constants.ActionField.printID].Value;
                    string actionTitle = actionNode.Attributes[Constants.ActionField.printTitle].Value;
                    string printHeader = actionNode.Attributes[Constants.ActionField.printHeader].Value;
                    string printFooter = actionNode.Attributes[Constants.ActionField.printFooter].Value;
                    if (!string.IsNullOrEmpty(actionID) && !string.IsNullOrEmpty(actionTitle))
                    {
                        CCSTemplate action = new CCSTemplate();
                        action.Id = actionID;
                        action.Title = actionTitle;
                        action.Header = printHeader;
                        action.Footer = printFooter;
                        XmlNode expressionsNode = actionNode.FirstChild;
                        foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                        {
                            if (expressionNode.Name == Constants.Field.fldNodeName)
                            {
                                string fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                Field expression = new Field();
                                expression.FieldName = fieldName;
                                action.Fields.Add(expression);
                            }
                        }
                        actions.Add(action);
                    }
                }
            }
            catch { }
            if (actions.Count <= 0)
            {
                actions = null;
            }
            return actions;
        }
Exemplo n.º 8
0
 internal static void AddTemplate(CCSTemplate ccsTemplate, SPList list)
 {
     XmlDocument xmlDoc = GetConfigFile(list, Constants.ConfigFile.PrintSettingsFile);
     CreateConfigFile(list, Constants.ConfigFile.PrintSettingsFile, SerializeActionToXML(ccsTemplate, xmlDoc));
 }
Exemplo n.º 9
0
 internal static void UpdateTemplate(CCSTemplate ccsTemplate, SPList list)
 {
     DeleteAction(ccsTemplate.Id, list);
     AddTemplate(ccsTemplate, list);
 }
Exemplo n.º 10
0
       protected void TemplatesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            string fieldName = string.Empty;
            string fldValues = string.Empty;
            string temp = string.Empty;
            string fld2 = string.Empty, printHead = string.Empty, printFoot = string.Empty;
             if (DropDownList1.SelectedValue.Equals("Item"))
            {
                this.PopulatePages();
            }
            else
            {
                string fieldName3 = string.Empty, fld3 = string.Empty, fldValues3 = string.Empty, textVal3 = string.Empty, textVal = string.Empty;
                 if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                    {

                        XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                        XmlNode rootNode = null;
                        if (xmlDoc == null)
                        {
                            rootNode = xmlDoc.CreateElement("Templates");
                            xmlDoc.AppendChild(rootNode);
                        }
                        else
                        {
                            rootNode = xmlDoc.DocumentElement;
                        }
                        foreach (XmlNode printNode in rootNode.ChildNodes)
                        {
                            string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                            string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                            string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                            if (!string.IsNullOrEmpty(templateTitle))
                            {
                                CCSTemplate action = new CCSTemplate();
                                XmlNode expressionsNode = printNode.FirstChild;
                                if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                {
                                    foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                    {
                                        if (expressionNode.Name == Constants.Field.fldNodeName)
                                        {
                                            try
                                            {
                                                fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                fld2 = currentList.Fields.GetField(fieldName3).Title;
                                            }
                                            catch { }
                                        }

                                        textVal3 += "<td class='ms-vh'>" + fld2 + "</td>";
                                    }
                                }
                            }
                        }
                    }

                    foreach (SPListItem selItem in items)
                    {
                        textVal += "<tr>";
                        if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                        {

                            XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                            XmlNode rootNode = null;
                            if (xmlDoc == null)
                            {
                                rootNode = xmlDoc.CreateElement("Templates");
                                xmlDoc.AppendChild(rootNode);
                            }
                            else
                            {
                                rootNode = xmlDoc.DocumentElement;
                            }
                            foreach (XmlNode printNode in rootNode.ChildNodes)
                            {
                                string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                                string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                                string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                                if (!string.IsNullOrEmpty(templateTitle))
                                {
                                    CCSTemplate action = new CCSTemplate();
                                    XmlNode expressionsNode = printNode.FirstChild;
                                    if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                    {
                                        foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                        {
                                            if (expressionNode.Name == Constants.Field.fldNodeName)
                                            {
                                                try
                                                {
                                                    fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                    fld3 = currentList.Fields.GetField(fieldName3).Title;
                                                    fldValues3 = Convert.ToString(selItem[Convert.ToString(fld3)]);

                                                }
                                                catch { }

                                                if (!string.IsNullOrEmpty(fldValues3))
                                                {
                                                    if (fldValues3.Equals("0;#"))
                                                    {
                                                        fldValues3 = string.Empty;
                                                    }
                                                    else if (fldValues3.Contains(";#"))
                                                    {
                                                        fldValues3 = fldValues3.Substring(fldValues3.IndexOf(";#") + 2);
                                                    }

                                                }
                                            }
                                            printHead = printHeader;
                                            printFoot = printFooter;
                                            textVal += "<td class='ms-vb2'>" + fldValues3 + "</td>";

                                        }
                                    }
                                }

                            }
                        }

                        textVal += "</tr>";
                    }
                    BdyTextBox.Text = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr>" + textVal3 + "</tr>" + textVal + "</table>" + "<br>" + printFoot;
                }

            }
Exemplo n.º 11
0
       protected void PopulatePages()
       {
           BdyTextBox.Text = string.Empty;
           string fieldName = string.Empty, fld2 = string.Empty;
           string fldValues = string.Empty, printHead = string.Empty, printFoot = string.Empty, temp = string.Empty, op2 = string.Empty;
           foreach (SPListItem strSelItemsID in items)
           {
                   try
                   {
                       XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                       XmlNode rootNode = null;
                       if (xmlDoc == null)
                       {
                           rootNode = xmlDoc.CreateElement("Templates");
                           xmlDoc.AppendChild(rootNode);
                       }
                       else
                       {
                           rootNode = xmlDoc.DocumentElement;
                       }
                       foreach (XmlNode printNode in rootNode.ChildNodes)
                       {
                           string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                           string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                           string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                           if (!string.IsNullOrEmpty(templateTitle))
                           {
                               CCSTemplate action = new CCSTemplate();
                               XmlNode expressionsNode = printNode.FirstChild;
                               if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                               {
                                   foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                   {
                                       if (expressionNode.Name == Constants.Field.fldNodeName)
                                       {
                                           try
                                           {
                                               fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                               if (fieldName.Equals(Blankrow))
                                               {
                                                   fld2 = "";
                                               }
                                               else if (fieldName.StartsWith("- Section:"))
                                               {
                                                   fld2 = fieldName;
                                               }
                                               else
                                               {
                                                   fld2 = currentList.Fields.GetField(fieldName).Title;
                                               }
                                               //fldValues = currentItem.GetFormattedValue(fieldName);
                                               if (string.IsNullOrEmpty(fld2))
                                               {

                                                   fld2 = "&nbsp;";
                                                   fldValues = string.Empty;
                                               }

                                               else if (fld2.Contains("- Section"))
                                               {
                                                   fldValues = string.Empty;
                                               }
                                               else
                                               {
                                                   fldValues = Convert.ToString(strSelItemsID[fieldName]);
                                               }
                                           }
                                           catch { }
                                       }
                                       if (!string.IsNullOrEmpty(fldValues))
                                       {
                                           if (fldValues.Equals("0;#"))
                                           {
                                               fldValues = string.Empty;
                                           }
                                           else if (fldValues.Contains(";#"))
                                           {
                                               fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2);
                                           }

                                       }
                                       if (string.IsNullOrEmpty(fld2) || fld2 == "&nbsp;")
                                       {
                                           temp += "<tr>" + "<td colspan='2'>" + "&nbsp" + "</td>" + "</tr>";
                                       }
                                       else if (fld2.Contains("- Section"))
                                       {
                                           fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8);
                                           fld2 = fld2.Substring(0, fld2.IndexOf(" "));
                                           temp += "<tr>" + "<td colspan='2' class='ms-linksectionheader'>" + "<span class='ms-standardheader'>" + fld2 + "</span>" + "</td>" + "</tr>";
                                       }
                                       else
                                       {
                                           temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield'>" + fldValues + "</td>" + "</tr>";
                                       }
                                       //style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; background-color:#E0E0E0; font-weight:300; padding:4px\">" + fld2 + "</td>" + "<td class='ms-vb2' style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; padding:4px; background-color: #ffffff\"
                                       printHead = printHeader;
                                       printFoot = printFooter;

                                   }
                               }
                       }
                            
                   }
                 
               }
                   catch { }
               op2 = printHead + "<br>" + "<table class='iw-formtbl' border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>" + "<br>" + printFoot + "<br>" + "<br>" + "<br>" + "<br>";
               BdyTextBox.Text += op2;
               op2 = string.Empty;
               temp = string.Empty;
           }
       }
Exemplo n.º 12
0
        protected void SaveButton_Clicked(object sender, EventArgs e)
        {
            if (this.TooListBox != null && this.TooListBox.Items.Count > 0)
            {
                List<Field> fields = new List<Field>();
                foreach (ListItem item in this.TooListBox.Items)
                {
                    Field newField = new Field();
                    newField.FieldName = item.Value;
                    fields.Add(newField);
                }
                if (this.gvTemplates.SelectedIndex != -1)
                {
                    CCSTemplate selectedAction = this.Templates[this.gvTemplates.SelectedIndex];
                    selectedAction.Title = this.TemplateTitle.Text.Trim();
                    selectedAction.Header = this.RichtextBox.Text.Trim();
                    selectedAction.Footer = this.RichtextBox2.Text.Trim();
                    selectedAction.Fields = fields;
                    selectedAction.Id = selectedAction.Id;

                    Helper.UpdateTemplate(selectedAction, SPContext.Current.List);
                }
                else
                {

                    CCSTemplate newAction = new CCSTemplate();
                    newAction.Title = this.TemplateTitle.Text.Trim();
                    newAction.Header = this.RichtextBox.Text.Trim();
                    newAction.Footer = this.RichtextBox2.Text.Trim();
                    newAction.Id = Guid.NewGuid().ToString();
                    newAction.Fields = fields;
                    Helper.AddTemplate(newAction, SPContext.Current.List);
                }
                btnCancel_Click(sender, e);

            }
            if (this.MessageLabel != null)
            {
                this.MessageLabel.Text = "";
            }
            if (this.ErrorLabel != null)
            {
                this.ErrorLabel.Text = "";
            }
            MessageLabel.Text += " Settings saved successfully.";
 
  
        }
Exemplo n.º 13
0
        protected void PopulatePage()
        {
          
            try
            {

                string textVal = string.Empty, textVal2 = string.Empty;
                string val = string.Empty, printHead = string.Empty, PrintFoot = string.Empty;
           
                this.GetTemplateName();
                
               
                if (items.Length == 1)
                {
                    this.lbl2.Enabled = false;
                    this.DropDownList1.Enabled = false;
                    try
                    {
                        XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                        XmlNode rootNode = null;
                        if (xmlDoc == null)
                        {
                            rootNode = xmlDoc.CreateElement("Templates");
                            xmlDoc.AppendChild(rootNode);
                        }
                        else
                        {
                            rootNode = xmlDoc.DocumentElement;
                        }
                        foreach (XmlNode printNode in rootNode.ChildNodes)
                        {
                            string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                            string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                            string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;


                            foreach (SPField field in currentList.Fields)
                            {

                                try
                                {
                                    if (field != null && !field.Hidden)// && !field.ReadOnlyField
                                    {
                                        System.Web.UI.WebControls.ListItem newFieldItem = new System.Web.UI.WebControls.ListItem(field.Title, field.InternalName);
                                        if (!this.UnvisibleListBox.Items.Contains(newFieldItem) && this.UnvisibleListBox.Items.FindByText(field.Title) == null)
                                            this.UnvisibleListBox.Items.Add(newFieldItem);

                                        //AllFieldsListBox.Items.Add(field.Title);
                                    }
                                }
                                catch { }
                            }


                            for (int i = 0; i < UnvisibleListBox.Items.Count; i++)
                            {
                                try
                                {

                                    val = Convert.ToString(currentItem[Convert.ToString(UnvisibleListBox.Items[i])]);

                                    if (!string.IsNullOrEmpty(val))
                                    {
                                        if (val.Equals("0;#"))
                                        {
                                            val = string.Empty;
                                        }
                                        else if (val.Contains(";#"))
                                        {
                                            val = val.Substring(val.IndexOf(";#") + 2);
                                        }

                                    }
                                }
                                catch { }



                                textVal += "<tr>" + "<td class='ms-formlabel'>" + Convert.ToString(UnvisibleListBox.Items[i]) + "</td>" + "<td class='ms-formfield'>" + val + "</td>" + "</tr>";
                                printHead = printHeader;
                                PrintFoot = printFooter;
                            }
                        }
                    }
                    catch { }
                    BdyTextBox.Text = printHead + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + textVal + "</table>" + PrintFoot;
                }

                else
                {

                    string fieldName2 = string.Empty, fld2 = string.Empty, fldValues2 = string.Empty;
                    if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                    {

                        XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                        XmlNode rootNode = null;
                        if (xmlDoc == null)
                        {
                            rootNode = xmlDoc.CreateElement("Templates");
                            xmlDoc.AppendChild(rootNode);
                        }
                        else
                        {
                            rootNode = xmlDoc.DocumentElement;
                        }
                        foreach (XmlNode printNode in rootNode.ChildNodes)
                        {
                            string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                            string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                            string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                            if (!string.IsNullOrEmpty(templateTitle))
                            {
                                CCSTemplate action = new CCSTemplate();
                                XmlNode expressionsNode = printNode.FirstChild;
                                if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                {
                                    foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                    {
                                        if (expressionNode.Name == Constants.Field.fldNodeName)
                                        {
                                            try
                                            {
                                                fieldName2 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                fld2 = currentList.Fields.GetField(fieldName2).Title;
                                            }
                                            catch { }
                                        }
                                        textVal2 += "<td class='ms-vh'>" + fld2 + "</td>";
                                    }
                                }
                            }
                        }
                    }
                    listItems = new System.Collections.Generic.List<SPListItem>();

                    for (int i = 0; i < items.Length; i++)
                    {
                        SPListItem currentListItem = currentList.GetItemById(int.Parse(items[i]));
                        listItems.Add(currentListItem);

                    }

                    foreach (SPListItem selItem in listItems)
                    {
                        textVal += "<tr>";
                        if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                        {

                            XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                            XmlNode rootNode = null;
                            if (xmlDoc == null)
                            {
                                rootNode = xmlDoc.CreateElement("Templates");
                                xmlDoc.AppendChild(rootNode);
                            }
                            else
                            {
                                rootNode = xmlDoc.DocumentElement;
                            }
                            foreach (XmlNode printNode in rootNode.ChildNodes)
                            {
                                string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                                string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                                string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                                if (!string.IsNullOrEmpty(templateTitle))
                                {
                                    CCSTemplate action = new CCSTemplate();
                                    XmlNode expressionsNode = printNode.FirstChild;
                                    if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                    {
                                        foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                        {
                                            if (expressionNode.Name == Constants.Field.fldNodeName)
                                            {
                                                try
                                                {
                                                    fieldName2 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                    fld2 = currentList.Fields.GetField(fieldName2).Title;
                                                    fldValues2 = Convert.ToString(selItem[Convert.ToString(fieldName2)]);
                                                }
                                                catch { }

                                                if (!string.IsNullOrEmpty(fldValues2))
                                                {
                                                    if (fldValues2.Equals("0;#"))
                                                    {
                                                        fldValues2 = string.Empty;
                                                    }
                                                    else if (fldValues2.Contains(";#"))
                                                    {
                                                        fldValues2 = fldValues2.Substring(fldValues2.IndexOf(";#") + 2);
                                                    }

                                                }
                                            }

                                            textVal += "<td class='ms-vb2'>" + fldValues2 + "</td>";
                                            printHead = printHeader;
                                            PrintFoot = printFooter;

                                        }
                                    }
                                }

                            }
                        }

                        textVal += "</tr>";
                    }
                    BdyTextBox.Text = printHead + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr >" + textVal2 + "</tr>" + textVal + "</table>" + PrintFoot;
                }


            }
            catch { }


        }
Exemplo n.º 14
0
        protected void TemplatesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue.Equals("Item"))
            {
                this.PopulatePages();
            }
            else
            {
                string fieldName = string.Empty;
                string fldValues = string.Empty;
                string temp = string.Empty;
                string fld2 = string.Empty, printHead = string.Empty, printFoot = string.Empty;

                if (items.Length == 1)
                {
                    if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                    {
                        XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                        XmlNode rootNode = null;
                        if (xmlDoc == null)
                        {
                            rootNode = xmlDoc.CreateElement("Templates");
                            xmlDoc.AppendChild(rootNode);
                        }
                        else
                        {
                            rootNode = xmlDoc.DocumentElement;
                        }
                        foreach (XmlNode printNode in rootNode.ChildNodes)
                        {
                            string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                            string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                            string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                            if (!string.IsNullOrEmpty(templateTitle))
                            {
                                CCSTemplate action = new CCSTemplate();
                                XmlNode expressionsNode = printNode.FirstChild;
                                if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                {
                                    foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                    {
                                        if (expressionNode.Name == Constants.Field.fldNodeName)
                                        {
                                            try
                                            {
                                                fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                if (fieldName.Equals(Blankrow))
                                                {
                                                    fld2 = "";
                                                }
                                                else if (fieldName.StartsWith("- Section:"))
                                                {
                                                    fld2 = fieldName;
                                                }
                                                else
                                                {
                                                    fld2 = currentList.Fields.GetField(fieldName).Title;
                                                }
                                                //fldValues = currentItem.GetFormattedValue(fieldName);
                                                if (string.IsNullOrEmpty(fld2))
                                                {

                                                    fld2 = "&nbsp;";
                                                    fldValues = string.Empty;
                                                }

                                                else if (fld2.Contains("- Section"))
                                                {
                                                    fldValues = string.Empty;
                                                }
                                                else
                                                {

                                                    fieldName = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                    fld2 = currentList.Fields.GetField(fieldName).Title;
                                                    //fldValues = currentItem.GetFormattedValue(fieldName);
                                                    fldValues = Convert.ToString(currentItem[Convert.ToString(fieldName)]);
                                                }
                                            }
                                            catch { }
                                        }
                                        if (!string.IsNullOrEmpty(fldValues))
                                        {
                                            if (fldValues.Equals("0;#"))
                                            {
                                                fldValues = string.Empty;
                                            }
                                            else if (fldValues.Contains(";#"))
                                            {
                                                fldValues = fldValues.Substring(fldValues.IndexOf(";#") + 2);
                                            }

                                        }
                                        if (string.IsNullOrEmpty(fld2) || fld2 == "&nbsp;")
                                        {
                                            temp += "<tr>" + "<td colspan='2'>" + "&nbsp" + "</td>" + "</tr>";
                                        }
                                        else if (fld2.Contains("- Section"))
                                        {
                                            fld2 = fld2.Substring(fieldName.IndexOf("Section:") + 8);
                                            fld2 = fld2.Substring(0, fld2.IndexOf(" "));
                                            temp += "<tr>" + "<td colspan='2' class='ms-linksectionheader'>" + "<span class='ms-standardheader'>" + fld2 + "</span>" + "</td>" + "</tr>";
                                        }
                                        else
                                        {
                                            temp += "<tr>" + "<td class='ms-formlabel'>" + fld2 + "</td>" + "<td class='ms-formfield'>" + fldValues + "</td>" + "</tr>";
                                        }
                                        //style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; background-color:#E0E0E0; font-weight:300; padding:4px\">" + fld2 + "</td>" + "<td class='ms-vb2' style=\" color:#000000; font-size:12px; font-family:Arial; border:1px solid #cccccc; padding:4px; background-color: #ffffff\"
                                        printHead = printHeader;
                                        printFoot = printFooter;
                                        string op2 = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + temp + "</table>" + "<br>" + printFoot;
                                        BdyTextBox.Text = op2;
                                    }
                                }
                            }
                        }
                    }
                    else if (TemplatesList.SelectedItem.Text.Equals("- None -"))
                    {
                        //this.TemplatesList.Items.Clear();
                        this.PopulatePage();
                    }
                }
                else
                {
                    string fieldName3 = string.Empty, fld3 = string.Empty, fldValues3 = string.Empty, textVal3 = string.Empty, textVal = string.Empty;
                    if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                    {

                        XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                        XmlNode rootNode = null;
                        if (xmlDoc == null)
                        {
                            rootNode = xmlDoc.CreateElement("Templates");
                            xmlDoc.AppendChild(rootNode);
                        }
                        else
                        {
                            rootNode = xmlDoc.DocumentElement;
                        }
                        foreach (XmlNode printNode in rootNode.ChildNodes)
                        {
                            string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                            string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                            string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                            if (!string.IsNullOrEmpty(templateTitle))
                            {
                                CCSTemplate action = new CCSTemplate();
                                XmlNode expressionsNode = printNode.FirstChild;
                                if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                {
                                    foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                    {
                                        if (expressionNode.Name == Constants.Field.fldNodeName)
                                        {
                                            try
                                            {
                                                fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                fld2 = currentList.Fields.GetField(fieldName3).Title;
                                            }
                                            catch { }
                                        }

                                        textVal3 += "<td class='ms-vh'>" + fld2 + "</td>";
                                    }
                                }
                            }
                        }
                    }
                    listItems = new System.Collections.Generic.List<SPListItem>();

                    for (int i = 0; i < items.Length; i++)
                    {
                        SPListItem currentListItem = currentList.GetItemById(int.Parse(items[i]));
                        listItems.Add(currentListItem);

                    }

                    foreach (SPListItem selItem in listItems)
                    {
                        textVal += "<tr>";
                        if (!string.IsNullOrEmpty(this.TemplatesList.SelectedValue))
                        {

                            XmlDocument xmlDoc = Helper.GetConfigFile(currentList, Constants.ConfigFile.PrintSettingsFile);
                            XmlNode rootNode = null;
                            if (xmlDoc == null)
                            {
                                rootNode = xmlDoc.CreateElement("Templates");
                                xmlDoc.AppendChild(rootNode);
                            }
                            else
                            {
                                rootNode = xmlDoc.DocumentElement;
                            }
                            foreach (XmlNode printNode in rootNode.ChildNodes)
                            {
                                string templateTitle = printNode.Attributes[Constants.ActionField.printTitle].Value;
                                string printHeader = printNode.Attributes[Constants.ActionField.printHeader].Value;
                                string printFooter = printNode.Attributes[Constants.ActionField.printFooter].Value;
                                if (!string.IsNullOrEmpty(templateTitle))
                                {
                                    CCSTemplate action = new CCSTemplate();
                                    XmlNode expressionsNode = printNode.FirstChild;
                                    if (templateTitle.Equals(TemplatesList.SelectedItem.Text))
                                    {
                                        foreach (XmlNode expressionNode in expressionsNode.ChildNodes)
                                        {
                                            if (expressionNode.Name == Constants.Field.fldNodeName)
                                            {
                                                try
                                                {
                                                    fieldName3 = expressionNode.Attributes[Constants.Field.fldFieldName].Value;
                                                    fld3 = currentList.Fields.GetField(fieldName3).Title;
                                                    fldValues3 = Convert.ToString(selItem[Convert.ToString(fld3)]);

                                                }
                                                catch { }

                                                if (!string.IsNullOrEmpty(fldValues3))
                                                {
                                                    if (fldValues3.Equals("0;#"))
                                                    {
                                                        fldValues3 = string.Empty;
                                                    }
                                                    else if (fldValues3.Contains(";#"))
                                                    {
                                                        fldValues3 = fldValues3.Substring(fldValues3.IndexOf(";#") + 2);
                                                    }

                                                }
                                            }
                                            printHead = printHeader;
                                            printFoot = printFooter;
                                            textVal += "<td class='ms-vb2'>" + fldValues3 + "</td>";

                                        }
                                    }
                                }

                            }
                        }

                        textVal += "</tr>";
                    }
                    BdyTextBox.Text = printHead + "<br>" + "<table border='1' style=\"border:1px solid #cccccc;margin-top:10px;margin-bottom:10px;border-collapse:collapse\" width='100%'>" + "<tr>" + textVal3 + "</tr>" + textVal + "</table>" + "<br>" + printFoot;
                }

            }

        }