示例#1
0
 public static void InitializeProgram(Dictionary <PROGRAM, ProgramConfig> configs)
 {
     m_ProgramInfos.Clear();
     for (int i = (int)PROGRAM.NONE + 1; i < (int)PROGRAM.COUNT; ++i)
     {
         PROGRAM program = (PROGRAM)i;
         if (!configs.ContainsKey(program))
         {
             continue;
         }
         var         config = configs[program];
         ProgramInfo info   = new ProgramInfo(program);
         info.CodeDirectory = config.CodeDirectory;
         info.DataDirectory = config.DataDirectory;
         info.Create        = ToBoolean(config.Create, false);
         info.Compress      = ToBoolean(config.Compress, false);
         DefaultInfo defaultInfo = (DefaultInfo)Attribute.GetCustomAttribute(program.GetType().GetMember(program.ToString())[0], typeof(DefaultInfo));
         info.Extension       = defaultInfo.Extension;
         info.GenerateTable   = defaultInfo.GenerateTable != null ? (IGenerate)System.Activator.CreateInstance(defaultInfo.GenerateTable) : null;
         info.GenerateData    = (IGenerate)System.Activator.CreateInstance(defaultInfo.GenerateData);
         info.GenerateMessage = (IGenerate)System.Activator.CreateInstance(defaultInfo.GenerateMessage);
         info.GenerateEnum    = (IGenerate)System.Activator.CreateInstance(defaultInfo.GenerateEnum);
         info.GenerateConst   = (IGenerate)System.Activator.CreateInstance(defaultInfo.GenerateConst);
         info.Bom             = defaultInfo.Bom;
         m_ProgramInfos.Add(program, info);
     }
     PrintDirectory();
 }
        public void TestRooksMove()
        {
            ChessBoard board = new ChessBoard();

            DefaultInfo.SetDefaultValues();
            // board.SetDefaultChessBoard();
            board['a', 1] = (sbyte)DefaultPieces.WhiteRook;
            board['h', 1] = (sbyte)DefaultPieces.WhiteRook;
            board['c', 2] = (sbyte)DefaultPieces.WhiteKing;
            board['a', 8] = (sbyte)DefaultPieces.BlackRook;
            board['h', 8] = (sbyte)DefaultPieces.BlackRook;
            board['c', 7] = (sbyte)DefaultPieces.BlackKing;
            board         = FIDEnotation.PerformWhiteMove(board, "Rae1");
            Assert.IsFalse(DefaultInfo.WhiteAsideRookIsUnMoved);
            board = FIDEnotation.PerformBlackMove(board, "Rhe8");
            Assert.IsFalse(DefaultInfo.BlackHsideRookIsUnMoved);
            board = FIDEnotation.PerformWhiteMove(board, "Rhf1");
            Assert.IsFalse(DefaultInfo.WhiteHsideRookIsUnMoved);
            board = FIDEnotation.PerformBlackMove(board, "Rab8");
            Assert.IsFalse(DefaultInfo.BlackAsideRookIsUnMoved);
            board.DebugConsoleSimpleDraw();
            board = FIDEnotation.PerformWhiteMove(board, "Rf6");
            board = FIDEnotation.PerformWhiteMove(board, "Rfe6");
            board = FIDEnotation.PerformWhiteMove(board, "R6e3");
        }
示例#3
0
        private static void scaleEffectSub(Transform trans, TemplateList <DefaultInfo> default_infos /*, float size_scale*/, float speed_scale, int layer, ref int scale_info_index)
        {
            trans.gameObject.layer = layer;

            ParticleSystem particle_system = trans.GetComponent <ParticleSystem>();

            if (particle_system != null)
            {
                ParticleSystem.MainModule main_module = particle_system.main;

                DefaultInfo default_info = default_infos[scale_info_index++];

                //main_module.startSizeMultiplier = size_scale * scale_info.m_SizeScale;
                main_module.scalingMode     = ParticleSystemScalingMode.Hierarchy;
                main_module.simulationSpeed = speed_scale * default_info.m_SpeedScale;
#if REPLACE_SHADER
                if (default_info.m_Materials != null)
                {
                    ParticleSystemRenderer particle_system_renderer = particle_system.GetComponent <ParticleSystemRenderer>();
                    if (particle_system_renderer != null)
                    {
                        particle_system_renderer.materials = default_info.m_Materials;
                    }
                }
#endif //REPLACE_SHADER
            }

            for (int idx = 0; idx < trans.childCount; idx++)
            {
                Transform child_trans = trans.GetChild(idx);
                scaleEffectSub(child_trans, default_infos /*, size_scale*/, speed_scale, layer, ref scale_info_index);
            }
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.ConsumerPages.PaymentInformation class.
        /// </summary>
        /// <param name="defaultInfo">Specifies how to initialize the payment information.</param>
        public PaymentInformation(DefaultInfo defaultInfo) :
            this()
        {
            if (defaultInfo < DefaultInfo.Standard || defaultInfo > DefaultInfo.Standard)
            {
                throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
                                                      "Must be one of the following: Standard");
            }

            switch (defaultInfo)
            {
            case DefaultInfo.Standard:
            {
                PaymentType        = "credit card";
                CreditCardType     = "Visa";
                CreditCardNumber   = "4111111111111111";
                NameOnCard         = "Sue Axelband";
                CreditCardSecurity = "411";
                ExpirationMonth    = "08 - August";
                ExpirationYear     = "2012";
                break;
            }

            default:
                throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
            }
        }
