コード例 #1
0
ファイル: frmMeeting.cs プロジェクト: gies74/Scheduler
 public frmMeeting(MeetingSpec pMeeting, MainUI parent, string action)
 {
     InitializeComponent();
     _pMeeting = pMeeting;
     _parent   = parent;
     _action   = action;
 }
コード例 #2
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
        private void cmdMtNew_Click(object sender, EventArgs e)
        {
            MeetingSpec pMeeting = new MeetingSpec("");

            if (!_frmMeetingDict.ContainsKey(pMeeting))
            {
                _frmMeetingDict.Add(pMeeting, new frmMeeting(pMeeting, this, "insert"));
            }
            _frmMeetingDict[pMeeting].Show();
        }
コード例 #3
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
        private void AddMeeting(MeetingSpec pMeeting)
        {
            ListViewItem lvi  = lvMeetings.Items.Add(pMeeting.Topic, pMeeting.Topic, 0);
            string       desc = pMeeting.Description;

            lvi.SubItems.Add(desc.Substring(0, Math.Min(desc.Length, 40)));
            lvi.SubItems.Add(pMeeting.RequiredResources.Count.ToString());
            lvi.SubItems.Add(pMeeting.DesiredResources.Count.ToString());
            lvi.Tag        = pMeeting;
            cmdRun.Enabled = (lvMeetings.Items.Count > 0);
        }
コード例 #4
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
        private void UpdateCounts(string topic)
        {
            ListViewItem lvi = lvMeetings.Items[topic];

            if (lvi != null)
            {
                MeetingSpec pMeeting = lvi.Tag as MeetingSpec;
                lvi.SubItems[2].Text = pMeeting.RequiredResources.Count.ToString();
                lvi.SubItems[3].Text = pMeeting.DesiredResources.Count.ToString();
            }
            UpdateResourceCounts();
        }
コード例 #5
0
ファイル: Meeting.cs プロジェクト: gies74/Scheduler
 public Meeting(MeetingSpec ms)
 {
     _meetingSpecification = ms;
     _actualResources      = new List <Resource>();
     foreach (Resource res in ms.RequiredResources)
     {
         _actualResources.Add(res);
     }
     foreach (Resource res in ms.DesiredResources)
     {
         _actualResources.Add(res);
     }
 }
コード例 #6
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
        private void LoadSpecs()
        {
            InitUI(false);
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(_currXDocFileName);
            XmlNodeList xResources = xDoc.DocumentElement.SelectNodes("RESOURCES/RESOURCE");

            foreach (XmlNode xResource in xResources)
            {
                Resource pResource = new Resource(xResource.Attributes["name"].Value, xResource.Attributes["type"].Value);
                AddResource(pResource);
            }
            XmlNodeList xMeetings = xDoc.DocumentElement.SelectNodes("MEETINGS/MEETING");

            foreach (XmlNode xMeeting in xMeetings)
            {
                string      topic    = xMeeting.Attributes["topic"].Value;
                MeetingSpec pMeeting = new MeetingSpec(topic);
                pMeeting.Description = xMeeting.SelectSingleNode("DESCRIPTION").InnerText;
                XmlNodeList xRelatedRsrcs = xMeeting.SelectNodes("RESOURCES/RESOURCE");
                foreach (XmlNode xRelatedRsrc in xRelatedRsrcs)
                {
                    Resource pResource = FindResourceByName(xRelatedRsrc.Attributes["name"].Value);
                    if (pResource != null)
                    {
                        string level = xRelatedRsrc.Attributes["level"].Value;
                        if (level == "required")
                        {
                            pMeeting.AddRequired(pResource);
                        }
                        else if (level == "desired")
                        {
                            pMeeting.AddDesired(pResource);
                        }
                    }
                }
                AddMeeting(pMeeting);
            }
            UpdateResourceCounts();
            XmlNode xSetting;

            xSetting           = xDoc.DocumentElement.SelectSingleNode("SETTINGS/SETTING[@name='noParSess']");
            tbxParSess.Text    = xSetting.Attributes["value"].Value;
            xSetting           = xDoc.DocumentElement.SelectSingleNode("SETTINGS/SETTING[@name='noSessBlocks']");
            tbxSessBlocks.Text = xSetting.Attributes["value"].Value;
            _dirty             = false;
        }
コード例 #7
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
 private void editMtngToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (lvMeetings.SelectedItems.Count == 1)
     {
         MeetingSpec pMeeting = lvMeetings.SelectedItems[0].Tag as MeetingSpec;
         if (!_frmMeetingDict.ContainsKey(pMeeting))
         {
             _frmMeetingDict.Add(pMeeting, new frmMeeting(pMeeting, this, "update"));
         }
         else if (_frmMeetingDict[pMeeting].IsDisposed)
         {
             _frmMeetingDict[pMeeting] = new frmMeeting(pMeeting, this, "update");
         }
         _frmMeetingDict[pMeeting].Show();
     }
 }
