Inheritance: MonoBehaviour
示例#1
0
 public static Init getInstance()
 {
     if( null == _instance ) {
         _instance = new Init();
     }
     return _instance;
 }
示例#2
0
文件: net.cs 项目: sbrown345/quakejs
 public net_driver_t(string name,
                     bool initialized,
                     Init delegate_Init,
                     Listen delegate_Listen,
                     SearchForHosts delegate_SearchForHosts,
                     Connect delegate_Connect,
                     CheckNewConnections delegate_CheckNewConnections,
                     QGetMessage delegate_QGetMessage,
                     QSendMessage delegate_QSendMessage,
                     SendUnreliableMessage delegate_SendUnreliableMessage,
                     CanSendMessage delegate_CanSendMessage,
                     CanSendUnreliableMessage delegate_CanSendUnreliableMessage,
                     Close delegate_Close,
                     Shutdown delegate_Shutdown)
 {
     this.name = name;
     this.initialized = initialized;
     this.delegate_Init = delegate_Init;
     this.delegate_Listen = delegate_Listen;
     this.delegate_SearchForHosts = delegate_SearchForHosts;
     this.delegate_Connect = delegate_Connect;
     this.delegate_CheckNewConnections = delegate_CheckNewConnections;
     this.delegate_QGetMessage = delegate_QGetMessage;
     this.delegate_QSendMessage = delegate_QSendMessage;
     this.delegate_SendUnreliableMessage = delegate_SendUnreliableMessage;
     this.delegate_CanSendMessage = delegate_CanSendMessage;
     this.delegate_CanSendUnreliableMessage = delegate_CanSendUnreliableMessage;
     this.delegate_Close = delegate_Close;
     this.delegate_Shutdown = delegate_Shutdown;
 }
    /***************************************** Common Functions *******************************/
    public void ManageDataApps_SelectedIndexChanged(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        ClearMessages();

         State["ManageDataType"] = null;
        string app_name = Request.Form.Get("ManageDataApps");
        if (!app_name.Contains("->"))
        {
             State["SelectedApp"] = app_name;
            ManageDataApps.SelectedValue = app_name;
            InitDataTrees(app_name);
            ViewStoryBoard.Style.Value = "";
            ManageDataType.Style.Value = "";
            ManageDataTypeLabel.Style.Value = "";
        }
        else
        {
            ManageDataType.Style.Value = "display:none";
            ManageDataTypeLabel.Style.Value = "display:none";
            ViewStoryBoard.Style.Value = "display:none";
            util.ResetAppStateVariables(State);
            ContentMultiPage.SelectedIndex = 0;
            ShouldRefreshStoryBoard.Text = "close";
            Init init = new Init();
            init.InitManageDataAppsList(State);
            DataMultiPage.SelectedIndex = 3;
        }
    }
    // Data members
    protected void Page_Load(object sender, EventArgs e)
    {
        Init init = new Init();
        Util util = new Util();

        try
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

            if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

            if ( HttpRuntime.Cache["TechSupportEmail"] != null)
            {
                util.AddEmailToButton(SupportButton,  HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support");
            }

            util.UpdateSessionLog(State, "post", "TabPublish");

            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();
            }

         //   SeeAllFields.Attributes.Add("onclick", "javascript: PopUp('../Help/Design/ViewAllNativeFields.htm', 'height=800, width=800, left=200, top=200, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes');return false;");
         //   LayoutVideo.Attributes.Add("onclick", "javascript: PopUp('../Help/Design/LayoutVideo.htm', 'height=325, width=570, left=200, top=200, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no');return false;");
         //   BasicFieldsVideo.Attributes.Add("onclick", "javascript: PopUp('../Help/Design/BasicFieldsVideo.htm', 'height=325, width=570, left=200, top=200, menubar=no, status=no, location=no, toolbar=no, scrollbars=no, resizable=no');return false;");

        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            throw;
        }
    }
示例#5
0
 private void Create(BaseClass baseClass, Write write)
 {
     BaseClass = baseClass;
     Define = new Define();
     Init = new Init(this);
     Write = write;
 }
 public State(StateMachine stateMachine, Action action = null, Init init = null, Finish finish = null)
 {
     _action = action;
     _init = init;
     _finish = finish;
     _mother = stateMachine;
     _transitions = new List<Transition>();
 }
		public TwainDotNetScannerManager(WindowsMessageLoopThread windowsMessageLoop)
		{
			_windowsMessageLoop = windowsMessageLoop;
			_sources = new List<TwainDotNetSource>();
			_log = LogManager.GetLogger(typeof(TwainDotNetScannerManager));

			var init = new Init(Initialize);
			_twain = _windowsMessageLoop.Invoke<TwainDotNet.Twain>(init, new object[] { _windowsMessageLoop.Hwnd });

			_log.Info("TwainDotNet scanner manager is used");

			RefreshSources();
		}
