Пример #1
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            ContentControl path    = (cmbPath.SelectedItem as ContentControl);
            string         pathStr = path != null ? (path.Tag as string) : cmbPath.Text;

            if (radProgram.IsChecked == true)
            {
                ID = ProgramID.NewProgID(pathStr);
            }
            else if (radService.IsChecked == true)
            {
                ServiceModel.Service svc = (cmbService.SelectedItem as ServiceModel.Service);
                ID = ProgramID.NewSvcID(svc != null ? svc.Value : cmbService.Text, pathStr);
            }
            else if (radApp.IsChecked == true)
            {
                AppModel.AppPkg name = (cmbApp.SelectedItem as AppModel.AppPkg);
                ID = ProgramID.NewAppID(name != null ? name.Value : cmbApp.Text, pathStr);
            }
            else
            {
                ID = ProgramID.NewID(ProgramID.Types.Global);
            }

            this.DialogResult = true;
        }
Пример #2
0
    protected void btnDelete_Click(Object sender, EventArgs e)
    {
        try
        {
            if (!String.IsNullOrEmpty(AssociateOfferID))
            {
                DisplayError(PhraseLib.Lookup("tcpedit.programused", LanguageID));
                return;
            }

            tcpService         = CurrentRequest.Resolver.Resolve <ITrackableCouponProgramService>();
            activityLogService = CurrentRequest.Resolver.Resolve <IActivityLogService>();
            AMSResult <bool> retVal = tcpService.DeleteTrackableCouponProgram(Convert.ToInt32(ProgramID));
            if (retVal.ResultType != AMSResultType.Success)
            {
                DisplayError(retVal.GetLocalizedMessage <bool>(LanguageID));
            }
            else
            {
                activityLogService.Activity_Log(ActivityTypes.TCProgram, ProgramID.ConvertToInt32(), CurrentUser.AdminUser.ID, String.Concat(PhraseLib.Lookup("term.trackablecouponprogram", LanguageID), " ", PhraseLib.Lookup("term.deleted", LanguageID)));
                Response.Redirect("~/logix/tcp-list.aspx", false);
            }
        }
        catch (Exception ex)
        {
            DisplayError(ErrorHandler.ProcessError(ex));
        }
    }
Пример #3
0
        private void PopEntry()
        {
            if (curIndex == -1)
            {
                return;
            }
            ProgramID id = mEventList.ElementAt(curIndex);

            mEventList.RemoveAt(curIndex);
            mEvents.Remove(id);

            if (curIndex >= mEventList.Count)
            {
                curIndex = mEventList.Count - 1;
            }
            if (curIndex < 0)
            {
                //btnIgnore.IsEnabled = false;
                IgnoreSB.IsEnabled = false;
                consGrid.Items.Clear();
                curIndex = -1;
                Emptied?.Invoke(this, new EventArgs());
                return;
            }

            UpdateIndex();
            LoadCurrent();
        }
Пример #4
0
        private void cmbProgram_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ContentControl program = (cmbProgram.SelectedItem as ContentControl);

            if (program == null)
            {
                return;
            }

            ProgramID id = (program.Tag as ProgramID);

            txtPath.Text = id.Path;
            switch (id.Type)
            {
            case ProgramID.Types.Service:
                txtService.Text = id.GetServiceName() + " (" + id.GetServiceId() + ")";
                break;

            case ProgramID.Types.App:
                txtApp.Text = id.GetPackageName();
                break;
            }
            txtService.IsEnabled = id.Type == ProgramID.Types.Service;
            txtApp.IsEnabled     = id.Type == ProgramID.Types.App;
        }
Пример #5
0
        private void cmbProgram_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ContentControl program = (cmbProgram.SelectedItem as ContentControl);

            if (program == null)
            {
                return;
            }

            ProgIDChanged = true;

            ProgramID id = (program.Tag as ProgramID);

            txtPath.Text = id.Path;
            switch (id.Type)
            {
            case ProgramID.Types.Service:
                txtService.Text = id.GetServiceId();
                break;

            case ProgramID.Types.App:
                string SID = id.GetPackageSID();
                txtApp.Text = SID != null?AppModel.GetInstance().GetAppPkgBySid(SID)?.ID ?? "" : "";

                break;
            }
            txtService.IsEnabled = id.Type == ProgramID.Types.Service;
            txtApp.IsEnabled     = id.Type == ProgramID.Types.App;
        }
