protected override bool Execute(CodeActivityContext context) { //Login не возвращает ID пока пишем в user_ID логин и ставим галку string user_ID = User_ID.Get(context); string eventSting = EventString.Get(context); byte applicationType = ApplicationType.Get(context); string commentString = CommentString.Get(context); string parentObjectID = ParentObjectID.Get(context); string parentObjectName = ParentObjectName.Get(context); string objectID = ObjectID.Get(context); string bjectName = ObjectName.Get(context); byte eventType = EventType.Get(context); try { DeclaratorService.Insert_ExplUserJournal(user_ID, eventSting, commentString, applicationType, 0, eventType, bjectName, objectID, parentObjectName, parentObjectID, true); } catch (Exception ex) { Error.Set(context, ex.Message); } return(string.IsNullOrEmpty(Error.Get(context))); }
protected override void Execute(NativeActivityContext context) { try { string strAppId = ApplicationId.Get(context); string strSafe = Safe.Get(context); string strObjectName = ObjectName.Get(context); PSDKPasswordRequest passRequest = new PSDKPasswordRequest(); PSDKPassword psdkpassword; passRequest.AppID = strAppId; // "RESTExamples"; passRequest.Safe = strSafe; // "T-APP-CYBR-RESTAPI"; passRequest.Object = strObjectName; //"Database-MicrosoftSQLServer-JG-sql01.joe-garcia.local-Svc_BambooHR"; // Set required properties to be returned other than password passRequest.RequiredProperties.Add("PolicyId"); passRequest.RequiredProperties.Add("UserName"); passRequest.RequiredProperties.Add("Address"); // Sending the request to get the password psdkpassword = PasswordSDK.GetPassword(passRequest); string username = psdkpassword.UserName; string textPwd = psdkpassword.Content; if (!string.IsNullOrEmpty(username)) { UserName.Set(context, username); } else { Logger.Log.Logger.LogData("User name is null or empty in activity FetchSecurePassword", Logger.LogLevel.Info); } if (!string.IsNullOrEmpty(textPwd)) { SecureString strpwd = ToSecureString(textPwd); if (strpwd != null) { Password.Set(context, strpwd); } } else { Logger.Log.Logger.LogData("Password is null or empty in activity FetchSecurePassword", Logger.LogLevel.Info); } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity FetchSecurePassword", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(CodeActivityContext context) { { System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string userName; string password; userName = Username.Get(context); //username from context password = Password.Get(context) + SecurityToken.Get(context); //password+token from context SforceService SfdcBinding = null; LoginResult CurrentLoginResult = null; SfdcBinding = new SforceService(); try { CurrentLoginResult = SfdcBinding.login(userName, password); } catch (System.Web.Services.Protocols.SoapException e) { // This is likley to be caused by bad username or password SfdcBinding = null; throw (e); } catch (Exception e) { // This is something else, probably comminication SfdcBinding = null; throw (e); } //Change the binding to the new endpoint SfdcBinding.Url = CurrentLoginResult.serverUrl; //Console.WriteLine(SfdcBinding.Url); //Console.ReadLine(); //Create a new session header object and set the session id to that returned by the login SfdcBinding.SessionHeaderValue = new SessionHeader(); SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; String[] fieldNames = FieldNames.Get(context); String[] fieldValues = FieldValues.Get(context); sObject obj = new sObject(); System.Xml.XmlElement[] objFields = new System.Xml.XmlElement[fieldNames.Length]; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); for (int i = 0; i < fieldNames.Length; i++) { objFields[i] = doc.CreateElement(fieldNames[i]); } for (int j = 0; j < fieldValues.Length; j++) { objFields[j].InnerText = fieldValues[j]; } obj.type = ObjectName.Get(context); obj.Any = objFields; sObject[] objList = new sObject[1]; objList[0] = obj; SaveResult[] results = SfdcBinding.create(objList); for (int j = 0; j < results.Length; j++) { if (results[j].success) { RecordID.Set(context, results[j].id); } else { // There were errors during the create call, // go through the errors array and write // them to the console String error; for (int i = 0; i < results[j].errors.Length; i++) { Error err = results[j].errors[i]; error = "Errors was found on item " + j.ToString() + Environment.NewLine + "Error code is: " + err.statusCode.ToString() + Environment.NewLine + "Error message: " + err.message; RecordID.Set(context, error); } } } } }