예제 #1
0
        public IApplicationClient CreateClient(EnvironmentSettings environment)
        {
            var creatioClient = new CreatioClient(environment.Uri, environment.Login, environment.Password,
                                                  true, environment.IsNetCore);

            return(new CreatioClientAdapter(creatioClient));
        }
예제 #2
0
        /// <summary> Добавить объект </summary>
        public T CreateObj <T>(T obj) where T : BaseEntity
        {
            String serializedEntity = JsonConvert.SerializeObject(obj,
                                                                  new JsonSerializerSettings
            {
                ContractResolver  = new JsonPropertiesResolver(),
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.Indented
            });

            StringContent       content  = new StringContent(serializedEntity, Encoding.UTF8, "application/json");
            Uri                 odataUri = new Uri(OdataUri, typeof(T).Name);
            HttpResponseMessage response = CreatioClient.PostAsync(odataUri, content).Result;

            try { response.EnsureSuccessStatusCode(); }
            catch (HttpRequestException ex)
            {
                String error = "\n\n" + JToken.Parse(response.Content.ReadAsStringAsync().Result).ToString(Formatting.Indented) + "\n";
                throw new Exception(error, ex);
            }
            String result = response.Content.ReadAsStringAsync().Result;

#if DEBUG
            result = JToken.Parse(result).ToString(Formatting.Indented);
#endif
            T operationResult = JsonConvert.DeserializeObject <T>(result);
            return(operationResult);
        }
예제 #3
0
        public static int GetPkgList(PkgListOptions options)
        {
            Configure(options);
            var    scriptData         = "{}";
            string responseFormServer = CreatioClient.ExecutePostRequest(ServiceUrl, scriptData);
            var    json             = CorrectJson(responseFormServer);
            var    packages         = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(json);
            var    selectedPackages = packages.Where(p => p["Name"].ToLower().Contains(options.SearchPattern.ToLower())).OrderBy(p => p["Name"]);

            if (selectedPackages.Count() > 0)
            {
                var row = GetFormatedString("Name", "Maintainer");
                Console.WriteLine();
                Console.WriteLine(row);
                Console.WriteLine();
            }
            foreach (var p in selectedPackages)
            {
                var row = GetFormatedString(p["Name"], p["Maintainer"]);
                Console.WriteLine(row);
            }
            Console.WriteLine();
            Console.WriteLine($"Find {selectedPackages.Count()} packages in {Settings.Uri}");
            return(0);
        }
예제 #4
0
        private static Dictionary <string, string> GetClassModels(string entitySchemaName, string fields)
        {
            var    url = string.Format(GetEntityModelsUrl, entitySchemaName, fields);
            string responseFormServer = CreatioClient.ExecuteGetRequest(url);
            var    result             = CorrectJson(responseFormServer);

            return(JsonConvert.DeserializeObject <Dictionary <string, string> >(result));
        }
예제 #5
0
        private static TCommand CreateRemoteCommand <TCommand>(EnvironmentOptions options,
                                                               params object[] additionalConstructorArgs)
        {
            var settings = GetEnvironmentSettings(options);
            var creatioClient = new CreatioClient(settings.Uri, settings.Login, settings.Password, true, settings.IsNetCore);
            var clientAdapter = new CreatioClientAdapter(creatioClient);
            var constructorArgs = new object[] { clientAdapter, settings }.Concat(additionalConstructorArgs).ToArray();

            return((TCommand)Activator.CreateInstance(typeof(TCommand), constructorArgs));
        }