Пример #6
0
 private void SetUpUserControls()
 {
     ucNotesUI.NoteType         = NoteTypes.TCProgram;
     ucNotesUI.LinkID           = ProgramID.ConvertToInt32();
     ucNotes_Popup.NoteType     = NoteTypes.TCProgram;
     ucNotes_Popup.LinkID       = ProgramID.ConvertToInt32();;
     ucNotes_Popup.ActivityType = ActivityTypes.TCProgram;
 }
Пример #7
0
        public void UpdateConnections(bool clear = false)
        {
            if (firewallPage == null)
            {
                return;
            }

            if (clear)
            {
                LogList.Clear();
            }

            Dictionary <Guid, LogItem> oldLog = new Dictionary <Guid, LogItem>();

            foreach (LogItem oldItem in LogList)
            {
                oldLog.Add(oldItem.entry.guid, oldItem);
            }

            Dictionary <Guid, List <Program.LogEntry> > entries = App.client.GetConnections(firewallPage.GetCurGuids());

            foreach (var entrySet in entries)
            {
                ProgramSet prog = firewallPage.GetProgSet(entrySet.Key);
                if (prog == null)
                {
                    continue;
                }

                foreach (Program.LogEntry entry in entrySet.Value)
                {
                    //if (!TestEntry(prog, entry))
                    //    continue;

                    //LogItem Item;
                    //if (!oldLog.TryGetValue(entry.guid, out Item))
                    if (!oldLog.Remove(entry.guid))
                    {
                        Program program = ProgramID.GetProgramFuzzy(prog.Programs, entry.ProgID, ProgramID.FuzzyModes.Any);

                        LogList.Insert(0, new LogItem(entry, program != null ? program.Description : prog.config.Name));
                    }

                    /*else
                     * {
                     *  oldLog.Remove(entry.guid);
                     *  Item.Update(entry);
                     * }*/
                }
            }

            foreach (LogItem item in oldLog.Values)
            {
                LogList.Remove(item);
            }
        }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            (this.Master as logix_LogixMasterPage).Tab_Name            = "5_3_2";
            (this.Master as logix_LogixMasterPage).OnOverridePageMenu += new logix_LogixMasterPage.OverridePageMenu(logix_tcp_edit_OnOverridePageMenu);

            btnDelete.Attributes.Add("onclick", "return confirm('" + PhraseLib.Lookup("term.confirmdeleteprogram", LanguageID) + "')");
            if (!Page.IsPostBack)
            {
                //CSRF CODE ENDS

                //Set Anti-XSRF token
                ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey;

                //If a user name is assigned, set the user name
                ViewState[AntiXsrfUserNameKey] =
                    Context.User.Identity.Name ?? String.Empty;

                //CSRF CODE ENDS

                TrackableCouponProgram tcProgram = VerifyPageUrl();
                FillPageControlText(tcProgram);
                AssignPageTitle("term.trackablecouponprogram", String.Empty, ProgramID.ToString());
                ApplyPermission();
                if (SystemCacheData.GetSystemOption_UE_ByOptionId(152) == "0")
                {
                    lblCouponusCount.Visible = false;
                    CouponCount.Visible      = false;
                }
            }
            else
            {
                //Validate the Anti-XSRF token
                if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue || (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty))
                {
                    throw new InvalidOperationException("Validation of Anti - XSRF token failed.");
                }
            }
            ucNotes_Popup.NotesUpdate += new EventHandler(ucNotes_Popup_NotesUpdate);
            SetUpUserControls();
            txtName.Focus();
        }
        catch (Exception ex)
        {
            DisplayError(ErrorHandler.ProcessError(ex));
        }
    }
Пример #9
0
        private void consGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ConEntry entry = (ConEntry)consGrid.SelectedItem;

            if (entry == null)
            {
                return;
            }

            ProgramID id = mEventList.ElementAt(curIndex);
            Tuple <Program, List <Engine.FwEventArgs> > list = mEvents[id];

            UInt64 expiration = GetExpiration();

            if (MakeCustom(list.Item1, expiration, entry))
            {
                PopEntry();
            }
        }
