/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; string text = pText.Get<string>(executionContext); string existingValue = pExistingValue.Get<string>(executionContext); var newValue = pNewValue.Get<string>(executionContext); if (newValue == null) newValue = String.Empty; var result = string.Empty; if (!pCaseSensitive.Get<bool>(executionContext)) { if (!String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(existingValue)) { result = text.Replace(existingValue, newValue); } } else { var regex = new Regex(existingValue, RegexOptions.IgnoreCase); result = regex.Replace(text, newValue); } pResult.Set(executionContext, result); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; string text = pText.Get <string>(executionContext); string existingValue = pExistingValue.Get <string>(executionContext); var newValue = pNewValue.Get <string>(executionContext); if (newValue == null) { newValue = String.Empty; } var result = string.Empty; if (!pCaseSensitive.Get <bool>(executionContext)) { if (!String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(existingValue)) { result = text.Replace(existingValue, newValue); } } else { var regex = new Regex(existingValue, RegexOptions.IgnoreCase); result = regex.Replace(text, newValue); } pResult.Set(executionContext, result); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; string result = PerformSubstring(pText.Get <string>(executionContext), StartIndex.Get <int>(executionContext), Length.Get <int>(executionContext), LeftToRight.Get <bool>(executionContext)); pResult.Set(executionContext, result); }
public static Entity GetUserSettings(Guid UserID, CubeBase Cube) { Result result = Cube.RetrieveActions.getItemFetch(String.Format(FetchXML, UserID)); if (result.isError) throw new Exception(result.Message); return (Entity)result.BusinessObject; }
public static Entity GetUserSettings(Guid UserID, CubeBase Cube) { Result result = Cube.RetrieveActions.getItemFetch(String.Format(FetchXML, UserID)); if (result.isError) { throw new Exception(result.Message); } return((Entity)result.BusinessObject); }
public static Result RetrieveLocalTimeFromUTCTime(DateTime utcTime, int timeZoneCode, CubeBase Cube) { var request = new LocalTimeFromUtcTimeRequest { TimeZoneCode = timeZoneCode, UtcTime = utcTime.ToUniversalTime() }; Result result = Cube.XRMActions.Execute<LocalTimeFromUtcTimeRequest, LocalTimeFromUtcTimeResponse>(request); return result; }
public static Result RetrieveUTCTimeFromLocalTime(DateTime localTime, int timeZoneCode, CubeBase Cube) { var request = new UtcTimeFromLocalTimeRequest { TimeZoneCode = timeZoneCode, LocalTime = localTime }; Result result = Cube.XRMActions.Execute<UtcTimeFromLocalTimeRequest, UtcTimeFromLocalTimeResponse>(request); return result; }
public void Hit(ItemBase itemBase) { Dictionary <Vector2, CubeBase> result = itemBase.GetAllShowDic(); foreach (var item in result) { CubeBase self = m_CubeBaseDic[item.Key]; if (self.IsShow) { self.CreatReplace(); } } }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="Cube">The cube.</param> protected override void Execute(CubeBase Cube) { string Text = pText.Get<string>((ActivityContext)Cube.BaseSystemObject); bool OperationType = pOperationType.Get<bool>((ActivityContext)Cube.BaseSystemObject); string Result = string.Empty; if (OperationType) Result = HttpUtility.UrlEncode(Text); else Result = HttpUtility.UrlDecode(Text); pResult.Set((ActivityContext)Cube.Context, Result); }
private void CreatPos() { float left = m_Width / 2.0f * m_Size - 0.5f * m_Size; for (int y = 0; y < m_Height; y++) { for (int x = 0; x < m_Width; x++) { Vector3 pos = new Vector3(-left + x * m_Size, y * m_Size + 0.5f * m_Size, 0); CubeBase cube = new CubeBase(x, y, pos, transform, m_CubeColor, m_Prefab, this, m_Size); m_CubeBaseDic.Add(new Vector2(x, y), cube); } } }
public void RightMove() { CubeBase right = null; for (int i = 0; i < m_Height; i++) { List <CubeBase> list = GetAllShowHorizontalCubeList(i); if (list.Count > 0) { if (right == null) { right = list[list.Count - 1]; } else { if (right.Position.x < list[list.Count - 1].Position.x) { right = list[list.Count - 1]; } } } } if (right == null || right.Position.x >= m_Width - 1) { return; } for (int i = 0; i < m_Height; i++) { List <CubeBase> list = GetAllShowHorizontalCubeList(i); list.Sort((a, b) => { int o = (int)b.Position.x - (int)a.Position.x; return(o); }); if (list.Count > 0) { foreach (var item in list) { Vector2 pos = item.Position + new Vector2(1, 0); item.SetIsShow(false); m_CubeBaseDic[pos].SetIsShow(true); m_CubeBaseDic[pos].SetColor(item.Color); } } } }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="Cube">The cube.</param> protected override void Execute(CubeBase Cube) { string Text = pText.Get <string>((ActivityContext)Cube.BaseSystemObject); bool OperationType = pOperationType.Get <bool>((ActivityContext)Cube.BaseSystemObject); string Result = string.Empty; if (OperationType) { Result = HttpUtility.UrlEncode(Text); } else { Result = HttpUtility.UrlDecode(Text); } pResult.Set((ActivityContext)Cube.Context, Result); }
public void CopyCubeBase(ItemBase itemBase) { Dictionary <Vector2, CubeBase> result = itemBase.GetAllShowDic(); foreach (var item in result) { CubeBase self = m_CubeBaseDic[item.Key]; if (self.IsShow) { //self.SetColor(item.Value.Color); self.SetColorAnimation(item.Value.Color); } else { self.SetIsShow(true); self.SetColor(item.Value.Color); } } }
/// <summary> /// Creates the solution. /// </summary> /// <param name="cube">The cube.</param> /// <param name="SolutionName">Name of the solution.</param> /// <returns>Result.</returns> /// <exception cref="Exception"></exception> private static Result CreateSolution(CubeBase cube, string SolutionName) { try { SolutionActions solAct = new SolutionActions(cube); solAct.Name = SolutionName; Result result = solAct.Create(); if (result.isError) { throw new Exception(result.Message); } return(new Result(false, string.Empty, solAct, cube.LogSystem)); } catch (Exception ex) { return(new Result(true, ex.Message, null, cube.LogSystem)); } }
public void LeftMove() { CubeBase left = null; for (int i = 0; i < m_Height; i++) { List <CubeBase> list = GetAllShowHorizontalCubeList(i); if (list.Count > 0) { if (left == null) { left = list[0]; } else { if (left.Position.x > list[0].Position.x) { left = list[0]; } } } } if (left == null || left.Position.x <= 0) { return; } for (int i = 0; i < m_Height; i++) { List <CubeBase> list = GetAllShowHorizontalCubeList(i); if (list.Count > 0) { foreach (var item in list) { Vector2 pos = item.Position + new Vector2(-1, 0); item.SetIsShow(false); m_CubeBaseDic[pos].SetIsShow(true); m_CubeBaseDic[pos].SetColor(item.Color); } } } }
/// <summary> /// Creates the solution settings. /// </summary> /// <param name="cube">The cube.</param> /// <param name="SolutionId">The solution identifier.</param> /// <returns>Result.</returns> /// <exception cref="Exception"></exception> private static Result CreateSolutionSettings(CubeBase cube, Guid SolutionId) { try { SolutionSettingActions solAct = new SolutionSettingActions(cube); solAct.SolutionId = SolutionId; solAct.Name = "Serial Key"; solAct.Value = "Trial"; Result result = solAct.Create(); if (result.isError) { throw new Exception(result.Message); } return(new Result(false, string.Empty, solAct, cube.LogSystem)); } catch (Exception ex) { return(new Result(true, ex.Message, null, cube.LogSystem)); } }
/// <summary> /// Executes the specified cube. /// </summary> /// <param name="cube">The cube.</param> /// <param name="SolutionName">Name of the solution.</param> /// <returns>Result.</returns> /// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception> /// <exception cref="Exception">couldn't read Mawens solution settings</exception> /// <exception cref="Exception">couldn't read Mawens solution</exception> public static Result Execute(CubeBase cube, string SolutionName) { try { Result resultSolution = retrieveSolution(cube, SolutionName); if (resultSolution.isError) { throw new Exception(resultSolution.Message); } if (resultSolution.BusinessObject != null) { SolutionActions sa = (SolutionActions)resultSolution.BusinessObject; Result resultSolutionSettings = retrieveSolutionSettings(cube, sa.ID); if (resultSolutionSettings.isError) { throw new Exception(resultSolutionSettings.Message); } if (resultSolution.BusinessObject != null) { return(resultSolutionSettings); } else { throw new Exception("couldn't read Mawens solution settings"); } } else { throw new Exception("couldn't read Mawens solution"); } } catch (Exception ex) { return(new Result(true, ex.Message, null, cube.LogSystem)); } }
/// <summary> /// Retrieves the solution. /// </summary> /// <param name="cube">The cube.</param> /// <param name="SolutionName">Name of the solution.</param> /// <returns>Result.</returns> /// <exception cref="Exception"></exception> private static Result retrieveSolution(CubeBase cube, string SolutionName) { try { SolutionActions solAct = new SolutionActions(cube); solAct.Name = SolutionName; Result resultSolution = solAct.GetItem(); if (resultSolution.isError) { throw new Exception(resultSolution.Message); } if (resultSolution.BusinessObject != null) { Entity e = (Entity)resultSolution.BusinessObject; SolutionActions sa = new SolutionActions(cube); if (e.Contains("mwns_name")) { sa.Name = e["mwns_name"].ToString(); } if (e.Contains("mwns_mawenssolutionid")) { sa.ID = new Guid(e["mwns_mawenssolutionid"].ToString()); } return(new Result(false, string.Empty, sa, cube.LogSystem)); } else { return(CreateSolution(cube, SolutionName)); } } catch (Exception ex) { return(new Result(true, ex.Message, null, cube.LogSystem)); } }
/// <summary> /// Retrieves the solution settings. /// </summary> /// <param name="cube">The cube.</param> /// <param name="SolutionId">The solution identifier.</param> /// <returns>Result.</returns> /// <exception cref="Exception"></exception> private static Result retrieveSolutionSettings(CubeBase cube, Guid SolutionId) { try { SolutionSettingActions solAct = new SolutionSettingActions(cube); solAct.SolutionId = SolutionId; Result resultSolutionSettings = solAct.GetLicenseItem(); if (resultSolutionSettings.isError) { throw new Exception(resultSolutionSettings.Message); } if (resultSolutionSettings.BusinessObject != null) { Entity e = (Entity)resultSolutionSettings.BusinessObject; SolutionSettingActions ssa = new SolutionSettingActions(cube); if (e.Contains("mwns_name")) { ssa.Name = e["mwns_name"].ToString(); } if (e.Contains("mwns_value")) { ssa.Value = e["mwns_value"].ToString(); } return(new Result(false, string.Empty, ssa, cube.LogSystem)); } else { return(CreateSolutionSettings(cube, SolutionId)); } } catch (Exception ex) { return(new Result(true, ex.Message, null, cube.LogSystem)); } }
protected override void Execute(CubeBase Cube) { //var executionContext = (ActivityContext)Cube.BaseSystemObject; //var dateFormat = pDateFormat.Get<string>(executionContext); //DateTime date = pDate.Get<DateTime>(executionContext); //pYear.Set(executionContext, date.Year); //pMonth.Set(executionContext, date.Month); //pDay.Set(executionContext, date.Day); //pHour.Set(executionContext, date.Hour); //var cultureInfo = GetCultureInfo(executionContext, LanguageCode.Get<int>(executionContext)); //MonthText.Set(executionContext, date.ToString("MMMM", cultureInfo.DateTimeFormat)); //pDayOfWeekString.Set(executionContext, date.ToString("dddd", cultureInfo.DateTimeFormat)); //pHour.Set(executionContext, date.Hour); //pMinute.Set(executionContext, date.Minute); //pDayOfWeek.Set(executionContext, (int)date.DayOfWeek); //pDayOfYear.Set(executionContext, date.DayOfYear); //pWeek.Set(executionContext, GetWeek(date)); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; string result = PerformSubstring(pText.Get<string>(executionContext), StartIndex.Get<int>(executionContext), Length.Get<int>(executionContext), LeftToRight.Get<bool>(executionContext)); pResult.Set(executionContext, result); }
/// <summary> /// Initializers the specified system setting reader. /// </summary> /// <param name="SystemSettingReader">The system setting reader.</param> private void Initializer(ISettingReader SystemSettingReader, string SettingKey) { ILogger SystemLogger = null; IOrganizationService XrmService = null; CubeBase SystemBase = null; List<SettingGroup> SystemSettingsGroup = SystemSettingReader.Read(SettingKey); //load global settings if (SystemSettingsGroup != null && SystemSettingsGroup.Count > 0) { SettingGroup groupGlobalSettings = SystemSettingsGroup.FirstOrDefault(s => s.GroupName == "GlobalSettings"); EnumCarrier.LogLevel logLevel = EnumCarrier.LogLevel.None; EnumCarrier.LogScreen logScreen = EnumCarrier.LogScreen.None; EnumCarrier.LogLocation logger = EnumCarrier.LogLocation.None; if (groupGlobalSettings != null && groupGlobalSettings.Settings != null && groupGlobalSettings.Settings.Count > 0) { //load logger settings logLevel = (EnumCarrier.LogLevel)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogLevel").Value; logScreen = (EnumCarrier.LogScreen)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogScreen").Value; logger = (EnumCarrier.LogLocation)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogLocation").Value; switch (logger) { case EnumCarrier.LogLocation.CRM: break; case EnumCarrier.LogLocation.SQL: SystemLogger = new SqlLogger(); break; case EnumCarrier.LogLocation.Text: SystemLogger = new TextLogger(); break; } } SettingGroup groupConnections = SystemSettingsGroup.FirstOrDefault(s => s.GroupName == "Connections"); if (groupConnections != null && groupConnections.Settings != null && groupConnections.Settings.Count > 0) { IDetailedLog logSystem = null; if (logger == EnumCarrier.LogLocation.SQL) { string connectionString = groupConnections.Settings.FirstOrDefault(l => l.Key == "SQL").Value.ToString(); SqlConnection connection = new SqlConnection(connectionString); logSystem = new DetailedLog(SystemLogger, logLevel, connection, logScreen); } else if (logger == EnumCarrier.LogLocation.Text) { string logPath = groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogPath").Value.ToString(); logSystem = new DetailedLog(SystemLogger, logLevel, logPath, logScreen); } SystemBase = new CubeBase(); SystemBase.LogSystem = logSystem; bool OpenOrganizationService = (bool)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "OpenOrganizationService").Value; if (OpenOrganizationService) { string crmConnection = groupConnections.Settings.FirstOrDefault(l => l.Key == "CRM").Value.ToString(); Service service = new Service(SystemBase.LogSystem); Result result = service.GetService(crmConnection); if (!result.isError) { XrmService = (IOrganizationService)result.BusinessObject; SystemBase.XrmService = XrmService; } } } cube = SystemBase; cube.XRMActions.Create(new Entity()); cube.RetrieveActions.getItemsFetch(""); cube.MetadataRetrieveActions.GetOptionSets("",""); } }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; pResult.Set(executionContext, pText.Get<string>(executionContext).Length); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionActions" /> class. /// </summary> /// <param name="cubeBase">The cube base.</param> public SolutionActions(CubeBase cubeBase) { cube = cubeBase; EntityName = "mwns_mawenssolution"; }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase Cube) { var executionContext = (ActivityContext)Cube.BaseSystemObject; pResult.Set(executionContext, pText.Get <string>(executionContext).Length); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionSettingActions" /> class. /// </summary> /// <param name="cubeBase">The cube base.</param> public SolutionSettingActions(CubeBase cubeBase) { cube = cubeBase; EntityName = "mwns_mawenssolutionsetting"; }
protected override void Execute(CubeBase Cube) { //var executionContext = (ActivityContext)Cube.BaseSystemObject; //var dateFormat = pDateFormat.Get<string>(executionContext); //DateTime date = pDate.Get<DateTime>(executionContext); //pYear.Set(executionContext, date.Year); //pMonth.Set(executionContext, date.Month); //pDay.Set(executionContext, date.Day); //pHour.Set(executionContext, date.Hour); //var cultureInfo = GetCultureInfo(executionContext, LanguageCode.Get<int>(executionContext)); //MonthText.Set(executionContext, date.ToString("MMMM", cultureInfo.DateTimeFormat)); //pDayOfWeekString.Set(executionContext, date.ToString("dddd", cultureInfo.DateTimeFormat)); //pHour.Set(executionContext, date.Hour); //pMinute.Set(executionContext, date.Minute); //pDayOfWeek.Set(executionContext, (int)date.DayOfWeek); //pDayOfYear.Set(executionContext, date.DayOfYear); //pWeek.Set(executionContext, GetWeek(date)); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="Cube">The cube.</param> protected override void Execute(CubeBase Cube) { pResult.Set((ActivityContext)Cube.BaseSystemObject, pText.Get <string>((ActivityContext)Cube.BaseSystemObject).Trim()); }
public static Result RetrieveUTCTimeFromLocalTime(DateTime localTime, int timeZoneCode, CubeBase Cube) { var request = new UtcTimeFromLocalTimeRequest { TimeZoneCode = timeZoneCode, LocalTime = localTime }; Result result = Cube.XRMActions.Execute <UtcTimeFromLocalTimeRequest, UtcTimeFromLocalTimeResponse>(request); return(result); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase cube) { Result r = cube.XRMActions.Execute<CreateRequest, CreateResponse>(new CreateRequest() { }); }
public static Result RetrieveLocalTimeFromUTCTime(DateTime utcTime, int timeZoneCode, CubeBase Cube) { var request = new LocalTimeFromUtcTimeRequest { TimeZoneCode = timeZoneCode, UtcTime = utcTime.ToUniversalTime() }; Result result = Cube.XRMActions.Execute <LocalTimeFromUtcTimeRequest, LocalTimeFromUtcTimeResponse>(request); return(result); }
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="cube">The cube.</param> protected override void Execute(CubeBase cube) { Result r = cube.XRMActions.Execute <CreateRequest, CreateResponse>(new CreateRequest() { }); }
/// <summary> /// Executes the specified execution context. /// </summary> /// <param name="executionContext">The execution context.</param> /// <exception cref="System.ArgumentNullException">ExecutionContext is null</exception> /// <exception cref="Microsoft.Xrm.Sdk.InvalidPluginExecutionException"> /// </exception> protected override void Execute(CodeActivityContext executionContext) { CubeBase cubeBase = new CubeBase(); try { if (executionContext == null) { throw new ArgumentNullException("ExecutionContext is null"); } // Obtain the tracing service from the service provider. cubeBase.LogSystem = new DetailedLog() { TraceService = executionContext.GetExtension<ITracingService>() }; cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "Entered the Execute() method : {0}", this.GetType().ToString())); // Obtain the execution context from the service provider. cubeBase.Context = executionContext.GetExtension<IWorkflowContext>(); // Use the factory to generate the Organization Service. IOrganizationServiceFactory ServiceFactory = executionContext.GetExtension<IOrganizationServiceFactory>(); cubeBase.XrmService = ServiceFactory.CreateOrganizationService(((IWorkflowContext)cubeBase.Context).UserId); cubeBase.BaseSystemObject = executionContext; Execute(cubeBase); } catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex) { cubeBase.LogSystem.CreateLog("The application terminated with an Organization Service Fault error."); cubeBase.LogSystem.CreateLog(string.Format("Timestamp: {0}", ex.Detail.Timestamp)); cubeBase.LogSystem.CreateLog(string.Format("Code: {0}", ex.Detail.ErrorCode)); cubeBase.LogSystem.CreateLog(string.Format("Message: {0}", ex.Detail.Message)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == ex.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault")); throw new InvalidPluginExecutionException(ex.Message, ex); } catch (System.TimeoutException ex) { cubeBase.LogSystem.CreateLog("The application terminated with an timeout error."); cubeBase.LogSystem.CreateLog(string.Format("Message: {0}", ex.Message)); cubeBase.LogSystem.CreateLog(string.Format("Stack Trace: {0}", ex.StackTrace)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == ex.InnerException.Message ? "No Inner Fault" : ex.InnerException.Message)); throw new InvalidPluginExecutionException(ex.Message, ex); } catch (System.Exception ex) { cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "General Exception with message: {0}", ex.Message)); if (ex.InnerException != null) { cubeBase.LogSystem.CreateLog("Inner Exception Message:" + ex.InnerException.Message); FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> fe = ex.InnerException as FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>; if (fe != null) { cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Timestamp: {0}", fe.Detail.Timestamp)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Code: {0}", fe.Detail.ErrorCode)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Message: {0}", fe.Detail.Message)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Trace: {0}", fe.Detail.TraceText)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == fe.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault")); } } throw new InvalidPluginExecutionException(ex.Message, ex); } finally { cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "Finished the Execute() method : {0}", this.GetType().ToString())); } }
/// <summary> /// Executes the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <exception cref="System.ArgumentNullException">serviceProvider is null</exception> /// <exception cref="Microsoft.Xrm.Sdk.InvalidPluginExecutionException"> /// </exception> public void Execute(IServiceProvider serviceProvider) { CubeBase cubeBase = new CubeBase(); try { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider is null"); } // Obtain the tracing service from the service provider. cubeBase.LogSystem = new DetailedLog() { TraceService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)) }; cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "Entered the Execute() method : {0}", this.GetType().ToString())); // Obtain the execution context from the service provider. cubeBase.Context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); // Use the factory to generate the Organization Service. IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); cubeBase.XrmService = serviceFactory.CreateOrganizationService(((IPluginExecutionContext)cubeBase.Context).UserId); cubeBase.BaseSystemObject = serviceProvider; Execute(cubeBase); //if (context.IsExecutingOffline || context.IsOfflinePlayback) } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ex) { cubeBase.LogSystem.CreateLog("The application terminated with an Organization Service Fault error."); cubeBase.LogSystem.CreateLog(string.Format("Timestamp: {0}", ex.Detail.Timestamp)); cubeBase.LogSystem.CreateLog(string.Format("Code: {0}", ex.Detail.ErrorCode)); cubeBase.LogSystem.CreateLog(string.Format("Message: {0}", ex.Detail.Message)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == ex.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault")); throw new InvalidPluginExecutionException(ex.Message, ex); } catch (System.TimeoutException ex) { cubeBase.LogSystem.CreateLog("The application terminated with an timeout error."); cubeBase.LogSystem.CreateLog(string.Format("Message: {0}", ex.Message)); cubeBase.LogSystem.CreateLog(string.Format("Stack Trace: {0}", ex.StackTrace)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == ex.InnerException.Message ? "No Inner Fault" : ex.InnerException.Message)); throw new InvalidPluginExecutionException(ex.Message, ex); } catch (System.Exception ex) { cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "General Exception with message: {0}", ex.Message)); if (ex.InnerException != null) { cubeBase.LogSystem.CreateLog("Inner Exception Message:" + ex.InnerException.Message); FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> fe = ex.InnerException as FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault>; if (fe != null) { cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Timestamp: {0}", fe.Detail.Timestamp)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Code: {0}", fe.Detail.ErrorCode)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Message: {0}", fe.Detail.Message)); cubeBase.LogSystem.CreateLog(string.Format("Fault Exception Trace: {0}", fe.Detail.TraceText)); cubeBase.LogSystem.CreateLog(string.Format("Inner Fault: {0}", null == fe.Detail.InnerFault ? "No Inner Fault" : "Has Inner Fault")); } } throw new InvalidPluginExecutionException(ex.Message, ex); } finally { cubeBase.LogSystem.CreateLog(string.Format(CultureInfo.InvariantCulture, "Finished the Execute() method : {0}", this.GetType().ToString())); } }
/// <summary> /// Executes the specified cube base. /// </summary> /// <param name="cubeBase">The cube base.</param> protected abstract void Execute(CubeBase cubeBase);
/// <summary> /// Executes the workflow activity. /// </summary> /// <param name="Cube">The cube.</param> protected override void Execute(CubeBase Cube) { pResult.Set((ActivityContext)Cube.BaseSystemObject, pText.Get<string>((ActivityContext)Cube.BaseSystemObject).Trim()); }
/// <summary> /// Initializers the specified system setting reader. /// </summary> /// <param name="SystemSettingReader">The system setting reader.</param> private void Initializer(ISettingReader SystemSettingReader, string SettingKey) { ILogger SystemLogger = null; IOrganizationService XrmService = null; CubeBase SystemBase = null; List <SettingGroup> SystemSettingsGroup = SystemSettingReader.Read(SettingKey); //load global settings if (SystemSettingsGroup != null && SystemSettingsGroup.Count > 0) { SettingGroup groupGlobalSettings = SystemSettingsGroup.FirstOrDefault(s => s.GroupName == "GlobalSettings"); EnumCarrier.LogLevel logLevel = EnumCarrier.LogLevel.None; EnumCarrier.LogScreen logScreen = EnumCarrier.LogScreen.None; EnumCarrier.LogLocation logger = EnumCarrier.LogLocation.None; if (groupGlobalSettings != null && groupGlobalSettings.Settings != null && groupGlobalSettings.Settings.Count > 0) { //load logger settings logLevel = (EnumCarrier.LogLevel)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogLevel").Value; logScreen = (EnumCarrier.LogScreen)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogScreen").Value; logger = (EnumCarrier.LogLocation)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogLocation").Value; switch (logger) { case EnumCarrier.LogLocation.CRM: break; case EnumCarrier.LogLocation.SQL: SystemLogger = new SqlLogger(); break; case EnumCarrier.LogLocation.Text: SystemLogger = new TextLogger(); break; } } SettingGroup groupConnections = SystemSettingsGroup.FirstOrDefault(s => s.GroupName == "Connections"); if (groupConnections != null && groupConnections.Settings != null && groupConnections.Settings.Count > 0) { IDetailedLog logSystem = null; if (logger == EnumCarrier.LogLocation.SQL) { string connectionString = groupConnections.Settings.FirstOrDefault(l => l.Key == "SQL").Value.ToString(); SqlConnection connection = new SqlConnection(connectionString); logSystem = new DetailedLog(SystemLogger, logLevel, connection, logScreen); } else if (logger == EnumCarrier.LogLocation.Text) { string logPath = groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "LogPath").Value.ToString(); logSystem = new DetailedLog(SystemLogger, logLevel, logPath, logScreen); } SystemBase = new CubeBase(); SystemBase.LogSystem = logSystem; bool OpenOrganizationService = (bool)groupGlobalSettings.Settings.FirstOrDefault(l => l.Key == "OpenOrganizationService").Value; if (OpenOrganizationService) { string crmConnection = groupConnections.Settings.FirstOrDefault(l => l.Key == "CRM").Value.ToString(); Service service = new Service(SystemBase.LogSystem); Result result = service.GetService(crmConnection); if (!result.isError) { XrmService = (IOrganizationService)result.BusinessObject; SystemBase.XrmService = XrmService; } } } cube = SystemBase; cube.XRMActions.Create(new Entity()); cube.RetrieveActions.getItemsFetch(""); cube.MetadataRetrieveActions.GetOptionSets("", ""); } }
/// <summary> /// Executes the specified cube base. /// </summary> /// <param name="cubeBase">The cube base.</param> protected abstract void Execute(CubeBase cubeBase);