Beispiel #1
0
        public HttpResponseMessage ActivityTypes()
        {
            var activityTypes = _IWkflowdefService.GetWkflowdefs().Select(u => new { id = u.Id, Name = u.Name });

            if (activityTypes == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(Request.CreateResponse <object>(HttpStatusCode.OK, activityTypes));
        }
Beispiel #2
0
        public HttpResponseMessage setFileException(int id, int reasonid, string reason)
        {
            try
            {
                int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());


                var wkflow = _IWkflowinstanceService.GetWkflowinstance(id);

                var batchProcessingWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Where(p => p.Code == "FPW").FirstOrDefault();

                var statusID = batchProcessingWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code == "EXCP").FirstOrDefault().WkflowStatId;


                wkflow.CurrWkflowStatId = statusID;

                var ccare = wkflow.Org.OrgUsers.Where(p => p.Type == "CustomerCare");

                if (ccare.Count() > 0)
                {
                    wkflow.CCUserId = ccare.FirstOrDefault().UserId;
                }

                var wkflowHist = new WkflowStepHist
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowStatId     = statusID,
                    WkflowStatReasId = reasonid,
                    CreatedUserId    = userID
                };

                wkflowHist.WkflowStepNotes.Add(new WkflowStepNote()
                {
                    WkflowStepHist = wkflowHist, CreatedDate = DateTime.UtcNow, NoteText = reason, Order = 1
                });
                wkflow.WkflowStepHists.Add(wkflowHist);

                _IWkflowinstanceService.UpdateWkflowinstance(wkflow);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
        }
        public HttpResponseMessage ClearSelections(WorkItemDTO WorkItem)
        {
            DateTime start  = DateTime.Now;
            bool     sucess = true;

            try
            {
                var docs = _IDocService.GetSouploads().Where(p => p.LockID == WorkItem.instanceID && p.WkflowInstanceDocs.FirstOrDefault().WkflowInstance.WkflowStepHists.OrderByDescending(o => o.Id).FirstOrDefault().WkflowStat.Code == "SCSELECTED");

                var batchProcessingWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Where(p => p.Code == "FPW").FirstOrDefault();
                var statusID = batchProcessingWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code == "UPLOADED").FirstOrDefault().WkflowStatId;

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

                if (docs != null)
                {
                    foreach (soUpload doc in docs)
                    {
                        // Set INIT state for new workflow instance.
                        doc.WkflowInstanceDocs.FirstOrDefault().WkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                        {
                            CreateDate    = DateTime.UtcNow,
                            DateLastMaint = DateTime.UtcNow,
                            WkflowStatId  = statusID,
                            CreatedUserId = userID
                        });

                        doc.WkflowInstanceDocs.FirstOrDefault().WkflowInstance.CurrWkflowStatId = statusID;
                        doc.LockID = null;

                        _IDocService.UpdateSoupload(doc);
                    }
                }
                ApiLog.Write("ClearSelections", start);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, sucess));
            }
            catch (Exception e)
            {
                var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Failed to Clear Selections");
                throw new HttpResponseException(createresponse);
            }
        }
