コード例 #1
0
        /// <summary>
        /// Load event of windows form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExportToXml_Load(object sender, EventArgs e)
        {
            try
            {
                lblMessage.Visible      = false;
                cbDocType.SelectedIndex = 0;
                repData = new RepositoryData();

                string        siteUrl       = ConfigurationManager.AppSettings["Site"];
                ClientContext clientContext = new ClientContext(siteUrl);
                collListItem = repData.LoadSubclassList(clientContext);
                lstMF        = new List <SubclassClass>();

                foreach (ListItem oListItem in collListItem)
                {
                    if (oListItem["Subclass"].ToString() != "All")
                    {
                        FieldLookupValue lookup = oListItem["Class"] as FieldLookupValue;
                        SubclassClass    MF     = new SubclassClass();
                        MF.SubclassName = oListItem["Subclass"].ToString();

                        MF.ClassName = lookup.LookupValue;
                        if (MF.ClassName == "Guru")
                        {
                            MF.ClassAlias = "GG";
                        }
                        else if (MF.ClassName == "Lara")
                        {
                            MF.ClassAlias = "LL";
                        }
                        else
                        {
                            MF.ClassAlias = "CH";
                        }

                        lstMF.Add(MF);
                        lstSubclass.Items.Add(MF.SubclassName);
                    }
                }
            }
            catch (Exception exec)
            {
                logger.WriteEventLog("Please contact admin : " + exec.Message);
                throw exec;
            }
        }
コード例 #2
0
        /// <summary>
        /// Click event of export button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private void btnExport_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Export will take some time to complete. Press OK to continue.");
            lblMessage.Visible = true;
            lblMessage.Text    = "Export started, please wait…";
            List <string> Class = GetSelectedClass();

            try
            {
                if (lstSubclass.SelectedIndex >= 0)
                {
                    writeXml = new WriteXML();
                    repData  = new RepositoryData();
                    logger   = new Logger();
                    ListItemCollection   listItemColl  = null;
                    string               siteUrl       = ConfigurationManager.AppSettings["SiteUrl"];
                    ClientContext        clientContext = new ClientContext(siteUrl);
                    List <SubclassClass> listSubclass  = GetSelectedSubclass();
                    var selectedSubclass = (from A in listSubclass
                                            select A.SubclassName).ToList();
                    listItemColl = repData.GetDocMetaData(clientContext, "Repository", "Custom Document Set", string.Join(",", selectedSubclass.ToArray()));
                    writeXml.CreateXml(listItemColl, dtRevDate.Value, cbDocType.Text, listSubclass, clientContext);
                    MessageBox.Show("Export completed successfully.");
                    lblMessage.Visible = false;
                }
                else
                {
                    MessageBox.Show("Please select Subclass number.");
                }
            }
            catch (Exception exec)
            {
                logger.WriteEventLog("Please contact admin : " + exec.Message);
                throw exec;
            }
        }