Example #1
0
        public static IList<Link> createLink(EOpenType type, IList<ARequestView> items, bool isPartial)
        {
            List<Link> links = new List<Link>();
            string link = "";
            link += isPartial ? "Partial" : "";
            switch (type) {
                case EOpenType.Element :
                    link +=  "Element";
                    break;
                case EOpenType.Project:
                    link += "Project";
                    break;
                case EOpenType.Request:
                    link += "Request";
                    break;
                default:
                    break;
            }

            foreach (ARequestView item in items) {
                Link l = new Link(type.ToString().Left(1) + item.ID + " - " + item.Summary, item.Summary.Replace("\"", "&quot;"), link + "/" + item.ID);
                if (type == EOpenType.Request && ((RequestView)item).RequestedDueDate < DateTime.Today)
                    l.Class = "invalid";
                links.Add(l);
            }

            return links;
        }
Example #2
0
        public IList<LookupActive> getRequestTypes(EOpenType type, bool activeOnly)
        {
            IList<LookupActive> requestType;
            if (type == EOpenType.Request)
                requestType = this.requestTypeList.Data;
            else
                requestType = this.projectTypeList.Data;

            if (activeOnly)
                return requestType.Where(x => x.Active == activeOnly).OrderBy(y => y.Text).ToList();
            else
                return requestType.OrderBy(x => x.Text).OrderByDescending(y => y.Active).ToList();
        }
Example #3
0
        public bool OpenDatabank(ref Databank databank, EOpenType openType, int openPosition)
        {
            if (openType == EOpenType.Pos)
            {
                if (openPosition > this.storage.Count)
                {
                    G.Writeln2("*** ERROR: There are " + (this.storage.Count - 1) + " numbered databanks in the databank list (F2).");
                    G.Writeln("           Opening in position " + openPosition + " is not possible.", Color.Red);
                    throw new GekkoException();
                }
            }

            if (openType == EOpenType.Ref)
            {
                G.Writeln2("+++ WARNING: OPEN<ref> is for advanced users, and will put the existing " + Globals.Ref + " in the list of 'normal' databanks", Globals.warningColor);
            }
            bool readFromFile = false;

            //Does not read the actual bank, but just arranges for the bank to be read into the right 'slot'
            //If <first/edit> or <ref>, the bank in the [0] or [1] slot is pushed down to [2].
            if (G.equal(databank.aliasName, Globals.Work))
            {
                if (openType == EOpenType.Normal || openType == EOpenType.Last)
                {
                    G.Writeln2("*** ERROR: The 'Work' databank cannot be opened or closed (it is always open).");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.First)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<first> with the 'Work' databank.");
                    G.Writeln("           If Work is not first and it needs to be, you must CLOSE");
                    G.Writeln("           the present first databank. After that, Work will be first.");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.Edit)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<edit> with the 'Work' databank.");
                    G.Writeln("           Work is always editable, and if Work is not first on");
                    G.Writeln("           the F2 databank list, you must CLOSE the present first");
                    G.Writeln("           databank. After that, Work will become first (and editable).");

                    throw new GekkoException();
                }
                else if (openType == EOpenType.Ref)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<ref> with the 'Work' databank.");
                    G.Writeln("           It is not legal to set Work as the ref databank.");
                    G.Writeln("           Use the Ref databank for such purposes.");
                    throw new GekkoException();
                }
            }
            else if (G.equal(databank.aliasName, Globals.Ref))  //Ref
            {
                if (openType == EOpenType.Normal)
                {
                    G.Writeln2("*** ERROR: The '" + Globals.Ref + "' databank cannot be opened or closed (it is always open).");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.First)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<first> with the '" + Globals.Ref + "' databank.");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.Last)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<last> with the '" + Globals.Ref + "' databank.");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.Edit)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<edit> with the '" + Globals.Ref + "' databank.");
                    throw new GekkoException();
                }
                else if (openType == EOpenType.Ref)
                {
                    G.Writeln2("*** ERROR: You cannot use OPEN<ref> with the '" + Globals.Ref + "' databank.");
                    throw new GekkoException();
                }
            }
            string name = databank.aliasName;
            int    existI; int WorkI; int BaseI; FindBanksI(name, out existI, out WorkI, out BaseI);

            List <Databank> m = new List <Databank>(this.storage.Count);

            if (existI != -12345)  //the databank name already exists. No actual file reading, just rearrange the banks
            {
                DatabankLogicExistingBank(out databank, openType, openPosition, out readFromFile, name, existI, WorkI, BaseI, m);
            }
            else  //the databank name does not exist, so it is new and will be read from file later on
            {
                readFromFile = true;
                if (G.equal(Program.options.databank_logic, "aremos"))
                {
                    DatabankLogicAREMOS(databank, openType, openPosition, name, m);
                }
                else
                {
                    DatabankLogicDefault(databank, openType, openPosition, name, m);
                }
            }
            this.storage = m;
            return(readFromFile);
        }
