public UserActivityAndIncludesTests()
        {
            userActivity = new UserActivity(
                new ActivitySettings(1, ActivityDrilldown.Year));

            userActivity.Reset().Wait();
        }
        public UserActivityXorIncludesTests()
        {
            userActivity = new UserActivity(
                new ActivitySettings(1, ActivityTimeframe.Year));

            userActivity.Reset().Wait();
        }
        public UserActivityOrCountTests()
        {
            userActivity = new UserActivity(
                new ActivitySettings(1, ActivityDrilldown.Year));

            userActivity.Reset().Wait();
        }
 protected UserActivityTrackTests(ActivityDrilldown drilldown)
 {
     UserActivity = new UserActivity(
         new ActivitySettings(1, drilldown));
     UserActivity.Reset().Wait();
     UserActivity.Track(EventName, Timestamp, 1, 2, 3).Wait();
 }
        public UserActivityMultipleBitOperationTests()
        {
            userActivity = new UserActivity(
                new ActivitySettings(1, ActivityTimeframe.Year));

            userActivity.Reset().Wait();
        }
 protected UserActivityTrackTests(ActivityTimeframe timeframe)
 {
     UserActivity = new UserActivity(
         new ActivitySettings(1, timeframe));
     UserActivity.Reset().Wait();
     UserActivity.Track(EventName, Timestamp, 1, 2, 3).Wait();
 }
        // PUT api/UserActivities/5
        public HttpResponseMessage PutUserActivity(int id, UserActivity useractivity)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != useractivity.Id)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(useractivity).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
        public UserActivityAndCountTests()
        {
            userActivity = new UserActivity(
                new ActivitySettings(1, ActivityTimeframe.Year));

            userActivity.Reset().Wait();
        }
        public static IContextBuilder ResolveContextBuilder(UserActivity activity)
        {
            if (contextBuilders.ContainsKey(activity))
              {
            return contextBuilders[activity];
              }

              return null;
        }
        public static IModelBuilder ResolveModelBuilder(UserActivity activity)
        {
            if (modelBuilders.ContainsKey(activity))
              {
            return modelBuilders[activity];
              }

              return null;
        }
        public static IEventAggregator ResolveAggregator(UserActivity activity)
        {
            if (aggregators.ContainsKey(activity))
              {
            return aggregators[activity];
              }

              return null;
        }
 public SessionController(
     IAuthenticationService authService,
     ISession session,
     IReporting reporting)
 {
     _session = session;
     _authService = authService;
     _reporting = reporting;
     _log = new UserActivity(_reporting);
 }
        // POST api/UserActivities
        public HttpResponseMessage PostUserActivity(UserActivity useractivity)
        {
            if (ModelState.IsValid)
            {
                db.UserActivities.Add(useractivity);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, useractivity);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = useractivity.Id }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
 public BaseActivityContext BuildContext(UserActivity activity, BaseAggregation aggregation)
 {
     return new BaseActivityContext(activity, aggregation.CurrentEvent);
 }
 public BasicActivityMatcher(Predicate<EventBase> predicate, UserActivity activity, int priority)
     : base(activity, priority)
 {
     _internalPredicate = predicate;
 }
Exemple #16
0
 public abstract UserActivity LogUserActivity(UserActivity message);
 /// <summary>
 /// Activate calls UserActivityInfrastructure to activate/deactivate provided record and returns true if action was successfull.
 /// </summary>
 /// <param name="UserActivity"></param>
 /// <returns></returns>
 public async Task <bool> Activate(UserActivity UserActivity)
 {
     return(await this.UserActivityInfrastructure.Activate(UserActivity));
 }
 public UserActivityEventNamesTests()
 {
     userActivity = new UserActivity(new ActivitySettings(1));
     userActivity.Reset().Wait();
 }
Exemple #19
0
        /// <summary>
        /// Converts an <see cref="Activity"/> to the most specific subclass of <see cref="Exercise"/> and fills in the
        /// relevant details.
        /// </summary>
        /// <param name="activity">An instance of <see cref="Activity"/> containing the data returned by an API
        /// endpoint.</param>
        /// <returns>A subclass of <see cref="Exercise"/> containing the data converted from <paramref name="activity"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="activity"/> is <c>null</c>.</exception>
        /// <exception cref="NotImplementedException">Thrown if <paramref name="activity"/> is an activity type that is
        /// not supported by the app at this time.</exception>
        public static Exercise ConvertActivityToExercise(Activity activity)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }

            if (activity.GetType() == typeof(ActivityEssay))
            {
                ActivityEssay resultEssay = (ActivityEssay)activity;
                EssayExercise essay       = new EssayExercise()
                {
                    Title           = resultEssay.Title,
                    Description     = resultEssay.Description,
                    MinimumWords    = resultEssay.MinimumWords,
                    MaximumWords    = resultEssay.MaximumWords,
                    PreliminaryText = resultEssay.PreliminaryText,
                    Contents        = (resultEssay.UserActivity != null) ? ((UserActivityEssay)resultEssay.UserActivity).Text : string.Empty,
                    Featured        = resultEssay.Featured,
                    Uid             = resultEssay.Id,
                    Language        = resultEssay.Language,
                    Level           = resultEssay.Level
                };
                foreach (string tag in resultEssay.Tags)
                {
                    essay.Tags.Add(tag);
                }

                UserActivity uActivity = resultEssay.UserActivity;
                if (uActivity != null)
                {
                    UserActivityEssay uActivityEss = uActivity as UserActivityEssay;
                    if (uActivityEss != null)
                    {
                        if (!string.IsNullOrEmpty(uActivityEss.Text))
                        {
                            essay.Contents = uActivityEss.Text;
                        }
                    }
                }

                return(essay);
            }

            if (activity.GetType() == typeof(ActivityDictionarySearch))
            {
                ActivityDictionarySearch resultDictSearch = (ActivityDictionarySearch)activity;
                DictionarySearchExercise dictionarySearch = new DictionarySearchExercise()
                {
                    Featured = resultDictSearch.Featured,
                    Uid      = resultDictSearch.Id,
                    Language = resultDictSearch.Language,
                    Level    = resultDictSearch.Level
                };

                UserActivity uActivity = resultDictSearch.UserActivity;
                if (uActivity != null)
                {
                    UserActivityDictionarySearch uActivityDs = uActivity as UserActivityDictionarySearch;
                    if (uActivityDs != null)
                    {
                        if (!string.IsNullOrEmpty(uActivityDs.Word))
                        {
                            dictionarySearch.Word = uActivityDs.Word;
                        }
                    }
                }

                return(dictionarySearch);
            }

            throw new NotImplementedException("The returned exercise type is not supported yet");
        }
