예제 #1
0
        internal static void BuildPeriod <T, R>(IDataManager dm, Guid rootId, Guid eventsId, Trace trace, DateTime datePeriod, string datePeriodFormat)
            where T : Entity, IEntity, IDataWrapper, new()
            where R : DataWrapper, IDataWrapper, IRelation, new()
        {
            IEntityManager em = dm as IEntityManager;

            string timeId = GetTimeIdFromDate(rootId, eventsId, datePeriod, datePeriodFormat);

            T t = em.GetInstance <T>(timeId);

            if (t == null)
            {
                t = dm.GetEntity <T>(timeId);

                if (t == null)
                {
                    t = em.CreateInstance <T>();

                    t.data["Id"]         = timeId;
                    t.data["TimeKey"]    = timeId.Split('|')[2];
                    t.data["DatePeriod"] = datePeriod;
                }
            }

            em.AssociateInstance <R>(trace, t);

            if (trace.Value != null)
            {
                t.data["Sum" + typeof(T).Name] = (decimal)t.data["Sum" + typeof(T).Name] + trace.Value;
            }
        }
예제 #2
0
        DataSet IUserProfile.GetUserProfile()
        {
            AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

            if (aspectizeUser.IsAuthenticated)
            {
                Guid userId = new Guid(aspectizeUser.UserId);

                IDataManager dm = EntityManager.FromDataBaseService(DataBaseService);

                IEntityManager em = dm as IEntityManager;

                User user = dm.GetEntity <User>(userId);

                if (user != null)
                {
                    CurrentUser currentUser = em.CreateInstance <CurrentUser>();

                    em.AssociateInstance <IsUser>(currentUser, user);

                    em.Data.AcceptChanges();

                    return(dm.Data);
                }
            }

            return(null);
        }
예제 #3
0
        public static Root GetRoot(IDataManager dm, bool withTag)
        {
            IEntityManager em = dm as IEntityManager;

            if (withTag)
            {
                var roleRelations = new List <IRoleRelationQuery>();

                roleRelations.Add(new RoleRelationQuery <Root, RootEvents>());

                dm.LoadEntitiesGraph <Root>(roleRelations);
            }
            else
            {
                dm.LoadEntities <Root>();
            }

            if (root == null)
            {
                if (em.GetAllInstances <Root>().Count == 0)
                {
                    root = em.CreateInstance <Root>();
                    dm.SaveTransactional();
                }
                else
                {
                    root = em.GetAllInstances <Root>()[0];
                }
            }

            return(em.GetAllInstances <Root>()[0]);
        }
예제 #4
0
        DataSet IUserProfile.GetUserProfile()
        {
            AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

            IDataManager dm = EntityManager.FromDataBaseService(ServiceName.MyDataService);

            IEntityManager em = dm as IEntityManager;

            if (aspectizeUser.IsAuthenticated)
            {
                var userId = new Guid(aspectizeUser.UserId.ToString());

                User user = dm.GetEntity <User>(userId);

                var roleRelations = new List <IRoleRelationQuery>();

                roleRelations.Add(new RoleRelationQuery <User, BoardUser>());

                dm.LoadEntitiesGraph <User>(roleRelations, userId);

                CurrentUser currentUser = em.CreateInstance <CurrentUser>();

                currentUser.Id = userId;

                em.AssociateInstance <IsUser>(currentUser, user);

                dm.Data.AcceptChanges();
            }

            return(dm.Data);
        }
예제 #5
0
        DataSet ILoadDataService.UploadAttachment(UploadedFile[] uploadedFiles, Guid workItemId)
        {
            IDataManager dm = EntityManager.FromDataBaseService("MyDataService");

            IEntityManager em = dm as IEntityManager;

            var fileService = ExecutingContext.GetService <IFileService>("MyFileService");

            var workItem = dm.GetEntity <WorkItem>(workItemId);

            foreach (UploadedFile uploadedFile in uploadedFiles)
            {
                var attachment = em.CreateInstance <Attachment>();

                string pathFile = string.Format(@"{0:N}/{1:N}", workItemId, attachment.Id);

                attachment.FileName   = uploadedFile.Name;
                attachment.FileLength = uploadedFile.ContentLength;

                em.AssociateInstance <WorkItemAttachment>(workItem, attachment);

                fileService.Write(pathFile, uploadedFile.Stream);
            }

            dm.SaveTransactional();

            return(dm.Data);
        }
예제 #6
0
        object IAutoIdentityService.GetAutoIdentityValue(string fullTableName)
        {
            IDataBaseService dataBaseService = ExecutingContext.GetService <IDataBaseService>(ServiceName.ADWDB);

            IDataManager dataManager = EntityManager.FromDataBaseService(ServiceName.ADWDB);

            if (DataBaseType == DBMS.AzureStorage)
            {
                TableId tableId = dataManager.GetEntity <TableId>(fullTableName);

                if (tableId != null)
                {
                    tableId.NextId++;
                }
                else
                {
                    IEntityManager em = dataManager as IEntityManager;

                    tableId = em.CreateInstance <TableId>();

                    tableId.TableName = fullTableName;
                    tableId.NextId    = 1;
                }

                dataManager.SaveTransactional();

                return(tableId.NextId);
            }
            else
            {
                return(dataManager.GetNextId(fullTableName));
            }
        }
