Beispiel #1
0
        private void Profile_ProfileHintReceived(object sender, ProfileHint e)
        {
            string oldValue = _lastProfileHint;

            _lastProfileHint = e.Tag;
            if (oldValue != _lastProfileHint)
            {
                UpdateStatusMessage();
                // send only a simple status message to status viewer instead of whole status via ReportStatusToStatusViewer
                ReportStatus($"Simulator is '{_lastProfileHint}'");
            }
            if (!Preferences.ProfileAutoStart)
            {
                return;
            }
            ConfigManager.LogManager.LogDebug($"received profile hint with tag '{e.Tag}'");
            string mostRecent = PreferencesFile.LoadSetting("RecentByTag", e.Tag, null);

            if (mostRecent == null)
            {
                ConfigManager.LogManager.LogInfo($"received profile hint with tag '{e.Tag}' but no matching profile has been loaded; cannot auto load");
                return;
            }
            if ((ActiveProfile != null) && (ActiveProfile.Path == mostRecent))
            {
                ConfigManager.LogManager.LogDebug($"most recent profile for profile hint with tag '{e.Tag}' is already active");
                // ask simulator to use the one we are running, if possible
                ActiveProfile.RequestProfileSupport();
                return;
            }
            // execute auto load
            ConfigManager.LogManager.LogDebug($"trying to start most recent matching profile '{mostRecent}'");
            ControlCenterCommands.RunProfile.Execute(mostRecent, Application.Current.MainWindow);
        }
Beispiel #2
0
        public TemplateWriter(ActiveProfile profile, HtmlConventionLibrary library, ITagRequestBuilder tagRequestBuilder)
        {
            _library = library;
            var factory = new TagGeneratorFactory(profile, library, tagRequestBuilder);

            _elements = new Lazy <ITagGenerator <ElementRequest> >(factory.GeneratorFor <ElementRequest>);
        }
Beispiel #3
0
    void OnDisable()
    {
        OnNewSample = null;
        // OnNewSampleSet = null;

        if (worker != null)
        {
            stopEvent.Set();
            worker.Join();
        }

        if (Streaming && OnStop != null)
        {
            OnStop();
        }

        if (ActiveProfile != null)
        {
            ActiveProfile.Dispose();
            ActiveProfile = null;
        }

        if (m_pipeline != null)
        {
            // if (Streaming)
            // m_pipeline.Stop();
            m_pipeline.Dispose();
            m_pipeline = null;
        }

        Streaming = false;
    }
Beispiel #4
0
        /// <summary>
        /// Closes the sensor and disposes any resources.
        /// </summary>
        public void Close()
        {
            OnFrameDataArrived = null;

            if (_streamingThread != null)
            {
                _streamingEvent.Set();
                _streamingThread.Join();
            }

            if (_pipeline != null)
            {
                if (IsOpen)
                {
                    _pipeline.Stop();
                }

                _pipeline.Release();
                _pipeline = null;
            }

            if (ActiveProfile != null)
            {
                ActiveProfile.Dispose();
                ActiveProfile = null;
            }

            if (_pipeline != null)
            {
                _pipeline.Release();
                _pipeline = null;
            }

            IsOpen = false;
        }
Beispiel #5
0
        public ActionResult _DesktopMessages(int convo_id)
        {
            string        myid = User.Identity.GetUserId();
            ActiveProfile act  = db.activeprofiles.ToList().Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            ViewBag.AccountType = act.AccountType;

            ViewBag.AccountID = act.ActiveProfileID;
            Conversation convo = db.conversations.ToList().Where(x => x.ID == convo_id).FirstOrDefault();

            if (convo.LastSenderID == act.ActiveProfileID)
            {
                convo.Seen = true;
                db.SaveChanges();
            }
            if (convo.FirstPersonID == act.ActiveProfileID)
            {
                ViewBag.RecieverID   = convo.SecondPersonID;
                ViewBag.RecieverName = convo.SecondPersonDispName;
            }
            else
            {
                ViewBag.RecieverID   = convo.FirstPersonID;
                ViewBag.RecieverName = convo.FirstPersonDispName;
            }

            List <Message> msgs = db.messages.ToList().Where(x => x.ConversationID == convo_id).ToList();

            return(PartialView(msgs));
        }
Beispiel #6
0
        private void RunProfile_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            _deletingProfile = false;

            string profileToLoad = e.Parameter as string;

            if (profileToLoad == null || !File.Exists(profileToLoad))
            {
                NativeMethods.BringWindowToTop(_helper.Handle);
            }
            else
            {
                if (ActiveProfile != null)
                {
                    if (ActiveProfile.IsStarted)
                    {
                        ActiveProfile.Stop();
                    }
                    ActiveProfile = null;
                }

                LoadProfile(profileToLoad);
                StartProfile();
            }
        }
