示例#1
0
 private void checkSecurityKey()
 {
     try
     {
         Log.Info("Checking if System Security Key exist");
         string cSSK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("System", "SecurityKey").Value;
         if (cSSK == " " || cSSK == "" || cSSK.Length < 16)
         {
             Log.Info("System Security Key found, but is not valid.");
             Log.Info("Generating a new Security Key...");
             OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", OSAESecurity.GenerateSecurityKey(), "Rest");
         }
         else
         {
             Log.Info("System Security Key found.");
         }
     }
     catch
     {
         Log.Info("System Security Key does not exist..");
         Log.Info("Creating System object property: SecurityKey.");
         OSAEObjectTypeManager.ObjectTypePropertyAdd("System", "SecurityKey", "String", "", "", false, true, "This key is used in HTTP and Rest authorization. Must be 16 characters.");
         Log.Info("Generating a new Security Key...");
         OSAEObjectPropertyManager.ObjectPropertySet("System", "SecurityKey", OSAESecurity.GenerateSecurityKey(), "Rest");
     }
 }
示例#2
0
 private void checkAPIKey()
 {
     try
     {
         Log.Info("Checking if REST API Key exist");
         string cRAK = OSAE.OSAEObjectPropertyManager.GetObjectPropertyValue("Rest", "APIKEY").Value;
         if (cRAK == " " || cRAK == "" || cRAK.Length < 32)
         {
             Log.Info("REST API Key found, but is not valid.");
             Log.Info("Creating a new REST API Key...");
             OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", OSAESecurity.GenerateAPIKey(), "Rest");
         }
         else
         {
             Log.Info("REST API Key found.");
         }
     }
     catch
     {
         Log.Info("REST API Key does not exist..");
         Log.Info("Creating Rest Plugin property: APIKEY.");
         OSAEObjectTypeManager.ObjectTypePropertyAdd("Rest", "APIKEY", "String", "", "", false, true, "This is the Rest Plugin API Key. This property is used by remote clients and devices to encrypt and decrypt user information for authentication.");
         Log.Info("Generating a new REST API Key...");
         OSAEObjectPropertyManager.ObjectPropertySet("Rest", "APIKEY", OSAESecurity.GenerateAPIKey(), "Rest");
     }
 }
示例#3
0
 protected void btnPropAdd_Click(object sender, EventArgs e)
 {
     if (ddlPropType.SelectedValue == "Object Type" & ddlBaseType2.SelectedValue == "")
     {
         Response.Write("<script>alert('You must select an Object Type!');</script>");
     }
     else
     {
         OSAEObjectTypeManager.ObjectTypePropertyAdd(hdnSelectedObjectName.Text, txtPropName.Text, ddlPropType.SelectedValue, ddlBaseType2.SelectedItem.ToString(), txtPropDefault.Text, chkTrackChanges.Checked, chkRequired.Checked, txtPropertyTooltip.Text);
         loadProperties();
     }
 }
示例#4
0
        public void updateFeeds()
        {
            this.Log.Debug("Trying to get all feed Urls:" + pName);

            DataSet ds = new DataSet();

            ds = OSAEObjectPropertyManager.ObjectPropertyArrayGetAll(pName, "Feeds");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                try
                {
                    this.Log.Debug("Fetching feed: " + dr["item_name"].ToString());
                    WebClient webClient = new WebClient();
                    string    strSource = webClient.DownloadString(dr["item_name"].ToString());
                    webClient.Dispose();

                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(strSource);

                    string feedTitle = xml.SelectSingleNode("/rss/channel/title").InnerText;
                    this.Log.Debug("Feeds title: " + feedTitle);
                    if (OSAEObjectPropertyManager.GetObjectPropertyValue(pName, feedTitle).Value == "")
                    {
                        this.Log.Debug("Adding property to object type");
                        OSAEObjectTypeManager.ObjectTypePropertyAdd(feedTitle, "List", "", "RSS", false);
                    }
                    OSAEObjectPropertyManager.ObjectPropertyArrayDeleteAll(pName, feedTitle);
                    this.Log.Debug("Cleared feed data");

                    XmlNodeList xnList = xml.SelectNodes("/rss/channel/item");
                    foreach (XmlNode xn in xnList)
                    {
                        string content = xn.SelectSingleNode("title").InnerText + " - " + xn.SelectSingleNode("description").InnerText;
                        content = Regex.Replace(content, "<.*?>", string.Empty);
                        this.Log.Debug("Added item to feed data: " + content);
                        OSAEObjectPropertyManager.ObjectPropertyArrayAdd(pName, feedTitle, content, "");
                    }
                }
                catch (Exception ex)
                {
                    this.Log.Error("Error", ex);
                }
            }
        }
 protected void btnPropAdd_Click(object sender, EventArgs e)
 {
     OSAEObjectTypeManager.ObjectTypePropertyAdd(txtPropName.Text, ddlPropType.SelectedValue, txtPropDefault.Text, hdnSelectedObjectName.Text, chkTrackChanges.Checked);
 }