예제 #7
0
        bool IInscriptionService.SignUp(string userName, string pwd)
        {
            IDataManager dm = EntityManager.FromDataBaseService(DataBaseService);

            IEntityManager em = dm as IEntityManager;

            List <User> users = dm.GetEntities <User>(new QueryCriteria(User.Fields.UserName, ComparisonOperator.Equal, userName.ToLower().Trim()));

            User user;

            if (users.Count == 0)
            {
                user = em.CreateInstance <User>();

                user.UserName = userName.ToLower().Trim();
                user.Password = pwd;

                dm.SaveTransactional();

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
        private static void traceQueue(string dataServiceName, string info)
        {
            IDataManager dm = EntityManager.FromDataBaseService(dataServiceName);

            IEntityManager em = dm as IEntityManager;

            var traceQueue = em.CreateInstance <TraceQueue>();

            traceQueue.Info = info;

            dm.SaveTransactional();
        }
예제 #9
0
        static void handleMessage(string dsn, DateTime dt, string eventName, string eventValue, string userId, string info, string userAgent)
        {
            var DataServiceName = dsn;

            IDataManager dm = EntityManager.FromDataBaseService(DataServiceName);

            IEntityManager em = dm as IEntityManager;

            DateTime traceDate = dt;

            decimal?decimalValue = null;

            if (!string.IsNullOrEmpty(eventValue))
            {
                decimal decimalValueNonNull;
                if (decimal.TryParse(eventValue, out decimalValueNonNull))
                {
                    decimalValue = decimalValueNonNull;
                }
            }

            Root root = GetRoot(dm, true);

            Who who = null;

            if (string.IsNullOrEmpty(userId))
            {
                userId = Guid.Empty.ToString("N");
            }

            who = dm.GetEntity <Who>(userId);

            if (who == null)
            {
                who = em.CreateInstance <Who>();

                who.Id = userId;

                em.AssociateInstance <RootWho>(who, root);
            }

            who.DateLastTrace = dt;

            string[] eventslist = eventName.Split('|');

            foreach (string name in eventslist)
            {
                BuildTrace(root, decimalValue, who, null, null, info, dm, traceDate, name.Trim());
            }

            dm.SaveTransactional();
        }
예제 #10
0
        DataSet IUploaderService.UploadFiles(UploadedFile[] uploadedFiles)
        {
            IEntityManager em = EntityManager.FromDomain <Upload.DomainProvider>();

            foreach (UploadedFile uploadedFile in uploadedFiles)
            {
                var file = em.CreateInstance <FileUploaded>();

                file.Name        = uploadedFile.Name;
                file.ContentType = uploadedFile.ContentType;
                file.Size        = uploadedFile.ContentLength;
            }

            em.Data.AcceptChanges();

            return(em.Data);
        }
예제 #11
0
        internal static void BuildStat(IDataManager dm, Guid rootId, Events events, DateTime dateTime)
        {
            IEntityManager em = dm as IEntityManager;

            Stat stat = em.CreateInstance <Stat>();

            stat.Id = events.Id;

            em.AssociateInstance <EventsStat>(events, stat);

            BuildStat <Year, EventsYear>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateYear);
            BuildStat <Quarter, EventsQuarter>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateQuarter);
            BuildStat <Month, EventsMonth>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateMonth);
            BuildStat <Week, EventsWeek>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateWeek);
            BuildStat <Day, EventsDay>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateDay);
            BuildStat <Hour, EventsHour>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateHour);
            //BuildTagStat<Minute, TagMinute>(dm, rootId, events, stat, dateTime, TraceService.ExtractFormatDateMinute);
        }
예제 #12
0
        void ITrace.WriteTrace(TraceInfo traceInfo)
        {
            IDataManager dm = EntityManager.FromDataBaseService(DataServiceName);

            IEntityManager em = dm as IEntityManager;

            Trace trace = em.CreateInstance <Trace>();

            trace.ApplicationName = traceInfo.ApplicationName;
            trace.CommandName     = traceInfo.CommandName;
            trace.InfoType        = traceInfo.InfoType.ToString();
            trace.InfoTypeName    = traceInfo.InfoTypeName;
            //trace.Message = traceInfo.Message.Length > 10000 ? traceInfo.Message.Substring(0, 10000) : traceInfo.Message;
            trace.Received    = traceInfo.Received;
            trace.ServiceName = traceInfo.ServiceName;
            trace.UserHost    = traceInfo.UserHost;
            trace.UserAgent   = (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null) ? System.Web.HttpContext.Current.Request.UserAgent : "";

            bool messageTooLong = traceInfo.Message.Length > 32000;

            if (messageTooLong)
            {
                IFileService fs = ExecutingContext.GetService <IFileService>(FileServiceName);

                Guid fileId = Guid.NewGuid();

                string fileName = string.Format("Trace/{0}.txt", fileId);

                trace.Message = fileName;

                using (Stream s = GenerateStreamFromString(traceInfo.Message))
                {
                    fs.Write(fileName, s);
                }
            }
            else
            {
                trace.Message = traceInfo.Message;
            }

            dm.SaveTransactional();
        }
예제 #13
0
        DataSet ILoadDataService.CreateClipboard(string libelle)
        {
            IDataManager dm = EntityManager.FromDataBaseService(ServiceName.DataService);

            IEntityManager em = dm as IEntityManager;

            var newClipboard = em.CreateInstance <Clipboard>();

            newClipboard.Libelle    = libelle;
            newClipboard.AccessCode = Utilities.GenerateUniqueCode(dm);

            //AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

            //var animateur = dm.GetEntity<User>(new Guid(aspectizeUser.UserId.ToString()));

            //em.AssociateInstance<Anime>(animateur, newMP);

            dm.SaveTransactional();

            return(em.Data);
        }
