示例#1
0
 public static void DisposeApp()
 {
     AppLogger.CloseLogfiles();
     AppLogger = null;
     Logger.CloseLogfiles();
     Logger = null;
     FormatWriter.dispose();
 }
示例#2
0
 static AppGlobal()
 {
     AppLogger = new AppLog();
     Logger = new AppErrorLog();
     FormatWriter = new LogFormatter(ref Logger);
     AppLogger.GenerateLogfiles(Application.StartupPath + "\\" + Application.ProductName + "\\ApplicationLog", "Trace_" + Application.ProductName);
     Logger.GenerateLogfiles(Application.StartupPath + "\\" + Application.ProductName + "\\ApplicationLog", Application.ProductName);
 }
示例#3
0
        public void test3()
        {
            Type t = typeof(MyClass);                       //获取描述MyClass类型的Type对象

            AppLog.Error("Analyzing methods in " + t.Name); //t.Name="MyClass"

            //两种不同的获取方式
            //MethodInfo[] mi = t.GetMethods();  //MethodInfo对象在System.Reflection命名空间下。
            MethodInfo[] mi = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); //不获取继承方法,为实例方法,为公开的

            foreach (MethodInfo m in mi)                                                                             //遍历mi对象数组
            {
                AppLog.Error(m.ReturnType.Name);                                                                     //返回方法的返回类型
                AppLog.Error(m.Name);                                                                                //返回方法的名称

                ParameterInfo[] pi = m.GetParameters();                                                              //获取方法参数列表并保存在ParameterInfo对象数组中
                for (int i = 0; i < pi.Length; i++)
                {
                    AppLog.Error(pi[i].ParameterType.Name); //方法的参数类型名称
                    AppLog.Error(pi[i].Name);               // 方法的参数名
                }
            }
        }
示例#4
0
    public static string SID_SPLevel        = "S-1-16-28672"; //	Secure Process Mandatory Level

    internal static bool TakeOwn(string path)
    {
        bool ret = true;

        try
        {
            TokenManipulator.AddPrivilege(TokenManipulator.SE_TAKE_OWNERSHIP_NAME);

            FileSecurity ac = File.GetAccessControl(path);
            ac.SetOwner(new SecurityIdentifier(FileOps.SID_Admins));
            File.SetAccessControl(path, ac);
        }
        catch (PrivilegeNotHeldException err)
        {
            AppLog.Line("Couldn't take Ovnership {0}", err.ToString());
            ret = false;
        }
        finally
        {
            TokenManipulator.RemovePrivilege(TokenManipulator.SE_TAKE_OWNERSHIP_NAME);
        }
        return(ret);
    }
示例#5
0
        public List <byte[]> RemoteExec(string func, List <byte[]> args)
        {
            List <byte[]> ret = null;

#if !DEBUG
            try
#endif
            {
                if (clientPipe == null) // && Connect(3000, true) == 0)
                {
                    throw new Exception("Not Connected");
                }

                ret = clientPipe.RemoteExec(func, args);
            }
#if !DEBUG
            catch (Exception err)
            {
                AppLog.Exception(err);
            }
#endif
            return(ret);
        }
示例#6
0
    public static T FindChild<T>(DependencyObject parentObj) where T : DependencyObject
    {
        if (parentObj == null)
            return null;

        try
        {
            if (parentObj is T)
                return parentObj as T;

            for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(parentObj); i++)
            {
                T childObj = FindChild<T>(System.Windows.Media.VisualTreeHelper.GetChild(parentObj, i));
                if (childObj != null)
                    return childObj;
            }
        }
        catch (Exception err)
        {
            AppLog.Exception(err);
        }
        return null;
    }
