Пример #1
0
        public HttpResponseMessage GetDocTyps(string soOrgKey)
        {
            DateTime start = DateTime.Now;

            try
            {
                var org = _IOrgService.GetOrgs().Where(p => p.soKey == Guid.Parse(soOrgKey)).FirstOrDefault();

                if (org != null)
                {
                    //Go Up the chain and get call DocTypes
                    List <OrgDocTyp> docTypes = new List <OrgDocTyp>();
                    GetAllDocs(ref docTypes, org);
                    var result = PlatformMappingHelper.Map <IList <OrgDocTyp>, IList <DocTypDTO> >(docTypes.ToList()).ToList();
                    ApiLog.Write("GetDocTypes", start);
                    return(Request.CreateResponse <IList <DocTypDTO> >(HttpStatusCode.OK, result));
                }
                else
                {
                    var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Org Key");
                    throw new HttpResponseException(createresponse);
                }
            }
            catch (Exception e)
            {
                var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Error Retriving Version Number/StorageAccessKey");
                throw new HttpResponseException(createresponse);
            }
        }
Пример #2
0
        public PortalDTO GetPortal(int portalId)
        {
            var port = _PortService.GetPort(portalId);

            var portalDTO = PlatformMappingHelper.Map <Port, PortalDTO>(port);

            return(portalDTO);
        }
Пример #3
0
        public HttpResponseMessage Search(SubscriptionSearchRequest requestInfo)
        {
            try
            {
                int?     orgid;
                DateTime?reviewEndDate;
                DateTime?reviewStartDate;

                List <SowWkflow> sows = new List <SowWkflow>();

                orgid           = requestInfo.OrgId != null ? requestInfo.OrgId : null;
                reviewEndDate   = requestInfo.ReviewEndDate != null ? requestInfo.ReviewEndDate : null;
                reviewStartDate = requestInfo.ReviewStartDate != null ? requestInfo.ReviewStartDate : null;


                if (orgid != null && reviewEndDate != null && reviewStartDate != null)
                {
                    //  All Search Params Search
                    sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid && p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList();
                }
                else if (orgid != null)
                {
                    // Search only by orgId
                    sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid).ToList();
                }
                else
                {
                    sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId > 0).ToList();
                }

                //if (requestInfo.OrgId != null)
                //{
                //    orgid = requestInfo.OrgId;

                //    sows = _ISowwkflowService.GetSowwkflows().Where(p => p.WkflowInstance.OrgId == orgid && p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList();

                //}
                //else
                //{
                //    sows = _ISowwkflowService.GetSowwkflows().Where(p => p.EffectiveDate >= requestInfo.ReviewStartDate && p.EffectiveDate <= requestInfo.ReviewEndDate).ToList();

                //}


                var result = PlatformMappingHelper.Map <IList <SowWkflow>, IList <SOWDTO> >(sows.ToList()).ToList();

                if (result == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                return(Request.CreateResponse <IEnumerable <SOWDTO> >(HttpStatusCode.OK, result));
            }
            catch (Exception daExp)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Пример #4
0
        public HttpResponseMessage GetWkflowInstance(int id)
        {
            var wkflowInstance = _IWkflowinstanceService.GetWkflowinstance(id);
            var result         = PlatformMappingHelper.Map <WkflowInstance, WkflowInstanceDTO>(wkflowInstance);

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <WkflowInstanceDTO>(HttpStatusCode.OK, result));
        }
Пример #5
0
        public HttpResponseMessage GetSOW(int wkflowId)
        {
            var sow    = _IWkflowinstanceService.GetWkflowinstance(wkflowId);
            var result = PlatformMappingHelper.Map <IList <SowWkflow>, IList <SOWDTO> >(sow.SowWkflows.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <SOWDTO> >(HttpStatusCode.OK, result));
        }