예제 #14
0
        bool IInscriptionService.SignUp(string firstName, string lastName, string email)
        {
            IDataManager dm = EntityManager.FromDataBaseService(ServiceName.MyDataService);

            List <User> users = dm.GetEntities <User>(new QueryCriteria(User.Fields.Email, ComparisonOperator.Equal, email.ToLower().Trim()));

            User user;

            if (users.Count == 0)
            {
                IEntityManager em = dm as IEntityManager;

                user = em.CreateInstance <User>();

                user.FirstName = firstName;
                user.LastName  = lastName;

                user.Email            = email;
                user.Status           = EnumUserStatus.Pending;
                user.VerificationCode = Guid.NewGuid();

                dm.SaveTransactional();
            }
            else
            {
                return(false);
            }

            var mailService = ExecutingContext.GetService <IAspectizeSMTPService>(ServiceName.MyMailService);

            string applicationLink = string.Format(@"{0}{1}/[email protected]&code={2}", ExecutingContext.CurrentHostUrl, ExecutingContext.CurrentApplicationName, user.VerificationCode);

            string subject = "Welcome to Application LeanKaban";

            string body = string.Format(@"To confirm your subscription, click on thr following link: <a href='{0}' target='_blank'>Application</a>", applicationLink);

            mailService.SendMailSimple(false, email, subject, body);

            return(true);
        }
        DataSet IHumanResourceService.LoadEmployeeStat()
        {
            IDataManager dataManager = EntityManager.FromDataBaseService(ServiceName.ADWDB);

            IEntityManager em = dataManager as IEntityManager;

            List <IRoleRelationQuery> roleRelations = new List <IRoleRelationQuery>();

            roleRelations.Add(new RoleRelationQuery <Employee, EmployeeContact>());

            dataManager.LoadEntitiesGraph <Employee>(roleRelations);

            foreach (Employee employee in em.GetAllInstances <Employee>())
            {
                int birthYear = employee.BirthDate.Year - 1900;

                EmployeeStat employeeStat = em.GetAllInstances <EmployeeStat>().Find(item => (item.YearMin <= birthYear && birthYear <= item.YearMax));

                if (employeeStat == null)
                {
                    employeeStat = em.CreateInstance <EmployeeStat>();

                    employeeStat.YearMin = (int)System.Math.Floor((decimal)((birthYear) / 5)) * 5;
                    employeeStat.YearMax = employeeStat.YearMin + 5;
                }

                if (employee.Gender == "M")
                {
                    employeeStat.NbMale++;
                }
                if (employee.Gender == "F")
                {
                    employeeStat.NbFemale++;
                }
            }

            dataManager.Data.AcceptChanges();

            return(dataManager.Data);
        }
예제 #16
0
        DataSet ILoadDataService.GetItemPage(string type, int page)
        {
            IEntityManager em = EntityManager.FromDataSet(new DataSet());

            //var url = rootUrl + $"{type}.json?page={page}";
            var url = rootUrlNewApi + $"{type}/{page}.json";

            getDataFromHNAPI(url, em, "item", type);

            var items = em.GetAllInstances <item>();

            items.ForEach(e => e.page = page);

            var newPage = em.CreateInstance <page>(new Dictionary <string, object>()
            {
                { "id", type + "-" + page }, { "type", type }, { "number", page }
            });

            newPage.last = (items.Count < 30);

            em.Data.AcceptChanges();

            return(em.Data);
        }
예제 #17
0
        //[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
        //DataSet ITrace.GetTrace(Date dateStart, Date dateEnd)
        //{
        //    IDataManager dm = EntityManager.FromDataBaseService(DataServiceName);

        //    var root = GetRoot(dm, true);

        //    IEntityManager em = dm as IEntityManager;

        //    TimeSpan timeSpan = dateEnd - dateStart;

        //    foreach (Events events in em.GetAllInstances<Events>())
        //    {
        //        string dayStart = TraceService.GetTimeTagKey(root.Id, events.Id, dateStart);//.Substring(0, 11).PadRight(6, '0');
        //        string dayEnd = TraceService.GetTimeTagKey(root.Id, events.Id, dateEnd.DateTime.AddDays(1)); //.Substring(0, 11).PadRight(6, '0');
        //        QueryCriteria qcDay = new QueryCriteria(Day.Fields.Id, ComparisonOperator.GreaterOrEquals, dayStart);
        //        qcDay = qcDay.AND(new QueryCriteria(Day.Fields.Id, ComparisonOperator.LessOrEquals, dayEnd));

        //        List<Day> tagDays = dm.GetEntities<Day>(qcDay);

        //        foreach (Day d in tagDays)
        //        {
        //            em.AssociateInstance<EventsDay>(events, d);
        //        }
        //    }

        //    dm.Data.AcceptChanges();

        //    return dm.Data;
        //}

        DataSet ITrace.GetEventsHistory(Guid eventsId, Date dateStart, Date dateEnd, EnumFrequency frequency)
        {
            IDataManager dm = EntityManager.FromDataBaseService(DataServiceName);

            var root = GetRoot(dm, false);

            IEntityManager em = dm as IEntityManager;

            DateTime dateEndTomorrow = dateEnd.DateTime.AddDays(1);

            Events events = dm.GetEntity <Events>(eventsId);

            string dayStart = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateStart, TraceService.ExtractFormatDateDay);
            string dayEnd   = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateEndTomorrow, TraceService.ExtractFormatDateDay);

            string weekStart = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateStart, TraceService.ExtractFormatDateWeek);
            string weekEnd   = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateEndTomorrow, TraceService.ExtractFormatDateWeek);

            string monthStart = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateStart, TraceService.ExtractFormatDateMonth);
            string monthEnd   = TraceService.GetTimeIdFromDate(root.Id, events.Id, dateEndTomorrow, TraceService.ExtractFormatDateMonth);

            QueryCriteria qcMonth = new QueryCriteria(Month.Fields.Id, ComparisonOperator.GreaterOrEquals, monthStart);

            qcMonth = qcMonth.AND(new QueryCriteria(Month.Fields.Id, ComparisonOperator.LessOrEquals, monthEnd));

            List <Month> tagMonths = dm.GetEntities <Month>(qcMonth);

            foreach (Month m in tagMonths)
            {
                em.AssociateInstance <EventsMonth>(events, m);
            }

            QueryCriteria qcWeek = new QueryCriteria(Month.Fields.Id, ComparisonOperator.GreaterOrEquals, weekStart);

            qcWeek = qcWeek.AND(new QueryCriteria(Month.Fields.Id, ComparisonOperator.LessOrEquals, weekEnd));

            List <Week> tagWeeks = dm.GetEntities <Week>(qcWeek);

            foreach (Week w in tagWeeks)
            {
                em.AssociateInstance <EventsWeek>(events, w);
            }

            QueryCriteria qcDay = new QueryCriteria(Day.Fields.Id, ComparisonOperator.GreaterOrEquals, dayStart);

            qcDay = qcDay.AND(new QueryCriteria(Day.Fields.Id, ComparisonOperator.LessOrEquals, dayEnd));

            List <Day> days = dm.GetEntities <Day>(qcDay);

            foreach (Day d in days)
            {
                em.AssociateInstance <EventsDay>(events, d);
            }

            DateTime temp = dateStart.DateTime;

            TimeSpan ts = new Date(dateEndTomorrow) - dateStart;

            for (var i = 0; i < ts.Days; i++)
            {
                string tempDayId = TraceService.GetTimeIdFromDate(root.Id, events.Id, temp, TraceService.ExtractFormatDateDay);

                if (!events.Day.Exists(item => item.Id == tempDayId))
                {
                    Day tempTagDay = em.CreateInstance <Day>();
                    tempTagDay.Id         = tempDayId;
                    tempTagDay.TimeKey    = tempDayId.Split('|')[2]; //TraceService.GetTimeKey(temp);
                    tempTagDay.DatePeriod = temp.AddHours(12);
                    em.AssociateInstance <EventsDay>(events, tempTagDay);
                }

                string tempWeekId = TraceService.GetTimeIdFromDate(root.Id, events.Id, temp, TraceService.ExtractFormatDateWeek);

                if (!events.Week.Exists(item => item.Id == tempWeekId))
                {
                    Week tempTagWeek = em.CreateInstance <Week>();
                    tempTagWeek.Id         = tempWeekId;
                    tempTagWeek.TimeKey    = tempWeekId.Split('|')[2]; //TraceService.GetTimeKey(temp);
                    tempTagWeek.DatePeriod = temp.AddHours(12);
                    em.AssociateInstance <EventsWeek>(events, tempTagWeek);
                }

                string tempMonthId = TraceService.GetTimeIdFromDate(root.Id, events.Id, temp, TraceService.ExtractFormatDateMonth);

                if (!events.Month.Exists(item => item.Id == tempMonthId))
                {
                    Month tempTagMonth = em.CreateInstance <Month>();
                    tempTagMonth.Id         = tempMonthId;
                    tempTagMonth.TimeKey    = tempMonthId.Split('|')[2]; //TraceService.GetTimeKey(temp);
                    tempTagMonth.DatePeriod = temp.AddHours(12);
                    em.AssociateInstance <EventsMonth>(events, tempTagMonth);
                }

                temp = temp.AddDays(1);
            }

            dm.Data.AcceptChanges();

            return(dm.Data);
        }
