Пример #1
0
        public Occasion CreateOccasion(DateTime startDate, DateTime endDate, DayOfWeekMask validDays)
        {
            if (startDate > endDate)
            {
                throw new ArgumentException("endDate is set before startDate");
            }

            return(new Occasion(startDate, endDate, validDays));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Occasion"/> class.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="mask">The mask.</param>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// startTime;Must be between greater or equal to zero and less than a day
        /// or
        /// endTime;Must be between greater or equal to zero and less than a day
        /// </exception>
        public Occasion(DateTime startDate, DateTime endDate, DayOfWeekMask mask, TimeSpan startTime,
                        TimeSpan endTime) : this(startDate, endDate, mask)
        {
            if (TimeSpan.Zero > startTime || TimeSpan.FromHours(24) <= startTime)
            {
                throw new ArgumentOutOfRangeException("startTime", startTime, "Must be between greater or equal to zero and less than a day");
            }

            if (TimeSpan.Zero > endTime || TimeSpan.FromHours(24) <= endTime)
            {
                throw new ArgumentOutOfRangeException("endTime", endTime, "Must be between greater or equal to zero and less than a day");
            }

            StartTime = startTime;
            EndTime   = endTime;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Occasion"/> class.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="mask">The mask.</param>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// startTime;Must be between greater or equal to zero and less than a day
        /// or
        /// endTime;Must be between greater or equal to zero and less than a day
        /// </exception>
        public Occasion(DateTime startDate, DateTime endDate, DayOfWeekMask mask, TimeSpan startTime,
            TimeSpan endTime) : this(startDate, endDate, mask)
        {
            if (TimeSpan.Zero > startTime || TimeSpan.FromHours(24) <= startTime)
            {
                throw new ArgumentOutOfRangeException("startTime", startTime, "Must be between greater or equal to zero and less than a day");
            }

            if(TimeSpan.Zero > endTime || TimeSpan.FromHours(24) <= endTime)
            {
                throw new ArgumentOutOfRangeException("endTime", endTime, "Must be between greater or equal to zero and less than a day");
            }

            StartTime = startTime;
            EndTime = endTime;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Occasion"/> class.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="mask">The mask.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// startDate;Must not be equals to end date, that is a zero period and does not exist.
        /// or
        /// endDate;Must be after start date:  + startDate
        /// </exception>
        public Occasion(DateTime startDate, DateTime endDate, DayOfWeekMask mask)
        {
            if (startDate == endDate)
            {
                throw new ArgumentOutOfRangeException("startDate", startDate, "Must not be equals to end date, that is a zero period and does not exist.");
            }

            if (startDate > endDate)
            {
                throw new ArgumentOutOfRangeException("endDate", endDate, "Must be after start date: " + startDate);
            }

            StartDate = startDate;
            EndDate   = endDate;
            Weekdays  = mask;
            StartTime = null;
            EndTime   = null;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Occasion"/> class.
        /// </summary>
        /// <param name="startDate">The start date.</param>
        /// <param name="endDate">The end date.</param>
        /// <param name="mask">The mask.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// startDate;Must not be equals to end date, that is a zero period and does not exist.
        /// or
        /// endDate;Must be after start date:  + startDate
        /// </exception>
        public Occasion(DateTime startDate, DateTime endDate, DayOfWeekMask mask)
        {
            if (startDate == endDate)
            {
                throw new ArgumentOutOfRangeException("startDate", startDate, "Must not be equals to end date, that is a zero period and does not exist.");
            }

            if (startDate > endDate)
            {
                throw new ArgumentOutOfRangeException("endDate", endDate, "Must be after start date: " + startDate);
            }

            StartDate = startDate;
            EndDate = endDate;
            Weekdays = mask;
            StartTime = null;
            EndTime = null;
        }
Пример #6
0
        public static DayOfWeekMask ConvertStringToDays(string source)
        {
            if (string.IsNullOrEmpty(source))
            {
                return(0);
            }
            DayOfWeekMask days = 0;

            foreach (var token in source.Split(','))
            {
                switch (token.ToUpper())
                {
                case "MO":
                    days = days | DayOfWeekMask.Monday;
                    break;

                case "TU":
                    days = days | DayOfWeekMask.Tuesday;
                    break;

                case "WE":
                    days = days | DayOfWeekMask.Wednesday;
                    break;

                case "TH":
                    days = days | DayOfWeekMask.Thursday;
                    break;

                case "FR":
                    days = days | DayOfWeekMask.Friday;
                    break;

                case "SA":
                    days = days | DayOfWeekMask.Saturday;
                    break;

                case "SU":
                    days = days | DayOfWeekMask.Sunday;
                    break;
                }
            }
            return(days);
        }
Пример #7
0
        public static string ConvertDaysToString(DayOfWeekMask source)
        {
            string day = "";

            foreach (var token in Enum.GetValues(typeof(DayOfWeekMask)))
            {
                DayOfWeekMask value = source & (DayOfWeekMask)token;
                switch (value)
                {
                case DayOfWeekMask.Monday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Tuesday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Wednesday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Thursday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Friday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Saturday:
                    day += "Mo";
                    break;

                case DayOfWeekMask.Sunday:
                    day += "Mo";
                    break;
                }
            }
            return(day);
        }
Пример #8
0
        public static void CommentedCode()
        {
            //string table = "RateRuleSiteType";
            //string folder = @"C:\Documents and Settings\v-elluo\Desktop\";
            //FileReader fileReader = new FileReader();
            //List<string> columns = fileReader.ReadFile(string.Format("{0}{1}Columns.txt", folder, table));
            //List<string> codeLines = fileReader.ReadFile(string.Format("{0}{1}.txt", folder, table));
            //SqlConnection myConnection = new SqlConnection(
            //    "Data Source=lodginginventorytx1.db.LISQA3.sb.karmalab.net,1433;Initial Catalog=LodgingInventoryMaster;Integrated Security=SSPI");

            //try
            //{
            //    SqlDataReader myReader = null;
            //    StringBuilder output = new StringBuilder();
            //    foreach (string column in columns)
            //    {
            //        StringBuilder values = new StringBuilder();
            //        myConnection.Open();
            //        string select = string.Format(
            //            "SELECT * FROM (SELECT DISTINCT CAST({0} AS VARCHAR(MAX)) AS VALUE FROM dbo.{1} WITH (NOLOCK)) AS T ORDER BY T.VALUE",
            //            column,
            //            table);
            //        SqlCommand myCommand = new SqlCommand(select, myConnection);
            //        myReader = myCommand.ExecuteReader();
            //        int count = 0;
            //        while (myReader.Read())
            //        {
            //            count++;
            //            values.Append(string.Format("{0}, ", myReader["VALUE"]));
            //            if (count > 10) break;
            //        }
            //        myConnection.Close();

            //        string outputLine = column;
            //        for (int i = 0; i < codeLines.Count; i++)
            //        {
            //            string line = codeLines.ElementAt(i);
            //            if (line.Contains(column))
            //            {
            //                int index;
            //                if (line.Contains(",") || line.Contains(";"))
            //                {
            //                    index = line.IndexOf("=");
            //                    if (index > 0)
            //                    {
            //                        outputLine = string.Format("{0}\t{1}\t{2}", column, values.ToString(), line.Substring(index + 2));
            //                    }
            //                }
            //                else
            //                {
            //                    string targetLine = line;
            //                    if (i + 2 < codeLines.Count)
            //                    {
            //                        targetLine = codeLines.ElementAt(i + 1).Trim() + codeLines.ElementAt(i + 2).Trim();
            //                    }
            //                    index = targetLine.IndexOf(":");
            //                    outputLine = string.Format("{0}\t{1}\t{2}", column, values.ToString(), targetLine);
            //                    i += 2;
            //                }
            //            }
            //        }
            //        output.AppendLine(outputLine);
            //    }

            //    string final = table + "\r\n\r\n" + output.ToString();
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.ToString());
            //}
            //finally
            //{
            //    myConnection.Close();
            //}
            FileReader    reader = new FileReader();
            List <string> lines  = reader.ReadFile("C:\\Documents and Settings\\v-elluo\\Desktop\\Expected.txt");
            List <string> actual = reader.ReadFile("C:\\Documents and Settings\\v-elluo\\Desktop\\Actual.txt");

            string        prefix   = "Expedia.Automation.Test.Hotels.APM.RatePlanUpdate.Negative.RatePlanUpdateNegativeTest.";
            List <string> expected = new List <string>();

            foreach (string line in lines)
            {
                if (line.Contains(prefix))
                {
                    int    index      = line.IndexOf(prefix);
                    string methodName =
                        line.Substring(index + prefix.Length, line.Length - index - prefix.Length - 2);
                    expected.Add(methodName);
                }
            }

            StringBuilder message = new StringBuilder();

            message.AppendLine("Below methods in LRM should be deleted:");
            foreach (string method in actual)
            {
                if (!expected.Contains(method))
                {
                    message.AppendLine(method);
                }
            }

            message.AppendLine();
            message.AppendLine("Below methods should be added to LRM:");
            foreach (string method in expected)
            {
                if (!actual.Contains(method))
                {
                    message.AppendLine(method);
                }
            }
            List <int> dayOfWeekMaskList = new List <int>()
            {
                //DayOfWeekMask.Monday,
                //DayOfWeekMask.Tuesday,
                DayOfWeekMask.Wednesday,
                //DayOfWeekMask.Thursday,
                //DayOfWeekMask.Friday,
                //DayOfWeekMask.Saturday,
                DayOfWeekMask.Sunday,
                DayOfWeekMask.Monday,
                DayOfWeekMask.Tuesday,
                //DayOfWeekMask.Wednesday,
                //DayOfWeekMask.Thursday,
                //DayOfWeekMask.Friday,
                //DayOfWeekMask.Saturday,
                DayOfWeekMask.Sunday
            };

            int value = DayOfWeekMask.ConvertToSystem(dayOfWeekMaskList);
            RatePlan_NoIdent ratePlan = new RatePlan_NoIdent();
            RatePlan_NoIdent copiedRatePlan;

            ratePlan.RatePlanID     = 1;
            ratePlan.RatePlanTypeID = 2;

            List <RatePlan_NoIdent> ratePlanList = new List <RatePlan_NoIdent>();

            ratePlanList.Add(ratePlan);

            List <RatePlan_NoIdent> copiedRatePlanList;

            //CopyValue(ratePlan, copiedRatePlan);
            copiedRatePlan     = CloneValue(ratePlan);
            copiedRatePlanList = CloneValue(ratePlanList);

            List <MyList> list = new List <MyList>
            {
                new MyList(0),
                new MyList(1)
            };
            IEnumerable <MyList> r1 = list.Where(m => m.age == 1);
            IEnumerable <MyList> r2 = list.Where(m => m.age == 2);

            //const byte Sunday = 0x01;
            //const byte Monday = 0x02;
            //const byte Tuesday = 0x04;
            //const byte Wednesday = 0x08;
            //const byte Thursday = 0x10;
            //const byte Friday = 0x20;
            //const byte Saturday = 0x40;
            //const byte All = 0x7f;

            //System.Diagnostics.Debug.WriteLine(Sunday + Monday);

            //BrowserControllerForm form = new BrowserControllerForm();
            //Application.Run(form);

            Name name = new Name();

            name.FirstName = "Elvin";
            name.LastName  = "Luo";

            Person p = new Person();

            p.Age = 0;
            SetObjectProperty(p, "Age", 10);
            SetObjectProperty(p, "Name", name);
            SetObjectProperty(p, "Name.FirstName", "New first name");
            SetObjectProperty(p, "Name.LastName", "New last name");
            //int Expedia = 0x00080000;
            //int ExpediaCorporate = 0x00800000;
            //int ExpediaPackage = 0x01000000;
            //System.Diagnostics.Debug.WriteLine(Expedia);
            //System.Diagnostics.Debug.WriteLine(ExpediaCorporate);
            //System.Diagnostics.Debug.WriteLine(ExpediaPackage);

            //string source = "~!@#$%^&()_+{}|:\"<>?`-=[]\\;',./";
            //char[] array = source.ToCharArray();

            //DataTable table = new DataTable();
            //table.Columns.Add("c1");
            //table.Columns.Add("c2");
            //string[] rowString = new string[] { "PDP", "1" };
            //table.Rows.Add(rowString);
            //rowString = new string[] { "PDP", "2" };
            //table.Rows.Add(rowString);
            //rowString = new string[] { "PPP", "2" };
            //table.Rows.Add(rowString);
            //DataRow[] rows = table.Select("NOT c1='PDP' AND c2='2'");

            //List<string> stringList = new List<string> { "PDP1", "OBP2", "PDP1", "OBP2", "PDP1" };

            //int index1;
            //index1 = stringList.IndexOf("PDP1");
            //index1 = stringList.IndexOf("OBP2");

            //List<string[]> stringArrayList = new List<string[]>();
            //string[] stringArray = new string[2];
            //stringArray = new string[] { "PDP", "1" };
            //stringArrayList.Add(stringArray);
            //stringArray = new string[] { "OBP", "2" };
            //stringArrayList.Add(stringArray);
            //stringArray = new string[] { "PDP", "1" };
            //stringArrayList.Add(stringArray);
            //stringArray = new string[] { "OBP", "2" };
            //stringArrayList.Add(stringArray);
            //stringArray = new string[] { "PDP", "1" };
            //stringArrayList.Add(stringArray);
            //stringArrayList.Distinct();

            //int index2;
            //index2 = stringArrayList.IndexOf(new string[] { "PDP", "1" });
            //index2 = stringArrayList.IndexOf(new string[] { "OBP", "2" });

            //List<int[]> intArrayList = new List<int[]>();
            //int[] intArray = new int[2];
            //intArray = new int[] { 1, 2 };
            //intArrayList.Add(intArray);
            //intArray = new int[] { 2, 2 };
            //intArrayList.Add(intArray);
            //intArray = new int[] { 1, 2 };
            //intArrayList.Add(intArray);
            //intArray = new int[] { 2, 2 };
            //intArrayList.Add(intArray);
            //intArray = new int[] { 1, 2 };
            //intArrayList.Add(intArray);
            //intArrayList.Distinct();

            //int index3;
            //index3 = intArrayList.IndexOf(new int[] { 1, 2 });
            //index3 = intArrayList.IndexOf(new int[] { 2, 2 });

            //string str1 = "1/2/";
            //string str2 = "/1/2";

            //string[] array = str1.Split('/');
            //array = str2.Split('/');

            //TestInstance a = new TestInstance(1, 2);
            //TestInstance b = new TestInstance();
            //b = a;
            //b.i = 3;
            //b.j = 4;

            //Convert<int>(1);
            //Convert<string>("s");
            //Convert<bool>(true);
            //MergeTables();

            //int originalV = 3;
            //int originalH = (originalV & 2) >> 1;
            //int originalL = originalV & 1;
            //int? h = null;
            //int? l = null;
            //int result = 10 * (h.HasValue ? h.Value : originalH) +
            //    (l.HasValue ? l.Value : originalL);
            //int j = System.Convert.ToInt32(result.ToString(), 2);

            //Dictionary<string, string> expected = new Dictionary<string, string>
            //{ { "200021792", "289400" },
            //{ "200021030", "Automation 000711182612" } };

            //Dictionary<string, string> actual = new Dictionary<string, string>
            //{{ "200021030", "Automation 000711182612" },
            //{ "200021792", "289400" }};

            //bool result = IsEquals(expected, actual);

            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new BrowserControllerForm());
        }
        public Occasion CreateOccasion(DateTime startDate, DateTime endDate, TimeSpan startTime, TimeSpan endTime, DayOfWeekMask validDays)
        {
            if (startDate > endDate)
            {
                throw new ArgumentException("endDate is set before startDate");
            }

            return new Occasion(startDate, endDate, validDays, startTime, endTime);
        }