• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Automation.ProgramBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HomeGenie.Automation.ProgramBlock的典型用法代码示例。如果您正苦于以下问题:C# ProgramBlock类的具体用法?C# ProgramBlock怎么用?C# ProgramBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProgramBlock类属于HomeGenie.Automation命名空间,在下文中一共展示了ProgramBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SaveMacro

 public ProgramBlock SaveMacro(string options)
 {
     RecordingDisable();
     //
     var program = new ProgramBlock();
     program.Name = "New Macro";
     program.Address = masterControlProgram.GeneratePid();
     program.Type = "Wizard";
     foreach (var migCommand in macroCommands)
     {
         var command = new ProgramCommand();
         command.Domain = migCommand.Domain;
         command.Target = migCommand.NodeId;
         command.CommandString = migCommand.Command;
         command.CommandArguments = "";
         if (!string.IsNullOrEmpty(migCommand.GetOption(0)) && migCommand.GetOption(0) != "null")
         {
             //TODO: should we pass entire command option string? migCmd.OptionsString
             command.CommandArguments = migCommand.GetOption(0) + (options != "" && options != "null" ? "/" + options : "");
         }
         program.Commands.Add(command);
     }
     masterControlProgram.ProgramAdd(program);
     //
     return program;
 }
开发者ID:florpan,项目名称:HomeGenie,代码行数:26,代码来源:MacroRecorder.cs


示例2: CSharpEngine

 public CSharpEngine(ProgramBlock pb) : base(pb) 
 {
     // TODO: SetShadowCopyPath/SetShadowCopyFiles methods are deprecated... 
     // TODO: create own AppDomain for "programDomain" instead of using CurrentDomain
     // TODO: and use AppDomainSetup to set shadow copy for each app domain
     // TODO: !!! verify AppDomain compatibility with mono !!!
     if (!isShadowCopySet)
     {
         isShadowCopySet = true;
         var domain = AppDomain.CurrentDomain;
         domain.SetShadowCopyPath(Path.Combine(domain.BaseDirectory, "programs"));
         domain.SetShadowCopyFiles();
     }
 }
开发者ID:Bounz,项目名称:HomeGenie,代码行数:14,代码来源:CSharpEngine.cs