示例#7
0
        internal void SetRecordTransmitted(BinaryWriter writer)
        {
            try
            {
                Transmitted = true;

                if (QueueFilePosition != -1)
                {
                    long curPos = writer.BaseStream.Position;
                    if (writer.BaseStream.Seek(QueueFilePosition, SeekOrigin.Begin) == QueueFilePosition)
                    {
                        writer.Write(Transmitted);
                        writer.BaseStream.Seek(curPos, SeekOrigin.Begin);
                    }

                    writer.Flush();
                }
            }
            catch (Exception e)
            {
                AppLog.Error(e);
            }
        }
        public ActionResult Entry(EntryModel model)
        {
            try
            {
                if (CheckModelIsValid(model))
                {
                    //string gridHidStr = model.EntryGridId + model.PageId + AppMember.HideString;
                    //Dictionary<string, object> objs = new Dictionary<string, object>();
                    //objs.Add("fiscalYearId", model.FiscalYearId);
                    //objs.Add("fiscalPeriodId", model.FiscalPeriodId);
                    //objs.Add("gridData", Request.Form[gridHidStr]);

                    Update(Repository, model, model.ViewTitle);
                }
                model.EntryGridLayout = EntryGridLayout();
                return(View(model));
            }
            catch (Exception ex)
            {
                AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsDepreciationController.Entry post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
            }
        }
