private string GetListTitle(CRMConfig crmconfig, string listTitle) { try { switch (listTitle) { case "account": return(crmconfig.SpAccountRoot); case "opportunity": return(crmconfig.SpOpportunityRoot); case "salesorder": return(crmconfig.SpOrderRoot); case "incident": return(crmconfig.SpIncidentRoot); case "quote": return(crmconfig.SpQuoteRoot); case "contract": return(crmconfig.SpContractRoot); } return(listTitle); } catch (Exception ex) { return(listTitle); } }
//private static string _ShowServerName = ""; //private static string _ShowDatabaseName = ""; #endregion #region | Construction | static ConnectionManager() { //JEC 11-11/2008 : just adding this static constructor fixed a problem where we were seeing the CRMAppConfig.SettingsCollection // being used above (in the static members) before it was initialized. It only happened in 'release' mode. I think it // had to do with optimization that is turned on in release mode that isn't on in debug mode. I think it changed the // timing for some of the events happing when the app starts up. _UseWindowsAuthentication = CRMConfig.GetConfigBoolean("UseWindowsAuthentication", true); _ServerName = CRMConfig.GetConfigString("DatabaseServer"); if (string.IsNullOrWhiteSpace(_ServerName)) { _ServerName = CRMConfig.GetConfigString("ExsEnterpriseDBServer"); } _DatabaseName = CRMConfig.GetConfigString("DatabaseName"); if (string.IsNullOrWhiteSpace(_DatabaseName)) { _DatabaseName = CRMConfig.GetConfigString("ExsEnterpriseDBName"); } _RegServerName = CRMConfig.GetConfigString("RegShowDBServer"); if (string.IsNullOrWhiteSpace(_RegServerName)) { _RegServerName = _ServerName; } }
/// <summary> /// /// </summary> /// <param name="service"></param> /// <param name="key"></param> /// <returns></returns> internal CRMConfig GetCRMConfig(IOrganizationService service) { try { var query = new QueryExpression("pp_signicatconfig"); query.ColumnSet = new ColumnSet("pp_spuser", "pp_sppassord", "pp_wordsignuser", "pp_spaccountroot", "pp_spquoteroot", "pp_spopportunityroot", "pp_spincidentroot", "pp_sporderroot", "pp_spcontractroot"); var results = service.RetrieveMultiple(query); if (results.Entities.Count == 1) { var entity = results.Entities[0]; var config = new CRMConfig(); config.SPUser = entity.GetAttributeValue <string>("pp_spuser"); config.SPpassword = entity.GetAttributeValue <string>("pp_sppassord"); config.SigningUser = entity.GetAttributeValue <EntityReference>("pp_wordsignuser"); var senderRef = service.Retrieve("systemuser", config.SigningUser.Id, new ColumnSet("fullname")); config.SigningUsername = senderRef.GetAttributeValue <string>("fullname"); //SP root folders config.SpAccountRoot = entity.GetAttributeValue <string>("pp_spaccountroot"); config.SpQuoteRoot = entity.GetAttributeValue <string>("pp_spquoteroot"); config.SpOpportunityRoot = entity.GetAttributeValue <string>("pp_spopportunityroot"); config.SpIncidentRoot = entity.GetAttributeValue <string>("pp_spincidentroot"); config.SpOrderRoot = entity.GetAttributeValue <string>("pp_sporderroot"); config.SpContractRoot = entity.GetAttributeValue <string>("pp_spcontractroot"); return(config); } return(null); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// /// </summary> /// <param name="listTitle"></param> /// <param name="web"></param> /// <param name="clientContext"></param> /// <param name="service"></param> /// <returns></returns> private List GetAccountList(string listTitle, Web web, ClientContext clientContext, CRMConfig crmconfig, IOrganizationService service) { try { List accountList; clientContext.Load(web.Lists, lists => lists.Include(list => list.Title).Where(list => list.Title == listTitle)); clientContext.ExecuteQuery(); if (web.Lists.Count > 0) { accountList = web.Lists.GetByTitle(listTitle); clientContext.Load(accountList); clientContext.ExecuteQuery(); } else { if (loop > 1) { return(null); } loop++; listTitle = GetListTitle(crmconfig, listTitle); accountList = GetAccountList(listTitle, web, clientContext, crmconfig, service); } return(accountList); } catch (Exception ex) { return(null); throw new Exception(ex.Message); } }
public void Execute() { SvcI = SvcBase.Service; //config = GetK2CRMConfig(SvcI.ServiceConfiguration.ServiceAuthentication.UserName, SvcI.ServiceConfiguration.ServiceAuthentication.Password, GetConfigPropertyValue("RESTServiceURL")); crmconfig = new CRMConfig { CRMURL = GetConfigPropertyValue("CRMURL"), CRMOrganization = GetConfigPropertyValue("CRMOrganization") }; if (!SvcI.ServiceConfiguration.ServiceAuthentication.Impersonate && !string.IsNullOrEmpty(SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Trim()) && !string.IsNullOrEmpty(SvcI.ServiceConfiguration.ServiceAuthentication.Password.Trim())) { // Static credentials if (SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Contains("\\")) { char[] sp = { '\\' }; string[] user = SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Split(sp); crmconfig.CRMDomain = user[0].Trim(); crmconfig.CRMUsername = user[1].Trim(); } else { crmconfig.CRMUsername = SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Trim(); } crmconfig.CRMPassword = SvcI.ServiceConfiguration.ServiceAuthentication.Password; } CRMFunctions = new Functions.CRMFunctions(crmconfig); ServiceObject so = SvcI.ServiceObjects[0]; string methodName = so.Methods[0].Name; switch (methodName.ToLower()) { case "changeowner": ChangeOwner(ref so); break; case "setstatestatus": SetStateStatus(ref so); break; case "getentities": GetEntities(ref so); break; case "bulkactiontasks": BulkActionTasks(ref so); break; case "createtask": CreateTask(ref so); break; case "getcrmuser": GetCRMUser(ref so); break; case "startcrmworkflow": StartCRMWorkflow(ref so); break; case "getentitymetadata": GetEntityMetadata(ref so); break; case "bulkactiontaskssetcriteria": BulkActionTasksSetCriteria(ref so); break; case "retrievemultiple": RetrieveMultiple(ref so); break; case "getallentities": GetAllEntities(ref so); break; case "getentityattributes": GetEntityAttributes(ref so); break; case "getpicklist": GetPicklist(ref so); break; case "getstatestatuspicklist": GetStateStatusPicklist(ref so); break; } }
public void Execute() { SvcI = SvcBase.Service; config = GetK2CRMConfig(SvcI.ServiceConfiguration.ServiceAuthentication.UserName, SvcI.ServiceConfiguration.ServiceAuthentication.Password, GetConfigPropertyValue("RESTServiceURL")); crmconfig = new CRMConfig { CRMURL = GetConfigPropertyValue("CRMURL"), CRMOrganization = GetConfigPropertyValue("CRMOrganization") }; ServiceObject so = SvcI.ServiceObjects[0]; string methodName = so.Methods[0].Name; switch (methodName.ToLower()) { case "changeowner": ChangeOwner(ref so); break; case "setstatestatus": SetStateStatus(ref so); break; case "getentities": GetEntities(ref so); break; case "bulkactiontasks": BulkActionTasks(ref so); break; case "createtask": CreateTask(ref so); break; case "getcrmuser": GetCRMUser(ref so); break; case "startcrmworkflow": StartCRMWorkflow(ref so); break; case "getentitymetadata": GetEntityMetadata(ref so); break; case "bulkactiontaskssetcriteria": BulkActionTasksSetCriteria(ref so); break; case "retrievemultiple": RetrieveMultiple(ref so); break; case "getallentities": GetAllEntities(ref so); break; case "getentityattributes": GetEntityAttributes(ref so); break; case "getpicklist": GetPicklist(ref so); break; case "getstatestatuspicklist": GetStateStatusPicklist(ref so); break; } }