Пример #10
0
        private void btnApply_Click(object sender, RoutedEventArgs e)
        {
            ProgramID id = mEventList.ElementAt(curIndex);
            Tuple <Program, List <Engine.FwEventArgs> > list = mEvents[id];

            UInt64 expiration = GetExpiration();

            ProgramSet.Config.AccessLevels NetAccess = (ProgramSet.Config.AccessLevels)(cmbAccess.SelectedItem as ComboBoxItem).Tag;

            if (NetAccess == ProgramSet.Config.AccessLevels.CustomConfig)
            {
                if (!MakeCustom(list.Item1, expiration))
                {
                    return;
                }
            }
            else
            {
                ProgramSet prog = App.client.GetProgram(id);

                if (NetAccess == ProgramSet.Config.AccessLevels.StopNotify)
                {
                    if (expiration != 0)
                    {
                        prog.config.SilenceUntill = expiration;
                    }
                    else
                    {
                        prog.config.Notify = false;
                    }

                    App.client.UpdateProgram(prog.guid, prog.config);
                }
                else
                {
                    prog.config.NetAccess = NetAccess;

                    App.client.UpdateProgram(prog.guid, prog.config, expiration);
                }
            }
            PopEntry();
        }
Пример #11
0
        private void PopEntry()
        {
            ProgramID id = mEventList.ElementAt(curIndex);

            mEventList.RemoveAt(curIndex);
            mEvents.Remove(id);

            if (curIndex >= mEventList.Count)
            {
                curIndex = mEventList.Count - 1;
            }
            if (curIndex < 0)
            {
                curIndex = -1;
                this.Close();
                return;
            }

            UpdateIndex();
            LoadCurrent();
        }
Пример #12
0
        public ProgramWnd(ProgramID id)
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_program");

            this.grpProgram.Header  = Translate.fmt("lbl_program");
            this.radProgram.Content = Translate.fmt("lbl_exe");
            this.radService.Content = Translate.fmt("lbl_svc");
            this.radApp.Content     = Translate.fmt("lbl_app");

            this.btnOK.Content     = Translate.fmt("lbl_ok");
            this.btnCancel.Content = Translate.fmt("lbl_cancel");

            ID = id;

            SuspendChange++;

            Paths = new ObservableCollection <PathEntry>();

            ListCollectionView lcv = new ListCollectionView(Paths);

            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            cmbPath.ItemsSource = lcv;

            Paths.Add(new PathEntry()
            {
                Content = Translate.fmt("pro_browse"), Tag = "*", Group = Translate.fmt("lbl_selec")
            });
            PathEntry itemAll = new PathEntry()
            {
                Content = Translate.fmt("pro_all"), Tag = null, Group = Translate.fmt("lbl_selec")
            };

            Paths.Add(itemAll);

            if (ID != null && ID.Path.Length > 0)
            {
                PathEntry itemPath;
                if (ID.Path.Equals("system"))
                {
                    itemPath = new PathEntry()
                    {
                        Content = Translate.fmt("pro_sys"), Tag = ID.Path, Group = Translate.fmt("lbl_selec")
                    }
                }
                ;
                else
                {
                    itemPath = new PathEntry()
                    {
                        Content = ID.Path, Tag = ID.Path, Group = Translate.fmt("lbl_known")
                    }
                };
                Paths.Add(itemPath);
                cmbPath.SelectedItem = itemPath;
            }
            else
            {
                cmbPath.SelectedItem = itemAll;
            }

            //if (ID != null &&  ((ID.Path.Length == 0 && ID.Name.Length == 0) || ID.Path.Equals("system")))
            if (ID != null)
            {
                radProgram.IsEnabled = false;
                radService.IsEnabled = false;
                radApp.IsEnabled     = false;

                cmbPath.IsEnabled    = false;
                cmbService.IsEnabled = false;
                cmbApp.IsEnabled     = false;
            }

            cmbService.ItemsSource = ServiceModel.GetInstance().GetServices();
            cmbApp.ItemsSource     = AppModel.GetInstance().GetApps();

            if (ID == null)
            {
                radProgram.IsChecked = true;
                //ID = ProgramID.NewID(ProgramID.Types.Program);
            }
            else
            {
                switch (ID.Type)
                {
                case ProgramID.Types.Program:
                    radProgram.IsChecked = true;
                    cmbPath.Text         = ID.GetPath();
                    break;

                case ProgramID.Types.Service:
                    radService.IsChecked = true;
                    foreach (ServiceModel.Service service in cmbService.Items)
                    {
                        if (MiscFunc.StrCmp(service.Value, ID.GetServiceId()))
                        {
                            cmbService.SelectedItem = service;
                            break;
                        }
                    }
                    if (cmbService.SelectedItem == null)
                    {
                        cmbService.Text = ID.GetServiceId();
                    }
                    break;

                case ProgramID.Types.App:
                    radApp.IsChecked = true;
                    foreach (AppModel.AppPkg app in cmbApp.Items)
                    {
                        if (MiscFunc.StrCmp(app.Value, ID.GetPackageSID()))
                        {
                            cmbApp.SelectedItem = app;
                            break;
                        }
                    }
                    if (cmbApp.SelectedItem == null)
                    {
                        cmbApp.Text = ID.GetPackageSID();
                    }
                    break;
                }
            }

            if (UwpFunc.IsWindows7OrLower)
            {
                radApp.IsEnabled = false;
                cmbApp.IsEnabled = false;
            }

            SuspendChange--;
        }