예제 #18
0
        internal static void BuildTrace(Root root, decimal?value, Who who, double?longitude, double?latitude, string info, IDataManager dm, DateTime traceDate, string tagName)
        {
            IEntityManager em = dm as IEntityManager;

            Events existingEvents = root.Events.Find(item => item.Name == tagName);

            if (existingEvents == null)
            {
                existingEvents = em.CreateInstance <Events>();

                existingEvents.Name = tagName;

                if (value.HasValue)
                {
                    existingEvents.ValueType = EnumTagValueType.Summarize;
                }

                em.AssociateInstance <RootEvents>(root, existingEvents);
            }

            Trace trace = em.CreateInstance <Trace>();

            trace.DateTrace = traceDate;
            trace.Value     = value;
            trace.Who       = (who != null) ? who.Id : "";
            trace.Longitude = longitude;
            trace.Latitude  = latitude;
            trace.Info      = info;

            if (HttpContext.Current != null && HttpContext.Current.Request != null)
            {
                trace.UserAgent = HttpContext.Current.Request.UserAgent;
            }

            trace.IndexKey = string.Format("{0:N}|{1:N}|{2}", root.Id, existingEvents.Id, GetTimeKey(traceDate)); //GetTimeTagKey(root.Id, existingEvents.Id, traceDate);

            if (value.HasValue)
            {
                existingEvents.SumEvents += value.Value;
            }

            int quarter = GetNumQuarter(traceDate);

            //BuildPeriod<Minute, TraceMinute>(dm, trace, new DateTime(traceDate.Year, traceDate.Month, traceDate.Day, traceDate.Hour, traceDate.Minute, 0), ExtractFormatDateMinute);
            BuildPeriod <Hour, TraceHour>(dm, root.Id, existingEvents.Id, trace, new DateTime(traceDate.Year, traceDate.Month, traceDate.Day, traceDate.Hour, 0, 0), ExtractFormatDateHour);
            BuildPeriod <Day, TraceDay>(dm, root.Id, existingEvents.Id, trace, new DateTime(traceDate.Year, traceDate.Month, traceDate.Day, 12, 0, 0), ExtractFormatDateDay);

            DayOfWeek dayOfWeek     = traceDate.DayOfWeek;
            int       dayFromMonday = ((int)dayOfWeek - 1) % 7;

            if (dayFromMonday < 0)
            {
                dayFromMonday += 7;
            }
            DateTime weekDate = traceDate.AddDays(-dayFromMonday);

            weekDate = weekDate.AddTicks(-(traceDate.Ticks % TimeSpan.TicksPerDay));
            weekDate = weekDate.AddHours(12);

            BuildPeriod <Week, TraceWeek>(dm, root.Id, existingEvents.Id, trace, weekDate, ExtractFormatDateWeek);
            BuildPeriod <Month, TraceMonth>(dm, root.Id, existingEvents.Id, trace, new DateTime(traceDate.Year, traceDate.Month, 1, 12, 0, 0), ExtractFormatDateMonth);
            BuildPeriod <Quarter, TraceQuarter>(dm, root.Id, existingEvents.Id, trace, new DateTime(traceDate.Year, 3 * (quarter - 1) + 1, 1, 12, 0, 0), ExtractFormatDateQuarter);
            BuildPeriod <Year, TraceYear>(dm, root.Id, existingEvents.Id, trace, new DateTime(traceDate.Year, 1, 1, 12, 0, 0), ExtractFormatDateYear);

            em.AssociateInstance <EventsTrace>(trace, existingEvents);
            em.AssociateInstance <RootTrace>(root, trace);
            if (who != null)
            {
                em.AssociateInstance <WhoTrace>(who, trace);
            }
        }