示例#8
0
		private static int Main ()
		{
			var t = typeof (Init);
			var m = t.GetMethod ("testcase.IInitializationExpression.AddRegistry", BindingFlags.NonPublic | BindingFlags.Instance);
			Console.WriteLine (m.Attributes);

			if (m.Attributes != (MethodAttributes.Private | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig | MethodAttributes.VtableLayoutMask | MethodAttributes.CheckAccessOnOverride))
				return 1;

			IInitializationExpression expression = new Init ();
			expression.AddRegistry<string> (11);
			return 0;
		}
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

        Message.Text = "";
        if (!IsPostBack)
        {
            Init init = new Init();
            init.InitAccountList(State, FromAccounts, true);
            init.InitAccountList(State, ToAccounts, false);
            CopyApplicationButton.Visible = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return;
         try
        {
            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();
            }

            if ( HttpRuntime.Cache["TechSupportEmail"] != null)
            {
                util.AddEmailToButton(SupportButton,  HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support");
            }

            util.UpdateSessionLog(State, "post", "TabPublishOld");

            /*PurchaseButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
               "http://stores.homestead.com/MobiFlexStore/StoreFront.bok", 700, 900, false, false, false, true));
           ManageBillingButton.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
               "http://stores.homestead.com/MobiFlexStore/StoreFront.bok", 700, 900, false, false, false, true));*/

            ShowProductionServices();

            ClearMessages();

            Init init = new Init();
            if (State["ResetProvisionApps"] != null)
            {
                State["SelectedApp"] = null;
                init.InitAppsList(State, ProvisionApps);
                State["ResetProvisionApps"] = null;
            }

            if (ProvisionApps.Items.Count == 0)
            {
                init.InitAppsList(State, ProvisionApps);

            }
            SetProvisionButtons(ProvisionApps.SelectedValue);
            SetProvisionFormPopup();
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
示例#11
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            HttpRuntime.Cache["UsersList"] = new Hashtable();

            Init init = new Init();
            init.InitSiteConfigurations();
            HttpRuntime.Cache["NewProjectPath"] = Server.MapPath(".") + @"\App_data\NewViziAppsNativeApp.xml";
            HttpRuntime.Cache["CanvasHtml"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\Canvas.txt");
            HttpRuntime.Cache["NewWebAppHtml"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\NewViziAppsWebApp.txt");
            HttpRuntime.Cache["NewHybridAppXml"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\NewViziAppsHybridApp.xml");
            HttpRuntime.Cache["ShareThisScripts"] = File.ReadAllText(Server.MapPath(".") + @"\App_Data\ShareThisScripts.txt");
            HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";
            HttpRuntime.Cache["Server"] = Server;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
      if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }
     if (!IsPostBack)
     {
         if (GoToPages.Items.Count == 0)
         {
             Init init = new Init();
             init.InitAppPagesAndCustom(State, GoToPages, false);
             init.InitAppPagesAndCustom(State, page_if_true, true);
             init.InitAppPagesAndCustom(State, page_if_false, true);
         }
         InitActions();
     }
 }
示例#13
0
        public void TestRsaSignature()
        {
            Init.Initizer("Xunit", () => "Xunit");
            var rsasign1 = new RsaSignatureProvider();
            var rsasign2 = new RsaSignatureProvider(rsasign1.PublicKey);

            rsasign1.ExportPrivateKey("testkey.dat");
            var rsasign3 = new RsaSignatureProvider("testkey.dat");
            var rsasign4 = new RsaSignatureProvider();
            var message  = "Unit Testing With Xunit is cool!!";
            var sb       = new StringBuilder(message);

            for (int i = 0; i < 1000; i++)
            {
                sb.Append(i.ToString());
                sb.Append(" : ");
                sb.Append(message);
                sb.AppendLine();
            }
            var Message = sb.ToString();
            var sign1   = rsasign1.GenerateSignture(message);
            var sign2   = rsasign1.GenerateSignture(Message);
            var sign3   = rsasign3.GenerateSignture(Message);
            var sign4   = rsasign4.GenerateSignture(Message);

            Assert.NotEqual(sign1, sign2);
            Assert.NotEqual(sign2, sign4);
            Assert.True(rsasign1.VerifySignature(message, sign1));
            Assert.True(rsasign1.VerifySignature(Message, sign2));
            Assert.False(rsasign1.VerifySignature(message, sign2));
            Assert.True(rsasign1.VerifySignature(Message, sign2));
            Assert.True(rsasign1.VerifySignature(Message, sign3));
            Assert.True(rsasign3.VerifySignature(message, sign1));
            Assert.False(rsasign4.VerifySignature(message, sign1));
            rsasign1.Dispose();
            rsasign2.Dispose();
            rsasign3.Dispose();
            rsasign4.Dispose();
        }
示例#14
0
        public static string Simple()
        {
            string service = "events";

            JsonObject security = new JsonObject();

            security.set("consumer_key", "yis0TYCu7U9V4o7M");
            security.set("user_id", "$ANONYMIZED_USER_ID");
            security.set("domain", "localhost");

            string secret = "74c5fd430cf1242a527f6223aebd42d30464be22";

            JsonObject request = new JsonObject();

            request.set("eventbus", true);
            request.set("skip", true);
            request.set("users", Events.users());

            Init init = new Init(service, security, secret, request);

            return(init.generate());
        }
示例#15
0
        public TrainintDBContext() : base("name=TrainintDBContext")
        {
            //Database.Delete();
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<UserContext, DataContextConfiguration>());

            if (ConfigurationManager.AppSettings["InitNewDB"].ToUpper() == bool.TrueString.ToUpper())
            {
                Database.SetInitializer(new CustomDropCreateDatabaseAlways());
            }
            else
            {
                Database.SetInitializer(new CreateDatabaseIfNotExists <TrainintDBContext>());
            }

            // Init SqlScripts
            var resourceName = Init.GetSqlTexts();

            foreach (var sqlText in resourceName)
            {
                Database.ExecuteSqlCommand(sqlText);
            }
        }
示例#16
0
        public static void UpdateInitial(string Status)
        {
            try
            {
                Form   form = Application.OpenForms["FormMain"];
                Button Init;
                if (form == null)
                {
                    return;
                }

                Init = form.Controls.Find("Initial_btn", true).FirstOrDefault() as Button;
                if (Init == null)
                {
                    return;
                }

                if (Init.InvokeRequired)
                {
                    UpdateOnline ph = new UpdateOnline(UpdateInitial);
                    Init.BeginInvoke(ph, Status);
                }
                else
                {
                    if (Status.ToUpper().Equals("TRUE"))
                    {
                        Init.BackColor = Color.Lime;
                    }
                    else
                    {
                        Init.BackColor = Color.Red;
                    }
                }
            }
            catch
            {
                logger.Error("UpdateInitial: Update fail.");
            }
        }
示例#17
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var userManager  = services.GetRequiredService <UserManager <User> >();
                    var rolesManager = services.GetRequiredService <RoleManager <IdentityRole> >();
                    await Init.InitializeAsync(userManager, rolesManager);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            host.Run();
        }
示例#18
0
        static void Main(string[] args)
        {
            PortConnect sms = new PortConnect();

            GSMapp.Models.SimCard card = new GSMapp.Models.SimCard();


            CardRep rep = new CardRep();



            /*gc.ReceiverTest(" test ");
             * gc.port.AddReceiver(gc.Receiver);
             *
             *
             *
             * sms.Connect();
             * Console.WriteLine(sms.IsConnected);
             *
             * if (sms.IsConnected)
             * {
             *  sms.Number();
             * //gc.port.RemoveReceiver(gc.Receiver);
             * gc.DeleteReceiver();
             *  sms.Operator();
             * }*/



            sms.Connect();

            Init.PortConnect = sms;
            Init.SimCard     = card;
            Init.Repository  = rep;
            Init.Excecute();


            Console.ReadLine();
        }
示例#19
0
        public override void GenerateBytecode(ClassesContainer container, ByteBlock context)
        {
            Init.GenerateBytecode(container, context);

            int jumpIndex = context.NextOpIndex;

            Condition.GenerateBytecode(container, context);

            JumpIfFalseCode code = new JumpIfFalseCode(-1);

            context.Instructions.Add(code);

            foreach (var statement in this.Statements)
            {
                statement.GenerateBytecode(container, context);
            }

            Update.GenerateBytecode(container, context);

            context.Instructions.Add(new JumpCode(jumpIndex));
            code.targetIndex = context.NextOpIndex;
        }
示例#20
0
文件: Program.cs 项目: Clouz/SynoAPI
        static void Main(string[] args)
        {
            Init server = new Init("http", "192.168.0.26", 5000, "Media", "f5_W@H");

            //login
            var login = syno.API.Auth.GetLogin(server);

            Console.WriteLine($"Login: {login.sid}");

            var fileStationInfo = syno.FileStation.List.list_share(server, additional: "real_path,owner");

            foreach (var item in fileStationInfo.shares)
            {
                Console.WriteLine($"{item.isdir} - {item.name} - {item.path}");
                Console.WriteLine($"\t{item.additional.real_path}");
            }

            var logout = syno.API.Auth.GetLogout(server);


            Console.ReadLine();
        }
        private void NetworkOnDataReceived(byte[] rawData)
        {
            var data = Compressor.Decompress(rawData);

            var reader     = new Deserializer(data);
            var messageTag = (MessageTag)reader.GetByte();

            switch (messageTag)
            {
            case MessageTag.Init:
                var paket = new Init();
                paket.Deserialize(reader);
                InitReceived?.Invoke(this, paket);
                break;

            case MessageTag.Input:
                var tick          = reader.GetUInt() + reader.GetByte(); //Tick + LagCompensation
                var countCommands = reader.GetInt();
                var actorId       = reader.GetByte();
                var commands      = new ICommand[countCommands];
                for (var i = 0; i < countCommands; i++)
                {
                    var tag = reader.GetUShort();
                    if (!_commandFactories.ContainsKey(tag))
                    {
                        continue;
                    }

                    var newCommand = (ICommand)Activator.CreateInstance(_commandFactories[tag]);
                    newCommand.Deserialize(reader);
                    commands[i] = newCommand;
                }


                base.Enqueue(new Input(tick, actorId, commands));
                break;
            }
        }
示例#22
0
        private void stepperLoop()
        {
            try
            {
                if (Init.WiringPiSetup() == -1)
                {
                    Console.WriteLine("WiPi init failed");
                }
                if (Init.WiringPiSetupGpio() == -1)
                {
                    Console.WriteLine("GPIO init failed");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }
            const int HIGH = (int)GPIOpinvalue.High;
            const int LOW  = (int)GPIOpinvalue.Low;

            GPIO.pinMode(0, (int)GPIOpinmode.Output);
            GPIO.pinMode(1, (int)GPIOpinmode.Output);
            GPIO.pinMode(2, (int)GPIOpinmode.Output);
            GPIO.digitalWrite(1, LOW);
            GPIO.digitalWrite(2, HIGH);

            Console.WriteLine("gpio started");

            while (true)
            {
                GPIO.digitalWrite(0, HIGH);
                Thread.Sleep(5);
                GPIO.digitalWrite(0, LOW);
            }

            Thread.Sleep(Timeout.Infinite);
        }
示例#23
0
        /// <summary>
        /// Splits data between parts
        /// </summary>
        /// <param name="cur">Data</param>
        public void AddData(List <Token> cur)
        {
            List <Token> data = new List <Token>();
            ICompilable  last = null;

            foreach (var x in cur)
            {
                switch (x.t)
                {
                case TType.ou:
                    FinishBlock(ref data, last);
                    last = new OutInit();
                    break;

                case TType.init:
                    FinishBlock(ref data, last);
                    last = new Init();
                    break;

                case TType.Beg:
                    FinishBlock(ref data, last);
                    last = new Body();
                    break;

                case TType.End:
                    FinishBlock(ref data, last);
                    break;

                default:
                    data.Add(x);
                    break;
                }
            }
            var v = new After();

            v.AddData(data);
            com.Add(v);
        }
示例#24
0
        private async Task Init()
        {
            BaseRequest baseRequest = new BaseRequest(cookie.wxuin, cookie.wxsid, cookie.skey);
            JObject     jsonObj     = new JObject();

            jsonObj.Add("BaseRequest", JObject.FromObject(baseRequest));
            String json = jsonObj.ToString().Replace("\r\n", "");

            String uri = "https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=" + Time.Now() + "&lang=ch_ZN&pass_ticket=" + cookie.pass_ticket;

            string result = await Post.Get_Response_Str(uri, json);

            //Debug.WriteLine(result);

            wxInit         = weixinInit.Init.FromJson(result);
            cookie.syncKey = wxInit.SyncKey;

            foreach (var member in wxInit.ContactList)
            {
                if (!member.UserName[1].Equals('@') && !member.NickName.Equals("文件传输助手"))
                {
                    FriendList friend = new FriendList();
                    friend.UserName = member.UserName;
                    friend.NickName = member.NickName;
                    friend.dialog   = new List <bubble>();

                    uri = "http://wx2.qq.com" + member.HeadImgUrl;

                    var response = await Get.Get_Response_Str(uri, cookie_str);

                    var r = await response.Content.ReadAsByteArrayAsync();

                    friend.bitmap = await ByteArrayToBitmapImage(r);

                    ContactView.AllItems.Add(friend);
                }
            }
        }
        public void EnabledTelemetryPreservesOtherMetaProps()
        {
            string     action   = "get";
            JsonObject security = this.generateSecurityObject();

            JsonObject metaField = new JsonObject();

            metaField.set("test_key_string", "test-string");
            metaField.set("test_key_integer", 12345);

            JsonObject request = new JsonObject();

            request.set("page", 1);
            request.set("meta", metaField);

            Init   init            = new Init("data", security, this.consumerSecret, request, action);
            string generatedString = init.generate();

            Assert.Contains("meta", generatedString);
            Assert.Contains("sdk", generatedString);
            Assert.Contains("test_key_string", generatedString);
            Assert.Contains("test_key_integer", generatedString);
        }
示例#26
0
        public void Configure(IApplicationBuilder app)
        {
            if (Environment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // uncomment if you want to add MVC
            app.UseStaticFiles();
            app.UseRouting();

            app.UseIdentityServer();

            // uncomment, if you want to add MVC
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();
            });


            Init.Initialize().Wait();
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

        AccountType.Value = State["AccountType"].ToString();

        if (!IsPostBack)
        {
            //Bold.Attributes.Add("onclick", "onBoldClick();");
            //Italic.Attributes.Add("onclick", "onItalicClick();");

            if (GoToPages.Items.Count == 0)
            {
                Init init = new Init();
                init.InitAppPagesAndCustom(State, GoToPages, false);
                init.InitAppPagesAndCustom(State, page_if_true, true);
                init.InitAppPagesAndCustom(State, page_if_false, true);
            }
            InitActions();
        }
    }
        public void InitGeneratesExactSameSignature()
        {
            string action = "get";

            JsonObject security = this.generateSecurityObject();

            JsonObject request = new JsonObject();

            request.set("limit", 100);

            Init.disableTelemetry();
            Init init = new Init("data", security, this.consumerSecret, request, action);

            // Assert signature is still the same
            Assert.Equal(
                "e1eae0b86148df69173cb3b824275ea73c9c93967f7d17d6957fcdd299c8a4fe",
                init.generateSignature()
                );

            // Assert telemetry is turned off
            Assert.False(init.isTelemetryEnabled());
            Init.enableTelemetry();
        }
示例#29
0
        public static void Register()
        {
            Suite suite = new Suite();

            suite.Name = "parse/f-info";

            suite.SetSetup(delegate() {
                p = Init.init_parse_f();
            });
            suite.SetTeardown(delegate() {
                p.Destroy();
            });

            suite.AddTest("n0", test_n0);
            suite.AddTest("g0", test_g0);
            suite.AddTest("m0", test_m0);
            suite.AddTest("p0", test_p0);
            suite.AddTest("f0", test_f0);
            suite.AddTest("x0", test_x0);
            suite.AddTest("e0", test_e0);

            UnitTest_Main.AddSuite(suite);
        }
示例#30
0
 //------------------------------------------------- HELPER METHODES -----------------------------------------------------------
 //checks if a unix platform and gpio pins are available
 private bool CheckForWiringPiSetuPhys()
 {
     if (Environment.OSVersion.Platform.ToString() == "Unix")
     {
         // The WiringPiSetup method is static and returns either true or false
         // Any value less than 0 represents a failure
         if (Init.WiringPiSetupPhys() >= 0)
         {
             return(true);
         }
         else
         {
             //ensures that it initializes the GPIO interface and reports ready to work. We will use Physical Pin Numbers
             MessageBox.Show($"Unable to get the gpio interface and reports to work\nWiringPi Error", "Error", MessageBoxButtons.OK);
             return(false);
         }
     }
     else
     {
         MessageBox.Show("No Unix Platform detected in WiringPi Setup", "Error", MessageBoxButtons.OK);
         return(false);
     }
 }
示例#31
0
        void doInit(object data)
        {
            try
            {
                Web.getInitCompletedEventArgs e = data as Web.getInitCompletedEventArgs;
                if (e.Error != null)
                {
                    Close();
                    return;
                }
                Init = e.Result;
                Dispatcher.BeginInvoke(new Action(UpdateUser));

                Web.apiSoapClient c = new Web.apiSoapClient();
                c.GetFreeSpacePercentageCompleted += new EventHandler <Web.GetFreeSpacePercentageCompletedEventArgs>(c_GetFreeSpacePercentageCompleted);
                if (Init.UserLevel != UserLevel.Student)
                {
                    c.getControlledOUsCompleted += new EventHandler <getControlledOUsCompletedEventArgs>(c_getControlledOUsCompleted);
                    if (!string.IsNullOrEmpty(Properties.Settings.Default.ControlledOU))
                    {
                        c.getControlledOUsAsync(Properties.Settings.Default.ControlledOU);
                    }
                    c.getMyTicketsCompleted += new EventHandler <Web.getMyTicketsCompletedEventArgs>(c_getMyTicketsCompleted);
                    c.getMyTicketsAsync(Environment.UserName);
                }
                else
                {
                    c.getPhotoCompleted += new EventHandler <Web.getPhotoCompletedEventArgs>(c_getPhotoCompleted);
                    c.getPhotoAsync(Init.EmployeeID);
                }
                if (!string.IsNullOrEmpty(Init.HomeDrive))
                {
                    c.GetFreeSpacePercentageAsync(Environment.UserName, Init.HomeDirectory);
                }
            }
            catch (Exception ex) { MessageBox.Show("Init Error:\n" + ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); Close(); }
        }
示例#32
0
        private void Timer_GetSystemTime_Tick(object sender, EventArgs e)
        {
            // 判断窗口状态
            if (window.IsTop != window.LastIsTop)
            {
                // 切换
                window.SetMyWindow(Handle);
                window.LastIsTop = window.IsTop;
            }
            // 检测极域窗口
            if (window.CheckMythwareWindow())
            {
                if (!window.IsDialog)
                {
                    // 防止多次弹窗鬼畜
                    window.IsDialog = true;
                    MythwareWindowRun();
                }
            }

            // 更新标签时钟
            MainWin_Label_Time.Text = DateTime.Now.ToLocalTime().ToString();

            // 更新双端信息
            RunState_TextBox_LocalIP.Text = Infos.NetWork.LocalIP;

            // 检测运行状态
            if (!MythwareState) // false 启动获取
            {
                MythwareState = Init.GetMythwareRunState();
                if (MythwareState)
                {
                    RunState_Label_State.Text      = "RUNNING";
                    RunState_Label_State.BackColor = System.Drawing.Color.LightCoral;
                }
            }
        }
示例#33
0
        public static string Simple()
        {
            // prepare all the params
            string service = "items";

            JsonObject security = new JsonObject();

            security.set("consumer_key", Credentials.ConsumerKey);
            security.set("domain", Credentials.Domain);
            security.set("user_id", "$ANONYMIZED_USER_ID");

            string secret = Credentials.ConsumerSecret;

            JsonObject pwd = new JsonObject();

            pwd.set("pwd", "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8");

            JsonObject config = new JsonObject();

            config.set("administration", pwd);

            JsonObject request = new JsonObject();

            request.set("activity_template_id", "demo-activity-1");
            request.set("activity_id", "my-demo-activity");
            request.set("name", "Demo Activity");
            request.set("course_id", "demo_yis0TYCu7U9V4o7M");
            request.set("session_id", Uuid.generate());
            request.set("user_id", "$ANONYMIZED_USER_ID");
            request.set("config", config);

            // Instantiate Init class
            Init init = new Init(service, security, secret, request);

            // Call the generate() method to retrieve a JavaScript object
            return(init.generate());
        }
示例#34
0
    public Actor(Init i)
    {
        statChange = new int[] { 0, 0, 0, 0, 0, 0 };
        actorState = i.state;
        comedy     = i.com;
        romance    = i.rom;
        action     = i.act;
        horror     = i.hor;
        scifi      = i.sci;
        other      = i.other;
        actorName  = i.name;
        if (i.baseCom == 0 && i.baseAct == 0 & i.baseHor == 0 & i.baseOth == 0 & i.baseRom == 0 & i.baseSci == 0)
        {
            baseComedy  = comedy;
            baseRomance = romance;
            baseAction  = action;
            baseHorror  = horror;
            baseScifi   = scifi;
            baseOther   = other;
        }
        else
        {
            baseComedy  = i.baseCom;
            baseRomance = i.baseRom;
            baseAction  = i.baseAct;
            baseHorror  = i.baseHor;
            baseScifi   = i.baseSci;
            baseOther   = i.baseOth;
        }

        actorPicture    = i.pic;
        moviesStarredIn = i.moviesActorIn;
        incomeValue     = i.incomeVal;
        experience      = i.exp;
        maxExperience   = 100;
        this.level      = i.level;
    }
        /// <summary>
        ///     Initializes a new instance of the <see cref="CustomContext" /> class.
        /// </summary>
        public CustomContext(bool headless, LogSettings lset)
        {
            if (_currContext == null)
            {
                _currContext = this;
            }

            //merge with server settings?
            var cfgFile = new DataFile("flopenserver.cfg");

            AccountDir = cfgFile.GetSetting("server", "acct_path")[0];
            if (AccountDir == "")
            {
                AccountDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                             @"\My Games\Freelancer\Accts\MultiPlayer";
            }
            _logger = new Logger(lset.LogToFile);
            _logger.LogMask[(int)LogType.ERROR]     = true;
            _logger.LogMask[(int)LogType.GENERAL]   = true;
            _logger.LogMask[(int)LogType.DPLAY_MSG] = lset.LogDPlay;
            _logger.LogMask[(int)LogType.FL_MSG]    = lset.LogFLMsg;
            _logger.LogMask[(int)LogType.FL_MSG2]   = lset.LogFLMsg2;



            _init = new Init();

            _init.Start(int.Parse(cfgFile.GetSetting("server", "port")[0]), cfgFile.GetSetting("server", "fl_path")[0]);
            //if (headless)
            //{
            //    _server = new DPServer(_logger);
            //}
            //else
            //{
            //    (new ControlWindow()).Show();
            //}
        }
示例#36
0
        static async Task MainAsync(string[] args)
        {
            try
            {
                var nodeSettings = GetPatchedNodeSettings(args);

                var builder = new FullNodeBuilder()
                              .UseNodeSettings(nodeSettings)
                              .UseBlockStore()
                              .UsePosConsensus()
                              .UseMempool()
                              .UseX1Wallet()
                              .UseX1WalletApi()
                              .UseSecureApiHost();

                FullNode = builder.Build();

                Init.PrintWelcomeMessage(nodeSettings, FullNode);

                cancellationTokenSource = Init.RunIfDebugModeDelayed(FullNode);

                await FullNode.RunAsync();
            }
            catch (Exception e)
            {
                var message = $"Critical error in {Init.GetName()}: {e.Message}";
                try
                {
                    FullNode.NodeService <ILoggerFactory>().CreateLogger(typeof(Program).Name).LogCritical(message);
                }
                catch (Exception)
                {
                    Console.WriteLine(message);
                }
            }
        }
示例#37
0
        // Start is called before the first frame update
        void Start()
        {
            masterCounter       = GameObject.Find("GameMaster").GetComponent <MasterCounter>();
            masterCounter.sword = sword;

            text.GetComponent <TextMeshProUGUI>().text  = masterCounter.getScore().ToString();
            money.GetComponent <TextMeshProUGUI>().text = masterCounter.money.ToString();

            masterCounter.scoreText = text;
            masterCounter.moneyText = money;
            masterCounter.livesText = lives;
            masterCounter.UpdatePowerUps();

            Init init = sword.GetComponent <Init>();

            init.damage     += masterCounter.damageIncrease;
            init.fullShield += masterCounter.shieldIncrease;
            init.maxBounces += masterCounter.bounceIncrease;

            masterCounter.ResetIncreases();

            masterCounter.AddToScore(0);
            masterCounter.AddToMoney(0);
        }
    protected void FromAccounts_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "../Default.aspx")) return;

        if (e.Text.IndexOf("->") > 0)
        {
            Applications.Visible = false;
            CopyApplicationButton.Visible = false;
            return;
        }
        Applications.Visible = true;

        DB db = new DB();
        string sql = "SELECT customer_id FROM customers WHERE username='******'";
        string customer_id = db.ViziAppsExecuteScalar(State, sql);
         State["CopyApplicationFromCustomerID"] = customer_id;

        Init init = new Init();
        init.InitAppsList(State, Applications, customer_id);

        db.CloseViziAppsDatabase(State);
    }