Пример #6
0
        public HttpResponseMessage search(CustomerSearchRequest requestInfo)
        {
            var orgs   = _IOrgcustService.GetCustomersByFilter(requestInfo);
            var result = PlatformMappingHelper.Map <IList <OrgCust>, IList <CustomerDTO> >(orgs.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <CustomerDTO> >(HttpStatusCode.OK, result));
        }
Пример #7
0
        public HttpResponseMessage GetWkflowsByFilter(int?orgId, int?docTypeId)
        {
            var wkflowInstances = _IWkflowinstanceService.GetWkflowinstances().Where(p => p.OrgId == orgId && p.WkflowInstanceDocs.FirstOrDefault().Doc.OrgDocTypId == docTypeId).ToList();
            var result          = PlatformMappingHelper.Map <IList <WkflowInstance>, IList <WkflowInstanceDTO> >(wkflowInstances.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <WkflowInstanceDTO> >(HttpStatusCode.OK, result));
        }
Пример #8
0
        public HttpResponseMessage GetDocument(int id)
        {
            var docs   = _IDocService.GetSoupload(id);
            var result = PlatformMappingHelper.Map <soUpload, DocDTO>(docs);

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <DocDTO>(HttpStatusCode.OK, result));
        }
Пример #9
0
        //public HttpResponseMessage GetOrgsByOrgTyp(string orgTypCd)
        //{
        //    var orgs = _IOrgService.QueryData().Where(p => p.OrgTyp.TypCd == orgTypCd).ToList();

        //    var result = PlatformMappingHelper.Map<IList<Org>, IList<OrgDTO>>(orgs.ToList()).ToList();

        //    if (result == null) throw new HttpResponseException(HttpStatusCode.NotFound);
        //    return Request.CreateResponse<IEnumerable<OrgDTO>>(HttpStatusCode.OK, result);
        //}

        #endregion

        #region Authorization
        public HttpResponseMessage GetAuthRols()
        {
            var authRols = _IAuthrolService.GetAuthrols();

            var result = PlatformMappingHelper.Map <IList <AuthRol>, IList <AuthRolDTO> >(authRols.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <AuthRolDTO> >(HttpStatusCode.OK, result));
        }
Пример #10
0
        public HttpResponseMessage GetPackages()
        {
            var packages = _PackageService.GetPackages();

            var result = PlatformMappingHelper.Map <IList <Package>, IList <PackageDTO> >(packages.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <PackageDTO> >(HttpStatusCode.OK, result));
        }
Пример #11
0
        public HttpResponseMessage RecentActivity(int custId)
        {
            var uploadActivities = _IWkflowinstanceService.GetRecentUploadActivity(custId, 10);

            var result = PlatformMappingHelper.Map <IList <WkflowInstance>, IList <BatchProcessingWorkflowDTO> >(uploadActivities).ToList();

            if (uploadActivities == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <BatchProcessingWorkflowDTO> >(HttpStatusCode.OK, result));
        }
Пример #12
0
        public HttpResponseMessage GetOrgs()
        {
            var orgs = _OrgService.GetOrgs().Where(p => p.InactiveDate == null);

            var result = PlatformMappingHelper.Map <IList <Org>, IList <OrgDTO> >(orgs.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <OrgDTO> >(HttpStatusCode.OK, result));
        }
Пример #13
0
        // Get All Users
        //[Authorize]
        public HttpResponseMessage GetUsers()
        {
            var users = _IUserService.GetUsers();

            var result = PlatformMappingHelper.Map <IList <User>, IList <UserDTO> >(users.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <UserDTO> >(HttpStatusCode.OK, result));
        }
Пример #14
0
        public HttpResponseMessage detail(int id)
        {
            var document = _IWkflowinstanceService.GetWkflowinstance(id);

            var result = PlatformMappingHelper.Map <WkflowInstance, DPWorkflowDTO>(document);

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <DPWorkflowDTO>(HttpStatusCode.OK, result));
        }