예제 #19
0
        public DataSet Evaluer(string strFormule, string id)
        {
            CResultAErreur result = CResultAErreur.True;

            IEntityManager       em = EntityManager.FromDataSet(DataSetHelper.Create());
            ExpressionAnalysable exp;

            if (id != null && id != "")
            {
                exp = em.GetInstance <ExpressionAnalysable>(id);
            }
            else
            {
                exp = em.CreateInstance <ExpressionAnalysable>();
            }
            exp.Formule  = strFormule;
            exp.Resultat = "";

            if (strFormule == "")
            {
                return(em.Data);
            }

            C2iExpression formule;
            string        strResultat            = "";
            Hashtable     tableLastFormuleDuType = new Hashtable();
            int           nLastIndex             = 0;

            // Analyser l'expression
            //Type tp = m_objet.GetType();
            CContexteAnalyse2iExpression   ctx       = new CContexteAnalyse2iExpression(new CFournisseurGeneriqueProprietesDynamiques(), null);
            CAnalyseurSyntaxiqueExpression analyseur = new CAnalyseurSyntaxiqueExpression(ctx);

            try
            {
                result = analyseur.AnalyseChaine(strFormule);
                if (result)
                {
                    formule = (C2iExpression)result.Data;
                }
                else
                {
                    result.EmpileErreur("Erreur dans la formule");
                    exp.Resultat = result.MessageErreur;
                    em.Data.AcceptChanges();
                    return(em.Data);
                }

                // Evaluer l'expression
                if (formule != null)
                {
                    CContexteEvaluationExpression contexte = new CContexteEvaluationExpression(null);
                    result = formule.Eval(contexte);
                    if (!result)
                    {
                        exp.Resultat = result.MessageErreur;
                        em.Data.AcceptChanges();
                        return(em.Data);
                    }
                    if (result.Data == null)
                    {
                        strResultat += "null";
                    }
                    else
                    {
                        strResultat += result.Data.ToString();
                    }

                    exp.Resultat = strResultat;
                    em.Data.AcceptChanges();
                    return(em.Data);
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }

            return(em.Data);
        }
예제 #20
0
        //-------------------------------------------------------------------------------------------------------------------------
        // Get Profile (ie initial DataSet) of user, authenticated or not
        DataSet IUserProfile.GetUserProfile()
        {
            // Get current user
            AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

            if (aspectizeUser.IsAuthenticated)
            {
                IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create());

                // Initialise l'utilisateur connecté
                var user = em.CreateInstance <User>();
                user.IsAuthentificated = true;
                user.Name            = (string)aspectizeUser[CUserTimosWebApp.c_champUserName];
                user.Login           = (string)aspectizeUser[CUserTimosWebApp.c_champUserLogin];
                user.TimosKey        = (string)aspectizeUser[CUserTimosWebApp.c_champUserKey];
                user.TimosSessionId  = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId];
                user.IsAdministrator = (bool)aspectizeUser[CUserTimosWebApp.c_champIsAdministrator];

                // Instancie les To do de l'utilisateur en cours
                ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));
                CResultAErreur            result = serviceClientAspectize.GetTodosForUser(user.TimosSessionId, user.TimosKey);

                if (result && result.Data != null)
                {
                    DataSet ds = result.Data as DataSet;
                    if (ds != null && ds.Tables.Contains(CTodoTimosWebApp.c_nomTable))
                    {
                        DataTable dt = ds.Tables[CTodoTimosWebApp.c_nomTable];

                        foreach (DataRow row in dt.Rows)
                        {
                            var todo = em.CreateInstance <Todos>();
                            todo.TimosId            = (int)row[CTodoTimosWebApp.c_champId];
                            todo.Label              = (string)row[CTodoTimosWebApp.c_champLibelle];
                            todo.StartDate          = (DateTime)row[CTodoTimosWebApp.c_champDateDebut];
                            todo.Instructions       = (string)row[CTodoTimosWebApp.c_champInstructions];
                            todo.ElementType        = (string)row[CTodoTimosWebApp.c_champTypeElementEdite];
                            todo.ElementId          = (int)row[CTodoTimosWebApp.c_champIdElementEdite];
                            todo.ElementDescription = (string)row[CTodoTimosWebApp.c_champElementDescription];
                            todo.DureeStandard      = (int)row[CTodoTimosWebApp.c_champDureeStandard];
                            int nEtat = (int)row[CTodoTimosWebApp.c_champEtatTodo];
                            todo.EtatTodo = (EtatTodo)nEtat;
                            if (row[CTodoTimosWebApp.c_champDateFin] == DBNull.Value)
                            {
                                todo.EndDate = null;
                            }
                            else
                            {
                                todo.EndDate = (DateTime)row[CTodoTimosWebApp.c_champDateFin];
                            }
                        }
                    }
                }

                // Récupère la liste des Actions globales disponibles pour cet utilisateur
                try
                {
                    result = serviceClientAspectize.GetActionsForUser(user.TimosSessionId, user.TimosKey);
                    if (!result)
                    {
                        throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + user.TimosSessionId + ", keyUser = "******")" +
                                                 Environment.NewLine +
                                                 result.MessageErreur);
                    }

                    if (result && result.Data != null)
                    {
                        DataSet ds = result.Data as DataSet;

                        if (ds != null && ds.Tables.Contains(CActionWeb.c_nomTable))
                        {
                            DataTable dt = ds.Tables[CActionWeb.c_nomTable];

                            foreach (DataRow row in dt.Rows)
                            {
                                var action = em.CreateInstance <Action>();
                                action.Id           = (int)row[CActionWeb.c_champId];
                                action.Libelle      = (string)row[CActionWeb.c_champLibelle];
                                action.Instructions = (string)row[CActionWeb.c_champInstructions];
                                action.IsGlobale    = (bool)row[CActionWeb.c_champIsGlobale];
                                action.HasForm      = (bool)row[CActionWeb.c_champHasForm];

                                // Variables Texte
                                action.IDT1 = (string)row[CActionWeb.c_champIdVarText1];
                                action.IDT2 = (string)row[CActionWeb.c_champIdVarText2];
                                action.IDT3 = (string)row[CActionWeb.c_champIdVarText3];
                                action.IDT4 = (string)row[CActionWeb.c_champIdVarText4];
                                action.IDT5 = (string)row[CActionWeb.c_champIdVarText5];
                                action.IDT6 = (string)row[CActionWeb.c_champIdVarText6];
                                action.IDT7 = (string)row[CActionWeb.c_champIdVarText7];
                                action.IDT8 = (string)row[CActionWeb.c_champIdVarText8];
                                action.IDT9 = (string)row[CActionWeb.c_champIdVarText9];

                                action.LBLT1 = (string)row[CActionWeb.c_champLabelVarText1];
                                action.LBLT2 = (string)row[CActionWeb.c_champLabelVarText2];
                                action.LBLT3 = (string)row[CActionWeb.c_champLabelVarText3];
                                action.LBLT4 = (string)row[CActionWeb.c_champLabelVarText4];
                                action.LBLT5 = (string)row[CActionWeb.c_champLabelVarText5];
                                action.LBLT6 = (string)row[CActionWeb.c_champLabelVarText6];
                                action.LBLT7 = (string)row[CActionWeb.c_champLabelVarText7];
                                action.LBLT8 = (string)row[CActionWeb.c_champLabelVarText8];
                                action.LBLT9 = (string)row[CActionWeb.c_champLabelVarText9];

                                string strValeursVarText1 = (string)row[CActionWeb.c_champValeursVarText1];
                                string strValeursVarText2 = (string)row[CActionWeb.c_champValeursVarText2];
                                string strValeursVarText3 = (string)row[CActionWeb.c_champValeursVarText3];
                                string strValeursVarText4 = (string)row[CActionWeb.c_champValeursVarText4];
                                string strValeursVarText5 = (string)row[CActionWeb.c_champValeursVarText5];
                                string strValeursVarText6 = (string)row[CActionWeb.c_champValeursVarText6];
                                string strValeursVarText7 = (string)row[CActionWeb.c_champValeursVarText7];
                                string strValeursVarText8 = (string)row[CActionWeb.c_champValeursVarText8];
                                string strValeursVarText9 = (string)row[CActionWeb.c_champValeursVarText9];

                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText1, "T1");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText2, "T2");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText3, "T3");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText4, "T4");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText5, "T5");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText6, "T6");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText7, "T7");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText8, "T8");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText9, "T9");

                                // Variables Int
                                action.IDN1  = (string)row[CActionWeb.c_champIdVarInt1];
                                action.IDN2  = (string)row[CActionWeb.c_champIdVarInt2];
                                action.IDN3  = (string)row[CActionWeb.c_champIdVarInt3];
                                action.LBLN1 = (string)row[CActionWeb.c_champLabelVarInt1];
                                action.LBLN2 = (string)row[CActionWeb.c_champLabelVarInt2];
                                action.LBLN3 = (string)row[CActionWeb.c_champLabelVarInt3];

                                string strValeursVarInt1 = (string)row[CActionWeb.c_champValeursVarInt1];
                                string strValeursVarInt2 = (string)row[CActionWeb.c_champValeursVarInt2];
                                string strValeursVarInt3 = (string)row[CActionWeb.c_champValeursVarInt3];
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt1, "N1");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt2, "N2");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt3, "N3");

                                // Variables Date
                                action.IDD1  = (string)row[CActionWeb.c_champIdVarDate1];
                                action.IDD2  = (string)row[CActionWeb.c_champIdVarDate2];
                                action.IDD3  = (string)row[CActionWeb.c_champIdVarDate3];
                                action.LBLD1 = (string)row[CActionWeb.c_champLabelVarDate1];
                                action.LBLD2 = (string)row[CActionWeb.c_champLabelVarDate2];
                                action.LBLD3 = (string)row[CActionWeb.c_champLabelVarDate3];
                                // Variables Bool
                                action.IDB1  = (string)row[CActionWeb.c_champIdVarBool1];
                                action.IDB2  = (string)row[CActionWeb.c_champIdVarBool2];
                                action.IDB3  = (string)row[CActionWeb.c_champIdVarBool3];
                                action.LBLB1 = (string)row[CActionWeb.c_champLabelVarBool1];
                                action.LBLB2 = (string)row[CActionWeb.c_champLabelVarBool2];
                                action.LBLB3 = (string)row[CActionWeb.c_champLabelVarBool3];
                            }
                        }

                        em.Data.AcceptChanges();
                        return(em.Data);
                    }
                }
                catch (Exception ex)
                {
                    throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + user.TimosSessionId + ", keyUser = "******")" +
                                             Environment.NewLine +
                                             result.MessageErreur);
                }

                em.Data.AcceptChanges();
                return(em.Data);
            }
            // No profile for unanthenticated user
            return(null);
        }
