public Uri BuildRequestUri(ModelServiceClient modelService)
 {
     return(UriCreator.FromUri(modelService.ModelServiceBaseUri)
            .WithPath($"api/navigation/{PublicationId}/subtree/{ParentSitemapItemId}")
            .WithQueryParam("includeAncestors", IncludeAncestors)
            .WithQueryParam("descendantLevels", DescendantLevels).Build());
 }
示例#2
0
 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!要它干嘛?
 /// <summary>
 /// 新增模型
 /// </summary>
 /// <param name="modelInfo"></param>
 public void AddModel(Model  model)
 {
     //ModelYunBLL.ModelInfo modelBLL = new ModelYunBLL.ModelInfo();
     ModelServiceClient ms=new ModelServiceClient();
     //modelBLL.AddModel(modelInfo);
     ms.Create(model.name, model.version, Convert.ToInt32(model.authorUserId), model.className, (Int32)model.topId, (Int32)model.typeId);
 }
        public string GetContent(string uri, string templateUri = "")
        {
            LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContent({0})", LoggingCategory.Performance, uri);
            LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContent({0})", LoggingCategory.Performance, uri);
            TcmUri             tcmUri         = new TcmUri(uri);
            TcmUri             templateTcmUri = new TcmUri(templateUri);
            EntityModelRequest request        = new EntityModelRequest
            {
                PublicationId = PublicationId,
                DataModelType = DataModelType.DD4T,
                DcpType       = DcpType.HIGHEST_PRIORITY,
                ComponentId   = tcmUri.ItemId
            };

            if (!string.IsNullOrEmpty(templateUri))
            {
                request.TemplateId = templateTcmUri.ItemId;
            }

            try
            {
                var response = ModelServiceClient.PerformRequest <IDictionary <string, object> >(request);
                return(response.Response["Content"] as string);
            }
            catch
            {
            }
            return(null);
        }
示例#4
0
 /// <summary>Snippet for ListModels</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void ListModels()
 {
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     string projectId  = "";
     string datasetId  = "";
     uint?  maxResults = 0U;
     // Make the request
     ListModelsResponse response = modelServiceClient.ListModels(projectId, datasetId, maxResults);
 }
 /// <summary>Snippet for GetModel</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetModel()
 {
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     string projectId = "";
     string datasetId = "";
     string modelId   = "";
     // Make the request
     Model response = modelServiceClient.GetModel(projectId, datasetId, modelId);
 }
示例#6
0
        /// <summary>Snippet for GetModelAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetModelAsync()
        {
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            string projectId = "";
            string datasetId = "";
            string modelId   = "";
            // Make the request
            Model response = await modelServiceClient.GetModelAsync(projectId, datasetId, modelId);
        }
        /// <summary>Snippet for ListModelsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListModelsAsync()
        {
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            string projectId  = "";
            string datasetId  = "";
            uint?  maxResults = 0U;
            // Make the request
            ListModelsResponse response = await modelServiceClient.ListModelsAsync(projectId, datasetId, maxResults);
        }
示例#8
0
        public BaseProvider(IProvidersCommonServices providersCommonServices)
        {
            if (providersCommonServices == null)
            {
                throw new ArgumentNullException("providersCommonServices");
            }

            LoggerService       = providersCommonServices.Logger;
            PublicationResolver = providersCommonServices.PublicationResolver;
            Configuration       = providersCommonServices.Configuration;
            ModelServiceClient  = new ModelServiceClient();
        }