Beispiel #7
0
 private void ResetProfile()
 {
     if (ActiveProfile != null)
     {
         ActiveProfile.Reset();
     }
 }
Beispiel #8
0
        private void RunProfile_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            string profileToLoad = e.Parameter as string;

            if (profileToLoad == null || !File.Exists(profileToLoad))
            {
                NativeMethods.BringWindowToTop(_helper.Handle);
            }
            else
            {
                if (ActiveProfile != null)
                {
                    if (ActiveProfile.IsStarted)
                    {
                        ActiveProfile.Stop();
                    }
                    ActiveProfile = null;
                }

                // try to load the profile, setting SelectedProfileName in the process
                SettingsLoadTime = DateTime.Now;
                (ConfigManager.SettingsManager as ISettingsManager2)?.SynchronizeSettings(null);
                LoadProfile(profileToLoad);

                if (ActiveProfile != null)
                {
                    // we need to fix up the selection index or Next/Prev buttons will not work correctly
                    // because LoadProfile sets SelectedProfileName but assumes the prev/next has already been set
                    // by user interaction.  however, we selected this profile without user interaction
                    LoadProfileList(profileToLoad);
                }

                StartProfile();
            }
        }
Beispiel #9
0
        public ActionResult OurOrders(int page)
        {
            string        myid = User.Identity.GetUserId();
            ActiveProfile act  = db.activeprofiles.ToList()
                                 .Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            if (act.AccountType == "Business")
            {
                List <Order> orders = db.orders.ToList()
                                      .Where(x => x.BusinessID == act.ActiveProfileID).ToList();
                double sold = 0;

                foreach (Order o in orders)
                {
                    sold += o.Total;
                }
                int Skip = 0;
                ViewBag.Sold = sold;
                if (page == 1)
                {
                    Skip = 0;
                }
                else
                {
                    Skip = page * 10;
                }
                return(View(orders.OrderByDescending(x => x.ID).Skip(Skip - 10).Take(10)));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #10
0
        internal void ChangeActiveProfile(Profile profile, ArtemisSurface surface)
        {
            if (profile != null && profile.Module != this)
            {
                throw new ArtemisCoreException($"Cannot activate a profile of module {profile.Module} on a module of plugin {PluginInfo}.");
            }
            if (!IsActivated)
            {
                throw new ArtemisCoreException("Cannot activate a profile on a deactivated module");
            }

            lock (this)
            {
                if (profile == ActiveProfile)
                {
                    return;
                }

                ActiveProfile?.Dispose();

                ActiveProfile = profile;
                ActiveProfile?.Activate(surface);
            }

            OnActiveProfileChanged();
        }
Beispiel #11
0
 private void StopProfile()
 {
     if (ActiveProfile != null && ActiveProfile.IsStarted)
     {
         ActiveProfile.Stop();
     }
 }
Beispiel #12
0
        public ActionResult OpenMessage(int RecieverID)//Accessed from profile
        {
            //If a conversation between the both of us exists, redirect me to Message( ), else show me a textbox that will call SendMessage( )
            string myUsername = User.Identity.GetUserName();
            string myId       = User.Identity.GetUserId();

            ActiveProfile active = db.activeprofiles.ToList()
                                   .Where(x => x.ApplicationUserId == myId).FirstOrDefault();

            BusinessAccount ba = db.businessaccounts.ToList()
                                 .Where(x => x.ID == RecieverID).FirstOrDefault();
            PersonalAccount pa = db.personalaccounts.ToList().Where(x => x.AppUserId == myId).FirstOrDefault();

            ViewBag.MyID                = active.ActiveProfileID;
            ViewBag.RecieverID          = RecieverID;
            ViewBag.RecieverDisplayName = ba.BusinessName;
            Conversation convo = db.conversations.ToList().
                                 Where(x => (x.FirstPersonID == pa.ID || x.SecondPersonID == pa.ID) && (x.FirstPersonID == RecieverID || x.SecondPersonID == RecieverID))
                                 .FirstOrDefault();

            if (convo != null)
            {
                return(RedirectToAction("Message", "pages", new { pageNo = 0, convoID = convo.ID }));
            }
            else
            {
                return(View()); //For creating the very first text or conversation, form must call SendMessage( )
            }
        }
Beispiel #13
0
 void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     if (ActiveProfile != null)
     {
         try
         {
             ActiveProfile.Tick();
             long currentTick = DateTime.Now.Ticks;
             if (currentTick - _lastTick > TOPMOST_TICK_COUNT)
             {
                 for (int i = 0; i < _windows.Count; i++)
                 {
                     if (_windows[i].Monitor.AlwaysOnTop)
                     {
                         NativeMethods.SetWindowPos(_windows[i].Handle, HWND_TOPMOST, 0, 0, 0, 0, NativeMethods.SWP_NOACTIVATE | NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE);
                     }
                 }
                 NativeMethods.SetWindowPos(_helper.Handle, HWND_TOPMOST, 0, 0, 0, 0, NativeMethods.SWP_NOACTIVATE | NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE);
                 _lastTick = currentTick;
             }
         }
         catch (Exception exception)
         {
             ConfigManager.LogManager.LogError("Error processing profile tick or refresh.", exception);
         }
     }
 }
Beispiel #14
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            bool loaded = ActiveProfile != null;

            if (loaded)
            {
                if (ActiveProfile.IsStarted)
                {
                    ConfigManager.LogManager.LogInfo("Stopping profile on exit.");
                    ActiveProfile.Stop();
                }
                ConfigManager.LogManager.LogInfo("Unloading profile on exit.");
                ActiveProfile = null;
            }

            ConfigManager.LogManager.LogInfo("Saving control center window position.");

            // Persist window placement details to application settings
            WINDOWPLACEMENT wp   = new WINDOWPLACEMENT();
            IntPtr          hwnd = new WindowInteropHelper(this).Handle;

            NativeMethods.GetWindowPlacement(hwnd, out wp);

            //Properties.PreferencesFile.Default.ControlCenterPlacement = wp;
            PreferencesFile.SaveSetting("ControlCenter", "WindowLocation", wp.normalPosition);

            if (loaded && _profileIndex >= 0 && _profileIndex < _profiles.Count)
            {
                PreferencesFile.SaveSetting("ControlCenter", "LastProfile", _profiles[_profileIndex]);
            }

            Properties.Settings.Default.Save();

            base.OnClosing(e);
        }
 public FormLineExpressionBuilder(IElementGenerator <T> generator, HtmlConventionLibrary library, ActiveProfile profile, IFieldAccessService fieldAccessService, IFubuRequest request)
 {
     _generator          = generator;
     _library            = library;
     _profile            = profile;
     _fieldAccessService = fieldAccessService;
     _request            = request;
 }