예제 #21
0
        void ILog.WriteLog(TraceInfo traceInfo)
        {
            if (traceInfo.Level < 0)
            {
                if (!ExecutingContext.CurrentHostUrl.ToLower().StartsWith(@"http://localhost"))
                {
                    bool messageTooLong = traceInfo.Message.Length > 32000;

                    IDataManager dm = null;

                    IEntityManager em = null;

                    if (!string.IsNullOrEmpty(DataServiceName))
                    {
                        dm = EntityManager.FromDataBaseService(DataServiceName);

                        em = dm as IEntityManager;
                    }
                    else
                    {
                        em = EntityManager.FromDataSet(DataSetHelper.Create());
                    }

                    LogException logException = em.CreateInstance <LogException>();

                    logException.ApplicationName = traceInfo.ApplicationName;
                    logException.CommandName     = traceInfo.CommandName;
                    logException.InfoTypeName    = traceInfo.InfoTypeName;
                    logException.Message         = (messageTooLong) ? "" : traceInfo.Message;
                    logException.ServiceName     = traceInfo.ServiceName;
                    logException.DateException   = traceInfo.Received;
                    logException.UserAgent       = (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null && (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.UserAgent))) ? System.Web.HttpContext.Current.Request.UserAgent : "";

                    AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

                    if (aspectizeUser.IsAuthenticated && aspectizeUser["Email"] != null)
                    {
                        logException.UserName = aspectizeUser["Email"].ToString();
                    }
                    else
                    {
                        logException.UserName = "******";
                    }

                    if (messageTooLong && !string.IsNullOrEmpty(FileServiceName))
                    {
                        IFileService fs = ExecutingContext.GetService <IFileService>(FileServiceName);

                        Guid fileId = Guid.NewGuid();

                        string fileName = string.Format("Trace/{0}.txt", fileId);

                        logException.Message = string.Format("Message Exception is too long to be saved in entity, and is saved in file {0}", fileName);

                        MemoryStream stream = new MemoryStream();
                        StreamWriter writer = new StreamWriter(stream);
                        writer.Write(traceInfo.Message);
                        writer.Flush();
                        stream.Position = 0;

                        fs.Write(fileName, stream);
                    }

                    if (!string.IsNullOrEmpty(DataServiceName))
                    {
                        dm.SaveTransactional();
                    }

                    if (!string.IsNullOrEmpty(MailTo) && !string.IsNullOrEmpty(MailServiceName))
                    {
                        IAspectizeSMTPService smtpService = ExecutingContext.GetService <IAspectizeSMTPService>(MailServiceName);

                        string subject = string.Format("Bug : {0} {1}", traceInfo.ApplicationName, logException.UserName);

                        StringBuilder sb = new StringBuilder();

                        sb.AppendLine();
                        sb.AppendFormat("Date: {0}", traceInfo.Received);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        sb.AppendFormat("Application: {0}", traceInfo.ApplicationName);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        sb.AppendFormat("Host: {0}", ExecutingContext.CurrentHostUrl);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null)
                        {
                            sb.AppendFormat("Url: {0}", System.Web.HttpContext.Current.Request.Url.AbsoluteUri);
                            sb.AppendLine("<br />");
                            sb.AppendLine();
                        }
                        sb.AppendFormat("UserAgent: {0}", logException.UserAgent);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        sb.AppendFormat("Service: {0}", traceInfo.ServiceName);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        sb.AppendFormat("Command: {0}", traceInfo.CommandName);
                        sb.AppendLine("<br />");
                        sb.AppendLine();
                        sb.AppendFormat("Message: {0}", (messageTooLong) ? logException.Message : traceInfo.Message.Replace("\r\n", "<br />"));
                        sb.AppendLine("<br />");

                        string emailContent = sb.ToString();

                        smtpService.SendMail(false, MailTo.Split(','), subject, emailContent, null);
                    }
                }
            }
        }
