Пример #1
0
        public static List <DashBoardItem> ToDashBoardList(this List <CustomerOrder> customerOrders)
        {
            List <DashBoardItem> list = new List <DashBoardItem>();

            try
            {
                foreach (var order in customerOrders)
                {
                    int amount = order.OrderDetails.Sum(od => (od.SalePrice * od.Quantity) - od.Discount);

                    var item = new DashBoardItem();
                    item.CustomerName = order.Customer.CustomerName;
                    item.CityName     = order.Customer.City.CityName;
                    item.OrderId      = order.Id;
                    item.DueAmount    = amount;

                    list.Add(item);
                }
                return(list);
            }
            catch
            {
                return(list);
            }
        }
Пример #2
0
        ///Creating Menu Items///
        private MenuItem CreateItem(DashBoardItem item)
        {
            MenuItem menuitem = new MenuItem();

            menuitem.Header = item.Name;
            if (item.isGroup)
            {
                foreach (DashBoardItem i in item.Items)
                {
                    if (i.Name.ToLower() == "---------")
                    {
                        MenuItem mnuitem = new MenuItem();
                        mnuitem.Header = new Separator();
                        menuitem.Items.Add(mnuitem);
                        // menuitem.Items.Add(new Separator());// { Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0)) }
                    }
                    else
                    {
                        menuitem.Items.Add(CreateItem(i));
                    }
                }
            }
            else
            {
                menuitem.Command          = item.Command;
                menuitem.CommandParameter = item.CommandParameter;
            }
            return(menuitem);
        }
        private void AddGetModelControlToGrid()
        {
            DashBoardItem dbi = ScoreCommand();

            modelcontrol = new GetModelsControl(dbi);
            scoringGrid.Children.Add(modelcontrol);
        }
        //21Jul2015 For creating toolbar dialog icons
        public List <DashBoardItem> GetDashBoardItems()//returns all DashBoardItems
        {
            List <DashBoardItem> alldashboardItems = new List <DashBoardItem>();

            //This 'idAttrValList' list is populated each time menus are generated i.e. when main window menus are generated
            //as well as when menus for each output window are generated from same menu.xml.
            //If we do not clean se what will happen:
            //say first menus are generated for main window (using menu.xml) and all the IDs from menu.xml are stored in idAttrValList.
            //Now when menus are generated again for OutputWindow1 (using menu.xml), the duplicate IDs will be seen but our duplicate
            //handler logic will postfix a number so as to make it unique and then stored in idAttrValList.
            //Say first time ID 'analysisMenu' was add for Analysis menu in the main window. Later for output window the ID will be
            // modified as analysisMenuXXX, where XXX is any number.
            //Now for output window we have a check to see if menu should be generated or not. That check is comparing hardcoded IDs
            // It is expecting that ID for say Analysis menu is 'analysisMenu' but our duplicate handling logic already renamed 'analysisMenu' ID
            // to analysisMenuXXX and comparison fails. And menu is not generated for outputwindow. This Happens for all the Output windows we try to open.
            //So we need to clear the idArrValList each time before generating menus for any next window.
            //
            //If in any case this starts behaving weird then find an appropriate place to clear this list or
            // put a separate list for each window(main or output(s))
            idAttrValList.Clear();

            document = new XmlDocument();
            bool success = false;

            try
            {
                document.Load(FileName);
                success = true;
            }
            catch (XmlException xe)
            {
                MessageBox.Show("XmlException while reading menu.xml");
                logService.WriteToLogLevel("XmlException.\n" + xe.StackTrace, LogLevelEnum.Fatal);
            }
            catch (DirectoryNotFoundException dnfe)
            {
                MessageBox.Show("DirectoryNotFoundException while reading menu.xml");
                logService.WriteToLogLevel("DirectoryNotFoundException.\n" + dnfe.StackTrace, LogLevelEnum.Fatal);
            }
            catch (FileNotFoundException fnfx)
            {
                MessageBox.Show("FileNotFoundException while reading menu.xml");
                logService.WriteToLogLevel("FileNotFoundException.\n" + fnfx.StackTrace, LogLevelEnum.Fatal);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception while reading menu.xml");
                logService.WriteToLogLevel("Exception.\n" + e.StackTrace, LogLevelEnum.Fatal);
            }
            if (success)
            {
                foreach (XmlNode nd in document.SelectNodes("//menus/*"))
                {
                    DashBoardItem item = CreateItem(nd);
                    alldashboardItems.Add(item);
                }
            }
            return(alldashboardItems);
        }
