Beispiel #1
0
        public EnergyAnalyseCompare GetEnergyAnalyseCompare(QueryAnalyse query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.Charts().GetEnergyAnalyseCompare(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new EnergyAnalyseCompare()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new EnergyAnalyseCompare()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #2
0
        public ExecuteProcess AddUser(QueryUser model)
        {
            var pAction = new ExecuteProcess();

            try
            {
                if (new NTS.WEB.BLL.User().IsExistUserName(model))
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "该用户名已存在";
                    return(pAction);
                }
                else
                {
                    new NTS.WEB.BLL.User().AddUser(model);
                    pAction.Success      = true;
                    pAction.ExceptionMsg = "新增用户成功";
                    return(pAction);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(pAction);
            }
        }
Beispiel #3
0
    public override Result PlayFile(string filename)
    {
        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        executable = "mplayer";
        List <string> parameters = new List <string>();

        parameters.Insert(0, filename);
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(0, "-title");              //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            parameters.Insert(1, "Chronojump video");
        }
        else
        {
            parameters.Insert(0, "-noborder");
        }


        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, false, true, false, true, true);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
Beispiel #4
0
        public UserListResult GetUsers()
        {
            UserListResult result  = new UserListResult();
            var            pAction = new ExecuteProcess();

            try
            {
                var userlist = new NTS.WEB.BLL.User().GetUsers();

                if (userlist.Count > 0)
                {
                    pAction.Success   = true;
                    result.UserList   = userlist;
                    result.ActionInfo = pAction;
                    return(result);
                }
                else
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    result.ActionInfo    = pAction;
                    return(result);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                result.ActionInfo    = pAction;
                return(result);
            }
        }
Beispiel #5
0
        public ResultAlarm GetAlarmDiagnose(QueryAlarm query)
        {
            ResultAlarm result  = new ResultAlarm();
            var         pAction = new ExecuteProcess();

            try
            {
                var alarmdiagnoselist = new NTS.WEB.BLL.AlarmDiagnose().GetAlarmDiagnose(query);
                if (alarmdiagnoselist.Count > 0)
                {
                    pAction.Success   = true;
                    result.Rows       = alarmdiagnoselist;
                    result.ActionInfo = pAction;
                    return(result);
                }
                else
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    result.ActionInfo    = pAction;
                    return(result);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                result.ActionInfo    = pAction;
                return(result);
            }
        }
        public ResultContrast IndexContrastChart()
        {
            ResultContrast refResutl = new ResultContrast();

            try
            {
                int inputValue = int.Parse(_ntsPage.Request["cType"]);
                switch (inputValue)
                {
                case 1:
                    refResutl = IndexContrastObjsChart();
                    break;

                case 2:
                    refResutl = IndexContrastPeriodsChart();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ResultContrast con     = new ResultContrast();
                ExecuteProcess process = new ExecuteProcess();
                process.ExceptionMsg = ex.Message;
                process.Success      = false;
                con.ActionInfo       = process;
                return(con);
            }
            return(refResutl);
        }
Beispiel #7
0
        public ResultQuota GetQuotaAnalyseChart(QueryQuota query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.Charts().GetQuotaAnalyseChart(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new ResultQuota()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new ResultQuota()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #8
0
    public Result PlayFile(string filename)
    {
        string executable = "ffplay";

        if (os == UtilAll.OperatingSystems.WINDOWS)
        {
            executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay.exe");
        }

        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        List <string> parameters = createParametersPlayFile(filename);

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, false, false, false);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programFfmpegNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
Beispiel #9
0
        //[Conditional("DEBUG_SERVICE")]
        //private  void DebugMode()
        //{
        //    Servicelog();
        //    Debugger.Break();
        //}
        public void Servicelog()
        {
            DML_Utility objDML = new DML_Utility();

            try
            {
                //objDML.Add_Exception_Log("Service Start", "");
                ExecuteProcess   obj    = new ExecuteProcess();
                Get_Data_Utility objGet = new Get_Data_Utility();
                string           error  = obj.Write_JSON_TO_Download();
                //objDML.Add_Exception_Log("Download Complete", "");

                System.Threading.Thread.Sleep(2000);

                CaseCreationProcessor obj1 = new CaseCreationProcessor();
                string output1             = obj.Execute_Excel_YetToStart_Process_Download();
                //objDML.Add_Exception_Log("FreshCase Request Sent", "");

                System.Threading.Thread.Sleep(2000);
                obj.Read_Response();
                string output = obj1.Create_Case_Creation_Json_For_FreshCase();
                //objDML.Add_Exception_Log("Service End", "");
            }
            catch (Exception ex)
            {
                objDML.Add_Exception_Log("Wipro exception : " + ex.Message, "");
                Console.WriteLine(ex.Message.ToString());
                throw ex;
            }
        }
Beispiel #10
0
        public MainInfo GetIndexCompareEneryNew()
        {
            //string username= HttpContext.Current.Session["userid"].ToString() ;
            MainInfo mainInfo = new MainInfo();
            var      nowMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-1"));
            var      endTime  = DateTime.Now;
            var      pAction  = new ExecuteProcess();

            try
            {
                mainInfo            = new NTS.WEB.BLL.IndexEnery().GetIndexCompareEneryNew(nowMonth, endTime);
                pAction.Success     = true;
                mainInfo.ActionInfo = pAction;
                return(mainInfo);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new MainInfo()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #11
0
        public IndexWindowResult GetIndexWindowResult(QueryIndexWindow query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.IndexEnery().GetItemCodeListByObjectID(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new IndexWindowResult()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new IndexWindowResult()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #12
0
        //convert text to GMI for raw text
        public static Tuple <int, string, string> HtmlToGmi(string rawPath, string outPath)
        {
            var appDir = System.AppDomain.CurrentDomain.BaseDirectory;
            var finder = new ResourceFinder();

            //allow for rebol and converters to be in sub folder of exe (e.g. when deployed)
            //otherwise we use the development ones which are version controlled
            var converterPath = finder.LocalOrDevFile(appDir, @"HtmlToGmi", @"..\..\..\HtmlToGmi", "html2gmi.exe");

            //for some unknown reason, the -m flag (numbered citations) must not be last when calling from this context
            //-e (show embedded images as links)
            //-n (number links)
            var command = String.Format("\"{0}\" -mne -i \"{1}\" -o \"{2}\"",
                                        converterPath,
                                        rawPath,
                                        outPath

                                        );

            var execProcess = new ExecuteProcess();

            var result = execProcess.ExecuteCommand(command);

            return(result);
        }
Beispiel #13
0
        //convert GopherText to GMI and save to outpath
        public static Tuple <int, string, string> GophertoGmi(string gopherPath, string outPath, string uri, GopherParseTypes parseType)
        {
            var appDir = System.AppDomain.CurrentDomain.BaseDirectory;
            var finder = new ResourceFinder();

            var parseScript = (parseType == GopherParseTypes.Map) ? "GophermapToGmi.r3" : "GophertextToGmi.r3";

            //allow for rebol and converters to be in sub folder of exe (e.g. when deployed)
            //otherwise we use the development ones which are version controlled
            var rebolPath  = finder.LocalOrDevFile(appDir, @"Rebol", @"..\..\Rebol", "r3-core.exe");
            var scriptPath = finder.LocalOrDevFile(appDir, @"GmiConverters", @"..\..\GmiConverters", parseScript);

            //due to bug in rebol 3 at the time of writing (mid 2020) there is a known bug in rebol 3 in
            //working with command line parameters, so we need to escape quotes
            //see https://stackoverflow.com/questions/6721636/passing-quoted-arguments-to-a-rebol-3-script
            //also hypens are also problematic, so we base64 each parameter and unpack it in the script
            var command = String.Format("\"{0}\" -cs \"{1}\" \"{2}\" \"{3}\" \"{4}\" ",
                                        rebolPath,
                                        scriptPath,
                                        Base64Service.Base64Encode(gopherPath),
                                        Base64Service.Base64Encode(outPath),
                                        Base64Service.Base64Encode(uri)

                                        );

            var execProcess = new ExecuteProcess();

            var result = execProcess.ExecuteCommand(command);

            return(result);
        }
Beispiel #14
0
    public static void WakeUpRaspberryIfNeeded()
    {
        string        executable = "xset";
        List <string> parameters = new List <string>();

        parameters.Insert(0, "-q");
        ExecuteProcess.Result execute_result = ExecuteProcess.run(executable, parameters);

        bool on = screenIsOn(execute_result.stdout);

        LogB.Information("Screen is on?" + on.ToString());

        if (!on)
        {
            //xset -display :0 dpms force on
            parameters = new List <string>();
            parameters.Insert(0, "-display");
            parameters.Insert(1, ":0");
            parameters.Insert(2, "dpms");
            parameters.Insert(3, "force");
            parameters.Insert(4, "on");
        }

        execute_result = ExecuteProcess.run(executable, parameters);
        LogB.Information("Result = " + execute_result.stdout);
    }
Beispiel #15
0
        public ExecuteProcess UpdateUserGroup(QueryUserGroup model)
        {
            var pAction = new ExecuteProcess();

            try
            {
                if (new NTS.WEB.BLL.UserGroup().IsExistUserGroupName(model))
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "该用户组已存在";
                    return(pAction);
                }
                else
                {
                    new NTS.WEB.BLL.UserGroup().UpdateUserGroup(model);
                    pAction.Success      = true;
                    pAction.ExceptionMsg = "更新用户组成功";
                    return(pAction);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(pAction);
            }
        }
Beispiel #16
0
        public ResultCostQuery GetCostQuery(QueryCost query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.CostQuery().GetCostQuery(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new ResultCostQuery()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new ResultCostQuery()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #17
0
    public bool StartOrContinue(EncoderStruct es)
    {
        status = Status.RUNNING;

        this.es = es;

        //options change at every capture. So do at continueProcess and startProcess
        writeOptionsFile();

        bool ok = true;

        if (ExecuteProcess.IsRunning(p) && ExecuteProcess.IsResponsive(p))
        {
            LogB.Debug("calling continue");
            ok = continueProcess();
        }
        else
        {
            LogB.Debug("calling start");
            ok = startProcess();
            LogB.Debug("StartedOk: " + ok.ToString());
        }

        status = Status.DONE;

        return(ok);
    }
        //convert GMI to HTML for display and save to outpath
        public static Tuple <int, string, string> GmiToHtml(string gmiPath, string outPath, string uri, SiteIdentity siteIdentity, string theme, bool showWebHeader)
        {
            var appDir = AppDomain.CurrentDomain.BaseDirectory;

            //allow for rebol and converters to be in sub folder of exe (e.g. when deployed)
            //otherwise we use the development ones which are version controlled
            var rebolPath  = ResourceFinder.LocalOrDevFile(appDir, @"Rebol", @"..\..\..\Rebol", "r3-core.exe");
            var scriptPath = ResourceFinder.LocalOrDevFile(appDir, @"GmiConverters", @"..\..\..\GmiConverters", "GmiToHtml.r3");

            var identiconUri = new Uri(siteIdentity.IdenticonImagePath());
            var fabricUri    = new Uri(siteIdentity.FabricImagePath());

            //due to bug in rebol 3 at the time of writing (mid 2020) there is a known bug in rebol 3 in
            //working with command line parameters, so we need to escape quotes
            //see https://stackoverflow.com/questions/6721636/passing-quoted-arguments-to-a-rebol-3-script
            //also hypens are also problematic, so we base64 each param and unpack in the script
            var command = string.Format("\"{0}\" -cs \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\" \"{7}\" \"{8}\" \"{9}\" \"{10}\" ",
                                        rebolPath,
                                        scriptPath,
                                        Base64Service.Base64Encode(gmiPath),
                                        Base64Service.Base64Encode(outPath),
                                        Base64Service.Base64Encode(uri),
                                        Base64Service.Base64Encode(theme),
                                        Base64Service.Base64Encode(identiconUri.AbsoluteUri),
                                        Base64Service.Base64Encode(fabricUri.AbsoluteUri),
                                        Base64Service.Base64Encode(siteIdentity.GetId()),
                                        Base64Service.Base64Encode(siteIdentity.GetSiteId()),
                                        Base64Service.Base64Encode(showWebHeader ? "true" : "false"));

            var result = ExecuteProcess.ExecuteCommand(command);

            return(result);
        }
Beispiel #19
0
        public static ExecuteProcessTaskWrapper CreateTask(ExecuteProcess executeProcess, ContainerWrapper containerWrapper)
        {
            ExecuteProcessTaskWrapper executeProcessTaskWrapper = new ExecuteProcessTaskWrapper(containerWrapper)
            {
                Name                 = executeProcess.Name,
                DelayValidation      = executeProcess.DelayValidation,
                ForceExecutionResult = executeProcess.ForceExecutionResult.ToString(),
                Arguments            = executeProcess.Arguments,
                Executable           = executeProcess.Executable,
                RequireFullFileName  = executeProcess.RequireFullFileName,
                FailTaskIfReturnCodeIsNotSuccessValue = executeProcess.FailTaskIfReturnCodeIsNotSuccessValue,
                StandardInputVariable        = executeProcess.StandardInputVariableName,
                StandardErrorVariable        = executeProcess.StandardErrorVariableName,
                StandardOutputVariable       = executeProcess.StandardOutputVariableName,
                SuccessValue                 = executeProcess.SuccessValue,
                TerminateProcessAfterTimeOut = executeProcess.TerminateProcessAfterTimeOut,
                TimeOut          = executeProcess.TimeOut,
                WindowStyle      = (System.Diagnostics.ProcessWindowStyle)executeProcess.WindowStyle,
                WorkingDirectory = executeProcess.WorkingDirectory,
            };

            executeProcessTaskWrapper.PropagateErrors(executeProcess.PropagateErrors);
            AddExpressions(executeProcessTaskWrapper, executeProcess.PropertyExpressions);

            return(executeProcessTaskWrapper);
        }
        static void Execute()
        {
            DML_Utility objDML = new DML_Utility();

            ExecuteProcess        obj  = new ExecuteProcess();
            CaseCreationProcessor obj1 = new CaseCreationProcessor();

            //objDML.Insert_Json_in_requesStateInstanse(Convert.ToInt64(338200), 1, "REQ-0002", 165, "Case Creation by Touchless", 1, 5, 0);
            //long NewRequestID = 23548;
            //string fileupload = "C:\\Users\\Grid\\Downloads\\My Received Files\\My Received Files";
            //string destinationPath = fileupload + "\\" + NewRequestID;
            //List<string> copiedFiles = FileUtility.FileUpload(fileupload, destinationPath);
            //objDML.Insert_FilePathIndocument_upload(copiedFiles, Convert.ToInt64(NewRequestID));


            string error = obj.Write_JSON_TO_Download();

            System.Threading.Thread.Sleep(2000);

            string output1 = obj.Execute_Excel_YetToStart_Process_Download();

            System.Threading.Thread.Sleep(2000);
            obj.Read_Response();
            //string output = obj1.Create_Case_Creation_Json_For_FreshCase();
        }
Beispiel #21
0
        public ResultMenus GetMenus(string username)
        {
            ResultMenus result  = new ResultMenus();
            var         pAction = new ExecuteProcess();

            try
            {
                result = new NTS.WEB.BLL.MenuTree().GetMenus(username);
                if (result != null)
                {
                    pAction.Success   = true;
                    result.ActionInfo = pAction;
                    return(result);
                }
                else
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    result.ActionInfo    = pAction;
                    return(result);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                result.ActionInfo    = pAction;
                return(result);
            }
        }
Beispiel #22
0
        public SingleUserGroupResult GetSingleUserGroup(int usergroupid)
        {
            SingleUserGroupResult result = new SingleUserGroupResult();
            var pAction = new ExecuteProcess();

            try
            {
                var query = new NTS.WEB.BLL.UserGroup().GetSingleUserGroup(usergroupid);

                if (query != null)
                {
                    //query.Password = DESEncrypt.Decrypt(query.Password);
                    pAction.Success       = true;
                    pAction.ExceptionMsg  = "获取单个用户组成功";
                    result.QueryUserGroup = query;
                    result.ActionInfo     = pAction;
                    return(result);
                }
                else
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    result.ActionInfo    = pAction;
                    return(result);
                }
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                result.ActionInfo    = pAction;
                return(result);
            }
        }
Beispiel #23
0
        public IndexMonthEnery GetIndexMonthEneryResult()
        {
            DateTime endTime;
            var      startTime = endTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-1"));
            var      pAction   = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.IndexEnery().GetMonthItemCodeList(startTime, endTime);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new IndexMonthEnery()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new IndexMonthEnery()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #24
0
        public QueryEneryTotal GetQueryEneryTotal(NTS.WEB.DataContact.BasicQuery query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.QueryEnery().GetQueryEneryTotal(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new QueryEneryTotal()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new QueryEneryTotal()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #25
0
        public void Servicelog()
        {
            DML_Utility objDML = new DML_Utility();

            try
            {
                ExecuteProcess   obj    = new ExecuteProcess();
                Get_Data_Utility objGet = new Get_Data_Utility();
                string           error  = obj.Write_JSON_TO_Download();
                System.Threading.Thread.Sleep(2000);

                CaseCreationProcessor obj1 = new CaseCreationProcessor();
                string output1             = obj.Execute_Excel_YetToStart_Process_Download();
                System.Threading.Thread.Sleep(2000);
                obj.Read_Response();
                string output = obj1.Create_Case_Creation_Json_For_FreshCase();

                //ExecuteProcess obj2 = new ExecuteProcess();
                //clsState state = new clsState();
                //List<tbl_request_state_instance> OpenStates = objGet.GetAllOpenState();
                //foreach (var item in OpenStates)
                //{
                //    state.SwitchAllOpenStates(item);
                //}
            }
            catch (Exception ex)
            {
                objDML.Add_Exception_Log(ex.Message, "");
                Console.WriteLine("Wipro exception : " + ex.Message.ToString());
                throw ex;
            }
        }
Beispiel #26
0
        public NTS.WEB.ResultView.ResultOrder GetShopOrderNew(NTS.WEB.DataContact.QueryOrderObjects query)
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.QueryEnery().GetShopOrderNew(query);
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new ResultOrder()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new ResultOrder()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #27
0
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         DateTime startTime       = DateTime.Now;
         string[] commandSwtiches = args;
         bool     deleteFiles     = commandSwtiches.Contains("/delete");
         bool     executeScan     = commandSwtiches.Contains("/e");
         try
         {
             startTime = DateTime.Now;
             //ExecuteProcess.scanPreviousData();        // deprecated. we dont have to scan as we are not maintaining any further information for failed to delete files.
             if (executeScan)
             {
                 ExecuteProcess.scanCurrentFileSystem(deleteFiles);
             }
         }
         catch (Exception ex)
         {
             //logFFCBatch.WriteEntry( DateTime.Now.ToString() + ": Error Occured: " + ex.Message + "-OnElapsedTime()");
             File.AppendAllText(ExecuteProcess._FileName, "\r\n" + DateTime.Now.ToString() + ": Error Occured: " + ex.Message + "-OnElapsedTime()");
         }
         finally
         {
             //logFFCBatch.WriteEntry( DateTime.Now.ToString() + ": Finished job @ " + System.DateTime.Now.ToString() + " and took " + DateTime.Now.Subtract(startTime).Minutes + " min. -OnElapsedTime()");
             File.AppendAllText(ExecuteProcess._FileName, "\r\n" + DateTime.Now.ToString() + ": Finished job @ " + System.DateTime.Now.ToString() + " and took " + DateTime.Now.Subtract(startTime).Seconds + " sec(s). -OnElapsedTime()");
         }
         Application.Exit(); Application.ExitThread(); return;
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new frmMain());
 }
Beispiel #28
0
        public NTS.WEB.ResultView.ObjectTree GetDeviceTree()
        {
            var pAction = new ExecuteProcess();

            try
            {
                var result = new NTS.WEB.BLL.BaseTree().GetDeviceTree();
                if (result == null)
                {
                    pAction.Success      = false;
                    pAction.ExceptionMsg = "暂无数据信息";
                    return(new NTS.WEB.ResultView.ObjectTree()
                    {
                        ActionInfo = pAction
                    });
                }
                pAction.Success   = true;
                result.ActionInfo = pAction;
                return(result);
            }
            catch (Exception e)
            {
                pAction.Success      = false;
                pAction.ExceptionMsg = e.Message;
                return(new NTS.WEB.ResultView.ObjectTree()
                {
                    ActionInfo = pAction
                });
            }
        }
Beispiel #29
0
        public ResultAlarmType GetAlarmType(string strWhere)
        {
            ExecuteProcess process = new ExecuteProcess();

            process.ActionName   = "";
            process.ActionTime   = System.DateTime.Now;
            process.Success      = true;
            process.ExceptionMsg = "";

            ResultAlarmType  alarm  = new ResultAlarmType();
            DataTable        dttype = _Alarm.GetAlarmType(strWhere);
            List <AlarmType> types  = new List <AlarmType>();

            foreach (DataRow row in dttype.Rows)
            {
                AlarmType type = new AlarmType();
                type.ItemCode = row["TYPE"].ToString();
                type.ItemName = row["NAME"].ToString();
                types.Add(type);
            }
            alarm.ActionInfo = process;
            alarm.ItemLst    = types;

            return(alarm);
        }
Beispiel #30
0
    void on_button_rfid_start_clicked(object o, EventArgs args)
    {
        string script_path = Util.GetRFIDCaptureScript();

        if (!File.Exists(script_path))
        {
            LogB.Debug("ExecuteProcess does not exist parameter: " + script_path);
            label_rfid.Text = "Error starting rfid capture";
            return;
        }

        string filePath = Util.GetRFIDCapturedFile();

        Util.FileDelete(filePath);


        // ---- start process ----
        //
        // on Windows will be different, but at the moment RFID is only supported on Linux (Raspberrys)
        // On Linux and OSX we execute Python and we pass the path to the script as a first argument

        string executable = "python";                 // TODO: check if ReadChronojump.py works on Python 2 and Python 3

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

        // first argument of the Python: the path to the script
        parameters.Insert(0, script_path);


        processRFIDcapture = new Process();
        bool calledOk = ExecuteProcess.RunAtBackground(processRFIDcapture, executable, parameters);

        if (calledOk)
        {
            button_rfid_start.Sensitive = false;
            label_rfid.Text             = "...";
        }
        else
        {
            label_rfid.Text = "Error starting rfid capture";
        }

        // ----- process is launched

        //create a new FileSystemWatcher and set its properties.
        FileSystemWatcher watcher = new FileSystemWatcher();

        watcher.Path   = Path.GetDirectoryName(filePath);
        watcher.Filter = Path.GetFileName(filePath);

        //add event handlers.
        watcher.Changed += new FileSystemEventHandler(rfid_watcher_changed);

        //start watching
        watcher.EnableRaisingEvents = true;

        //also perform an initial search
        rfid_read();
    }