Пример #13
0
        private void LoadCurrent(bool bUpdate = false)
        {
            if (!bUpdate)
            {
                ProgramSet.Config.AccessLevels NetAccess = ProgramSet.Config.AccessLevels.Unconfigured;

                cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess);
                WpfFunc.CmbSelect(cmbAccess, NetAccess.ToString());
            }

            btnApply.IsEnabled = false;

            ProgramID id = mEventList.ElementAt(curIndex);
            Tuple <Program, List <Engine.FwEventArgs> > list = mEvents[id];

            //int PID = list.Item2.Count > 0 ? list.Item2.First().FwEvent.ProcessId : 0;
            string FilePath = list.Item2.Count > 0 ? list.Item2.First().entry.FwEvent.ProcessFileName : "";

            imgIcon.Source = ImgFunc.GetIcon(FilePath, imgIcon.Width); // todo: use .progSet.GetIcon instead?
            //lblName.Text = id.GetDisplayName(false);
            grpBox.Header = list.Item1.Description;
            //lblPID.Text = string.Format("{0} ({1})", System.IO.Path.GetFileName(id.Path), PID);
            lblPID.Text = System.IO.Path.GetFileName(id.Path);

            List <string> services = new List <string>();

            consGrid.Items.Clear();
            foreach (Engine.FwEventArgs args in list.Item2)
            {
                consGrid.Items.Insert(0, new ConEntry(args.entry));

                if (args.services != null)
                {
                    foreach (var service in args.services)
                    {
                        if (!services.Contains(service))
                        {
                            services.Add(service);
                        }
                    }
                }
            }

            if (services.Count > 0)
            {
                cmbService.Visibility = Visibility.Visible;
                cmbService.Items.Clear();
                foreach (var service in services)
                {
                    cmbService.Items.Add(service);
                }
                cmbService.SelectedIndex = -1;
                cmbService.Text          = Translate.fmt("msg_pick_svc");
            }
            else
            {
                cmbService.Visibility = Visibility.Collapsed;
                switch (id.Type)
                {
                //case ProgramList.Types.Program: lblSubName.Text = ""; break;
                case ProgramID.Types.Service: lblSubName.Text = id.GetServiceId(); break;

                case ProgramID.Types.App: lblSubName.Text = id.GetPackageName(); break;

                default: lblSubName.Text = ""; break;
                }
            }
            lblPath.Text = id.Path;
        }
Пример #14
0
        public void Add(ProgramSet progs, Engine.FwEventArgs args)
        {
            ProgramID id   = args.entry.ProgID;
            Program   prog = null;

            if (!progs.Programs.TryGetValue(id, out prog))
            {
                return;
            }

            Tuple <Program, List <Engine.FwEventArgs> > list;

            if (!mEvents.TryGetValue(id, out list))
            {
                if (args.update)
                {
                    return;
                }

                list = new Tuple <Program, List <Engine.FwEventArgs> >(prog, new List <Engine.FwEventArgs>());
                mEvents.Add(id, list);
                mEventList.Add(id);
            }

            if (args.update)
            {
                foreach (var oldEntry in list.Item2)
                {
                    if (oldEntry.entry.guid.Equals(args.entry.guid))
                    {
                        oldEntry.entry.Update(args.entry);
                        break;
                    }
                }
            }
            else
            {
                list.Item2.Add(args);
            }

            int oldIndex = curIndex;

            if (curIndex < 0)
            {
                curIndex = 0;
            }
            else if (curIndex >= mEventList.Count)
            {
                curIndex = mEventList.Count - 1;
            }

            UpdateIndex();

            // don't update if the event is for a different entry
            int index = mEventList.FindIndex((x) => { return(id.CompareTo(x) == 0); });

            if (curIndex != index)
            {
                return;
            }

            LoadCurrent(oldIndex == curIndex);
        }