Exemple #20
0
 public async Task LogUserActivityAsync(string userSessionId, UserActivity userActivity)
 {
     var updateBuilder    = Builders <UserSession> .Update;
     var updateDefinition = updateBuilder.Push(a => a.UserActivities, userActivity);
     await Collection.FindOneAndUpdateAsync(a => a.Id == userSessionId, updateDefinition);
 }
 public void Update(UserActivity t)
 {
     throw new NotImplementedException();
 }
        public override void ViewWillDisappear(bool animated)
        {
            UserActivity?.ResignCurrent();

            base.ViewWillDisappear(animated);
        }
Exemple #23
0
        private static UserActivity ApplyCustomeActivityParams(FileEntry entry, string imgFileName, string actionText, int actionType, int businessValue, string containerId)
        {
            if (entry == null)
            {
                return(null);
            }

            string url;
            var    moduleId       = ProductEntryPoint.ID;
            var    additionalData = "";
            var    securityId     = "0";

            if (entry.RootFolderType == FolderType.BUNCH)
            {
                var title = Global.DaoFactory.GetFolderDao().GetFolder(entry.RootFolderId).Title;

                if (title.StartsWith("projects/project/"))
                {
                    moduleId       = ProjectModuleId;
                    additionalData = "File||";
                    containerId    = title.Replace("projects/project/", "");
                    securityId     = "File||" + containerId;
                }
                else if (title.StartsWith("crm/crm_common/"))
                {
                    moduleId   = CrmModuleId;
                    securityId = "6|" + entry.UniqID;
                }
            }

            if (entry is File)
            {
                url = FileUtility.ExtsWebPreviewed.Contains(FileUtility.GetFileExtension(entry.Title), StringComparer.CurrentCultureIgnoreCase)
                          ? CommonLinkUtility.GetFileWebViewerUrl(entry.ID)
                          : ((File)entry).ViewUrl;
            }
            else
            {
                url = PathProvider.GetFolderUrl((Folder)entry);
            }

            var ua = new UserActivity
            {
                Title        = entry.Title,
                ContentID    = entry.UniqID,
                URL          = url,
                ModuleID     = moduleId,
                ProductID    = moduleId,
                TenantID     = TenantProvider.CurrentTenantID,
                Date         = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                ImageOptions = new ImageOptions {
                    PartID = ProductEntryPoint.ID, ImageFileName = imgFileName
                },
                ActionText     = actionText,
                UserID         = SecurityContext.CurrentAccount.ID,
                ActionType     = actionType,
                BusinessValue  = businessValue,
                AdditionalData = additionalData,
                ContainerID    = containerId,
                SecurityId     = securityId
            };

            return(ua);
        }
