Exemple #1
0
        public InboxItems SearchByInboxItemName(string InboxItemName)
        {
            List <TransactionCode> tranCodelst = new List <TransactionCode>();
            InboxItems             searchItem  = new InboxItems();

            searchItem.Name = InboxItemName;
            string       url     = HttpContext.Current.Request.PhysicalApplicationPath + this.xmlPath;
            StreamReader sr      = new StreamReader(url);
            XDocument    doc     = XDocument.Load(sr);
            var          records = from InboxItem in doc.Root.Elements("InboxItem")
                                   where (string)InboxItem.Attribute("Name") == InboxItemName
                                   select InboxItem;

            foreach (var i in records)
            {
                var tranCode = from tran in i.Elements("TransactionCode")
                               select tran;
                foreach (var x in tranCode)
                {
                    TransactionCode objTrC = new TransactionCode();
                    objTrC.FlowName = x.Attribute("FlowName").Value;
                    objTrC.Step     = x.Attribute("Step").Value;
                    objTrC.StepName = x.Attribute("StepName").Value;
                    objTrC.Right    = x.Attribute("Right").Value;
                    tranCodelst.Add(objTrC);
                }
                searchItem.TransactionCodeList = tranCodelst;
            }
            sr.Close();
            InboxItems objGrantedItems = new InboxItems();

            searchItem = objGrantedItems.GetGrantedInboxItem(searchItem);
            return(searchItem);
        }
Exemple #2
0
        public InboxRowGrid GetGrantedInBoxItems()
        {
            List <InboxItems> MyInBoxGranted = new List <InboxItems>();

            InboxItems        objGrantedInboxItem = new InboxItems();
            List <InboxItems> l = this.GetFormXML();

            MyInBoxGranted = objGrantedInboxItem.GetGrantedInboxItems(l);
            InboxRowGrid dictInboxRowGrid = new InboxRowGrid();

            foreach (InboxItems i in MyInBoxGranted)
            {
                if (!(dictInboxRowGrid.InboxRow.ContainsKey(i.Name)))
                {
                    dictInboxRowGrid.InboxRow.Add(i.Name, new List <string>());
                }
                foreach (TransactionCode tranCode in i.TransactionCodeList)
                {
                    dictInboxRowGrid.InboxRow[i.Name].Add(tranCode.StepName);
                }
            }



            return(dictInboxRowGrid);
        }
Exemple #3
0
        public InboxItems GetGrantedInboxItem(InboxItems objInboxItem)
        {
            List <InboxItems> myInboxItem = new List <InboxItems>();
            //Get all Inbox Item Rights.
            List <string> Rights = new List <string>();

            foreach (TransactionCode t in objInboxItem.TransactionCodeList)
            {
                Rights.Add(t.Right);
            }

            string[] RightArr = Rights.ToArray <String>();
            //Todo Add Warehouse Location.
            List <string>          hasRight  = UserBLL.HasRoles(UserBLL.GetCurrentUser(), RightArr);
            InboxItems             inbox     = new InboxItems();
            List <TransactionCode> grantedTC = new List <TransactionCode>();

            foreach (TransactionCode t in objInboxItem.TransactionCodeList)
            {
                var has = from x in hasRight
                          where x.ToUpper() == t.Right.ToUpper()
                          select x;
                if (has.Count <string>() > 0)
                {
                    grantedTC.Add(t);
                }
            }
            inbox.TransactionCodeList = grantedTC;
            return(inbox);
        }
Exemple #4
0
        private List <InboxItems> GetFormXML()
        {
            List <InboxItems> MyInBox = new List <InboxItems>();
            string            url     = HttpContext.Current.Request.PhysicalApplicationPath + this.xmlPath;
            FileStream        fs      = null;

            fs = File.OpenRead(url);
            XmlReader reader = XmlReader.Create(fs);

            if (reader == null)
            {
                throw new Exception("Invalid XML Path");
            }
            try
            {
                using (reader)
                {
                    InboxItems             obj     = new InboxItems();
                    List <TransactionCode> lstTran = new List <TransactionCode>();
                    lstTran = new List <TransactionCode>();
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                            if (reader.Name == "InboxItem")
                            {
                                obj.Name = reader.GetAttribute("Name");
                            }
                            if (reader.Name == "TransactionCode")
                            {
                                TransactionCode oBjTr = new TransactionCode();
                                oBjTr.FlowName = reader.GetAttribute("FlowName");
                                oBjTr.StepName = reader.GetAttribute("StepName");
                                oBjTr.Step     = reader.GetAttribute("Step");
                                oBjTr.Right    = reader.GetAttribute("Right");
                                lstTran.Add(oBjTr);
                            }
                            obj.TransactionCodeList = lstTran;


                            break;

                        case XmlNodeType.EndElement:
                            if (reader.Name == "InboxItem")
                            {
                                MyInBox.Add(obj);
                                obj     = new InboxItems();
                                lstTran = new List <TransactionCode>();
                            }
                            else if (reader.Name == "TransactionCode")
                            {
                            }
                            break;

                        case XmlNodeType.Text:
                            break;

                        case XmlNodeType.CDATA:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Inbox Item Exception.", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                    fs.Dispose();
                }
            }



            return(MyInBox);
        }