示例#39
0
        public GameUserHandler(WebSocket webSocket, GameLogic game)
        {
            this.webSocket = webSocket;
            this.game      = game;
            Connected      = true;

            this.socketGame          = new GameSocketServer(webSocket);
            this.sockeMessageHandler = new MessageHandler(socketGame);
            var initMessage = new Init();

            sockeMessageHandler.PopulateActions(initMessage);
            sockeMessageHandler.RegisterActionReceiver(this);

            socketGame.OnDisconnect += SocketGame_OnDisconnect;
            socketGame.OnError      += (sender, e) => {
                var i = 3;
                socketGame.Disconnect();
            };

            game.OnWinner += Game_OnWinner;

            game.OnTurnChange += Game_OnTurnChange;

            game.OnUsersChange += Game_OnUsersChange;

            game.OnGridChange += Game_OnGridChange;

            UserNumber           = game.AddUser();
            initMessage.UserData = new User()
            {
                Id = "",
                Nr = UserNumber
            };
            initMessage.Points = game.GetGameGrid().ToGrid().Grid;
            sockeMessageHandler.SendMessage(initMessage);
        }
示例#40
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                var logger   = services.GetRequiredService <ILogger <Program> >();
                try
                {
                    var userManager = services.GetRequiredService <UserManager <AppUser> >();
                    var context     = services.GetRequiredService <DataContext>();
                    context.Database.Migrate();
                    Init.SeedData(context, userManager).Wait();
                    logger.LogInformation("Files migrated");
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, "Error occurred during database migration");
                }
            }

            host.Run();
        }
        public async Task <IActionResult> Get()
        {
            var ct = new CancellationToken();

            var result = new List <KeyValuePair <int, Character> >();

            try
            {
                var characterDictionary = await _stateManager.GetOrAddAsync <IReliableDictionary <int, Character> >(CharactersName);

                using (ITransaction tx = _stateManager.CreateTransaction())
                {
                    var list = await characterDictionary.CreateEnumerableAsync(tx);

                    var enumerator = list.GetAsyncEnumerator();


                    while (await enumerator.MoveNextAsync(ct))
                    {
                        result.Add(enumerator.Current);
                    }

                    // init
                    if (!result.Any())
                    {
                        result.AddRange(await Init.Populate(characterDictionary, tx));
                    }

                    return(Json(result));
                }
            }
            catch
            {
                return(new BadRequestResult());
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Init init = new Init();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

        try
        {

            if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }
            {

                if (!Page.IsPostBack)
                {

                    if (InitAppsList(State, RadComboAppSelector) == false)
                    {
                        //There are no Apps which can add a NEW Service at this moment.
                        RadNotification1.Title = "WARNING";
                        RadNotification1.Text = "There are no Apps with Billing History";
                        RadNotification1.Visible = true;
                        RadNotification1.Show();
                    }

                    /*if ((State["SelectedApp"] != null) && State["SelectedApp"].ToString() != "")
                    {
                        RadComboAppSelector.SelectedValue = State["SelectedApp"].ToString();
                    }*/
                }
            }
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
示例#43
0
    public static void Main(string[] args)
    {
        Init.WiringPiSetup();
        int       currentReadAttempt = 0;
        int       maxReadAttempts    = 20;
        Dht22Data data;

        var reader = new Dht22Reader(Int32.Parse(ConfigurationManager.AppSettings["ReadPin"]));

        do
        {
            if (currentReadAttempt > 0)
            {
                Timing.delay(100);
            }

            data = reader.ReadDHT22Data();
            currentReadAttempt++;
        } while (!data.IsValid && currentReadAttempt <= maxReadAttempts);

        var saver = new Dht22SQLiteSaver(ConfigurationManager.ConnectionStrings["default"].ConnectionString);

        saver.SaveData(data);
    }
示例#44
0
        private void OnDataReceived(byte[] data)
        {
            data = Compressor.Decompress(data);

            var reader     = new Deserializer(data);
            var messageTag = (MessageTag)reader.GetByte();

            switch (messageTag)
            {
            case MessageTag.StartSimulation:
                var init = new Init();
                init.Deserialize(reader);
                InitReceived?.Invoke(init);
                break;

            case MessageTag.Input:
                var commanderId   = reader.GetByte();
                var frameNumber   = reader.GetUInt();
                var countCommands = reader.GetInt();
                var commands      = new ICommand[countCommands];
                for (var i = 0; i < countCommands; i++)
                {
                    var tag = reader.GetUShort();

                    if (_commandFactories.ContainsKey(tag))
                    {
                        var newCommand = _commandFactories[tag].Invoke();
                        newCommand.Deserialize(reader);
                        commands[i] = newCommand;
                    }
                }

                base.Insert(frameNumber, commanderId, commands);
                break;
            }
        }
示例#45
0
文件: Schedule.cs 项目: Clouz/SynoAPI
        /// <summary>
        /// Provides advanced schedule settings
        /// </summary>
        /// <returns></returns>
        public static ScheduleConfigObject GetConfig(Init server)
        {
            Uri fullPath = new UriBuilder(server.BaseAddress)
            {
                Path  = BasePath,
                Query = "api=SYNO.DownloadStation.Schedule&version=1&method=getconfig",
            }.Uri;

            Console.WriteLine(fullPath);

            string json = Init.Richiesta(fullPath).Result;
            ScheduleConfigObject results;

            try
            {
                results = JsonConvert.DeserializeObject <ScheduleConfigObject>(JObject.Parse(json)["data"].ToString());
            }
            catch
            {
                throw syno.SynoException.FromJson(json, SynoException.ExceptionType.DownloadStation_Schedule);
            }

            return(results);
        }
    protected void UpdateAppLists()
    {
        try
        {
            Init init = new Init();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            init.InitAppsList(State, CurrentApp);

            RadComboBox ProvisionApps = (RadComboBox) State["ProvisionApps"];
            init.InitAppsList(State, ProvisionApps);

            init.InitManageDataAppsList(State);
            SetAllAppNames();
        }
        catch (Exception ex)
        {
            Util util = new Util();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            util.LogError(State, ex);
            Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace;
        }
    }
示例#47
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        Util util = new Util();
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        State["CustomersByAccount"] = CustomersByAccount;
        State["CustomersByEmail"] = CustomersByEmail;

        if (!IsPostBack)
        {
            if (State["Password"] == null)
            {
                Response.Redirect("Default.aspx", false);
                return;
            }
             string status = util.LoginToViziApps(State, State["Username"].ToString(),
                  State["Password"].ToString());

            if (status != "admin")
            {
                Response.Redirect("Default.aspx", false);
                return;
            }

            ClearMessages();
            try
            {

                if ( State["ServerAdminCustomerID"] == null ||  State["ServerAdminCustomerID"].ToString() == "0")
                {
                     State["ServerAdminCustomerID"] = "0";
                    Init init = new Init();
                    init.InitApplicationCustomers(State);
                }
                if (!Page.IsPostBack)
                {
                    ViewUserProfile.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                        "Dialogs/Admin/ViewUserProfile.aspx", 750, 750, true, true, true, true));
                   // ViewAllCustomers.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                   //     "Dialogs/Admin/ViewAllCustomers.aspx", 10, 10, true, true, true, true));
                    ViewActiveCustomers.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                        "Dialogs/Admin/ViewActiveCustomers.aspx", 120, 550, true, true, true, true));
                    ViewCurrentUsers.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                        "Dialogs/Admin/ViewCurrentUsers.aspx", 480, 500, true, true, true, true));
                    this.EmailCustomers.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                        "Dialogs/Admin/AdminEmail.aspx", 900, 800, true, true, true, true));
                    ShowXmlDesign.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                        "Dialogs/Admin/ShowXmlDesign.aspx", 750, 750, true, true, true, true));

                    HideForCustomers();
                }
            }

            catch (Exception ex)
            {
                util.ProcessMainExceptions(State, Response, ex);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
            Init init = new Init();

            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];

            try
            {

                if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }
                {

                    if (!Page.IsPostBack)
                    {
                        cgbilling.Visible = false;
                        CancelSubscriptionsButton.Visible = false;

                        if (InitAppsList(State, RadComboAppSelector) == false)
                        {
                            //There are no Apps to cancel
                            RadNotification1.Title = "WARNING";
                            RadNotification1.Text = "There are no App Subscriptions which can be cancelled.";
                            RadNotification1.Visible = true;
                            RadNotification1.Show();
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                util.ProcessMainExceptions(State, Response, ex);
            }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return;
         try
        {
            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();
            }

            if ( HttpRuntime.Cache["TechSupportEmail"] != null)
            {
                util.AddEmailToButton(SupportButton,  HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support");
            }

            util.UpdateSessionLog(State, "post", "ManageData");

            State["DatabaseEvents"] = DatabaseEvents;
            State["SpreadSheetEvents"] = SpreadSheetEvents;
            State["WebServiceEvents"] = WebServiceEvents;
            State["ManageDataApps"] = ManageDataApps;
            ManageDataType.Attributes.Add("onclick", "checkChangingManageDataType(this);");
            string attr = "javascript: NamedPopUp('Dialogs/Design/StoryBoard.aspx', 'StoryBoardPopup','height=900, width=460, left=0, top=400, menubar=no, status=no, location=no, toolbar=no, scrollbars=yes, resizable=yes');return false;";
            ViewStoryBoard.Attributes.Add("onclick", attr);

            ClearMessages();

            if (DataMultiPage.SelectedIndex == 2)
                return;

            WebServiceEventMappingStatus.Attributes.Add("onclick", PopupHelper.GeneratePopupScript(
                "Dialogs/ManageData/EventMappingStatus.aspx", 500, 500, false, false, false, true));

            Init init = new Init();
            if (State["ResetManageDataApps"] != null)
            {
                State["SelectedApp"] = null;
                init.InitManageDataAppsList(State);
                State["ResetManageDataApps"] = null;
            }

            if (ManageDataApps.Items.Count == 0 || ManageDataApps.SelectedValue.Contains("->"))
            {
                init.InitManageDataAppsList(State);
                ManageDataType.Style.Value = "display:none";
                ManageDataTypeLabel.Style.Value = "display:none";
                ViewStoryBoard.Style.Value = "display:none";
                ShouldRefreshStoryBoard.Text = "close";
                ManageTypeMultiPage.SelectedIndex = Constants.BLANK_PAGE;
                State["ManageDataType"] = null;
            }

            if (ManageDataApps.SelectedIndex > 0)
            {
                ViewStoryBoard.Style.Value = "";
                ManageDataType.Style.Value = "";
                ManageDataTypeLabel.Style.Value = "";

                string target = Request.Form.Get("__EVENTTARGET");
                if (target != "SaveDataRequestMap" &&
                    target != "SaveDataResponseMap" &&
                    target != "WebServiceResponseTreeView")
                    PrepareAppDisplay(target);
                if (target == "ViewConnectionString")
                {
                    DatabaseCommandsView.Nodes.Clear();
                    DatabaseEvents.SelectedIndex = 0;
                    SpreadsheetCommandsView.Nodes.Clear();
                    SpreadSheetEvents.SelectedIndex = 0;
                }
            }
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
    public XmlDocument Report()
    {
        Init init = new Init();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        init.InitSkuConfigurations(State);
         HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";
        Util util = new Util();
        XmlUtil x_util = new XmlUtil();
        XmlNode status_node = null;
        XmlDocument Report = new XmlDocument();
        XmlNode root = Report.CreateElement("report_response");
        Report.AppendChild(root);
        try
        {
            DB db = new DB();

            HttpRequest request = Context.Request;
            string application_id = request.QueryString.Get("appid");
            string application_name = request.QueryString.Get("app");
            string isproduction = request.QueryString.Get("isproduction");
            string username = request.QueryString.Get("customer");
            string user_id = request.QueryString.Get("userid");
            string device_id = request.QueryString.Get("deviceid");
            string device_version = request.QueryString.Get("device_version");
            string device_model = request.QueryString.Get("device_model");

            string viziapps_version = request.QueryString.Get("viziapps_version");
            if (viziapps_version == null)
                viziapps_version = request.QueryString.Get("mobiflex_version");

            string latitude = request.QueryString.Get("latitude");
            string longitude = request.QueryString.Get("longitude");

            string app_status = "staging";
            if (isproduction == "yes")
            {
                app_status = "production";
            }

            string customer_id = request.QueryString.Get("custid");
            if (app_status == "production")
            {
                util.GetProductionAccountInfo(State, username);
                util.GetProductionAppInfo(State, application_name);
                application_id = State["AppID"].ToString();

                if (State["IsProductionAppPaid"] != null && State["IsProductionAppPaid"].ToString() != "true")
                {
                    //if (!util.IsFreeProductionValid(State, application_id))
                    if (State["IsFreeProductionValid"] != null && State["IsFreeProductionValid"].ToString() != "true")
                    {
                        x_util.CreateNode(Report, root, "status", "kill");
                        x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                        throw new System.InvalidOperationException("The publishing service for your app has expired.");
                    }
                }
                if (State["AccountStatus"].ToString() == "inactive")
                {
                    x_util.CreateNode(Report, root, "status", "kill");
                    x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                    return Report;
                }
            }
            //else app is staging
            else if (customer_id != null && customer_id.Length > 0)
            {
                State["CustomerID"] = customer_id;
                string active_sql = "SELECT COUNT(*) FROM customers where customer_id='" + customer_id + "' AND status!='inactive'";
                string active_count = db.ViziAppsExecuteScalar(State, active_sql);
                if (active_count == "0")
                {
                    x_util.CreateNode(Report, root, "status", "kill");
                    x_util.CreateNode(Report, root, "status_message", "The account for this app is inactive. Contact ViziApps to re-activate your account.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app killed due to inactive account");
                    return Report;
                }
            }

            string display_width = request.QueryString.Get("display_width");
            if (display_width == null)
                display_width = "320";

            string display_height = request.QueryString.Get("display_height");
            if (display_height == null)
                display_height = "480";

            if (device_model == null)
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("iphone") || device_model.ToLower().Contains("ipod"))
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("ipad"))
                State["SelectedDeviceType"] = Constants.IPAD;
            else if (Convert.ToInt32(display_width) > 600)
                State["SelectedDeviceType"] = Constants.ANDROID_TABLET;
            else
                State["SelectedDeviceType"] = Constants.ANDROID_PHONE;

            if (application_id != null && application_id.Length > 0)
            {
                string sql = null;
                if (app_status == "staging")
                {
                    sql = "SELECT status FROM applications WHERE application_id='" + application_id + "'";
                    string staging_status = db.ViziAppsExecuteScalar(State, sql);
                    if (staging_status == null || (!staging_status.Contains("staging") && customer_id != null))
                    {
                        sql = "SELECT application_id FROM applications WHERE customer_id='" + customer_id + "' AND status LIKE '%staging%'";
                        string new_application_id = db.ViziAppsExecuteScalar(State, sql);
                        if (new_application_id != null)
                        {
                            XmlDocument Design = GetDesign(new_application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                            if (Design != null)
                            {
                                Design.SelectSingleNode("//status").InnerText = "update_app";
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                            }
                            else
                            {
                                Design = new XmlDocument();
                                XmlNode root2 = Design.CreateElement("report_response");
                                Design.AppendChild(root2);
                                x_util.CreateNode(Design, root2, "status", "kill");
                                x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                            }
                            return Design;
                        }
                    }
                    db.CloseViziAppsDatabase(State);
                }
            }

            string app_time_stamp = request.QueryString.Get("app_time_stamp");
            if (app_time_stamp != null && app_time_stamp.Length > 0)
            {
                string date_time_modified = null;
                if (app_status == "staging")
                    date_time_modified = util.GetStagingAppTimeStamp(State, application_id);
                else
                {
                    date_time_modified = State["DateTimeModified"].ToString();
                }
                DateTime AppDateTime;
                bool isGoodAppDateTime= DateTime.TryParse(app_time_stamp, out AppDateTime);
                DateTime DateTimeModified;
                bool isGoodDateTimeModified = DateTime.TryParse(date_time_modified, out DateTimeModified);
                if (isGoodAppDateTime && isGoodDateTimeModified && AppDateTime != DateTimeModified)
                { // assuming that there is a newer version
                    XmlDocument Design = null;
                    if (app_status == "staging")
                    {
                        Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, date_time_modified);
                    }
                    else
                    {
                        Design = new XmlDocument();
                        Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
                    }
                    if (Design != null)
                    {
                        Design.SelectSingleNode("//status").InnerText = "update_app";
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                    }
                    else
                    {
                        Design = new XmlDocument();
                        XmlNode root2 = Design.CreateElement("report_response");
                        Design.AppendChild(root2);
                        x_util.CreateNode(Design, root2, "status", "kill");
                        x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                    }

                    return Design;
                }
                else
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");

            string status = "OK";

            //check for unlimited use
            if (app_status == "production")
            {
                if (State["HasUnlimitedUsers"].ToString() == "true")
                    status += " unlimited";
            }

            status_node = x_util.CreateNode(Report, root, "status", status);
        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);
            if (status_node == null)
            {
                Report = new XmlDocument();
                XmlNode root2 = Report.CreateElement("report_response");
                Report.AppendChild(root2);
                status_node = x_util.CreateNode(Report, root2, "status");

            }
            status_node.InnerText = SE.Message + ": " + SE.StackTrace;
        }

        return Report;
    }
示例#51
0
文件: Program.cs 项目: tdhieu/iSpy
    private static void Main(string[] args)
    {
        //uninstall?
        string[] arguments = Environment.GetCommandLineArgs();

        foreach (string argument in arguments)
        {
            if (argument.Split('=')[0].ToLower() == "/u")
            {
                string guid = argument.Split('=')[1];
                string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
                var si = new ProcessStartInfo(path + "/msiexec.exe", "/x " + guid);
                Process.Start(si);
                Application.Exit();
                return;
            }
        }

        try
        {
            Application.EnableVisualStyles();            
            Application.SetCompatibleTextRenderingDefault(false);


            bool firstInstance = true;

            var me = Process.GetCurrentProcess();
            var arrProcesses = Process.GetProcessesByName(me.ProcessName);

            //only want to do this if not passing in a command

            if (arrProcesses.Length > 1)
            {
                firstInstance = false;
            }
            
            string executableName = Application.ExecutablePath;
            var executableFileInfo = new FileInfo(executableName);
            ExecutableDirectory = executableFileInfo.DirectoryName;

            bool ei = (!Directory.Exists(AppDataPath) || !Directory.Exists(AppDataPath + @"XML\") ||
                       !File.Exists(AppDataPath + @"XML\config.xml"));
            if (ei)
                EnsureInstall(true);
            else
            {
                try
                {
                    var o = Registry.CurrentUser.OpenSubKey(@"Software\ispy",true);
                    if (o?.GetValue("firstrun") != null)
                    {
                        o.DeleteValue("firstrun");
                        //copy over updated static files on first run of new install
                        EnsureInstall(false);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogExceptionToFile(ex, "startup");
                }
            }

            bool silentstartup = false;

            string command = "";
            if (args.Length > 0)
            {
                if (args[0].ToLower().Trim() == " - reset" && !ei)
                {
                    if (firstInstance)
                    {
                        if (
                            MessageBox.Show("Reset iSpy? This will overwrite all your settings.", "Confirm",
                                            MessageBoxButtons.OKCancel) == DialogResult.OK)
                            EnsureInstall(true);
                    }
                    else
                    {
                        MessageBox.Show("Please exit iSpy before resetting it.");
                    }
                }
                if (args[0].ToLower().Trim() == "-silent" || args[0].ToLower().Trim('\\') == "s")
                {
                    if (firstInstance)
                    {
                        silentstartup = true;
                    }
                }
                else
                {
                    command = args.Aggregate(command, (current, s) => current + (s + " "));
                }
            }

            if (!firstInstance)
            {
                if (!string.IsNullOrEmpty(command))
                {
                    File.WriteAllText(AppDataPath + "external_command.txt", command);
                    Thread.Sleep(1000);
                }
                else
                {
                    //show form
                    File.WriteAllText(AppDataPath + "external_command.txt", "showform");
                    Thread.Sleep(1000);
                }
                
                Application.Exit();
                return;
            }

            if (IntPtr.Size == 8)
                Platform = "x64";

            File.WriteAllText(AppDataPath + "external_command.txt", "");

            // in case our https certificate ever expires or there is some other issue
            ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
            ServicePointManager.Expect100Continue = false;
            ServicePointManager.DefaultConnectionLimit = 1000;

            FfmpegMutex = new Mutex();
            
            Application.ThreadException += ApplicationThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
            
            var ffmpegSetup = new Init();
            ffmpegSetup.Initialise();

            _previousExecutionState = NativeCalls.SetThreadExecutionState(NativeCalls.EsContinuous | NativeCalls.EsSystemRequired);
            
            AppIdle = new WinFormsAppIdleHandler {Enabled = false};
            var mf = new MainForm(silentstartup, command);
            Application.Run(mf);
            FfmpegMutex.Close();

            GC.KeepAlive(FfmpegMutex);
            AppIdle.Enabled = false;
            ffmpegSetup.DeInitialise();
            

            if (_previousExecutionState != 0)
            {
                NativeCalls.SetThreadExecutionState(_previousExecutionState);
            }
            
        }
        catch (Exception ex)
        {
            try
            {
                Logger.LogExceptionToFile(ex);
            } catch
            {
                
            }
            while (ex.InnerException != null)
            {
                try
                {
                    Logger.LogExceptionToFile(ex);
                }
                catch
                {

                }
            }
        }
    }
    protected void DuplicateApp_Click(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        try
        {
            ClearMessages();
            if (SavedCanvasHtml.Text.Length > 0)
                SavePage();
            State["SelectedApp"] = CurrentApp.SelectedValue;
            AppName.Text = Request.Form.Get("AppName");
            string new_name = AppName.Text.Trim();
            AppName.Text = "";
            util.CopyApp(State, new_name);
            Message.Text = new_name + " has been created. ";
            Init init = new Init();
             State["SelectedApp"] = new_name;
            UpdateAppLists();
            InitAppPages();
        }
        catch (Exception ex)
        {
             util.LogError(State, ex);
            Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace;
        }
    }
    protected void ShowProductionServices()
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        ArrayList PaidServices = util.GetPaidServices(State);
        State["PaidServices"] = PaidServices;
        if (PaidServices == null || PaidServices.Count == 0)
            return;

        DataTable ServiceTable = new DataTable();
        ServiceTable.Columns.Add("Paid Service");
        ServiceTable.Columns.Add("Associated App");
        ServiceTable.Columns.Add(" ");
        foreach (string[] PaidService in PaidServices)
        {
            DataRow row = ServiceTable.NewRow();

            row.ItemArray = PaidService;
            ServiceTable.Rows.Add(row);
        }

        ProductionServices.DataSource = ServiceTable;
        ProductionServices.DataBind();

        int index = 0;
        Init init = new Init();

         foreach (GridDataItem row in ProductionServices.Items)
        {
            string[] service = (string[])PaidServices[index];
             if (service[1] == null || service[1].Length == 0)
             {
                 RadComboBox box = new RadComboBox();
                 box.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(box_SelectedIndexChanged);
                 box.AutoPostBack = true;
                 box.ID = "ServiceApp." + index.ToString();
                 box.Width = Unit.Pixel(200);
                 init.InitAppsListNoDefault(State, box);
                 row.Cells[3].Controls.Add(box);
             }
             else
             {
                 ImageButton delete_button = new ImageButton();
                 delete_button.ImageUrl = "~/images/delete_small.gif";
                 delete_button.ID = "remove." + index.ToString();
                 delete_button.ToolTip = "Remove this service from this app";
                 delete_button.Click += new ImageClickEventHandler(delete_button_Click);
                 delete_button.Attributes.Add("onclick", "return confirm('Are you sure you want to remove this app from this service?');");
                 row.Cells[4].Controls.Add(delete_button);
             }
             index++;
        }
    }
    public XmlDocument Login()
    {
        Init init = new Init();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        init.InitSkuConfigurations(State);
         HttpRuntime.Cache["TempFilesPath"] = Server.MapPath(".") + @"\temp_files\";
        Util util = new Util();
        XmlUtil x_util = new XmlUtil();
        XmlNode status = null;
        XmlDocument Design = null;

        try
        {
            DB db = new DB();

            HttpRequest request = Context.Request;

            string viziapps_version = request.QueryString.Get("viziapps_version");
            if (viziapps_version == null)
                viziapps_version = request.QueryString.Get("mobiflex_version");

            string device_id = request.QueryString.Get("deviceid");
            string device_model = request.QueryString.Get("device_model");
            string customer_username = request.QueryString.Get("customer");
            string app_status = (customer_username != null && customer_username.Length > 0) ? "production" : "staging";
            string application_name = request.QueryString.Get("app");
            string application_id = request.QueryString.Get("app_id");
            string unlimited = request.QueryString.Get("unlimited");
            string device_version = request.QueryString.Get("device_version");
            if (application_id == null)
                application_id = "";

            string sql = null;
            DataRow[] rows = null;
            string customer_id = null;
            string user_id = null;
            string user = request.QueryString.Get("user");
            string password = request.QueryString.Get("pwd");

            string display_width = request.QueryString.Get("display_width");
            if (display_width == null)
                display_width = "320";

            string display_height = request.QueryString.Get("display_height");
            if (display_height == null)
                display_height = "480";

            if (device_model == null)
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("iphone") || device_model.ToLower().Contains("ipod"))
                State["SelectedDeviceType"] = Constants.IPHONE;
            else if (device_model.ToLower().Contains("ipad"))
                State["SelectedDeviceType"] = Constants.IPAD;
            else if (Convert.ToInt32(display_width) > 600)
                State["SelectedDeviceType"] = Constants.ANDROID_TABLET;
            else
                State["SelectedDeviceType"] = Constants.ANDROID_PHONE;

            if (unlimited == null || unlimited != "true")
            {
                if (user == null || password == null)
                {
                    Design = new XmlDocument();
                    XmlNode root2 = Design.CreateElement("login_response");
                    Design.AppendChild(root2);
                    status = x_util.CreateNode(Design, root2, "status", "Either the username or the password: "******" is incorrect.");
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                    return Design;
                }
            }

            if (app_status == "production")
            {
                util.GetProductionAccountInfo(State, customer_username);
                if (customer_id == null)
                    customer_id = State["CustomerID"].ToString();
                //State["Username"] = customer_username;
                //customer_id = util.GetCustomerIDFromUsername(State, customer_username);
                //State["CustomerID"] = customer_id;
                //string account_status = util.GetCustomerStatus(State);
                // if (account_status == "inactive")
                if (State["AccountStatus"].ToString() == "inactive")
                {
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: account inactive");
                    throw new System.InvalidOperationException("Your customer account is inactive.");
                }
                util.GetProductionAppInfo(State, application_name);
                application_id = State["AppID"].ToString();

                if (State["IsProductionAppPaid"] != null && State["IsProductionAppPaid"].ToString() != "true")
                {
                    //if (!util.IsFreeProductionValid(State, application_id))
                    if (State["IsFreeProductionValid"] != null && State["IsFreeProductionValid"].ToString() != "true")
                    {
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: publishing service expired");
                        throw new System.InvalidOperationException("The publishing service for your app has expired.");
                    }
                }

                if (unlimited == null || unlimited != "true")
                {
                    //check username and password
                    // sql = "SELECT * FROM users WHERE username='******' AND password='******' AND application_id='" + application_id + "'";

                    //rows = db.ViziAppsExecuteSql(State, sql);
                    //if (rows.Length == 0)
                    if (State["Password"] == null)
                    {
                        //db.CloseViziAppsDatabase(State);
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                        throw new System.InvalidOperationException("Either the username or the password: "******" is incorrect.");
                    }

                    //check number of users -- unlimited use never needs a login
                    //bool use_1_user_credential = util.GetUse1UserCredential(State, application_id);
                    //if (use_1_user_credential)
                    if (State["Use1UserCredential"] != null && State["Use1UserCredential"].ToString() == "true")
                    {
                        Hashtable features = util.IsProductionAppPaid(State, application_id);
                        DataRow row = rows[0];
                        sql = "SELECT COUNT(*) FROM users_device_ids WHERE user_id='" + row["user_id"].ToString() + "'";
                        int device_count = Convert.ToInt32(db.ViziAppsExecuteScalar(State, sql));

                        sql = "SELECT COUNT(*) FROM users_device_ids WHERE device_id='" + device_id + "'";
                        string device_exists = db.ViziAppsExecuteScalar(State, sql);

                        if (device_exists == "0")
                        {
                            if (device_count >= (int)features["max_users"])
                            {
                                db.CloseViziAppsDatabase(State);
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: reached limit of users");
                                throw new System.InvalidOperationException("Cannot download app: reached limit of users.");
                            }
                            else
                            {
                                sql = "INSERT INTO users_device_ids SET device_id='" + device_id + "',user_id='" + row["user_id"].ToString() + "'";
                                db.ViziAppsExecuteNonQuery(State, sql);
                            }
                        }
                        //else app is allowed
                    }
                }
            }
            else //staging
            {
                sql = "SELECT * FROM customers WHERE username='******'";
                rows = db.ViziAppsExecuteSql(State, sql);
                if (rows.Length == 0)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: user not registered");
                    throw new Exception("The username " + user.ToLower() + " is not registered. Go to www.viziapps.com and create a free account.");
                }

                DataRow row = rows[0];
                if (row["password"].ToString() != password)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                    throw new Exception("Either the username or the password: "******" is incorrect.");
                }
                if (row["status"].ToString() == "inactive")
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: account is inactive");
                    throw new Exception("Your account is inactive. Contact ViziApps to re-activate your account.");
                }
                customer_id = row["customer_id"].ToString();
                State["CustomerID"] = customer_id;
            }

            //user is now logged in

            if (app_status == "staging")
            {
                sql = "SELECT application_id FROM applications WHERE " +
                   "in_staging=1 AND customer_id='" + customer_id + "'";

                application_id = db.ViziAppsExecuteScalar(State, sql);
                if (application_id == null)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                    throw new System.InvalidOperationException("You need to select an app to test, on the design page of your ViziApps Studio account.");
                }
            }

            db.CloseViziAppsDatabase(State);

            //get design
            if (State["AppDesignURL"] == null)
            {
                Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                //save design in a file if production
                if (app_status == "production")
                {
                    util.SaveProductionAppInfo(State, application_name, Design);
                }
            }
            else
            {
                Design = new XmlDocument();
                Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
            }
            if (Design == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                status = x_util.CreateNode(Design, root2, "status", "You need to select an app to test, on the design page of your ViziApps Studio account.");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: design downloaded");

        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);

            if (status == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                status = x_util.CreateNode(Design, root2, "status");

            }
            status.InnerText = SE.Message;
            util.LogError(State, SE);
        }
        return Design;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Util util = new Util();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (util.CheckSessionTimeout(State, Response, "Default.aspx")) return;

        Init init = new Init();
        try
        {
            if (util.CheckSessionTimeout(State,Response,"Default.aspx")) return;
            if ( HttpRuntime.Cache["TechSupportEmail"] != null)
            {
                util.AddEmailToButton(SupportButton,  HttpRuntime.Cache["TechSupportEmail"].ToString(), "Email To Tech Support");
            }
            util.UpdateSessionLog(State, "post", "TabDesignWeb");

            ClearMessages();

            if (!IsPostBack)
            {
                CopyRight.InnerText = HttpRuntime.Cache["CopyRight"].ToString();
                UserLabel.Text = State["Username"].ToString();

                if (CurrentApp.Items.Count == 0 || CurrentApp.SelectedValue.Contains("->") ||
                              State["SelectedApp"] == null)
                {
                    init.InitAppsList(State, CurrentApp);
                }

                State["SelectedAppType"] = Constants.WEB_APP_TYPE;
                AppType.Text = Constants.WEB_APP_TYPE;
                State["UrlAccountIdentifier"] = util.GetUrlAccountIdentifier(State);
                UrlAccountIdentifier.Text = State["UrlAccountIdentifier"].ToString();

                if (State["SelectedApp"] == null || !util.DoesAppExist(State) || CurrentApp.SelectedIndex == 0)
                {
                    InitCurrentApp("->");
                    State["SelectedDeviceType"] = Constants.IPHONE;
                    DeviceType.Text = State["SelectedDeviceType"].ToString();
                }
                else if (State["SelectedApp"] != null)
                {
                    InitCurrentApp(State["SelectedApp"].ToString());
                }
            }
            DeletePage.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this page?');");

            if (State["ResetConfigApps"] != null)
            {
                State["SelectedApp"] = null;
                init.InitAppsList(State, CurrentApp);
                State["ResetConfigApps"] = null;
            }

            State["WebServiceValidated"] = null;
            if (State["SelectedDeviceType"] == null)
            {
                State["SelectedDeviceType"] = Constants.IPHONE;
                DeviceType.Text = State["SelectedDeviceType"].ToString();
             }
            SetAllAppNames();
        }
        catch (Exception ex)
        {
            util.ProcessMainExceptions(State, Response, ex);
        }
    }