示例#9
0
        public Uri BuildRequestUri(ModelServiceClient modelService)
        {
            var builder = UriCreator.FromUri(modelService.ModelServiceBaseUri)
                          .WithPath($"EntityModel/{CmUriScheme}/{PublicationId}/{EntityId}")
                          .WithQueryParam("modelType", DataModelType)
                          .WithQueryParam("dcpType", DcpType);

            if (ContentType != ContentType.IGNORE)
            {
                builder.WithQueryParam("raw", ContentType == ContentType.RAW);
            }
            return(builder.Build());
        }
        public Uri BuildRequestUri(ModelServiceClient modelService)
        {
            var builder = UriCreator.FromUri(modelService.ModelServiceBaseUri)
                          .WithPath($"PageModel/{CmUriScheme}/{PublicationId}/{GetCanonicalUrlPath(Path)}")
                          .WithQueryParam("includes", PageInclusion)
                          .WithQueryParam("modelType", DataModelType);

            if (ContentType != ContentType.IGNORE)
            {
                builder.WithQueryParam("raw", ContentType == ContentType.RAW);
            }
            return(builder.Build());
        }
        /// <summary>Snippet for DeleteModel</summary>
        public void DeleteModel()
        {
            // Snippet: DeleteModel(string, string, string, CallSettings)
            // Create client
            ModelServiceClient modelServiceClient = ModelServiceClient.Create();
            // Initialize request argument(s)
            string projectId = "";
            string datasetId = "";
            string modelId   = "";

            // Make the request
            modelServiceClient.DeleteModel(projectId, datasetId, modelId);
            // End snippet
        }
 /// <summary>Snippet for PatchModel</summary>
 public void PatchModel()
 {
     // Snippet: PatchModel(string, string, string, Model, CallSettings)
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     string projectId = "";
     string datasetId = "";
     string modelId   = "";
     Model  model     = new Model();
     // Make the request
     Model response = modelServiceClient.PatchModel(projectId, datasetId, modelId, model);
     // End snippet
 }
 /// <summary>Snippet for GetModel</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetModelRequestObject()
 {
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     GetModelRequest request = new GetModelRequest
     {
         ProjectId = "",
         DatasetId = "",
         ModelId   = "",
     };
     // Make the request
     Model response = modelServiceClient.GetModel(request);
 }
示例#14
0
        /// <summary>Snippet for DeleteModel</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void DeleteModelRequestObject()
        {
            // Create client
            ModelServiceClient modelServiceClient = ModelServiceClient.Create();
            // Initialize request argument(s)
            DeleteModelRequest request = new DeleteModelRequest
            {
                ProjectId = "",
                DatasetId = "",
                ModelId   = "",
            };

            // Make the request
            modelServiceClient.DeleteModel(request);
        }
示例#15
0
 /// <summary>Snippet for ListModels</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void ListModelsRequestObject()
 {
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     ListModelsRequest request = new ListModelsRequest
     {
         ProjectId  = "",
         DatasetId  = "",
         MaxResults = 0U,
         PageToken  = "",
     };
     // Make the request
     ListModelsResponse response = modelServiceClient.ListModels(request);
 }
示例#16
0
        /// <summary>Snippet for GetModelAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetModelRequestObjectAsync()
        {
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetModelRequest request = new GetModelRequest
            {
                ProjectId = "",
                DatasetId = "",
                ModelId   = "",
            };
            // Make the request
            Model response = await modelServiceClient.GetModelAsync(request);
        }
        /// <summary>Snippet for ListModelsAsync</summary>
        public async Task ListModelsAsync()
        {
            // Snippet: ListModelsAsync(string, string, uint?, CallSettings)
            // Additional: ListModelsAsync(string, string, uint?, CancellationToken)
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            string projectId  = "";
            string datasetId  = "";
            uint?  maxResults = 0U;
            // Make the request
            ListModelsResponse response = await modelServiceClient.ListModelsAsync(projectId, datasetId, maxResults);

            // End snippet
        }
        /// <summary>Snippet for GetModelAsync</summary>
        public async Task GetModelAsync()
        {
            // Snippet: GetModelAsync(string, string, string, CallSettings)
            // Additional: GetModelAsync(string, string, string, CancellationToken)
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            string projectId = "";
            string datasetId = "";
            string modelId   = "";
            // Make the request
            Model response = await modelServiceClient.GetModelAsync(projectId, datasetId, modelId);

            // End snippet
        }
