Exemplo n.º 1
0
        private void cmdSend_Click(object sender, EventArgs e)
        {
            frmLoginSendHaxCom oLogin = new frmLoginSendHaxCom {
                LoginURL = TimeKeeperBaseURL
            };

            oLogin.openMode        = frmLoginSendHaxCom.OpenMode.Submit;
            oLogin.optDays.Enabled = lvwHistory.SelectedItems.Count > 0;
            oLogin.optSel.Enabled  = oLogin.optDays.Enabled;
            if (oLogin.ShowDialog() == DialogResult.OK)
            {
                var Clients = GetHaxcomClients(oLogin.PHPSession);
                List <ListViewItem> Items;
                switch (oLogin.SendSelected)
                {
                case SendSelected.Selected:
                    Items = lvwHistory.SelectedItems.Cast <ListViewItem>().ToList();
                    ListViewGroup grp;
                    foreach (ListViewItem item in Items)
                    {
                        grp = item.Group;
                        lvwHistory.Items.Remove(item);
                        lvwHistory.Items.Add(SendItemToHaxCom(item, oLogin.PHPSession, Clients, grp));
                    }
                    break;

                case SendSelected.Days:
                    List <ListViewGroup> oLvgs = new List <ListViewGroup>();
                    foreach (ListViewItem item in lvwHistory.SelectedItems)
                    {
                        if (!oLvgs.Any(x => x == item.Group))
                        {
                            oLvgs.Add(item.Group);
                        }
                    }
                    foreach (var oLvg in oLvgs)
                    {
                        Items = oLvg.Items.Cast <ListViewItem>().ToList();
                        foreach (ListViewItem oItem in Items)
                        {
                            lvwHistory.Items.Remove(oItem);
                            lvwHistory.Items.Add(SendItemToHaxCom(oItem, oLogin.PHPSession, Clients, oLvg));
                        }
                    }
                    break;

                case SendSelected.All:
                    Items = lvwHistory.Items.Cast <ListViewItem>().ToList();
                    foreach (ListViewItem item in Items)
                    {
                        grp = item.Group;
                        lvwHistory.Items.Remove(item);
                        lvwHistory.Items.Add(SendItemToHaxCom(item, oLogin.PHPSession, Clients, grp));
                    }
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void LoadTFSCSV()
        {
            frmLoginSendHaxCom oLogin = new frmLoginSendHaxCom {
                LoginURL = TimeKeeperBaseURL
            };

            oLogin.openMode        = frmLoginSendHaxCom.OpenMode.Search;
            oLogin.optDays.Enabled = false;
            oLogin.optSel.Enabled  = false;
            if (oLogin.ShowDialog() == DialogResult.OK)
            {
                List <WorkItemsDay> oItems = new List <WorkItemsDay>();
                List <CsvReg>       regs   = getHaxComTFSTime(oLogin.PHPSession, dtpFrom.Value, DateTime.Today, oLogin.chkAll.Checked, (oLogin.CHKBug.Checked || oLogin.chkPBI.Checked || oLogin.chkOther.Checked), oLogin.chkMeeting.Checked, oLogin.chkPrjtLess.Checked, oLogin.chkNonBillable.Checked, oLogin.chkCapitalized.Checked);
                var oDataSource            = oDataSources.First(x => x.Type == Datasourcetype.TFS);
                var outlookDataSource      = oDataSources.FirstOrDefault(x => x.Type == Datasourcetype.Outlook);
                //gets rest of TFS data using the TFS IDS
                var tfsItems = WorkItemMapper.GetHistoricalWorkitemsByIDs(oDataSource.ServerUrl, oDataSource.ProjectName, oDataSource.User, regs.Select(x => x.TFSId).Distinct());
                //assembles the listview
                foreach (DateTime dDate in regs.Select(x => x.Date).Distinct())
                {
                    var oTemp = new WorkItemsDay(dDate);
                    foreach (CsvReg oReg in regs.Where(x => x.Date == dDate))
                    {
                        if (oReg.TFSId == 0) //meetings
                        {
                            var oWI = new WorkItemHours();
                            oWI.HaxComID       = oReg.EntryID;
                            oWI.ID             = "meeting";
                            oWI.ProjectId      = 0;
                            oWI.ClientId       = 166;
                            oWI.SubClientId    = 5;
                            oWI.Function       = 41; //dev meeting
                            oWI.Description    = oReg.Title;
                            oWI.Title          = oReg.Title;
                            oWI.FromDatasource = outlookDataSource;
                            oWI.BillingType    = BillingType.Capitalized;
                            oWI.HaxComHours    = oReg.Hours;
                            oTemp.WorkItems.Add(oWI);
                        }
                        else
                        {
                            var oTFSI = tfsItems.FirstOrDefault(x => x.ID == oReg.TFSId.ToString());
                            if (oTFSI != null)
                            {
                                string sType = oTFSI.Type.ToUpperInvariant();
                                if (oLogin.chkAll.Checked || (sType == "BUG" && oLogin.CHKBug.Checked) || (sType == "USER STORY" && oLogin.chkPBI.Checked) ||
                                    (sType != "BUG" && sType != "PRODUCT BACKLOG ITEM" && oLogin.chkOther.Checked))
                                {
                                    oTemp.WorkItems.Add(WorkItemToWIHours(oTFSI, oReg.EntryID, oDataSource, oReg.Hours));
                                }
                            }
                        }
                    }
                    oItems.Add(oTemp);
                }
                UpdateListview(oItems, false);
            }
        }