예제 #6
0
        private static void ExecuteCodeFromAssemblyInternal(ExecuteAssemblyOptions options)
        {
            string filePath           = options.Name;
            string executorType       = options.ExecutorType;
            var    fileContent        = File.ReadAllBytes(filePath);
            string body               = Convert.ToBase64String(fileContent);
            string requestData        = @"{""Body"":""" + body + @""",""LibraryType"":""" + executorType + @"""}";
            var    responseFromServer = CreatioClient.ExecutePostRequest(ExecutorUrl, requestData);

            Console.WriteLine(responseFromServer);
        }
예제 #7
0
        private static Version GetAppApiVersion()
        {
            var apiVersion = new Version("0.0.0.0");

            try {
                string appVersionResponse = CreatioClient.ExecuteGetRequest(ApiVersionUrl).Trim('"');
                apiVersion = new Version(appVersionResponse);
            } catch (Exception) {
            }
            return(apiVersion);
        }
예제 #8
0
 private static void DownloadZipPackagesInternal(string packageName, string destinationPath)
 {
     try {
         Console.WriteLine("Start download packages ({0}).", packageName);
         var    packageNames = string.Format("\"{0}\"", packageName.Replace(" ", string.Empty).Replace(",", "\",\""));
         string requestData  = "[" + packageNames + "]";
         CreatioClient.DownloadFile(GetZipPackageUrl, destinationPath, requestData);
         Console.WriteLine("Download packages ({0}) completed.", packageName);
     } catch (Exception) {
         Console.WriteLine("Download packages ({0}) not completed.", packageName);
     }
 }
예제 #9
0
        private static void CreateSysSetting(SysSettingsOptions opts)
        {
            Guid   id          = Guid.NewGuid();
            string requestData = "{" + string.Format("\"id\":\"{0}\",\"name\":\"{1}\",\"code\":\"{1}\",\"valueTypeName\":\"{2}\",\"isCacheable\":true",
                                                     id, opts.Code, opts.Type) + "}";

            try {
                CreatioClient.ExecutePostRequest(InsertSysSettingsUrl, requestData);
                Console.WriteLine("SysSettings with code: {0} created.", opts.Code);
            } catch {
                Console.WriteLine("SysSettings with code: {0} already exists.", opts.Code);
            }
        }
예제 #10
0
        public static void UpdateSysSetting(SysSettingsOptions opts, EnvironmentSettings settings = null)
        {
            if (settings != null)
            {
                Configure(settings);
            }
            string requestData = "{\"isPersonal\":false,\"sysSettingsValues\":{" + string.Format("\"{0}\":{1}", opts.Code, opts.Value) + "}}";

            try {
                CreatioClient.ExecutePostRequest(PostSysSettingsValuesUrl, requestData);
                Console.WriteLine("SysSettings with code: {0} updated.", opts.Code);
            } catch {
                Console.WriteLine("SysSettings with code: {0} is not updated.", opts.Code);
            }
        }
예제 #11
0
        /// <summary> Удалить объект </summary>
        public void DeleteObj <T>(T obj) where T : BaseEntity
        {
            if (obj.Id == null)
            {
                throw new InvalidOperationException("Не указан идентификатор изменяемого объекта");
            }
            Uri odataUri = new Uri(OdataUri, $"{typeof(T).Name}({obj.Id})");
            HttpResponseMessage response = CreatioClient.DeleteAsync(odataUri).Result;

            try { response.EnsureSuccessStatusCode(); }
            catch (HttpRequestException ex)
            {
                String error = "\n\n" + JToken.Parse(response.Content.ReadAsStringAsync().Result).ToString(Formatting.Indented) + "\n";
                throw new Exception(error, ex);
            }
        }
예제 #12
0
        static void Main(string[] args)
        {
            var app          = " http://tsagent-2-3:88/StudioENU_3627526_1112";
            var authApp      = "http://tsagent-2-3:88/studioenu_3627526_is_1112/connect/token";
            var clientId     = "3B24D68AD2A710EC244320105D362A99";
            var clientSecret = "AB23B7D15810B4229B028848DFE09581D05F101F35FD71490782C420BF873B52";


            //var client = new CreatioClient(app, "Supervisor", "Supervisor");
            var    client      = CreatioClient.CreateOAuth20Client(app, authApp, clientId, clientSecret);
            string serviceName = "RightsService";
            string methodName  = "GetCanExecuteOperation";
            string requestData = "{\"operation\":\"CanManageSolution\"}";
            string request     = client.CallConfigurationService(serviceName, methodName, requestData);

            Console.WriteLine(request);
            Console.ReadLine();
        }
예제 #13
0
        /// <summary> Модифицировать объект </summary>
        public void UpdateObj <T>(T obj) where T : BaseEntity
        {
            if (obj.Id == null)
            {
                throw new InvalidOperationException("Не указан идентификатор изменяемого объекта");
            }

            String serializedEntity = JsonConvert.SerializeObject(obj,
                                                                  new JsonSerializerSettings
            {
                ContractResolver  = new JsonPropertiesResolver(),
                NullValueHandling = NullValueHandling.Ignore
            });

#if DEBUG
            String entityForDebug = JsonConvert.SerializeObject(obj,
                                                                new JsonSerializerSettings
            {
                ContractResolver  = new JsonPropertiesResolver(),
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.Indented
            });
            //serializedEntity = "{\"Notes\": \"*****\"}";
#endif


            StringContent       content  = new StringContent(serializedEntity, Encoding.UTF8, "application/json");
            Uri                 odataUri = new Uri(OdataUri, $"{typeof(T).Name}({obj.Id})");
            HttpResponseMessage response = CreatioClient.PatchAsync(odataUri, content).Result;
            try { response.EnsureSuccessStatusCode(); }
            catch (HttpRequestException ex)
            {
                String error = "\n\n" + JToken.Parse(response.Content.ReadAsStringAsync().Result).ToString(Formatting.Indented) + "\n";
                throw new Exception(error, ex);
            }
        }
예제 #14
0
 internal CreatioClientAdapter(string applicationUrl, string username, string password, bool isNetCore = false)
 {
     _creatioClient = new CreatioClient(applicationUrl, username, password, isNetCore);
 }
예제 #15
0
 public CreatioClientAdapter(string appUrl, string clientId, string clientSecret, string AuthAppUrl, bool isNetCore = false)
 {
     _creatioClient = CreatioClient.CreateOAuth20Client(appUrl, AuthAppUrl, clientId, clientSecret, isNetCore);
 }
예제 #16
0
 public CreatioClientAdapter(string appUrl, string userName, string userPassword, bool isNetCore = false, string workspaceId = "0")
 {
     _creatioClient = new CreatioClient(appUrl, userName, userPassword, isNetCore, workspaceId);
 }
예제 #17
0
 public CreatioClientAdapter(string appUrl, string userName, string userPassword, bool isNetCore = false)
 {
     _creatioClient = new CreatioClient(appUrl, userName, userPassword, true, isNetCore);
 }
예제 #18
0
 public FeatureModerator(CreatioClient client)
 {
     CreatioClient = client;
 }
예제 #19
0
 public CreatioClientAdapter(CreatioClient creatioClient)
 {
     _creatioClient = creatioClient;
 }