Exemple #1
0
        public ActionResult RaiseRequisition()
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();
            List <ItemModel>     ItemsList      = new List <ItemModel>();
            RequisitionViewModel reqvm          = new RequisitionViewModel();

            try
            {
                reqvm.Reqdate     = DateTime.Now;
                reqvm.Raisedby    = um.Userid;
                reqvm.Depid       = um.Deptid;
                dcpm              = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                reqvm.Cpid        = dcpm.CpID;
                reqvm.Cpname      = dcpm.CpName;
                reqvm.Status      = ConRequisition.Status.PENDING;
                ItemsList         = APIItem.GetAllItems(token, out error);
                ViewBag.ItemsList = ItemsList;
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
            return(View(reqvm));
        }
    /// <summary>
    /// 通过接口类型和接口名称获取接口定义
    /// </summary>
    /// <param name="apiType"></param>
    /// <param name="apiName"></param>
    /// <returns></returns>
    public APIItem GetApiItemByTypeAndName(string apiType, string apiName)
    {
        var     apiTypes = this._webApi._project._ApiList._ApiTypes;
        APIItem apiItem  = null;

        if (apiTypes != null)
        {
            foreach (var api in apiTypes)
            {
                if (!api.TypeName.Equals(apiType))
                {
                    continue;
                }
                foreach (APIItem item in api.Apies)
                {
                    if (item.APIName.Equals(apiName))
                    {
                        apiItem = item;
                        break;
                    }
                }
            }
        }
        return(apiItem);
    }
Exemple #3
0
        public void refreshValues(List <APIItem> items)
        {
            this.itemsListView.BeginUpdate();
            this.itemsListView.Items.Clear();

            ColumnHeader nameColumn = this.itemsListView.Columns["Name"];

            for (int i = 0; i < items.Count; i++)
            {
                APIItem item = items[i];
                if (item.isFunction)
                {
                    ListViewItem itemNode = this.itemsListView.Items.Add(item.name);
                    itemNode.Group = this.itemsListView.Groups["functionsGroup"];
                }

                else
                {
                    ListViewItem itemNode = this.itemsListView.Items.Add(item.name);
                    itemNode.Group = this.itemsListView.Groups["fieldsGroup"];
                }
            }

            this.itemsListView.EndUpdate();
        }
        public async Task <IActionResult> PostItemToStore([FromBody] APIItem item, CancellationToken ct)
        {
            //TODO: Check to make sure the store is trying to add the item
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error = "Model state is not valid" }));
            }

            var currentUser = HttpContext.User;
            var userclaim   = currentUser.Claims.First();
            var userId      = Guid.Parse(userclaim.Value);
            var storeUser   = await _storeUserRepository.GetEntityAsync(userId, ct);

            if (storeUser == null)
            {
                return(BadRequest(new { error = "Not a store, can't add items unless you are a store." }));
            }

            if (storeUser.HomeStoreId == 0)
            {
                return(BadRequest(new { error = "You are a store, but haven't created your homestore yet." }));
            }

            ItemEntity itemEntity = new ItemEntity
            {
                Name = item.Name,
                SpoonacularProductId = item.SpoonId
            };

            ItemStoreLinkEntity linkEntity = new ItemStoreLinkEntity
            {
                InStock     = item.InStock,
                StockAmount = item.StockAmount,
                StoreId     = storeUser.HomeStoreId,
                Price       = item.Price
            };

            bool itemAdded = await _itemRepository.AddEntityAsync(itemEntity, ct);

            if (itemAdded)
            {
                linkEntity.ItemId = itemEntity.Id;
                itemAdded         = await _itemStoreLinkRepository.AddEntityAsync(linkEntity, ct);

                if (itemAdded)
                {
                    return(Ok());
                }

                return(BadRequest());
            }

            return(BadRequest());
        }
    private APIType GetApiTypeFromElement(XElement element)
    {
        APIType api = new APIType();

        api.AssemblyName = element.Attributes("AssemblyName").FirstOrDefault().Value;
        api.TypeBrief    = element.Attributes("TypeBrief").FirstOrDefault().Value;
        api.TypeName     = element.Attributes("TypeName").FirstOrDefault().Value;
        api.TypeOrder    = element.Attributes("TypeOrder").FirstOrDefault().Value;
        api.Apies        = new List <APIItem>();
        foreach (var xElement in element.Elements())
        {
            APIItem item = GetApiItemFromElement(xElement, api.AssemblyName);
            api.Apies.Add(item);
        }
        return(api);
    }
    private APIItem GetApiItemFromElement(XElement element, string assemblyName)
    {
        APIItem item = new APIItem();

        item.APIBrief     = element.Attributes("APIBrief").FirstOrDefault().Value;
        item.APIName      = element.Attributes("APIName").FirstOrDefault().Value;
        item.AssemblyName = assemblyName;
        string parentType = element.Parent.Attributes("TypeName").FirstOrDefault().Value;

        item.MethodName = element.Attributes("MethodName").FirstOrDefault().Value;
        item.TypeName   = parentType + "." + element.Attributes("TypeName").FirstOrDefault().Value;
        XElement inputElement  = element.Element("InputData");
        XElement outputElement = element.Element("OutputData");

        item.input  = GetParamDefFromElement(inputElement);
        item.output = GetParamDefFromElement(outputElement);
        return(item);
    }
        public ActionResult ItemUsageReport()
        {
            string        token = GetToken();
            SupplierModel sm    = new SupplierModel();
            string        error = "";

            UserModel um = GetUser();

            ViewBag.SupplierModel = sm;
            MonthlyItemUsageViewModel viewmodel = new MonthlyItemUsageViewModel();
            List <SupplierModel>      sml       = new List <SupplierModel>();

            sml = APISupplier.GetAllSuppliers(token, out error);

            try
            {
                //ViewBag.SupplierModel = APISupplier.GetAllSuppliers(token, out error);
                ViewBag.count       = 0;
                viewmodel.supplier1 = sm.SupId;
                viewmodel.supplier2 = sm.SupId;
                viewmodel.supplier3 = sm.SupId;
                List <int> suppliername = new List <int>();

                ViewBag.supplier = sml;

                foreach (SupplierModel s in sml)
                {
                    suppliername.Add(s.SupId);
                }
                List <SupplierModel> sups = APISupplier.GetAllSuppliers(token, out error);
                ViewBag.slist = sups;
                ViewBag.ilist = APIItem.GetAllItems(token, out error);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new
                {
                    error = ex.Message
                }));
            }
            ViewBag.count = 0;
            return(View(viewmodel));
        }
Exemple #8
0
        public ActionResult ItemsPartialUpdate(APIItem item)
        {
            var model = new object[0];

            if (ModelState.IsValid)
            {
                try
                {
                    // Insert here a code to update the item in your model
                    ItemList.UpdateItem(item);
                }
                catch (Exception e)
                {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
            {
                ViewData["EditError"] = "Please, correct all errors.";
            }
            return(PartialView("_ItemsPartial", ItemList.GetData()));
        }
        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);
                            }
                        }
                    }
                }
            }
        }