public ActionResult ItemTrendAnalysisReport()
        {
            string                     token     = GetToken();
            DepartmentModel            dm        = new DepartmentModel();
            string                     error     = "";
            ItemTrendAnalysisViewModel viewmodel = new ItemTrendAnalysisViewModel();

            List <DepartmentModel> mm = APIDepartment.GetAllDepartments(token, out error);

            viewmodel.itd = new List <ItemTrendDetailViewModel>();



            foreach (DepartmentModel m in mm)
            {
                var result = new ItemTrendDetailViewModel();
                result.d1     = m.Deptid;
                result.d2     = m.Deptid;
                result.d3     = m.Deptid;
                result.d1Name = m.Deptname;
                result.d2Name = m.Deptname;
                result.d3Name = m.Deptname;
                viewmodel.itd.Add(result);
            }
            ViewBag.catlist  = APICategory.GetAllCategories(token, out error);
            ViewBag.deptlist = APIDepartment.GetAllDepartments(token, out error);
            ViewBag.count    = 0;
            return(View(viewmodel));
        }
Esempio n. 2
0
        public JsonResult DeleteCategory(APICategory _category)
        {
            var restResult = new RestModel();

            try
            {
                category updateModel = new Models.category();

                updateModel = db.categories.Find(_category.id);

                updateModel.is_deleted = 1;

                db.Entry(updateModel).State = EntityState.Modified;
                db.SaveChanges();

                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }

            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
        private void addItem(string catName, string itemName, bool isFunction)
        {
            if (catName != null)
            {
                //Check if the category already exists
                bool doesCategoryExist = false;
                int  index             = -1;

                for (int i = 0; i < this.Categories.Count; i++)
                {
                    if (this.Categories[i].name.Equals(catName))
                    {
                        doesCategoryExist = true;
                        index             = i;
                        break;
                    }
                }

                if (doesCategoryExist == true)
                {
                    this.Categories[index].Items.Add(new APIItem(itemName, isFunction));
                }
                else
                {
                    APICategory cat = new APICategory(catName);
                    cat.Items.Add(new APIItem(itemName, isFunction));
                    this.Categories.Add(cat);
                }
            }
            else
            {
                this.Items.Add(new APIItem(itemName, isFunction));
            }
        }
Esempio n. 4
0
 public APIUnit(int pid, string function, APIType type, APICategory category, APIID id)
 {
     Function  = function.Split('!')[1];
     ProcessID = pid;
     Category  = category;
     Type      = type;
     ID        = id;
 }
 //----------------------------------------------------------
 //--------------------- METHODES ---------------------------
 //----------------------------------------------------------
 public void resetCurrentWord()
 {
     this.CurrentWord      = "";
     isActive              = true;
     this.isInACategory    = false;
     this.CategorySelected = null;
     showFunctions         = false;
 }
Esempio n. 6
0
 public SequenceUnit(APICategory cat, APIUnit api, List <APIUnit> consumers)
 {
     Category  = cat;
     API       = api;
     Consumers = new List <APIUnit>();
     if (consumers != null && consumers.Count > 0)
     {
         Consumers.AddRange(consumers);
     }
 }
        public ActionResult Parts(int id = 0, int page = 1, int per_page = 10)
        {
            if (id > 0) {
                APICategory category = new APICategory();

                category = CURTAPI.GetCategory(id);
                ViewBag.category = category;

                List<APIPart> parts = CURTAPI.GetCategoryParts(id, page, per_page);

                Dictionary<string, List<APIPart>> ordered_parts = new Dictionary<string, List<APIPart>>();
                foreach (APIPart part in parts) {
                    APIColorCode color_code = CURTAPI.GetColorCode(part.partID);
                    part.colorCode = color_code.code;
                    if (part.pClass.Length > 0) {
                        if (ordered_parts.Keys.Contains(part.pClass)) { // Already added to dictionary
                            List<APIPart> existing_parts = ordered_parts.Where(x => x.Key == part.pClass).Select(x => x.Value).FirstOrDefault<List<APIPart>>();
                            existing_parts.Add(part);
                            ordered_parts[part.pClass] = existing_parts;
                        } else { // New Color Code
                            List<APIPart> new_parts = new List<APIPart>();
                            new_parts.Add(part);
                            ordered_parts.Add(part.pClass, new_parts);
                        }
                    } else {
                        if (ordered_parts.Keys.Contains(category.catTitle.Trim())) { // Already added to dictionary
                            List<APIPart> existing_parts = ordered_parts.Where(x => x.Key == category.catTitle.Trim()).Select(x => x.Value).FirstOrDefault<List<APIPart>>();
                            existing_parts.Add(part);
                            ordered_parts[category.catTitle.Trim()] = existing_parts;
                        } else { // New Color Code
                            List<APIPart> new_parts = new List<APIPart>();
                            new_parts.Add(part);
                            ordered_parts.Add(category.catTitle.Trim(), new_parts);
                        }
                    }
                }
                ViewBag.parts = ordered_parts;

                // We need to figure out if there are going to be more parts to display
                int more_count = CURTAPI.GetCategoryParts(id, page + 1, per_page).Count;
                ViewBag.more_count = more_count;

                ViewBag.page = page;
                ViewBag.per_page = per_page;

                return View();
            } else {
                return RedirectToAction("Index", "Index");
            }
        }
Esempio n. 8
0
        static APIUnit Base(APIType type, APICategory cat, APIID id, NktHook hook, NktProcess process, NktHookCallInfo callInfo)
        {
            if (callInfo.StackTrace().Module(0) == null)
            {
                return(null);
            }
            string module = callInfo.StackTrace().Module(0).Name.ToUpper();

            if (!Modules.Contains(module))
            {
                return(null);
            }

            APIUnit report = new APIUnit(process.Id, hook.FunctionName, type, cat, id);

            report.Module = module;
            return(report);
        }
        public ActionResult Index(int catID = 0)
        {
            if (catID > 0) {
                APICategory category = new APICategory();
                category = CURTAPI.GetCategory(catID);

                ViewBag.category = category;

                if (category.sub_categories.Count == 0) { // Redirect to view the parts for this category
                    return RedirectToAction("Parts", "Categories", new { id = category.catID });
                }
            } else {
                APICategory category = new APICategory();
                category.catTitle = "Product Categories";
                category.catID = 0;
                category.sub_categories = CURTAPI.GetParentCategories();
                ViewBag.category = category;
            }

            return View();
        }
Esempio n. 10
0
        public JsonResult InsertCategory(APICategory _category)
        {
            var restResult = new RestModel();

            try
            {
                db.categories.Add(new category()
                {
                    name       = _category.name,
                    is_deleted = 0
                });
                db.SaveChanges();
                restResult.status = true;
            }
            catch (Exception ex)
            {
                restResult.status  = false;
                restResult.message = ex.Message;
            }
            return(Json(restResult, JsonRequestBehavior.AllowGet));
        }
        public void checkForAutoCompletion(char lastCharEntered)
        {
            if (lastCharEntered.Equals(' ') || lastCharEntered.Equals('\t') ||
                lastCharEntered.Equals('\r') || lastCharEntered.Equals('\n'))
            {
                isActive      = true;
                CurrentWord   = "";
                isInACategory = false;
                showFunctions = false;


                return;
            }

            /* if (this.autoCompleteForm.Visible == false)
             * {
             *   this.autoCompleteForm.Show(this.editorParent);
             *   this.editorParent.Focus();
             * }
             * this.autoCompleteForm.Location = Cursor.Position;
             * this.autoCompleteForm.refreshValues(this.Items);*/


            if (isActive == true)
            {
                if (lastCharEntered.Equals('.') || lastCharEntered.Equals(':'))
                {
                    if (CategorySelected != null && this.isInACategory == true)
                    {
                        bool containsCategory = false;

                        for (int i = 0; i < CategorySelected.SubCategories.Count; i++)
                        {
                            APICategory cat = CategorySelected.SubCategories[i];


                            if (cat.name.Equals(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                            {
                                CategorySelected = cat;
                                CurrentWord      = "";
                                containsCategory = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        bool containsCategory = false;
                        for (int i = 0; i < this.Categories.Count; i++)
                        {
                            APICategory cat = Categories[i];
                            if (cat.name.Equals(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                            {
                                CategorySelected = cat;
                                containsCategory = true;
                                isInACategory    = true;
                                CurrentWord      = "";
                                break;
                            }
                        }
                        if (containsCategory == false)
                        {
                            this.resetCurrentWord();
                            this.isActive = true;
                            return;
                        }
                    }
                }
                else
                {
                    if (!lastCharEntered.Equals('!'))
                    {
                        CurrentWord += lastCharEntered;
                    }
                }


                //Chercher dans les categories
                string autoCompleteStr = "";


                if (lastCharEntered.Equals(':'))
                {
                    showFunctions = true;
                }

                if (CategorySelected != null && this.isInACategory == true)
                {
                    for (int i = 0; i < CategorySelected.SubCategories.Count; i++)
                    {
                        APICategory cat = CategorySelected.SubCategories[i];
                        if (cat.name.StartsWith(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                        {
                            autoCompleteStr += cat.name + "?1 ";
                        }
                    }
                    for (int i = 0; i < CategorySelected.Items.Count; i++)
                    {
                        APIItem item = CategorySelected.Items[i];
                        if (item.name.StartsWith(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                        {
                            if (showFunctions == true)
                            {
                                if (item.isFunction == true)
                                {
                                    autoCompleteStr += item.name + "?0 ";
                                }
                            }
                            else
                            {
                                if (item.isFunction == false)
                                {
                                    autoCompleteStr += item.name + "?2 ";
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < this.Categories.Count; i++)
                    {
                        APICategory cat = this.Categories[i];
                        if (cat.name.StartsWith(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                        {
                            autoCompleteStr += cat.name + "?1 ";
                        }
                    }

                    for (int i = 0; i < this.Items.Count; i++)
                    {
                        APIItem item = this.Items[i];
                        if (item.name.StartsWith(CurrentWord, StringComparison.CurrentCultureIgnoreCase) == true)
                        {
                            if (showFunctions == true)
                            {
                                if (item.isFunction == true)
                                {
                                    autoCompleteStr += item.name + "?0 ";
                                }
                            }
                            else
                            {
                                if (item.isFunction == false)
                                {
                                    autoCompleteStr += item.name + "?2 ";
                                }
                            }
                        }
                    }
                }

                if (!autoCompleteStr.Equals(""))
                {
                    if (this.editorParent.ActiveDocument != null)
                    {
                        this.editorParent.ActiveDocument.Scintilla.AutoComplete.ListString = autoCompleteStr;


                        if (this.editorParent.ActiveDocument.Scintilla.AutoComplete.IsActive == false)
                        {
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.SingleLineAccept = true;
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.DropRestOfWord   = true;
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.ClearRegisteredImages();

                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.RegisterImage(0, methodsImg);
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.RegisterImage(1, classesImg);
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.RegisterImage(2, propsImg);
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.RegisterImage(3, fieldsImg);
                        }



                        if (this.editorParent.ActiveDocument.Scintilla.AutoComplete.IsActive == false)
                        {
                            this.editorParent.ActiveDocument.Scintilla.AutoComplete.Show();
                        }
                        // this.editorParent.ActiveDocument.Scintilla.AutoComplete.ShowUserList(0,autoCompleteStr);
                    }
                }
            }
        }
        public void refreshAPI(string sourcePage)
        {
            //Clear all lists
            this.Categories.Clear();
            this.Items.Clear();


            //Chercher toutes les infex de href="#
            int    indexStart           = 0;
            int    indexFirstEndBalise  = 0;
            int    indexSecondEndBalise = 0;
            string strStart             = "href=\"#";
            string strEndFirstBalise    = ">";
            string strEndSecondBalise   = "</a>";

            while (indexStart < sourcePage.Length)
            {
                indexStart = sourcePage.IndexOf(strStart, indexSecondEndBalise);
                if (indexStart == -1)
                {
                    break;
                }

                indexFirstEndBalise = sourcePage.IndexOf(strEndFirstBalise, indexStart);
                if (indexFirstEndBalise == -1)
                {
                    break;
                }

                indexSecondEndBalise = sourcePage.IndexOf(strEndSecondBalise, indexFirstEndBalise);
                if (indexSecondEndBalise == -1)
                {
                    break;
                }

                string content = sourcePage.Substring(indexFirstEndBalise + 1, indexSecondEndBalise - indexFirstEndBalise - 1);

                //Treat the content
                content = content.Replace("\n", "");
                content = content.Replace(" ", "");

                //Treat if is a category
                if (content.Contains("."))
                {
                    string catName  = content.Substring(0, content.IndexOf("."));
                    int    len      = content.Length - content.IndexOf(".");
                    string itemName = content.Substring(content.IndexOf(".") + 1, len - 1);
                    this.addItem(catName, itemName, false);
                }
                else if (content.Contains(":"))
                {
                    string catName  = content.Substring(0, content.IndexOf(":"));
                    int    len      = content.Length - content.IndexOf(":");
                    string itemName = content.Substring(content.IndexOf(":") + 1, len - 1);
                    this.addItem(catName, itemName, true);
                }
                else
                {
                    this.addItem(null, content, false);
                }
            }

            APICategory objectCategory = null;

            for (int i = 0; i < this.Categories.Count; i++)
            {
                if (this.Categories[i].name.ToLower().Equals("object"))
                {
                    objectCategory = this.Categories[i];
                    break;
                }
            }

            if (this.editorParent.sceneSelected != null)
            {
                CoronaGameProject currentProject = this.editorParent.sceneSelected.projectParent;
                if (currentProject != null)
                {
                    APICategory catStoryboard = new APICategory("storyboard");
                    this.Categories.Add(catStoryboard);

                    if (currentProject.Snippets.Count > 0)
                    {
                        APICategory catSnippets = new APICategory("snippets");
                        this.Categories.Add(catSnippets);
                        for (int i = 0; i < currentProject.Snippets.Count; i++)
                        {
                            Snippet snippet     = currentProject.Snippets[i];
                            APIItem itemSnippet = new APIItem(snippet.Name.Replace(" ", ""), true);
                            catSnippets.Items.Add(itemSnippet);
                        }
                    }


                    APICategory catResources = new APICategory("resources");
                    catStoryboard.SubCategories.Add(catResources);

                    //AJouter les scenes
                    for (int i = 0; i < currentProject.Scenes.Count; i++)
                    {
                        Scene       scene    = currentProject.Scenes[i];
                        APICategory catScene = new APICategory(scene.Name);
                        catResources.SubCategories.Add(catScene);

                        for (int j = 0; j < scene.Layers.Count; j++)
                        {
                            CoronaLayer layer    = scene.Layers[j];
                            APICategory catLayer = new APICategory(layer.Name);
                            catScene.SubCategories.Add(catLayer);

                            for (int k = 0; k < layer.CoronaObjects.Count; k++)
                            {
                                CoronaObject obj    = layer.CoronaObjects[k];
                                APICategory  catObj = new APICategory(obj.DisplayObject.Name);
                                catLayer.SubCategories.Add(catObj);

                                if (objectCategory != null)
                                {
                                    catObj.SubCategories.Add(objectCategory);
                                }
                            }

                            for (int k = 0; k < layer.Jointures.Count; k++)
                            {
                                CoronaJointure joint     = layer.Jointures[k];
                                APIItem        itemJoint = new APIItem(joint.name, false);
                                catLayer.Items.Add(itemJoint);
                            }

                            for (int k = 0; k < layer.Controls.Count; k++)
                            {
                                CoronaControl control     = layer.Controls[k];
                                APIItem       itemControl = new APIItem(control.ControlName, false);
                                catLayer.Items.Add(itemControl);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 13
0
 public SequenceUnit(APICategory cat, APIUnit api)
 {
     Category  = cat;
     API       = api;
     Consumers = new List <APIUnit>();
 }
        public async Task<ActionResult> Index(int catID = 0, int page = 1, int per_page = 10) {
            HttpContext ctx = System.Web.HttpContext.Current;

            APICategory category = new APICategory();
            APIColorCode color_code = new APIColorCode();
            List<APIPart> catparts = new List<APIPart>();
            List<APIPart> moreparts = new List<APIPart>();
            Task<List<APICategory>> pcats = CURTAPI.GetParentCategoriesAsync();
            Task<List<APICategory>> crumbs = null;
            Task<APICategory> cat = null;
            Task<List<APIPart>> parts = null;
            Task<List<APIPart>> moreTask = null;
            Task<APIColorCode> codetask = null;
            List<APICategory> breadcrumbs = new List<APICategory>();
            List<Task> tasks = new List<Task> { pcats };

            if (catID > 0) {
                UDF.SetCategoryCookie(ctx, catID);
                cat = CURTAPI.GetCategoryAsync(catID);
                parts = CURTAPI.GetCategoryPartsAsync(catID, page, per_page);
                moreTask = CURTAPI.GetCategoryPartsAsync(catID, page + 1, per_page);
                codetask = CURTAPI.GetCategoryColorCodeAsync(catID);
                crumbs = CURTAPI.GetBreadcrumbsAsync(catID);
                tasks.Add(cat);
                tasks.Add(parts);
                tasks.Add(moreTask);
                tasks.Add(codetask);
                tasks.Add(crumbs);
            } else {
                category.catTitle = "Product Categories";
                category.catID = 0;
            }
            await Task.WhenAll( tasks.ToArray() );
            ViewBag.parent_cats = await pcats;
            if (catID > 0) {
                category = await cat;
                color_code = await codetask;
            } else {
                category.SubCategories = ViewBag.parent_cats;
            }
            ViewBag.category = category;
            if (crumbs != null) {
                breadcrumbs = await crumbs;
            }
            ViewBag.breadcrumbs = breadcrumbs;
            if (parts != null) {
                catparts = await parts;
                moreparts = await moreTask;
                if (catparts.Count > 0) {
                    ViewBag.parts = catparts;
                    int more_count = moreparts.Count;
                    ViewBag.more_count = more_count;

                    ViewBag.page = page;
                    ViewBag.per_page = per_page;

                    return View("Parts");
                }
            }

            return View();
        }