コード例 #8
0
 private void SetResourceControls(object sender, EventArgs e)
 {
     tbxMeetings.Clear();
     foreach (ListViewItem lvi in _parent.LVMeetings.Items)
     {
         MeetingSpec pMeetingSpec = lvi.Tag as MeetingSpec;
         if (pMeetingSpec.RequiredResources.Contains(_pResource))
         {
             tbxMeetings.Text += pMeetingSpec.Topic + " (r)" + Environment.NewLine;
         }
         else if (pMeetingSpec.DesiredResources.Contains(_pResource))
         {
             tbxMeetings.Text += pMeetingSpec.Topic + " (d)" + Environment.NewLine;
         }
     }
     cmdShowMeetings.Text = "Meetings>>";
     this.Size            = new Size(308, 188);
     tbxMeetings.Visible  = false;
 }
コード例 #9
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
 internal void doProcessMeeting(MeetingSpec pMeeting, string action)
 {
     if (action == "update")
     {
         foreach (ListViewItem lvi in lvMeetings.Items)
         {
             if (pMeeting == (lvi.Tag as MeetingSpec))
             {
                 lvi.Text             = pMeeting.Topic;
                 lvi.SubItems[1].Text = pMeeting.Description.Substring(0, Math.Min(40, pMeeting.Description.Length));
                 UpdateCounts(pMeeting.Topic);
                 _dirty = true;
                 break;
             }
         }
     }
     else if (action == "insert")
     {
         AddMeeting(pMeeting);
         _dirty = true;
     }
 }
コード例 #10
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
 private void UpdateResourceCounts()
 {
     foreach (ListViewItem lvi in lvResources.Items)
     {
         Resource r = lvi.Tag as Resource;
         int      req = 0, des = 0;
         foreach (ListViewItem lvi2 in lvMeetings.Items)
         {
             MeetingSpec ms = lvi2.Tag as MeetingSpec;
             if (ms.RequiredResources.Contains(r))
             {
                 req++;
             }
             if (ms.DesiredResources.Contains(r))
             {
                 des++;
             }
         }
         r.NumReqMeetings     = req;
         r.NumDesMeetings     = des;
         lvi.SubItems[2].Text = r.NumReqMeetings.ToString();
         lvi.SubItems[3].Text = r.NumDesMeetings.ToString();
     }
 }
コード例 #11
0
ファイル: ScheduleEngine.cs プロジェクト: gies74/Scheduler
        private static List <Schedule> BuildPermutations(List <MeetingSpec> meetings)
        {
            int             level        = meetings.Count;
            decimal         facPrevLevel = (decimal)Faculteit(level - 1);
            decimal         facLevel     = (decimal)level * facPrevLevel;
            List <Schedule> retval       = new List <Schedule>();

            if (meetings.Count == 1)
            {
                for (int i = 0; i < noSessBlocks; i++)
                {
                    Schedule s = new Schedule(noParSess, noSessBlocks);
                    s.Meetings[i].Add(new Meeting(meetings[0]));
                    retval.Add(s);
                }
            }
            else
            {
                MeetingSpec head = meetings[0];
                meetings.RemoveAt(0);
                List <Schedule> perms = BuildPermutations(meetings);
                int             pi = 0, pN = perms.Count;
                foreach (Schedule aSchedule in perms)
                {
                    for (int i = 0; i < noSessBlocks; i++)
                    {
                        if (aSchedule.Meetings[i].Count < noParSess)
                        {
                            Schedule cloneSchedule = aSchedule.Clone();
                            cloneSchedule.Meetings[i].Insert(0, new Meeting(head));
                            retval.Add(cloneSchedule);
                        }
                    }
                    if (pi % 5000 == 0)
                    {
                        _d.BeginInvoke("Building perms (" + level.ToString() + ") " + pi.ToString(), 50M * ((facPrevLevel + (pi / pN) * (facLevel - facPrevLevel)) / facAll), null, null);
                    }
                    pi++;
                }
                if (facLevel >= 120)
                {
                    // build a histogram for all score values seen so far
                    SortedDictionary <int, int> hist = new SortedDictionary <int, int>();
                    foreach (Schedule s in retval)
                    {
                        int score = s.Evaluate(_penalties);
                        if (!hist.ContainsKey(score))
                        {
                            hist.Add(score, 1);
                        }
                        else
                        {
                            hist[score]++;
                        }
                    }
                    // determine the score threshold that splits 1% - 99%
                    int    N            = retval.Count;
                    int    cumsumCounts = 0;
                    int    threshold    = int.MaxValue;
                    double thrRatio     = .0001; // -((double).6 * level / _parent.LVMeetings.Items.Count);
                    foreach (int sckey in hist.Keys)
                    {
                        double ratio = (double)cumsumCounts / N;
                        if (ratio > thrRatio)
                        {
                            break;
                        }
                        threshold     = sckey;
                        cumsumCounts += hist[sckey];
                    }
                    List <Schedule> retval2 = new List <Schedule>();
                    foreach (Schedule s in retval)
                    {
                        if (s.Score <= threshold)
                        {
                            retval2.Add(s);
                        }
                    }
                    retval = retval2;
                }
            }
            _d.BeginInvoke("perms", 50M * (facLevel / facAll), null, null);
            return(retval);
        }