Пример #15
0
        public HttpResponseMessage DocTypeStatus()
        {
            var docTypestatus = _IDoctypstatusService.GetDoctypstatus();

            var doctypestatus = PlatformMappingHelper.Map <IList <DocTypStatus>, IList <DocTypStatusDTO> >(docTypestatus.ToList()).ToList();

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

            return(Request.CreateResponse <IList <DocTypStatusDTO> >(HttpStatusCode.OK, doctypestatus));
        }
Пример #16
0
        public HttpResponseMessage DefaultDoctyps()
        {
            var defaultdocTypes = _IOrgdoctypService.GetDefaultDoctyps();

            var defaults = PlatformMappingHelper.Map <IList <OrgDocTyp>, IList <DocTypDTO> >(defaultdocTypes.ToList()).ToList();

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

            return(Request.CreateResponse <IList <DocTypDTO> >(HttpStatusCode.OK, defaults));
        }
Пример #17
0
        public HttpResponseMessage get(int id)
        {
            var docType = _IOrgdoctypService.GetOrgdoctyp(id);

            var doctypedto = PlatformMappingHelper.Map <OrgDocTyp, DocTypDTO>(docType);

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


            return(Request.CreateResponse <DocTypDTO>(HttpStatusCode.OK, doctypedto));
        }
Пример #18
0
        public HttpResponseMessage DataTypes()
        {
            var dataElmTyps = _IDataelmtypService.GetDataelmtyps();

            var datatypes = PlatformMappingHelper.Map <IList <DataElmTyp>, IList <DataElmTypDTO> >(dataElmTyps.ToList()).ToList();

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


            return(Request.CreateResponse <List <DataElmTypDTO> >(HttpStatusCode.OK, datatypes));
        }
Пример #19
0
        public HttpResponseMessage GetDocumentsByFilter(string orgIds, string docTypCd, int?elmId, string value)
        {
            // var docs = _IDocService.QueryData().Where(p => p.DocTyp.DocTypCd == docTypCd).ToList();

            var docs = _IDocService.GetSouploads().ToList().Where(p => p.OrgId == Convert.ToInt32(orgIds));

            var result = PlatformMappingHelper.Map <IList <soUpload>, IList <DocDTO> >(docs.ToList()).ToList();

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

            return(Request.CreateResponse <IEnumerable <DocDTO> >(HttpStatusCode.OK, result));
        }
Пример #20
0
        public HttpResponseMessage Search(SupportSearchRequest requestInfo)
        {
            int org_id = int.Parse(Request.Headers.GetValues("orgId").FirstOrDefault());

            requestInfo.OrgIds = new List <int>();

            if (requestInfo.OrgId == null)
            {
                var org = _IOrgService.GetOrg(org_id);
                if (org.OrgTyp.TypCd == "RESE")
                {
                    requestInfo.OrgIds.Add(org_id);
                    var custOrgs = _IOrgorgService.GetOrgorgs().Where(p => p.OrgId == org_id).Select(s => s.AssociatedOrgId).ToList();
                    requestInfo.OrgIds.AddRange(custOrgs);
                    requestInfo.OrgId = 0;
                }
                else if (org.OrgTyp.TypCd == "CUST")
                {
                    requestInfo.OrgIds.Add(org_id);
                    requestInfo.OrgId = 0;
                }
                else if (org.OrgTyp.TypCd == "TENA")
                {
                }
                else
                {
                    requestInfo.OrgId = 0;
                }
            }
            else
            {
                requestInfo.OrgIds.Add((int)requestInfo.OrgId);
            }


            var work = _IWkflowinstanceService.GetSupportActivityByFilter(requestInfo);

            var result = PlatformMappingHelper.Map <IList <WkflowInstance>, IList <SupportActivityDTO> >(work.ToList()).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <SupportActivityDTO> >(HttpStatusCode.OK, result));
        }