示例#9
0
 public ActionResult UpLoad(EntryModel model)
 {
     try
     {
         PDACheck pdachk = new PDACheck();
         try
         {
             pdachk.UpLoad(model.UpLoadFileName);
             model.HasError = "false";
         }
         catch (Exception ex)
         {
             model.HasError = "true";
             model.Message  = ex.Message;
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsCheckController.UpLoad post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
示例#10
0
        static public bool IsTaskEnabled(string path, string name)
        {
            if (name == "*")
            {
                List <string> names = EnumTasks(path);
                if (names == null)
                {
                    return(true); // we dont know so just in case
                }
                foreach (string found in names)
                {
                    if (IsTaskEnabled(path, found))
                    {
                        return(true);
                    }
                }
                return(false);
            }

            try
            {
                TaskScheduler.TaskScheduler service = new TaskScheduler.TaskScheduler();
                service.Connect();
                ITaskFolder     folder = service.GetFolder(path);
                IRegisteredTask task   = folder.GetTask(name);
                return(task.Enabled);
            }
            catch (FileNotFoundException)
            {
                return(false);
            }
            catch (Exception err)
            {
                AppLog.Exception(err);
            }
            return(true); // we dont know so just in case
        }
示例#11
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
            // NLogを設定する
            AppLog.LoadConfiguration(NLogConfig);

            try
            {
                this.Logger.Trace("begin.");

                // バージョンを出力する
                this.Logger.Info($"{EnvironmentHelper.GetProductName()} {EnvironmentHelper.GetVersion().ToStringShort()}");

                // サーバを開始する
                RemoteTTSServer.Instance.Open();

                // Boyomiサーバーを開始する
                if (Config.Instance.IsBoyomiServerAutoStart)
                {
                    BoyomiTcpServer.Instance.Start(Config.Instance.BoyomiServerPortNo);
                }

                // シャットダウンタイマーをセットする
                this.shutdownTimer.Tick -= this.ShutdownTimerOnTick;
                this.shutdownTimer.Tick += this.ShutdownTimerOnTick;
                this.shutdownTimer.Start();
            }
            catch (Exception ex)
            {
                var message = "App initialize error";
                this.Logger.Fatal(ex, message);
                ShowMessageBoxException(message, ex);
            }
            finally
            {
                this.Logger.Trace("end.");
            }
        }
示例#12
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            HttpHelper helper = new HttpHelper();
            string     url    = ConfigFile.ReadConfig("Car", "FromCity");
            HttpItem   item   = GetHttpItem(url, "", "utf-8");
            HttpResult result = helper.GetHtml(item);

            // AppLog.Write("httpResult2:" + result.Html, AppLog.LogMessageType.Info);

            if (result.StatusCode == HttpStatusCode.OK)
            {
                string json = PubFun.Decrypt(result.Html);//, ConfigFile.ReadConfig("AppData", "DesKey"));
                AppLog.Write("json:" + json, AppLog.LogMessageType.Info);
                _carEntity._querySetOutResponse = PubFun.GetJsonObject <QuerySetOutResponse>(json);
                if (_carEntity._querySetOutResponse != null)
                {
                    if (string.IsNullOrEmpty(_carEntity._querySetOutResponse.ErrorCode))
                    {
                        e.Cancel = false;
                    }
                    else
                    {
                        ShowMessageAndGoBack(_carEntity._querySetOutResponse.ErrorCode + ":" + _carEntity._querySetOutResponse.Msg);
                        e.Cancel = false;
                        e.Result = new object();
                    }
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
示例#13
0
        public void EndPlugin()
        {
            try
            {
                EnvironmentHelper.GarbageLogs();
                this.Logger.Trace("start DeInitPlugin");

                // ターゲット情報ワーカを終了する
                MainWorker.Instance.End();

                // FFXIVプラグインへのアクセスを終了する
                FFXIVPlugin.Instance.End();
                EnmityPlugin.Free();
                FFXIVPlugin.Free();
                FFXIVReader.Free();

                // 設定ファイルを保存する
                Settings.Instance.Save();

                // 参照を開放する
                WavePlayer.Free();
                MainWorker.Free();
                Settings.Free();

                this.PluginStatusLabel.Text = "Plugin exited.";
                this.Logger.Trace("end DeInitPlugin. succeeded.");
            }
            catch (Exception ex)
            {
                this.Logger.Fatal(ex, "DeInitPlugin error.");
                this.ShowMessage("DeInitPlugin error.", ex);
            }
            finally
            {
                AppLog.FlushAll();
            }
        }
示例#14
0
 private void HandleDownloadActivity()
 {
     try
     {
         mshtml.HTMLDocument domDocument = (mshtml.HTMLDocument) this._webBrowser.Document;
         if (domDocument == null)
         {
             return;
         }
         if (_isLoading || _isLoaded)
         {
             return;
         }
         this._isLoading = true;
         if (domDocument.readyState == "complete")
         {
             DomDocumentCompleteHandler(domDocument);
         }
         else
         {
             DomEventHandler handler = null;
             handler = new DomEventHandler(delegate
             {
                 if (domDocument.readyState == "complete")
                 {
                     domDocument.detachEvent("onreadystatechange", handler);
                     DomDocumentCompleteHandler(domDocument);
                 }
             });
             domDocument.attachEvent("onreadystatechange", handler);
         }
     }
     catch (Exception ex)
     {
         AppLog.LogException(ex);
     }
 }
示例#15
0
        static public bool UnBlockFile(string path)
        {
            try
            {
                path = Environment.ExpandEnvironmentVariables(path);
                if (!FileOps.TakeOwn(path))
                {
                    return(false);
                }

                FileSecurity ac = File.GetAccessControl(path);
                AuthorizationRuleCollection rules = ac.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); // get as SID not string
                foreach (FileSystemAccessRule rule in rules)
                {
                    if (!rule.IdentityReference.ToString().Equals(FileOps.SID_World))
                    {
                        continue;
                    }
                    if (rule.FileSystemRights != FileSystemRights.ExecuteFile)
                    {
                        continue;
                    }
                    if (rule.AccessControlType != AccessControlType.Deny)
                    {
                        continue;
                    }
                    ac.RemoveAccessRule(rule);
                }
                File.SetAccessControl(path, ac);
                return(true);
            }
            catch (Exception err)
            {
                AppLog.Exception(err);
            }
            return(false);
        }
示例#16
0
        static public bool Install(bool start = false)
        {
            try
            {
                string binPathName = "\"" + App.appPath + "\\" + SvcBinary + "\" -svc";

                var svcConfigInfo = ServiceHelper.GetServiceInfoSafe(App.SvcName);
                if (svcConfigInfo != null)
                {
                    // Note: if teh service path is is wrong re-install the service
                    if (!svcConfigInfo.BinaryPathName.Equals(binPathName, StringComparison.OrdinalIgnoreCase))
                    {
                        Uninstall();
                        svcConfigInfo = null;
                    }
                }

                if (svcConfigInfo == null)
                {
                    ServiceHelper.Install(App.SvcName, App.Title, binPathName);
                }

                ServiceHelper.ChangeStartMode(App.SvcName, ServiceHelper.ServiceBootFlag.AutoStart);

                if (start)
                {
                    ServiceHelper.StartService(App.SvcName);
                }

                return(true);
            }
            catch (Exception err)
            {
                AppLog.Exception(err);
            }
            return(false);
        }
示例#17
0
        public ActionResult Entry(EntryModel model)
        {
            try
            {
                //if (CheckModelIsValid(model))
                //{
                //    Update(EntryRepository, model, model.FormMode, model.GroupId, model.ViewTitle);

                //}
                //return View(model);
                if (model.IsFixed == "Y")
                {
                    ModelState.AddModelError("GroupNo", AppMember.AppText["IsFixed"]);
                    return(View(model));
                }
                if (Update(Repository, model, model.GroupId) == 1)
                {
                    if (model.FormMode == "new")
                    {
                        return(View(model));
                    }
                    else
                    {
                        return(RedirectToAction("List", new { pageId = model.PageId, viewTitle = model.ViewTitle }));
                    }
                }
                else
                {
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "GroupController.Entry post", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
            }
        }
示例#18
0
        public void AddListener(string targetAddress)
        {
            if (!IsOpen)
            {
                throw new Exception("The Endpoint must have an a request processor set up via the Open method in order to receive messages on a listener.");
            }

            string t = targetAddress.ToUpper();

            if (listeners.ContainsKey(t))
            {
                throw new Exception("The specified targetAddress is already in use.");
            }

            Exception ex = null;

            Task.Run(() =>
            {
                try
                {
                    InternalMessageProcessor p = new InternalMessageProcessor(this, targetAddress);
                    inboundHost.RegisterMessageProcessor(targetAddress, p);
                    AppLog.Info($"Listener registered on {targetAddress}");
                    listeners[t] = p;
                }
                catch (Exception exception)
                {
                    ex = exception;
                    AppLog.Error(ex);
                }
            }).Wait();

            if (ex != null)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Invokes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="appLogger">Application logger instance</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public async Task Invoke(HttpContext context, IAppLogger appLogger, AppLog log)
        {
            if (IsAssetRequest(context.Request.Path.Value))
            {
                await _next(context);

                return;
            }
            var stopWatch = Stopwatch.StartNew();

            log.Request = GetBodyString(context.Request);
            var originalBodyStream = context.Response.Body;

            using (var responseBody = new MemoryStream())
            {
                context.Response.Body  = responseBody;
                log.ApplicationVersion = _settings.AppVersion;
                log.DeviceInfo         = context.Request.Headers["DeviceInfo"].FirstOrDefault();
                log.DeviceIP           = context.Request.Headers["DeviceIP"].FirstOrDefault();
                log.OSType             = context.Request.Headers["OSType"].FirstOrDefault();
                log.HostIP             = GetIpAddress();
                log.RequestMethod      = context.Request.Method;
                log.RequestURL         = context.Request.Path;
                log.RequestHeaders     = JsonConvert.SerializeObject(context.Request.Headers);
                await _next(context);

                var response = await FormatResponse(context.Response);

                log.HttpStatus   = context.Response.StatusCode;
                log.Response     = log.HttpStatus == 200 ? "Success" : response;
                log.ResponseTime = stopWatch.Elapsed.Milliseconds;
                context.Response.Headers.Add("Reference", log.ReferenceNumber.ToString());
                await appLogger.Commit(log);

                await responseBody.CopyToAsync(originalBodyStream);
            }
        }
示例#20
0
        private bool OpenWriter()
        {
            try
            {
                if (dataWriter == null)
                {
                    return(false);
                }

                // Validate File
                if (dataWriter.BaseStream.Length > 0)
                {
                    dataWriter.BaseStream.Seek(0, SeekOrigin.End);
                }
                else
                {
                    // Write Signature
                    dataWriter.Write(this.fileSignature);

                    // Write File Version
                    dataWriter.Write(this.fileVersion);

                    // Write the Cache Size
                    dataWriter.Write((int)0);

                    dataWriter.Flush();
                }

                return(true);
            }
            catch (Exception e)
            {
                AppLog.Error(e);
            }

            return(false);
        }
示例#21
0
 public ActionResult Select(string pageId, string showCheckbox, string selectVal, string fieldIdObj)
 {
     try
     {
         DropMultipleSelectModel model = new DropMultipleSelectModel();
         model.PageId     = pageId;
         model.TreeId     = TreeId.GroupTreeId;
         model.FieldIdObj = fieldIdObj;
         UserInfo        sysUser = CacheInit.GetUserInfo(HttpContext);
         GroupRepository grep    = new GroupRepository();
         model.DataTree = grep.GetGroupTree(sysUser);
         if (showCheckbox == "true")
         {
             model.ShowCheckBox = true;
         }
         model.PkId = selectVal;
         return(PartialView("DropMultipleSelect", model));
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "GroupController.Select", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(Content("[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace, "text/html"));
     }
 }
示例#22
0
            void IMessageProcessor.Process(MessageContext messageContext)
            {
                try
                {
                    List <CFXEnvelope> messages = AmqpUtilities.EnvelopesFromMessage(messageContext.Message);
                    if (messages != null && messages.Any())
                    {
                        foreach (CFXEnvelope message in messages)
                        {
                            parentProcessor.Fire_OnMessageReceivedFromListener(TargetAddress, message);
                        }
                    }
                    else
                    {
                        AppLog.Warn($"Undecodeable message received on listener {TargetAddress}");
                    }
                }
                catch (Exception ex)
                {
                    AppLog.Error(ex);
                }

                messageContext.Complete();
            }
示例#23
0
        public FilteringModes GetFilteringMode()
        {
            try
            {
                if (TestFirewallEnabled(true))
                {
                    if (TestDefaultOutboundAction(FirewallRule.Actions.Allow))
                    {
                        return(FilteringModes.BlackList);
                    }

                    if (TestDefaultOutboundAction(FirewallRule.Actions.Block))
                    {
                        return(FilteringModes.WhiteList);
                    }
                }
                return(FilteringModes.NoFiltering);
            }
            catch (Exception err)
            {
                AppLog.Exception(err);
            }
            return(FilteringModes.Unknown);
        }
示例#24
0
 public JsonResult GetDefaultByAssetsClass(string assetsClassId)
 {
     try
     {
         ClearClientPageCache(Response);
         DataRow          dr            = Repository.GetModel(assetsClassId);
         string           assetsClassNo = DataConvert.ToString(dr["assetsClassNo"]);
         AssetsRepository arep          = new AssetsRepository();
         var selectList = new
         {
             remainRate       = DataConvert.ToDouble(dr["RemainRate"]),
             durableYears     = DataConvert.ToInt32(dr["durableYears"]),
             unitId           = DataConvert.ToString(dr["unitId"]),
             depreciationType = DataConvert.ToString(dr["depreciationType"]),
             assetsBarcode    = arep.GetAssetsBarcode(assetsClassNo)
         };
         return(Json(selectList, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "AssetsClassController.GetDefaultByAssetsClass", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
         return(new JsonResult());
     }
 }
示例#25
0
 public Auditing GetAuditPolicy()
 {
     try
     {
         AuditPolicy.AUDIT_POLICY_INFORMATION pol = AuditPolicy.GetSystemPolicy(FirewallEventPolicyID);
         if ((pol.AuditingInformation & AuditPolicy.AUDIT_POLICY_INFORMATION_TYPE.Success) != 0 && (pol.AuditingInformation & AuditPolicy.AUDIT_POLICY_INFORMATION_TYPE.Failure) != 0)
         {
             return(Auditing.All);
         }
         if ((pol.AuditingInformation & AuditPolicy.AUDIT_POLICY_INFORMATION_TYPE.Success) != 0)
         {
             return(Auditing.Allowed);
         }
         if ((pol.AuditingInformation & AuditPolicy.AUDIT_POLICY_INFORMATION_TYPE.Failure) != 0)
         {
             return(Auditing.Blocked);
         }
     }
     catch (Exception err)
     {
         AppLog.Exception(err);
     }
     return(Auditing.Off);
 }
示例#26
0
        protected void Application_End(object sender, EventArgs e)
        {
            AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Debug, "AutoTask", string.Format(AppMember.AppText["AutoTaskEnd"]));
            Thread.Sleep(1000);
            ///下面的代码是关键,可解决IIS应用程序池自动回收的问题
            //这里设置你的web地址,可以随便指向你的任意一个aspx页面甚至不存在的页面,目的是要激发Application_Start
            //string url = HttpRuntime.AppDomainAppVirtualPath + "/Home/Error";
            //string s1=  RouteTable.Routes["Default"].GetRouteData;
            //string ss=UrlHelper.GenerateUrl("Default","Error","Home",null,RouteTable.Routes,app
            //string sss = Request.Path;
            //AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Debug, "AutoTask", sss);
            string hostUrl = ConfigurationManager.AppSettings["HostUrl"].ToString();

            if (!hostUrl.EndsWith("/"))
            {
                hostUrl = hostUrl + "/";
            }
            string url = hostUrl + "Home/Error";

            AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Debug, "AutoTask", url);
            HttpWebRequest  myHttpWebRequest  = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream          receiveStream     = myHttpWebResponse.GetResponseStream();//得到回写的字节流
        }
示例#27
0
 public static bool Exec(string cmd, string args, bool hidden = true)
 {
     try
     {
         Process process = new Process();
         process.StartInfo.UseShellExecute = false;
         if (hidden)
         {
             process.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
             process.StartInfo.CreateNoWindow = true;
         }
         process.StartInfo.FileName  = cmd;
         process.StartInfo.Arguments = args;
         process.StartInfo.Verb      = "runas"; // run as admin
         process.Start();
         process.WaitForExit();
         return(true);
     }
     catch (Exception err)
     {
         AppLog.Exception(err);
     }
     return(false);
 }
示例#28
0
        public JsonResult GridData(string filterString)
        {
            try
            {
                ListCondition condition = new ListCondition();
                condition.SortField    = DataConvert.ToString(Request.Form["sidx"]);
                condition.SortType     = DataConvert.ToString(Request.Params["sord"]);
                condition.PageIndex    = DataConvert.ToInt32(Request.Params["page"]);
                condition.PageRowNum   = DataConvert.ToInt32(Request.Params["rows"]);
                condition.FilterString = filterString;
                UserInfo sysUser = CacheInit.GetUserInfo(HttpContext);
                condition.SysUser = sysUser;
                //if (Request.Form.AllKeys.Contains("isQuery") && DataConvert.ToString(Request.Form["isQuery"]) == "true")
                //    condition.PageIndex = 1;
                if (Request.Form.AllKeys.Contains("formVar"))
                {
                    condition.ListModelString = DataConvert.ToString(Request.Form["formVar"]);
                }
                int cnt = ListRepository.GetGridDataCount(condition);
                condition.TotalRowNum = cnt;
                DataTable dt = ListRepository.GetGridDataTable(condition);

                var    rows    = DataTable2Object.Data(dt, GridLayout().GridLayouts);
                double aa      = (double)cnt / condition.PageRowNum;
                double pageCnt = Math.Ceiling(aa);
                var    result  = new JsonResult();
                result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                result.Data = new { page = condition.PageIndex, records = cnt, total = pageCnt, rows = rows };
                return(result);
            }
            catch (Exception ex)
            {
                AppLog.WriteLog(AppMember.AppText["SystemUser"], LogType.Error, "MasterController.GridData", ControllerName + "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(new JsonResult());
            }
        }
示例#29
0
 public override void HandlePushNotification(string func, object args)
 {
     try
     {
         if (Application.Current == null)
         {
             return; // not ready yet
         }
         if (func == "ActivityNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ActivityNotification?.Invoke(this, (Priv10Engine.FwEventArgs)args);
             }));
         }
         else if (func == "ChangeNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ChangeNotification?.Invoke(this, (Priv10Engine.ChangeArgs)args);
             }));
         }
         else if (func == "UpdateNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 UpdateNotification?.Invoke(this, (Priv10Engine.UpdateArgs)args);
             }));
         }
         else
         {
             throw new Exception("Unknown Notificacion");
         }
     }
     catch (Exception err)
     {
         AppLog.Exception(err);
     }
 }