コード例 #12
0
ファイル: MainUI.cs プロジェクト: gies74/Scheduler
        //private string RestorableDirectory(string sDir)
        //{
        //    if (sDir == null)
        //    {
        //        string s = Registry.CurrentUser.GetValue(@"Software\Gies\Scheduler") as string;
        //        if (s == null)
        //            s = "";
        //        return s;
        //    }
        //    else
        //    {
        //        Registry.CurrentUser.SetValue(@"Software\Gies\Scheduler", sDir);
        //        return null;
        //    }
        //}

        private void SaveSpecs()
        {
            XmlDocument xDoc   = new XmlDocument();
            XmlElement  xSpecs = xDoc.CreateElement("SCHEDULE_SPECS");

            XmlElement xResources = xDoc.CreateElement("RESOURCES");

            foreach (ListViewItem lvi in lvResources.Items)
            {
                XmlElement   xResource = xDoc.CreateElement("RESOURCE");
                Resource     pResource = lvi.Tag as Resource;
                XmlAttribute xaName    = xDoc.CreateAttribute("name");
                xaName.Value = pResource.Name;
                xResource.Attributes.Append(xaName);
                XmlAttribute xaType = xDoc.CreateAttribute("type");
                xaType.Value = pResource.Type.ToString().ToLower();
                xResource.Attributes.Append(xaType);
                xResources.AppendChild(xResource);
            }
            xSpecs.AppendChild(xResources);

            XmlElement xMeetings = xDoc.CreateElement("MEETINGS");

            foreach (ListViewItem lvi in lvMeetings.Items)
            {
                XmlElement   xMeeting = xDoc.CreateElement("MEETING");
                MeetingSpec  pMeeting = lvi.Tag as MeetingSpec;
                XmlAttribute xaTopic  = xDoc.CreateAttribute("topic");
                xaTopic.Value = pMeeting.Topic;
                xMeeting.Attributes.Append(xaTopic);
                XmlElement xDescription = xDoc.CreateElement("DESCRIPTION");
                XmlText    xDescVal     = xDoc.CreateTextNode(pMeeting.Description);
                xDescription.AppendChild(xDescVal);
                xMeeting.AppendChild(xDescription);

                xResources = xDoc.CreateElement("RESOURCES");
                foreach (Resource pReqRsrc in pMeeting.RequiredResources)
                {
                    XmlElement   xResource = xDoc.CreateElement("RESOURCE");
                    XmlAttribute xaName    = xDoc.CreateAttribute("name");
                    xaName.Value = pReqRsrc.Name;
                    xResource.Attributes.Append(xaName);
                    XmlAttribute xaLevel = xDoc.CreateAttribute("level");
                    xaLevel.Value = "required";
                    xResource.Attributes.Append(xaLevel);
                    xResources.AppendChild(xResource);
                }
                foreach (Resource pDesRsrc in pMeeting.DesiredResources)
                {
                    XmlElement   xResource = xDoc.CreateElement("RESOURCE");
                    XmlAttribute xaName    = xDoc.CreateAttribute("name");
                    xaName.Value = pDesRsrc.Name;
                    xResource.Attributes.Append(xaName);
                    XmlAttribute xaLevel = xDoc.CreateAttribute("level");
                    xaLevel.Value = "desired";
                    xResource.Attributes.Append(xaLevel);
                    xResources.AppendChild(xResource);
                }
                xMeeting.AppendChild(xResources);
                xMeetings.AppendChild(xMeeting);
            }
            xSpecs.AppendChild(xMeetings);

            XmlElement   xSettings = xDoc.CreateElement("SETTINGS");
            XmlElement   xSetting;
            XmlAttribute xaSettname, xaValue;

            xSetting         = xDoc.CreateElement("SETTING");
            xaSettname       = xDoc.CreateAttribute("name");
            xaSettname.Value = "noParSess";
            xSetting.Attributes.Append(xaSettname);
            xaValue       = xDoc.CreateAttribute("value");
            xaValue.Value = tbxParSess.Text;
            xSetting.Attributes.Append(xaValue);
            xSettings.AppendChild(xSetting);
            xSetting         = xDoc.CreateElement("SETTING");
            xaSettname       = xDoc.CreateAttribute("name");
            xaSettname.Value = "noSessBlocks";
            xSetting.Attributes.Append(xaSettname);
            xaValue       = xDoc.CreateAttribute("value");
            xaValue.Value = tbxSessBlocks.Text;
            xSetting.Attributes.Append(xaValue);
            xSettings.AppendChild(xSetting);
            xSpecs.AppendChild(xSettings);

            xDoc.AppendChild(xSpecs);
            xDoc.Save(_currXDocFileName);
            _dirty = false;
        }