Showing posts with label Javascript SharePoint. Show all posts
Showing posts with label Javascript SharePoint. Show all posts

Wednesday, November 29, 2017

SQL Important Query

Select * from(
SELECT 0 as SORTCOLUMN, -1 AS [KEY], 'Select' AS [VALUE]
UNION all
SELECT 1 AS SORTCOLUMN, PARAMALLOWEDVALUEID AS [KEY], PARAMETERVALUE AS [VALUE]
FROM ICM_COMMPARAMALLOWDVALUE where PARAMETERID = 1 AND ISACTIVE = 1) tbl order by case when SORTCOLUMN=0 then 3 else 1 end,[value]

Controller.cs inside WebApi

namespace CSSI.VUE.Web.API.Controllers
{
public class ProducerEligibiltyController : ApiController
{

 

[CSSIScope("GET_PRODUCER_ELIGIBILITY")]
[HttpGet]
public ResponseMessageResult Get(
string ApplicationSignedDate,
string CarrierCode,
string LOB,
string SitusState,
string RequestType,
string AgentCode = null,
string WritingNumber = null,
string SolicitationState = null)
{
AgentDemographicResponse obj = null;
AgentDemographicRequest req = new AgentDemographicRequest();
MetLifeEncryptDecryptAES encryption = new MetLifeEncryptDecryptAES();

req.RequestType = RequestType;
req.AgentCode = AgentCode;
req.ApplicationSignedDate = DateTime.ParseExact(ApplicationSignedDate, "yyyy-MM-dd", CultureInfo.InvariantCulture);
req.CarrierCode = CarrierCode;
req.LOB = LOB;
req.SitusState = SitusState;
req.SolicitationState = SolicitationState;
req.WritingNumber = WritingNumber;

ICommonExtService service = ProxyHelper.GetCommonServiceProxy();
if (service != null)
{
obj = service.ProducerEligibility(req);
if (obj.ErrorMessage == "" || string.IsNullOrEmpty(obj.ErrorMessage))
{
if (obj.IsAgency == "1")
{
if (!string.IsNullOrEmpty(obj.TaxID))
{
obj.TaxID = encryption.Encrypt(WebHelper.Encryption(obj.TaxID, false));
}
}
else
{
if (!string.IsNullOrEmpty(obj.SSN))
{
obj.SSN = encryption.Encrypt(WebHelper.Encryption(obj.SSN, false));
}
}
}
}

//XElement xeAgentDemographicResponse = EntityHelper.XmlSerializeEntity(obj);
//return xeAgentDemographicResponse.ToString();
//if (obj.AgentCode == null)
//{
// obj.AgentCode = "";
//}

return ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ObjectContent<AgentDemographicResponse>(obj,
new System.Net.Http.Formatting.XmlMediaTypeFormatter
{
UseXmlSerializer = true
})

});

}}
}

Web Service Project Structure :-

  1. Entity Project Class file–>DLL

Agent.cs  File:-

#region usings

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using CSSI.Common.Utilities;
using CSSI.VUE.Common.Entities;
using CSSI.VUE.Custom.Entities;
using System.Web.Mvc;
using CSSI.VUE.Entities;

Tuesday, September 5, 2017

backup restore external content type and external list

1. Create ECT in SPD using Secure Store as Authentication

2. Configure in BCS as required

3. Export the ECT from SPD on Dev

4. Set up identical Secure Store on Test

5. Import BCS Model in Test

6. Set Permissions as required on ECT

7. Create list from ECT

backup restore external content type and external list 

Thursday, August 3, 2017

SharePoint: CAML Query not working based on WHERE clause

When we write the CAML query in SharePoint development and if we put WHERE clause in query it still returns all records.


For example look at the below query, it works fine in U2U builder but returns all records if we use the same in code.


SPQuery query = new SPQuery();
query.Query = "<Query><Where></Where></Query>"


Here is the Fix:

Remove the "<Query>" Tag and rewrite it

SPQuery query = new SPQuery();
query.Query = "<Where></Where>"

SharePoint: SPSecurity.RunWithElevatedPrivileges method

This is used to execute the specified method with Full Control rights even if the logged in user does not otherwise have Full Control.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    // Your code here...
});


Note:

1.The RunWithElevatedPrivileges method can not be used within a sandbox solution 

2.The item that is actioned with elevated privileges will be executed under the web applications App pool account in IIS, which means that the modified user of the document/list item will most likely display as SYSTEM ACCOUNT.

3.If you did not want to execute the code as the App Pool account for any reason, you could alternatively use a specific user account to execute the code under by implementing the SPUserToken class.