예제 #22
0
        DataSet IDataService.SaveData(DataSet dataSet, string sessionId, string circulatingId, bool updateVersion)
        {
            IDataManager dm = EntityManager.FromDataSetAndBaseService(dataSet, "MyDataService");

            IEntityManager em = dm as IEntityManager;

            var log = new AspectizeTaskLoggingHelper();

            var currentSessionId = circulatingId;

            var appName = "PlayGroundRT";

            Session session = null;

            var sessions = em.GetAllInstances <Session>();

            if (sessions.Count > 0)
            {
                session = sessions[0];
            }
            else
            {
                session = dm.GetEntity <Session>(circulatingId);
            }

            if (updateVersion)
            {
                NextId nextId        = null;
                var    nextIdSession = "";

                if (currentSessionId.Contains("-"))
                {
                    var parts = currentSessionId.Split('-');

                    nextIdSession = parts[0];
                }
                else
                {
                    nextIdSession = currentSessionId;
                }

                nextId = dm.GetEntity <NextId>(nextIdSession);

                if (nextId != null)
                {
                    nextId.Version++;
                }
                else
                {
                    nextId = em.CreateInstance <NextId>();

                    nextId.Id      = session.Id;
                    nextId.Version = 1;
                }

                currentSessionId = string.Format("{0}-{1}", nextId.Id, nextId.Version);

                session.Id      = currentSessionId;
                session.Persist = true;

                session.data.AcceptChanges();
                session.data.SetAdded();
            }

            var controlInfos = WebBuilder.BuildHtml(appName, session.Html, session.JSLibrary, log);

            string jsonControlInfos = JsonSerializer.Serialize(controlInfos);

            session.HtmlControlInfoJSON = jsonControlInfos;

            IFileService fs = ExecutingContext.GetService <IFileService>("MyFileService");

            var typeInfo = fs.Read("PlayGroundRT.Types.Intellisense.txt");

            System.IO.StreamReader reader = new System.IO.StreamReader(typeInfo);
            string allTypesInfo           = reader.ReadToEnd();

            //var typeInfoString = System.Text.Encoding.UTF8.GetString(text);

            var ctrinfos = WebBuilder.BuildTypeDefinitionControl(appName, controlInfos);

            var indexControls = allTypesInfo.IndexOf("aas:'Controls'") + "aas:'Controls'".Length;

            allTypesInfo = allTypesInfo.Substring(0, indexControls) + ctrinfos + allTypesInfo.Substring(indexControls);

            var javaScriptCommandInfos = WebTypeInfo.BuildJavascriptCommandInfo(session.js);

            var serviceInfos = WebBuilder.BuildTypeDefinitionBrowserServices(javaScriptCommandInfos);

            var indexBrowserServices = allTypesInfo.IndexOf("aas:'BrowserServices'") + "aas:'BrowserServices'".Length;

            allTypesInfo = allTypesInfo.Substring(0, indexBrowserServices) + serviceInfos + allTypesInfo.Substring(indexBrowserServices);

            var clientSchema = JavascriptEntityDeclaration.Translate(session.MainJS);

            var indexContextData = allTypesInfo.IndexOf("aas:'ContextData'") + "aas:'ContextData'".Length;

            allTypesInfo = allTypesInfo.Substring(0, indexContextData) + "," + clientSchema + allTypesInfo.Substring(indexContextData);

            var jsView = WebBuilder.BuildViews(appName, session.Bindings, allTypesInfo, log);

            session.JSView = jsView;

            var jsLibrary = WebBuilder.BuildJSLibrary(appName, session.js, log);

            session.JSLibrary     = jsLibrary;
            session.Log           = log.ToString();
            session.CirculatingId = currentSessionId;

            dm.SaveTransactional();

            //Create new Entity with same id for result

            IEntityManager emResult = EntityManager.FromDataSet(DataSetHelper.Create());

            Session sessionResult = emResult.CreateInstance <Session>();

            sessionResult.Id = sessionId;

            foreach (DataColumn dc in session.data.Table.Columns)
            {
                if (dc.ColumnName != PlayGround.Session.Fields.Id)
                {
                    sessionResult.data[dc.ColumnName] = session.data[dc.ColumnName];
                }
            }

            emResult.Data.AcceptChanges();

            return(emResult.Data);
        }
예제 #23
0
        //-------------------------------------------------------------------------------------------------------------------------------
        public DataSet GetExportForDisplay(string keyExport, string strLibelle, string strDescription)
        {
            AspectizeUser  aspectizeUser = ExecutingContext.CurrentUser;
            IEntityManager em            = EntityManager.FromDataSet(DataSetHelper.Create());

            if (aspectizeUser.IsAuthenticated)
            {
                int nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId];

                ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));
                CResultAErreur            result = serviceClientAspectize.GetSession(nTimosSessionId);
                if (!result)
                {
                    throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter");
                }
                try
                {
                    IFileService fs           = ExecutingContext.GetService <IFileService>("TimosFileService");
                    string       relativePath = keyExport + ".json";
                    string       fullPath     = fs.GetFileUrl(relativePath);
                    fullPath = fullPath.Substring(16);
                    if (File.Exists(fullPath))
                    {
                        byte[]  buffer      = fs.ReadBytes(relativePath);
                        string  jsonLecture = Encoding.ASCII.GetString(buffer);
                        DataSet dsExport    = JsonConvert.DeserializeObject <DataSet>(jsonLecture);

                        if (dsExport != null && dsExport.Tables.Count > 0)
                        {
                            Export export = em.CreateInstance <Export>();
                            export.Id          = keyExport;
                            export.Libelle     = strLibelle;
                            export.Description = strDescription;
                            export.DataDate    = File.GetLastWriteTime(fullPath);

                            // Extraction des données du DataSet
                            DataTable tableExport = dsExport.Tables[0]; // On traite uniquement la première table
                            int       nIndexCol   = 1;                  // Les 10 premières colonnes uniquement
                            foreach (DataColumn col in tableExport.Columns)
                            {
                                export.data["COL" + nIndexCol] = col.ColumnName;
                                nIndexCol++;
                                if (nIndexCol > 10)
                                {
                                    break;
                                }
                            }
                            // Traitement des données (lignes)
                            int nIndexRow = 0;
                            foreach (DataRow row in tableExport.Rows)
                            {
                                string      strIdCompose = keyExport + "#" + nIndexRow++;
                                ExportDatas expData      = em.GetInstance <ExportDatas>(strIdCompose);
                                if (expData == null)
                                {
                                    expData    = em.CreateInstance <ExportDatas>();
                                    expData.Id = strIdCompose;
                                    em.AssociateInstance <RelationExportDatas>(export, expData);
                                }
                                for (int i = 0; i < tableExport.Columns.Count && i < 10; i++)
                                {
                                    if (row[i] == DBNull.Value)
                                    {
                                        expData.data[i + 1] = "";
                                    }
                                    else
                                    {
                                        expData.data[i + 1] = row[i];
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new SmartException(1010,
                                             "Erreur GetExportForDisplay(nTimosSessionId = " + nTimosSessionId + ", keyExport = " + keyExport + ")" +
                                             Environment.NewLine +
                                             ex.Message);
                }
            }
            else
            {
                throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter");
            }
            em.Data.AcceptChanges();
            return(em.Data);
        }
예제 #24
0
        //-------------------------------------------------------------------------------------------------------------------------------
        public DataSet GetListeExportsForCurrentUser()
        {
            AspectizeUser  aspectizeUser = ExecutingContext.CurrentUser;
            IEntityManager em            = EntityManager.FromDataSet(DataSetHelper.Create());

            if (aspectizeUser.IsAuthenticated)
            {
                int    nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId];
                string keyUser         = (string)aspectizeUser[CUserTimosWebApp.c_champUserKey];

                ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));
                CResultAErreur            result = serviceClientAspectize.GetSession(nTimosSessionId);
                if (!result)
                {
                    throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter");
                }

                try
                {
                    result = serviceClientAspectize.GetExportsForUser(nTimosSessionId, keyUser);
                    if (!result)
                    {
                        throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + nTimosSessionId + ", keyUser = "******")" +
                                                 Environment.NewLine +
                                                 result.MessageErreur);
                    }

                    if (result && result.Data != null)
                    {
                        DataSet ds = result.Data as DataSet;

                        if (ds != null && ds.Tables.Contains(CExportWeb.c_nomTable))
                        {
                            DataTable dt = ds.Tables[CExportWeb.c_nomTable];

                            foreach (DataRow row in dt.Rows)
                            {
                                var export = em.CreateInstance <Export>();
                                export.Id           = (string)row[CExportWeb.c_champId];
                                export.Libelle      = (string)row[CExportWeb.c_champLibelle];
                                export.Description  = (string)row[CExportWeb.c_champDescription];
                                export.UpdatePeriod = (int)row[CExportWeb.c_champPeriode];

                                var    fs           = ExecutingContext.GetService <IFileService>("TimosFileService");
                                string relativePath = export.Id + ".json";
                                string fullPath     = fs.GetFileUrl(relativePath);
                                fullPath = fullPath.Substring(16);
                                if (File.Exists(fullPath))
                                {
                                    export.DataDate = File.GetLastWriteTime(fullPath);
                                }
                                else
                                {
                                    export.DataDate = null;
                                }
                            }
                        }


                        em.Data.AcceptChanges();
                        return(em.Data);
                    }
                }
                catch (Exception ex)
                {
                    throw new SmartException(1010,
                                             "Erreur GetExportsForUser(nTimosSessionId = " + nTimosSessionId + ", keyUser = "******")" +
                                             Environment.NewLine +
                                             ex.Message);
                }
            }
            else
            {
                throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter");
            }
            return(null);
        }