Beispiel #16
0
        public ActionResult Shops(string search)
        {
            string        myid = User.Identity.GetUserId();
            ActiveProfile act  = db.activeprofiles.ToList()
                                 .Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            if (act.AccountType == "Business")
            {
                return(RedirectToAction("Feedback", "pages", new { feedback = "Please switch to personal account" }));
            }
            else
            {
                List <Follow>          fololws    = db.follows.ToList().Where(x => x.PersonalAccID == act.ActiveProfileID).ToList();
                List <BusinessAccount> businesses = db.businessaccounts.ToList();
                bool hasSearch = false;


                if (search != null)
                {
                    hasSearch      = true;
                    ViewBag.Search = search;
                    List <BusinessAccount> businesses_i_follow = new List <BusinessAccount>();
                    foreach (Follow f in fololws)
                    {
                        foreach (BusinessAccount b in businesses)
                        {
                            if (f.BusinessID == b.ID && b.BusinessName.ToLower().Contains(search.ToLower()))
                            {
                                businesses_i_follow.Add(b);
                            }
                        }
                    }
                    ViewBag.hasSearch = hasSearch;

                    return(View(businesses_i_follow));
                }
                else
                {
                    ViewBag.hasSearch = hasSearch;
                    List <BusinessAccount> businesses_i_follow = new List <BusinessAccount>();

                    foreach (Follow f in fololws)
                    {
                        foreach (BusinessAccount b in businesses)
                        {
                            if (f.BusinessID == b.ID)
                            {
                                businesses_i_follow.Add(b);
                            }
                        }
                    }


                    return(View(businesses_i_follow));
                }
            }
        }
Beispiel #17
0
        /// <summary>
        ///     Switches to the requested profile
        /// </summary>
        /// <param name="Id">Id of the profile to switch to</param>
        public void SwitchProfile(int Id)
        {
            var profileMemento = ActiveProfile.MakeMemento();

            ProfileCaretaker.AddOrUpdateProfile(profileMemento);

            var newProfile = ProfileCaretaker.GetProfile(Id);

            ActiveProfile.LoadMemento(newProfile);
        }