示例#30
0
 public Auditing GetAuditPol()
 {
     try
     {
         AuditPol.AUDIT_POLICY_INFORMATION pol = AuditPol.GetSystemPolicy("0CCE9226-69AE-11D9-BED3-505054503030");
         if ((pol.AuditingInformation & AuditPol.AUDIT_POLICY_INFORMATION_TYPE.Success) != 0 && (pol.AuditingInformation & AuditPol.AUDIT_POLICY_INFORMATION_TYPE.Failure) != 0)
         {
             return(Auditing.All);
         }
         if ((pol.AuditingInformation & AuditPol.AUDIT_POLICY_INFORMATION_TYPE.Success) != 0)
         {
             return(Auditing.Allowed);
         }
         if ((pol.AuditingInformation & AuditPol.AUDIT_POLICY_INFORMATION_TYPE.Failure) != 0)
         {
             return(Auditing.Blocked);
         }
     }
     catch (Exception err)
     {
         AppLog.Line("Error in {0}: {1}", MiscFunc.GetCurrentMethod(), err.Message);
     }
     return(Auditing.Off);
 }
示例#31
0
        public FilteringModes GetFilteringMode()
        {
            try
            {
                if (TestFirewallEnabled(true))
                {
                    if (TestDefaultOutboundAction(NET_FW_ACTION_.NET_FW_ACTION_ALLOW))
                    {
                        return(FilteringModes.BlackList);
                    }

                    if (TestDefaultOutboundAction(NET_FW_ACTION_.NET_FW_ACTION_BLOCK))
                    {
                        return(FilteringModes.WhiteList);
                    }
                }
                return(FilteringModes.NoFiltering);
            }
            catch (Exception err)
            {
                AppLog.Line("Getting FilteringMode failed: " + err.Message);
            }
            return(FilteringModes.Unknown);
        }