示例#56
0
 public void Handle(Init req)
 {}
示例#57
0
文件: Init.cs 项目: pawluk/MOSHApp-WS
        public object Get(Init request)
        {
            if (!IsLoggedIn) return UnauthorizedResponse();

            return GetInitInfo(UserId);
        }
示例#58
0
 public void On(Init x) {}
示例#59
0
    protected void RemoveCustomer_Click(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        string customer_id = State["ServerAdminCustomerID"].ToString();
        if (customer_id == "0")
        {
            AdminMessage.Text = "Select a customer and try again.";
            return;
        }

        string sql = "SELECT status,username FROM customers WHERE customer_id='" + customer_id + "'";
        DB db = new DB();
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataRow row = rows[0];

        string status = row["status"].ToString();
        string username = row["username"].ToString();

        if (status != "inactive")
        {
            AdminMessage.Text = "Customer can only be removed after it has been deactivated.";
        }
        else
        {
            DoRemoveCustomer(username, customer_id);
            AdminMessage.Text = "Customer has been removed.";

            HideForCustomers();

            Init init = new Init();
            init.InitApplicationCustomers(State);
            CustomerStatus.Text = "";
        }

        db.CloseViziAppsDatabase(State);
        CustomersByAccount.Items[0].Selected = true;
        CustomersByEmail.Items[0].Selected = true;
        HideForApplications();
    }
示例#60
0
 // Use this for initialization
 void Start()
 {
     current = this;
     Game.ShowStartScreen ();
 }