Beispiel #4
0
        public HttpResponseMessage Signup(SignupRequestInfo signupRequestInfo)
        {
            OrgCust     newCustomer = new OrgCust();
            OrgReseller newReseller = new OrgReseller();


            try
            {
                var rolename = 0;

                bool isNewCustomer = signupRequestInfo.userType == "RESE" ? false : true;

                var orgCustomerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_CUSTOMER).FirstOrDefault();
                var orgResellerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_RESELLER).FirstOrDefault();

                var newOrg = _IOrgService.GetOrgs().Where(p => p.soKey == Guid.Parse(signupRequestInfo.id)).FirstOrDefault();
                if (newOrg == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid Invitation"));
                }

                Locn newLocn = new Locn
                {
                    AddressLine1  = signupRequestInfo.addressStreet1,
                    AddressLine2  = signupRequestInfo.addressStreet2,
                    City          = signupRequestInfo.addressCity,
                    DateLastMaint = DateTime.UtcNow,
                    CreateDate    = DateTime.UtcNow,
                    State         = signupRequestInfo.addressState,
                    ZipCode       = signupRequestInfo.addressZip
                };

                var os = _IOrgtyporgstatusService.GetOrgtyporgstatus().Where(p => p.OrgStatus.StatusCd == "INREVIEW").FirstOrDefault();
                newOrg.OrgStatusHists.Add(new OrgStatusHist()
                {
                    Org = newOrg, OrgTypOrgStatu = os, CreateDate = DateTime.UtcNow
                });

                //  Associate Organization to Location
                newOrg.OrgLocns.Add(new OrgLocn {
                    Locn = newLocn, Org = newOrg
                });

                //  Created New OrgCust or OrgReseller based on request
                if (isNewCustomer)
                {
                    rolename = 2;
                }
                else
                {
                    rolename = 3;
                }

                _IOrgService.UpdateOrg(newOrg);

                // Create User
                var newuser = _IUserService.GetUsers().Where(p => p.UserName == signupRequestInfo.email).FirstOrDefault();
                var ctype   = _IContacttypService.GetContacttyps().Find(p => p.ContactTypCd == "PHON");
                var contact = new Contact {
                    ContactTyp = ctype, Value = signupRequestInfo.phone
                };

                var curDateTime = DateTime.UtcNow;
                var guid        = Guid.NewGuid();

                if (newuser.Per == null)
                {
                    Per per = new Per()
                    {
                        FirstName = signupRequestInfo.firstName, LastName = signupRequestInfo.lastName, MiddleName = signupRequestInfo.middleName, Createdate = curDateTime, Title = signupRequestInfo.contactTitle
                    };
                    newuser.Per = per;
                }
                else
                {
                    newuser.Per.FirstName  = signupRequestInfo.firstName;
                    newuser.Per.MiddleName = signupRequestInfo.middleName;
                    newuser.Per.LastName   = signupRequestInfo.lastName;
                    newuser.Per.Title      = signupRequestInfo.contactTitle;
                }

                newuser.Per.PersContacts.Add(new PersContact()
                {
                    Per = newuser.Per, Contact = contact
                });

                var authrole = _IAuthrolService.GetAuthrol(rolename);

                newuser.UserAuthRols.Add(new UserAuthRol()
                {
                    User = newuser, AuthRol = authrole
                });
                newuser.InactiveDate = null;
                newuser.InviteDate   = null;

                var messagetemp = _IMessagetemplateService.GetMessagetemplates().Where(p => p.Name == "SignupAccepted").FirstOrDefault();
                var baseUrl     = Request.RequestUri.GetLeftPart(UriPartial.Authority);

                if (messagetemp != null)
                {
                    newuser.MessageUsers.Add(new MessageUser()
                    {
                        User = newuser, DeliveryMethodId = 1, Message = new Message()
                        {
                            CreateDate = curDateTime, HeaderText = messagetemp.HeaderText, MessageBody = messagetemp.TemplateText + "\n" + baseUrl + "/login"
                        }
                    });
                }

                _IUserService.UpdateUser(newuser);
                _IUserService.UpdatePassword(signupRequestInfo.email, PasswordHash.CreateHash(signupRequestInfo.password));

                // Create Sign Up Workflow
                WkflowDef signUpWorkflow;
                int       wkflowDefId = isNewCustomer ? 1 : 2; // 1= customer signup , 2 = reseller signup
                signUpWorkflow = _IWkflowdefService.GetWkflowdefs().Where(p => p.Id == wkflowDefId).FirstOrDefault();

                var signUpWorkflowInstance = new WkflowInstance
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDefId      = signUpWorkflow.Id,
                    OrgId            = newOrg.Id,
                    UserId           = 1,
                    CurrWkflowStatId = 5//InReview State
                };

                signUpWorkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                {
                    CreateDate    = DateTime.UtcNow,
                    DateLastMaint = DateTime.UtcNow,
                    WkflowStatId  = 5,
                    CreatedUserId = 1
                });


                _IWkflowinstanceService.AddWkflowinstance(signUpWorkflowInstance);

                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception daExp)
            {
                return(Request.CreateResponse <bool>(HttpStatusCode.InternalServerError, false));
            }
        }
        public HttpResponseMessage Create(DocTypDTO docTypeDTO)
        {
            try
            {
                int userID   = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());
                int statusID = _IDoctypstatusService.GetDoctypstatus().Where(p => p.StatusCd == "INREVIEW").FirstOrDefault().Id;

                var sameNames = _IOrgdoctypService.GetOrgdoctyps().Where(p => p.OrgId == docTypeDTO.OrgId && p.Descript == docTypeDTO.Descript);

                if (sameNames.Count() <= 0)
                {
                    var DocTypWorkflowdef =
                        _IWkflowdefService.GetWkflowdefs().Where(p => p.Code == "DTSW").FirstOrDefault();

                    var wkstatusID = DocTypWorkflowdef.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code == "INREVIEW").FirstOrDefault().WkflowStatId;

                    var messagetemp = _IMessagetemplateService.GetMessagetemplates().Where(p => p.Name == "NewDocTypeSetup").FirstOrDefault();

                    var user = _IUserService.GetUser(userID);

                    // Create a new Document Type Setup workflow
                    var batchWkflowInstance = new WkflowInstance
                    {
                        CreateDate       = DateTime.UtcNow,
                        WkflowDefId      = DocTypWorkflowdef.Id,
                        OrgId            = docTypeDTO.OrgId,
                        User             = user,
                        CurrWkflowStatId = wkstatusID
                    };

                    // Set INIT state for new workflow instance.
                    batchWkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                    {
                        CreateDate    = DateTime.UtcNow,
                        WkflowStatId  = wkstatusID,
                        CreatedUserId = userID
                    });

                    if (messagetemp != null)
                    {
                        _IMessageuserService.AddMessageuser(new MessageUser()
                        {
                            User = user, DeliveryMethodId = 1, Message = new Message()
                            {
                                CreateDate = DateTime.UtcNow, WkflowInstance = batchWkflowInstance, HeaderText = messagetemp.HeaderText, MessageBody = string.Format(messagetemp.TemplateText, docTypeDTO.Name)
                            }
                        });
                    }

                    _IWkflowinstanceService.AddWkflowinstance(batchWkflowInstance);
                    _IOrgdoctypService.CreateNewDocType(docTypeDTO, userID, statusID);
                    _UnitOfWork.Commit();
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "DocType Name Should be Unique"));
                }
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
        }