Example #4
0
 public bool ShouldPutBankLastAREMOS(EOpenType openType, int openPosition)
 {
     return(openType == EOpenType.Last || (openType == EOpenType.Pos && openPosition == this.storage.Count + 1));
 }
Example #5
0
        private void DatabankLogicAREMOS(Databank databank, EOpenType openType, int openPosition, string name, List <Databank> m)
        {
            //AREMOS logic
            if (openType == EOpenType.Normal || openType == EOpenType.Sec || (openType == EOpenType.Pos && openPosition == 2))
            {
                m.Add(this.storage[0]);  //first
                m.Add(this.storage[1]);  //ref
                m.Add(databank);
                for (int i = 2; i < this.storage.Count; i++)
                {
                    m.Add(this.storage[i]);
                }
                G.Writeln2("Databank '" + name + "' opened");
            }
            else if (openType == EOpenType.First || openType == EOpenType.Edit || (openType == EOpenType.Pos && openPosition == 1))
            {
                bool edit = false;
                if (openType == EOpenType.Edit)
                {
                    edit = true;
                }
                m.Add(databank);         //first
                m.Add(this.storage[1]);  //ref
                m.Add(this.storage[0]);
                for (int i = 2; i < this.storage.Count; i++)
                {
                    m.Add(this.storage[i]);
                }
                if (openType == EOpenType.Edit)
                {
                    G.Writeln2("Databank '" + name + "' opened as editable in first position");
                }
                else
                {
                    G.Writeln2("Databank '" + name + "' opened in first position");
                }
            }
            else if (openType == EOpenType.Ref)
            {
                m.Add(this.storage[0]);         //first
                m.Add(databank);                //ref
                m.Add(this.storage[1]);
                for (int i = 2; i < this.storage.Count; i++)
                {
                    m.Add(this.storage[i]);
                }
                G.Writeln2("Databank '" + name + "' opened as ref");
            }
            else if (ShouldPutBankLastAREMOS(openType, openPosition))
            {
                m.Add(this.storage[0]);  //first
                m.Add(this.storage[1]);  //ref
                for (int i = 2; i < this.storage.Count; i++)
                {
                    m.Add(this.storage[i]);
                }
                m.Add(databank);
                G.Writeln2("Databank '" + name + "' opened");
            }
            else if (openType == EOpenType.Pos)
            {
                //pos is not 1., 2. or count+1 ===> so 3, 4, ..., up to count.
                if (openPosition < 1)
                {
                    G.Writeln2("*** ERROR: OPEN<pos=...> cannot be 0 or negative");
                    throw new GekkoException();
                }
                m.Add(this.storage[0]);  //first
                m.Add(this.storage[1]);  //ref
                for (int i = 2; i < openPosition; i++)
                {
                    m.Add(this.storage[i]);
                }
                m.Add(databank);
                for (int i = openPosition; i < this.storage.Count; i++)
                {
                    m.Add(this.storage[i]);
                }
                G.Writeln2("Databank '" + name + "' opened in position " + openPosition);
            }
            else
            {
                G.Writeln("*** ERROR: Internal error ยค89435734");
                throw new GekkoException();
            }

            return;
        }
Example #6
0
 private void DatabankLogicExistingBank(out Databank databank, EOpenType openType, int openPosition, out bool readFromFile, string name, int existI, int WorkI, int BaseI, List <Databank> m)
 {
     databank     = this.storage[existI]; //now points to the existing databank, and no longer the empty databank the method was called with
     readFromFile = false;
     if (openType == EOpenType.Normal || openType == EOpenType.Last || (openType == EOpenType.Pos && openPosition != 1))
     {
         G.Writeln2("*** ERROR: Databank '" + databank.aliasName + "' is already open. Use CLOSE to close it first.");
         throw new GekkoException();
     }
     else if (openType == EOpenType.Edit || openType == EOpenType.First || (openType == EOpenType.Pos && openPosition == 1))
     {
         if (existI == 0)
         {
             //Note: OPEN<edit> could be used to unlock an OPEN<first>...
             //this.storage[0].protect = false;  //this is set elsewhere
             if (openType == EOpenType.Edit)
             {
                 if (databank.protect == false)
                 {
                     G.Writeln2("Databank '" + databank.aliasName + "' is already editable in first position.");
                 }
                 else
                 {
                     databank.protect = false;
                     G.Writeln2("Databank '" + databank.aliasName + "' set editable.");
                 }
             }
             m.AddRange(this.storage);    //just copied, and put back again later on
         }
         else if (existI == 1)            //Trying an OPEN<edit>db on a db that is already ref (opened with OPEN<ref>db).
         {
             m.Add(this.storage[existI]); //first, = former sec
             m.Add(this.storage[BaseI]);  //ref, = Ref databank, to aviod empty slot
             m.Add(this.storage[0]);      //former first ends here
             for (int i = 2; i < this.storage.Count; i++)
             {
                 if (i == BaseI)
                 {
                     continue;
                 }
                 m.Add(this.storage[i]);
             }
         }
         else  //Trying an OPEN<edit>db on a db that is already there in slot [2] or below
         {
             m.Add(this.storage[existI]);         //first
             m.Add(this.storage[1]);              //ref, same
             m.Add(this.storage[0]);
             for (int i = 2; i < this.storage.Count; i++)
             {
                 if (i == existI)
                 {
                     continue;
                 }
                 m.Add(this.storage[i]);
             }
         }
         if (openType == EOpenType.Edit)
         {
             G.Writeln2("Databank '" + name + "' set as editable databank, put first position.");
         }
         else
         {
             G.Writeln2("Databank '" + name + "' put in first position.");
         }
     }
     else if (openType == EOpenType.Ref)
     {
         if (existI == 0)                 //Trying an OPEN<sec>db on a db that is already first/editable (opened with OPEN<first> or OPEN<edit>)
         {
             m.Add(this.storage[WorkI]);  //first, = Work databank, to aviod empty slot
             m.Add(this.storage[existI]); //ref, = former first
             m.Add(this.storage[1]);      //former ref ends here
             for (int i = 2; i < this.storage.Count; i++)
             {
                 if (i == WorkI)
                 {
                     continue;
                 }
                 m.Add(this.storage[i]);
             }
         }
         else if (existI == 1)
         {
             G.Writeln2("*** ERROR: Databank '" + databank.aliasName + "' is already open as ref bank");
             throw new GekkoException();
         }
         else  //Trying an OPEN<edit/first>db on a db that is already there in slot [2] or below
         {
             m.Add(this.storage[0]);         //first, same
             m.Add(this.storage[existI]);    //ref
             m.Add(this.storage[1]);
             for (int i = 2; i < this.storage.Count; i++)
             {
                 if (i == existI)
                 {
                     continue;
                 }
                 m.Add(this.storage[i]);
             }
         }
         G.Writeln2("Databank '" + name + "' set as ref bank");
     }
 }
Example #7
0
 public IList<LookupSorted> getStatusList(EOpenType type)
 {
     switch (type) {
         case EOpenType.Request:
             return this.requestStatusList.Data.OrderBy(x => x.SortOrder).ToList();
         case EOpenType.Element:
             return this.elementStatusList.Data.OrderBy(x => x.SortOrder).ToList();
         default:
             return this.projectStatusList.Data.OrderBy(x => x.SortOrder).ToList();
     }
 }
Example #8
0
 public IList<ARequestView> getRequests(EOpenType type, IUser user)
 {
     List<ARequestView> items = new List<ARequestView>();
     switch (type) {
         case EOpenType.Request :
             if (user != null)
                 return this.requestList
                     .Data
                     .Where(x => ((x.AssignedTo.EmployeeID == user.EmployeeID || x.RequestedBy.EmployeeID == user.EmployeeID) && x.ClosedDate == null) || (user == null))
                     .Cast<ARequestView>()
                     .ToList();
             else
                 return this.requestList.Data.Cast<ARequestView>().ToList();
         case EOpenType.Project :
             foreach (RequestView r in this.requestList.Data)
                 if (r.AssignedTo.Equals(user) && new[] { "complete", "cancelled", "rejected", "out of scope" }.All(x => !x.Equals(r.Parent == null ? "complete" : r.Parent.Status.Text.ToLower())))
                     if (!items.Any(x => x.ID == r.Parent.ID))
                         items.Add(r.Parent);
             return items.OrderBy(x => x.Summary).ToList();
         case EOpenType.Element :
             foreach (RequestView r in this.requestList.Data)
                 items.AddRange(r.ElementList.Where(x => x.AssignedTo.EmployeeID == user.EmployeeID && x.ClosedDate == null));
             return items;
         default:
             return items;
     }
 }