예제 #1
0
        /// <summary>
        /// Clones a release
        /// </summary>
        /// <param name="releaseCode"></param>
        /// <param name="grpCode"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        internal int CloneRelease(int releaseCode, string grpCode, string username)
        {
            Release_ADO releaseAdo = new Release_ADO(Ado);

            //Clone the comment first
            return(releaseAdo.Clone(releaseCode, grpCode, username));
        }
예제 #2
0
        internal dynamic GetPendingLiveForLive(int rlsCode, string samAccountName)
        {
            Release_ADO rAdo = new Release_ADO(_ado);

            if (!rAdo.IsLiveNow(rlsCode))
            {
                return(null);
            }

            dynamic query = rAdo.Read(rlsCode, samAccountName);

            if (query == null)
            {
                return(null);
            }
            query = rAdo.ReadPendingLive(new Release_DTO_Read()
            {
                MtrCode = query.MtrCode
            });
            if (query == null)
            {
                return(null);
            }
            if (rAdo.IsLiveNext(query.RlsCode))
            {
                return(query);
            }

            return(null);
        }
예제 #3
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.Format.FrmDirection != FormatDirection.DOWNLOAD.ToString())
            {
                return(false);
            }
            ////See if this request has cached data
            MemCachedD_Value cache = MemCacheD.Get_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadMetadata", DTO);

            if (cache.hasData)
            {
                Response.data = cache.data;
                return(true);
            }


            if (Throttle_BSO.IsThrottled(Ado, HttpContext.Current.Request, Request, SamAccountName))
            {
                Log.Instance.Debug("Request throttled");
                Response.error = Label.Get("error.throttled");
            }

            var items = new Release_ADO(Ado).ReadLiveNow(DTO.matrix, DTO.language);

            var result = Release_ADO.GetReleaseDTO(items);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }
            //The Language of the received data may be different from the request - so we make sure it corresponds to the language of the metadata
            DTO.language = items.LngIsoCode;
            return(ExecuteReadMetadata(Ado, DTO, result, Response));
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Release_ADO adoRelease = new Release_ADO(Ado);
            Release_DTO dtoRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(DTO.RlsCode, SamAccountName));


            DTO.MtrCode = dtoRelease.MtrCode;

            //We can do this now because the MtrCode is available to us
            MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + DTO.MtrCode);
            MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_METADATA + DTO.MtrCode);

            int updated;

            if (dtoRelease.CmmCode == 0)
            {
                dtoRelease.CmmValue = DTO.CmmValue;
                updated             = adoRelease.CreateComment(dtoRelease, SamAccountName);
            }
            else
            {
                dtoRelease.CmmValue = DTO.CmmValue;
                updated             = adoRelease.UpdateComment(dtoRelease, SamAccountName);
            }

            if (updated == 0)
            {
                Log.Instance.Debug("Failed to update Release Comment");
                Response.error = Label.Get("error.update");
                return(false);
            }
            Response.data = JSONRPC.success;
            return(true);
        }
예제 #5
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.Format.FrmDirection != FormatDirection.DOWNLOAD.ToString())
            {
                return(false);
            }

            ////See if this request has cached data
            MemCachedD_Value cache = MemCacheD.Get_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadPreMetadata", DTO);

            if (cache.hasData)
            {
                Response.data = cache.data;
                return(true);
            }

            var item   = new Matrix_ADO(Ado).Read(DTO.release, DTO.language, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadMetadata.ExecuteReadMetadata(Ado, DTO, result, Response, false));
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoRelease = new Release_ADO(Ado);
            var list       = adoRelease.ReadLivePrevious(DTO.RlsCode);

            Response.data = list;

            return(true);
        }
예제 #7
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoRelease = new Release_ADO(Ado);
            var list       = adoRelease.Read(DTO.RlsCode, SamAccountName);

            Response.data = list;

            return(true);
        }
예제 #8
0
        internal Matrix GetMetadataMatrix(string LngIsoCode, string MtrCode)
        {
            var release = new Release_ADO(ado).ReadLiveNow(MtrCode, LngIsoCode);

            var result = Release_ADO.GetReleaseDTO(release);

            // The matrix constructor will load all the metadata from the db when instances specification
            return(result != null ? new Matrix(ado, result, LngIsoCode) : null);
        }
예제 #9
0
        /// <summary>
        /// Get the latest release for a matrix
        /// </summary>
        /// <param name="theMatrix"></param>
        /// <returns></returns>
        internal Release_DTO GetLatestRelease(Matrix theMatrix)
        {
            Release_ADO releaseAdo     = new Release_ADO(Ado);
            var         releaseDTORead = new Release_DTO_Read()
            {
                MtrCode = theMatrix.Code
            };

            return(Release_ADO.GetReleaseDTO(releaseAdo.ReadLatest(releaseDTORead)));
        }
예제 #10
0
        /// <summary>
        /// Delete method
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="rlsCode"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        internal int Delete(ADO Ado, int rlsCode, string userName, bool mandatoryKeywordsOnly)
        {
            Matrix_ADO adoMatrix = new Matrix_ADO(Ado);

            int deleted = adoMatrix.Delete(rlsCode, userName);

            Keyword_Release_ADO adoKeywordRelease = new Keyword_Release_ADO();

            deleted = adoKeywordRelease.Delete(Ado, rlsCode, null, mandatoryKeywordsOnly);

            Release_ADO adoRelease = new Release_ADO(Ado);


            deleted = adoRelease.Delete(rlsCode, userName);

            return(deleted);
        }
예제 #11
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.jStatQueryExtension.extension.Pivot != null)
            {
                if (DTO.jStatQueryExtension.extension.Format.Type != "CSV" && DTO.jStatQueryExtension.extension.Format.Type != "XLSX")
                {
                    DTO.jStatQueryExtension.extension.Pivot = null;
                }
            }
            //if the role details haven't been supplied then look it up from the metadata in the database
            if (DTO.Role == null)
            {
                DTO.Role = new Cube_BSO().UpdateRoleFromMetadata(Ado, DTO);
            }

            //The Language of the received data may be different from the request - so we make sure it corresponds to the language of the dataset (???)
            var items = new Release_ADO(Ado).ReadLiveNow(DTO.jStatQueryExtension.extension.Matrix, DTO.jStatQueryExtension.extension.Language.Code);

            ////See if this request has cached data
            MemCachedD_Value cache = MemCacheD.Get_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadDataset", DTO);

            if (cache.hasData)
            {
                Response.data = cache.data;
                return(true);
            }


            if (Throttle_BSO.IsThrottled(Ado, HttpContext.Current.Request, Request, SamAccountName))
            {
                Log.Instance.Debug("Request throttled");
                Response.error = Label.Get("error.throttled");
            }

            var result = Release_ADO.GetReleaseDTO(items);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            var data = ExecuteReadDataset(Ado, DTO, result, Response, DTO.jStatQueryExtension.extension.Language.Code, DTO.jStatQueryExtension.extension.Language.Culture, defaultPivot);

            return(data);
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //Validation of parameters and user have been successful. We may now proceed to read from the database
            var adoReasonRelease = new ReasonRelease_ADO();

            ADO_readerOutput adoReader = new ADO_readerOutput();


            //We must  check if there is a workflow in place for this release. If so, then we don't allow the ReasonRelease update
            Workflow_DTO workflowDTO = new Workflow_DTO();
            Workflow_ADO workflowADO = new Workflow_ADO();

            workflowDTO.RlsCode            = DTO.RlsCode;
            workflowDTO.WrqCurrentFlagOnly = true;

            adoReader = workflowADO.Read(Ado, workflowDTO, SamAccountName);
            if (adoReader.hasData)
            {
                Log.Instance.Debug("Can't update ReasonRelease because a Workflow is already in place for this Release");
                Response.error = Label.Get("error.create");
                return(false);
            }

            Release_ADO adoRelease = new Release_ADO(Ado);

            if (!adoRelease.IsWip(DTO.RlsCode))
            {
                Log.Instance.Debug("Can't update ReasonRelease - Release is not in WIP status");
                Response.error = Label.Get("error.update");
                return(false);
            }

            //Update the Reason
            int updated = adoReasonRelease.Update(Ado, DTO, SamAccountName);

            if (updated == 0)
            {
                Log.Instance.Debug("Can't update ReasonRelease");
                Response.error = Label.Get("error.update");
                return(false);
            }

            Response.data = JSONRPC.success;
            return(true);
        }
예제 #13
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Release_ADO adoRelease = new Release_ADO(Ado);
            Release_DTO dtoRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(DTO.RlsCode, SamAccountName));

            dtoRelease.RlsDependencyFlag = DTO.RlsDependencyFlag.Value;
            DTO.MtrCode = dtoRelease.MtrCode;
            int updated = adoRelease.Update(dtoRelease, SamAccountName);

            if (updated == 0)
            {
                Log.Instance.Debug("Failed to update Dependency flag");
                Response.error = Label.Get("error.update");
                return(false);
            }
            Response.data = JSONRPC.success;
            return(true);
        }
예제 #14
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            if (DTO.Format.FrmDirection != FormatDirection.DOWNLOAD.ToString())
            {
                return(false);
            }

            var item   = new Matrix_ADO(Ado).Read(DTO.release, DTO.language, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadMetadata.ExecuteReadMetadata(Ado, DTO, result, Response));
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Release_ADO adoRelease = new Release_ADO(Ado);

            Release_DTO dtoRelease = new Release_DTO();

            dtoRelease.RlsCode = DTO.RlsCode;
            int deleted = adoRelease.DeleteComment(dtoRelease, SamAccountName);

            if (deleted == 0)
            {
                //Can't create a comment so we can't proceed
                Log.Instance.Debug("Can't delete  comment - request refused");
                Response.error = Label.Get("error.delete");
                return(false);
            }

            Response.data = JSONRPC.success;
            return(true);
        }
예제 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var item   = new Matrix_ADO(Ado).Read(DTO.jStatQueryExtension.extension.RlsCode, DTO.jStatQueryExtension.extension.Language.Code, SamAccountName);
            var result = Release_ADO.GetReleaseDTO(item);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            DTO.jStatQueryExtension.extension.Matrix = result.MtrCode;
            //if the role details haven't been supplied then look it up from the metadata in the database
            if (DTO.Role == null)
            {
                DTO.Role = new Cube_BSO().UpdateRoleFromMetadata(Ado, DTO);
            }

            //The returned data may not be in the same language as the preferred language, so we must change the DTO.language property
            // DTO.language = item.LngIsoCode;
            return(Cube_BSO_ReadDataset.ExecuteReadDataset(Ado, DTO, result, Response, DTO.jStatQueryExtension.extension.Language.Code, DTO.jStatQueryExtension.extension.Language.Culture));
        }
예제 #17
0
        /// <summary>
        /// Create a new release
        /// </summary>
        /// <param name="theMatrix"></param>
        /// <param name="releaseVersion"></param>
        /// <param name="releaseRevision"></param>
        /// <param name="grpCode"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        internal int CreateRelease(Matrix theMatrix, int releaseVersion, int releaseRevision, string grpCode, string username)
        {
            Release_ADO releaseAdo = new Release_ADO(Ado);
            Release_DTO releaseDto = new Release_DTO()
            {
                GrpCode             = grpCode,
                RlsLiveDatetimeFrom = DateTime.MinValue,
                RlsLiveDatetimeTo   = DateTime.MaxValue,
                RlsRevision         = releaseRevision,
                RlsVersion          = releaseVersion
            };

            ValidationResult releaseValidatorResult = new ReleaseValidator().Validate(releaseDto);

            if (!releaseValidatorResult.IsValid)
            {
                Log.Instance.Debug(releaseValidatorResult.Errors);
                return(0);
            }

            return(releaseAdo.Create(releaseDto, username));
        }
예제 #18
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Release_ADO adoRelease = new Release_ADO(Ado);

            if (adoRelease.IsWip(DTO.RlsCode))
            {
                Release_BSO_Delete deleteBso = new Release_BSO_Delete();
                if (deleteBso.Delete(Ado, DTO.RlsCode, SamAccountName, false) == 0)
                {
                    Log.Instance.Debug("Can't delete Release");
                    Response.error = Label.Get("error.delete");
                    return(false);
                }

                Response.data = JSONRPC.success;
                return(true);
            }
            else
            {
                Log.Instance.Debug("Release can't be deleted because it is not WIP");
                return(false);
            }
        }
예제 #19
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //if the role details haven't been supplied then look it up from the metadata in the database
            if (DTO.Role == null)
            {
                DTO.Role = new Cube_BSO().UpdateRoleFromMetadata(Ado, DTO);
            }

            //The Language of the received data may be different from the request - so we make sure it corresponds to the language of the dataset (???)
            var items = new Release_ADO(Ado).ReadLiveNow(DTO.jStatQueryExtension.extension.Matrix, DTO.jStatQueryExtension.extension.Language.Code);

            /* string requestLanguage = DTO.language;
             * DTO.language = items.LngIsoCode; */


            ////See if this request has cached data
            MemCachedD_Value cache = MemCacheD.Get_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadDataset", DTO);

            if (cache.hasData)
            {
                Response.data = cache.data;
                return(true);
            }


            var result = Release_ADO.GetReleaseDTO(items);

            if (result == null)
            {
                Response.data = null;
                return(true);
            }

            var data = ExecuteReadDataset(Ado, DTO, result, Response, DTO.jStatQueryExtension.extension.Language.Code, DTO.jStatQueryExtension.extension.Language.Culture);

            return(data);
        }
예제 #20
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            // uses authentication and filters privileges according to user access
            var currentRelease = Release_ADO.GetReleaseDTO(new Matrix_ADO(Ado).Read(DTO.RlsCode, Configuration_BSO.GetCustomConfig("language.iso.code"), SamAccountName));

            if (currentRelease == null)
            {
                Response.data = null;
                return(true);
            }

            int previousReleaseId = new Compare_ADO(Ado).ReadPreviousRelease(DTO.RlsCode);

            if (previousReleaseId == 0)
            {
                Response.data = null;
            }
            else
            {
                Response.data = previousReleaseId;
            }

            return(true);
        }
예제 #21
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Release_ADO adoRelease = new Release_ADO(Ado);

            Release_DTO dtoRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(DTO.RlsCode, SamAccountName));


            DTO.MtrCode = dtoRelease.MtrCode;


            //We can do this now because the MtrCode is available to us
            MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + DTO.MtrCode);
            MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_METADATA + DTO.MtrCode);

            bool historicalTest = adoRelease.IsHistorical(DTO.RlsCode);
            int  deleted        = 0;

            if (!historicalTest)
            {
                deleted = adoRelease.DeleteComment(dtoRelease, SamAccountName);
            }


            if (deleted == 0)
            {
                //Can't create a comment so we can't proceed
                Log.Instance.Debug("Can't delete  comment - request refused");
                Response.error = Label.Get("error.delete");
                return(false);
            }



            Response.data = JSONRPC.success;
            return(true);
        }
예제 #22
0
        internal int CloneComment(int releaseCode, int RlsIdNew, string username)
        {
            Release_ADO releaseAdo = new Release_ADO(Ado);

            return(releaseAdo.CloneComment(releaseCode, RlsIdNew, username));
        }
예제 #23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="request"></param>
 internal Matrix_BSO_Create(JSONRPC_API request) : base(request, new PxUploadValidator())
 {
     matrixAdo  = new Matrix_ADO(Ado);
     releaseAdo = new Release_ADO(Ado);
 }
예제 #24
0
        /// <summary>
        /// Get the collection with metadata
        /// </summary>
        /// <param name="theAdo"></param>
        /// <param name="theCubeDTO"></param>
        /// <param name="theResponse"></param>
        /// <returns></returns>
        internal dynamic ExecuteReadCollection(ADO theAdo, Cube_DTO_ReadCollection DTO, bool meta = true)
        {
            var ado = new Cube_ADO(theAdo);

            var dbData = ado.ReadCollectionMetadata(DTO.language, DTO.datefrom, DTO.product, meta);

            List <dynamic> jsonStatCollection = new List <dynamic>();

            //Get a list of individual matrix data entities
            List <dynamic> releases = getReleases(dbData, meta);


            var theJsonStatCollection = new JsonStatCollection();

            theJsonStatCollection.Link      = new JsonStatCollectionLink();
            theJsonStatCollection.Link.Item = new List <Item>();

            List <Format_DTO_Read> formats = new List <Format_DTO_Read>();

            using (Format_BSO format = new Format_BSO(new ADO("defaultConnection")))
            {
                formats = format.Read(new Format_DTO_Read()
                {
                    FrmDirection = Utility.GetCustomConfig("APP_FORMAT_DOWNLOAD_NAME")
                });
            };

            //For each of these, get a list of statistics and a list of classifications
            //Then get the JSON-stat for that metadata and add to jsonStatCollection
            foreach (var rls in releases)
            {
                List <dynamic> thisReleaseMetadata = dbData.Where(x => x.RlsCode == rls.RlsCode).Where(x => x.LngIsoCode == rls.LngIsoCode).ToList <dynamic>();
                if (meta)
                {
                    List <dynamic> stats           = getStatistics(thisReleaseMetadata);
                    List <dynamic> classifications = getClassifications(thisReleaseMetadata);
                    List <dynamic> periods         = getPeriods(thisReleaseMetadata);
                    theJsonStatCollection.Link.Item.Add(GetJsonStatRelease(thisReleaseMetadata, stats, classifications, periods, formats));
                }
                else
                {
                    List <dynamic> classifications = getClassificationsNoVrbCount(thisReleaseMetadata);
                    theJsonStatCollection.Link.Item.Add(GetJsonStatReleaseNoCollections(thisReleaseMetadata, formats, classifications));
                }
            }

            //Get the minimum next release date. The cache can only live until then.
            //If there's no next release date then the cache will live for the maximum configured amount.

            DateTime minDateItem = default;

            Release_ADO rAdo = new Release_ADO(theAdo);

            dynamic dateQuery = rAdo.ReadNextReleaseDate();

            if (dateQuery != null)
            {
                minDateItem = dateQuery.RlsDatetimeNext.Equals(DBNull.Value) ? default(DateTime) : dateQuery.RlsDatetimeNext;
            }
            else
            {
                minDateItem = default;
            }



            var result = new JRaw(Serialize.ToJson(theJsonStatCollection));


            MemCacheD.Store_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadCollection", DTO, result, minDateItem, Constants.C_CAS_DATA_CUBE_READ_COLLECTION);


            // return the formatted data. This is an array of JSON-stat objects.
            return(result);
        }