示例#6
0
        public void discoverDevices()
        {
            this.Log.Info(objName + " is performing Device Discovery...");
            List <string> fDev = mySonyLib.Locator.LocateDevices();

            if (fDev.Count > 0)
            {
                this.Log.Info("Discovery found: " + fDev.Count + " Device(s)");
                for (int i = 0; i < fDev.Count; i++)
                {
                    string selDev = fDev[i];
                    try
                    {
                        this.Log.Info("Building Object from Document: " + selDev);
                        mySonyDevice.BuildFromDocument(new Uri(selDev));
                    }
                    catch (Exception e)
                    {
                        this.Log.Error("ERROR - Building Object for " + mySonyDevice.Name, e);
                        return;
                    }
                    this.Log.Info("Checking if Object " + mySonyDevice.Name + " is SONY Compatiable");
                    if (mySonyDevice.Ircc.ControlUrl != null)
                    {
                        if (!CheckObjByName(mySonyDevice.Name.ToString()))
                        {
                            try
                            {
                                this.Log.Info("Creating Sony Object Type for: " + mySonyDevice.Name);
                                OSAEObjectTypeManager.ObjectTypeAdd(mySonyDevice.Name, "Sony Device", "Sony", mySonyDevice.Name, true, false, false, true);
                                OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "REGISTER", "Register", "", "", "", "", "Executing this Method will Register this device wity OSA");
                                OSAEObjectTypeManager.ObjectTypeStateAdd(mySonyDevice.Name, "ON", "Online", "This state represents that the Sony Device is Online");
                                OSAEObjectTypeManager.ObjectTypeStateAdd(mySonyDevice.Name, "OFF", "OffLine", "This state represents that the Sony Device is Offline");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "DocumentURL", "String", "String", "", false, true, "Enter the URL to the Sony Device Document");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Channel", "String", "String", "", false, false, "This will contain the current channel");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Volume", "String", "String", "", false, false, "This will contain the current Volume Level");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Current_Status", "String", "String", "", false, false, "This will contain the current Device Status");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Registered", "Boolean", "String", "FALSE", false, true, "Select True/False if this device is registered");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd(mySonyDevice.Name, "Online", "Boolean", "String", "FALSE", false, true, "Select True/False if this device is Online");
                                this.Log.Info("Sony Object Type was Created: " + mySonyDevice.Name);
                                this.Log.Info("Creating Object for " + mySonyDevice.Name);
                                OSAEObjectManager.ObjectAdd(mySonyDevice.Name, "Sony Device", "Sony Device", mySonyDevice.Name, mySonyDevice.IPAddress, "", 30, true);
                                OSAEObjectStateManager.ObjectStateSet(mySonyDevice.Name, "OFF", "Sony");
                                OSAEObjectPropertyManager.ObjectPropertySet(mySonyDevice.Name, "DocumentURL", mySonyDevice.DocumentUrl, "Sony");
                                OSAEObjectManager.ObjectUpdate(mySonyDevice.Name, mySonyDevice.Name, "Sony Device", "Sony Device", mySonyDevice.Name, mySonyDevice.IPAddress, "", 30, true);
                                this.Log.Info("Sony Object Created: " + mySonyDevice.Name);

                                foreach (APILibrary.SonyCommands sCmd in mySonyDevice.Commands)
                                {
                                    string cName  = sCmd.name;;
                                    string cValue = sCmd.value;
                                    OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, cName.ToUpper(), cName, "", "", "", "", "Retrieved Method from Device");
                                    this.Log.Info("Created Method: " + cName + " for device " + mySonyDevice.Name);
                                    if (cName == "ChannelUp")
                                    {
                                        OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "SETCHANNEL", "Set Channel", "Channel #", "", "", "", "Executing this method will set the entered channel on the device");
                                        this.Log.Info("Created Method: Set Channel for device " + mySonyDevice.Name);
                                    }
                                }
                                OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "GETSTATUS", "Get Status", "", "", "", "", "Executing this method will retrieve the current status from the Sony Device");
                                this.Log.Info("Created Method: Get Status for device " + mySonyDevice.Name);
                                OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "SENDTEXT", "Send Text", "Text", "", "", "", "Executing this method will send the netered text to the Sony Device");
                                this.Log.Info("Created Method: Send Text for device " + mySonyDevice.Name);
                                OSAEObjectTypeManager.ObjectTypeMethodAdd(mySonyDevice.Name, "GETTEXT", "Get Text", "", "", "", "", "Executing this method will check if the Sony device is accepting a Text input");
                                this.Log.Info("Created Method: Get Text for device " + mySonyDevice.Name);


                                if (debug)
                                {
                                    this.Log.Debug("Run the Register method for the : " + mySonyDevice.Name + " Object to register this device!");
                                }
                            }
                            catch (Exception ex)
                            {
                                this.Log.Error("An error occurred!!!: " + ex.Message);
                                if (debug)
                                {
                                    this.Log.Debug("An Error occured in the Object Creation for: " + mySonyDevice.Name);
                                }
                            }
                        }
                        else
                        {
                            this.Log.Error("The object " + mySonyDevice.Name + " already exist. Object NOT Created");
                        }
                    }
                    else
                    {
                        this.Log.Debug("The object " + mySonyDevice.Name + " is NOT compatiable");
                    }
                }
            }
            else
            {
                this.Log.Error("The Sony Discovery Method did NOT find any devices");
            }
        }