示例#1
0
        public override void execute()
        {
            Console.WriteLine("this is process start command");
            //Console.WriteLine("assigned to" + this.AssignTo);
            TeamInfo teamInfo = TeamInfoAccess.getTeam(0);
            string   bugId    = "N/A";

            using (PSDataAccess psDataAccess = new PSDataAccess(teamInfo.domain, teamInfo.product))
            {
                bugId = "bug12345";
            }

            TrackingDataContext tdc = new TrackingDataContext();

            CommonResource.Tracking t = new CommonResource.Tracking();
            t.wfname       = this.WFName;
            t.bugid        = bugId;
            t.wfinstanceid = new Guid(this.InstanceId);
            t.lastmodified = DateTime.Now;
            t.assignedto   = this.AssignedTo;
            t.title        = this.Title;
            t.qfestatus    = this.qFEStatus;

            //t.qfestatus=
            t.lastmodifiedby = AuthenticationHelper.GetCurrentUser();
            tdc.Trackings.InsertOnSubmit(t);
            tdc.SubmitChanges();
        }
示例#2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            TrackingDataContext trackingDataContext = new TrackingDataContext();
            MouseTracker        mouseTracker        = new MouseTracker();
            KeyboardTracker     keyboardTracker     = new KeyboardTracker();


            //Set timer to record activity data every second
            DispatcherTimer timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };

            //Start tracking productivity and logging it
            timer.Tick += (o, e) =>
            {
                var newTrackingRecord = new TrackingRecord
                {
                    Active      = false,
                    ProcessName = ProcessTracker.GetActiveProcessName(),
                    Timestamp   = DateTime.Now
                };

                if (mouseTracker.HasMouseMoved() || keyboardTracker.GetTimeElapsedSinceLastKeyPress() < timer.Interval.TotalMilliseconds)
                {
                    newTrackingRecord.Active = true;
                    trackingDataContext.Add(newTrackingRecord);
                }
                else
                {
                    trackingDataContext.Add(newTrackingRecord);
                }

                trackingDataContext.SaveChanges();
            };
            timer.IsEnabled = true;

            //Code for setting up MVVM
            ViewNavigator viewNavigator    = new ViewNavigator();
            MainViewModel defaultViewModel = new MainViewModel(viewNavigator);

            viewNavigator.CurrentViewModel = defaultViewModel;
            Window window = new MainWindow();

            window.DataContext = defaultViewModel;
            window.Show();
            base.OnStartup(e);
        }
示例#3
0
        public CommandInfo doCommand(CommandInfo CommandInfo)
        {
            CommandInfo.CommandName = CommandInfo.CommandName.Trim();
            try
            {
                CommandInteraction cmdInteraction = new CommandInteraction();
                Dictionary<string, string> paras = new Dictionary<string, string>();
                paras.Add("InstanceId", CommandInfo.InstanceId);
                paras.Add("WFName", CommandInfo.WFName);
                if (CommandInfo.ParameterList != null)
                {
                    foreach (Parameter p in CommandInfo.ParameterList)
                    {
                        paras.Add(p.Name, p.Value);
                    }
                }
                TrackingDataContext tdc = new TrackingDataContext();
                Guid guid = new Guid(CommandInfo.InstanceId);
                IQueryable<CommonResource.Tracking> trackingQuery =
                    from tracking in tdc.Trackings
                    where ((tracking.wfinstanceid == guid))
                    select tracking;
                foreach (CommonResource.Tracking t in trackingQuery)
                {
                    t.lastmodifiedby = AuthenticationHelper.GetCurrentUser();
                }
                //CommonResource.Tracking t = new CommonResource.Tracking();
                //t.wfname = this.WFName;
                //t.bugid = bugId;
                //t.wfinstanceid = new Guid(this.InstanceId);
                //tdc.Trackings.InsertOnSubmit(t);
                tdc.SubmitChanges();

                cmdInteraction.executeCommand(CommandInfo.CommandName, paras);//this is do the real action in extension
                TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction();
                twfi.doCommand(CommandInfo);// this is just trigger the state machine(WF) to do one step
            }
            catch (Exception e)
            {
                throw new WebFaultException<string>(e.ToString(), HttpStatusCode.InternalServerError);
            }
            return CommandInfo;
        }
示例#4
0
 public WorkFlowInstance GetWorkFlowInstance(string InstanceId)
 {
     WorkFlowInstance wfi = new WorkFlowInstance();
     TrackingDataContext trackingContext = new TrackingDataContext();
     Guid guid = new Guid(InstanceId);
     IQueryable<Tracking> trackingQuery =
         from tracking in trackingContext.Trackings
         where ((tracking.wfinstanceid == guid))
         select tracking;
     foreach (Tracking t in trackingQuery)
     {
         TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction();
         wfi = new WorkFlowInstance();
         List<string> candCmds=twfi.getCandidateCommands(t.wfname, InstanceId);
         CandidateCommandList ccl=new CandidateCommandList();
         ccl.AddRange(candCmds);
         wfi.CandidateCommandList = ccl;
         return wfi;
     }
     return null;
 }
示例#5
0
        public WorkFlowInstanceList GetWorkFlowInstances()
        {
            //WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;

            //WindowsIdentity identity = (WindowsIdentity)principal.Identity;

            //TrackingLog.Log(identity.Name);

            WorkFlowInstanceList l = new WorkFlowInstanceList();
            try
            {
                TrackingDataContext dataContext = new TrackingDataContext();

                IQueryable<CommonResource.Tracking> trackingQuery =
                    from tracking in dataContext.Trackings
                    select tracking;

                foreach (CommonResource.Tracking t in trackingQuery)
                {
                    using (TrackingWorkFlowInteraction interaction = new TrackingWorkFlowInteraction())
                    {
                        WorkFlowInstance wfi = new WorkFlowInstance();
                        wfi.BugId = t.bugid;
                        wfi.Id = t.wfinstanceid.ToString();
                        wfi.Title = t.title;
                        wfi.WFName = t.wfname;
                        wfi.LastModified = t.lastmodified.ToString();
                        wfi.QFEStatus = t.qfestatus;
                        wfi.AssignedTo = t.assignedto;
                        wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.Value.ToString();
                        wfi.LastModifiedBy = t.lastmodifiedby;
                        //
                        //List<string> candiCmds = interaction.getCandidateCommands(t.wfname.Trim(), t.wfinstanceid.ToString());
                        //CandidateCommandList ccl = new CandidateCommandList();
                        //if (candiCmds != null)
                        //{
                        //    foreach (string cmd in candiCmds)
                        //    {
                        //        ccl.Add(cmd);
                        //    }
                        //}
                        //wfi.CandidateCommandList = ccl;
                        l.Add(wfi);
                    }
                }
            }
            catch (Exception e)
            {
                TrackingLog.Log(e.ToString() + "!!" + e.Message);
            }
            return l;
        }
示例#6
0
        public WorkFlowInstance GetWorkFlowInstance(string InstanceId)
        {
            WorkFlowInstance wfi = new WorkFlowInstance();
            wfi.Id = InstanceId;
            try
            {
                TrackingDataContext trackingContext = new TrackingDataContext();
                Guid guid = new Guid(InstanceId);
                IQueryable<CommonResource.Tracking> trackingQuery =
                    from tracking in trackingContext.Trackings
                    where ((tracking.wfinstanceid == guid))
                    select tracking;
                foreach (CommonResource.Tracking t in trackingQuery)
                {
                    using (TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction())
                    {
                        wfi = new WorkFlowInstance();
                        wfi.BugId = t.bugid;
                        wfi.Id = t.wfinstanceid.ToString();
                        wfi.Title = t.title;
                        wfi.WFName = t.wfname;
                        //wfi.LastModified = t.lastmodified==null?"N/A":t.lastmodified.ToString();
                        wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.ToString();
                        wfi.QFEStatus = t.qfestatus;
                        wfi.AssignedTo = t.assignedto;
                        wfi.LastModifiedBy = t.lastmodifiedby;
                        try
                        {
                            CandidateCommandList ccl = twfi.getCandidateCommands(t.wfname.Trim(), InstanceId);
                            wfi.CandidateCommandList = ccl;
                        }
                        catch (WorkFlowNotFoundException e)
                        {

                        }
                    }
                    return wfi;
                }
            }
            catch (Exception e)
            {
                throw new WebFaultException<string>(e.ToString(),HttpStatusCode.InternalServerError);
            }
            return null;
        }