Exemplo n.º 1
0
        public ParameterList GetParameters(string CommandName)
        {
            ParameterList pList = new ParameterList();
            CommandInteraction ci = new CommandInteraction();
            try
            {
                List<string> requierdInputs = ci.getRequiredInputs(CommandName);
                foreach (string i in requierdInputs)
                {
                    Parameter p = new Parameter();
                    p.Name = i;
                    pList.Add(p);
                }
                TeamInfo teamInfo=TeamInfoAccess.getTeam(0);

                using (PSDataAccess psDataAccess = new PSDataAccess(teamInfo.domain, teamInfo.product))
                {
                    string psFieldNames = string.Empty;
                    foreach (Parameter p in pList)
                    {
                        p.Name = p.Name.Replace("__", " ");
                        if (psFieldNames == string.Empty)
                        {
                            psFieldNames = p.Name;//"__" is for the white space issue
                        }
                        else
                        {
                            psFieldNames = string.Format("{0};{1}", psFieldNames, p.Name);
                        }
                    }
                    List<PSFieldDefinition> fieldDefinitions = psDataAccess.LoadingPSFields(psFieldNames);
                    foreach (Parameter p in pList)
                    {
                        if (p.Name.Equals("AssignedTo"))
                        {
                            p.Values.AddRange(new string[] { "t-limliu", "yuanzhua", "zachary", "zichsun" });
                        }
                        foreach (PSFieldDefinition definition in fieldDefinitions)
                        {
                            if (p.Name.Equals(definition.Name))
                            {
                                List<object> values = definition.GetAllowedValues();
                                foreach (object v in values)
                                {
                                    p.Values.Add(v.ToString());
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new WebFaultException<string>(e.ToString(),HttpStatusCode.InternalServerError);
            }
            return pList;
        }
Exemplo n.º 2
0
 public CommandInfo doCommand(CommandInfo CommandInfo)
 {
     CommandInteraction cmdInteraction = new CommandInteraction();
     Dictionary<string, string> paras = new Dictionary<string, string>();
     foreach (Parameter p in CommandInfo.ParameterList)
     {
         paras.Add(p.Name, p.Value);
     }
     cmdInteraction.executeCommand(CommandInfo.CommandName, paras);
     TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction();
     twfi.doCommand(CommandInfo);
     return CommandInfo;
 }
Exemplo n.º 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;
        }
Exemplo n.º 4
0
 public ParameterList GetParameters(string CommandName)
 {
     ParameterList pList=new ParameterList();
     CommandInteraction ci = new CommandInteraction();
     try
     {
         List<string> requierdInputs = ci.getRequiredInputs(CommandName);
         foreach (string i in requierdInputs)
         {
             Parameter p = new Parameter();
             p.Name = i;
             pList.Add(p);
         }
     }
     catch (Exception e)
     {
         throw new HttpException((int)HttpStatusCode.InternalServerError,e.Message);
     }
     return pList;
 }
Exemplo n.º 5
0
        public WorkFlowInstance startWorkFlow(CommandInfo CommandInfo)
        {
            WorkFlowInstance wfi = new WorkFlowInstance();
            try
            {
                string WFName = CommandInfo.WFName.Trim();
                TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction();
                string id = twfi.startProcess(WFName);

                CommandInteraction cmdInteraction = new CommandInteraction();
                Dictionary<string, string> paras = new Dictionary<string, string>();
                paras.Add("InstanceId", id);
                paras.Add("WFName", CommandInfo.WFName);
                if (CommandInfo.ParameterList != null)
                {
                    foreach (Parameter p in CommandInfo.ParameterList)
                    {
                        paras.Add(p.Name, p.Value);
                    }
                }
                TrackingWorkFlowInteraction II = new TrackingWorkFlowInteraction();
                StateMachineDefinition statemachineDefinition = II.getStateMachineDefinition(CommandInfo.WFName);
                paras.Add("QFEStatus", statemachineDefinition.InitialState);
                cmdInteraction.executeCommand(CommandInfo.CommandName, paras);

                wfi.Id = id;
                List<string> candCmds = twfi.getCandidateCommands(WFName, id);
                CandidateCommandList ccl = new CandidateCommandList();
                ccl.AddRange(candCmds);
                wfi.CandidateCommandList = ccl;
            }
            catch (Exception e)
            {
                throw new WebFaultException<string>(e.ToString(), HttpStatusCode.InternalServerError);
            //                TrackingLog.Log(e.Message + "!!" + e.ToString());
            }
            return wfi;
        }