예제 #1
0
        public void Add(ClientProcess clientProcess, int assignTo)
        {
            try
            {
                if (primarySteps.Count() > 0)
                {
                    PrimaryStep primaryStep = primarySteps.First(i => i.Id == clientProcess.PrimaryStepId);

                    if (primaryStep != null)
                    {
                        linkSubSteps  = processService.GetLinkSubSteps(clientProcess.PrimaryStepId);
                        primaryStepNo = primaryStep.StepNo;
                    }
                    else
                    {
                        throw new Exception("Invalid process step as parameter.");
                    }

                    string taskId = addTask(clientProcess, assignTo);
                    addClientProcess(clientProcess, assignTo, taskId);
                }
            }
            catch (Exception ex)
            {
                //log error
            }
        }
        private PrimaryStep convertToPrimaryStep(DataRow dr)
        {
            PrimaryStep primaryStep = new PrimaryStep();

            primaryStep.Id                    = dr.Field <int>("ID");
            primaryStep.StepNo                = dr.Field <int>("StepNo");
            primaryStep.Title                 = dr.Field <string>("Title");
            primaryStep.Description           = dr.Field <string>("Description");
            primaryStep.Remarks               = dr.Field <string>("Remarks");
            primaryStep.DurationInMinutes     = dr.Field <int>("DurationInMinutes");
            primaryStep.TimelineInDays        = dr.Field <int>("TimelineInDays");
            primaryStep.PrimaryResponsibility = dr.Field <int>("PrimaryResponsibility");
            primaryStep.Owner                 = dr.Field <int>("Owner");
            primaryStep.Checker               = dr.Field <int>("Checker");
            return(primaryStep);
        }
        public Result <PrimaryStep> Update(PrimaryStep primaryStep)
        {
            var result = new Result <PrimaryStep>();

            try
            {
                ProcessService processService = new ProcessService();
                result.Value     = processService.UpdatePrimaryStep(primaryStep);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.IsSuccess     = false;
                result.ExceptionInfo = exception;
            }
            return(result);
        }
        public PrimaryStep UpdatePrimaryStep(PrimaryStep primaryStep)
        {
            try
            {
                string countResult = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_CLIENT_NAME_QUERY, 0));

                if (primaryStep.Id == 0)
                {
                    DataBase.DBService.ExecuteCommand(string.Format(INSERT_PRIMARY_STEP_QUERY,
                                                                    primaryStep.StepNo, primaryStep.Title, primaryStep.Description,
                                                                    primaryStep.Remarks, primaryStep.DurationInMinutes,
                                                                    primaryStep.TimelineInDays, primaryStep.PrimaryResponsibility,
                                                                    primaryStep.Owner, primaryStep.Checker));
                }
                else
                {
                    DataBase.DBService.ExecuteCommand(string.Format(UPDATE_PRIMARY_STEP_QUERY,
                                                                    primaryStep.StepNo,
                                                                    primaryStep.Title,
                                                                    primaryStep.Description,
                                                                    primaryStep.Remarks,
                                                                    primaryStep.DurationInMinutes,
                                                                    primaryStep.TimelineInDays,
                                                                    primaryStep.PrimaryResponsibility,
                                                                    primaryStep.Owner,
                                                                    primaryStep.Checker,
                                                                    primaryStep.Id));
                }

                string primaryStepId = DataBase.DBService.ExecuteCommandScalar(string.Format("SELECT PrimaryStep.Id FROM PrimaryStep where StepNo = {0} and Title = '{1}' and DurationInMinutes = {2} and TimelineInDays = {3}", primaryStep.StepNo, primaryStep.Title, primaryStep.DurationInMinutes, primaryStep.TimelineInDays));
                if (!string.IsNullOrEmpty(primaryStepId))
                {
                    primaryStep.Id = int.Parse(primaryStepId);
                }
                return(primaryStep);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                throw ex;
            }
        }
 public IList <PrimaryStep> GetPrimarySteps()
 {
     try
     {
         Logger.LogInfo("Get: Primary steps process start");
         IList <PrimaryStep> processSteps = new List <PrimaryStep>();
         DataTable           dtAppConfig  = DataBase.DBService.ExecuteCommand(SELECT_PRIMARY_STEP);
         foreach (DataRow dr in dtAppConfig.Rows)
         {
             PrimaryStep processStep = convertToPrimaryStep(dr);
             processSteps.Add(processStep);
         }
         Logger.LogInfo("Get: Primary steps process completed.");
         return(processSteps);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
예제 #6
0
        private string getTaskTitleByProcessId(int primaryStepId, int linkStepId)
        {
            string title = string.Empty;

            if (!linkStepId.Equals(0))
            {
                LinkSubStep linkSub = linkSubSteps.First(i => i.PrimaryStepId == primaryStepId && i.Id.Equals(linkStepId));
                if (linkSub != null)
                {
                    title = linkSub.Title;
                }
            }
            else
            {
                PrimaryStep primaryStep = primarySteps.First(i => i.Id.Equals(primaryStepId));
                if (primaryStep != null)
                {
                    title = primaryStep.Title;
                }
            }
            return(title);
        }