示例#19
0
        /// <summary>Snippet for ListModelsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListModelsRequestObjectAsync()
        {
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListModelsRequest request = new ListModelsRequest
            {
                ProjectId  = "",
                DatasetId  = "",
                MaxResults = 0U,
                PageToken  = "",
            };
            // Make the request
            ListModelsResponse response = await modelServiceClient.ListModelsAsync(request);
        }
        public DefaultModelServiceProvider()
        {
            string uri = WebConfigurationManager.AppSettings["model-service-uri"];
            int    n;
            int    retryCount = int.TryParse(
                WebConfigurationManager.AppSettings["model-service-retries"], out n)
                ? n
                : DefaultRetryCount;

            int timeout = int.TryParse(
                WebConfigurationManager.AppSettings["model-service-timeout"], out n)
                ? n
                : DefaultTimeout;

            _modelServiceClient = new ModelServiceClient(uri, retryCount, timeout);
            _binder             = new Binder();
        }
 /// <summary>Snippet for PatchModel</summary>
 public void PatchModelRequestObject()
 {
     // Snippet: PatchModel(PatchModelRequest, CallSettings)
     // Create client
     ModelServiceClient modelServiceClient = ModelServiceClient.Create();
     // Initialize request argument(s)
     PatchModelRequest request = new PatchModelRequest
     {
         ProjectId = "",
         DatasetId = "",
         ModelId   = "",
         Model     = new Model(),
     };
     // Make the request
     Model response = modelServiceClient.PatchModel(request);
     // End snippet
 }
        public DefaultModelServiceProvider()
        {
            string uri = WebConfigurationManager.AppSettings["model-builder-service-uri"];
            int    n;
            int    retryCount = int.TryParse(
                WebConfigurationManager.AppSettings["model-builder-service-retries"], out n)
                ? n
                : DefaultRetryCount;

            int timeout = int.TryParse(
                WebConfigurationManager.AppSettings["model-builder-service-timeout"], out n)
                ? n
                : DefaultTimeout;

            _modelServiceClient = new ModelServiceClient(uri, retryCount, timeout);
            _binder             = new Binder();
            Log.Debug($"{ModelServiceName} found at URL '{_modelServiceClient.ModelServiceBaseUri}'");
        }
        /// <summary>Snippet for GetModelAsync</summary>
        public async Task GetModelRequestObjectAsync()
        {
            // Snippet: GetModelAsync(GetModelRequest, CallSettings)
            // Additional: GetModelAsync(GetModelRequest, CancellationToken)
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetModelRequest request = new GetModelRequest
            {
                ProjectId = "",
                DatasetId = "",
                ModelId   = "",
            };
            // Make the request
            Model response = await modelServiceClient.GetModelAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListModelsAsync</summary>
        public async Task ListModelsRequestObjectAsync()
        {
            // Snippet: ListModelsAsync(ListModelsRequest, CallSettings)
            // Additional: ListModelsAsync(ListModelsRequest, CancellationToken)
            // Create client
            ModelServiceClient modelServiceClient = await ModelServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListModelsRequest request = new ListModelsRequest
            {
                ProjectId  = "",
                DatasetId  = "",
                MaxResults = 0U,
                PageToken  = "",
            };
            // Make the request
            ListModelsResponse response = await modelServiceClient.ListModelsAsync(request);

            // End snippet
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string url)
        {
            LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContentByUrl({0})", LoggingCategory.Performance, url);
            string           content = null;
            PageModelRequest req     = new PageModelRequest
            {
                PublicationId = PublicationId,
                DataModelType = DataModelType.DD4T,
                PageInclusion = PageInclusion.INCLUDE,
                Path          = url
            };

            try
            {
                content = ModelServiceClient.PerformRequest(req).Response;
            }
            catch
            {
            }
            //  LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContentByUrl({0}) returns {1}", LoggingCategory.Performance, url, content);
            return(content);
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URI
        /// </summary>
        /// <param name="Url">TCM URI of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUri(string tcmUri)
        {
            LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContentByUri({0})", LoggingCategory.Performance, tcmUri);
            string           content     = null;
            TcmUri           tcm         = new TcmUri(tcmUri);
            PageMetaFactory  metaFactory = GetPageMetaFactory(tcm.PublicationId);
            PageModelRequest req         = new PageModelRequest
            {
                PublicationId = tcm.PublicationId,
                DataModelType = DataModelType.DD4T,
                PageInclusion = PageInclusion.INCLUDE,
                Path          = metaFactory.GetMeta(tcm.ItemId).UrlPath
            };

            try
            {
                content = ModelServiceClient.PerformRequest(req).Response;
            }
            catch
            {
            }
            //  LoggerService.Debug(">>DD4T.Providers.DxaModelService::GetContentByUrl({0}) returns {1}", LoggingCategory.Performance, tcmUri, content);
            return(content);
        }
 public Uri BuildRequestUri(ModelServiceClient modelService)
 {
     return
         UriCreator.FromUri(modelService.ModelServiceBaseUri).WithPath($"api/navigation/{PublicationId}").Build();
 }
示例#28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string Method = Request["Method"];
            //保存文件时用到的模型ID,用于分类目录
            string ModelIDParam = "";
            try
            {
                ModelIDParam = Request["ModelID"];
            }
            catch { }

            if (Method == "saveOMI")
            {
                saveFile(this.Context, "UploadOMI");
            }
            else if (Method == "saveDLL")
            {
                saveFile(this.Context, "UploadDLL");
            }
            else if (Method == "ModelInfo")//!!!!!!!!!!!!!!!!!!!!!!!!!与下面的switch重复了!!!!!!!!!!!!!!!!!!
            {
                //ModelYunModel.ModelInfo _oneModel = new ModelYunModel.ModelInfo();
                Model _oneModel = new Model();
                _oneModel.name = Request["ModelName"];
                _oneModel.typeId = Convert.ToInt32(Request["SelectModelType"]);
               // _oneModel.ModelDllName = Request["ModelDllName"];
               // _oneModel.ResultStartRow = Convert.ToInt32(Request["ResultStartRow"]);
               // _oneModel.OMIFileName = Request["uploadifyNote"];
               // ModelYunBLL.ModelInfo _modelBLL = new ModelYunBLL.ModelInfo();
                ModelServiceClient ms = new ModelServiceClient();
                ms.Create(_oneModel.name,_oneModel.version,Convert.ToInt32(_oneModel.authorUserId),_oneModel.className,(Int32)_oneModel.topId,(Int32)_oneModel.typeId);
                Response.Write("OK");
            }
            switch (Method)
            {
                case "Login":
                    string username = Request["UserName"];
                    string password = Request["Password"];
                    int userID = 0;
                    //ModelYunBLL.Users UsersBll = new ModelYunBLL.Users();
                    UserServiceClient UsersBll = new UserServiceClient();
                    bool IsAccountOK = UsersBll.Auth(username, password);
                    userID = Convert.ToInt32(UsersBll.GetByUsername(username).id);
                    if (IsAccountOK == true)
                    {
                        Response.Write("OK");
                        Response.Cookies["DigitalBasinUserName"].Value = username;
                        Response.Cookies["DigitalBasinUserName"].Expires = DateTime.MaxValue;
                        Response.Cookies["DigitalBasinUserID"].Value = userID.ToString();
                        Response.Cookies["DigitalBasinUserID"].Expires = DateTime.MaxValue;

                    }
                    else
                    {
                        Response.Write("Not OK");
                    }
                    break;
                case "saveOMI":
                    saveFile(this.Context, "UploadOMI");
                    break;
                case "saveDLL":
                    saveFile(this.Context, "UploadDLL");
                    break;

                case "ModelInfo":
                   // ModelYunModel.ModelInfo _oneModel = new ModelYunModel.ModelInfo();
                    Model _oneModel = new Model();
                    _oneModel.name = Request["ModelName"];
                    _oneModel.typeId=Convert.ToInt32(Request["SelectModelType"]);
                    //_oneModel.ModelDllName = Request["ModelDllName"];
                    //_oneModel.ResultStartRow = Convert.ToInt32(Request["ResultStartRow"]);
                    //_oneModel.OMIFileName = Request["uploadifyNote"];
                    //ModelYunBLL.ModelInfo _modelBLL = new ModelYunBLL.ModelInfo();
                    ModelServiceClient _modelBLL = new ModelServiceClient();
                    _modelBLL.Create(_oneModel.name, _oneModel.version, Convert.ToInt32(_oneModel.authorUserId), _oneModel.className, (Int32)_oneModel.topId, (Int32)_oneModel.typeId);
                    Response.Write("OK");
                    break;

                //参数配置-------------------------------------Start-------------|
                case "canshupeizhi":
                    saveFile(this.Context, "DATA\\" + ModelIDParam + "\\canshupeizhi");
                    break;
                    //参数配置
                case "CanshupeizhiSubmit":
                    //水流时间步长(秒)
                    string buchang = Request["BuChang"];
                    Response.Write("OK");
                    break;
                //--------参数配置--------End

                //边界控制-------------------------------------Start-------------|
                case "bianjiekongzhi_DiXing":
                    saveFile(this.Context, "DATA\\" + ModelIDParam + "\\bianjiekongzhi\\bianjiekongzhi_DiXing");
                    break;
                //边界控制-------------------------------------Start-------------|
                case "bianjiekongzhi_RuKou":
                    saveFile(this.Context, "DATA\\" + ModelIDParam + "\\bianjiekongzhi\\bianjiekongzhi_RuKou");
                    break;
                case "BianjiekongzhiSubmit":
                    Response.Write("OK");
                    break;
                //--------边界控制--------End

                //初始条件-------------------------------------Start-------------|
                case "chushitiaojian":
                    saveFile(this.Context, "DATA\\" + ModelIDParam + "\\chushitiaojian");
                    break;
                case "ChushitiaojianSubmit":
                    Response.Write("OK");
                    break;
                //--------初始条件--------End

                //过程控制-------------------------------------Start-------------|
                case "guochengkongzhi":
                    saveFile(this.Context, "DATA\\" + ModelIDParam + "\\guochengkongzhi");
                    break;
                case "GuochengkongzhiSubmit":
                    Response.Write("OK");
                    break;
                //--------过程控制--------End
            }
        }