Beispiel #6
0
        public HttpResponseMessage Create(SOWDTO requestInfo)
        {
            try
            {
                var SOWWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Find(p => p.Code == "SOW");

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

                var CreatedstatusID = SOWWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Created")).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 org      = _IOrgService.GetOrg((int)orgid);
                int?ccuserid = org.OrgUsers.Where(p => p.Type == "CustomerCare").Count() > 0 ? (int?)org.OrgUsers.Where(p => p.Type == "CustomerCare").FirstOrDefault().UserId : null;

                var WKflow = new WkflowInstance()
                {
                    Org              = org,
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDef        = SOWWorkflow,
                    UserId           = userID,
                    CurrWkflowStatId = CreatedstatusID,
                    CCUserId         = ccuserid
                };

                var hist = new WkflowStepHist
                {
                    CreateDate    = DateTime.UtcNow,
                    DateLastMaint = DateTime.UtcNow,
                    WkflowStatId  = CreatedstatusID,
                    CreatedUserId = userID
                };
                var sowWkflow = new SowWkflow
                {
                    WkflowInstance    = WKflow,
                    ProjectName       = requestInfo.ProjectName,
                    Amend             = 0,
                    EffectiveDate     = DateTime.UtcNow,
                    LastReviewDate    = DateTime.UtcNow,
                    NextReviewDate    = DateTime.UtcNow.AddMonths(6),
                    MonthlyCommitment = requestInfo.Commitment
                };

                foreach (var attrib in requestInfo.Attribs)
                {
                    //var newatt = new SowWklowSowAttribute() { SowAttributeId = attrib.Id, SowWkflow = sowWkflow };
                    //newatt.SowAttributeValueHists.Add(new SowAttributeValueHist() { SowWklowSowAttribute = newatt, EffectiveDate = DateTime.UtcNow, SowAttributeId = attrib.Id, Qty = attrib.Qty, UnitPrice = attrib.UnitPrice, ExtendedPrice = attrib.ExtendedPrice });
                    //sowWkflow.SowWklowSowAttributes.Add(newatt);

                    var newatt = new SowWklowSowAttribute()
                    {
                        SowAttributeId = attrib.Id, SowWkflow = sowWkflow
                    };
                    newatt.SowAttributeValueHists.Add(new SowAttributeValueHist()
                    {
                        SowWklowSowAttribute = newatt, EffectiveDate = DateTime.UtcNow, Qty = attrib.Qty, UnitPrice = attrib.UnitPrice, ExtendedPrice = attrib.ExtendedPrice
                    });
                    sowWkflow.SowWklowSowAttributes.Add(newatt);
                }

                foreach (var docSetup in requestInfo.DocSetups)
                {
                    sowWkflow.SowWkflowDocSetups.Add(new SowWkflowDocSetup()
                    {
                        DocumentName = docSetup.Name, SowWkflow = sowWkflow, NoIndexes = docSetup.NoIndexes, NoDataFields = docSetup.NoDataFields, SLA = docSetup.SLA, Volume = docSetup.CommitVolume, ListPrice = docSetup.UnitPrice
                    });
                }

                if (requestInfo.RebateOverride)
                {
                    var reseller = org.OrgOrgs1.FirstOrDefault().Org.OrgReseller;
                    sowWkflow.SOWWkflowOrgResellerDiscOverrides.Add(new SOWWkflowOrgResellerDiscOverride {
                        Discount = requestInfo.ResellerRebate, EffectiveDate = DateTime.UtcNow, SowWkflow = sowWkflow, OrgReseller = reseller
                    });
                }

                WKflow.SowWkflows.Add(sowWkflow);
                WKflow.WkflowStepHists.Add(hist);
                _IWkflowinstanceService.AddWkflowinstance(WKflow);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }