private bool login() { try { //execute the login placing the results //in a LoginResult object LoginResult loginResult = client.login(USERNAME, PASSWORD); //set the session id header for subsequent calls sessionHeader = new SessionHeader(); sessionHeader.session = loginResult.Session; //reset the endpoint url to that returned from login // binding.Url = loginResult.ServerUrl; print("Session: " + loginResult.Session); print("ServerUrl: " + loginResult.ServerUrl); return true; } catch (Exception ex) { //Login failed, report message then return false Console.WriteLine("Login failed with message: " + ex.Message); return false; } }
public void CreateSession() { // Create the header. CurrentSessionHeader = new SessionHeader(Guid.NewGuid().ToString()); // From now on, all session data will be indexed under that key. Application[CurrentSessionHeader.SessionID] = new Hashtable(); }
/// <summary> /// Create a session summary packet from the provided session header /// </summary> /// <param name="sessionHeader"></param> public SessionSummaryPacket(SessionHeader sessionHeader) : base(sessionHeader.Id, true) { //Stuff that aligns with SESSION table in index m_ComputerId = sessionHeader.ComputerId.GetValueOrDefault(); Timestamp = sessionHeader.StartDateTime; m_EndDateTime = sessionHeader.EndDateTime; m_Caption = sessionHeader.Caption; m_TimeZoneCaption = sessionHeader.TimeZoneCaption; m_ProductName = sessionHeader.Product; m_ApplicationName = sessionHeader.Application; m_EnvironmentName = sessionHeader.Environment; m_PromotionLevelName = sessionHeader.PromotionLevel; m_ApplicationType = (ApplicationType)Enum.Parse(typeof(ApplicationType), sessionHeader.ApplicationTypeName, true); m_ApplicationDescription = sessionHeader.ApplicationDescription; m_ApplicationVersion = sessionHeader.ApplicationVersion; m_AgentVersion = sessionHeader.AgentVersion; m_UserName = sessionHeader.UserName; m_UserDomainName = sessionHeader.UserDomainName; m_HostName = sessionHeader.HostName; m_DnsDomainName = sessionHeader.DnsDomainName; //Stuff that aligns with SESSION_DETAILS table in index m_OSPlatformCode = sessionHeader.OSPlatformCode; m_OSVersion = sessionHeader.OSVersion; m_OSServicePack = sessionHeader.OSServicePack; m_OSCultureName = sessionHeader.OSCultureName; m_OSArchitecture = sessionHeader.OSArchitecture; m_OSBootMode = sessionHeader.OSBootMode; m_OSSuiteMaskCode = sessionHeader.OSSuiteMask; m_OSProductTypeCode = sessionHeader.OSProductType; m_RuntimeVersion = sessionHeader.RuntimeVersion; m_RuntimeArchitecture = sessionHeader.RuntimeArchitecture; m_CurrentCultureName = sessionHeader.CurrentCultureName; m_CurrentUICultureName = sessionHeader.CurrentUICultureName; m_MemoryMB = sessionHeader.MemoryMB; m_Processors = sessionHeader.Processors; m_ProcessorCores = sessionHeader.ProcessorCores; m_UserInteractive = sessionHeader.UserInteractive; m_TerminalServer = sessionHeader.TerminalServer; m_ScreenWidth = sessionHeader.ScreenWidth; m_ScreenHeight = sessionHeader.ScreenHeight; m_ColorDepth = sessionHeader.ColorDepth; m_CommandLine = sessionHeader.CommandLine; //and app.config properties. m_Properties = new Dictionary <string, string>(sessionHeader.Properties); //finally calculated value. CalculateFullyQualifiedUserName(); }
private bool login() { Console.Write("Enter username: "******"Enter password: "******"Enter SalesForce user key: "); password = password + Console.ReadLine(); // Create a SoapClient specifically for logging in loginClient = new SoapClient(); try { Console.WriteLine("\nLogging in..."); lr = loginClient.login(null, username, password); } catch (Exception e) { Console.WriteLine("An unexpected error has occurred: " + e.Message); Console.WriteLine(e.StackTrace); return(false); } // Check if the password has expired if (lr.passwordExpired) { Console.WriteLine("An error has occurred. Your password has expired."); return(false); } /** Once the client application has logged in successfully, it will use * the results of the login call to reset the endpoint of the service * to the virtual server instance that is servicing your organization */ // On successful login, cache session info and API endpoint info endpoint = new EndpointAddress(lr.serverUrl); /** The sample client application now has a cached EndpointAddress * that is pointing to the correct endpoint. Next, the sample client * application sets a persistent SOAP header that contains the * valid sessionId for our login credentials. To do this, the sample * client application creates a new SessionHeader object. Add the session * ID returned from the login to the session header */ header = new SessionHeader(); header.sessionId = lr.sessionId; // Create and cache an API endpoint client client = new SoapClient("Soap", endpoint); // Return true to indicate that we are logged in, pointed // at the right URL and have our security token in place. Console.SetCursorPosition(Console.CursorLeft + 13, Console.CursorTop - 1); Console.Write("OK"); return(true); }
/// <summary> /// Create a new file information tracking object /// </summary> public SessionFileInfo(SessionHeader sessionHeader, T fileInfo, bool isNew) { #if DEBUG Debug.Assert(sessionHeader != null); Debug.Assert(fileInfo != null); #endif m_SessionId = sessionHeader.Id; //this will be our best session header since it's the first m_SessionHeader = sessionHeader; m_SessionHeader.IsNew = isNew; m_SessionFragments.Add(sessionHeader.FileSequence, fileInfo); }
public void LookupHistoricSpot() { var origin = new Place { Item = SampleFactory.Origin }; var destination = new Place { Item = SampleFactory.Destination }; var request = new LookupHistoricSpotRatesRequest { lookupHistoricSpotRatesOperation = new LookupHistoricSpotRatesOperation { origin = origin, destination = destination, equipment = EquipmentCategory } }; /* pass a local variable as a "ref" parameter, rather than passing the field itself, so * the service won't modify what the field refers to */ CorrelationHeader correlationHeader = _correlationHeader; SessionHeader sessionHeader = _sessionHeader; WarningHeader warningHeader; LookupHistoricSpotRatesResponse lookupHistoricSpotRatesResponse; _client.LookupHistoricSpotRates(_applicationHeader, ref correlationHeader, ref sessionHeader, request, out warningHeader, out lookupHistoricSpotRatesResponse); if (lookupHistoricSpotRatesResponse != null) { Data item = lookupHistoricSpotRatesResponse.lookupHistoricSpotRatesResult.Item; var data = item as LookupHistoricSpotRatesSuccessData; if (data == null) { var serviceError = item as ServiceError; serviceError.Display(); } else { data.Display(); } } }
/// <summary> /// Attempt to load the session header from the specified file, returning null if it can't be loaded /// </summary> /// <param name="sessionFileNamePath">The full file name & path</param> /// <returns>The session header, or null if it can't be loaded</returns> private SessionHeader SafeGetSessionHeader(string sessionFileNamePath) { #if DEBUG if (m_LoggingEnabled) { Log.Write(LogMessageSeverity.Verbose, LogCategory, "Opening session file to read header", "Opening file {0}.", sessionFileNamePath); } #endif SessionHeader header = null; try { FileStream sourceFile = null; using (sourceFile = FileHelper.OpenFileStream(sessionFileNamePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)) { if (sourceFile == null) { if (m_LoggingEnabled) { Log.Write(LogMessageSeverity.Verbose, LogCategory, "Unable to open session file, it is probably locked", "While attempting to open the local session fragment at '{0}', probably because it is still being written to.", sessionFileNamePath); } } using (var sourceGlfFile = new GLFReader(sourceFile)) { if (sourceGlfFile.IsSessionStream) { header = sourceGlfFile.SessionHeader; } } } } catch (Exception ex) { if (m_LoggingEnabled) { Log.Write(LogMessageSeverity.Warning, LogWriteMode.Queued, ex, LogCategory, "Unexpected exception while attempting to load a session header", "While opening the file '{0}' an exception was thrown reading the session header. Since this routine is designed to not generate exceptions this may indicate a flaw in the logic of the routine.\r\nException: {1}\r\n", sessionFileNamePath, ex.Message); } } return(header); }
private void AddSessionHeaderToIndex(SessionHeader sessionHeader, ZipArchiveEntry sessionFragment) { lock (m_Lock) { SessionFileInfo <ZipArchiveEntry> sessionFileInfo; if (m_Sessions.TryGetValue(sessionHeader.Id, out sessionFileInfo)) { //add this file fragment to the existing session info sessionFileInfo.AddFragment(sessionHeader, sessionFragment, true); } else { //create a new session file info - this is the first we've seen this session. sessionFileInfo = new SessionFileInfo <ZipArchiveEntry>(sessionHeader, sessionFragment, true); m_Sessions.Add(sessionFileInfo.Id, sessionFileInfo); } } }
public static RoutingServiceClient RoutingServiceClient; // Object to handle the Routing Client Service from the Webservices // Login to RNA Webservice - Needs a Webservice valid user public static string[] Login() { try { // Build Application Information. The ClientApplicationIdentifier GUID is the application ID // for integration users and should not be changed ClientApplicationInfo AppInfo = new ClientApplicationInfo { ClientApplicationIdentifier = new Guid(ConfigurationManager.AppSettings["ClientApplicationIdentifier"]) }; // Call the Web Services LoginServiceClient loginServiceClient = new LoginServiceClient(); LoginResult loginResult = loginServiceClient.Login( ConfigurationManager.AppSettings["Login"], ConfigurationManager.AppSettings["Password"], new CultureOptions(), AppInfo); // Checks if the process returned a valid result if (loginResult == null) { throw new Exception("Login failed."); } else { // Stores the Webservice session header SessionHeader = new SessionHeader { SessionGuid = loginResult.UserSession.Guid }; // Enable the Query Client Service QueryServiceClient = new QueryServiceClient("BasicHttpBinding_IQueryService", loginResult.QueryServiceUrl); string[] r = new string[] { loginResult.User.EntityKey.ToString(), loginResult.User.EmailAddress.ToString() }; return(r); } } catch (Exception Ex) { throw new Exception(Ex.Message); } }
/// <summary> /// Callback for OpenAsync calls /// </summary> /// <param name="sender">should be this object</param> /// <param name="e">Event Args holding the login information from Salesforce</param> private void ls_restloginCompleted(object sender, loginCompletedEventArgs e) { LoginTime = DateTime.Now; Url = e.Result.serverUrl; SessionHeaderValue = new SessionHeader(); SessionHeaderValue.sessionId = e.Result.sessionId; SessionId = e.Result.sessionId; ServerUrl = e.Result.serverUrl; string[] pieces = ServerUrl.Split('/'); Version = pieces[pieces.Length - 2]; ApiEndPoint = new Uri(e.Result.serverUrl); baseUrl = "https://" + ApiEndPoint.Host; state = ConnectionState.Open; }
/// <summary> /// Create a new GLF reader to operate on the provided stream. The GLFReader then owns the stream and will dispose it /// when disposed itself. (Use static GLFReader.IsGLF() to test a stream without giving it up.) /// </summary> /// <param name="file"></param> public GLFReader(Stream file) { m_File = file; m_IsSessionStream = IsGLF(m_File, out m_FileHeader); if (m_IsSessionStream) { //it's a session - load the session header byte[] header = new byte[m_FileHeader.DataOffset - FileHeader.HeaderSize]; m_File.Position = FileHeader.HeaderSize; m_File.Read(header, 0, header.Length); m_File.Position = 0; m_SessionHeader = new SessionHeader(header); m_SessionHeader.HasData = true; //since we're on a file FragmentStorageSummary = new FragmentStorageSummary(m_SessionHeader.FileStartDateTime, m_SessionHeader.FileEndDateTime, file.Length); //BUG: Should now validate the CRC's before we accept it as a valid file } }
/// <summary> /// Add another fragment to this session's information /// </summary> /// <param name="sessionHeader"></param> /// <param name="fileInfo"></param> /// <param name="isNew"></param> public void AddFragment(SessionHeader sessionHeader, T fileInfo, bool isNew) { lock (m_SessionFragments) { //if a file got duplicated or copied for some reason (which can happen if someone is messing around in the log directory) //then we could get a duplicate item. We need to make sure we don't process that. if (!m_SessionFragments.ContainsKey(sessionHeader.FileSequence)) { //If this header is newer than our previous best it takes over (headers are cumulative) if (sessionHeader.FileSequence > m_SessionHeader.FileSequence) { sessionHeader.IsNew = m_SessionHeader.IsNew; //preserve our existing setting... m_SessionHeader = sessionHeader; } m_SessionHeader.IsNew = m_SessionHeader.IsNew || isNew; //if any are new, it's new. //and we add this file info to our set in its correct order. m_SessionFragments.Add(sessionHeader.FileSequence, fileInfo); } } }
public void UpdateAlarm(string alarmUrl) { var updateAlarmUrlRequest = new UpdateAlarmUrlRequest { updateAlarmUrlOperation = new UpdateAlarmUrlOperation { alarmUrl = alarmUrl } }; /* pass a local variable as a "ref" parameter, rather than passing the field itself, so * the service can't modify what the field refers to */ CorrelationHeader correlationHeader = _correlationHeader; SessionHeader sessionHeader = _sessionHeader; WarningHeader warningHeader; UpdateAlarmUrlResponse updateAlarmUrlResponse; _client.UpdateAlarmUrl(_applicationHeader, ref correlationHeader, ref sessionHeader, updateAlarmUrlRequest, out warningHeader, out updateAlarmUrlResponse); if (updateAlarmUrlResponse != null) { Data item = updateAlarmUrlResponse.updateAlarmUrlResult.Item; var data = item as UpdateAlarmUrlSuccessData; if (data == null) { var serviceError = item as ServiceError; serviceError.Display(); } else { data.Display(alarmUrl); } } }
/// <summary> /// Callback for OpenAsync calls /// </summary> /// <param name="sender">should be this object</param> /// <param name="e">Event Args holding the login information from Salesforce</param> private void ls_loginCompleted(object sender, loginCompletedEventArgs e) { LoginTime = DateTime.Now; Url = e.Result.serverUrl; SessionHeaderValue = new SessionHeader(); SessionHeaderValue.sessionId = e.Result.sessionId; SessionId = e.Result.sessionId; ServerUrl = e.Result.serverUrl; string[] pieces = ServerUrl.Split('/'); Version = pieces[pieces.Length - 2]; ApiEndPoint = new Uri(e.Result.serverUrl); state = ConnectionState.Open; if (customLoginCompleted != null) { customLoginCompleted(sender, e); } }
private void LookupDobCarriers(LookupDobCarriersRequest lookupDobCarriersRequest, string description, int indent) { /* pass a local variable as a "ref" parameter, rather than passing the field itself, so * the service can't modify what the field refers to */ CorrelationHeader correlationHeader = _correlationHeader; SessionHeader sessionHeader = _sessionHeader; WarningHeader warningHeader; LookupDobCarriersResponse lookupDobCarriersResponse; _client.LookupDobCarriers(_applicationHeader, ref correlationHeader, ref sessionHeader, lookupDobCarriersRequest, out warningHeader, out lookupDobCarriersResponse); if (indent == 0) { Console.WriteLine(description + ":"); } if (lookupDobCarriersResponse != null) { LookupDobCarriersResult result = lookupDobCarriersResponse.lookupDobCarriersResults; var data = result.Item as LookupDobCarriersSuccessData; if (data == null) { var serviceError = result.Item as ServiceError; serviceError.Display(); } else { data.Display(indent); } } }
/// <summary> /// Calls <see cref="TfmiFreightMatchingPortTypeClient.PostAsset" /> method and writes result to console. /// </summary> /// <param name="postAssetRequest"> </param> public void Post(PostAssetRequest postAssetRequest) { /* pass a local variable as a "ref" parameter, rather than passing the field itself, so * the service can't modify what the field refers to */ CorrelationHeader correlationHeader = _correlationHeader; SessionHeader sessionHeader = _sessionHeader; WarningHeader warningHeader; PostAssetResponse postAssetResponse; _client.PostAsset(_applicationHeader, ref correlationHeader, ref sessionHeader, postAssetRequest, out warningHeader, out postAssetResponse); Console.WriteLine("===============Post Results==============="); if (postAssetResponse != null) { foreach (PostAssetResult postAssetResult in postAssetResponse.postAssetResults) { var postAssetSuccessData = postAssetResult.Item as PostAssetSuccessData; if (postAssetSuccessData == null) { var serviceError = postAssetResult.Item as ServiceError; serviceError.Display(); } else { postAssetSuccessData.Display(); } } } }
/// <summary> /// Initialize the GLF writer for storing information about the current live session /// </summary> /// <param name="file">The file stream to write the session file into (should be empty)</param> /// <param name="sessionSummary"></param> /// <param name="fileSequence"></param> /// <param name="fileStartTime">Used during initial collection to indicate the real time this file became the active file.</param> /// <param name="majorVersion">Major version of the serialization protocol</param> /// <param name="minorVersion">Minor version of the serialization protocol</param> /// <remarks>The file header is configured with a copy of the session summary, assuming that we're about to make a copy of the /// session. For live data collection the caller should supply the file start time to reflect the true time period /// covered by this file. </remarks> public GLFWriter(Stream file, SessionSummary sessionSummary, int fileSequence, DateTimeOffset?fileStartTime, int majorVersion, int minorVersion) { //for use to use the stream, it has to support if (file.CanSeek == false) { throw new ArgumentException("Provided stream can't be used because it doesn't support seeking", nameof(file)); } m_SessionSummary = sessionSummary; m_OutputStream = file; // This logic will store GZip compressed files for protocol version 2 and beyond if (majorVersion > 1) { //we are explicitly *NOT* using the system GZipStream because it doesn't support flush. m_PacketStream = new GZipStream(m_OutputStream, CompressionMode.Compress, CompressionLevel.Default, true) { FlushMode = FlushType.Sync }; } else { m_PacketStream = new MemoryStream(BufferSize + MaxExpectedPacketSize); } m_PacketWriter = new PacketWriter(m_PacketStream, majorVersion, minorVersion); //initialize the stream with the file header and session header m_FileHeader = new FileHeader(majorVersion, minorVersion); m_SessionHeader = new SessionHeader(sessionSummary); //There are two variants of the GLF format: One for a whole session, one for a session fragment. if (fileStartTime.HasValue) { m_SessionHeader.FileId = Guid.NewGuid(); m_SessionHeader.FileSequence = fileSequence; m_SessionHeader.FileStartDateTime = fileStartTime.Value; m_SessionHeader.FileEndDateTime = m_SessionHeader.EndDateTime; //by default, this is the last file - it won't be if we open another. m_SessionHeader.IsLastFile = true; } //we need to know how big the session header will be (it's variable sized) before we can figure out the data offset. byte[] sessionHeader = m_SessionHeader.RawData(); //where are we going to start our data block? m_FileHeader.DataOffset = FileHeader.HeaderSize + sessionHeader.Length; byte[] header = m_FileHeader.RawData(); m_OutputStream.Position = 0; //move to the start of the stream, we rely on this. m_OutputStream.Write(header, 0, FileHeader.HeaderSize); m_OutputStream.Write(sessionHeader, 0, sessionHeader.Length); m_OutputStream.Flush(); m_OutputStream.Position = m_FileHeader.DataOffset; //so we are sure we start writing our data at the correct spot. // When we added GZip compression to streams we noticed that we were sometimes // losing a lot of data that went unflushed while programmers were testing in // Visual Studio. To address this, we have the GZip stream flush to disk much // more aggressively when we detect that the debugger is attached. #if !DEBUG // We only want this behavior for release builds, not for our own debug builds // we might prefer the writing to be the more typical optimized behavior. AutoFlush = Debugger.IsAttached; #endif }
public bool InsertDataintoSFDC(string userName, string password) { bool Result = false; var bllist = GetBillingInformation(); List <Customer> lstCus = new List <Customer>(); bool result = false; SoapClient ss = new SoapClient(); LoginResult lr = new LoginResult(); LoginScopeHeader LH = new LoginScopeHeader(); if (sessionId == null | sessionId == "") { lr = ss.login(null, userName, password); if (!lr.passwordExpired) { sessionId = lr.sessionId.ToString().Trim(); serverUrl = lr.serverUrl.ToString().Trim(); // Store SessionId in SessionHeader; We will need while making query() call SessionHeader sHeader = new SessionHeader(); sHeader.sessionId = sessionId; serverUrl = "https://abilitycentre--NEWACUAT.my.salesforce.com/services/Soap/c/51.0/00D5P0000008nfN"; // Variable to store query results QueryResult qr = new QueryResult(); SoapClient ss1 = new SoapClient(); //ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://abilitycentre--NEWACUAT.my.salesforce.com/services/data/v51.0/composite/tree/enrtcr__Support_Delivered__c/"); ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl); //foreach (var res in bllist) //{ enrtcr__Support_Delivered__c esdc = new enrtcr__Support_Delivered__c(); esdc.Batch_Created__c = true; esdc.enrtcr__Client__c = "0035P000003ws2OQAQ"; esdc.enrtcr__Date__c = Convert.ToDateTime("2021-03-30"); esdc.enrtcr__Quantity__c = 10; esdc.enrtcr__Support_Contract_Item__c = "a0n5P000000kHNgQAM"; esdc.enrtcr__Support_Contract__c = "a0o5P000000Bc9vQAC"; esdc.enrtcr__Site__c = "a0l5P000000046nQAA"; esdc.enrtcr__Support_CategoryId__c = "a0c5P000000Co8EQAS"; esdc.enrtcr__Site_Service_Program__c = "a0j5P000000dLBpQAM"; esdc.enrtcr__Rate__c = "a0b5P0000014SHkQAM"; esdc.enrtcr__Worker__c = "0057F000005AtbWQAS"; esdc.enrtcr__Client_Rep_Accepted__c = true; esdc.enrtcr__Use_Negotiated_Rate__c = true; esdc.enrtcr__Negotiated_Rate_Ex_GST__c = 0.85; esdc.enrtcr__Negotiated_Rate_GST__c = 0.00; LimitInfo[] limt; SaveResult[] createResults; try { ss.create(sHeader, null, null, null, null, null, null, null, null, null, null, null, new sObject[] { esdc }, out limt, out createResults); // CreateRecord(new HttpClient(), "New Record", "enrtcr__Support_Delivered__c", esdc); // Result = true; var results = createResults[0].success; } catch (Exception ex) { var exp = ex.ToString(); Result = false; } // } // } } return(Result); }
public bool IntegerateSfCustServiceLine(string userName, string password) { logger.Info("Scheduled Customer Service Line job triggered"); DBAction dba = new DBAction(_integrationAppSettings); string filterstring = dba.GetSalesforceInformation().Replace("\n", ""); bool result = false; List <CustomerServiceLine> ltsCusline = new List <CustomerServiceLine>(); SoapClient ss = new SoapClient(); LoginResult lr = new LoginResult(); LoginScopeHeader LH = new LoginScopeHeader(); if (sessionId == null | sessionId == "") { lr = ss.login(null, userName, password); if (!lr.passwordExpired) { sessionId = lr.sessionId.ToString().Trim(); serverUrl = lr.serverUrl.ToString().Trim(); } } // Store SessionId in SessionHeader; We will need while making query() call SessionHeader sHeader = new SessionHeader(); sHeader.sessionId = sessionId; // Variable to store query results QueryResult qr = new QueryResult(); SoapClient ss1 = new SoapClient(); ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl); var lastintegratedDate = dba.GetLastintegratedDateandTime("Last_CustomerLineIntegrate"); // if (lastintegratedDate == null) ss1.query(sHeader, null, null, null, @"SELECT Id ,Name ,enrtcr__Remaining__c ,enrtcr__Item_Overclaim__c ,enrtcr__Support_Contract__c ,enrtcr__Support_Contract__r.Name ,enrtcr__Support_Contract__r.enrtcr__End_Date__c ,enrtcr__Support_Contract__r.enrtcr__Status__c ,enrtcr__Support_Contract__r.enrtcr__Funding_Type__c ,enrtcr__Support_Contract__r.enrtcr__Funding_Management__c ,enrtcr__Support_Contract__r.enrtcr__Client__c ,enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c ,enrtcr__Category_Item__r.enrtcr__Delivered__c ,enrtcr__Site__c ,enrtcr__Site__r.Name ,enrtcr__Site__r.enrtcr__Site_GL_Code__c ,enrtcr__Service__c ,enrtcr__Service__r.Name ,enrtcr__Site_Service_Program__c ,enrtcr__Rate__c ,enrtcr__Rate__r.Name ,enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c ,enrtcr__Rate__r.enrtcr__Quantity_Type__c ,enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c FROM enrtcr__Support_Contract_Item__c WHERE(" + filterstring + ") AND enrtcr__Support_Contract__r.enrtcr__Status__c = 'Current' ", out qr); //else //{ // var UTCTime = Convert.ToDateTime(lastintegratedDate).ToString("yyyy-MM-dd") + "T" + Convert.ToDateTime(lastintegratedDate).ToString("HH:mm:ss") + "Z"; // ss1.query(sHeader, null, null, null, @"SELECT Id // ,Name // ,enrtcr__Remaining__c // ,enrtcr__Item_Overclaim__c // ,enrtcr__Support_Contract__c // ,enrtcr__Support_Contract__r.Name // ,enrtcr__Support_Contract__r.enrtcr__End_Date__c // ,enrtcr__Support_Contract__r.enrtcr__Status__c // ,enrtcr__Support_Contract__r.enrtcr__Funding_Type__c // ,enrtcr__Support_Contract__r.enrtcr__Funding_Management__c // ,enrtcr__Support_Contract__r.enrtcr__Client__c // ,enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c // ,enrtcr__Category_Item__r.enrtcr__Delivered__c // ,enrtcr__Site__c // ,enrtcr__Site__r.Name // ,enrtcr__Site__r.enrtcr__Site_GL_Code__c // ,enrtcr__Service__c // ,enrtcr__Service__r.Name // ,enrtcr__Site_Service_Program__c // ,enrtcr__Rate__c // ,enrtcr__Rate__r.Name // ,enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c // ,enrtcr__Rate__r.enrtcr__Quantity_Type__c // ,enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c,LastModifiedDate // FROM enrtcr__Support_Contract_Item__c // WHERE(" + filterstring + ") AND enrtcr__Support_Contract__r.enrtcr__Status__c = 'Current' and LastModifiedDate > YESTERDAY", out qr); //} sObject[] records = qr.records; if (records != null) { if (records.Length > 0) { for (var i = 0; i <= records.Length - 1; i++) { CustomerServiceLine csl = new CustomerServiceLine(); var customerId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Client__c; csl.ServiceAgreementCustomerId = dba.GetCustomerId(customerId); csl.ServiceAgreementId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__c;; csl.ServiceAgreementName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.Name; csl.ServiceAgreementEndDate = Convert.ToDateTime(((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__End_Date__c); if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Current") { csl.ServiceAgreementStatus = (int)CustomerStatus.Current; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Expired") { csl.ServiceAgreementStatus = (int)CustomerStatus.Expired; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Rollover") { csl.ServiceAgreementStatus = (int)CustomerStatus.Rollover; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Cancelled") { csl.ServiceAgreementStatus = (int)CustomerStatus.Cancelled; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Quote Submitted") { csl.ServiceAgreementStatus = (int)CustomerStatus.QuoteSubmitted; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c == "Client Declined") { csl.ServiceAgreementStatus = (int)CustomerStatus.ClientDeclined; } csl.ServiceAgreementFundingManagement = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Management__c; csl.ServiceAgreementFundingType = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Type__c; csl.ServiceAgreementItemId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Id; csl.ServiceAgreementItemName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Name; csl.SupportCategoryAmount = (float)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c; csl.SupportCategoryDelivered = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Delivered__c; csl.FundsRemaining = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Remaining__c; if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Allow") { csl.ItemOverclaim = (int)ItemOverClaim.Allow; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Warn") { csl.ItemOverclaim = (int)ItemOverClaim.Warn; } if (((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c == "Prevent") { csl.ItemOverclaim = (int)ItemOverClaim.Prevent; } csl.SiteId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__c; csl.SiteName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__r.Name; // csl.SiteGlCode = ""; csl.SiteServiceProgramId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site_Service_Program__c; csl.ServiceId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__c; csl.ServiceName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__r.Name; csl.RateId = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__c; csl.RateName = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.Name; csl.RateAmount = (float?)((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c; csl.RateType = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Quantity_Type__c; csl.AllowRateNegotiation = Convert.ToBoolean(((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c == null ? false : true); csl.Default = false; ltsCusline.Add(csl); } //Insert record to Database dba.IntegrateCustomerLineinfointoDB(ltsCusline); } result = true; } return(result); }
public bool IntegerateSfCustomeList(string userName, string password) { logger.Info("Scheduled Customer List job triggered"); List <Customer> lstCus = new List <Customer>(); bool result = false; SoapClient ss = new SoapClient(); LoginResult lr = new LoginResult(); LoginScopeHeader LH = new LoginScopeHeader(); DBAction dba = new DBAction(_integrationAppSettings); var lastintegratedDate = dba.GetLastintegratedDateandTime("Last_CustomerIntegrate"); if (sessionId == null | sessionId == "") { lr = ss.login(null, userName, password); if (!lr.passwordExpired) { sessionId = lr.sessionId.ToString().Trim(); serverUrl = lr.serverUrl.ToString().Trim(); // Store SessionId in SessionHeader; We will need while making query() call SessionHeader sHeader = new SessionHeader(); sHeader.sessionId = sessionId; // Variable to store query results QueryResult qr = new QueryResult(); SoapClient ss1 = new SoapClient(); ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl); // if (lastintegratedDate == null) ss1.query(sHeader, null, null, null, @"SELECT Id,Name,OtherStreet,OtherCity,OtherState,OtherPostalCode,RecordType.Name,Enrite_Care_Auto_Number__c,enrtcr__Status__c,LastModifiedDate FROM Contact WHERE RecordType.Name = 'Client' AND (enrtcr__Status__c='Current' OR enrtcr__Status__c='Deceased' OR enrtcr__Status__c='Inactive')", out qr); //else //{ // var UTCDate = Convert.ToDateTime(lastintegratedDate); // var UTCTime = UTCDate.ToString("yyyy-MM-dd") + "T" + UTCDate.ToString("HH:mm:ss") + "Z"; // ss1.query(sHeader, null, null, null, @"SELECT Id,Name,OtherStreet,OtherCity,OtherState,OtherPostalCode,RecordType.Name,Enrite_Care_Auto_Number__c,enrtcr__Status__c,LastModifiedDate FROM Contact WHERE RecordType.Name = 'Client' // AND (enrtcr__Status__c='Current' OR enrtcr__Status__c='Deceased' OR enrtcr__Status__c='Inactive') and LastModifiedDate >YESTERDAY", out qr); //} sObject[] records = qr.records; if (records != null) { if (records.Length > 0) { for (var i = 0; i <= records.Length - 1; i++) { Customer cs = new Customer(); cs.CustomerId = ((SfServiceRef.Contact)qr.records[i]).Id; cs.Name = ((SfServiceRef.Contact)qr.records[i]).Name; cs.Street = ((SfServiceRef.Contact)qr.records[i]).OtherStreet; cs.City = ((SfServiceRef.Contact)qr.records[i]).OtherCity; cs.State = ((SfServiceRef.Contact)qr.records[i]).OtherState; cs.PostalCode = ((SfServiceRef.Contact)qr.records[i]).OtherPostalCode; cs.LumaryId = ((SfServiceRef.Contact)qr.records[i]).Enrite_Care_Auto_Number__c; if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c != null) { cs.Active = false; if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Current") { cs.Status = 1; } if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Deceased") { cs.Status = 2; } if (((SfServiceRef.Contact)qr.records[i]).enrtcr__Status__c == "Inactive") { cs.Status = 3; } } cs.Active = true; cs.OnHold = false; lstCus.Add(cs); } } dba.IntegrateCustomerInfotoDB(lstCus); } } result = true; } return(result); }
//[Route("IntegerateSfCustomeList")] public ClsCustomerListResponse IntegerateSfCustomeList(ClsCusIntegRequest ObjRequest) { ClsCustomerListResponse ObjResponse = new ClsCustomerListResponse(); List <ClsListofCustomers> LstRes = new List <ClsListofCustomers>(); try { //ObjRequest.LoginUserName = "******"; //ObjRequest.LoginPassword = "******" + "6ohQKoPPG99OP0u8SalTFy8E"; SoapClient ss = new SoapClient(); LoginResult lr = new LoginResult(); LoginScopeHeader LH = new LoginScopeHeader(); if (sessionId == null | sessionId == "") { // Login Call lr = ss.login(null, ObjRequest.LoginUserName, ObjRequest.LoginPassword); if (lr.passwordExpired) { ObjResponse.StatusID = 300; ObjResponse.StatusDescription = "Password Expired"; // ObjResponse.Response = null; return(ObjResponse); } sessionId = lr.sessionId.ToString().Trim(); serverUrl = lr.serverUrl.ToString().Trim(); } // Store SessionId in SessionHeader; We will need while making query() call SessionHeader sHeader = new SessionHeader(); sHeader.sessionId = sessionId; // Variable to store query results QueryResult qr = new QueryResult(); SoapClient ss1 = new SoapClient(); ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl); ss1.query(sHeader, null, null, null, @"SELECT Id,Name,OtherStreet,OtherCity,OtherState,OtherPostalCode,RecordType.Name FROM Contact WHERE RecordType.Name = 'Client' AND (enrtcr__Status__c='Current' OR enrtcr__Status__c='Deceased' OR enrtcr__Status__c='Inactive')", out qr); sObject[] records = qr.records; if (records != null) { if (records.Length > 0) { for (var i = 0; i <= records.Length - 1; i++) { ClsListofCustomers Res = new ClsListofCustomers(); Res.Id = ((SfServiceRef.Contact)qr.records[i]).Id; Res.Name = ((SfServiceRef.Contact)qr.records[i]).Name; Res.OtherStreet = ((SfServiceRef.Contact)qr.records[i]).OtherStreet; Res.OtherCity = ((SfServiceRef.Contact)qr.records[i]).OtherCity; Res.OtherStreet = ((SfServiceRef.Contact)qr.records[i]).OtherState; Res.OtherPostalCode = ((SfServiceRef.Contact)qr.records[i]).OtherPostalCode; Res.RecordTypeName = ((SfServiceRef.Contact)qr.records[i]).RecordType.Name; LstRes.Add(Res); } ObjResponse.StatusID = 200; ObjResponse.StatusDescription = "Success"; ObjResponse.ObjLstCutomers = LstRes; } else { ObjResponse.StatusID = 202; ObjResponse.StatusDescription = "Unable to find client"; } } else { ObjResponse.StatusID = 201; ObjResponse.StatusDescription = "User not found"; } //string JS = JsonConvert.SerializeObject(records); //Interaction.MsgBox("Success"); // ObjResponse.Response = records; return(ObjResponse); } catch (Exception ex) { ObjResponse.StatusID = 500; ObjResponse.StatusDescription = ex.Message.ToString(); //ObjResponse.Response = null; return(ObjResponse); } }
public AirAllocateWrapper(SessionHeader sessionHeader, AllocateItem[] allocateItems) { SessionHeader = sessionHeader; AllocateItems = allocateItems; }
private async Task LoginAsync() { if (ConnectionParameter == null) { throw new NotSupportedException($"{nameof(SfdcConnectionParameter)} can't be null"); } if (string.IsNullOrWhiteSpace(ConnectionParameter.UserName)) { throw new NotSupportedException($"{nameof(SfdcConnectionParameter)}.UserName can't be null"); } if (string.IsNullOrWhiteSpace(ConnectionParameter.Password)) { throw new NotSupportedException($"{nameof(SfdcConnectionParameter)}.Password can't be null"); } if (string.IsNullOrWhiteSpace(ConnectionParameter.Token)) { throw new NotSupportedException($"{nameof(SfdcConnectionParameter)}.Token can't be null"); } if (string.IsNullOrWhiteSpace(ConnectionParameter.Endpoint)) { throw new NotSupportedException($"{nameof(SfdcConnectionParameter)}.Endpoint can't be null"); } // configure SoapClient for login EndpointAddress loginEndpoint = new EndpointAddress(ConnectionParameter.Endpoint); SoapClient loginClient = new SoapClient(_binding, loginEndpoint); // try login to Sfdc loginResponse loginResponse; try { Logger.LogInfo("Login to Sfdc"); loginResponse = await loginClient.loginAsync(null, null, ConnectionParameter.UserName, ConnectionParameter.ApiPassword); } catch (Exception e) { throw new Exception("Failed login to Sfdc", e); } // check is password expired if (loginResponse.result.passwordExpired) { throw new Exception("Sfdc password expired"); } // save session id _sessionHeader = new SessionHeader { sessionId = loginResponse.result.sessionId }; // set SoapClient for Api interaction EndpointAddress endpoint = new EndpointAddress(loginResponse.result.serverUrl); _soapClient = new SoapClient(_binding, endpoint); Logger.LogInfo("Success login to Sfdc"); }
public async override Task <ActionResponse> ExecuteActionAsync(ActionRequest request) { string objects = request.DataStore.GetValue("ObjectTables"); string sfUsername = request.DataStore.GetValue("SalesforceUser"); string sfPassword = request.DataStore.GetValue("SalesforcePassword"); string sfToken = request.DataStore.GetValue("SalesforceToken"); string sfTestUrl = request.DataStore.GetValue("SalesforceUrl"); List <string> sfObjects = objects.Split(',').ToList(); Dictionary <string, int> initialCounts = new Dictionary <string, int>(); SoapClient binding = new SoapClient("Soap"); if (!string.IsNullOrEmpty(sfTestUrl) && sfTestUrl.Contains("test")) { binding.Endpoint.Address = new System.ServiceModel.EndpointAddress(binding.Endpoint.Address.ToString().Replace("login", "test")); } LoginResult lr; SecurityHelper.SetTls12(); binding.ClientCredentials.UserName.UserName = sfUsername; binding.ClientCredentials.UserName.Password = sfPassword; lr = binding.login(null, null, sfUsername, string.Concat(sfPassword, sfToken)); binding = new SoapClient("Soap"); SessionHeader sheader = new SessionHeader(); BasicHttpBinding bind = new BasicHttpBinding(); bind = (BasicHttpBinding)binding.Endpoint.Binding; bind.MaxReceivedMessageSize = int.MaxValue; bind.MaxBufferPoolSize = int.MaxValue; bind.MaxBufferSize = int.MaxValue; bind.CloseTimeout = new TimeSpan(0, 0, 5, 0); bind.OpenTimeout = new TimeSpan(0, 0, 5, 0); bind.SendTimeout = new TimeSpan(0, 0, 5, 0); bind.ReaderQuotas.MaxArrayLength = int.MaxValue; bind.ReaderQuotas.MaxDepth = int.MaxValue; bind.ReaderQuotas.MaxNameTableCharCount = int.MaxValue; bind.ReaderQuotas.MaxStringContentLength = int.MaxValue; bind.ReaderQuotas.MaxBytesPerRead = int.MaxValue; bind.ReaderQuotas.MaxNameTableCharCount = int.MaxValue; binding.Endpoint.Binding = bind; binding.Endpoint.Address = new EndpointAddress(lr.serverUrl); sheader.sessionId = lr.sessionId; binding.Endpoint.ListenUri = new Uri(lr.metadataServerUrl); foreach (var obj in sfObjects) { QueryResult result; binding.query(sheader, null, null, null, null, $"SELECT COUNT() FROM {obj} " + $"WHERE LastModifiedDate > {DateTime.UtcNow.AddYears(-3).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)} " + $"AND LastModifiedDate <= {DateTime.UtcNow.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)}", out result); initialCounts.Add(obj.ToLower(), result.size); } request.DataStore.AddToDataStore("InitialCounts", JsonUtility.GetJObjectFromObject(initialCounts)); return(new ActionResponse(ActionStatus.Success)); }
/// <summary> /// Create a new session header message without any clock drift /// </summary> /// <param name="sessionHeader"></param> public SessionHeaderMessage(SessionHeader sessionHeader) : this(sessionHeader, TimeSpan.Zero) { }
public GetShoppingCartWrapper(SessionHeader sessionHeader, string shoppingCartId) { SessionHeader = sessionHeader; ShoppingCartId = shoppingCartId; }
public FinalizeShoppingWrapper(SessionHeader sessionHeader, string shoppingCartId) { SessionHeader = sessionHeader; ShoppingCartId = shoppingCartId; }
public BillingSubmitWrapper(SessionHeader sessionHeader, string shoppingCartId, BillingInformation billingInformation) { SessionHeader = sessionHeader; ShoppingCartId = shoppingCartId; BillingInformation = billingInformation; }
//[Route("IntegerateSfCustomeList")] public ClsCustomerServiceLineResponse IntegerateSfCustServiceLine(ClsCusServiceLineIntegRequest ObjRequest) { ClsCustomerServiceLineResponse ObjResponse = new ClsCustomerServiceLineResponse(); List <ClsListofCustServiceLine> LstRes = new List <ClsListofCustServiceLine>(); try { //ObjRequest.LoginUserName = "******"; //ObjRequest.LoginPassword = "******" + "6ohQKoPPG99OP0u8SalTFy8E"; SoapClient ss = new SoapClient(); LoginResult lr = new LoginResult(); LoginScopeHeader LH = new LoginScopeHeader(); if (sessionId == null | sessionId == "") { // Login Call lr = ss.login(null, ObjRequest.LoginUserName, ObjRequest.LoginPassword); if (lr.passwordExpired) { ObjResponse.StatusID = 300; ObjResponse.StatusDescription = "Password Expired"; return(ObjResponse); } sessionId = lr.sessionId.ToString().Trim(); serverUrl = lr.serverUrl.ToString().Trim(); } // Store SessionId in SessionHeader; We will need while making query() call SessionHeader sHeader = new SessionHeader(); sHeader.sessionId = sessionId; // Variable to store query results QueryResult qr = new QueryResult(); SoapClient ss1 = new SoapClient(); ss1.ChannelFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(serverUrl); ss1.query(sHeader, null, null, null, @"SELECT Id ,Name ,enrtcr__Remaining__c ,enrtcr__Item_Overclaim__c ,enrtcr__Support_Contract__c ,enrtcr__Support_Contract__r.Name ,enrtcr__Support_Contract__r.enrtcr__End_Date__c ,enrtcr__Support_Contract__r.enrtcr__Status__c ,enrtcr__Support_Contract__r.enrtcr__Funding_Type__c ,enrtcr__Support_Contract__r.enrtcr__Funding_Management__c ,enrtcr__Support_Contract__r.enrtcr__Client__c ,enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c ,enrtcr__Category_Item__r.enrtcr__Delivered__c ,enrtcr__Site__c ,enrtcr__Site__r.Name ,enrtcr__Site__r.enrtcr__Site_GL_Code__c ,enrtcr__Service__c ,enrtcr__Service__r.Name ,enrtcr__Site_Service_Program__c ,enrtcr__Rate__c ,enrtcr__Rate__r.Name ,enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c ,enrtcr__Rate__r.enrtcr__Quantity_Type__c ,enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c FROM enrtcr__Support_Contract_Item__c WHERE ( (enrtcr__Service__c = 'a0h5P0000004KmMQAU' AND enrtcr__Rate__r.enrtcr__Quantity_Type__c = 'Annual') OR (enrtcr__Service__c = 'a0h5P0000005n8GQAQ' AND enrtcr__Rate__r.enrtcr__Quantity_Type__c = 'Each') OR (enrtcr__Service__c = 'a0h5P0000004L35QAE' AND enrtcr__Rate__r.enrtcr__Quantity_Type__c = 'Hour') ) ", out qr); sObject[] records = qr.records; if (records != null) { if (records.Length > 0) { for (var i = 0; i <= records.Length - 1; i++) { ClsListofCustServiceLine Res = new ClsListofCustServiceLine(); Res.Id = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Id; Res.Name = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).Name; Res.enrtcr__remaining__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Remaining__c; Res.enrtcr__Item_Overclaim__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Item_Overclaim__c; Res.enrtcr__Support_Contract__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__c; Res.enrtcr__Support_Contract__r_Name = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.Name; Res.enrtcr__Support_Contract__r_enrtcr__End_Date__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__End_Date__c; Res.enrtcr__Support_Contract__r_enrtcr__Status__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Status__c; Res.enrtcr__Support_Contract__r_enrtcr__Funding_Type__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Type__c; Res.enrtcr__Support_Contract__r_enrtcr__Funding_Management__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Funding_Management__c; Res.enrtcr__Support_Contract__r_enrtcr__Client__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Support_Contract__r.enrtcr__Client__c; Res.enrtcr__Category_Item__r_enrtcr__Support_Category_Amount__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Support_Category_Amount__c; Res.enrtcr__Category_Item__r_enrtcr__Delivered__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Category_Item__r.enrtcr__Delivered__c; Res.enrtcr__Site__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__c; Res.enrtcr__Site__r_Name = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__r.Name; Res.enrtcr__Site__r_enrtcr__Site_GL_Code__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site__r.enrtcr__Site_GL_Code__c; Res.enrtcr__Service__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__c; Res.enrtcr__Service__r_Name = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Service__r.Name; Res.enrtcr__Site_Service_Program__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Site_Service_Program__c; Res.enrtcr__Rate__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__c; Res.enrtcr__Rate__r_Name = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.Name; Res.enrtcr__Rate__r_enrtcr__Amount_Ex_GST__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Amount_Ex_GST__c; Res.enrtcr__Rate__r_enrtcr__Quantity_Type__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Quantity_Type__c; Res.enrtcr__Rate__r_enrtcr__Allow_Rate_Negotiation__c = ((SfServiceRef.enrtcr__Support_Contract_Item__c)qr.records[i]).enrtcr__Rate__r.enrtcr__Allow_Rate_Negotiation__c; LstRes.Add(Res); } ObjResponse.StatusID = 200; ObjResponse.StatusDescription = "Success"; ObjResponse.ObjLstCutomers = LstRes; } else { ObjResponse.StatusID = 202; ObjResponse.StatusDescription = "Query executed successfully with no records returned"; } } else { ObjResponse.StatusID = 201; ObjResponse.StatusDescription = "Query executed successfully with null result"; } return(ObjResponse); } catch (Exception ex) { ObjResponse.StatusID = 500; ObjResponse.StatusDescription = ex.Message.ToString(); return(ObjResponse); } }
/// <remarks/> public NamedFieldTemplateManagerService(string ipAddr, int port, string sessionId) { this.Url = "http://" + ipAddr + ":" + port + "/ProjectServer/services/NamedFieldTemplateManager"; sessionHeader = new SessionHeader(); sessionHeader.SessionID = sessionId; }
private static void loginToSF(string userName, string password) { try { if (sforceSvc == null) { sforceSvc = new SforceService(); } loginResult = sforceSvc.login(userName, password); if (loginResult != null) { sforceSvc.Url = loginResult.serverUrl; SessionHeader sessionHeader = new SessionHeader(); sessionHeader.sessionId = loginResult.sessionId; sforceSvc.SessionHeaderValue = sessionHeader; } } catch (Exception ex) { Console.WriteLine("Error logging in to Salesforce.com Error: {0}\nInnerException: {1}", ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty); } }
/// <remarks/> public EventLogManagerService(string ipAddr, int port, string sessionId) { this.Url = "http://" + ipAddr + ":" + port + "/ProjectServer/services/EventLogManager"; sessionHeader = new SessionHeader(); sessionHeader.SessionID = sessionId; }
private bool login() { string username = "******"; string password = "******"; // Create a SoapClient specifically for logging in TimeSpan ts = new TimeSpan(50000000000); loginClient = new SoapClient("https://login.salesforce.com/services/Soap/c/45.0", ts, username, password); // (combine pw and token if necessary) LoginResult lr; try { Console.WriteLine("\nLogging in...\n"); System.Threading.Tasks.Task <sfservice.loginResponse> t = loginClient.loginAsync(null, username, password); t.Wait(); lr = t.Result.result; } catch (Exception e) { // Write the fault message to the console Console.WriteLine("An unexpected error has occurred: " + e.Message); // Write the stack trace to the console Console.WriteLine(e.StackTrace); return(false); } // Check if the password has expired if (lr.passwordExpired) { Console.WriteLine("An error has occurred. Your password has expired."); return(false); } /** Once the client application has logged in successfully, it will use * the results of the login call to reset the endpoint of the service * to the virtual server instance that is servicing your organization */ // On successful login, cache session info and API endpoint info endpoint = new EndpointAddress(lr.serverUrl); /** The sample client application now has a cached EndpointAddress * that is pointing to the correct endpoint. Next, the sample client * application sets a persistent SOAP header that contains the * valid sessionId for our login credentials. To do this, the sample * client application creates a new SessionHeader object. Add the session * ID returned from the login to the session header */ header = new SessionHeader(); header.sessionId = lr.sessionId; // Create and cache an API endpoint client client = new SoapClient(lr.serverUrl, ts, username, password); printUserInfo(lr, lr.serverUrl); // Return true to indicate that we are logged in, pointed // at the right URL and have our security token in place. return(true); }