예제 #1
0
        private void SetDirectory()
        {
            try
            {
                SessionStore csSession = SessionManager.GetSession();

                CSDirectory csobj = csSession.GetCurrentDirectory();    // Directories.Where(d => d.Name == name).FirstOrDefault();
                if (csobj != null)
                {
                    //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Existing Current Directory"));
                    if (Directory.Exists(csobj.Path))
                    {
                        //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found Directory Path"));
                        if (csobj.HasFilesInChild == true && csobj.Labels.Count == 0)
                        {
                            //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found Labels"));
                            TemplatesLB.Items.Clear();
                            string[] fileEntries = Directory.GetFiles(csobj.Path, "*.lab", SearchOption.AllDirectories);
                            foreach (string fileName in fileEntries)
                            {
                                //log4net.LogManager.GetLogger("DEBUG").Error(new Exception("Found File: " + fileName));
                                CSLabel csobjl = new CSLabel();
                                csobjl.Name = fileName.Substring(fileName.LastIndexOf("\\") + 1, fileName.Length - fileName.LastIndexOf("\\") - 1);
                                csobjl.Path = fileName;

                                if (!csobj.Labels.Exists(l => l.Name.ToLower() == csobjl.Name.ToLower()))
                                {
                                    csobj.Labels.Add(csobjl);
                                }

                                if (!SessionManager.Labels.Exists(l => l.Name.ToLower() == csobjl.Name.ToLower()))
                                {
                                    SessionManager.Labels.Add(csobjl);
                                }
                                //SessionManager.Labels.Add(csobjl);
                            }
                        }
                        if (csobj.HasFilesInChild == true)
                        {
                            TemplatesLB.DataSource     = csobj.Labels.OrderBy(o => o.Name);
                            TemplatesLB.DataTextField  = "Name";
                            TemplatesLB.DataValueField = "Path";
                            TemplatesLB.DataBind();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SessionManager.ClearSession();
                log4net.LogManager.GetLogger("ERROR").Error(ex);
                //MessageLbl.Text = "An internal server error has occurred. Check the server logs for details.";
                //Response.Redirect("./");
            }
        }