Exemple #24
0
 public ConsultationSummaryPage(UserActivity param)
 {
     this.param = param;
     InitializeComponent();
 }
 public BaseActivityContext BuildContext(UserActivity activity, BaseAggregation aggregation)
 {
     var aggr = aggregation as UpdateAggregation;
       return new UpdateActivityContext(activity, aggr.CurrentEvent, aggr.PreviousEvent);
 }
 public UserActivityPubSubTests()
 {
     activity = new UserActivity(
         new ActivitySettings(1, ActivityTimeframe.Year));
     activity.Reset().Wait();
 }
    private DataSet ResultsToDataSet(IList <Activity> results)
    {
        TimeZone  timeZone  = (TimeZone)_Context.GetContext("TimeZone");
        DataSet   dataSet   = new DataSet();
        DataTable dataTable = new DataTable("Reminders");

        dataTable.Columns.Add(new DataColumn("Type"));
        dataTable.Columns.Add(new DataColumn("TypeImage"));
        dataTable.Columns.Add(new DataColumn("StartDate"));
        dataTable.Columns.Add(new DataColumn("ContactName"));
        dataTable.Columns.Add(new DataColumn("AccountName"));
        dataTable.Columns.Add(new DataColumn("Description"));
        dataTable.Columns.Add(new DataColumn("Priority"));
        dataTable.Columns.Add(new DataColumn("Notes"));
        dataTable.Columns.Add(new DataColumn("SchedFor"));
        dataTable.Columns.Add(new DataColumn("Id"));

        //_CurrentActivity = null;
        foreach (Activity item in results)
        {
            //if (_CurrentActivity == null) { _CurrentActivity = item; }
            UserActivity ua = item.Attendees.FindAttendee(_UserId);
            _UserName = User.GetById(item.UserId).ToString();
            DataRow row = dataTable.NewRow();
            switch (item.Type)
            {
            case ActivityType.atAppointment:
                row[1] = Page.ResolveUrl("images/icons/Meeting_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atToDo:
                row[1] = Page.ResolveUrl("images/icons/To_Do_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atPhoneCall:
                row[1] = Page.ResolveUrl("images/icons/Call_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            case ActivityType.atPersonal:
                row[1] = Page.ResolveUrl("images/icons/Personal_16x16.gif");
                row[0] = item.TypeDisplay;
                break;

            default:
                row[1] = Page.ResolveUrl("images/icons/Calendar_16x16.gif");
                row[0] = item.TypeDisplay;
                break;
            }
            if (item.Timeless)
            {
                row[2] = item.StartDate.ToShortDateString() + " (timeless)";
            }
            else
            {
                row[2] = timeZone.UTCDateTimeToLocalTime(item.StartDate).ToString();
            }
            row[3] = item.ContactName;
            row[4] = item.AccountName;
            row[5] = item.Description;
            row[6] = item.Priority;
            row[7] = item.Notes;
            row[8] = _UserName;
            row[9] = item.Id;
            if (item.Id == Request["entityid"])
            {
                _highlightIndex = dataTable.Rows.Count;
            }
            dataTable.Rows.Add(row);
        }
        dataSet.Tables.Add(dataTable);
        return(dataSet);
    }
Exemple #28
0
        private static string GetProductName(UserActivity userActivity)
        {
            var module = ProductManager.Instance.Products.Where(x => userActivity.ProductID == x.ID).SingleOrDefault();

            return(module == null ? "Unknown module" : module.Name);
        }
 public UserActivityPubSubTests()
 {
     publisher = new UserActivity(
         new ActivitySettings(1, ActivityDrilldown.Year));
     publisher.Reset().Wait();
 }
 public UpdateActivityContext(UserActivity activity, EventBase currentEvent, EventBase previousEvent)
     : base(activity, currentEvent)
 {
     PreviousEvent = previousEvent;
 }
 internal void Store(UserActivity userActivity)
 {
     History.Last().AddUserActivity(userActivity);
 }
Exemple #32
0
 /// <summary>
 /// Returns the list of users which are currently registered in the lobby.
 /// </summary>
 public IReadOnlyList <User> GetUsers(UserActivity acitivity)
 {
     return(this.UsersInLobby.Values.Where(user => user.Activity == acitivity).ToList().AsReadOnly());
 }
 public UserActivityPubSubTests()
 {
     activity = new UserActivity(
         new ActivitySettings(1, ActivityTimeframe.Year));
     activity.Reset().Wait();
 }
 public BaseActivityContext(UserActivity activity, EventBase currentEvent)
 {
     Activity = activity;
       CurrentEvent = currentEvent;
 }
Exemple #35
0
        private void RefreshUser(System.Security.Claims.ClaimsPrincipal user)
        {
            var uid = _signInManager.UserManager.GetUserId(User);

            UserActivity.RefreshUser(uid);
        }
Exemple #36
0
 private Task OnUserActivity(object sender, UserActivity args)
 {
     _lastRegisteredActivity.AddOrUpdate(args.UserId, DateTimeOffset.UtcNow, (_, _1) => DateTimeOffset.UtcNow);
     return(Task.CompletedTask);
 }
Exemple #37
0
 internal static void PublishInternal(UserActivity activity)
 {
     UserActivityPublisher.Publish <WikiActivityPublisher>(activity);
 }
        public async Task AddActivityLog(int userId, ActionExecutedContext response)
        {
            try
            {
                var user = await _context.Users.FindAsync(userId);

                var action     = (string)response.RouteData.Values["action"];
                var controller = (string)response.RouteData.Values["controller"];
                var activity   = "";
                if (user != null)
                {
                    activity = user.UserName;
                }

                if (action.ToLower().Contains("add"))
                {
                    activity = activity + " Added " + controller;
                }
                else if (action.ToLower().Contains("update"))
                {
                    activity = activity + " Updated " + controller;
                }
                else if (action.ToLower().Contains("delete"))
                {
                    activity = activity + " Deleted " + controller;
                }
                else if (action.ToLower().Contains("get"))
                {
                    activity = activity + " Viewed " + controller + " List ";
                }

                if (action.ToLower().Contains("delete") || action.ToLower().Contains("update") || action.ToLower().Contains("add"))
                {
                    var resultString = "";
                    if (response.Result is JsonResult json)
                    {
                        var x      = json.Value;
                        var status = json.StatusCode;
                        resultString = (JsonConvert.SerializeObject(x));
                    }
                    if (response.Result is ObjectResult objectResult)
                    {
                        var status       = objectResult.StatusCode;
                        var value        = objectResult.Value;
                        var stringResult = objectResult.ToString();
                        resultString = (JsonConvert.SerializeObject(value));
                    }
                    if (controller.ToLower().Contains("user"))
                    {
                        ////TODO: need to find the result values
                        var resultData = Newtonsoft.Json.JsonConvert.DeserializeObject <User>(resultString);
                        if (resultData != null)
                        {
                            // activity = activity+" " + resultData.FirstName + " " + resultData.LastName;
                        }
                    }
                    if (controller.ToLower().Contains("landdetail"))
                    {
                        var resultData = Newtonsoft.Json.JsonConvert.DeserializeObject <LandDetail>(resultString);

                        if (resultData != null)
                        {
                            var LandDetail = _context.LandDetails.Where(x => x.ID == resultData.ID).FirstOrDefault();
                            activity = LandDetail.Village + " (" + LandDetail.Name + ")" + " has Added" + ".";
                        }
                    }
                }
                var userActivity = new UserActivity {
                    TimeStamp = DateTime.Now, UserID = userId
                };
                userActivity.Activity = activity + "  Successfully";

                _context.UserActivity.Add(userActivity);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
            }
        }
 public UserActivityIncludesTest()
 {
     userActivity = new UserActivity(
         new ActivitySettings(1, ActivityDrilldown.Year));
     userActivity.Reset().Wait();
 }
Exemple #40
0
        private static void Main()
        {
            var myOperator = new Logger().Deserialize <Operator>();

            var createOperator = false;
            var fillOperator   = false;
            var addNewUser     = false;

            // Get user answer what to do
            int activity;

            do
            {
                Console.WriteLine("Choose what do you want to execute:");
                Console.WriteLine("1 - Create Operator.");
                Console.WriteLine("2 - Make actions(call/sms).");
                Console.WriteLine("3 - Add new user.");
                Console.WriteLine("4 - Create Operator + Make actions + Add new user.");

                int.TryParse(Console.ReadLine(), out activity);
            }while (activity != 1 && activity != 2 && activity != 3 && activity != 4);

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (activity)
            {
            case 1:
            {
                createOperator = myOperator.ListAccounts.Count == 0;

                break;
            }

            case 2:
            {
                createOperator = myOperator.ListAccounts.Count == 0;
                fillOperator   = true;

                break;
            }

            case 3:
            {
                createOperator = myOperator.ListAccounts.Count == 0;
                addNewUser     = true;

                break;
            }

            case 4:
            {
                createOperator = myOperator.ListAccounts.Count == 0;
                fillOperator   = true;
                addNewUser     = true;

                break;
            }
            }

            // initialize empty Operator
            if (createOperator)
            {
                myOperator = new Logger().Deserialize <Operator>();

                #region Initializing mobile accounts

                var vasyl = myOperator.CreateMobileAccount();
                vasyl = myOperator.SetAccountParameters(vasyl,
                                                        "Vasyl",
                                                        "Vasylovych",
                                                        "*****@*****.**",
                                                        new DateTime(1987, 10, 24));

                var petro = myOperator.CreateMobileAccount();
                petro = myOperator.SetAccountParameters(petro,
                                                        "Petro",
                                                        "Petrovych",
                                                        "*****@*****.**",
                                                        new DateTime(1988, 01, 15, 10, 0, 0));

                var taras = myOperator.CreateMobileAccount();
                taras = myOperator.SetAccountParameters(taras,
                                                        "Taras",
                                                        "Tarasovych",
                                                        "*****@*****.**",
                                                        new DateTime(1991, 01, 28, 10, 0, 0));

                var nazar = myOperator.CreateMobileAccount();
                nazar = myOperator.SetAccountParameters(nazar,
                                                        "Nazar",
                                                        "Nazarovych",
                                                        "*****@*****.**",
                                                        new DateTime(1997, 06, 10, 10, 0, 0));

                var igor = myOperator.CreateMobileAccount();
                igor = myOperator.SetAccountParameters(igor,
                                                       "Igor",
                                                       "Igorovych",
                                                       "*****@*****.**",
                                                       new DateTime(1997, 01, 28, 10, 0, 0));

                var andriy = myOperator.CreateMobileAccount();
                andriy = myOperator.SetAccountParameters(andriy,
                                                         "Andriy",
                                                         "Andriyovych",
                                                         "*****@*****.**",
                                                         new DateTime(1997, 10, 16, 10, 0, 0));

                #endregion

                #region Set AddressBook contacts

                vasyl.AddressBook.SetAccounts(petro, taras, nazar, igor, andriy);
                petro.AddressBook.SetAccounts(vasyl, taras, nazar, igor, andriy);
                taras.AddressBook.SetAccounts(vasyl, petro, nazar, igor, andriy);
                nazar.AddressBook.SetAccounts(vasyl, petro, taras, igor, andriy);
                andriy.AddressBook.SetAccounts(vasyl, petro, taras, nazar, igor);
                igor.AddressBook.SetAccounts(vasyl, petro, taras, nazar);

                #endregion

                myOperator.Logger.Serialize(myOperator);
            }

            if (fillOperator)
            {
                myOperator = new Logger().Deserialize <Operator>();

                #region Get/initialize accounts from file

                var vasyl1  = myOperator.FindMobileAccountByName("Vasyl");
                var petro1  = myOperator.FindMobileAccountByName("Petro");
                var taras1  = myOperator.FindMobileAccountByName("Taras");
                var nazar1  = myOperator.FindMobileAccountByName("Nazar");
                var igor1   = myOperator.FindMobileAccountByName("Igor");
                var andriy1 = myOperator.FindMobileAccountByName("Andriy");

                #endregion

                #region Call

                vasyl1.Call(petro1.User.Number);
                vasyl1.Call(andriy1.User.Number);
                vasyl1.Call(nazar1.User.Number);
                vasyl1.Call(petro1.User.Number);
                vasyl1.Call(petro1.User.Number);

                petro1.Call(vasyl1.User.Number);
                petro1.Call(vasyl1.User.Number);
                petro1.Call(andriy1.User.Number);
                petro1.Call(andriy1.User.Number);

                taras1.Call(nazar1.User.Number);
                taras1.Call(nazar1.User.Number);
                taras1.Call(nazar1.User.Number);
                taras1.Call(andriy1.User.Number);
                taras1.Call(andriy1.User.Number);
                taras1.Call(vasyl1.User.Number);
                taras1.Call(igor1.User.Number);
                taras1.Call(igor1.User.Number);
                taras1.Call(nazar1.User.Number);

                nazar1.Call(taras1.User.Number);
                nazar1.Call(taras1.User.Number);
                nazar1.Call(andriy1.User.Number);
                nazar1.Call(andriy1.User.Number);
                nazar1.Call(igor1.User.Number);
                nazar1.Call(igor1.User.Number);
                nazar1.Call(petro1.User.Number);
                nazar1.Call(vasyl1.User.Number);

                igor1.Call(andriy1.User.Number);
                igor1.Call(nazar1.User.Number);
                igor1.Call(taras1.User.Number);
                igor1.Call(petro1.User.Number);

                andriy1.Call(igor1.User.Number);
                andriy1.Call(nazar1.User.Number);
                andriy1.Call(taras1.User.Number);
                andriy1.Call(petro1.User.Number);

                #endregion Call

                #region SMS

                vasyl1.Sms(petro1.User.Number);
                vasyl1.Sms(andriy1.User.Number);
                vasyl1.Sms(nazar1.User.Number);
                vasyl1.Sms(petro1.User.Number);
                vasyl1.Sms(petro1.User.Number);

                petro1.Sms(vasyl1.User.Number);
                petro1.Sms(vasyl1.User.Number);
                petro1.Sms(andriy1.User.Number);
                petro1.Sms(andriy1.User.Number);

                taras1.Sms(nazar1.User.Number);
                taras1.Sms(nazar1.User.Number);
                taras1.Sms(nazar1.User.Number);
                taras1.Sms(andriy1.User.Number);
                taras1.Sms(andriy1.User.Number);
                taras1.Sms(vasyl1.User.Number);
                taras1.Sms(igor1.User.Number);
                taras1.Sms(igor1.User.Number);
                taras1.Sms(nazar1.User.Number);

                nazar1.Sms(taras1.User.Number);
                nazar1.Sms(taras1.User.Number);
                nazar1.Sms(andriy1.User.Number);
                nazar1.Sms(andriy1.User.Number);
                nazar1.Sms(igor1.User.Number);
                nazar1.Sms(igor1.User.Number);
                nazar1.Sms(petro1.User.Number);
                nazar1.Sms(vasyl1.User.Number);

                igor1.Sms(andriy1.User.Number);
                igor1.Sms(nazar1.User.Number);
                igor1.Sms(taras1.User.Number);
                igor1.Sms(petro1.User.Number);

                andriy1.Sms(igor1.User.Number);
                andriy1.Sms(nazar1.User.Number);
                andriy1.Sms(taras1.User.Number);
                andriy1.Sms(petro1.User.Number);

                #endregion SMS

                myOperator.Logger.WriteLogMessages();

                myOperator.Logger.Serialize(myOperator);
            }

            // ReSharper disable once InvertIf
            if (addNewUser)
            {
                #region Add new user

                // Get answer from user if he want
                // to add a new account until answer yes/no
                string addNewUserAnswer;
                do
                {
                    Console.WriteLine("Do you want to add new account, write yes/no");
                    addNewUserAnswer = Console.ReadLine();
                }while (addNewUserAnswer != "yes" && addNewUserAnswer != "no");

                // check answers and make new account
                if (addNewUserAnswer.ToLower() == "yes")
                {
                    var newAccount = new User();

                    #region Fill new account properties

                    Console.WriteLine();
                    Console.WriteLine("Enter user properties:");
                    Console.Write("Name: ");
                    newAccount.Name = Console.ReadLine();

                    Console.Write("Surname: ");
                    newAccount.Surname = Console.ReadLine();

                    Console.Write("Date of birth: ");
                    DateTime.TryParse(Console.ReadLine(), out var birth);
                    newAccount.DateBirth = birth;

                    Console.Write("E-mail: ");
                    newAccount.Email = Console.ReadLine();

                    #endregion

                    // test new account
                    var newMobileAccount = myOperator.CreateMobileAccount();
                    newMobileAccount = myOperator.SetAccountParameters(newMobileAccount,
                                                                       newAccount.Name,
                                                                       newAccount.Surname,
                                                                       newAccount.Email,
                                                                       newAccount.DateBirth);

                    #region Make call/sms

                    newMobileAccount?.Call(myOperator.ListAccounts.Where(m => m.User.Name == "Nazar")
                                           .Select(m => m.User.Number)
                                           .FirstOrDefault());

                    newMobileAccount?.Sms(myOperator.ListAccounts.Where(m => m.User.Name == "Taras")
                                          .Select(m => m.User.Number)
                                          .FirstOrDefault());

                    #endregion Make call/sms
                }

                #endregion Add new user

                //Logger.ShowLog(6, "Call ended", MessageType.Call);
                Console.WriteLine();

                myOperator.Logger.WriteLogMessages();

                myOperator.Logger.Serialize(myOperator);
            }

            UserActivity.GetMostActiveUser(myOperator.Logger.FolderPath + myOperator.Logger.CallLoggerFileName, myOperator.ListAccounts);

            Console.ReadLine();
        }
Exemple #41
0
        private static string GetModuleName(UserActivity userActivity)
        {
            IModule module = ProductManager.Instance.GetModuleByID(userActivity.ModuleID);

            return(module == null ? "Unknown module" : module.Name);
        }
Exemple #42
0
        /// <summary>
        /// Page_Load handler.
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            try // try to handle Page_Load
            {
                _ajaxManager = null;

                if ((_ajaxManager = RadAjaxManager.GetCurrent(Page)) == null)
                {
                    _ajaxManager = new RadAjaxManager()
                    {
                        ID = "amEditUser", EnableAJAX = true
                    };
                    {
                        phAjaxManager.Controls.Add(_ajaxManager);
                    }
                }

                var apMainSetting = new AjaxSetting("apMain");
                {
                    apMainSetting.UpdatedControls.Add(new AjaxUpdatedControl("apMain", "alpMain"));
                    {
                        _ajaxManager.AjaxSettings.Add(apMainSetting);
                    }
                }
                var apScoringActionsSetting = new AjaxSetting("apScoringActions");
                {
                    apScoringActionsSetting.UpdatedControls.Add(new AjaxUpdatedControl("apScoringActions", "alpMain"));
                    {
                        _ajaxManager.AjaxSettings.Add(apScoringActionsSetting);
                    }
                }
                var apUserBadgesSetting = new AjaxSetting("apUserBadges");
                {
                    apUserBadgesSetting.UpdatedControls.Add(new AjaxUpdatedControl("apUserBadges", "alpMain"));
                    {
                        _ajaxManager.AjaxSettings.Add(apUserBadgesSetting);
                    }
                }

                if (!IsPostBack)
                {
                    int userId = -1; // define user ID to parse

                    if (Int32.TryParse(Request.QueryString["id"], out userId))
                    {
                        hfId.Value = userId.ToString();

                        if (Int32.TryParse(Request.QueryString["id"], out userId))
                        {
                            _editingUser = UserController.GetUserById(PortalId, userId);
                        }

                        int portalId = PortalId;

                        UserActivity userActivity = UnitOfWork.UserActivities.GetBy(userId, portalId);
                        {
                            decimal activityPoints = (userActivity != null ? userActivity.ActivityPoints : 0);
                            {
                                tbActivityPoints.Text = activityPoints.ToString();
                            }
                        }

                        RebindBadges(userId, portalId);
                    }

                    string backUrl = Request.QueryString["returnUrl"] ?? "/";
                    {
                        btnCancel.NavigateUrl = backUrl;
                    }
                }
            }
            catch (Exception ex) // catch exceptions
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Exemple #43
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string IsManualSingle = "F";
            string chute_label    = string.Empty;

            this.Master.Reset();

            this.Master.RegisterStandardScript = true;

            decimal I_chute_id      = decimal.Parse(Request.QueryString["chuteID"].ToString());
            string  I_chute_barcode = Request.QueryString["chutebarcode"].ToString();
            string  I_user          = Request.QueryString["userlogon"].ToString();
            decimal I_trolley_id    = decimal.Parse(Request.QueryString["trolleyid"].ToString());
            decimal I_chute_type    = decimal.Parse(Request.QueryString["chutetype"].ToString());
            decimal I_chute_area    = decimal.Parse(Request.QueryString["chutearea"] == null?"0":Request.QueryString["chutearea"].ToString());


            //string I_terminal = this.Master.HostName;
            string I_terminal = null;


            UserActivity   setclass = new UserActivity();
            ActivityLogDAO actlog   = new ActivityLogDAO();

            if (!IsPostBack)
            {
                // on page load display this message
                this.Master.MessageBoard = "Scan SKU Barcode";
            }
            else
            {
                string sku_barcode = this.Master.BarcodeValue;
                if (sku_barcode == string.Empty)
                {
                    this.Master.ErrorMessage   = "Invalid Scan. Please scan again";
                    this.Master.DisplayMessage = true;
                    this.Master.BarcodeValue   = string.Empty;
                }
                else
                {
                    if (sku_barcode.Length > 50)
                    {
                        sku_barcode = sku_barcode.Substring(0, 50);
                    }

                    LocateDAO locdao = new LocateDAO();

                    decimal item_id       = 0;
                    string  location_name = null;

                    // the user can either scan a sku or another chute


                    // check if it is a chute or sku barcode

                    if (sku_barcode.Length < 2)
                    {
                        this.Master.ErrorMessage   = "Invalid Barcode";
                        this.Master.DisplayMessage = true;
                        this.Master.BarcodeValue   = string.Empty;
                    }
                    else
                    {
                        string chk_barcode = sku_barcode.Substring(0, 2).ToUpper();


                        if (chk_barcode.ToUpper() == "CH")
                        {
                            // user has scanned the chute

                            decimal   chute_id      = 0;
                            decimal   chute_type    = 0;
                            LocateDAO locdaoch      = new LocateDAO();
                            string    chute_barcode = sku_barcode;

                            string barcodetype_ch = "Chute";
                            try
                            {
                                // logoff user from previous session


                                /************ commented out for time being ************/
                                //locdaoch.Log_off_Chute(I_chute_id, I_user);


                                // activity logging

                                setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                                setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                                setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                                setclass.EventType           = (Int32)EventType.LogOffChuteForLocate;
                                setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.Success;
                                setclass.ExpectedBarcodeType = barcodetype_ch;
                                setclass.Barcode             = chute_barcode;
                                setclass.TerminalId          = I_terminal;
                                setclass.UserId  = I_user;
                                setclass.ChuteId = decimal.ToInt32(chute_id);



                                actlog.SaveUserActivity(setclass);
                                /************ commented out for time being ************/



                                // validate chute using oms_attach_trolley.p_validate_chute

                                chute_id = locdaoch.Validate_Chute(chute_barcode, I_user, I_terminal);

                                // Log user to chute using p_log_on_to_chute


                                /************ commented out for time being ************/
                                //locdaoch.Log_on_to_Chute(chute_barcode, I_user);
                                /************ commented out for time being ************/


                                // find the chute type if it is singles = 1 or multi = 2

                                chute_type = locdaoch.Get_chute_type(chute_id);

                                if (chute_type == 2)
                                {
                                    I_chute_area = locdao.Get_Chute_Area(chute_id);
                                }


                                // find the trolley attached p_chute_trolley

                                decimal trolley_id_ch = locdaoch.Chute_Trolley(chute_barcode, I_user, I_terminal);

                                if (trolley_id_ch == 0)
                                {
                                    // if the trolley id is null then ask user to scan trolley
                                    // redirect to attach trolley

                                    // no trolley attached to chute
                                    if (chute_type == 1) // singles
                                    {
                                        // redirect to scan trolley page
                                        Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + I_user + "&chutetype=" + chute_type + "&chutearea =" + I_chute_area);
                                    }
                                    else if (chute_type == 2) // multi
                                    {
                                        // redirect to scan trolley page
                                        Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + I_user + "&chutetype=" + chute_type + "&chutearea =" + I_chute_area);
                                    }
                                }
                                else
                                {
                                    // trolley is already attached
                                    if (chute_type == 1) // singles
                                    {
                                        // redirect to scan trolley page
                                        Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + I_user + "&chutetype=" + chute_type + "&chutearea =" + I_chute_area);
                                    }
                                    else if (chute_type == 2) // multi
                                    {
                                        // redirect to scan sku

                                        Response.Redirect("LocateScanSku.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + I_user + "&trolleyid=" + trolley_id_ch + "&chutetype=" + chute_type + "&chutearea =" + I_chute_area);
                                    }
                                    else
                                    {
                                        this.Master.ErrorMessage   = "Wrong Chute Type";
                                        this.Master.DisplayMessage = true;
                                        this.Master.BarcodeValue   = string.Empty;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                // activity logging


                                setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                                setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                                setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                                setclass.EventType           = (Int32)EventType.ScanChuteForAttach;
                                setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.ChuteScanFailed;
                                setclass.ExpectedBarcodeType = barcodetype_ch;
                                setclass.Barcode             = chute_barcode;
                                setclass.TerminalId          = I_terminal;
                                setclass.UserId  = I_user;
                                setclass.ChuteId = decimal.ToInt32(chute_id);


                                actlog.SaveUserActivity(setclass);


                                this.Master.ErrorMessage   = ex.Message.Substring(ex.Message.IndexOf(" ", 0), (ex.Message.IndexOf("ORA", 1) - ex.Message.IndexOf(" ", 0)));
                                this.Master.DisplayMessage = true;
                                this.Master.BarcodeValue   = string.Empty;
                            }
                        }
                        else
                        {
                            // user has scanned a SKU
                            // Validate SKU
                            // find item using p_find_chute_item
                            string barcodetype = "SKU";
                            try
                            {
                                item_id = locdao.Find_item(I_chute_id, sku_barcode, I_user, I_terminal, I_chute_area);


                                if (item_id > 0)
                                {
                                    IsManualSingle = locdao.OrderForManualArea(I_chute_area, I_chute_id, item_id);

                                    if (IsManualSingle.ToUpper() != "F")
                                    {
                                        string[] T_chute_Val;


                                        T_chute_Val = IsManualSingle.Split('-');


                                        Response.Redirect("LocateManualAreaChute.aspx?chuteID=" + I_chute_id + "&chutebarcode=" + I_chute_barcode + "&userlogon=" + I_user + "&trolleyid=" + I_trolley_id + "&chutetype=" + I_chute_type + "&itemid=" + item_id + "&skubarcode=" + sku_barcode + "&chutearea=" + I_chute_area + "&tchutelabel=" + T_chute_Val[1] + "&tchuteid=" + T_chute_Val[0]);
                                    }
                                }


                                if (item_id == 0)
                                {
                                    // if item not found
                                    this.Master.ErrorMessage   = "Item not for this chute";
                                    this.Master.DisplayMessage = true;
                                    this.Master.BarcodeValue   = string.Empty;
                                    this.Master.MessageBoard   = "Please Scan the SKU Barcode";
                                }
                                else
                                {
                                    // else display trolley location using p_location_name_for_item



                                    location_name = locdao.Find_location_name(item_id);
                                    if (location_name == null)
                                    {
                                        this.Master.ErrorMessage   = "Location not found for Item";
                                        this.Master.DisplayMessage = true;

                                        this.Master.MessageBoard = "Scan SKU Barcode";
                                    }
                                    else
                                    {
                                        // display location label

                                        // redirect to scan trolley location
                                        //this.Master.MessageBoard = "location is " + location_name;
                                        Response.Redirect("LocateScanLocation.aspx?chuteID=" + I_chute_id + "&chutebarcode=" + I_chute_barcode + "&userlogon=" + I_user + "&trolleyid=" + I_trolley_id + "&chutetype=" + I_chute_type + "&itemid=" + item_id + "&skubarcode=" + sku_barcode + "&locationname=" + location_name + "&chutearea=" + I_chute_area);
                                    }
                                }
                            }
                            catch (Exception ex1)
                            {
                                // activity logging
                                setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                                setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                                setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                                setclass.EventType           = (Int32)EventType.ScanItemForLocate;
                                setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.ItemvalidationFailed;
                                setclass.ExpectedBarcodeType = barcodetype;
                                setclass.Barcode             = sku_barcode;
                                setclass.TerminalId          = I_terminal;
                                setclass.UserId     = I_user;
                                setclass.ChuteId    = decimal.ToInt32(I_chute_id);
                                setclass.TrolleyId  = decimal.ToInt32(I_trolley_id);
                                setclass.ItemNumber = decimal.ToInt32(item_id);



                                actlog.SaveUserActivity(setclass);

                                this.Master.ErrorMessage   = ex1.Message.Substring(ex1.Message.IndexOf(" ", 0), (ex1.Message.IndexOf("ORA", 1) - ex1.Message.IndexOf(" ", 0)));
                                this.Master.DisplayMessage = true;
                                this.Master.BarcodeValue   = string.Empty;
                            }
                        } // sku
                    }     // barcode length greater than 2
                }         // barcode not empty
            }             //end of else
        }
Exemple #44
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.Reset();

            this.Master.RegisterStandardScript = true;
            string I_message = null;

            if (Request.QueryString["message"] != null)
            {
                I_message = Request.QueryString["message"].ToString();
            }



            string user_logon = User.Identity.Name;

            //string I_terminal = this.Master.HostName; //Shared.UserHostName;

            string I_terminal = null;

            string barcodetype = "Chute";

            UserActivity   setclass = new UserActivity();
            ActivityLogDAO actlog   = new ActivityLogDAO();

            if (!IsPostBack)
            {
                if (I_message == "T") // message exists
                {
                    this.Master.MessageBoard = "Trolley is successfully located and detached. Scan next Chute for Locate";
                }
                else
                {
                    // on page load display this message
                    this.Master.MessageBoard = "Scan Chute for Locate";
                }
            }
            else
            {
                string chute_barcode = this.Master.BarcodeValue;

                if (chute_barcode != string.Empty)
                {
                    if (chute_barcode.Length > 50)
                    {
                        chute_barcode = chute_barcode.Substring(0, 50);
                    }
                }

                decimal chute_id   = 0;
                decimal chute_type = 0;
                decimal chute_area = 0;

                LocateDAO locdao = new LocateDAO();


                try
                {
                    // validate chute using oms_attach_trolley.p_validate_chute

                    chute_id = locdao.Validate_Chute(chute_barcode, user_logon, I_terminal);


                    // find the chute type if it is singles = 1 or multi = 2

                    chute_type = locdao.Get_chute_type(chute_id);


                    if (chute_type == 2)
                    {
                        chute_area = locdao.Get_Chute_Area(chute_id);
                    }
                }
                catch (Exception ex)
                {
                    // activity logging


                    setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                    setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                    setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                    setclass.EventType           = (Int32)EventType.ScanChuteForAttach;
                    setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.ChuteScanFailed;
                    setclass.ExpectedBarcodeType = barcodetype;
                    setclass.Barcode             = chute_barcode;
                    setclass.TerminalId          = I_terminal;
                    setclass.UserId  = user_logon;
                    setclass.ChuteId = decimal.ToInt32(chute_id);



                    actlog.SaveUserActivity(setclass);



                    //this.Master.MessageBoard = chute_id.ToString();
                    this.Master.ErrorMessage   = ex.Message.Substring(ex.Message.IndexOf(" ", 0), (ex.Message.IndexOf("ORA", 1) - ex.Message.IndexOf(" ", 0)));
                    this.Master.DisplayMessage = true;
                    this.Master.BarcodeValue   = string.Empty;
                }


                try
                {
                    // find the trolley attached p_chute_trolley



                    decimal trolley_id = locdao.Chute_Trolley(chute_barcode, user_logon, I_terminal);
                    if (trolley_id == 0)
                    {
                        // if the trolley id is null then ask user to scan trolley
                        // redirect to attach trolley

                        // no trolley attached to chute
                        if (chute_type == 1) // singles
                        {
                            // redirect to scan trolley page
                            Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + user_logon + "&chutetype=" + chute_type + "&chutearea=" + chute_area);
                        }
                        else if (chute_type == 2) // multi
                        {
                            // redirect to scan trolley page
                            Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + user_logon + "&chutetype=" + chute_type + "&chutearea=" + chute_area);
                        }

                        else
                        {
                            // activity logging


                            setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                            setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                            setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                            setclass.EventType           = (Int32)EventType.LogOnChuteForLocate;
                            setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.InvalidChuteType;
                            setclass.ExpectedBarcodeType = barcodetype;
                            setclass.Barcode             = chute_barcode;
                            setclass.TerminalId          = I_terminal;
                            setclass.UserId  = user_logon;
                            setclass.ChuteId = decimal.ToInt32(chute_id);



                            actlog.SaveUserActivity(setclass);


                            // end of activity logging

                            this.Master.ErrorMessage   = "Please enter either Chute Type: Single or Chute Type: Multi";
                            this.Master.DisplayMessage = true;
                            this.Master.BarcodeValue   = string.Empty;
                        }
                    }
                    else
                    {
                        // trolley is already attached
                        if (chute_type == 1) // singles
                        {
                            // redirect to scan trolley page
                            Response.Redirect("LocateTrolleyAttach.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + user_logon + "&chutetype=" + chute_type + "&chutearea=" + chute_area);
                        }
                        else if (chute_type == 2) // multi
                        {
                            // redirect to scan sku
                            // Log user to chute using p_log_on_to_chute



                            // ************ commented out for time being ************ /
                            //locdao.Log_on_to_Chute(chute_barcode, user_logon);
                            // ************ commented out for time being ************ /


                            Response.Redirect("LocateScanSku.aspx?chuteID=" + chute_id + "&chutebarcode=" + chute_barcode + "&userlogon=" + user_logon + "&trolleyid=" + trolley_id + "&chutetype=" + chute_type + "&chutearea=" + chute_area);
                        }
                        else
                        {
                            // activity logging


                            setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                            setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                            setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                            setclass.EventType           = (Int32)EventType.LogOnChuteForLocate;
                            setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.InvalidChuteType;
                            setclass.ExpectedBarcodeType = barcodetype;
                            setclass.Barcode             = chute_barcode;
                            setclass.TerminalId          = I_terminal;
                            setclass.UserId  = user_logon;
                            setclass.ChuteId = decimal.ToInt32(chute_id);



                            actlog.SaveUserActivity(setclass);



                            // end of activity logging

                            this.Master.ErrorMessage   = "Please enter either Chute Type: Single or Chute Type: Multi";
                            this.Master.DisplayMessage = true;
                            this.Master.BarcodeValue   = string.Empty;
                        }
                    }
                }
                catch (Exception ex1)
                {
                    // activity logging


                    setclass.AppSystem           = (Int32)ActivityLogEnum.AppSystem.IHF;
                    setclass.ApplicationId       = (Int32)ActivityLogEnum.ApplicationID.AttachAndLocate;
                    setclass.ModuleId            = (Int32)ActivityLogEnum.ModuleID.AttachAndlocate;
                    setclass.EventType           = (Int32)EventType.LogOnChuteForLocate;
                    setclass.ResultCode          = (Int32)ActivityLogEnum.ResultCd.LogonFailed;
                    setclass.ExpectedBarcodeType = barcodetype;
                    setclass.Barcode             = chute_barcode;
                    setclass.TerminalId          = I_terminal;
                    setclass.UserId  = user_logon;
                    setclass.ChuteId = decimal.ToInt32(chute_id);



                    actlog.SaveUserActivity(setclass);



                    // end of activity logging

                    this.Master.ErrorMessage   = ex1.Message.Substring(ex1.Message.IndexOf(" ", 0), (ex1.Message.IndexOf("ORA", 1) - ex1.Message.IndexOf(" ", 0)));
                    this.Master.DisplayMessage = true;
                    this.Master.BarcodeValue   = string.Empty;
                }
            }
        }
