/// <summary> /// Submit the process to NS and get a rtid. /// </summary> public static String SubmitProcess() { try { NetClient.PostData(GlobalContext.URL_SubmitProcess, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "pid", MPController.CurrentTransaction.ProcessPID }, { "from", "MasterPanel.NET" }, { "renid", MPController.CurrentTransaction.RenUsername }, { "bindingType", MPController.CurrentTransaction.IsolationType.ToString() }, { "launchType", MPController.CurrentTransaction.LaunchType.ToString() }, { "failureType", MPController.CurrentTransaction.FailureType.ToString() }, { "authType", MPController.CurrentTransaction.AuthType.ToString() }, // todo auth type { "binding", "" } // todo static Resources.xml }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); return(ReturnDataHelper.DecodeString(response)); } catch (Exception ex) { LogUtils.LogLine("Submit process, exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }
/// <summary> /// Get BO of a process. /// </summary> /// <param name="pid">process pid</param> /// <returns>A List of Dictonary of BO items</returns> public static List <Dictionary <String, String> > GetProcessBO(string pid) { try { NetClient.PostData(GlobalContext.URL_GetProcessBOByPid, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "pid", pid } }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); var boList = ReturnDataHelper.DecodeList(response); return(boList.Select(bo => (bo as JArray).ToObject <List <String> >()) .Select(boKVP => new Dictionary <string, string> { { "boid", boKVP[0] }, { "bo_name", boKVP[1] } }) .ToList()); } catch (Exception ex) { LogUtils.LogLine("GetProcessBO exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }
/// <summary> /// Decode a standard response to a .NET dictionary(string, string) data struct. /// </summary> /// <param name="response">StdResponseEntity instance to be decoded</param> /// <returns>Dictionary in .NET</returns> public static Dictionary <String, String> DecodeToStringStringDictionary(StdResponseEntity response) { var returnElement = response.returnElement.data.ToString(); var jtoken = (JToken)JsonConvert.DeserializeObject <Object>(returnElement); return(ReturnDataHelper.DecodeDictionaryJToken(jtoken)); }
/// <summary> /// Get the data version of this Ren auth binding COrgan. /// </summary> public static String GetDataVersion() { try { NetClient.PostData(GlobalContext.URL_GetDataVersion, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "renid", MPController.CurrentTransaction.RenUsername } }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); return(ReturnDataHelper.DecodeString(response)); } catch (Exception ex) { LogUtils.LogLine("Submit process, exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }
/// <summary> /// Upload a BO. /// </summary> /// <param name="boName"></param> /// <param name="content"></param> /// <returns>Dictionary of BO upload response</returns> public static Dictionary <String, String> UploadBO(string boName, string content) { try { NetClient.PostData(GlobalContext.URL_UploadBO, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "pid", MPController.CurrentTransaction.ProcessPID }, { "name", boName }, { "content", System.Web.HttpUtility.UrlEncode(content, Encoding.UTF8) } }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); return(ReturnDataHelper.DecodeToStringStringDictionary(response)); } catch (Exception ex) { LogUtils.LogLine("UploadBO exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }
/// <summary> /// Get processes of a ren user. /// </summary> /// <returns>A list of dictionary of processes</returns> public static List <Dictionary <String, String> > GetProcess() { try { NetClient.PostData(GlobalContext.URL_GetProcessByRenId, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "renid", MPController.CurrentTransaction.RenUsername } }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); var processList = ReturnDataHelper.DecodeList(response); return(processList.Select(proc => (Dictionary <String, String>)(proc as JObject).ToObject(typeof(Dictionary <String, String>))).ToList()); } catch (Exception ex) { LogUtils.LogLine("GetProcess exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }
/// <summary> /// Authorization connect. /// </summary> /// <param name="username">user unique name</param> /// <param name="password">pure password</param> /// <returns>KVP (successflag, token)</returns> public static KeyValuePair <bool, string> Login(string username, string password) { try { NetClient.PostData(GlobalContext.URL_Auth_Connect, new Dictionary <string, string> { { "username", username }, { "password", password } }, out string retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); var retToken = ReturnDataHelper.DecodeString(response); var successFlag = !retToken.StartsWith("#"); return(new KeyValuePair <bool, string>(successFlag, successFlag ? retToken : "")); } catch (Exception ex) { LogUtils.LogLine("LoginForm exception occurred" + ex, "MPController", LogLevel.Error); return(new KeyValuePair <bool, string>(false, "")); } }
/// <summary> /// Register mappings to NS. /// </summary> public static String RegisterMappings() { try { NetClient.PostData(GlobalContext.URL_UploadMapping, new Dictionary <string, string> { { "token", MPController.CurrentTransaction.AuthToken }, { "rtid", GlobalContext.CurrentRTID }, { "organgid", GlobalContext.ResourcesCOrganGid }, { "dataversion", GlobalContext.ResourcesDataVersion }, { "map", MPController.GeneratePostMapStringOfMappings() } }, out var retStr); var response = JsonConvert.DeserializeObject <StdResponseEntity>(retStr); return(ReturnDataHelper.DecodeString(response)); } catch (Exception ex) { LogUtils.LogLine("Register mappings, exception occurred" + ex, "MPController", LogLevel.Error); return(null); } }