Beispiel #18
0
        public static void SetActiveProfile(Profile profile)
        {
            if (ActiveProfile != null)
            {
                ActiveProfile.DeActivate();
            }

            profile.Activate();
            ActiveProfile = profile;
        }
Beispiel #19
0
        public ActionResult SwitchAcc()
        {
            string          myid = User.Identity.GetUserId();
            PersonalAccount p    = db.personalaccounts.ToList().Where(x => x.AppUserId == myid).FirstOrDefault();
            ActiveProfile   a    = db.activeprofiles.ToList().Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            a.AccountType     = "Personal";
            a.ActiveProfileID = p.ID;
            db.SaveChanges();
            return(RedirectToAction("shops", "pages"));
        }
Beispiel #20
0
 private void Save()
 {
     lock (lockobj) {
         using (MyStopWatch.Measure()) {
             try {
                 ActiveProfile.Save();
             } catch (Exception ex) {
                 Logger.Error(ex);
             }
         }
     }
 }
Beispiel #21
0
        internal override void InternalRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
        {
            Render(deltaTime, surface, canvas, canvasInfo);

            lock (this)
            {
                // Render the profile
                ActiveProfile?.Render(deltaTime, canvas, canvasInfo);
            }

            ProfileRendered(deltaTime, surface, canvas, canvasInfo);
        }
Beispiel #22
0
 private void ResetProfile()
 {
     if (ActiveProfile != null)
     {
         ActiveProfile.Reset();
         if (ActiveProfile.IsStarted)
         {
             StatusMessage = StatusValue.Running;
             return;
         }
     }
     StatusMessage = StatusValue.RunningVersion;
 }