Exemple #45
0
 protected virtual void OnUserActivity(EventArgs e)
 {
     UserActivity?.Invoke(this, e);
 }
Exemple #46
0
        protected void OnLoggedIn_Command(object sender, LogOnEventArgs e)
        {
            if (e.ResultCode == ResultCode.Success)
            {
                UserActivity.LogUserLogon(e.UserName, e.GlobalId, DateTime.Now);
                var loggedOnString = string.Format("{0} {1} {2}", e.UserName, e.GlobalId, DateTime.Now.ToShortDateString());
                var redirectUrl    = FormsAuthentication.GetRedirectUrl(e.UserName, e.IsPersistent);

                Session["UserLoggedOn"]       = loggedOnString;
                Session["LoggedOnEmployeeId"] = e.GlobalId;

                var useAd = bool.Parse(Mars.Properties.Settings.Default.UseActiveDirectoryRoleCheck);

                if (useAd)
                {
                    var principalContext = new PrincipalContext(ContextType.Domain,
                                                                Mars.Properties.Settings.Default.ActiveDirectoryDomain,
                                                                Mars.Properties.Settings.Default.ADContainer);

                    var inLicenceeGroup = ActiveDirectory.IsUserInADGroup(e.GlobalId, principalContext,
                                                                          Mars.Properties.Settings.Default.AdLicenseeGroup);



                    var inCorporateGroup = ActiveDirectory.IsUserInADGroup(e.GlobalId, principalContext,
                                                                           Mars.Properties.Settings.Default.AdCorporateGroup);


                    if (inCorporateGroup == ResultCode.Success && inLicenceeGroup == ResultCode.Success)
                    {
                        lblMessage.Text = InBothActiveDirectoyGroups;
                        return;
                    }

                    var employeeId = e.EmployeeId;

                    if (employeeId == string.Empty)
                    {
                        //Special case for ITDEMO accounts that don't have employeeIds
                        employeeId = e.GlobalId;
                    }

                    if (inCorporateGroup == ResultCode.Success)
                    {
                        SetCookieExpirationForMidnight();
                        ProcessUser(employeeId, redirectUrl, CompanyTypeEnum.Corporate);

                        return;
                    }

                    if (inLicenceeGroup == ResultCode.Success)
                    {
                        SetCookieExpirationForMidnight();
                        ProcessUser(employeeId, redirectUrl, CompanyTypeEnum.Licensee);

                        return;
                    }

                    lblMessage.Text = NotInActiveDirectoy;
                }
                else
                {
                    SetCookieExpirationForMidnight();
                    Response.Redirect(redirectUrl);
                }
            }
        }
        /// <summary>
        /// Add calls UserActivityInfrastructure to adds new object in database and returns provided ObjectId.
        /// </summary>
        /// <param name="UserActivity"></param>
        /// <returns></returns>
        public async Task <uint> Add(UserActivity UserActivity)
        {
            var response = await this.UserActivityInfrastructure.Add(UserActivity);

            return(response);
        }
