예제 #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
예제 #2
0
        }//end AddAppt2DayScheduleXML

        public static XmlDocument Add_ID_2DayScheduleXML(string fileName, string dayScheduleID)
        {
            try {
                if (!String.IsNullOrEmpty(fileName))
                {
                    //OpenFile handles new file
                    XmlDocument xdoc = QueryXML.OpenFile(fileName);

                    //get root element
                    XmlElement root = xdoc.DocumentElement;

                    //add attributes to root node
                    root.SetAttribute(name: "ID", value: dayScheduleID.ToString());
                    xdoc.AppendChild(root);

                    //save document
                    xdoc.Save(fileName);

                    //return xmlDocument
                    return(xdoc);
                }
                //if fileName is invalid
                return(null);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end AddAppt2DayScheduleXML
예제 #3
0
        }//end AddNode2ISummaryXML

        public static XmlDocument AddChild2ISummaryXML(string fileName, string perform, string value2Add)
        {
            try {
                //OpenFile handles new file
                XmlDocument xdoc = QueryXML.OpenFile(fileName, rootName: "Installation");

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

                //set parent Names
                switch (perform)
                {
                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
                }

                xdoc = QueryXML.AddChild2SpecificNode(filename: fileName, parentName: parentName, childName: childName, childIValue: childValue);

                //save document
                xdoc.Save(fileName);

                return(xdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end AddNode2ISummaryXML
예제 #4
0
        }//end GetInstallationSummaryXML

        public static XmlDocument CreateNewInstallSummaryXML(string fileName)
        {
            try {
                //ie default fileName: "~/App_Data/ISummaryXML.xml"

                //OpenFile handles creating a new file
                XmlDocument iSumXMLdoc = QueryXML.CreateBlankFile(fileName, rootName: "Installation");

                //save document
                iSumXMLdoc.Save(fileName);

                //return xmlDocument
                return(iSumXMLdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end CreateISummaryXML
예제 #5
0
        /// <summary>
        /// Either Returns the XMLDocument or full fileName created (including file path) depending on isFileNameReq parameter passed
        /// by default ist returns the xmlDoc
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="agendaID"></param>
        /// <param name="date"></param>
        /// <param name="isFileNameReq"></param>
        /// <returns></returns>
        public static dynamic CreateDayScheduleXML(string filePath, short?agendaID, DateTime date, bool isFileNameReq = false)
        {
            try {
                string staff1stName  = EmployeeBLL.GetStaffByAgendaID(agendaID, isFirstName: true);
                string staffFilePath = filePath + "/" + staff1stName;

                //ie default filePath: "~/App_Data/DailySchedules/"
                if (!Directory.Exists(staffFilePath))
                {
                    Directory.CreateDirectory(staffFilePath);
                }

                string staffDaySchedXMLFileName = staffFilePath + "/" + date.ToString("yyyy_MM_dd") + ".xml";
                STAFF_DAYSCHEDULEXML_FILENAME = staffDaySchedXMLFileName;

                //OpenFile handles creating a new file
                XmlDocument xdoc = QueryXML.OpenFile(staffDaySchedXMLFileName, rootName: "DailySchedule");

                //get root element
                XmlElement root = xdoc.DocumentElement;

                //add attributes to root node
                root.SetAttribute(name: "AgendaID", value: agendaID.ToString());
                root.SetAttribute(name: "Date", value: date.ToString("yyyy_MM_dd"));
                xdoc.AppendChild(root);

                //save document
                xdoc.Save(staffDaySchedXMLFileName);

                //if required on parameter return fileName
                if (isFileNameReq)
                {
                    return(staffDaySchedXMLFileName);
                }
                //return xmlDocument
                return(xdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end CreateDayScheduleXML
예제 #6
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
예제 #7
0
        public static XmlDocument GetInstallationSummaryXML(Installation i, string fileName)
        {
            try {
                //create XML file
                XmlDocument xmlDoc = QueryXML.OpenFile(fileName);
                XDocument   xDoc   = XDocument.Parse(xmlDoc.OuterXml);
                //get xml file timestamp
                var      xTimestamp     = from key in xDoc.Descendants(AppSettings.iTimestamp) select key.Value;
                DateTime?xFileTimestamp = Utils.GetDateFromString(xTimestamp.ToList().First());
                if (xFileTimestamp == null || DateTime.Compare((DateTime)xFileTimestamp, i.Timestamp) != 0)
                {
                    xmlDoc = CreateNewInstallSummaryXML(fileName);
                }

                //get given installation timestamp
                DateTime curInstTimestamp = i.Timestamp;
                //add to xml
                xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iTimestamp, curInstTimestamp.ToString());

                //get company
                int curInstCoID = (int)i.Company.ID;
                //add to xml
                xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iCompanyID, curInstCoID.ToString());

                // Loop through all employees
                int tempStaffID = 0;
                for (int a = 0; a < i.Employees.Count; a++)
                {
                    EmployeeBLL employee = i.Employees[a];
                    //get staff ID
                    tempStaffID = (int)employee.ID;
                    //add to xml
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iEmpID, tempStaffID.ToString(), a);
                }
                ////still add Employees parent node if users dont exist this point
                if (i.Employees.Count == 0)
                {
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iEmpID, String.Empty, 0, addChild: false);
                }

                // Loop through all services
                int tempServID = 0;
                for (int b = 0; b < i.Services.Count; b++)
                {
                    ServicesBLL service = i.Services[b];
                    //get service ID
                    tempServID = (int)service.ID;
                    //add to xml
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iServID, tempServID.ToString(), b);
                }
                ////still add services parent node if users dont exist this point
                if (i.Services.Count == 0)
                {
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iServID, String.Empty, 0, addChild: false);
                }

                // Loop through all endUsers
                int tempEndUserID = 0;
                for (int c = 0; c < i.EndUsers.Count; c++)
                {
                    EndUserBLL endUser = i.EndUsers[c];
                    //get endUser ID
                    tempEndUserID = (int)endUser.ID;
                    //add to xml
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iuserID, tempEndUserID.ToString(), c);
                }
                //still add EndUser parent node if users dont exist this point
                if (i.EndUsers.Count == 0)
                {
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iuserID, String.Empty, 0, addChild: false);
                }


                // Loop through all appointments
                int tempApptID = 0;
                for (int d = 0; d < i.Appointments.Count; d++)
                {
                    ApptBLL appt = i.Appointments[d];
                    //get appt ID
                    tempApptID = (int)appt.ID;
                    //add to xml
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iApptID, tempApptID.ToString(), d);
                }
                ////still add appt parent node if users dont exist this point
                if (i.Appointments.Count == 0)
                {
                    xmlDoc = AddNode2ISummaryXML(fileName, AppSettings.iApptID, String.Empty, 0, addChild: false);
                }


                //return XML file
                return(xmlDoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end GetInstallationSummaryXML
예제 #8
0
        public void TestCreateDatabase()
        {
            DatabaseManager manager = (DatabaseManager)container["DatabaseManager"];

            //Recherche Fichier Schema
            string current;
            string expected;
            string dropview;


            //variable resulat query
            string resultat_req_create_sql_n_1;
            string resultat_req_create_sql_n;
            string resultat_req_update_sql;

            //variable resultat create
            string req_create_sql_n_1;
            string req_create_sql_n;
            string req_update_sql;
            string req_delete_view;

            //variable key
            string key_create_sql_n_1;
            string key_create_sql_n;
            string key_update_sql;



            QueryXML qXML = new QueryXML(ConfigSettings.GetInstance().GetDirectory);

            current  = qXML.FindValueOfFileXML("upgrade", "current", UPGRADE_SCHEMA_FILE_NAME);
            expected = qXML.FindValueOfFileXML("upgrade", "expected", UPGRADE_SCHEMA_FILE_NAME);

            QueryFilesSQL qSQLCreateN_1 = new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);
            QueryFilesSQL qSQLUpdateN   = new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);
            QueryFilesSQL qSQLDelete    = new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);



            key_create_sql_n_1 = string.Concat(CREATE_DATABASE, current);
            key_create_sql_n   = string.Concat(CREATE_DATABASE, expected);
            key_update_sql     = string.Concat(UPDATE_DATABASE, current, AND, expected);


            req_create_sql_n_1 = qSQLCreateN_1.SelectedFileInDirectoryToString(key_create_sql_n_1);
            req_update_sql     = qSQLUpdateN.SelectedFileInDirectoryToString(key_update_sql);
            req_delete_view    = qSQLDelete.SelectedFileInDirectoryToString(DROP_VIEW_TABLE);



            Assert.IsNotNull(manager);
            //Creation Base N-1
            bool   success     = true;
            int    querieCount = 0;
            string error       = "";
            string failedQuery = "";

            manager.ExecuteScript(req_delete_view, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);

            manager.ExecuteScript(req_create_sql_n_1, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);

            manager.ExecuteScript(req_update_sql, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);



            //Attribute Current et Old et  version N-1 et N
            //Selection SQL N-1 Create
            //Execute SQL N-1 Create
            //Execute SQL N Update
            //Chargement du schema N en base
            //Comparaison avec le shema de base de donnee commitee
        }
