internal XrmService(IOrganizationService actualService, LogController uiController)
 {
     _service = actualService;
     Controller = uiController;
     if (Controller == null)
         Controller = new LogController();
 }
Exemplo n.º 2
0
 public abstract void ExecuteExtention(TRequest request, TResponse response, LogController controller);
        public static void CreateCsv <T>(string path, string name, IEnumerable <T> objects, LogController ui)
        {
            name = GetCsvFileName(name);

            if (objects != null && objects.Any(o => o != null))
            {
                var typeToOutput = objects.First(o => o != null).GetType();

                var propertyNames     = typeToOutput.GetReadableProperties().Select(p => p.Name).ToArray();
                var propertyNamesText = String.Join(",", propertyNames);
                FileUtility.CheckCreateFile(path, name, propertyNamesText);

                var stringBuilder = new StringBuilder();
                stringBuilder.AppendLine();

                foreach (var o in objects)
                {
                    var thisObjectType = o.GetType();
                    var valueStrings   = new List <string>();
                    foreach (var property in propertyNames)
                    {
                        object value = null;
                        if (thisObjectType.GetProperty(property) != null)
                        {
                            value = o.GetPropertyValue(property);
                        }
                        if (value == null)
                        {
                            valueStrings.Add("");
                        }
                        else
                        {
                            var thisString = value.ToString();
                            thisString = thisString.Replace("\n", CsvNewLine);
                            thisString = thisString.Replace("\"", "\"\"");
                            valueStrings.Add("\"" + thisString + "\"");
                        }
                    }
                    stringBuilder.AppendLine(string.Join(",", valueStrings));
                }
                FileUtility.AppendToFile(path, name, stringBuilder.ToString());
            }
        }
 public XrmService(IXrmConfiguration crmConfig)
 {
     XrmConfiguration = crmConfig;
     Controller = new LogController();
 }
 public XrmService(IXrmConfiguration crmConfig, LogController controller)
 {
     XrmConfiguration = crmConfig;
     Controller = controller;
 }