Пример #5
0
 private void InitializeLocalMenu(XmlDocument menuDocument)
 {
     foreach (XmlNode nd in menuDocument.SelectNodes("//menus/*"))
     {
         DashBoardItem item = CreateItem(nd);
         OnAddDashBoardItem(item);
     }
 }
        //Create Analysis Graphic and Data menu etc.
        private MenuItem CreateItem(DashBoardItem item)
        {
            bool enableDialog = true; //

            if (!item.isGroup)        // if its a command and not catagory(folder)
            {
                if (!_commcode.Equals("test"))
                {
                    if (!osdc.ContainsDialog(item)) //for Opensource
                    {
                        enableDialog = false;
                    }
                }
            }

            MenuItem menuitem = new MenuItem();

            menuitem.Header = item.Name;

            if (item.ID != null && item.ID.Trim().Length > 0 && !item.ID.Equals("new_id"))
            {
                menuitem.Name = RemoveSpecialCharsFromString(item.ID); //02Oct2017 remove special chars and then assign to Name property
            }

            if (item.isGroup)
            {
                foreach (DashBoardItem i in item.Items)
                {
                    if (i.Name.ToLower() == "---------")
                    {
                        if (menuitem.Items.Count > 0)//'if' added for line below. So separator is not the first item in menu
                        {
                            menuitem.Items.Add(new Separator());
                        }
                    }
                    else
                    {
                        MenuItem dlgmi = CreateItem(i);
                        if (dlgmi != null)
                        {
                            menuitem.Items.Add(dlgmi);
                        }
                    }
                }
            }
            else
            {
                menuitem.Command          = item.Command;
                menuitem.IsEnabled        = enableDialog;
                menuitem.CommandParameter = item.CommandParameter;
                if (AdvancedLogging)
                {
                    logService.WriteToLogLevel("Menu item :" + menuitem.Name + ": Enable = " + enableDialog, LogLevelEnum.Info);                 //21Jun2016
                }
            }
            return(menuitem);
        }
Пример #7
0
        IUIController UIController;        //for getting active dataset and filename.

        public CommandHistoryMenuHandler() //This constructor is meant to used for Main App only
        {
            //Giving error here UIController = LifetimeService.Instance.Container.Resolve<IUIController>();
            DashBoardItem item = new DashBoardItem();

            item.Command          = null;
            item.CommandParameter = null;
            item.isGroup          = true;
            item.Name             = BSky.GlobalResources.Properties.UICtrlResources.HistoryMenuName;// MenuName
            item.Items            = new List <DashBoardItem>();

            commandhistmenu = CreateItem(item);
        }
        public GetModelsControl(DashBoardItem item)
        {
            InitializeComponent();
            UIController = LifetimeService.Instance.Container.Resolve <IUIController>();
            RefreshModelClassList();

            //binding score dialog (Make Predictions) to score button
            scoreButton.Command          = item.Command;
            scoreButton.CommandParameter = item.CommandParameter;

            //set initial value
            //classtypecombo.SelectedIndex = 0; //18Sep2017 Bsky crashes during launch if you do this here
        }
