Ejemplo n.º 1
0
        }//end AddNode2ISummaryXML

        #endregion
        /// <summary>
        /// Convert an Installation object into XMLDocument.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public static XmlDocument GetAsXMLDocument(ref Installation i)
        {
            try {
                //Dim t As New TimerUtil("5 GetAsXMLDocument (returns an XMLDocument from Installation)")
                //t.startTimer()
                //working ~20sec
                XmlDocument  doc    = new XmlDocument();
                MemoryStream stream = new MemoryStream();
                AppSettings.oXS.Serialize(stream, i);
                stream.Position = 0;
                doc.Load(stream);
                stream.Flush();
                stream.Close();
                stream = null;

                //  t.endTimer()
                //Debug.Print("5 Created XML Document length: " & vbTab & doc.InnerXml.Length)
                //Debug.Print(t.outputDetails())


                //Dim f As New StreamWriter("C:\GetAsXMLDocument5.xml", FileMode.Create)
                //f.Write(doc.InnerXml)
                //f.Flush()
                //f.Close()

                return(doc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static int?GetServiceIDByServName_Int(string servName)
        {
            try {
                var allServsFound  = GetServiceIDByServName(servName);
                int numbServsFound = allServsFound.Rows.Count;

                //if data wasnt found
                if (numbServsFound == 0)
                {
                    return(null);
                }
                //more than 1
                else if (numbServsFound > 1)
                {
                    throw new Exception("BLL.ServicesBLL.GetServiceIDByServName_Int(x1), MORE THAN ONE SERVICE WAS FOUND WITH THE GIVEN NAME");
                }
                else  //count=1 return value
                {
                    return((int)allServsFound.Rows[0].ItemArray[0]);
                }
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 3
0
        public static string GetStaffByAgendaID(short?agendaID, bool isFirstName = true, bool isLastName = false)
        {
            try {
                //the index here matches the column index at PersonReturn Table
                int selectedIndex = 2;
                //change index if lastName is required
                if (isLastName)
                {
                    selectedIndex = 3;
                }

                //get all employees dataTable
                DataSet1Main.PersonReturnDataTable staff = GetEmployeeByAgendaID(agendaID);

                if (staff != null)
                {
                    return(staff.Rows[0].Field <string>(selectedIndex));
                }

                //else
                return(null);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex); return(null);
            }
        }
Ejemplo n.º 4
0
        /* public static void SaveAppoitmentToDB(ref Installation i) {
         *   try {
         *       //save appointments
         *       int? tempServID;
         *       foreach (ServicesBLL service in i.Services) {
         *           //save service
         *           tempServID = ServicesBLL.AddService(service.name, service.isCertifReq, service.isInsuranceReq, service.description, service.duration, service.durationUnit, service.price);
         *           service.ID = tempServID;
         *       }
         *   }
         *   catch (Exception ex) {
         *       ExceptionHandling.LogException(ref ex);
         *   }
         * }*/

        #endregion

        #region "Functions"
        public static List <string> GetStaff1stNameWithTitle(Installation i, bool is1stName = true, bool isLastName = false)
        {
            try {
                //create list to save services items
                List <string> liStaffNames = new List <string>();

                //loop through services
                foreach (EmployeeBLL staff in i.Employees)
                {
                    //select appropriate detail
                    if (is1stName)
                    {
                        //save service name  to new list of string
                        liStaffNames.Add(staff.title + " " + staff.firstName);
                    }
                    if (isLastName)
                    {
                        //save service name  to new list of string
                        liStaffNames.Add(staff.title + " " + staff.lastName);
                    }
                }

                return(liStaffNames);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// send email
        /// </summary>
        /// <param name="fromAddress"></param>
        /// <param name="toAddress"></param>
        /// <param name="mainBody"></param>
        /// <param name="subject"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static bool SendEmail(MailAddress fromAddress, MailAddress toAddress, string mainBody, string subject)
        {
            try {
                //create email message
                DeliveryNotificationOptions  DeliveryOptions = DeliveryNotificationOptions.OnFailure;
                System.Net.Mail.MailPriority Priority        = MailPriority.Normal;

                string      Attachfile = null;
                MailAddress bcc        = null;
                MailAddress CC         = null;

                //add header (greetings) to body
                dynamic Body = "<p></p>Dear " + toAddress.DisplayName.ToUpperInvariant() + "," + "<p></p>" + mainBody;
                //add footer to body
                Body = Body + "<p></p><br /><br />Kind Regards," + "<p></p><br />" + fromAddress.DisplayName.ToUpperInvariant();


                return(SendMail.Send(Body, subject, DeliveryOptions, Priority, toAddress, fromAddress, Attachfile, bcc, CC));
            }
            catch (Exception ex) {
                //do nothing if there is an exception logging an exception - really bad!
                System.Diagnostics.Debug.Print("Error in sending email exception " + Environment.NewLine + ex.StackTrace + Environment.NewLine + ex.Message);
                ExceptionHandling.LogException(ref ex);
                //UtilsShared.LogException(ex3);
                return(false);
            }
        }
Ejemplo n.º 6
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
Ejemplo n.º 7
0
        public static List <string> GetServiceDetailsFull(Installation i)
        {
            try {
                //create list to save services items
                List <string> liServNames = new List <string>();
                string        temp        = "";

                //loop through services
                foreach (ServicesBLL service in i.Services)
                {
                    //select appropriate detail
                    //save service name  to new list of string
                    temp = String.Format("{0, 177}, {1, 87} mins £ {2,500}", service.name, service.duration.ToString(), service.price.ToString());
                    System.Diagnostics.Debug.Print(temp);
                    temp = service.name.PadRight(35) + (service.duration.ToString() + " mins").PadRight(15) + "£ " + service.price.ToString();
                    System.Diagnostics.Debug.Print(temp);
                    liServNames.Add(temp);
                }

                return(liServNames);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 8
0
        }//end CreateDayScheduleXML

        public static List <int> GetTimesFromDayScheduleXML(XDocument xDoc)
        {
            try {
                // //load file
                //  var xmlDocument = XDocument.Load("fileName");

                //select booking time tags
                //get NatureBusiness code
                //  var indElem = from key in xmlDocument.Descendants("ID") where key.Parent.Element("Name").Value == natureOfBus select key.Value;

                //  var items = from key in xDoc.Descendants("Time") where key.ElementsAfterSelf.items[0].Value == "Busy"  select key.Value select key.value;
                var items = from key in xDoc.Descendants("Time") select key.Value;

                //convert items to list
                List <string> stringItems = items.ToList();

                //convert to ints
                List <int> intItems = new List <int>();
                // ... Loop with the foreach string.
                foreach (string value in stringItems)
                {
                    System.Diagnostics.Debug.Print(value);
                    //convert to int and add to list
                    intItems.Add((int)Utils.GetNumberInt(value));
                }

                return(intItems);
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.Print("<h2>BLL.DaySheculeXML.GetTimesFromDayScheduleXML(xdoc)</h2>\n" + ex.Message + "\n" + ex.InnerException + "\n" + ex.ToString());
                // Log the exception and notify system operators
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 9
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
Ejemplo n.º 10
0
        /// <summary>
        /// Add exception details to database - extra parameters which are to be added when using this on the website.
        ///
        /// Connection string is in settings.xml
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="logIt"></param>
        /// <remarks></remarks>
        private static void LogExceptionToDatabase(Exception exc, bool logIt, Guid?userID)
        {
            try {
                if (logIt)
                {
                    string innerException = "";
                    if (exc.InnerException == null)
                    {
                        innerException = "";
                    }
                    else
                    {
                        innerException = exc.InnerException.ToString();
                    }
                    Exceptions.AddException(System.DateTime.Now, exc.Source, exc.Message.ToString(), innerException, exc.StackTrace.ToString(), exc.TargetSite.ToString(), userID);
                }
            }
            catch (Exception ex) {
                //if there is an invalid UserID an exception happens here (f.k. INSERT if user id is not in asp_users table)
                System.Diagnostics.Debug.Print(ex.ToString() + "\n" + "userID: " + userID.ToString());

                //verify that all parameters are valid, including userID
                System.Diagnostics.Debug.Print("BLL.LogExceptionToDatabase function(). verify that all parameters are valid, including userID");
                System.Diagnostics.Debug.Print(System.DateTime.Now.ToString());
                System.Diagnostics.Debug.Print(ex.Source);
                System.Diagnostics.Debug.Print(ex.InnerException.ToString());
                System.Diagnostics.Debug.Print(ex.Message); ExceptionHandling.LogException(ref ex);
                System.Diagnostics.Debug.Print(ex.TargetSite.ToString());
                System.Diagnostics.Debug.Print(ex.StackTrace.ToString());
                System.Diagnostics.Debug.Print(userID.ToString());
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Return ToString value.
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        public override string ToString()
        {
            try {
                StringBuilder x      = new StringBuilder("Applications Settings:" + Environment.NewLine);
                var           _with1 = x;
                _with1.Append("SettingsXML filename: " + Environment.NewLine + SettingsXML + Environment.NewLine);
                _with1.Append("Exception Handling Settings: " + Environment.NewLine + base.ToString() + Environment.NewLine);
                //.Append("Email Notifications On" & vbTab & EmailNotificationsOn & vbCrLf)
                //.Append("Exception Recipient:" & vbTab & ExceptionRecipient & vbCrLf)
                //.Append("Record to DataBase:" & vbTab & RecordToDataBase & vbCrLf)

                _with1.Append("System User ID " + "\t" + SystemUserID.ToString() + Environment.NewLine);
                _with1.Append("Application Name " + "\t" + ApplicationName + Environment.NewLine);
                _with1.Append("Client" + "\t" + Client + Environment.NewLine);

                _with1.Append("ClientAsset" + "\t" + ClientAsset + Environment.NewLine);
                _with1.Append("ClientLogo" + "\t" + ClientLogo + Environment.NewLine);
                _with1.Append("ClientUnit " + "\t" + ClientUnit + Environment.NewLine);

                return(_with1.ToString());
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return("Error in creating ToString of AppSettings");
            }
        }
Ejemplo n.º 12
0
        public static bool?IsStaffBusy(SerializableDictionary <int, string> daySchedule, int time2Check)
        {
            try {
                //source http://www.dotnetperls.com/dictionary
                //ie: d.Remove("cat"); // Removes cat.

                string testResult;
                //TryGetValue implies, it tests for the key. It then returns the value if it finds the key.
                if (daySchedule.TryGetValue(time2Check, out testResult)) // Returns true or false.
                {
                    //print current status
                    System.Diagnostics.Debug.Print("Current Day Schedule Status at " + time2Check.ToString() + " is: " + testResult);
                    //check status is busy
                    if (testResult == GetDayStatusEnumString(DayStatusEnum.BUSY))
                    {
                        return(true);
                    }
                    else
                    {
                        //status is available
                        return(false);
                    }
                }

                //time paramater doesnt exist on dictionary
                //R   throw new Exception("Given time paramater doesnt exist on dictionary!");
                return(false);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex); return(null);
            }
        }
Ejemplo n.º 13
0
        public static DaySchedule GetDaySchedule(ref SerializableDictionary <DateTime, DaySchedule> staffCalendar, DateTime date2Add)
        {
            try {
                //clean dateTime parameter to only show date
                DateTime    cleanDate         = date2Add.Date;
                DaySchedule resultDaySchedule = null;

                //TryGet daySchedule for giving date
                if (staffCalendar.TryGetValue(cleanDate, out resultDaySchedule))
                {
                    //add daySchedule to local variable
                    //  SerializableDictionary<int, string> staffDaySchedule = resultDaySchedule.daySchedule;
                    //add to daySchedule and return
                    return(resultDaySchedule);
                }

                //this will be null if gets here
                return(resultDaySchedule);
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.Print("<h2>BLL.AgendaBLL.GetDaySchedule(x2)</h2>\n" + ex.ToString() + "\n" + ex.InnerException + "\n" + ex.Message);
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end AddBooking
Ejemplo n.º 14
0
        public static bool Send(string Body, string Subject, DeliveryNotificationOptions DeliveryOptions, MailPriority Priority, MailAddress ToMail, MailAddress FromMail, string AttachFile, MailAddress bcc, MailAddress CC)
        {
            MailMessage mail = new MailMessage();

            // Check that the connection is good
            if (!DoesPing("securesend.lawyersonline.co.uk"))
            {
                //Need to try another time
                //set flag for retry?
                return(false);
            }

            using (mail) {
                try {
                    var _with1 = mail;
                    if ((AttachFile != null) && System.IO.File.Exists(AttachFile))
                    {
                        //check that file exists Throw exception?
                        Attachment item = new Attachment(AttachFile);
                        _with1.Attachments.Add(item);
                    }
                    if ((bcc != null))
                    {
                        _with1.Bcc.Add(bcc);
                    }
                    if ((CC != null))
                    {
                        _with1.CC.Add(CC);
                    }
                    _with1.BodyEncoding = System.Text.Encoding.Unicode;
                    _with1.To.Add(ToMail);
                    _with1.From     = FromMail;
                    _with1.Priority = Priority;
                    _with1.DeliveryNotificationOptions = DeliveryOptions;
                    if ((FromMail != null))
                    {
                        _with1.ReplyTo = FromMail;
                    }
                    _with1.Sender     = FromMail;
                    _with1.Subject    = Subject;
                    _with1.Body       = Body;
                    _with1.IsBodyHtml = true;
                    SmtpClient SmtpMail = new SmtpClient();
                    var        _with2   = SmtpMail;
                    _with2.Host           = "securesend.lawyersonline.co.uk";
                    _with2.DeliveryMethod = SmtpDeliveryMethod.Network;
                    _with2.Send(mail);
                    //smtpMail
                    //mail
                    return(true);
                }
                catch (Exception ex) {
                    System.Diagnostics.Debug.Print(ex.Message); ExceptionHandling.LogException(ref ex);
                    return(false);
                }
            }
            //mail
        }
Ejemplo n.º 15
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
Ejemplo n.º 16
0
 public static Guid?GetUserIDByUserName(string userName)
 {
     try {
         return(AspNetUser.GetUserIDByUserName(userName));
     }
     catch (Exception ex) {
         ExceptionHandling.LogException(ref ex);
         return(null);
     }
 }
Ejemplo n.º 17
0
 public static bool AddBooking(ref SerializableDictionary <int, string> daySchedule, int time2Add)
 {
     try {
         //add to calendar.
         // calendar.Add(time2Add, GetAgendaEnumString(AgendaStatusEnum.BUSY));
         //NB--19/7 wot if time2Add doesnt exist? should calendar.Add() then???? TEST
         // ------ assume time already exists ------------
         //set unavailable to  calendar
         daySchedule[time2Add] = GetDayStatusEnumString(DayStatusEnum.BUSY);
         return(true);
     }
     catch (Exception ex) {
         ExceptionHandling.LogException(ref ex); return(false);
     }
 }
Ejemplo n.º 18
0
 public void SetCompanyOpeningDays(List <bool> items2Set)
 {
     try {
         //loop throught selected list
         // foreach (int time in selectedEnum) {
         for (int i = 0; i < OpeningDays.Count; i++)
         {
             //set given time
             OpeningDays[i] = items2Set[i];
         }
     }
     catch (Exception ex) {
         ExceptionHandling.LogException(ref ex);
     }
 }
Ejemplo n.º 19
0
        }//end AddAppt2DayScheduleXML

        /// <summary>
        ///Returns the XMLDocument created from staff daily Shedule
        /// it returns fileName by default
        /// </summary>
        /// <param name="employee"></param>
        /// <param name="filePath"></param>
        /// <param name="date"></param>
        /// <param name="isFileNameReq"></param>
        /// <returns></returns>
        public static XmlDocument CreateXMLFromDaySchedule(EmployeeBLL employee, string filePath, DateTime date)
        {
            try {
                //get staff's agenda calendar
                SerializableDictionary <DateTime, DaySchedule> staffCalendar = employee.agenda.staffCalendar;
                //get staff day schedule for given day
                DaySchedule employeeDaySchedule = AgendaBLL.GetDaySchedule(ref staffCalendar, date);

                //create XML file
                XmlDocument xdoc     = new XmlDocument();
                string      fileName = DayScheduleXML.CreateDayScheduleXML(filePath, employee.agenda.ID, date, isFileNameReq: true);

                if (employeeDaySchedule != null)
                {
                    //loop through day schedule. ie: each hr and 1/h of the staff agenda
                    foreach (var pair in employeeDaySchedule.daySchedule)
                    {
                        //get time and availability
                        int    tempTime       = pair.Key;   //ie: 1100, 1130
                        string tempTimeStatus = pair.Value; //ie BUSY, AVAILABLE
                        System.Diagnostics.Debug.Print("Key: {0},  Value: {1}", tempTime, tempTimeStatus);


                        //check if staff is busy
                        if (pair.Value == DaySchedule.GetDayStatusEnumString(DayStatusEnum.BUSY))
                        {
                            //Add child to xml / appointment
                            xdoc = DayScheduleXML.AddApptNode2DayScheduleXML(fileName, date, tempTime);
                        }
                    } //endforloop
                }     //endif
                else
                {
                    //staff daySchedule is empty so enable all buttons
                    System.Diagnostics.Debug.Print("<h2>BLL.DayScheduleXML.CreateXMLFromDaySchedule()</h2> \t  staff daySchedule is empty!");
                    return(null);
                }

                //return XML file
                return(xdoc);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }//end CreateDayScheduleXML
Ejemplo n.º 20
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
Ejemplo n.º 21
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
Ejemplo n.º 22
0
        public override string ToString()
        {
            try {
                //if (i == null)
                //    i = new Installation();
                StringBuilder x      = new StringBuilder();
                var           _with1 = x;
                _with1.Append("Installation:\n");

                //company
                _with1.Append("Company:\t" + this.Company.ToString() + "\n");

                //client (company main contact)
                _with1.Append("Client (company main contact):\t" + this.Company.mainClientContact.ToString() + "\n");

                //company contact details
                _with1.Append("Company Contact Details:\t" + this.Company.businessAddress.ToString() + "\n");

                //Services Provided by Staff
                _with1.Append("Services Provided by Staff:\t" + this.ServicesProvidedByStaff.ToString() + "\n");

                //Employees
                foreach (EmployeeBLL employee in this.Employees)
                {
                    _with1.Append("Employee:\t" + employee.ToString() + "\n");
                    _with1.Append("Employee Contact Detail:\t" + employee.contactDetail.ToString() + "\n");
                }

                //Services
                foreach (ServicesBLL service in this.Services)
                {
                    _with1.Append("Service:\t" + service.ToString() + "\n");
                }

                return(_with1.ToString());
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return("<h2>Error in Installation.cs ToString Function  </h2> \n" + ex.Message);
            }
        }
Ejemplo n.º 23
0
        public static List <string> GetAllStaff1stNames()
        {
            try {
                List <string> staffNames = new List <string>();
                //get all employees dataTable
                var allStaff = GetAllEmployees();

                // ... Loop over all rows.
                foreach (DataRow row in allStaff.Rows)
                {
                    // ... Write value of 3rd field as integer.
                    System.Diagnostics.Debug.Print(row.Field <string>(2));
                    //add name to list
                    staffNames.Add(row.Field <string>(2));
                }

                return(staffNames);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);     return(null);
            }
        }
Ejemplo n.º 24
0
        public void SetCompanyTimes(List <int> items2Set, bool isOpeningtime = true, bool isClosingTime = false)
        {
            try {
                //select enum required
                List <int> selectedEnum = OpeningTime;
                if (isClosingTime)
                {
                    selectedEnum = ClosingTime;
                }

                //loop throught selected list
                // foreach (int time in selectedEnum) {
                for (int i = 0; i < selectedEnum.Count; i++)
                {
                    //set given time
                    selectedEnum[i] = items2Set[i];
                }
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
            }
        }
Ejemplo n.º 25
0
        public static bool IsUserOfType(string aspUserName, bool isTypeClient = false, bool isTypeEndUser = false)
        {
            try {
                //get aspUserID
                Guid aspUserID   = (Guid)AppSettings.GetUserIDByUserName(aspUserName);
                var  curUser     = ClientBLL.GetPersonByASPuserID(aspUserID);
                byte curUserRole = 0;

                // get curUser ROLE
                if (curUser != null)
                {
                    curUserRole = (byte)curUser.Rows[0].ItemArray[5];
                }

                //check parameters condition which applys
                if (isTypeClient)
                {
                    if (curUserRole == (byte)RolesEnum.CLIENT)
                    {
                        return(true);
                    }
                }

                if (isTypeEndUser)
                {
                    if (curUserRole == (byte)RolesEnum.END_USER)
                    {
                        return(true);
                    }
                }

                //for now 18/7/16  --- anything else return false
                return(false);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(false);
            }
        }
Ejemplo n.º 26
0
        public static List <string> GetServiceDetails(Installation i, bool isNames = true, bool isDesc = false, bool isDuration = false, bool isPrice = false)
        {
            try {
                //create list to save services items
                List <string> liServNames = new List <string>();

                //loop through services
                foreach (ServicesBLL service in i.Services)
                {
                    //select appropriate detail
                    if (isNames)
                    {
                        //save service name  to new list of string
                        liServNames.Add(service.name);
                    }
                    if (isDesc)
                    {
                        //save service name  to new list of string
                        liServNames.Add(service.description);
                    }
                    if (isDuration)
                    {
                        //save service name  to new list of string
                        liServNames.Add(service.duration.ToString());
                    }
                    if (isPrice)
                    {
                        //save service name  to new list of string
                        liServNames.Add(service.price.ToString());
                    }
                }

                return(liServNames);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(null);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Get object with exception handling settings
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static AppSettings GetAppSettings(string filename)
        {
            try {
                if (!File.Exists(filename))
                {
                    System.Diagnostics.Debug.Print("BLL.AppSettings.GetAppSettings(): EXCEPTION in GetAppSettings: FileNotFoundException: " + filename);
                    throw new FileNotFoundException("Exception in BLL.AppSettings.GetAppSettings()" + filename + " cannot be found /  accessed");
                }

                //load exception handling settings
                //sdkfj assign to this public class
                // dynamic exceptions = GetExceptionHandlingSettings(filename);

                //create new instance of AppSettings
                AppSettings sharedSets = new AppSettings();

                //load the settings XML file
                dynamic doc = XDocument.Load(filename);

                //query XML to get all children of Settings--Setting
                dynamic y = doc.Element(XMLConstants.Settings).Elements(XMLConstants.Setting);

                //create settings object from values in
                var _with2 = sharedSets;
                //SettingsXML
                _with2.SettingsXML = filename;

                ////exception
                //_with2.EmailNotificationsOn = exceptions.EmailNotificationsOn;
                //_with2.RecordToDataBase = exceptions.RecordToDataBase;
                //_with2.ExceptionRecipient = exceptions.ExceptionRecipient;

                ////client
                //_with2.SystemUserID = new Guid(UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.SystemUserID));
                //_with2.ApplicationName = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.ApplicationName);
                //_with2.Client = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.CLIENT);

                //_with2.ClientAsset = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.ClientAsset);
                //_with2.ClientLogo = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.ClientLogo);
                //_with2.ClientUnit = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.ClientUnit);

                ////Q & A filename
                //_with2.QAFilename = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.QAFilename);

                ////units filename
                //_with2.UnitsXMLFilename = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.UnitsXMLFilename);

                ////demo
                //_with2.TotalLoginsAllowed = UtilsShared.GetNumberInt(UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.TotalPeriodAllowed));
                //_with2.NumberOfLogins = UtilsShared.GetNumberInt(UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.NumberOfLogins));
                // _with2.ApplicationsXML = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.ApplicationsXML);


                // _with2.TagMatchingXml = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.TagMatchingXml);
                //_with2.InstallationDemoXML = UtilsShared.GetSettingValueUsingLINQ(y, XMLConstantsShared.InstallationDemoXML);

                return(sharedSets);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex); return(null);
            }
        }
Ejemplo n.º 28
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
Ejemplo n.º 29
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
Ejemplo n.º 30
0
        }//end AddNode2ISummaryXML

        public static List <int> GetIDsList(XmlDocument iSumXmlDoc, string perform)
        {
            try {
                //convert to XDoc
                XDocument xDoc = XDocument.Parse(iSumXmlDoc.OuterXml);
                //check file is not null
                xDoc = xDoc ?? new XDocument();

                string id2Search = "";

                //select ID according to given parameter
                switch (perform)
                {
                case iTimestamp:
                    // case operations
                    id2Search = iTimestamp;
                    break;

                case iCompanyID:
                    // case operations
                    id2Search = iCompanyID;
                    break;

                case iEmpID:
                    // case operations
                    id2Search = iEmpID;
                    break;

                case iServID:
                    // case operations
                    id2Search = iServID;
                    break;

                case iuserID:
                    // case operations
                    id2Search = iuserID;
                    break;

                case iApptID:
                    // case operations
                    id2Search = iApptID;
                    break;
                    //   default:
                    // Do nothing
                }

                //ie:   get NatureBusiness code
                //  var indElem = from key in xmlDocument.Descendants("ID") where key.Parent.Element("Name").Value == natureOfBus select key.Value;

                //  var items = from key in xDoc.Descendants("Time") where key.ElementsAfterSelf.items[0].Value == "Busy"  select key.Value select key.value;
                var items = from key in xDoc.Descendants(id2Search) select key.Value;

                //convert items to list
                List <string> stringItems = items.ToList();

                //convert to ints
                List <int> intIDs = new List <int>();
                // ... Loop with the foreach string.
                foreach (string idStrg in stringItems)
                {
                    System.Diagnostics.Debug.Print(id2Search + "\t ID: \t" + idStrg);
                    //convert to int and add to list
                    intIDs.Add((int)Utils.GetNumberInt(idStrg));
                }

                return(intIDs);
            }
            catch (Exception ex) {
                ExceptionHandling.LogException(ref ex);
                return(new List <int>());
            }
        }//end AddNode2ISummaryXML