示例#32
0
 public bool WatchConnections(bool enable = true)
 {
     try
     {
         if (enable)
         {
             mEventWatcher = new EventLogWatcher(new EventLogQuery("Security", PathType.LogName, "*[System[(Level=4 or Level=0) and (EventID=" + (int)EventIDs.Blocked + " or EventID=" + (int)EventIDs.Allowed + ")]] and *[EventData[Data[@Name='LayerRTID']>='48']]"));
             mEventWatcher.EventRecordWritten += new EventHandler <EventRecordWrittenEventArgs>(OnConnection);
             mEventWatcher.Enabled             = true;
         }
         else
         {
             mEventWatcher.EventRecordWritten -= new EventHandler <EventRecordWrittenEventArgs>(OnConnection);
             mEventWatcher.Dispose();
             mEventWatcher = null;
         }
     }
     catch (Exception err)
     {
         AppLog.Line("Error in {0}: {1}", MiscFunc.GetCurrentMethod(), err.Message);
         return(false);
     }
     return(true);
 }
示例#33
0
 private void AddToContext(AppLog appLog)
 {
     _context = new SICIBD2Entities1();
     _context.spInsertNewAppLogItem(appLog.Tipo, appLog.PostTime, appLog.Componente, appLog.Metodo, appLog.TiempoTomado, appLog.Propiedades, appLog.Usuario);
 }