Пример #9
0
        public ActionResult Index()
        {
            DashBoardItem di = new DashBoardItem();

            int testEmpId = 5;

            var work = db.Works.Where(s => s.EmpID == testEmpId);

            if (work.Count() > 0)
            {
                di.personalPlayed = work.Sum(s => s.CustomerPlayWith);
                di.personalSale   = work.Sum(s => s.Sold);
            }
            else
            {
                di.personalPlayed = 0;
                di.personalSale   = 0;
            }
            var customer = db.Customers.Where(s => s.EmpID == testEmpId);

            if (customer.Count() > 0)
            {
                di.personalInfoCollected = customer.Count();
            }
            else
            {
                di.personalInfoCollected = 0;
            }

            int campaignId = 1;
            var campaign   = db.Works.Where(s => s.CamID == campaignId);

            if (campaign.Count() > 0)
            {
                di.campaignPlayed = campaign.Sum(s => s.CustomerPlayWith);
                di.campaignSale   = campaign.Sum(s => s.Sold);
            }
            customer = db.Customers.Where(s => s.CamID == campaignId);
            if (customer.Count() > 0)
            {
                di.campaignInfoColleted = customer.Count();
            }
            else
            {
                di.campaignInfoColleted = 0;
            }

            di.totalAccount = db.Employees.Count();

            return(View(di));
        }
        public bool ContainsDialog(DashBoardItem di)
        {
            UAMenuCommand uamc = (UAMenuCommand)di.CommandParameter; //BlueSky.Services.UAMenuCommand
            string        name = (uamc.commandtemplate != null && uamc.commandtemplate.Length > 1) ? uamc.commandtemplate : uamc.text;

            if (_dialoglist.Contains(name))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
 protected virtual bool OnAddDashBoardItem(DashBoardItem item)
 {
     if (AddDashBoardItem != null)
     {
         DashBoardEventArgs args = new DashBoardEventArgs();
         args.DashBoardItem = item;
         AddDashBoardItem(this, args);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #12
0
        List <Microcharts.Entry> GetEntries(DashBoardItem dashboard)
        {
            var entries = new List <Microcharts.Entry>();

            foreach (var serie in dashboard.Series)
            {
                entries.Add(new Microcharts.Entry(serie.Value)
                {
                    Label      = serie.Label,
                    ValueLabel = serie.ValueLabel,
                    Color      = SKColor.Parse(serie.Color)
                });
            }
            return(entries);
        }
        /// <summary>
        /// Creating clone of Output menu from App's main window. The section that shows names of each output window in current session.
        /// </summary>
        private void CreateClone()//List<DashBoardItem> di)
        {
            MenuItem output_menu = null;

            if (allOutputMenus.Count > 0)
            {
                output_menu = allOutputMenus[0];//grab the first menu.(this should be from Apps main window)
            }
            if (output_menu.Header.ToString() == BSky.GlobalResources.Properties.Resources.OutputMenu)
            {
                MenuItem mi1 = null;
                //Separator spr;
                foreach (object objmi in output_menu.Items)    /// windownames
                {
                    if (objmi.GetType().Name == "MenuItem")
                    {
                        mi1 = objmi as MenuItem;
                    }
                    //else if (objmi.GetType().Name == "Separator")
                    //    spr = objmi as Separator;

                    /// default items are already being created ///
                    if (mi1 != null && (mi1.Header.ToString().Equals(BSky.GlobalResources.Properties.Resources.NewOutputWin) ||
                                        mi1.Header.ToString().Equals(BSky.GlobalResources.Properties.Resources.OpenOutput) ||
                                        mi1.Header.ToString().Equals(BSky.GlobalResources.Properties.Resources.SaveOutput)) ||
                        (objmi.GetType().Name == "Separator"))
                    {
                        continue;
                    }
                    //////creating clone////
                    DashBoardItem item = new DashBoardItem();
                    item.Command = new SelectOutputWindowCommand();

                    UAMenuCommand uamc = new UAMenuCommand();         //01Aug2012. There was no 'new' before
                    uamc.commandformat       = mi1.Header.ToString(); //window name is key. Action shud b taken on this.
                    uamc.commandoutputformat = ""; uamc.commandtemplate = ""; uamc.commandtype = "";
                    item.CommandParameter    = uamc;

                    item.isGroup = false;
                    item.Name    = mi1.Header.ToString(); //this should also be the key
                    MenuItem createdmi = CreateItem(item);
                    createdmi.Icon = mi1.Icon;

                    outputmenu.Items.Add(createdmi);
                }
            }
        }
Пример #14
0
        private DashBoardItem CreateItem(XmlNode node)
        {
            DashBoardItem item = new DashBoardItem();

            item.Name    = GetAttributeString(node, "text");
            item.isGroup = node.HasChildNodes;

            if (node.HasChildNodes)
            {
                item.Items = new List <DashBoardItem>();
                foreach (XmlNode child in node.ChildNodes)
                {
                    item.Items.Add(CreateItem(child));
                }
            }
            else
            {
                UAMenuCommand cmd = new UAMenuCommand();
                cmd.commandtype = GetAttributeString(node, "command");
                if (string.IsNullOrEmpty(cmd.commandtype))
                {
                    cmd.commandtype = typeof(AUAnalysisCommandBase).FullName;
                }
                cmd.commandtemplate     = GetAttributeString(node, "commandtemplate");
                cmd.commandformat       = GetAttributeString(node, "commandformat");
                cmd.commandoutputformat = GetAttributeString(node, "commandoutputformat");
                cmd.text = GetAttributeString(node, "text"); //04mar2013
                //cmd.id = GetAttributeString(node, "id"); //04mar2013
                //cmd.owner = GetAttributeString(node, "owner"); //04mar2013
                item.Command          = CreateCommand(cmd);
                item.CommandParameter = cmd;

                #region 11Jun2015 Set icon fullpathfilename
                item.iconfullpathfilename = GetAttributeString(node, "icon");
                string showicon = GetAttributeString(node, "showtoolbaricon");
                if (showicon == null || showicon.Trim().Length == 0 || !showicon.ToLower().Equals("true"))
                {
                    item.showshortcuticon = false;
                }
                else
                {
                    item.showshortcuticon = true;
                }
                #endregion
            }
            return(item);
        }
Пример #15
0
        //Add executed command per Dataset
        public void AddCommand(string DatasetName, UAMenuCommand Command)
        {
            //Creating a copy of command for putting it in "History" menu
            UAMenuCommand uamc = new UAMenuCommand(); // new obj needed, because same obj can't be child at two places.

            uamc.commandformat       = Command.commandformat;
            uamc.commandoutputformat = Command.commandoutputformat;
            uamc.commandtemplate     = Command.commandtemplate;
            uamc.commandtype         = Command.commandtype;
            //29Mar2013 //If History Menu text is not present. Dont add this command to "History" menu
            if (Command.text == null || Command.text.Length < 1)
            {
                return;
            }
            uamc.text = Command.text;//Command name shown in "History" menu

            //now create menuitem for each command and add to "History" menu
            DashBoardItem item = new DashBoardItem();

            item.Command          = new AUAnalysisCommandBase(); // should point to AUAnalysisCommandBase
            item.CommandParameter = uamc;
            item.isGroup          = false;
            item.Name             = uamc.text;// MenuName
            MenuItem newmi = CreateItem(item);

            //Check if command already in history menu ///
            bool ExistsInHistory = false;
            int  miIndex         = 0;

            foreach (MenuItem mi in commandhistmenu.Items)
            {
                if (mi.Header == newmi.Header)//command already in History
                {
                    ExistsInHistory = true;
                    break;
                }
                miIndex++;
            }

            // Adding command with "latest executed on top" in menu ///
            if (ExistsInHistory)
            {
                commandhistmenu.Items.RemoveAt(miIndex);
            }
            commandhistmenu.Items.Insert(0, newmi);//Adding to "History" menu
        }
        //this is binding the 'Make Predictions' dialog to 'Score' button in GetModelsControl control.
        private DashBoardItem ScoreCommand()
        {
            DashBoardItem item = new DashBoardItem();
            UAMenuCommand cmd  = new UAMenuCommand();

            cmd.commandtype = "BlueSky.Commands.Analytics.TTest.AUAnalysisCommandBase";

            cmd.commandtemplate     = BSkyAppData.RoamingUserBSkyConfigL18nPath + "Make Predictions.xaml";
            cmd.commandformat       = "";
            cmd.commandoutputformat = BSkyAppData.RoamingUserBSkyConfigL18nPath + "Make Predictions.xml";
            cmd.text = "Make Predictions";

            item.Command          = CreateCommand(cmd);
            item.CommandParameter = cmd;

            return(item);
        }
        public OutputMenuHandler() //This constructor is meant to used for Main App only
        {
            DashBoardItem item = new DashBoardItem();

            item.Command          = null;
            item.CommandParameter = null;
            item.isGroup          = true;
            item.Name             = BSky.GlobalResources.Properties.Resources.OutputMenu;//"Output";// MenuName
            item.Items            = new List <DashBoardItem>();

            outputmenu = CreateItem(item);
            allOutputMenus.Add(outputmenu); //adding output menu to common list
            //15Aug2019 AddDefaultOutputMenuItem();//NEW and OPEN output in the FILE menu. SAVE dropped.
            if (allOutputMenus.Count > 1)   // first item is the output menu from App's main window. When App launches, it is first one to create Output menu
            {
                CreateClone();              /// for newly opened Syntax Editor window ///
            }
        }
Пример #18
0
        public OutputMenuHandler() //This constructor is meant to used for Main App only
        {
            DashBoardItem item = new DashBoardItem();

            item.Command          = null;
            item.CommandParameter = null;
            item.isGroup          = true;
            item.Name             = "Output";// MenuName
            item.Items            = new List <DashBoardItem>();

            outputmenu = CreateItem(item);
            allOutputMenus.Add(outputmenu); //adding output menu to common list
            AddDefaultOutputMenuItem();
            if (allOutputMenus.Count > 1)   // first item is the output menu from App's main window. When App launches, it is first one to create Output menu
            {
                CreateClone();              /// for newly opened Syntax Editor window ///
            }
        }
        ///// Add Default items in Output Menu ////
        private void AddDefaultOutputMenuItem()//string outwindowname)
        {
            ///New Output////
            DashBoardItem item = new DashBoardItem();

            item.Command = new NewOutputWindow();
            item.Name    = BSky.GlobalResources.Properties.Resources.NewOutputWin;
            item.isGroup = false;
            outputmenu.Items.Add(CreateItem(item));

            ////Open Output/////
            DashBoardItem item2 = new DashBoardItem();

            item2.Command = new OutputOpenCommand();
            item2.Name    = BSky.GlobalResources.Properties.Resources.OpenOutput;
            item2.isGroup = false;
            outputmenu.Items.Add(CreateItem(item2));

            ////Save Output/////Output menu 'll hv "Save output" option in App's Main window.Other windows will not (like Syn Edtr window) hv.
            //count = 0 in begining. But when App's main window is shown count will become 1. That means 1 Output menu exists and thats
            // in App's Main window. Later when Syntax Editor window is shown Output count is not == 1 so "Save Output" is not created.
            if (allOutputMenus.Count == 1)
            {
                DashBoardItem item3 = new DashBoardItem();
                item3.Command = new OutputSaveAsCommand();
                item3.Name    = BSky.GlobalResources.Properties.Resources.SaveOutput;
                item3.isGroup = false;
                outputmenu.Items.Add(CreateItem(item3));
            }

            ///Adding separator////
            //MenuItem menuitem = new MenuItem();
            //menuitem.Header = new Separator();
            //outputmenu.Items.Add(menuitem);

            //MenuItem menuitem = new MenuItem();
            //menuitem.Header = "";
            //menuitem.Items.Add(new Separator());
            //outputmenu.Items.Add(menuitem);

            outputmenu.Items.Add(new Separator());
        }
        ///Creating Menu Items///
        private MenuItem CreateItem(DashBoardItem item)
        {
            MenuItem menuitem = new MenuItem();

            menuitem.Header = item.Name;
            if (item.isGroup)
            {
                foreach (DashBoardItem i in item.Items)
                {
                    if (i.Name.ToLower() == "---------")
                    {
                        //MenuItem mnuitem = new MenuItem();
                        //mnuitem.Header = new Separator();
                        //if (menuitem.Items.Count > 0) //'if' added for line below. So separator is not the first item in menu
                        //    menuitem.Items.Add(mnuitem);

                        if (menuitem.Items.Count > 0) //'if' added for line below. So separator is not the first item in menu
                        {
                            menuitem.Items.Add(new Separator());
                        }

                        //Separator spr = new Separator();
                        //spr.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0, 0, 0));
                        //spr.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0, 0xFF, 0));
                        //spr.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0));
                        //spr.Margin = new System.Windows.Thickness(3);
                        //menuitem.Items.Add(spr);
                        //menuitem.ItemContainerStyle = new System.Windows.Style(
                    }
                    else
                    {
                        menuitem.Items.Add(CreateItem(i));
                    }
                }
            }
            else
            {
                menuitem.Command          = item.Command;
                menuitem.CommandParameter = item.CommandParameter;
            }
            return(menuitem);
        }
Пример #21
0
        //21Jul2015 For creating toolbar dialog icons
        public List <DashBoardItem> GetDashBoardItems()//returns all DashBoardItems
        {
            List <DashBoardItem> alldashboardItems = new List <DashBoardItem>();

            document = new XmlDocument();
            bool success = false;

            try
            {
                document.Load(FileName);
                success = true;
            }
            catch (XmlException xe)
            {
                MessageBox.Show("XmlException while reading menu.xml");
                logService.WriteToLogLevel("XmlException.\n" + xe.StackTrace, LogLevelEnum.Fatal);
            }
            catch (DirectoryNotFoundException dnfe)
            {
                MessageBox.Show("DirectoryNotFoundException while reading menu.xml");
                logService.WriteToLogLevel("DirectoryNotFoundException.\n" + dnfe.StackTrace, LogLevelEnum.Fatal);
            }
            catch (FileNotFoundException fnfx)
            {
                MessageBox.Show("FileNotFoundException while reading menu.xml");
                logService.WriteToLogLevel("FileNotFoundException.\n" + fnfx.StackTrace, LogLevelEnum.Fatal);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception while reading menu.xml");
                logService.WriteToLogLevel("Exception.\n" + e.StackTrace, LogLevelEnum.Fatal);
            }
            if (success)
            {
                foreach (XmlNode nd in document.SelectNodes("//menus/*"))
                {
                    DashBoardItem item = CreateItem(nd);
                    alldashboardItems.Add(item);
                }
            }
            return(alldashboardItems);
        }
Пример #22
0
        /// <summary>
        /// Creating clone of Output menu from App's main window. The section that shows names of each output window in current session.
        /// </summary>
        private void CreateClone()//List<DashBoardItem> di)
        {
            MenuItem output_menu = null;

            if (allOutputMenus.Count > 0)
            {
                output_menu = allOutputMenus[0];//grab the first menu.(this should be from Apps main window)
            }
            if (output_menu.Header.ToString() == "Output")
            {
                foreach (MenuItem mi in output_menu.Items)    /// windownames
                {
                    /// default items are already being created ///
                    if (mi.Header.ToString().Equals("New Output Window") ||
                        mi.Header.ToString().Equals("Open Output") ||
                        mi.Header.ToString().Equals("Save Output") ||
                        mi.Header.GetType() == typeof(Separator))
                    {
                        continue;
                    }
                    //////creating clone////
                    DashBoardItem item = new DashBoardItem();
                    item.Command = new SelectOutputWindowCommand();

                    UAMenuCommand uamc = new UAMenuCommand();        //01Aug2012. There was no 'new' before
                    uamc.commandformat       = mi.Header.ToString(); //window name is key. Action shud b taken on this.
                    uamc.commandoutputformat = ""; uamc.commandtemplate = ""; uamc.commandtype = "";
                    item.CommandParameter    = uamc;

                    item.isGroup = false;
                    item.Name    = mi.Header.ToString(); //this should also be the key
                    MenuItem createdmi = CreateItem(item);
                    createdmi.Icon = mi.Icon;

                    outputmenu.Items.Add(createdmi);
                }
            }
        }
        //// Adding new output windows ////
        public void AddOutputMenuItem(string outwindowname)
        {
            DashBoardItem item = new DashBoardItem();

            item.Command = new SelectOutputWindowCommand();

            UAMenuCommand uamc = new UAMenuCommand(); //01Aug2012. There was no 'new' before

            uamc.commandformat       = outwindowname; //window name is key. Action shud b taken on this.
            uamc.commandoutputformat = ""; uamc.commandtemplate = ""; uamc.commandtype = "";
            item.CommandParameter    = uamc;

            item.isGroup = false;
            item.Name    = outwindowname;//this should also be the key

            foreach (MenuItem output_menu in allOutputMenus)
            {
                if (output_menu.Header.ToString() == BSky.GlobalResources.Properties.Resources.OutputMenu)
                {
                    output_menu.Items.Add(CreateItem(item));
                }
            }
            CheckOutputMenuItem(outwindowname);//putting a check or alphabet to show which one is active
        }
Пример #24
0
        //Adds all menus and submenu items. But not history or output menu.
        void dashBoardService_AddDashBoardItem(object sender, DashBoardEventArgs e)
        {
            DashBoardItem item = e.DashBoardItem;

            _menu.Items.Add(CreateItem(item));
        }
Пример #25
0
        public ActionResult Index()
        {
            DashBoardItem di = new DashBoardItem();

            string          currentUserId = User.Identity.GetUserId();
            ApplicationUser currentUser   = (db.Users.Include(r => r.Employee).Include(r => r.Employee.Campaigns).FirstOrDefault(x => x.Id == currentUserId));

            int empID = currentUser.Employee.EmpID;

            var work = db.Works.Where(s => s.EmpID == empID);

            if (work.Count() > 0)
            {
                di.personalPlayed = work.Sum(s => s.CustomerPlayWith);
                di.personalSale   = work.Sum(s => s.Sold);
            }
            else
            {
                di.personalPlayed = 0;
                di.personalSale   = 0;
            }
            var customer = db.Customers.Where(s => s.EmpID == empID);

            if (customer.Count() > 0)
            {
                di.personalInfoCollected = customer.Count();
            }
            else
            {
                di.personalInfoCollected = 0;
            }

            var todayCam = currentUser.GetTodaysCampaign();

            if (todayCam == null)
            {
                di.campaignPlayed       = 0;
                di.campaignSale         = 0;
                di.campaignInfoColleted = 0;
            }
            else
            {
                int campaignId = todayCam.CamID;
                var campaign   = db.Works.Where(s => s.CamID == campaignId);
                if (campaign.Count() > 0)
                {
                    di.campaignPlayed = campaign.Sum(s => s.CustomerPlayWith);
                    di.campaignSale   = campaign.Sum(s => s.Sold);
                }
                customer = db.Customers.Where(s => s.CamID == campaignId);
                if (customer.Count() > 0)
                {
                    di.campaignInfoColleted = customer.Count();
                }
                else
                {
                    di.campaignInfoColleted = 0;
                }
            }

            di.totalAccount = db.Employees.Count();

            return(View(di));
        }
Пример #26
0
        public ActionResult Index()
        {
            DashBoardItem di = new DashBoardItem();

            string          currentUserId = User.Identity.GetUserId();
            ApplicationUser currentUser   = (db.Users.Include(r => r.Employee).Include(r => r.Employee.Campaigns).FirstOrDefault(x => x.Id == currentUserId));


            int empID = currentUser.Employee.EmpID;

            di.personalStat.role  = currentUser.Employee.Role;
            di.personalStat.name  = currentUser.Employee.EmpName;
            di.personalStat.decks = currentUser.Employee.DecksOnHand;

            //Ambassdor per day
            var work = db.Works.Where(s => s.EmpID == empID && s.Date == DateTime.Today);

            if (work.Count() > 0)
            {
                di.personalStat.playedPerDay       = work.Sum(s => s.CustomerPlayWith);
                di.personalStat.salePerDay         = work.Sum(s => s.Sold);
                di.personalStat.closingRatioPerDay = getClosingRatio(di.personalStat.salePerDay, di.personalStat.playedPerDay);
            }

            //Ambassdor per campaign
            var todayCam = currentUser.GetTodaysCampaign();

            if (todayCam != null)
            {
                di.personalStat.assignedToCampaign = true;
                work = db.Works.Where(s => s.EmpID == empID && s.CamID == todayCam.CamID);
                if (work.Count() > 0)
                {
                    di.personalStat.playedPerCampaign       = work.Sum(s => s.CustomerPlayWith);
                    di.personalStat.salePerCampaign         = work.Sum(s => s.Sold);
                    di.personalStat.closingRatioPerCampaign = getClosingRatio(di.personalStat.salePerCampaign, di.personalStat.playedPerCampaign);
                }
            }

            //Ambassdor overall
            work = db.Works.Where(s => s.EmpID == empID);
            if (work.Count() > 0)
            {
                di.personalStat.playedOverall       = work.Sum(s => s.CustomerPlayWith);
                di.personalStat.saleOverall         = work.Sum(s => s.Sold);
                di.personalStat.closingRatioOverall = getClosingRatio(di.personalStat.saleOverall, di.personalStat.playedOverall);
            }

            //Exit for ambassdor
            if (currentUser.Employee.Role == Role.AMBASSADOR)
            {
                return(View(di));
            }

            //Manager Overall
            var list = db.Works.ToList();

            if (list.Count() > 0)
            {
                di.overallPlayed       = list.Sum(s => s.CustomerPlayWith);
                di.overallSale         = list.Sum(s => s.Sold);
                di.overallClosingRatio = getClosingRatio(di.overallSale, di.overallPlayed);
            }

            //Manager list of campaigns
            var campaigns = db.Campaigns.ToList();

            List <string> campaignNames          = new List <string>();
            List <int>    campaignInventory      = new List <int>();
            List <int>    campaignSales          = new List <int>();
            List <int>    campaignPlayeds        = new List <int>();
            List <double> campaignClosingRatioes = new List <double>();

            foreach (var c in campaigns)
            {
                campaignNames.Add(c.CamName);
                campaignInventory.Add(c.Inventory);

                var cam = db.Works.Where(s => s.CamID == c.CamID).ToList();
                if (cam.Count() > 0)
                {
                    campaignPlayeds.Add(cam.Sum(s => s.CustomerPlayWith));
                    campaignSales.Add(cam.Sum(s => s.Sold));
                    campaignClosingRatioes.Add(getClosingRatio(campaignSales.Last(), campaignPlayeds.Last()));
                }
                else
                {
                    campaignPlayeds.Add(0);
                    campaignSales.Add(0);
                    campaignClosingRatioes.Add(0);
                }
            }
            di.campaignNames          = campaignNames;
            di.campaignInventory      = campaignInventory;
            di.campaignSales          = campaignSales;
            di.campaignPlayeds        = campaignPlayeds;
            di.campaignClosingRatioes = campaignClosingRatioes;

            //Exit for manager
            if (currentUser.Employee.Role == Role.MANAGER)
            {
                return(View(di));
            }

            //Employee list for Admin

            var employees = db.Employees.ToList();
            var works     = db.Works.ToList();
            var account   = db.Users.ToList();

            List <EmployeeStat> employeeStats = new List <EmployeeStat>();

            foreach (var a in account)
            {
                var          e  = a.Employee;
                EmployeeStat es = new EmployeeStat();
                es.name  = e.EmpName;
                es.role  = e.Role;
                es.decks = e.DecksOnHand;

                //Ambassdor per day
                work = db.Works.Where(s => s.EmpID == e.EmpID && s.Date == DateTime.Today);
                if (work.Count() > 0)
                {
                    es.playedPerDay       = work.Sum(s => s.CustomerPlayWith);
                    es.salePerDay         = work.Sum(s => s.Sold);
                    es.closingRatioPerDay = getClosingRatio(es.salePerDay, es.playedPerDay);
                }

                //Ambassdor per campaign
                todayCam = e.GetTodaysCampaign();
                if (todayCam != null)
                {
                    es.assignedToCampaign = true;
                    work = db.Works.Where(s => s.EmpID == e.EmpID && s.CamID == todayCam.CamID);
                    if (work.Count() > 0)
                    {
                        es.playedPerCampaign       = work.Sum(s => s.CustomerPlayWith);
                        es.salePerCampaign         = work.Sum(s => s.Sold);
                        es.closingRatioPerCampaign = getClosingRatio(es.salePerCampaign, es.playedPerCampaign);
                    }
                }

                //Ambassdor overall
                work = db.Works.Where(s => s.EmpID == e.EmpID);
                if (work.Count() > 0)
                {
                    es.playedOverall       = work.Sum(s => s.CustomerPlayWith);
                    es.saleOverall         = work.Sum(s => s.Sold);
                    es.closingRatioOverall = getClosingRatio(es.saleOverall, es.playedOverall);
                }
                employeeStats.Add(es);
            }
            di.employeeStats = employeeStats;

            //Exit for admin
            return(View(di));
        }
        private DashBoardItem CreateItem(XmlNode node)
        {
            DashBoardItem item = new DashBoardItem();

            item.ID      = GetAttributeString(node, "id");//02Oct2017
            item.Name    = GetAttributeString(node, "text");
            item.isGroup = node.HasChildNodes;

            if (node.HasChildNodes)
            {
                item.Items = new List <DashBoardItem>();
                foreach (XmlNode child in node.ChildNodes)
                {
                    item.Items.Add(CreateItem(child));
                }
            }
            else
            {
                UAMenuCommand cmd = new UAMenuCommand();
                cmd.commandtype = GetAttributeString(node, "command");
                if (string.IsNullOrEmpty(cmd.commandtype))
                {
                    cmd.commandtype = typeof(AUAnalysisCommandBase).FullName;
                }

                //09Oct2017
                //First we need to convert dialogs for support localization. Say for supporting German (de-DE) first
                //the source dialogs must be opened in Dialog Designer and saved after changing to German.
                //Then Using Dialog-Installer user with German locale should install the dialogs by Overwriting the
                //exisitng ones. This will overwrite the dialogs in 'Config/de-DE' folder replacing US dialogs.
                //Now about the following code:
                //During developement and testing phase we need postfix CulterName below But ones the German user overwrite-install
                //his dialogs the menu.xml will have 'de-DE' included in menu.xml for XAML/XML location (which was not there and
                //so we postfixed CultureName). Now after overwriting dialogs by German user we do not need CulterName postfixed.
                //So we can achieve this in two ways:
                //1) In Develop/Test phase keep the CultureName in following and once German Dialogs are installed/overwritten
                //then we can drop this CulterName postfix because now menu.xml will inculde 'de-De' for XAML/XML dialog path.
                //2) In this method we need to check if commandtemplate/commandoutputformat in following have two '/' or three '/'
                //if there are two '/' that means language foldernames are not yet included, so postfix CultureName.
                //If there ar three '/' that means language folder name is included and there is not need to postfix with CultureName.
                //
                string dialogPath  = BSkyAppData.RoamingUserBSkyConfigPath + CultureName;
                string CmdTemplate = GetAttributeString(node, "commandtemplate");
                //if (CountCharacter(CmdTemplate, '/') == 2)
                //{
                //    cmd.commandtemplate = GetAttributeString(node, "commandtemplate").Replace("/Config", "/Config/" + CultureName);
                //}
                //else
                //{
                //    cmd.commandtemplate = GetAttributeString(node, "commandtemplate");
                //}
                //cmd.commandtemplate=cmd.commandtemplate.Replace("./Config", BSkyAppData.RoamingUserBSkyConfigPath);
                cmd.commandtemplate = string.Format(@"{0}\{1}", dialogPath, CmdTemplate);

                string CmdOutTemplate = GetAttributeString(node, "commandoutputformat");
                //if (CountCharacter(CmdTemplate, '/') == 2)
                //{
                //    cmd.commandoutputformat = GetAttributeString(node, "commandoutputformat").Replace("/Config", "/Config/" + CultureName);
                //}
                //else
                //{
                //    cmd.commandoutputformat = GetAttributeString(node, "commandoutputformat");
                //}
                //cmd.commandoutputformat = cmd.commandoutputformat.Replace("./Config", BSkyAppData.RoamingUserBSkyConfigPath);
                cmd.commandoutputformat = string.Format(@"{0}\{1}", dialogPath, CmdOutTemplate);


                //cmd.commandtemplate = GetAttributeString(node, "commandtemplate");//no localization
                //if-else above  cmd.commandtemplate = GetAttributeString(node, "commandtemplate").Replace("/Config", "/Config/"+CultureName);

                //cmd.commandoutputformat = GetAttributeString(node, "commandoutputformat");//no localization
                //if-else above  cmd.commandoutputformat = GetAttributeString(node, "commandoutputformat").Replace("/Config", "/Config/" + CultureName);

                cmd.commandformat = GetAttributeString(node, "commandformat");

                cmd.text = GetAttributeString(node, "text"); //04mar2013
                //cmd.id = GetAttributeString(node, "id"); //04mar2013
                //cmd.owner = GetAttributeString(node, "owner"); //04mar2013
                item.Command          = CreateCommand(cmd);
                item.CommandParameter = cmd;

                #region 11Jun2015 Set icon fullpathfilename
                item.iconfullpathfilename = GetAttributeString(node, "icon");
                string showicon = GetAttributeString(node, "showtoolbaricon");
                if (showicon == null || showicon.Trim().Length == 0 || !showicon.ToLower().Equals("true"))
                {
                    item.showshortcuticon = false;
                }
                else
                {
                    item.showshortcuticon = true;
                }
                #endregion
            }
            return(item);
        }
        //21Jun2015 Adds analysis dialog icon to toolbar
        private void AddToolbarIcon(DashBoardItem item)
        {
            if (item.Items != null && item.Items.Count > 0)//Parent Node
            {
                foreach (DashBoardItem dbi in item.Items)
                {
                    AddToolbarIcon(dbi);
                }
            }
            else
            {
                if (item.showshortcuticon)
                {
                    string icontooltip = item.Name;
                    string imgsource   = item.iconfullpathfilename;
                    if (!File.Exists(imgsource))
                    {
                        imgsource = "images/noimage.png";
                    }

                    bool enableDialog = true;
                    if (!item.isGroup)
                    {
                        if (!_commcode.Equals("test"))
                        {
                            if (!osdc.ContainsDialog(item))
                            {
                                enableDialog = false;
                            }
                        }
                    }
                    Button iconButton = new Button();
                    if (enableDialog)
                    {
                        iconButton.Command          = item.Command;
                        iconButton.CommandParameter = item.CommandParameter;//all XAML XML info
                    }
                    iconButton.IsEnabled = enableDialog;
                    if (AdvancedLogging)
                    {
                        logService.WriteToLogLevel("icon: " + item.Name + ": Enable = " + enableDialog, LogLevelEnum.Info);                 //21Jun2016
                    }
                    StackPanel sp = new StackPanel();

                    #region create icon
                    Image iconImage = new Image();
                    iconImage.ToolTip = icontooltip;
                    var bitmap = new BitmapImage();
                    try
                    {
                        var stream = File.OpenRead(imgsource);
                        bitmap.BeginInit();
                        bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                        bitmap.StreamSource = stream;
                        bitmap.EndInit();
                        stream.Close();
                        stream.Dispose();
                        iconImage.Source = bitmap;
                        bitmap.StreamSource.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                    #endregion

                    //add to stackpanel
                    sp.Children.Add(iconImage);

                    //add stackpanel to button content
                    iconButton.Content = sp;

                    //add iconbutton to toolbar
                    _dialogtoolbar.Items.Add(iconButton);
                }
            }
        }
Пример #29
0
        //11Jun2015 Adds analysis dialog icon to toolbar
        private void AddToolbarIcon(DashBoardItem item)
        {
            if (item.showshortcuticon)
            {
                string icontooltip = item.Name;
                string imgsource   = item.iconfullpathfilename;
                if (!File.Exists(imgsource))
                {
                    imgsource = "images/noimage.png";
                }

                bool enableDialog = true; //
                if (!item.isGroup)
                {
                    if (!_commcode.Equals("test"))
                    {
                        if (!osdc.ContainsDialog(item))
                        {
                            enableDialog = false;
                        }
                    }
                }

                Button iconButton = new Button();
                if (enableDialog)
                {
                    iconButton.Command          = item.Command;
                    iconButton.CommandParameter = item.CommandParameter;//all XAML XML info
                }
                iconButton.IsEnabled = enableDialog;

                StackPanel sp = new StackPanel();

                #region create icon
                Image iconImage = new Image();

                iconImage.ToolTip = icontooltip;
                var bitmap = new BitmapImage();
                try
                {
                    var stream = File.OpenRead(imgsource);
                    bitmap.BeginInit();
                    bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmap.StreamSource = stream;
                    bitmap.EndInit();
                    stream.Close();
                    stream.Dispose();
                    iconImage.Source = bitmap;
                    bitmap.StreamSource.Close();
                }
                catch (Exception ex)
                {
                }
                #endregion

                //add to stackpanel
                sp.Children.Add(iconImage);

                //add stackpanel to button content
                iconButton.Content = sp;

                //add iconbutton to toolbar
                _mainToolbar.Items.Add(iconButton);
            }
        }