예제 #9
0
        public void TestCreateDatabase()
        {
            DatabaseManager manager = (DatabaseManager)container["DatabaseManager"];

            //Recherche Fichier Schema
            string current;
            string expected;
            string dropview;

            //variable resulat query
            string resultat_req_create_sql_n_1;
            string resultat_req_create_sql_n;
            string resultat_req_update_sql;

            //variable resultat create
            string req_create_sql_n_1;
            string req_create_sql_n;
            string req_update_sql;
            string req_delete_view;

            //variable key
            string key_create_sql_n_1;
            string key_create_sql_n;
            string key_update_sql;

            QueryXML qXML=new QueryXML(ConfigSettings.GetInstance().GetDirectory);
            current = qXML.FindValueOfFileXML("upgrade", "current", UPGRADE_SCHEMA_FILE_NAME);
            expected = qXML.FindValueOfFileXML("upgrade", "expected", UPGRADE_SCHEMA_FILE_NAME);

            QueryFilesSQL qSQLCreateN_1 = new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);
            QueryFilesSQL qSQLUpdateN= new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);
            QueryFilesSQL qSQLDelete=new QueryFilesSQL(ConfigSettings.GetInstance().GetDirectory);

            key_create_sql_n_1 = string.Concat(CREATE_DATABASE, current);
            key_create_sql_n = string.Concat(CREATE_DATABASE, expected);
            key_update_sql = string.Concat(UPDATE_DATABASE, current, AND, expected);

            req_create_sql_n_1 = qSQLCreateN_1.SelectedFileInDirectoryToString(key_create_sql_n_1);
            req_update_sql = qSQLUpdateN.SelectedFileInDirectoryToString(key_update_sql);
            req_delete_view=qSQLDelete.SelectedFileInDirectoryToString(DROP_VIEW_TABLE);

            Assert.IsNotNull(manager);
            //Creation Base N-1
            bool success=true;
            int querieCount=0;
            string error="";
            string failedQuery="";

            manager.ExecuteScript(req_delete_view, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);

            manager.ExecuteScript(req_create_sql_n_1, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);

            manager.ExecuteScript(req_update_sql, false, ref success, ref querieCount, ref error, ref failedQuery, null);
            Assert.IsTrue(success);

            //Attribute Current et Old et  version N-1 et N
            //Selection SQL N-1 Create
            //Execute SQL N-1 Create
            //Execute SQL N Update
            //Chargement du schema N en base
            //Comparaison avec le shema de base de donnee commitee
        }