示例#5
0
        public static void Access( string command, AccessLevel level )
        {
            try{

            if ( Server.Commands.Entries[command] == null )
                return;

            DefaultInfo info = new DefaultInfo();

            if ( !HasMod( command ) )
            {
                info = new DefaultInfo();
                info.OldCommand = command;
                info.NewCommand = command;
                info.NewAccess = level;
                info.OldAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel;
                s_Defaults[command] = info;
            }
            else
            {
                info = (DefaultInfo)s_Defaults[command];
                info.NewAccess = level;
            }

            CommandEntry entry = new CommandEntry( command, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.NewAccess );
            Server.Commands.Entries[command] = entry;

            foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
                foreach( string str in new ArrayList( imp.Commands.Keys ) )
                    if ( str == command )
                        ((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;

            }catch{ Errors.Report( "Commands-> Access-> AccessLevel" ); }
        }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the Lynda.Test.ConsumerPages.BillingInformation class.
 /// </summary>
 /// <param name="defaultInfo">Specifies how to initalize the billing information.</param>
 public BillingInformation(DefaultInfo defaultInfo)
     : this()
 {
     if (defaultInfo < DefaultInfo.Standard || defaultInfo > DefaultInfo.Standard)
     {
         throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
               "Must be one of the following: Standard");
     }
     switch (defaultInfo)
     {
         case DefaultInfo.Standard:
             {
                 FirstName="TESTfirstname";
                 LastName="test";
                 Company="lynda.com";
                 Address="6410 via real";
                 Apt=null;
                 City="Carpinteria";
                 State="California";
                 Zip="93013";
                 Country="United States";
                 Phone="5555555555";
                 BillingEmail=null;
                 HowHear="Other";
                 break;
             }
         default:
             throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
     }
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.ConsumerPages.BillingInformation class.
        /// </summary>
        /// <param name="defaultInfo">Specifies how to initalize the billing information.</param>
        public BillingInformation(DefaultInfo defaultInfo) :
            this()
        {
            if (defaultInfo < DefaultInfo.Standard || defaultInfo > DefaultInfo.Standard)
            {
                throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
                                                      "Must be one of the following: Standard");
            }
            switch (defaultInfo)
            {
            case DefaultInfo.Standard:
            {
                FirstName    = "TESTfirstname";
                LastName     = "test";
                Company      = "lynda.com";
                Address      = "6410 via real";
                Apt          = null;
                City         = "Carpinteria";
                State        = "California";
                Zip          = "93013";
                Country      = "United States";
                Phone        = "5555555555";
                BillingEmail = null;
                HowHear      = "Other";
                break;
            }

            default:
                throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
            }
        }
示例#8
0
		public static void ApplyCommand( string old, string txt )
		{try{

            if (CommandSystem.Entries[txt] != null
            || CommandSystem.Entries[old] == null)
				return;

			if ( HasMod( old ) )
			{
				((DefaultInfo)s_Defaults[old]).NewCommand = txt;
				s_Defaults[txt] = s_Defaults[old];
				s_Defaults.Remove( old );
			}
			else
			{
				DefaultInfo info = new DefaultInfo();
				info.OldCommand = old;
				info.NewCommand = txt;
                info.NewAccess = ((CommandEntry)CommandSystem.Entries[old]).AccessLevel;
				info.OldAccess = info.NewAccess;
				s_Defaults[txt] = info;
			}

            CommandSystem.Entries[txt] = CommandSystem.Entries[old];
            CommandSystem.Entries.Remove(old);

			foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
				foreach( string str in new ArrayList( imp.Commands.Keys ) )
					if ( str == old )
					{
						imp.Commands[txt] = imp.Commands[str];
						imp.Commands.Remove( str );
					}

		}catch{ Errors.Report( "Commands-> ApplyCommand" ); } }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.ConsumerPages.PaymentInformation class.
        /// </summary>
        /// <param name="defaultInfo">Specifies how to initialize the payment information.</param>
        public PaymentInformation(DefaultInfo defaultInfo)
            : this()
        {
            if (defaultInfo<DefaultInfo.Standard || defaultInfo>DefaultInfo.Standard)
            {
                throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
                      "Must be one of the following: Standard");
            }

            switch (defaultInfo)
            {
                case DefaultInfo.Standard:
                    {
                        PaymentType="credit card";
                        CreditCardType="Visa";
                        CreditCardNumber="4111111111111111";
                        NameOnCard="Sue Axelband";
                        CreditCardSecurity="411";
                        ExpirationMonth="08 - August";
                        ExpirationYear="2012";
                        break;
                    }
                default:
                    throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
            }
        }
        internal String Delete(int id)
        {
            // NOTE: Why do we declare data? We don't use it...
            DefaultInfo data = GetById(id);

            _repo.Delete(id);
            return("delorted");
        }
        internal DefaultInfo Edit(DefaultInfo updated)
        {
            DefaultInfo data = GetById(updated.Id);

            data.Name   = updated.Name != null ? updated.Name : data.Name;
            data.Amount = updated.Amount != null ? updated.Amount : data.Amount;

            return(_repo.Edit(data));
        }
        internal DefaultInfo GetById(int id)
        {
            DefaultInfo data = _repo.GetById(id);

            if (data == null)
            {
                throw new Exception("Invalid Id");
            }
            return(data);
        }
 public ActionResult <DefaultInfo> Create([FromBody] DefaultInfo newDefaultInfo)
 {
     try
     {
         return(Ok(_service.Create(newDefaultInfo)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public ActionResult <DefaultInfo> EditDefaultInfo([FromBody] DefaultInfo updated, int id)
 {
     try
     {
         updated.Id = id;
         return(Ok(_service.Edit(updated)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 public void TestSetDefaultValues()
 {
     DefaultInfo.SetDefaultValues();
     Assert.IsTrue(DefaultInfo.IsWhiteMove);
     Assert.IsFalse(DefaultInfo.WhiteWin);
     Assert.IsFalse(DefaultInfo.BlackWin);
     Assert.IsTrue(DefaultInfo.WhiteAsideRookIsUnMoved);
     Assert.IsTrue(DefaultInfo.WhiteKingIsUnMoved);
     Assert.IsTrue(DefaultInfo.WhiteHsideRookIsUnMoved);
     Assert.IsTrue(DefaultInfo.BlackKingIsUnMoved);
     Assert.IsTrue(DefaultInfo.BlackAsideRookIsUnMoved);
     Assert.IsTrue(DefaultInfo.BlackHsideRookIsUnMoved);
     Assert.IsFalse(DefaultInfo.WhiteEnPassantEndangered);
     Assert.IsFalse(DefaultInfo.BlackEnPassantEndangered);
 }
示例#16
0
        private void PublishHomework()
        {
            Info.Pictures.Clear();
            foreach (var pic in Pictures)
            {
                if (pic.IsChecked)
                {
                    Info.Pictures.Add(pic.FilePath);
                }
            }

            Info.Categ.Subject = this.CurrentSubject;
            string fromId    = "1";
            string timestamp = GetTimestamp(DateTime.Now).ToString();

            this.Tips = NetworkConnect.PublishHomeworkAsync(Info, fromId, timestamp).Result;
            DefaultInfo.WriteDefaultInfo(Info);
        }
示例#17
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.ConsumerPages.AccountInfo class.
        /// </summary>
        /// <param name="defaultInfo">Specifies how to initalize the account information.</param>
        public AccountInfo(DefaultInfo defaultInfo) :
            this()
        {
            if (defaultInfo < DefaultInfo.Standard || defaultInfo > DefaultInfo.Standard)
            {
                throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
                                                      "Must be one of the following: Standard");
            }
            switch (defaultInfo)
            {
            case DefaultInfo.Standard:
            {
                //Form fields
                FirstName = "TESTfirstname";
                LastName  = "test";
                System.DateTime currentDateTime = System.DateTime.Now;
                //short date from current DateTime e.g. "2/20/2012". Uses current culture e.g. mm/dd/yyyy
                string shortDate = currentDateTime.ToShortDateString();
                //Format for use as valid e-mail address e.g. 2-20-2012
                shortDate = shortDate.Replace('/', '-');
                //Fraction of the day that has elapsed since midnight
                TimeSpan timeSinceMidnight = currentDateTime.TimeOfDay;
                //Seconds since midnight e.g. 47003.9293606
                double secondsSinceMidnight = timeSinceMidnight.TotalSeconds;
                //Format lyndaqa-"shortDate"-"secondsSinceMidnight" to no decimal places.
                //e.g. lyndaqa-2-20-2012-47004
                Username        = String.Format("lyndaqa-{0}-{1:0.}", shortDate, secondsSinceMidnight);
                Email           = String.Format("{0}@mailinator.com", username);
                Password        = "******";
                PasswordConfirm = password;

                //No sign ups
                SignMeUpNewReleases = false;
                SignMeUpNewsletters = false;
                SignMeUpSpecial     = false;

                break;
            }

            default:
                throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
            }
        }
示例#18
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.ConsumerPages.AccountInfo class.
        /// </summary>
        /// <param name="defaultInfo">Specifies how to initalize the account information.</param>
        public AccountInfo(DefaultInfo defaultInfo)
            : this()
        {
            if (defaultInfo < DefaultInfo.Standard || defaultInfo > DefaultInfo.Standard)
            {
                throw new ArgumentOutOfRangeException("defaultInfo", defaultInfo,
                      "Must be one of the following: Standard");

            }
            switch (defaultInfo)
            {
                case DefaultInfo.Standard:
                    {
                        //Form fields
                        FirstName="TESTfirstname";
                        LastName="test";
                        System.DateTime currentDateTime = System.DateTime.Now;
                        //short date from current DateTime e.g. "2/20/2012". Uses current culture e.g. mm/dd/yyyy
                        string shortDate = currentDateTime.ToShortDateString();
                        //Format for use as valid e-mail address e.g. 2-20-2012
                        shortDate = shortDate.Replace('/', '-');
                        //Fraction of the day that has elapsed since midnight
                        TimeSpan timeSinceMidnight = currentDateTime.TimeOfDay;
                        //Seconds since midnight e.g. 47003.9293606
                        double secondsSinceMidnight = timeSinceMidnight.TotalSeconds;
                        //Format lyndaqa-"shortDate"-"secondsSinceMidnight" to no decimal places.
                        //e.g. lyndaqa-2-20-2012-47004
                        Username = String.Format("lyndaqa-{0}-{1:0.}", shortDate, secondsSinceMidnight);
                        Email = String.Format("{0}@mailinator.com", username);
                        Password = "******";
                        PasswordConfirm = password;

                        //No sign ups
                        SignMeUpNewReleases=false;
                        SignMeUpNewsletters=false;
                        SignMeUpSpecial=false;

                        break;
                    }
                default:
                    throw new Exception(String.Format("Code not implemented yet: {0}", defaultInfo.ToString()));
            }
        }
示例#19
0
        public static void RestoreCommand(string command)
        {
            try{
                if (!HasMod(command))
                {
                    s_Defaults.Remove(command);
                    CommandSystem.Entries.Remove(command);
                    return;
                }

                DefaultInfo  info  = (DefaultInfo)s_Defaults[command];
                CommandEntry entry = new CommandEntry(info.OldCommand, ((CommandEntry)CommandSystem.Entries[command]).Handler, info.OldAccess);
                CommandSystem.Entries.Remove(command);

                if (HasMod(info.OldCommand))
                {
                    RestoreCommand(info.OldCommand);
                }

                CommandSystem.Entries[info.OldCommand] = entry;

                s_Defaults.Remove(command);

                foreach (BaseCommandImplementor imp in BaseCommandImplementor.Implementors)
                {
                    foreach (string str in new ArrayList(imp.Commands.Keys))
                    {
                        if (str == command)
                        {
                            imp.Commands[info.OldCommand] = imp.Commands[str];
                            ((BaseCommand)imp.Commands[str]).AccessLevel = info.OldAccess;

                            if (str != info.OldCommand)
                            {
                                imp.Commands.Remove(str);
                            }
                        }
                    }
                }
            }
            catch { Errors.Report("Commands-> RestoreDefault"); }
        }
示例#20
0
        public static void ApplyCommand(string old, string txt)
        {
            try{
                if (CommandSystem.Entries[txt] != null ||
                    CommandSystem.Entries[old] == null)
                {
                    return;
                }

                if (HasMod(old))
                {
                    ((DefaultInfo)s_Defaults[old]).NewCommand = txt;
                    s_Defaults[txt] = s_Defaults[old];
                    s_Defaults.Remove(old);
                }
                else
                {
                    DefaultInfo info = new DefaultInfo();
                    info.OldCommand = old;
                    info.NewCommand = txt;
                    info.NewAccess  = ((CommandEntry)CommandSystem.Entries[old]).AccessLevel;
                    info.OldAccess  = info.NewAccess;
                    s_Defaults[txt] = info;
                }

                CommandSystem.Entries[txt] = CommandSystem.Entries[old];
                CommandSystem.Entries.Remove(old);

                foreach (BaseCommandImplementor imp in BaseCommandImplementor.Implementors)
                {
                    foreach (string str in new ArrayList(imp.Commands.Keys))
                    {
                        if (str == old)
                        {
                            imp.Commands[txt] = imp.Commands[str];
                            imp.Commands.Remove(str);
                        }
                    }
                }
            }catch { Errors.Report("Commands-> ApplyCommand"); }
        }
示例#21
0
        public static void Access(string command, AccessLevel level)
        {
            try{
                if (CommandSystem.Entries[command] == null)
                {
                    return;
                }

                DefaultInfo info = new DefaultInfo();

                if (!HasMod(command))
                {
                    info                = new DefaultInfo();
                    info.OldCommand     = command;
                    info.NewCommand     = command;
                    info.NewAccess      = level;
                    info.OldAccess      = ((CommandEntry)CommandSystem.Entries[command]).AccessLevel;
                    s_Defaults[command] = info;
                }
                else
                {
                    info           = (DefaultInfo)s_Defaults[command];
                    info.NewAccess = level;
                }

                CommandEntry entry = new CommandEntry(command, ((CommandEntry)CommandSystem.Entries[command]).Handler, info.NewAccess);
                CommandSystem.Entries[command] = entry;

                foreach (BaseCommandImplementor imp in BaseCommandImplementor.Implementors)
                {
                    foreach (string str in new ArrayList(imp.Commands.Keys))
                    {
                        if (str == command)
                        {
                            ((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;
                        }
                    }
                }
            }catch { Errors.Report("Commands-> Access-> AccessLevel"); }
        }
示例#22
0
        public void RequestUserAgentString()
        {
            if (Helper.IsNetworkAvailable())
            {
                var info    = new DefaultInfo();
                var http    = new DefaultRequester(info);
                var request = new DefaultRequest();
                request.Address = new Uri("http://httpbin.org/user-agent");
                request.Method  = HttpMethod.GET;

                var response = http.Request(request);
                Assert.IsNotNull(response);
                Assert.AreEqual(200, (int)response.StatusCode);
                Assert.IsTrue(response.Content.CanRead);
                Assert.IsTrue(response.Headers.Count > 0);

                var stream = new StreamReader(response.Content);
                Assert.IsNotNull(stream);

                var content = stream.ReadToEnd();
                Assert.IsTrue(content.Length > 0);
                Assert.AreEqual("{\n  \"user-agent\": \"" + info.Agent + "\"\n}", content);
            }
        }
示例#23
0
        //TO DO drawns

        static void Main(string[] args)
        {
            ChessBoard gameboard = new ChessBoard();

            gameboard.SetDefaultChessBoard();
            DefaultInfo.SetDefaultValues();
            string        notation  = "";
            List <string> gamestory = new List <string>();
            string        move      = "";
            // Code Review: Назва локальної змінної повинна починатися з малої літери.
            int NumberOfMoves = 1;
            int rows          = 20;
            int rowwidth      = 20;

            //Draw.DrawChessBoard(gameboard);
            Console.Title = "Dan's True Chess Game";
            do
            {
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                if (DefaultInfo.IsWhiteMove)
                {
                    if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, true))
                    {
                        if (!WhiteKing.IsSafe(gameboard))
                        {
                            DefaultInfo.BlackWin = true;
                        }
                        break;
                    }
                    WhiteMove(ref gameboard, ref notation, ref move);
                }
                else
                {
                    if (!FIDEnotation.CheckIfArePossibleMoves(gameboard, false))
                    {
                        if (!BlackKing.IsSafe(gameboard))
                        {
                            DefaultInfo.WhiteWin = true;
                        }

                        break;
                    }
                    BlackMove(ref gameboard, ref notation, gamestory, ref move, ref NumberOfMoves);
                }
            }while (true);

            if (DefaultInfo.WhiteWin)
            {
                gamestory[gamestory.Count] += "+";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("White win!");
            }
            if (DefaultInfo.BlackWin)
            {
                gamestory[gamestory.Count - 1] += "+";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("Black win!");
            }
            else
            {
                gamestory[gamestory.Count] += "=";
                move = " ";
                DrawGameField(gameboard, gamestory, ref move, NumberOfMoves, ref rows, rowwidth);
                Console.WriteLine("Draw");
            }
        }
示例#24
0
文件: Contact.cs 项目: ohel/kerppi
 public override string ToString()
 {
     return((string.IsNullOrEmpty(Name) ? "" : (Name + " | ")) +
            (string.IsNullOrEmpty(DefaultInfo) ? "" : (DefaultInfo.Substring(0, Math.Min(DefaultInfo.Length, 30)) +
                                                       (DefaultInfo.Length < 31 ? "" : "…"))));
 }
示例#25
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public PostType()
 {
     Defaults = new DefaultInfo();
 }
示例#26
0
        public void RequestUserAgentString()
        {
            if (Helper.IsNetworkAvailable())
            {
                var info = new DefaultInfo();
                var http = new DefaultRequester(info);
                var request = new DefaultRequest();
                request.Address = new Uri("http://httpbin.org/user-agent");
                request.Method = HttpMethod.Get;

                var response = http.Request(request);
                Assert.IsNotNull(response);
                Assert.AreEqual(200, (int)response.StatusCode);
                Assert.IsTrue(response.Content.CanRead);
                Assert.IsTrue(response.Headers.Count > 0);

                var stream = new StreamReader(response.Content);
                Assert.IsNotNull(stream);

                var content = stream.ReadToEnd();
                Assert.IsTrue(content.Length > 0);
                Assert.AreEqual("{\n  \"user-agent\": \"" + info.Agent + "\"\n}", content);
            }
        }
 internal DefaultInfo Create(DefaultInfo newDefaultInfo)
 {
     return(_repo.Create(newDefaultInfo));
 }
示例#28
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		public PostType() {
			Defaults = new DefaultInfo();
		}
示例#29
0
        private string getDefaultInfo(string distributor, string strJson, string blog)
        {
            combineBlogDistributor(blog, distributor);
            if (String.IsNullOrEmpty(distributor) || String.IsNullOrEmpty(strJson))
                return "{}";
            else
            {
                string strSQL = "";
                try
                {
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    TimeInterval ti = js.Deserialize<TimeInterval>(strJson);

                    List<string> labels = new List<string>();
                    labels.Add("Yesterday");
                    labels.Add("Last 7 days");
                    labels.Add("Last 30 days");
                    labels.Add("This Month");
                    labels.Add("Last Month");
                    if (ti != null)
                    {
                        string strSQL1 = string.Format("select '{2}' as period, type, COUNT(distinct token) as cnt, COUNT(type) as cnt_v from tb_page_visit_info_xango where distributor = '{3}' and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}' group by type;", ti.yesterday.start, ti.yesterday.end, "Yesterday", distributor);
                        string strSQL2 = string.Format("select '{2}' as period, type, COUNT(distinct token) as cnt, COUNT(type) as cnt_v from tb_page_visit_info_xango where distributor = '{3}' and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}' group by type;", ti.last_7_days.start, ti.last_7_days.end, "Last 7 days", distributor);
                        string strSQL3 = string.Format("select '{2}' as period, type, COUNT(distinct token) as cnt, COUNT(type) as cnt_v from tb_page_visit_info_xango where distributor = '{3}' and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}' group by type;", ti.last_30_days.start, ti.last_7_days.end, "Last 30 days", distributor);
                        string strSQL4 = string.Format("select '{2}' as period, type, COUNT(distinct token) as cnt, COUNT(type) as cnt_v from tb_page_visit_info_xango where distributor = '{3}' and convert(date, visit_time) >= '{0}' and convert(date, visit_time) <= '{1}' group by type;", ti.this_month.start, ti.this_month.end, "This month", distributor);
                        string strSQL5 = string.Format("select '{2}' as period, type, COUNT(distinct token) as cnt, COUNT(type) as cnt_v from tb_page_visit_info_xango where distributor = '{3}' and convert(date, visit_time) >= '{0}' and convert(date, visit_time) <= '{1}' group by type;", ti.last_month.start, ti.last_month.end, "Last month", distributor);

                        strSQL = strSQL1 + strSQL2 + strSQL3 + strSQL4 + strSQL5;

                        List<string> times = new List<string>();
                        times.Add(string.Format(" and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}';", ti.yesterday.start, ti.yesterday.end));
                        times.Add(string.Format(" and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}';", ti.last_7_days.start, ti.last_7_days.end));
                        times.Add(string.Format(" and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}';", ti.last_30_days.start, ti.last_7_days.end));
                        times.Add(string.Format(" and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}';", ti.this_month.start, ti.this_month.end));
                        times.Add(string.Format(" and convert(date, visit_time) >= '{0}' and convert(date, visit_time) < '{1}';", ti.last_month.start, ti.last_month.end));
                        using (SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString))
                        {
                            if (sc != null)
                            {
                                // select count(new)
                                // select count(*)
                                // do minus --- return
                                // because return can be new as well
                                List<DefaultInfo> dInfo = new List<DefaultInfo>();
                                for (int i = 0; i < times.Count; i++)
                                {
                                    DefaultInfo di = new DefaultInfo();
                                    di.visitor = new Visitor();

                                    strSQL = string.Format("select COUNT(distinct token) as cnt from tb_page_visit_info_xango where distributor = '{0}' and type='new'{1}", distributor, times[i]);
                                    DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL);
                                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                    {
                                        DataRow r = ds.Tables[0].Rows[0];
                                        di.period = labels[i];
                                        di.visitor.n = Convert.ToInt32(r[0]);
                                    }

                                    strSQL = string.Format("select COUNT(distinct token) as cnt, COUNT(*) as cnt_v from tb_page_visit_info_xango where distributor = '{0}'{1}", distributor, times[i]);
                                    ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL);
                                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                    {
                                        DataRow r = ds.Tables[0].Rows[0];
                                        di.period = labels[i];
                                        di.visitor.r = Convert.ToInt32(r[0]) - di.visitor.n;
                                        di.visit = Convert.ToInt32(r[1]);
                                    }
                                    dInfo.Add(di);
                                }

                                return new JavaScriptSerializer().Serialize(dInfo);

                                //DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL);
                                //if (ds != null && ds.Tables.Count > 0)
                                //{
                                //    List<DefaultInfo> dInfo = new List<DefaultInfo>();
                                //    for (int i = 0; i < ds.Tables.Count; i++)
                                //    {
                                //        DefaultInfo di = new DefaultInfo();
                                //        di.visit = new Visit();
                                //        di.visitor = new Visitor();
                                //        if (ds.Tables[i].Rows.Count == 0)
                                //        {
                                //            di.period = labels[i];
                                //            di.visit.n = di.visit.r = 0;
                                //            di.visitor.n = di.visitor.r = 0;
                                //        }
                                //        else
                                //        {
                                //            for (int j = 0; j < ds.Tables[i].Rows.Count; j++)
                                //            {
                                //                DataRow r = ds.Tables[i].Rows[j];
                                //                di.period = Convert.ToString(r[0]);
                                //                if (String.Compare("new", Convert.ToString(r[1]), StringComparison.OrdinalIgnoreCase) == 0)
                                //                {
                                //                    di.visitor.n = Convert.ToInt32(r[2]);
                                //                    di.visit.n = Convert.ToInt32(r[3]);
                                //                }
                                //                else if (String.Compare("return", Convert.ToString(r[1]), StringComparison.OrdinalIgnoreCase) == 0)
                                //                {
                                //                    di.visitor.r = Convert.ToInt32(r[2]);
                                //                    di.visit.r = Convert.ToInt32(r[3]);
                                //                }
                                //            }
                                //        }
                                //        dInfo.Add(di);
                                //    }

                                //    return new JavaScriptSerializer().Serialize(dInfo);
                                //}
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    AdssLogger.WriteLog("getDefaultInfo Exception: " + ex.Message + " --- sql: " + strSQL);
                }
            }
            return "{}";
        }
示例#30
0
        //private string getTrafficOverTime(string distributor, string startDate, string endDate, string blog)
        //{
        //    combineBlogDistributor(blog, distributor);
        //    // select CAST(visit_time as DATE), COUNT(id) from tb_page_visit_info_xango where visit_time <= '2016-05-05' group by CAST(visit_time as DATE)
        //    // select t3.d, t3.t, COUNT(t4.type)as c from tb_page_visit_info_xango t4 right join (select * from (select distinct CAST(visit_time as DATE) as d from tb_page_visit_info_xango  where visit_time < '2016-01-01') t1 ,(select distinct type as t from tb_page_visit_info_xango) t2 ) t3 on CAST(t4.visit_time as DATE) = t3.d and t4.type = t3.t group by t3.d, t3.t order by t3.d, t3.t
        //    string strSQL;
        //    try
        //    {
        //        string strClause = String.IsNullOrEmpty(startDate) ? "" : string.Format(" and convert(date, visit_time) >= '{0}'", startDate);
        //        string strClause2 = String.IsNullOrEmpty(endDate) ? "" : string.Format(" and convert(date, visit_time) <= '{0}'", endDate);
        //        //string strHead = "select DATEDIFF(SECOND,{d '1970-01-01'}, t3.d), t3.t, COUNT(t4.type)as c ";
        //        string strHead = "select t3.d, t3.t, COUNT(distinct t4.token)as visitor, COUNT(t4.type) as pageview ";
        //        strSQL = strHead + string.Format("from tb_page_visit_info_xango t4 right join (select '{3}' as dis, * from (select distinct CAST(visit_time as DATE) as d from tb_page_visit_info_xango  where distributor='{0}'{1}{2}) t1 ,(select distinct type as t from tb_page_visit_info_xango) t2 ) t3 on CAST(t4.visit_time as DATE) = t3.d and t4.type = t3.t and t4.distributor = '{0}' group by t3.d, t3.t order by t3.d, t3.t", distributor, strClause, strClause2, distributor);
        //    }
        //    catch (Exception e)
        //    {
        //        AdssLogger.WriteLog("GetSampleAnalyticsInfo(getTrafficOverTime) --- Exception: " + e.Message);
        //        return "{}";
        //    }
        //    try
        //    {
        //        using (SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString))
        //        {
        //            if (sc != null)
        //            {
        //                DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL);
        //                if (ds != null && ds.Tables.Count > 0)
        //                {
        //                    List<DefaultInfo> dInfo = new List<DefaultInfo>();
        //                    DefaultInfo di = null;
        //                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //                    {
        //                        // d,t,visitor,pageview(visit)
        //                        DataRow r = ds.Tables[0].Rows[i];
        //                        if (i % 2 == 0)
        //                        {
        //                            di = new DefaultInfo();
        //                            di.visit = new Visit();
        //                            di.visitor = new Visitor();
        //                        }
        //                        //di.period = Convert.ToString(r[0]);
        //                        di.period = ((DateTime)r[0]).ToString("yyyy-MM-dd");
        //                        if (i % 2 == 0)
        //                        {
        //                            di.visit.n = Convert.ToInt32(r[3]);
        //                            di.visitor.n = Convert.ToInt32(r[2]);
        //                        }
        //                        else
        //                        {
        //                            di.visit.r = Convert.ToInt32(r[3]);
        //                            di.visitor.r = Convert.ToInt32(r[2]);
        //                            dInfo.Add(di);
        //                        }
        //                    }
        //                    return new JavaScriptSerializer().Serialize(dInfo);
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        //Trace.WriteLine(e.Message);
        //        AdssLogger.WriteLog("GetSampleAnalyticsInfo(getTrafficOverTime sql excute) --- Exception: " + e.Message + " --- sql: " + strSQL);
        //    }
        //    return "{}";
        //}
        private string getTrafficOverTime(string distributor, string startDate, string endDate, string blog)
        {
            combineBlogDistributor(blog, distributor);
            string strSQL;
            try
            {
                string strClause = String.IsNullOrEmpty(startDate) ? "" : string.Format(" and convert(date, visit_time) >= '{0}'", startDate);
                string strClause2 = String.IsNullOrEmpty(endDate) ? "" : string.Format(" and convert(date, visit_time) <= '{0}'", endDate);

                strSQL = string.Format("select distinct CAST(visit_time as DATE) as d from tb_page_visit_info_xango where distributor='{0}'{1}{2} order by d", distributor, strClause, strClause2);
            }
            catch (Exception e)
            {
                AdssLogger.WriteLog("GetSampleAnalyticsInfo(getTrafficOverTime) --- Exception: " + e.Message);
                return "{}";
            }
            try
            {
                using (SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString))
                {
                    if (sc != null)
                    {
                        DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL);
                        if (ds != null && ds.Tables.Count > 0)
                        {
                            List<DefaultInfo> dInfo = new List<DefaultInfo>();
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                DataRow r = ds.Tables[0].Rows[i];

                                DefaultInfo di = new DefaultInfo();
                                di.visitor = new Visitor();

                                di.period = ((DateTime)r[0]).ToString("yyyy-MM-dd");

                                string strSQL1 = string.Format("select COUNT(distinct token) as cnt from tb_page_visit_info_xango where distributor = '{0}' and type='new' and convert(date, visit_time) = '{1}'", distributor, di.period);
                                DataSet ds1 = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL1);
                                if (ds1 != null && ds1.Tables.Count > 0)
                                {
                                    DataRow r1 = ds1.Tables[0].Rows[0];
                                    di.visitor.n = Convert.ToInt32(r1[0]);
                                    string strSQL2 = string.Format("select COUNT(distinct token) as cnt, COUNT(*) as cnt_v from tb_page_visit_info_xango where distributor = '{0}' and convert(date, visit_time) = '{1}'", distributor, di.period);
                                    DataSet ds2 = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL2);
                                    if (ds2 != null && ds1.Tables.Count > 0)
                                    {
                                        DataRow r2 = ds2.Tables[0].Rows[0];
                                        di.visitor.r = Convert.ToInt32(r2[0]) - di.visitor.n;
                                        di.visit = Convert.ToInt32(r2[1]);
                                    }
                                }
                                dInfo.Add(di);
                            }
                            return new JavaScriptSerializer().Serialize(dInfo);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //Trace.WriteLine(e.Message);
                AdssLogger.WriteLog("GetSampleAnalyticsInfo(getTrafficOverTime sql excute) --- Exception: " + e.Message + " --- sql: " + strSQL);
            }
            return "{}";
        }
示例#31
0
 private PublishViewModel()
 {
     Info = new PublishInfo();
     DefaultInfo.ReadDefaultInfo(Info);
     PushCommand = new ActionCommand(PublishHomework);
 }
示例#32
0
 public CurrencyDisplayInfo GetInstance(ULocale locale, bool withFallback)
 {
     return(DefaultInfo.GetWithFallback(withFallback));
 }