示例3: ProcessRequest

        public void ProcessRequest(MIGClientRequest request, MIGInterfaceCommand migCommand)
        {
            string streamcontent = "";
            ProgramBlock currentProgram;
            ProgramBlock newProgram;
            //
            homegenie.ExecuteAutomationRequest(migCommand);
            if (migCommand.Command.StartsWith("Macro."))
            {
                switch (migCommand.Command)
                {
                    case "Macro.Record":
                        homegenie.ProgramEngine.MacroRecorder.RecordingEnable();
                        break;
                    case "Macro.Save":
                        newProgram = homegenie.ProgramEngine.MacroRecorder.SaveMacro(migCommand.GetOption(1));
                        migCommand.Response = newProgram.Address.ToString();
                        break;
                    case "Macro.Discard":
                        homegenie.ProgramEngine.MacroRecorder.RecordingDisable();
                        break;
                    case "Macro.SetDelay":
                        switch (migCommand.GetOption(0).ToLower())
                        {
                            case "none":
                                homegenie.ProgramEngine.MacroRecorder.DelayType = MacroDelayType.None;
                                break;

                            case "mimic":
                                homegenie.ProgramEngine.MacroRecorder.DelayType = MacroDelayType.Mimic;
                                break;

                            case "fixed":
                                double secs = double.Parse(migCommand.GetOption(1), System.Globalization.CultureInfo.InvariantCulture);
                                homegenie.ProgramEngine.MacroRecorder.DelayType = MacroDelayType.Fixed;
                                homegenie.ProgramEngine.MacroRecorder.DelaySeconds = secs;
                                break;
                        }
                        break;
                    case "Macro.GetDelay":
                        migCommand.Response = "[{ DelayType : '" + homegenie.ProgramEngine.MacroRecorder.DelayType + "', DelayOptions : '" + homegenie.ProgramEngine.MacroRecorder.DelaySeconds + "' }]";
                        break;
                }
            }
            else if (migCommand.Command.StartsWith("Scheduling."))
            {
                switch (migCommand.Command)
                {
                    case "Scheduling.Add":
                    case "Scheduling.Update":
                        var item = homegenie.ProgramEngine.SchedulerService.AddOrUpdate(migCommand.GetOption(0), migCommand.GetOption(1).Replace("|", "/"));
                        item.ProgramId = migCommand.GetOption(2);
                        homegenie.UpdateSchedulerDatabase();
                        break;
                    case "Scheduling.Delete":
                        homegenie.ProgramEngine.SchedulerService.Remove(migCommand.GetOption(0));
                        homegenie.UpdateSchedulerDatabase();
                        break;
                    case "Scheduling.Enable":
                        homegenie.ProgramEngine.SchedulerService.Enable(migCommand.GetOption(0));
                        homegenie.UpdateSchedulerDatabase();
                        break;
                    case "Scheduling.Disable":
                        homegenie.ProgramEngine.SchedulerService.Disable(migCommand.GetOption(0));
                        homegenie.UpdateSchedulerDatabase();
                        break;
                    case "Scheduling.Get":
                        migCommand.Response = JsonConvert.SerializeObject(homegenie.ProgramEngine.SchedulerService.Get(migCommand.GetOption(0)));
                        break;
                    case "Scheduling.List":
                        homegenie.ProgramEngine.SchedulerService.Items.Sort((SchedulerItem s1, SchedulerItem s2) =>
                        {
                            return s1.Name.CompareTo(s2.Name);
                        });
                        migCommand.Response = JsonConvert.SerializeObject(homegenie.ProgramEngine.SchedulerService.Items);
                        break;
                }
            }
            else if (migCommand.Command.StartsWith("Programs."))
            {
                if (migCommand.Command != "Programs.Import")
                {
                    streamcontent = new StreamReader(request.InputStream).ReadToEnd();
                }
                //
                switch (migCommand.Command)
                {
                    case "Programs.Import":
                        string archiveName = "homegenie_program_import.hgx";
                        if (File.Exists(archiveName)) File.Delete(archiveName);
                        //
                        var encoding = (request.Context as HttpListenerContext).Request.ContentEncoding;
                        string boundary = MIG.Gateways.WebServiceUtility.GetBoundary((request.Context as HttpListenerContext).Request.ContentType);
                        MIG.Gateways.WebServiceUtility.SaveFile(encoding, boundary, request.InputStream, archiveName);
                        //
                        var serializer = new XmlSerializer(typeof(ProgramBlock));
                        var reader = new StreamReader(archiveName);
                        newProgram = (ProgramBlock)serializer.Deserialize(reader);
                        reader.Close();
                        //
//.........这里部分代码省略.........
开发者ID:florpan,项目名称:HomeGenie,代码行数:101,代码来源:Automation.cs


示例4: StartProgramEvaluator

 private void StartProgramEvaluator(ProgramBlock program)
 {
     EvaluateProgramConditionArgs evalArgs = new EvaluateProgramConditionArgs() {
         Program = program,
         Callback = (ProgramBlock p, bool conditionsatisfied) =>
         {
             if (conditionsatisfied && p.IsEnabled)
             {
                 Run(p, null); // that goes async too
             }
         }
     };
     ThreadPool.QueueUserWorkItem(new WaitCallback(EvaluateProgramCondition), evalArgs);
 }
开发者ID:asm7100,项目名称:HomeGenie,代码行数:14,代码来源:ProgramManager.cs


示例5: Run

        // TODO: v1.1 !!!IMPORTANT!!! move thread allocation and starting to ProgramEngineBase.cs class
        public void Run(ProgramBlock program, string options)
        {
            if (program.IsRunning)
                return;

            if (program.Engine.ProgramThread != null)
            {
                program.Engine.Stop();
                program.IsRunning = false;
            }

            program.IsRunning = true;
            RaiseProgramModuleEvent(program, Properties.PROGRAM_STATUS, "Running");

            program.TriggerTime = DateTime.UtcNow;

            program.Engine.ProgramThread = new Thread(() =>
            {
                MethodRunResult result = null;
                try
                {
                    result = program.Run(options);
                }
                catch (Exception ex)
                {
                    result = new MethodRunResult();
                    result.Exception = ex;
                }
                //
                if (result != null && result.Exception != null && !result.Exception.GetType().Equals(typeof(System.Reflection.TargetException)))
                {
                    // runtime error occurred, script is being disabled
                    // so user can notice and fix it
                    List<ProgramError> error = new List<ProgramError>() { program.GetFormattedError(result.Exception, false) };
                    program.ScriptErrors = JsonConvert.SerializeObject(error);
                    program.IsEnabled = false;
                    RaiseProgramModuleEvent(program, Properties.RUNTIME_ERROR, "CR: " + result.Exception.Message.Replace('\n', ' ').Replace('\r', ' '));
                }
                program.IsRunning = false;
                program.Engine.ProgramThread = null;
                RaiseProgramModuleEvent(program, Properties.PROGRAM_STATUS, "Idle");
            });
            //
            if (program.ConditionType == ConditionType.Once)
            {
                program.IsEnabled = false;
            }
            //
            try
            {
                program.Engine.ProgramThread.Start();
            }
            catch
            {
                program.Engine.Stop();
                program.IsRunning = false;
                RaiseProgramModuleEvent(program, Properties.PROGRAM_STATUS, "Idle");
            }
            //
            //Thread.Sleep(100);
        }
开发者ID:asm7100,项目名称:HomeGenie,代码行数:62,代码来源:ProgramManager.cs


示例6: ProgramAdd

 public void ProgramAdd(ProgramBlock program)
 {
     automationPrograms.Add(program);
     program.EnabledStateChanged += program_EnabledStateChanged;
     program.Engine.SetHost(homegenie);
     // Initialize state
     RaiseProgramModuleEvent(program, Properties.PROGRAM_STATUS, "Idle");
     if (program.IsEnabled)
     {
         StartProgramEvaluator(program);
     }
 }
开发者ID:asm7100,项目名称:HomeGenie,代码行数:12,代码来源:ProgramManager.cs


示例7: ProcessRequest


//.........这里部分代码省略.........
                    // regenerate encrypted files
                    homegenie.SystemConfiguration.Update();
                    homegenie.UpdateModulesDatabase();
                }
                else if (migCommand.GetOption(0) == "Security.ClearPassword")
                {
                    homegenie.MigService.SetWebServicePassword("");
                    homegenie.SystemConfiguration.HomeGenie.UserPassword = "";
                    // regenerate encrypted files
                    homegenie.SystemConfiguration.Update();
                    homegenie.UpdateModulesDatabase();
                }
                else if (migCommand.GetOption(0) == "Security.HasPassword")
                {
                    migCommand.Response = JsonHelper.GetSimpleResponse((homegenie.SystemConfiguration.HomeGenie.UserPassword != "" ? "1" : "0"));
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestore")
                {
                    // file uploaded by user
                    string archivename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Utility.GetTmpFolder(), "homegenie_restore_config.zip");
                    Utility.FolderCleanUp(Utility.GetTmpFolder());
                    try
                    {
                        MIG.Gateways.WebServiceUtility.SaveFile(request.InputStream, archivename);
                        Utility.UncompressZip(archivename, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Utility.GetTmpFolder()));
                        File.Delete(archivename);
                    }
                    catch
                    {
                    }
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestoreS1")
                {
                    var serializer = new XmlSerializer(typeof(List<ProgramBlock>));
                    var reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Utility.GetTmpFolder(), "programs.xml"));
                    var newProgramsData = (List<ProgramBlock>)serializer.Deserialize(reader);
                    reader.Close();
                    var newProgramList = new List<ProgramBlock>();
                    foreach (ProgramBlock program in newProgramsData)
                    {
                        if (program.Address >= ProgramEngine.USER_SPACE_PROGRAMS_START)
                        {
                            ProgramBlock p = new ProgramBlock();
                            p.Address = program.Address;
                            p.Name = program.Name;
                            p.Description = program.Description;
                            newProgramList.Add(p);
                        }
                    }
                    newProgramList.Sort(delegate(ProgramBlock p1, ProgramBlock p2)
                    {
                        string c1 = p1.Address.ToString();
                        string c2 = p2.Address.ToString();
                        return c1.CompareTo(c2);
                    });
                    migCommand.Response = JsonConvert.SerializeObject(newProgramList);
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestoreS2")
                {
                    var serializer = new XmlSerializer(typeof(List<Group>));
                    var reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Utility.GetTmpFolder(), "automationgroups.xml"));
                    var automationGroups = (List<Group>)serializer.Deserialize(reader);
                    reader.Close();
                    //
                    foreach (var automationGroup in automationGroups)
                    {
开发者ID:Qu3uk,项目名称:HomeGenie,代码行数:67,代码来源:Config.cs


示例8: ProgramsDiff

 private bool ProgramsDiff(ProgramBlock oldProgram, ProgramBlock newProgram)
 {
     bool unchanged = (JsonConvert.SerializeObject(oldProgram.ConditionType) == JsonConvert.SerializeObject(newProgram.ConditionType)) &&
     (JsonConvert.SerializeObject(oldProgram.Conditions) == JsonConvert.SerializeObject(newProgram.Conditions)) &&
     (JsonConvert.SerializeObject(oldProgram.Commands) == JsonConvert.SerializeObject(newProgram.Commands)) &&
     (oldProgram.ScriptCondition == newProgram.ScriptCondition) &&
     (oldProgram.ScriptSource == newProgram.ScriptSource) &&
     (oldProgram.Name == newProgram.Name) &&
     (oldProgram.Description == newProgram.Description) &&
     (oldProgram.Group == newProgram.Group) &&
     (oldProgram.Type == newProgram.Type);
     return !unchanged;
 }
开发者ID:michaelita,项目名称:HomeGenie,代码行数:13,代码来源:UpdateChecker.cs


示例9: CompileScript

 public List<ProgramError> CompileScript(ProgramBlock program)
 {
     List<ProgramError> errors = new List<ProgramError>();
     switch (program.Type.ToLower())
     {
     case "csharp":
         errors = CompileCsharp(program);
         break;
     case "ruby":
     case "python":
         errors = CompileIronScript(program);
         break;
     case "javascript":
         errors = CompileJavascript(program);
         break;
     case "arduino":
         errors = CompileArduino(program);
         break;
     }
     return errors;
 }
开发者ID:jarrettv,项目名称:HomeGenie,代码行数:21,代码来源:ProgramEngine.cs


示例10: CompileCsharp

        private List<ProgramError> CompileCsharp(ProgramBlock program)
        {
            List<ProgramError> errors = new List<ProgramError>();

            // check for output directory
            if (!Directory.Exists(Path.GetDirectoryName(program.AssemblyFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(program.AssemblyFile));
            }

            // dispose assembly and interrupt current task (if any)
            program.AppAssembly = null;
            program.IsEnabled = false;

            // DO NOT CHANGE THE FOLLOWING LINES OF CODE
            // it is a lil' trick for mono compatibility
            // since it will be caching the assembly when using the same name
            // and use the old one instead of the new one
            string tmpfile = Path.Combine("programs", Guid.NewGuid().ToString() + ".dll");
            System.CodeDom.Compiler.CompilerResults result = new System.CodeDom.Compiler.CompilerResults(null);
            try
            {
                result = CSharpAppFactory.CompileScript(program.ScriptCondition, program.ScriptSource, tmpfile);
            }
            catch (Exception ex)
            {
                // report errors during post-compilation process
                result.Errors.Add(new System.CodeDom.Compiler.CompilerError(program.Name, 0, 0, "-1", ex.Message));
            }

            if (result.Errors.Count > 0)
            {
                int sourceLines = program.ScriptSource.Split('\n').Length;
                foreach (System.CodeDom.Compiler.CompilerError error in result.Errors)
                {
                    int errorRow = (error.Line - CSharpAppFactory.PROGRAM_CODE_OFFSET);
                    string blockType = "CR";
                    if (errorRow >= sourceLines + CSharpAppFactory.CONDITION_CODE_OFFSET)
                    {
                        errorRow -= (sourceLines + CSharpAppFactory.CONDITION_CODE_OFFSET);
                        blockType = "TC";
                    }
                    if (!error.IsWarning)
                    {
                        errors.Add(new ProgramError() {
                            Line = errorRow,
                            Column = error.Column,
                            ErrorMessage = error.ErrorText,
                            ErrorNumber = error.ErrorNumber,
                            CodeBlock = blockType
                        });
                    }
                    else
                    {
                        var warning = String.Format("{0},{1},{2}: {3}", blockType, errorRow, error.Column, error.ErrorText);
                        RaiseProgramModuleEvent(program, Properties.COMPILER_WARNING, warning);
                    }
                }
            }
            if (errors.Count == 0)
            {
                program.AppAssembly = result.CompiledAssembly;
            }

            return errors;
        }
开发者ID:Qu3uk,项目名称:HomeGenie,代码行数:66,代码来源:ProgramEngine.cs


示例11: ProgramAdd

 public void ProgramAdd(ProgramBlock program)
 {
     program.SetHost(homegenie);
     automationPrograms.Add(program);
     program.EnabledStateChanged += program_EnabledStateChanged;
     //
     // in case of c# script preload assembly from generated .dll
     if (program.Type.ToLower() == "csharp" && !program.AssemblyLoad())
     {
         program.ScriptErrors = "Program update is required.";
     }
     //
     // Initialize state
     RaiseProgramModuleEvent(program, Properties.PROGRAM_STATUS, "Idle");
     if (program.IsEnabled)
     {
         StartProgramEvaluator(program);
     }
 }
开发者ID:Qu3uk,项目名称:HomeGenie,代码行数:19,代码来源:ProgramEngine.cs


示例12: ProgramRemove

 public void ProgramRemove(ProgramBlock program)
 {
     RaiseProgramModuleEvent(program, Properties.ProgramStatus, "Removed");
     program.IsEnabled = false;
     automationPrograms.Remove(program);
     // delete program files
     string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "programs");
     // remove csharp assembly
     try
     {
         File.Delete(Path.Combine(file, program.Address + ".dll"));
     }
     catch
     {
     }
     // remove arduino folder files 
     try
     {
         Directory.Delete(Path.Combine(file, "arduino", program.Address.ToString()), true);
     } catch { }
 }
开发者ID:shadab-entrepreneur,项目名称:HomeGenie,代码行数:21,代码来源:ProgramManager.cs


示例13: ProgramAdd

 public void ProgramAdd(ProgramBlock program)
 {
     automationPrograms.Add(program);
     program.EnabledStateChanged += program_EnabledStateChanged;
     program.Engine.SetHost(homegenie);
     RaiseProgramModuleEvent(program, Properties.ProgramStatus, "Added");
     if (isEngineEnabled && program.IsEnabled)
     {
         program.Engine.StartScheduler();
     }
 }
开发者ID:shadab-entrepreneur,项目名称:HomeGenie,代码行数:11,代码来源:ProgramManager.cs


示例14: Run

 // TODO: v1.1 !!!IMPORTANT!!! move thread allocation and starting to ProgramEngineBase.cs class
 public void Run(ProgramBlock program, string options)
 {
     program.Engine.StartProgram(options);
 }
开发者ID:shadab-entrepreneur,项目名称:HomeGenie,代码行数:5,代码来源:ProgramManager.cs


示例15: ProgramRemove

 public void ProgramRemove(ProgramBlock program)
 {
     program.IsEnabled = false;
     program.Stop();
     automationPrograms.Remove(program);
 }
开发者ID:florpan,项目名称:HomeGenie,代码行数:6,代码来源:ProgramEngine.cs


示例16: CompileArduino

        private List<ProgramError> CompileArduino(ProgramBlock program)
        {
            List<ProgramError> errors = new List<ProgramError>();

            // Generate, compile and upload Arduino Sketch
            string sketchFileName = ArduinoAppFactory.GetSketchFile(program.Address.ToString());
            if (!Directory.Exists(Path.GetDirectoryName(sketchFileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(sketchFileName));
            }
            string sketchMakefile = Path.Combine(Path.GetDirectoryName(sketchFileName), "Makefile");

            try
            {
                // .ino source is stored in the ScriptSource property
                File.WriteAllText(sketchFileName, program.ScriptSource);
                // Makefile source is stored in the ScriptCondition property
                File.WriteAllText(sketchMakefile, program.ScriptCondition);
                errors = ArduinoAppFactory.CompileSketch(sketchFileName, sketchMakefile);
            }
            catch (Exception e)
            { 
                errors.Add(new ProgramError() {
                    Line = 0,
                    Column = 0,
                    ErrorMessage = "General failure: is 'arduino-mk' package installed?\n\n" + e.Message,
                    ErrorNumber = "500",
                    CodeBlock = "CR"
                });
            }

            return errors;
        }
开发者ID:jarrettv,项目名称:HomeGenie,代码行数:33,代码来源:ProgramEngine.cs


示例17: CSharpEngine

 public CSharpEngine(ProgramBlock pb)
     : base(pb)
 {
 }
开发者ID:asm7100,项目名称:HomeGenie,代码行数:4,代码来源:CSharpEngine.cs


示例18: Run

 public void Run(ProgramBlock program, string options)
 {
     if (program.IsRunning) return;
     //
     if (program.ProgramThread != null)
     {
         program.Stop();
         program.IsRunning = false;
     }
     //
     program.IsRunning = true;
     RaiseProgramModuleEvent(program, "Program.Status", "Running");
     //
     if (program.Type.ToLower() != "wizard")
     {
         if (program.Type.ToLower() == "csharp" && program.AppAssembly == null)
         {
             program.IsRunning = false;
         }
         else
         {
             program.TriggerTime = DateTime.UtcNow;
             program.ProgramThread = new Thread(() =>
             {
                 MethodRunResult result = null;
                 try
                 {
                     result = program.Run(options);
                 } catch (Exception ex) {
                     result = new MethodRunResult();
                     result.Exception = ex;
                 }
                 //
                 if (result != null && result.Exception != null)
                 {
                     // runtime error occurred, script is being disabled
                     // so user can notice and fix it
                     List<ProgramError> error = new List<ProgramError>() { new ProgramError() {
                             CodeBlock = "CR",
                             Column = 0,
                             Line = 0,
                             ErrorNumber = "-1",
                             ErrorMessage = result.Exception.Message
                         }
                     };
                     program.ScriptErrors = JsonConvert.SerializeObject(error);
                     program.IsEnabled = false;
                     RaiseProgramModuleEvent(
                         program,
                         "Runtime.Error",
                         "CR: " + result.Exception.Message.Replace(
                             '\n',
                             ' '
                         )
                     );
                 }
                 program.IsRunning = false;
                 program.ProgramThread = null;
                 RaiseProgramModuleEvent(program, "Program.Status", "Idle");
             });
             //
             try
             {
                 program.ProgramThread.Start();
             }
             catch
             {
                 program.Stop();
                 program.IsRunning = false;
                 RaiseProgramModuleEvent(program, "Program.Status", "Idle");
             }
         }
     }
     else
     {
         program.TriggerTime = DateTime.UtcNow;
         if (program.ConditionType == ConditionType.Once)
         {
             program.IsEnabled = false;
         }
         //
         program.ProgramThread = new Thread(() =>
         {
             try
             {
                 ExecuteWizardScript(program);
             }
             catch (ThreadAbortException)
             {
                 program.IsRunning = false;
             }
             finally
             {
                 program.IsRunning = false;
             }
             RaiseProgramModuleEvent(program, "Program.Status", "Idle");
         });
         //
         program.ProgramThread.Start();
     }
//.........这里部分代码省略.........
开发者ID:jarrettv,项目名称:HomeGenie,代码行数:101,代码来源:ProgramEngine.cs


示例19: ProcessRequest


//.........这里部分代码省略.........
                {
                    homegenie.MigService.GetGateway("WebServiceGateway").SetOption("Port", migCommand.GetOption(1));
                    homegenie.SystemConfiguration.Update();
                }
                else if (migCommand.GetOption(0) == "HttpService.GetHostHeader")
                {
                    var host = homegenie.MigService.GetGateway("WebServiceGateway").GetOption("Host");
                    request.ResponseData = new ResponseText(host != null ? host.Value : "*");
                }
                else if (migCommand.GetOption(0) == "HttpService.SetHostHeader")
                {
                    homegenie.MigService.GetGateway("WebServiceGateway").SetOption("Host", migCommand.GetOption(1));
                    homegenie.SystemConfiguration.Update();
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestore")
                {
                    // file uploaded by user
                    string archivename = Path.Combine(tempFolderPath, "homegenie_restore_config.zip");
                    Utility.FolderCleanUp(Utility.GetTmpFolder());
                    try
                    {
                        MIG.Gateways.WebServiceUtility.SaveFile(request.RequestData, archivename);
                        Utility.UncompressZip(archivename, tempFolderPath);
                        File.Delete(archivename);
                        request.ResponseData = new ResponseStatus(Status.Ok);
                    }
                    catch
                    {
                        request.ResponseData = new ResponseStatus(Status.Error);
                    }
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestoreS1")
                {
                    var serializer = new XmlSerializer(typeof(List<ProgramBlock>));
                    var reader = new StreamReader(Path.Combine(tempFolderPath, "programs.xml"));
                    var newProgramsData = (List<ProgramBlock>)serializer.Deserialize(reader);
                    reader.Close();
                    var newProgramList = new List<ProgramBlock>();
                    foreach (ProgramBlock program in newProgramsData)
                    {
                        if (program.Address >= ProgramManager.USER_SPACE_PROGRAMS_START)
                        {
                            ProgramBlock p = new ProgramBlock();
                            p.Address = program.Address;
                            p.Name = program.Name;
                            p.Description = program.Description;
                            newProgramList.Add(p);
                        }
                    }
                    newProgramList.Sort(delegate(ProgramBlock p1, ProgramBlock p2)
                    {
                        string c1 = p1.Address.ToString();
                        string c2 = p2.Address.ToString();
                        return c1.CompareTo(c2);
                    });
                    request.ResponseData = newProgramList;
                }
                else if (migCommand.GetOption(0) == "System.ConfigurationRestoreS2")
                {
                    // Import automation groups
                    var serializer = new XmlSerializer(typeof(List<Group>));
                    var reader = new StreamReader(Path.Combine(tempFolderPath, "automationgroups.xml"));
                    var automationGroups = (List<Group>)serializer.Deserialize(reader);
                    reader.Close();
                    foreach (var automationGroup in automationGroups)
                    {
开发者ID:Solertis,项目名称:HomeGenie,代码行数:67,代码来源:Config.cs


示例20: ProgramAdd

 public void ProgramAdd(ProgramBlock program)
 {
     program.SetHost(homegenie);
     automationPrograms.Add(program);
     program.EnabledStateChanged += program_EnabledStateChanged;
     //
     // Initialize state
     RaiseProgramModuleEvent(program, "Program.Status", "Idle");
     if (program.IsEnabled)
     {
         StartProgramEvaluator(program);
     }
 }
开发者ID:jarrettv,项目名称:HomeGenie,代码行数:13,代码来源:ProgramEngine.cs



注:本文中的HomeGenie.Automation.ProgramBlock类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Views.VPort类代码示例发布时间:2022-05-26
下一篇:
C# Model.Resource类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap