예제 #1
0
 public AlertEventRow(objectsActionsEntry oae)
 {
     Oae = oae;
     InitializeComponent();
     lblSummary.Text = GetSummary(Oae.type, Oae.param1, Oae.param2, Oae.param3, Oae.param4);
     BackColor       = DefaultBackColor;
 }
예제 #2
0
 public AlertEventRow(objectsActionsEntry oae)
 {
     Oae = oae;
     InitializeComponent();
     lblSummary.Text = GetSummary(Oae.type, Oae.param1, Oae.param2, Oae.param3, Oae.param4);
     BackColor = DefaultBackColor;
 }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ddlAction.SelectedIndex < 1)
            {
                MessageBox.Show(this, LocRm.GetString("SelectAnActionToAdd"));
                return;
            }
            var oa = (ListItem)ddlAction.SelectedItem;

            if (!MainForm.Conf.Subscribed && oa.Restricted)
            {
                if (LoginRequested != null)
                {
                    LoginRequested(this, EventArgs.Empty);
                }
                return;
            }
            bool cancel;

            string[] config = GetConfig("", "", "", "", oa.Value, out cancel);
            if (cancel)
            {
                return;
            }


            var oae = new objectsActionsEntry
            {
                mode         = Mode,
                objectid     = Oid,
                objecttypeid = Otid,
                type         = oa.Value,
                param1       = config[0],
                param2       = config[1],
                param3       = config[2],
                param4       = config[3]
            };

            MainForm.Actions.Add(oae);
            RenderEventList();
        }
예제 #4
0
        private void CopyActions(int OID, int oid, int otid, string mode)
        {
            MainForm.Actions.RemoveAll(p => p.objectid == oid && p.objecttypeid == otid && p.mode == mode);
            var l = MainForm.Actions.Where(p => p.objectid == OID && p.objecttypeid == otid && p.mode == mode).ToList();

            foreach (var oa in l)
            {
                var oae = new objectsActionsEntry
                {
                    mode         = mode,
                    objectid     = oid,
                    objecttypeid = otid,
                    type         = oa.type,
                    param1       = oa.param1,
                    param2       = oa.param2,
                    param3       = oa.param3,
                    param4       = oa.param4
                };
                MainForm.Actions.Add(oae);
            }
        }