Пример #21
0
        public HttpResponseMessage search(int?OrgId, string docName, DateTime?startDate, DateTime?endDate, int?createUserID)
        {
            if (OrgId == null)
            {
                OrgId = int.Parse(Request.Headers.GetValues("orgId").FirstOrDefault());
            }


            var docTypes = _IOrgdoctypService.GetDoctypsByFilter(OrgId, docName, startDate, endDate, createUserID);

            var search = PlatformMappingHelper.Map <IList <OrgDocTyp>, IList <DocTypDTO> >(docTypes.ToList()).ToList();

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

            return(Request.CreateResponse <IList <DocTypDTO> >(HttpStatusCode.OK, search));
        }
Пример #22
0
        public HttpResponseMessage search(UploadActivitySearchRequest filter)
        {
            if (filter.OrgId == null)
            {
                filter.OrgId = int.Parse(Request.Headers.GetValues("orgId").FirstOrDefault());
            }

            //filter.LastId = filter.LastId == null? int.MaxValue: filter.LastId;

            var uploadActivities = _IWkflowinstanceService.GetUploadActivityByFilter(filter);

            var result = PlatformMappingHelper.Map <IList <WkflowInstance>, IList <BatchProcessingWorkflowDTO> >(uploadActivities).ToList();

            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <IEnumerable <BatchProcessingWorkflowDTO> >(HttpStatusCode.OK, result));
        }
Пример #23
0
        public HttpResponseMessage GetPendingEmails(int count)
        {
            DateTime start = DateTime.Now;

            try
            {
                var msgUsers = _IMessageuserService.GetMessageusers().Where(u => u.DeliveryMethod.Name == "EMail" && u.Message.DeliveredDate == null).Take(count);

                var result = PlatformMappingHelper.Map <IList <MessageUser>, IList <MessageDTO> >(msgUsers.ToList()).ToList();

                ApiLog.Write("GetPendingEmails", start);
                return(Request.CreateResponse <IList <MessageDTO> >(HttpStatusCode.OK, result));
            }
            catch (Exception e)
            {
                var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Error Retriving Version Number/StorageAccessKey");
                throw new HttpResponseException(createresponse);
            }
        }
Пример #24
0
        public HttpResponseMessage detail(int id)
        {
            var uploadactivity = _IWkflowinstanceService.GetWkflowinstance(id);

            var result = PlatformMappingHelper.Map <WkflowInstance, BatchProcessingWorkflowDTO>(uploadactivity);

            var storageAccess    = _IPortsettingService.GetPortsettings().Where(p => p.PortId == 1 && p.Setting.Name == "StorageAccess").FirstOrDefault().PortSettingValues.FirstOrDefault().Value;
            var storageContainer = uploadactivity.WkflowInstanceDocs.FirstOrDefault().Doc.soStorageContainer;
            var versionData      = new VersionData();

            versionData.container  = storageContainer;
            versionData.accountKey = storageAccess;
            int imageType = 0;

            try
            {
                if (result.FileName.ToUpper().Contains(".PDF"))
                {
                    imageType = 1;
                    var pdfimage = BlobImage.GetImage(uploadactivity.WkflowInstanceDocs.FirstOrDefault().Doc.soStorageKey, versionData, imageType);
                    result.image = pdfimage[0];
                }
                else
                {
                    imageType      = 2;
                    result.preview = BlobImage.GetImage(uploadactivity.WkflowInstanceDocs.FirstOrDefault().Doc.soStorageKey, versionData, imageType);
                }
            }
            catch (Exception e)
            {
            }


            if (result == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(Request.CreateResponse <BatchProcessingWorkflowDTO>(HttpStatusCode.OK, result));
        }
Пример #25
0
        public HttpResponseMessage Reseller(int resellerId)
        {
            ResellerDTO search = null;

            var reseller = _IOresellerService.GetOrgresellers().Where(p => p.Org.Id == resellerId).FirstOrDefault();

            if (reseller != null)
            {
                search = PlatformMappingHelper.Map <OrgReseller, ResellerDTO>(reseller);

                if (search == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Reseller could not be found"));
            }

            return(Request.CreateResponse <ResellerDTO>(HttpStatusCode.OK, search));
        }
Пример #26
0
        public HttpResponseMessage User(int userId)
        {
            UserDTO search = null;

            var user = _IUserService.GetUser(userId);

            if (user != null)
            {
                search = PlatformMappingHelper.Map <User, UserDTO>(user);

                if (search == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "UserName could not be found"));
            }

            return(Request.CreateResponse <UserDTO>(HttpStatusCode.OK, search));
        }
Пример #27
0
        public HttpResponseMessage Customer(int custId)
        {
            CustomerDTO search = null;

            var customer = _IOrgcustService.GetOrgcusts().Where(p => p.Org.Id == custId).FirstOrDefault();

            if (customer != null)
            {
                search = PlatformMappingHelper.Map <OrgCust, CustomerDTO>(customer);

                if (search == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Customer could not be found"));
            }

            return(Request.CreateResponse <CustomerDTO>(HttpStatusCode.OK, search));
        }
Пример #28
0
        public HttpResponseMessage Search(UserSearchRequest request)
        {
            //if (request.OrgId == null)
            //{
            //    request.OrgId = int.Parse(Request.Headers.GetValues("orgId").FirstOrDefault());
            //}

            request.UserName  = request.UserName == null ? string.Empty : request.UserName;
            request.FirstName = request.FirstName == null ? string.Empty : request.FirstName;
            request.LastName  = request.LastName == null ? string.Empty : request.LastName;


            var users = _IUserService.GetUsersByFilter(request);

            var search = PlatformMappingHelper.Map <IList <User>, IList <UserDTO> >(users.ToList()).ToList();

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

            return(Request.CreateResponse <IList <UserDTO> >(HttpStatusCode.OK, search));
        }
Пример #29
0
        public HttpResponseMessage UserLogin(UserPasswordModel userPasswordModel)
        {
            var securityUrl = ConfigurationManager.AppSettings["AuthServer"];
            var clientID    = ConfigurationManager.AppSettings["ClientID"];

            HttpWebRequest httpWReq =
                (HttpWebRequest)WebRequest.Create(securityUrl + @"/oauth2/token");

            ASCIIEncoding encoding = new ASCIIEncoding();
            string        postData = "Username="******"&Password="******"&grant_type=password";
            postData += "&client_id=" + clientID;

            try
            {
                byte[] data = encoding.GetBytes(postData);

                httpWReq.Method        = "POST";
                httpWReq.ContentType   = "application/x-www-form-urlencoded";
                httpWReq.ContentLength = data.Length;

                using (Stream stream = httpWReq.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }

                HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();

                string       responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                AuthTokenDTO authToken      = JsonConvert.DeserializeObject <AuthTokenDTO>(responseString);


                var user = _IUserService.GetUserByUserName(userPasswordModel.UserName);

                var userLookedUp = user;

                var portUser = _IPortalUserService.QueryData().Where(p => p.User.Id == user.Id).ToList();
                var userPort = portUser[0].Port;

                //var portalDefinition = _IPortalService.GetPortalDefinition(userPort.Id);

                var portalUser = PlatformMappingHelper.Map <User, PortalUserDTO>(user);

                //AutherizationResponseDTO autherizationResponse = new AutherizationResponseDTO
                //{ AuthToken = authToken, PortalId = userPort.Id, PortalUser = portalUser };

                var autherizationResponse = new
                { data = authToken, error = "" };

                var userOrg = user.Orgs.FirstOrDefault();


                portalUser.Org = PlatformMappingHelper.Map <Org, OrgDTO>(userOrg);


                try
                {
                    if (user != null)
                    {
                        user.UserLoginHists.Add(new UserLoginHist {
                            LoginDate = DateTime.UtcNow
                        });
                        _UnitOfWork.Commit();
                    }
                }
                catch (Exception daExp)
                {
                    var x = daExp;
                }

                return(Request.CreateResponse <dynamic>(HttpStatusCode.OK, autherizationResponse));
            }
            catch (Exception exp)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }