Пример #1
0
        public HttpResponseMessage Update(SupportActivityDTO requestInfo)
        {
            try
            {
                int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());


                int?orgid;

                if (requestInfo.OrgId != null)
                {
                    orgid = requestInfo.OrgId;
                }
                else
                {
                    orgid = _IUserService.GetUser(userID).OrgUsers.Where(p => p.Type == null || p.Type.Contains("Primary")).FirstOrDefault().OrgId;
                }

                var org = _IOrgService.GetOrg((int)orgid);

                var supportWkflowInstance = _IWkflowinstanceService.GetWkflowinstance((int)requestInfo.Id);

                if (supportWkflowInstance.CCUserId != requestInfo.CCUserId)
                {
                    supportWkflowInstance.CCUserId = requestInfo.CCUserId;
                }

                if (supportWkflowInstance.Priority != requestInfo.Priority)
                {
                    supportWkflowInstance.Priority = requestInfo.Priority;
                }

                supportWkflowInstance.DateLastMaint = DateTime.UtcNow;

                if (requestInfo.NextStepId != null)
                {
                    supportWkflowInstance.CurrWkflowStatId = (int)requestInfo.NextStepId;

                    var hist = new WkflowStepHist
                    {
                        CreateDate       = DateTime.UtcNow,
                        DateLastMaint    = DateTime.UtcNow,
                        WkflowStatId     = (int)requestInfo.NextStepId,
                        CreatedUserId    = userID,
                        WkflowStatReasId = requestInfo.ReasonId
                    };
                    if (requestInfo.NewMessage != null && requestInfo.NewMessage != "")
                    {
                        hist.WkflowStepNotes.Add(new WkflowStepNote()
                        {
                            CreatedDate = DateTime.UtcNow, NoteText = requestInfo.NewMessage
                        });
                    }
                    if (requestInfo.Resolution != null && requestInfo.Resolution != "")
                    {
                        hist.WkflowStepNotes.Add(new WkflowStepNote()
                        {
                            CreatedDate = DateTime.UtcNow, NoteText = requestInfo.Resolution
                        });
                    }

                    supportWkflowInstance.WkflowStepHists.Add(hist);
                }

                _IWkflowinstanceService.UpdateWkflowinstance(supportWkflowInstance);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Пример #2
0
        public HttpResponseMessage Create(SupportActivityDTO requestInfo)
        {
            try
            {
                var supportRequestWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Find(p => p.Code == "SRW");

                int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());

                //var createdstatusID = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Created")).FirstOrDefault().WkflowStatId;

                var ccstatusID = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Assigned to CustomerCare")).FirstOrDefault().WkflowStatId;
                var cstatusID  = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Assigned to Customer")).FirstOrDefault().WkflowStatId;

                int?orgid;

                if (requestInfo.OrgId != null)
                {
                    orgid = requestInfo.OrgId;
                }
                else
                {
                    orgid = _IUserService.GetUser(userID).OrgUsers.Where(p => p.Type == null || p.Type.Contains("Primary")).FirstOrDefault().OrgId;
                }

                var statusID = 0;

                var org = _IOrgService.GetOrg((int)orgid);

                if (org.OrgTyp.TypCd == "TENA")
                {
                    statusID = cstatusID;
                }
                else
                {
                    statusID = ccstatusID;
                }

                int?ccuserid = org.OrgUsers.Where(p => p.Type == "CustomerCare").Count() > 0 ? (int?)org.OrgUsers.Where(p => p.Type == "CustomerCare").FirstOrDefault().UserId : null;

                // Create a new batch processing workflow
                var supportWkflowInstance = new WkflowInstance
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDefId      = supportRequestWorkflow.Id,
                    OrgId            = orgid,
                    UserId           = userID,
                    CurrWkflowStatId = statusID,
                    Summary          = requestInfo.Summary,
                    Priority         = requestInfo.Priority,
                    CCUserId         = ccuserid
                };

                var hist = new WkflowStepHist
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowStatId     = statusID,
                    CreatedUserId    = userID,
                    WkflowStatReasId = requestInfo.ReasonId
                };

                hist.WkflowStepNotes.Add(new WkflowStepNote()
                {
                    CreatedDate = DateTime.UtcNow, NoteText = requestInfo.NewMessage
                });
                supportWkflowInstance.WkflowStepHists.Add(hist);
                _IWkflowinstanceService.AddWkflowinstance(supportWkflowInstance);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }