Пример #1
0
        public List <MediaModel> VisualizationMediaSearch(
            string name,
            DateTime?dateFrom,
            DateTime?dateTo)
        {
            var visualizationRepository = Globals.Resolve <IVisualizationRepository>();
            var result   = new List <MediaModel>();
            var spMedias = MediaSearch(name, dateFrom, dateTo);
            var dbMedias = visualizationRepository
                           .MediaGet(IDBContext.Current.Operation, name, dateFrom, dateTo, true);

            foreach (var media in spMedias)
            {
                var mediaUrl = media.MediaUrl.ToLower();
                if (!dbMedias.Any(dbm => dbm.MediaUrl.ToLower() == mediaUrl) &&
                    !string.IsNullOrEmpty(mediaUrl))
                {
                    var mime = ImageHelper.URLGetMime(mediaUrl);
                    if (mime.StartsWith("image/"))
                    {
                        media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "IMAGE").MasterId;
                    }
                    else
                    {
                        media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "VIDEO").MasterId;
                    }

                    media.Name = mediaUrl.SubstringFromLast('/');
                    result.Add(media);
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Save the visual output information
        /// </summary>
        /// <param name="vpv">The VPV (operation mapping) data</param>
        /// <param name="vovs">Array of all vov</param>
        /// <returns></returns>
        public virtual ActionResult VisualizationDataSave(
            VPVVModels vpv,
            VOVVModel[] vovs)
        {
            if (vpv != null)
            {
                var business = new VisualizationBusinessContext();
                vpv.LocationTypeId       = MasterDefinitions.GetMaster("UNDEFINED").MasterId;
                business.VisualProjectId = vpv.VisualProjectId;
                business.Load(IDBContext.Current.Operation);
                business.ViewModel = vpv;
                if (vpv.VisualProjectMedia != null)
                {
                    foreach (var media in vpv.VisualProjectMedia)
                    {
                        //TODO: Get the media source from the sended name for each media
                        //TODO: Transform the sended media from base64 and send to sharepoint
                        //new SharepointProxy().AddMediaFile(Request.Files[0]);
                        //TODO: create the media phat based in the sharepoint url+operation+media directory+filename
                        //TODO: Set the URL from in the media model
                        //TODO: Set MediaTypeId depending of the media type sended
                    }
                }

                business.Execute("Visualization.VP.Save");

                //TODO: Update vpv location with the GeolocationWK
                //business.VisualizationRepository.VisualProjectVersionSetGeolocation(vpv.GeolocationWNT);
            }

            if (vovs != null)
            {
                foreach (var vov in vovs)
                {
                    if (vov.VisualOutputMedia != null)
                    {
                        foreach (var media in vov.VisualOutputMedia)
                        {
                            //TODO: Get the media source from the sended name for each media
                            //TODO: Transform the sended media from base64 and send to sharepoint
                            //new SharepointProxy().AddMediaFile(Request.Files[0]);
                            //TODO: create the media phat based in the sharepoint url+operation+media directory+filename
                            //TODO: Set the URL from in the media model
                            //TODO: Set MediaTypeId depending of the media type sended
                        }
                    }

                    vov.DeliveryStatusId = MasterDefinitions
                                           .GetMaster(vov.DeliveryStatus, "VO_DELIVERY_STATUS").MasterId;
                }
            }

            return(Content(string.Empty));
        }
Пример #3
0
        /// <summary>
        /// Save the visual data.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="vpv">The VPV.</param>
        /// <param name="vovs">The vovs.</param>
        /// <param name="userName"></param>
        public void VisualizationDataSave(
            string operation,
            VPVVModels vpv,
            VOVVModel[] vovs, string userName)
        {
            var imageTypes = new string[] { "png", "jpg", "jpeg", "gif", "bpm" };

            IDBContext.Current.Operation = operation;
            //check if operation mapping is empty before call to save
            if (vpv.IsNotNull())
            {
                var business = new VisualizationBusinessContext();
                vpv.LocationTypeId       = MasterDefinitions.GetMaster("UNDEFINED").MasterId;
                business.VisualProjectId = vpv.VisualProjectId;
                business.Load(operation);
                business.ViewModel = vpv;
                if (vpv.VisualProjectMedia.IsNotNull())
                {
                    foreach (var media in vpv.VisualProjectMedia)
                    {
                        //Transform the sended media from base64 and send to sharepoint
                        media.MediaUrl = new SharepointProxy().AddMediaFile(
                            new Base64file(media.MediaFile64, media.MediaUrl));

                        //Get the media source from the sended name for each media
                        media.MediaSourceId = MasterDefinitions
                                              .GetMaster("MEDIA_SOURCE", media.MediaSource).MasterId;

                        //Set MediaTypeId depending of the media type sended
                        var mime = ImageHelper.URLGetMime(media.MediaUrl);
                        if (mime.StartsWith("image/"))
                        {
                            media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "IMAGE").MasterId;
                        }
                        else
                        {
                            media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "VIDEO").MasterId;
                        }
                    }
                }
                business.ViewModel = vpv;
                business.Execute("Visualization.VP.Save");
            }

            if (vovs.IsNotNull())
            {
                var business = new VisualizationBusinessContext();

                business.ViewModel = vpv;
                foreach (var vov in vovs)
                {
                    vov.LocationTypeId = MasterDefinitions.GetMaster("UNDEFINED").MasterId;
                    if (vov.VisualOutputId == -1)
                    {
                        business.OutputId = vov.OutputId.Value;
                    }
                    else
                    {
                        business.VisualOutputId = vov.VisualOutputId;
                        business.OutputId       = business
                                                  .VisualOutputGet(vov.VisualOutputId)
                                                  .VisualOutputVersions
                                                  .First()
                                                  .OutputYearPlan
                                                  .OutputId;
                    }
                    business.Load(IDBContext.Current.Operation);
                    vov.LocationTypeId   = MasterDefinitions.GetMasterByName("VO_LOCATION_TYPE", vov.LocationType).MasterId;
                    vov.DeliveryStatusId = MasterDefinitions.GetMasterByName("VO_DELIVERY_STATUS", vov.DeliveryStatus).MasterId;
                    business.ViewModel   = vov;

                    if (vov.VisualOutputMedia.IsNotNull())
                    {
                        foreach (var media in vov.VisualOutputMedia)
                        {
                            //Transform the sended media from base64 and send to sharepoint
                            media.MediaUrl = new SharepointProxy().AddMediaFile(
                                new Base64file(media.MediaFile64, media.MediaUrl));

                            //Get the media source from the sended name for each media
                            media.MediaSourceId = MasterDefinitions
                                                  .GetMaster("MEDIA_SOURCE", media.MediaSource).MasterId;
                            //get the history status from given information
                            media.MediaHistoryStatusId = MasterDefinitions.GetMasterByName(
                                "VO_DELIVERY_STATUS", media.MediaHistoryStatus).MasterId;

                            //Set MediaTypeId depending of the media type sended
                            var mime = ImageHelper.URLGetMime(media.MediaUrl);
                            if (mime.StartsWith("image/"))
                            {
                                media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "IMAGE").MasterId;
                            }
                            else
                            {
                                media.MediaTypeId = MasterDefinitions.GetMaster("MEDIA_TYPE", "VIDEO").MasterId;
                            }
                        }
                    }
                    business.Execute("Visualization.VO.Save");
                }
            }
        }