Пример #15
0
        public void UpdateDnsLog(bool clear = false)
        {
            if (firewallPage == null)
            {
                return;
            }

            if (clear)
            {
                LogList.Clear();
            }

            Dictionary <Guid, DnsItem> oldLog = new Dictionary <Guid, DnsItem>();

            foreach (DnsItem oldItem in LogList)
            {
                oldLog.Add(oldItem.entry.guid, oldItem);
            }

            Dictionary <Guid, List <Program.DnsEntry> > entries = App.client.GetDomains(firewallPage.GetCurGuids());

            foreach (var entrySet in entries)
            {
                ProgramSet prog = firewallPage.GetProgSet(entrySet.Key);
                if (prog == null)
                {
                    continue;
                }

                foreach (Program.DnsEntry logEntry in entrySet.Value)
                {
                    DnsItem entry = null;
                    if (!oldLog.TryGetValue(logEntry.guid, out entry))
                    {
                        oldLog.Remove(logEntry.guid);

                        Program program = ProgramID.GetProgramFuzzy(prog.Programs, logEntry.ProgID, ProgramID.FuzzyModes.Any);

                        LogList.Insert(0, new DnsItem(logEntry, program != null ? program.Description : prog.config.Name));
                    }
                    else // update entry
                    {
                        oldLog.Remove(logEntry.guid);
                        entry.Update(logEntry);
                    }
                }
            }

            foreach (DnsItem item in oldLog.Values)
            {
                LogList.Remove(item);
            }

            // force sort
            // todo: improve that

            /*if (sockGrid.Items.SortDescriptions.Count > 0)
             * {
             *  sockGrid.Items.SortDescriptions.Insert(0, sockGrid.Items.SortDescriptions.First());
             *  sockGrid.Items.SortDescriptions.RemoveAt(0);
             * }*/
        }
Пример #16
0
        public void UpdateSockets(bool clear = false)
        {
            if (firewallPage == null)
            {
                return;
            }

            if (clear)
            {
                SocketList.Clear();
            }

            Dictionary <Guid, SocketItem> oldLog = new Dictionary <Guid, SocketItem>();

            foreach (SocketItem oldItem in SocketList)
            {
                oldLog.Add(oldItem.sock.guid, oldItem);
            }

            Dictionary <Guid, List <NetworkSocket> > entries = App.client.GetSockets(firewallPage.GetCurGuids());

            foreach (var entrySet in entries)
            {
                ProgramSet prog = firewallPage.GetProgSet(entrySet.Key);
                if (prog == null)
                {
                    continue;
                }

                foreach (NetworkSocket socket in entrySet.Value)
                {
                    SocketItem entry = null;
                    if (!oldLog.TryGetValue(socket.guid, out entry))
                    {
                        oldLog.Remove(socket.guid);

                        Program program = ProgramID.GetProgramFuzzy(prog.Programs, socket.ProgID, ProgramID.FuzzyModes.Any);

                        SocketList.Insert(0, new SocketItem(socket, program != null ? program.Description : prog.config.Name));
                    }
                    else // update entry
                    {
                        oldLog.Remove(socket.guid);
                        entry.Update(socket);
                    }
                }
            }

            foreach (SocketItem item in oldLog.Values)
            {
                SocketList.Remove(item);
            }


            // force sort
            // todo: improve that

            /*if (socksGrid.Items.SortDescriptions.Count > 0)
             * {
             *  socksGrid.Items.SortDescriptions.Insert(0, socksGrid.Items.SortDescriptions.First());
             *  socksGrid.Items.SortDescriptions.RemoveAt(0);
             * }*/
        }