Exemple #48
0
 public int AddUserActivity(UserActivity activity)
 {
     _dbSet.Add(activity);
     return(_context.SaveChanges());
 }
 /// <summary>
 /// GetAll calls UserActivityInfrastructure to fetch and returns queried list of items with specific fields from database.
 /// </summary>
 /// <param name="UserActivity"></param>
 /// <returns></returns>
 public async Task <List <UserActivity> > GetList(UserActivity UserActivity)
 {
     return(await this.UserActivityInfrastructure.GetList(UserActivity));
 }
Exemple #50
0
        public async Task <int> AddUserActivityAsync(UserActivity activity)
        {
            await _dbSet.AddAsync(activity);

            return(await _context.SaveChangesAsync());
        }
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            if (returnUrl == null)
            {
                returnUrl = "Home/Index";
            }
            ViewData["ReturnUrl"] = returnUrl;

            if (ModelState.IsValid)
            {
                var user = await _userManager.FindByNameAsync(model.UserName);

                //if (user != null)
                //{
                //    if (!await _userManager.IsEmailConfirmedAsync(user))
                //    {
                //        ModelState.AddModelError(string.Empty, "You must have a confirmed email to log in.");
                //        return View(model);
                //    }
                //}

                var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, lockoutOnFailure : true);

                if (result.Succeeded)
                {
                    UserActivity activity = new UserActivity
                    {
                        Browser   = Request.Headers["User-Agent"].ToString(),
                        IpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(),
                        TimeStamp = DateTime.Now
                    };

                    //await _userStore.AddUserActivities(user, activity);

                    if (await _userManager.IsInRoleAsync(user, "Admin"))
                    {
                        _logger.LogInformation(1, "Admin User logged in.");
                        return(RedirectToAction("Index", "Home", new { Area = "Admin" }));
                    }

                    _logger.LogInformation(1, "User logged in.");
                    return(RedirectToLocal(returnUrl));
                }
                if (result.RequiresTwoFactor)
                {
                    return(RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));
                }
                if (result.IsLockedOut)
                {
                    _logger.LogWarning(2, "User account locked out.");
                    return(View("Lockout"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return(View(model));
                }
            }

            return(View(model));
        }
		public override void TrackActivity(UserActivity activity)
		{
			BusinessObjects.Instance.ActivityManager.AddActivity(activity);
		}