示例#34
0
        /// <summary>
        /// Is called when one of the observed application logs has been
        /// removed.
        /// </summary>
        /// <param name="log">The log to remove/delete.</param>
        private void AppLog_LogRemoved(AppLog log)
        {
            log.LogChanged -= AppLog_LogChanged;

            _view.HideLog(log.Name);
        }
示例#35
0
 /// <summary>
 /// Is called when one of the observed application log has received 
 /// new messages.
 /// </summary>
 /// <param name="log">The log that has changed</param>
 private void AppLog_LogChanged(AppLog log)
 {
     if (_activeLog != null && _activeLog.Name == log.Name)
         UpdateView();
 }
示例#36
0
        /// <summary>
        /// Is called when a new application log is created.
        /// </summary>
        /// <param name="log">The new application log.</param>
        private void AppLog_LogAdded(AppLog log)
        {
            log.LogChanged += AppLog_LogChanged;

            _view.IncludeLog(log.Name);
        }
示例#37
0
 /// <summary>
 /// Should be called once the user has chosen a different application log
 /// as the currently active one.
 /// </summary>
 /// <param name="name">The name of the log selected.</param>
 public void SelectedLogChanged(string name)
 {
     _activeLog = AppLog.GetLog(name);
     _view.SelectLog(name);
     UpdateView();
 }