Beispiel #23
0
        /// <summary>
        ///     Creates a new menu and adds it to the current active profile
        /// </summary>
        /// <param name="menuType">MenuType to create</param>
        /// <param name="drinkType">Type of drink to add</param>
        /// <param name="sideType">Type of menu side to add</param>
        /// <param name="mainDishType">Type of the main dish</param>
        /// <param name="sizeType">Size of the dish</param>
        public void AddProductToProfile(MenuType menuType, DrinkType drinkType, SideType sideType,
                                        MainDishType mainDishType, SizeType sizeType)
        {
            var menu = new DishFactory(
                menuType,
                drinkType,
                sideType,
                mainDishType,
                sizeType)
                       .CreateMenu();

            ActiveProfile.AddItem(menu);
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationDbContext db = new ApplicationDbContext();

                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    PersonalAccount personalAcc = new PersonalAccount()
                    {
                        Names       = model.Name,
                        Surname     = model.Surname,
                        PhoneNumber = model.PhoneNumber,
                        Province    = "",
                        City        = "",
                        AppUserId   = user.Id
                    };

                    db.personalaccounts.Add(personalAcc);
                    db.SaveChanges();

                    ActiveProfile ap = new ActiveProfile()
                    {
                        ApplicationUserId = user.Id,
                        AccountType       = "Personal", ActiveProfileID = personalAcc.ID
                    };
                    db.activeprofiles.Add(ap);
                    db.SaveChanges();

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Create", "ProfilePics"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #25
0
        /// <summary>
        ///     Creates a new profile and sets it as active
        /// </summary>
        public void NewProfile()
        {
            if (ActiveProfile == null)
            {
                ActiveProfile = new Profile(ProfileCaretaker.TotalProfiles);
            }
            else
            {
                ProfileCaretaker.AddOrUpdateProfile(ActiveProfile.MakeMemento());
            }

            ActiveProfile.ItemCollection.Clear();
            ActiveProfile.Id = ProfileCaretaker.TotalProfiles;
            ProfileCaretaker.AddOrUpdateProfile(ActiveProfile.MakeMemento());
        }
Beispiel #26
0
        public ActionResult Deals()
        {
            string        myid = User.Identity.GetUserId();
            ActiveProfile act  = db.activeprofiles.ToList()
                                 .Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            ViewBag.MyID = act.ActiveProfileID;

            bool im_business = false;

            if (act.AccountType == "Business")
            {
                im_business        = true;
                ViewBag.ImBusiness = im_business;

                List <Deal> deals = db.deals.ToList()
                                    .Where(x => x.BusinessID == act.ActiveProfileID).ToList();
                return(View(deals));
            }
            else
            {
                ViewBag.ImBusiness = im_business;
                List <Follow> follows = db.follows.ToList()
                                        .Where(x => x.PersonalAccID == act.ActiveProfileID).ToList();
                List <int>  business_ids   = new List <int>();
                List <Deal> alldeals       = db.deals.ToList();
                List <Deal> deals_i_follow = new List <Deal>();

                foreach (Follow f in follows)
                {
                    business_ids.Add(f.BusinessID);
                }

                foreach (Deal d in alldeals)
                {
                    foreach (int id in business_ids)
                    {
                        if (id == d.BusinessID)
                        {
                            deals_i_follow.Add(d);
                        }
                    }
                }

                return(View(deals_i_follow.OrderByDescending(x => x.ID)));
            }
        }
Beispiel #27
0
        public ActionResult BulkOrder(int business_id, int personal_id, string time)
        {
            string        myid   = User.Identity.GetUserId();
            ActiveProfile active = db.activeprofiles.ToList()
                                   .Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            PersonalAccount customer = db.personalaccounts.ToList().Where(x => x.ID == personal_id).FirstOrDefault();

            ListOrder listorder = db.listorders.ToList()
                                  .Where(x => x.BusinessID == business_id && x.PersonalAccID == personal_id && x.Date.TimeOfDay.ToString().Substring(0, 5) == time)
                                  .FirstOrDefault();
            List <ProductListOrder> productorder = db.productlistorders.ToList()
                                                   .Where(x => x.ListOrderID == listorder.ID).ToList();

            List <Order> orders      = new List <Order>();
            double       total       = 0;
            bool         im_business = false;

            foreach (ProductListOrder p in productorder)
            {
                Order order = db.orders.ToList().Where(x => x.ID == p.OrderID).FirstOrDefault();
                if (order != null)
                {
                    orders.Add(order);
                    total += order.Price * order.Qauntity;
                }
            }

            if (listorder.BusinessID == active.ActiveProfileID)
            {
                im_business = true;
            }
            if (listorder.BusinessID == active.ActiveProfileID && listorder.Status == "Pending")
            {
                listorder.Status = "Seen";
                db.SaveChanges();
            }
            ViewBag.ImBusiness   = im_business;
            ViewBag.OrderID      = listorder.ID;
            ViewBag.Status       = listorder.Status;
            ViewBag.Total        = total;
            ViewBag.PersonalID   = personal_id;
            ViewBag.CustomerName = customer.Names + " " + customer.Surname;

            return(View(orders));
        }
Beispiel #28
0
    void OnDestroy()
    {
        // OnStart = null;
        OnStop = null;

        if (ActiveProfile != null)
        {
            ActiveProfile.Dispose();
            ActiveProfile = null;
        }

        if (m_pipeline != null)
        {
            m_pipeline.Dispose();
            m_pipeline = null;
        }
    }
Beispiel #29
0
        public ActionResult MakeDealPage(int prod_id)
        {
            string        myid = User.Identity.GetUserId();
            ActiveProfile act  = db.activeprofiles.ToList()
                                 .Where(x => x.ApplicationUserId == myid).FirstOrDefault();

            if (act.AccountType == "Business")
            {
                ProfilePic_Product prod = db.profilepic_products.ToList()
                                          .Where(x => x.ID == prod_id && x.BusinessId == act.ActiveProfileID).FirstOrDefault();

                return(View(prod));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #30
0
        public ActionResult BusinessProfile(int id)
        {
            BusinessAccount b = db.businessaccounts.ToList().Where(x => x.ID == id).FirstOrDefault();

            if (b == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                string                    myid     = User.Identity.GetUserId();
                ActiveProfile             ac       = db.activeprofiles.ToList().Where(x => x.ApplicationUserId == myid).FirstOrDefault();
                List <ProfilePic_Product> products = db.profilepic_products.ToList()
                                                     .Where(x => x.BusinessId == b.ID).ToList();
                int  follows = db.follows.ToList().Where(x => x.BusinessID == b.ID).ToList().Count();
                bool iFollow = false;

                Follow f = db.follows.ToList()
                           .Where(x => x.BusinessID == b.ID && x.PersonalAccID == ac.ActiveProfileID)
                           .FirstOrDefault();
                if (f != null)
                {
                    iFollow = true;
                }

                ViewBag.iFollow      = iFollow;
                ViewBag.Followers    = follows;
                ViewBag.BusinessName = b.BusinessName;
                ViewBag.Type         = b.BusinessType;
                ViewBag.Website      = b.Website;
                ViewBag.Email        = b.Email;
                ViewBag.Phone        = b.Phone;
                ViewBag.Location     = b.Location;
                ViewBag.ID           = b.ID;
                ViewBag.MyID         = ac.ActiveProfileID;



                return(View(products));
            }
        }