コード例 #1
0
        public void Sel([AliasesAttribute("arg0")] string label, [AliasesAttribute("d")] string depot)
        {
            //            shellControl1.WriteText("list");


            // if event = .. set parent event

            // find the event in the depot

            // if only one -> set current event



            //string [] events;
            string eventsRoot = null;

            if (depot == null)
            {
                depot = iniget("depots", "_depot");
                if (depot != null)
                {
                    eventsRoot = Directory.GetCurrentDirectory();
                }
                else
                {
                    console.DoLog("on doit d abord définir un dépot");
                    return;
                }
            }

            eventsRoot = iniget("depots", depot);

            //
            if (label == null)
            {
                // retour a la racine du depot
                iniwrite(depot, "_event", null);
                string _labelDepot = iniget("depots", "_depot");
                string _path       = iniget("depots", _labelDepot);
                if (_path != null)
                {
                    System.IO.Directory.SetCurrentDirectory(_path);
                    console.DoPromptDepot(_labelDepot);
                }
                return;
            }
            else if (label.StartsWith("last"))
            {
//					var _event = events.FirstOrDefault();
                var eventRelPath = iniget(depot, "_event");

                //iniwrite("events", "_event", eventRelPath);

                //inidata["config"][key] = value;
                string eventAbsolutePath = Path.Combine(eventsRoot, eventRelPath.ToString());
                System.IO.Directory.SetCurrentDirectory(eventAbsolutePath);
                console.DoPromptEvent(iniget("depots", "_depot") + ":" + eventRelPath);
                return;
            }
            else
            {
                label = "*" + label + "*";
            }

            // events
            if (eventsRoot != null)
            {
//				var events = Parallel.ForEach(Directory.EnumerateDirectories(eventsRoot), file=> {
//
//				                    console.DoLog(file.Substring(file.LastIndexOf("\\") + 1));
//				  });
//				if (label == null) label="*";
                //else label = "*" + label + "*";

                var events = from eventdir in Directory.EnumerateDirectories(eventsRoot, label, SearchOption.AllDirectories).AsParallel()
                             select eventdir;

                var eventslist = events.ToList();
                if (eventslist.Count() > 1)
                {
                    foreach (var _event in eventslist)
                    {
                        // affiche la différence d'event
                        var eventRelPath = ShellUtils.Utils.MakeRelativePath(eventsRoot, _event);
                        console.DoLog(eventRelPath);
                    }
                }
                else
                {
                    var _event       = events.FirstOrDefault();
                    var eventRelPath = ShellUtils.Utils.MakeRelativePath(eventsRoot, _event);

                    //iniwrite("events", "_event", eventRelPath);

                    //inidata["config"][key] = value;
                    iniwrite(iniget("depots", "_depot"), "_event", eventRelPath);

                    System.IO.Directory.SetCurrentDirectory(_event.ToString());
                    console.DoPromptEvent(iniget("depots", "_depot") + ":" + eventRelPath);
                }


//				}
            }
            //for (int i = 0; i < count; i++)
            //{
            //    Console.WriteLine("variable {0} = {1}", _key, _value);
            //}
        }