예제 #5
0
파일: JSONServer.cs 프로젝트: tdhieu/iSpy
        private void SaveJson(String sPhysicalFilePath, string sHttpVersion, string sBuffer, ref HttpRequest req)
        {
            string resp = "";
            int ot, oid;

            int.TryParse(GetVar(sPhysicalFilePath, "oid"), out oid);
            int.TryParse(GetVar(sPhysicalFilePath, "ot"), out ot);
            bool saveObjects = true;
            try
            {
                var d = getJSONObject(sBuffer);
                if (d == null)
                    return;

                String n = d.name;
                resp = "{\"actionResult\":\"ok\"}";
                bool apply = false;
                string nl = n.ToLowerInvariant();
                switch (nl)
                {
                    default:
                    {
                        resp = "{\"error\":\"" + nl + " not recognized\"}";
                        saveObjects = false;
                    }
                        break;
                    case "liveupdate":
                    {
                        switch (ot)
                        {
                            case 1:
                            {
                                var c = MainForm.Microphones.FirstOrDefault(p => p.id == oid);
                                if (c != null)
                                {
                                    PopulateObject(d, c);
                                }
                            }
                                break;
                            case 2:
                            {
                                var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                                if (c != null)
                                {
                                    PopulateObject(d, c);
                                }
                            }
                                break;
                        }
                        apply = true;
                        saveObjects = false;
                    }
                        break;
                    case "editpelco":
                    {
                        var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                        if (c != null)
                        {
                            PopulateObject(d, c);
                        }
                    }
                        break;
                    case "settings":
                    {
                        PopulateObject(d, MainForm.Conf);
                        if (!string.IsNullOrEmpty(MainForm.Conf.Archive))
                        {
                            MainForm.Conf.Archive = MainForm.Conf.Archive.Replace("/", @"\");
                            if (!MainForm.Conf.Archive.EndsWith(@"\"))
                                MainForm.Conf.Archive += @"\";
                        }
                        ReloadAllowedIPs();
                        ReloadAllowedReferrers();
                        MainForm.SaveConfig();
                        saveObjects = false;
                    }
                        break;
                    case "editftpserver":
                    {
                        resp = "{\"actionResult\":\"reloadFTPServers\"}";
                        if (d.ident == "new")
                        {
                            d.ident = Guid.NewGuid().ToString();
                            var cfgs = new configurationServer {ident = d.ident};
                            var l = MainForm.Conf.FTPServers.ToList();
                            l.Add(cfgs);
                            MainForm.Conf.FTPServers = l.ToArray();
                        }

                        PopulateObject(d, MainForm.Conf.FTPServers.First(p => p.ident == d.ident.ToString()));
                        MainForm.SaveConfig();
                        saveObjects = false;
                    }
                        break;
                    case "editstorage":
                    {
                        resp = "{\"actionResult\":\"reloadStorage\"}";
                        if (d.ident.ToString() == "new")
                        {
                            d.ident = MainForm.Conf.MediaDirectories.Max(p => p.ID) + 1;
                        }
                        int idnew = Convert.ToInt32(d.ident);
                        d.ident = idnew;

                        var md = MainForm.Conf.MediaDirectories.FirstOrDefault(p => p.ID == idnew);
                        bool ndir = false;
                        if (md == null)
                        {
                            md = new configurationDirectory {ID = d.ident, Entry = ""};
                            ndir = true;
                        }

                        var exdir = md.Entry;
                        PopulateObject(d, md);
                        md.Entry = md.Entry.Replace("/", @"\");
                        if (!md.Entry.EndsWith(@"\"))
                            md.Entry += @"\";

                        try
                        {
                            if (!Directory.Exists(md.Entry))
                            {
                                throw new Exception("Invalid Directory");
                            }
                        }
                        catch (Exception ex)
                        {
                            if (exdir != "")
                                md.Entry = exdir;
                            resp = "{\"actionResult\":\"reloadStorage\",\"error\":\"" + ex.Message.JsonSafe() + "\"}";
                            break;
                        }

                        if (ndir)
                        {
                            var l = MainForm.Conf.MediaDirectories.ToList();
                            l.Add(md);
                            MainForm.Conf.MediaDirectories = l.ToArray();
                        }
                        else
                        {
                            var di = new DirectoryInfo(exdir);
                            var di2 = new DirectoryInfo(md.Entry);
                            if (di.ToString() != di2.ToString())
                            {
                                var t = new Thread(() => Helper.CopyFolder(exdir, md.Entry)) {IsBackground = true};
                                t.Start();
                                resp =
                                    "{\"actionResult\":\"reloadStorage\",\"message\":\"Media is being copied to the new location.\"}";
                            }
                        }

                        MainForm.SaveConfig();
                        saveObjects = false;
                    }
                        break;
                    case "editcamera":
                        {
                            var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                            if (c != null)
                            {
                                var olddir = c.directory;
                                PopulateObject(d, c);
                                apply = true;
                                var newdir = c.directory;
                                if (olddir.ToLowerInvariant() != newdir.ToLowerInvariant())
                                {
                                    if (!Helper.IsAlphaNumeric(newdir))
                                    {
                                        c.directory = olddir;
                                        resp = "{\"error\":\"Directory invalid. Should be alphanumeric eg: ABCD.\"}";
                                    }
                                    else
                                    {
                                        var fullolddir = Helper.GetMediaDirectory(2, c.id) + "video\\" + olddir + "\\";
                                        var fullnewdir = Helper.GetMediaDirectory(2, c.id) + "video\\" + newdir + "\\";
                                        try
                                        {
                                            Directory.Move(fullolddir, fullnewdir);
                                        }
                                        catch (Exception ex)
                                        {
                                            c.directory = olddir;
                                            resp = "{\"error\":\""+ex.Message.JsonSafe()+"\"}";
                                        }
                                    }
                                }
                                MainForm.InstanceReference.SaveObjectList(false);
                            }
                        }
                        break;
                    case "motionzones":
                    {
                        var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                        if (c != null)
                        {
                            var lz = new List<objectsCameraDetectorZone>();
                            if (d.zones != null)
                            {
                                foreach (var z in d.zones)
                                {
                                    var x = Convert.ToInt32(z["x"].Value);
                                    var y = Convert.ToInt32(z["y"].Value);
                                    var w = Convert.ToInt32(z["w"].Value);
                                    var h = Convert.ToInt32(z["h"].Value);
                                    lz.Add(new objectsCameraDetectorZone { height = h, left = x, top = y, width = w });
                                }
                            }
                            c.detector.motionzones = lz.ToArray();
                            var cw = MainForm.InstanceReference.GetCameraWindow(oid);
                            cw?.Camera?.SetMotionZones(lz.ToArray());
                        }
                        saveObjects = false;
                    }
                        break;
                    case "screenarea":
                        {
                            var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                            if (c != null)
                            {

                                if (d.zones != null)
                                {
                                    var z = d.zones[0];
                                    int si;
                                    int.TryParse(c.settings.videosourcestring, out si);
                                    if (Screen.AllScreens.Length <= si)
                                        si = 0;
                                    var s = Screen.AllScreens[si];
                                    var x = Convert.ToInt32((Convert.ToDecimal(z["x"].Value) / 100) * s.WorkingArea.Width);
                                    var y = Convert.ToInt32((Convert.ToDecimal(z["y"].Value) / 100) * s.WorkingArea.Height);
                                    var w = Convert.ToInt32((Convert.ToDecimal(z["w"].Value) / 100) * s.WorkingArea.Width);
                                    var h = Convert.ToInt32((Convert.ToDecimal(z["h"].Value) / 100) * s.WorkingArea.Height);
                                    //even height and width
                                    if (w % 2 != 0)
                                        w -= 1;
                                    if (h % 2 != 0)
                                        h -= 1;

                                    c.settings.desktoparea = x + "," + y + "," + w + "," + h;
                                }
                                else
                                    c.settings.desktoparea = "";
                            }
                            saveObjects = false;
                        }
                        
                        break;
                    case "pip":
                        {
                            var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                            if (c != null)
                            {
                                string cfg = "";
                                if (d.zones != null)
                                {
                                    foreach (var z in d.zones)
                                    {
                                        var id = Convert.ToInt32(z["id"].Value);
                                        var x = Convert.ToInt32(z["x"].Value);
                                        var y = Convert.ToInt32(z["y"].Value);
                                        var w = Convert.ToInt32(z["w"].Value);
                                        var h = Convert.ToInt32(z["h"].Value);
                                        cfg += id + "," + x + "," + y + "," + w + "," + h + "|";
                                    }
                                }
                                c.settings.pip.config = cfg.Trim('|');
                                
                                var cw = MainForm.InstanceReference.GetCameraWindow(oid);
                                if (cw?.Camera != null)
                                {
                                    cw.Camera.PiPConfig = c.settings.pip.config;
                                }

                            }
                            saveObjects = false;
                        }
                        
                        break;
                    case "editmicrophone":
                        {
                            var c = MainForm.Microphones.FirstOrDefault(p => p.id == oid);
                            if (c != null)
                            {
                                var olddir = c.directory;
                                PopulateObject(d, c);
                                apply = true;
                                var newdir = c.directory;
                                if (olddir.ToLowerInvariant() != newdir.ToLowerInvariant())
                                {
                                    if (!Helper.IsAlphaNumeric(newdir))
                                    {
                                        c.directory = olddir;
                                        resp = "{\"error\":\"Directory invalid. Should be alphanumeric eg: ABCD.\"}";
                                    }
                                    else
                                    {
                                        var fullolddir = Helper.GetMediaDirectory(2, c.id) + "video\\" + olddir + "\\";
                                        var fullnewdir = Helper.GetMediaDirectory(2, c.id) + "video\\" + newdir + "\\";
                                        try
                                        {
                                            Directory.Move(fullolddir, fullnewdir);
                                        }
                                        catch (Exception ex)
                                        {
                                            c.directory = olddir;
                                            resp = "{\"error\":\"" + ex.Message.JsonSafe() + "\"}";
                                        }
                                    }
                                } 
                                MainForm.InstanceReference.SaveObjectList(false);
                            }
                        }
                        break;
                    case "editschedule":
                        {
                            resp = "{\"actionResult\":\"reloadSchedule\"}";
                            objectsScheduleEntry s = null;
                            if (d.ident.ToString() == "new")
                            {
                                s = new objectsScheduleEntry
                                {
                                    active = true,
                                    time = 0,
                                    daysofweek = "",
                                    objectid = oid,
                                    objecttypeid = ot,
                                    parameter = "",
                                    typeid = 0
                                };
                                MainForm.Schedule.Add(s);
                            }
                            else
                            {
                                var l = MainForm.Schedule.Where(p => p.objectid == oid && p.objecttypeid == ot).ToList();
                                int i = Convert.ToInt32(d.ident);

                                if (i < l.Count)
                                {
                                    s = l[i];
                                }
                            }
                            if (s != null)
                            {
                                PopulateObject(d, s);
                            }
                        }
                        break;
                    case "editptzschedule":
                        {
                            resp = "{\"actionResult\":\"reloadPTZSchedule\"}";
                            var oc = MainForm.Cameras.First(p => p.id == oid);
                            objectsCameraPtzscheduleEntry pe;
                            if (d.ident.ToString() == "new")
                            {
                                pe = new objectsCameraPtzscheduleEntry
                                {
                                    command = "",
                                    time = new DateTime()
                                };

                                PopulateObject(d, pe);
                                var l = oc.ptzschedule.entries.ToList();
                                l.Add(pe);
                                oc.ptzschedule.entries = l.ToArray();
                            }
                            else
                            {
                                int i = Convert.ToInt32(d.ident);
                                var l = oc.ptzschedule.entries.ToList();
                                if (i < l.Count)
                                {
                                    pe = l[i];
                                    PopulateObject(d, pe);

                                }
                            }
                        }
                        break;
                    case "editaction":
                        resp = "{\"actionResult\":\"reloadActions\"}";
                        objectsActionsEntry a;
                        if (d.ident.ToString() == "new")
                        {
                            a = new objectsActionsEntry
                            {
                                type = "",
                                mode = "",
                                active = true,
                                objectid = oid,
                                objecttypeid = ot,
                                ident = Guid.NewGuid().ToString()
                            };
                            MainForm.Actions.Add(a);
                            resp = resp.Replace("PARAMS", "");
                        }
                        else
                        {
                            a = MainForm.Actions.FirstOrDefault(p => p.ident == d.ident.ToString());
                        }
                        if (a != null)
                        {
                            var p1 = a.param1;
                            PopulateObject(d, a);
                            if (Helper.WebRestrictedAlertTypes.Contains(a.type))
                            {
                                a.param1 = a.param1.Replace("/", "\\");
                                if (a.param1.IndexOf("\\", StringComparison.Ordinal)!=-1)
                                {
                                    resp = "{\"error\":\"Only filenames (not paths) are allowed in actions via the website\"}";
                                    a.param1 = p1;
                                }
                            }
                            
                            MainForm.InstanceReference.SaveObjectList(false);
                        }
                        break;
                    case "editaudiosource":
                    {
                        var c = MainForm.Microphones.FirstOrDefault(p => p.id == oid);
                        if (c != null)
                        {
                            PopulateObject(d, c);
                            
                            var vl = MainForm.InstanceReference.GetVolumeLevel(c.id);
                            if (vl != null)
                            {
                                vl.Disable();
                                vl.Enable();
                            }
                            
                        }
                        resp = "{\"actionResult\":\"waiteditobject\"}";
                    }
                        break;
                    case "editvideosource":
                        {
                            var c = MainForm.Cameras.FirstOrDefault(p => p.id == oid);
                            if (c != null)
                            {
                                PopulateObject(d, c);

                                if (c.settings.sourceindex == 9)
                                {
                                    string url = c.settings.onvifident;

                                    Uri u;
                                    if (!Uri.TryCreate(url, UriKind.Absolute, out u))
                                    {
                                        resp = "{\"error\":\"URI invalid\"}";
                                        break;
                                    }
                                    string addr = u.DnsSafeHost;
                                    var dev = MainForm.ONVIFDevices.FirstOrDefault(p => p.Address == addr);
                                    if (dev == null)
                                    {
                                        if (NV(c.settings.namevaluesettings, "profileid") == "")
                                            c.settings.namevaluesettings = NVSet(c.settings.namevaluesettings, "profileid", "0");
                                    }
                                    else
                                    {
                                        TransportProtocol tp;
                                        if (!Enum.TryParse(NV(c.settings.namevaluesettings, "transport"), true, out tp))
                                            tp = TransportProtocol.rtsp;

                                        dev.Account = new NetworkCredential
                                        {
                                            UserName = c.settings.login,
                                            Password = c.settings.password
                                        };
                                        var sessionFactory = new NvtSessionFactory(dev.Account);
                                        var profilename = NV(c.settings.namevaluesettings, "profilename");

                                        foreach (var uri in dev.Uris)
                                        {
                                            var f = sessionFactory.CreateSession(uri);
                                            dev.URL = uri.ToString();
                                            Profile[] profiles;
                                            try
                                            {
                                                profiles = f.GetProfiles().RunSynchronously();
                                            }
                                            catch (Exception ex)
                                            {
                                                Logger.LogExceptionToFile(ex, "ONVIF");
                                                continue;
                                            }

                                            dev.Profiles = profiles;
                                            var strSetup = new StreamSetup { transport = new Transport() };
                                            strSetup.transport.protocol = tp;
                                            int i = 0;
                                            foreach (var p in profiles)
                                            {
                                                try
                                                {
                                                    if (p.token == profilename)
                                                    {
                                                        var strUri = f.GetStreamUri(strSetup, p.token).RunSynchronously();
                                                        string urlAuth = strUri.uri.Replace("://", "://[USERNAME]:[PASSWORD]@");
                                                        string streamSize = p.videoEncoderConfiguration.resolution.width + "x" + p.videoEncoderConfiguration.resolution.height;

                                                        c.settings.videosourcestring = urlAuth;
                                                        c.settings.namevaluesettings = NVSet(c.settings.namevaluesettings, "profileid", i.ToString(CultureInfo.InvariantCulture));
                                                        c.settings.namevaluesettings = NVSet(c.settings.namevaluesettings, "streamsize", streamSize);

                                                        string[] sz = streamSize.Split('x');
                                                        c.settings.desktopresizewidth = Convert.ToInt32(sz[0]);
                                                        c.settings.desktopresizeheight = Convert.ToInt32(sz[1]);

                                                        break;
                                                    }
                                                    i++;
                                                }
                                                catch (Exception ex)
                                                {
                                                    Logger.LogExceptionToFile(ex, "ONVIF");
                                                }

                                            }
                                        }
                                    }
                                    c.ptz = -5;
                                }
                                
                                var cw = MainForm.InstanceReference.GetCameraWindow(c.id);
                                if (cw != null)
                                {
                                    cw.Disable();
                                    cw.Enable();
                                }
                                resp = "{\"actionResult\":\"waiteditobject\"}";
                            }

                        }
                        break;
                }
                if (apply)
                {
                    var io = MainForm.InstanceReference.GetISpyControl(ot, oid);
                    io?.Apply();
                }
            }
            catch (Exception ex)
            {
                Logger.LogExceptionToFile(ex, "JSON Parser");
            }
            if (saveObjects)
            {
                try
                {
                    MainForm.InstanceReference.SaveObjectList(false);
                }
                catch (Exception ex)
                {
                    Logger.LogExceptionToFile(ex, "JSON Parser");
                }
            }

            SendHeader(sHttpVersion, "application/json", resp.Length, " 200 OK", 0, ref req);
            SendToBrowser(resp, req);
        }
예제 #6
0
        public static string AlertSummary(objectsActionsEntry e)
        {
            string t = "Unknown";
            bool   b;

            switch (e.type.ToUpperInvariant())
            {
            case "EXE":
                t = LocRm.GetString("ExecuteFile") + ": " + e.param1;
                break;

            case "URL":
                t = LocRm.GetString("CallURL") + ": " + e.param1;
                Boolean.TryParse(e.param2, out b);
                if (b)
                {
                    t += " (POST grab)";
                }
                break;

            case "NM":
                t = e.param1 + " " + e.param2 + ":" + e.param3 + " (" + e.param4 + ")";
                break;

            case "S":
                t = LocRm.GetString("PlaySound") + ": " + e.param1;
                break;

            case "ATC":
                t = LocRm.GetString("SoundThroughCamera") + ": " + e.param1;
                break;

            case "SW":
                t = LocRm.GetString("ShowWindow");
                break;

            case "B":
                t = LocRm.GetString("Beep");
                break;

            case "M":
                t = LocRm.GetString("Maximise");
                break;

            case "MO":
                t = LocRm.GetString("SwitchMonitorOn");
                break;

            case "TA":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id = Convert.ToInt32(op[1]);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("TriggerAlertOn") + " " + n;
            }
            break;

            case "SOO":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id = Convert.ToInt32(op[1]);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("SwitchObjectOn") + " " + n;
            }
            break;

            case "SOF":
            {
                string[] op = e.param1.Split(',');
                string   n  = "[removed]";
                int      id;
                int.TryParse(op[1], out id);
                switch (op[0])
                {
                case "1":
                    objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                    if (om != null)
                    {
                        n = om.name;
                    }
                    break;

                case "2":
                    objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                    if (oc != null)
                    {
                        n = oc.name;
                    }
                    break;
                }
                t = LocRm.GetString("SwitchObjectOff") + " " + n;
            }
            break;

            case "E":
                t = LocRm.GetString("SendEmail") + ": " + e.param1;
                if (e.param2 != "")
                {
                    bool.TryParse(e.param2, out b);
                    if (b)
                    {
                        t += " (include grab)";
                    }
                }

                break;

            case "SMS":
                t = LocRm.GetString("SendSMS") + ": " + e.param1;
                break;

            case "TM":
                t = LocRm.GetString("SendTwitterMessage");
                break;
            }

            return(t);
        }
예제 #7
0
 public ActionEntry(objectsActionsEntry e) => OAE = e;
예제 #8
0
파일: Helper.cs 프로젝트: dberliner/iSpy
        public static string AlertSummary(objectsActionsEntry e)
        {
            string t = "Unknown";
            bool b;
            switch (e.type.ToUpperInvariant())
            {
                case "EXE":
                    t = LocRm.GetString("ExecuteFile") + ": " + e.param1;
                    break;
                case "URL":
                    t = LocRm.GetString("CallURL") + ": " + e.param1;
                    Boolean.TryParse(e.param2, out b);
                    if (b)
                        t += " (POST grab)";
                    break;
                case "NM":
                    t = e.param1 + " " + e.param2 + ":" + e.param3 + " (" + e.param4 + ")";
                    break;
                case "S":
                    t = LocRm.GetString("PlaySound") + ": " + e.param1;
                    break;
                case "ATC":
                    t = LocRm.GetString("SoundThroughCamera") + ": " + e.param1;
                    break;
                case "SW":
                    t = LocRm.GetString("ShowWindow");
                    break;
                case "B":
                    t = LocRm.GetString("Beep");
                    break;
                case "M":
                    t = LocRm.GetString("Maximise");
                    break;
                case "MO":
                    t = LocRm.GetString("SwitchMonitorOn");
                    break;
                case "TA":
                    {
                        string[] op = e.param1.Split(',');
                        string n = "[removed]";
                        int id = Convert.ToInt32(op[1]);
                        switch (op[0])
                        {
                            case "1":
                                objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                                if (om != null)
                                    n = om.name;
                                break;
                            case "2":
                                objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                                if (oc != null)
                                    n = oc.name;
                                break;
                        }
                        t = LocRm.GetString("TriggerAlertOn") + " " + n;
                    }
                    break;
                case "SOO":
                    {
                        string[] op = e.param1.Split(',');
                        string n = "[removed]";
                        int id = Convert.ToInt32(op[1]);
                        switch (op[0])
                        {
                            case "1":
                                objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                                if (om != null)
                                    n = om.name;
                                break;
                            case "2":
                                objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                                if (oc != null)
                                    n = oc.name;
                                break;
                        }
                        t = LocRm.GetString("SwitchObjectOn") + " " + n;
                    }
                    break;
                case "SOF":
                    {
                        string[] op = e.param1.Split(',');
                        string n = "[removed]";
                        int id;
                        int.TryParse(op[1], out id);
                        switch (op[0])
                        {
                            case "1":
                                objectsMicrophone om = MainForm.Microphones.FirstOrDefault(p => p.id == id);
                                if (om != null)
                                    n = om.name;
                                break;
                            case "2":
                                objectsCamera oc = MainForm.Cameras.FirstOrDefault(p => p.id == id);
                                if (oc != null)
                                    n = oc.name;
                                break;
                        }
                        t = LocRm.GetString("SwitchObjectOff") + " " + n;
                    }
                    break;
                case "E":
                    t = LocRm.GetString("SendEmail") + ": " + e.param1;
                    if (e.param2 != "")
                    {
                        bool.TryParse(e.param2, out b);
                        if (b)
                            t += " (include grab)";
                    }

                    break;
                case "SMS":
                    t = LocRm.GetString("SendSMS") + ": " + e.param1;
                    break;
                case "TM":
                    t = LocRm.GetString("SendTwitterMessage");
                    break;
            }

            return t;
        }
예제 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ddlAction.SelectedIndex < 1)
            {
                MessageBox.Show(this, LocRm.GetString("SelectAnActionToAdd"));
                return;
            }
            var oa = (ListItem) ddlAction.SelectedItem;

            if (!MainForm.Conf.Subscribed && oa.Restricted)
            {
                LoginRequested?.Invoke(this, EventArgs.Empty);
                return;
            }
            bool cancel;
            string[] config = GetConfig("", "", "", "", oa.Value, out cancel);
            if (cancel)
                return;

            var oae = new objectsActionsEntry
                      {
                                mode=Mode,
                                objectid = Oid,
                                objecttypeid = Otid,
                                type = oa.Value,
                                param1 = config[0],
                                param2 = config[1],
                                param3 = config[2],
                                param4 = config[3]
                            };
            MainForm.Actions.Add(oae);
            RenderEventList();
        }
예제 #10
0
파일: ActionEditor.cs 프로젝트: jjmata/iSpy
 public ActionEntry(objectsActionsEntry e)
 {
     OAE = e;
 }
예제 #11
0
 private void CopyActions(int OID, int oid, int otid, string mode)
 {
     MainForm.Actions.RemoveAll(p => p.objectid == oid && p.objecttypeid == otid && p.mode==mode);
     var l = MainForm.Actions.Where(p => p.objectid == OID && p.objecttypeid == otid && p.mode==mode).ToList();
     foreach (var oa in l)
     {
         var oae = new objectsActionsEntry
         {
             mode = mode,
             objectid = oid,
             objecttypeid = otid,
             type = oa.type,
             param1 = oa.param1,
             param2 = oa.param2,
             param3 = oa.param3,
             param4 = oa.param4
         };
         MainForm.Actions.Add(oae);
     }
 }