Example #1
0
        }//end CreateDayScheduleXML

        /// <summary>
        /// Adds a new appointment child to DailySchedule XML
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="isBusy"></param>
        /// <returns></returns>
        public static XmlDocument AddApptNode2DayScheduleXML(string fileName, DateTime date, int time, bool isBusy = true)
        {
            try {
                //set booking status to BUSY
                string bookStatus = DaySchedule.GetDayStatusEnumString(DayStatusEnum.BUSY);
                if (!isBusy)
                {
                    //set booking status to AVAILABLE
                    bookStatus = DaySchedule.GetDayStatusEnumString(DayStatusEnum.AVAILABLE);
                }

                //OpenFile handles new file
                XmlDocument xdoc = QueryXML.OpenFile(fileName);

                xdoc = QueryXML.AddChild2Root(filename: fileName, childName: "Booking");
                xdoc = QueryXML.AddChild2LastChild(filename: fileName, childName: "Time", childIValue: time.ToString());
                xdoc = QueryXML.AddChild2LastChild(filename: fileName, childName: "Status", childIValue: bookStatus);

                //save document
                xdoc.Save(fileName);

                return(xdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end AddAppt2DayScheduleXML
Example #2
0
        }//end CreateISummaryXML

        public static XmlDocument AddNode2ISummaryXML(string fileName, string perform, string value2Add, int index = 0, bool addChild = true)
        {
            try {
                //OpenFile handles new file
                XmlDocument xdoc = QueryXML.OpenFile(fileName, rootName: "Installation");

                //declare parent Names
                string parentName  = "";
                string parentValue = "";
                string childName   = "";
                string childValue  = "";

                bool addparent = true;
                //only allow 1 child Parent to be added once
                if (index != 0)
                {
                    addparent = false;
                }

                //set parent Names
                switch (perform)
                {
                case iTimestamp:
                    // case operations
                    parentName  = iTimestamp;
                    parentValue = value2Add;
                    addChild    = false;
                    break;

                case iCompanyID:
                    // case operations
                    parentName  = iCompanyID;
                    parentValue = value2Add;
                    addChild    = false;
                    break;

                case iEmpID:
                    // case operations
                    parentName = "Employees";
                    childName  = iEmpID;
                    childValue = value2Add;
                    break;

                case iServID:
                    // case operations
                    parentName = "Services";
                    childName  = iServID;
                    childValue = value2Add;
                    break;

                case iuserID:
                    // case operations
                    parentName = "EndUsers";
                    childName  = iuserID;
                    childValue = value2Add;
                    break;

                case iApptID:
                    // case operations
                    parentName = "Appointments";
                    childName  = iApptID;
                    childValue = value2Add;
                    break;
                    //   default:
                    // Do nothing
                }

                //Add parents to xml file
                if (addparent)
                {
                    xdoc = QueryXML.AddChild2Root(filename: fileName, childName: parentName, childIValue: parentValue);
                }
                if (addChild)
                {
                    xdoc = QueryXML.AddChild2LastChild(filename: fileName, childName: childName, childIValue: childValue);
                }

                //save document
                xdoc.Save(fileName);

                return(xdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end AddNode2ISummaryXML