Exemplo n.º 1
0
        ///<summary>Returns true if either the XCharge program or PayConnect program is enabled and at least one clinic has online payments enabled.
        ///progEnabledForPayments will return the program that is enabled for online payments if it is allowed.  Both programs cannot be enabled at the same time</summary>
        public static bool HasOnlinePaymentEnabled(out ProgramName progEnabledForPayments)
        {
            progEnabledForPayments = ProgramName.None;
            Program progXCharge    = Programs.GetCur(ProgramName.Xcharge);
            Program progPayConnect = Programs.GetCur(ProgramName.PayConnect);

            if (!progXCharge.Enabled && !progPayConnect.Enabled)
            {
                return(false);
            }
            if (progXCharge.Enabled)
            {
                List <ProgramProperty> listXChargeProps = ProgramProperties.GetForProgram(progXCharge.ProgramNum);
                if (listXChargeProps.Any(x => x.PropertyDesc == "IsOnlinePaymentsEnabled" && x.PropertyValue == "1"))
                {
                    progEnabledForPayments = ProgramName.Xcharge;
                    return(true);
                }
            }
            if (progPayConnect.Enabled)
            {
                List <ProgramProperty> listPayConnectProps = ProgramProperties.GetForProgram(progPayConnect.ProgramNum);
                if (listPayConnectProps.Any(x => x.PropertyDesc == PayConnect.ProgramProperties.PatientPortalPaymentsEnabled && x.PropertyValue == "1"))
                {
                    progEnabledForPayments = ProgramName.PayConnect;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        // Load a Formula file into env.
        public void DoLoadFile(string filename, out AST <Program> program, out string debugInfo)
        {
            if (string.IsNullOrWhiteSpace(filename))
            {
                Console.WriteLine("Cannot load empty filename.");
                program   = null;
                debugInfo = null;
                return;
            }

            // Get AST tree from parsing result and store its reference.
            ProgramName        progName = new ProgramName(filename);
            Task <ParseResult> task     = Factory.Instance.ParseFile(progName);

            task.Wait();

            if (!task.Result.Succeeded)
            {
                Console.WriteLine("Failed to parse the Formula file.");
                program   = null;
                debugInfo = null;
                return;
            }

            program = task.Result.Program;

            // Install program into current env.
            InstallResult result;

            env.Install(program, out result);
            debugInfo = DebugInfo(result);
        }
Exemplo n.º 3
0
        ///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
        public static long GetProgramNum(ProgramName progName)
        {
            //No need to check RemotingRole; no call to db.
            Program program = GetCur(progName);

            return(program == null ? 0 : program.ProgramNum);
        }
Exemplo n.º 4
0
        private void TryEnqueue(string name, AST <Program> refSource, Span refSpan, ParseResult res)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            try
            {
                var progName = new ProgramName(name, refSource.Node.Name);
                workItems.Add(new Tuple <ProgramName, string, Span>(progName, refSource.Node.Name.ToString(env.Parameters), refSpan));
            }
            catch (Exception e)
            {
                var badRef = new Flag(
                    SeverityKind.Error,
                    refSpan,
                    Constants.BadFile.ToString(e.Message),
                    Constants.BadFile.Code,
                    refSource.Node.Name);

                if (res == null)
                {
                    iresult.AddFlag(refSource, badRef);
                }
                else
                {
                    res.AddFlag(badRef);
                }
            }
        }
Exemplo n.º 5
0
        public static string GetPropVal(ProgramName programName, string desc)
        {
            //No need to check RemotingRole; no call to db.
            long programNum = Programs.GetProgramNum(programName);

            return(GetPropVal(programNum, desc));
        }
Exemplo n.º 6
0
        ///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
        public static bool IsEnabled(ProgramName progName)
        {
            //No need to check RemotingRole; no call to db.
            Program program = GetFirstOrDefault(x => x.ProgName == progName.ToString());

            return(program == null ? false : program.Enabled);
        }
        public void valid(string name)
        {
            var pn = new ProgramName(name);

            Assert.Equal(name, pn.Value);
            Assert.Equal(name, pn.ToString());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Makes a predicate that matches folders to the program, and then matches the remainder
        /// </summary>
        public NodePred[] MkProgramPredicate(ProgramName prog, params NodePred[] remainder)
        {
            Contract.Requires(prog != null);
            var segs = prog.Uri.Segments;

            Contract.Assert(segs.Length > 1 && segs[0] == "/");
            var preds = new NodePred[segs.Length + (remainder == null ? 0 : remainder.Length)];

            preds[0] = MkPredicate(NodeKind.Folder) & MkNamePredicate("/");
            for (int i = 1; i < segs.Length - 1; ++i)
            {
                var seg = segs[i];
                preds[i] = MkPredicate(NodeKind.Folder) & MkNamePredicate(seg.Substring(0, seg.Length - 1));
            }

            preds[segs.Length - 1] = MkPredicate(NodeKind.Program) & MkNamePredicate(prog.ToString());

            if (remainder != null)
            {
                for (int i = 0; i < remainder.Length; ++i)
                {
                    preds[segs.Length + i] = remainder[i];
                }
            }

            return(preds);
        }
Exemplo n.º 9
0
        ///<summary>If isRemovable is false, then the file referenced in the program property will be cleared.
        ///If isRemovable is true, then the file referenced in the program property will be deleted.</summary>
        private static void ScrubFileForProperty(ProgramName programName, string strFileProperty, string strFilePropertySuffix, bool isRemovable)
        {
            Program program = Programs.GetCur(programName);

            if (!program.Enabled)
            {
                return;
            }
            string strFileToScrub = CodeBase.ODFileUtils.CombinePaths(ProgramProperties.GetPropVal(program.ProgramNum, strFileProperty), strFilePropertySuffix);

            if (!File.Exists(strFileToScrub))
            {
                return;
            }
            try {
                File.WriteAllText(strFileToScrub, "");               //Always clear the file contents, in case deleting fails below.
            }
            catch {
                //Another instance of OD might be closing at the same time, in which case the delete will fail. Could also be a permission issue or a concurrency issue. Ignore.
            }
            if (!isRemovable)
            {
                return;
            }
            try {
                File.Delete(strFileToScrub);
            }
            catch {
                //Another instance of OD might be closing at the same time, in which case the delete will fail. Could also be a permission issue or a concurrency issue. Ignore.
            }
        }
Exemplo n.º 10
0
Arquivo: Programs.cs Projeto: mnisl/OD
		///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
		public static bool IsEnabled(ProgramName progName){
			//No need to check RemotingRole; no call to db.
			Hashtable hashPrograms=ProgramC.GetHList();
			if(hashPrograms.ContainsKey(progName.ToString()) && ((Program)hashPrograms[progName.ToString()]).Enabled) {
				return true;
			}
			return false;
		}
Exemplo n.º 11
0
        // Load model file into env and store reference of ProgramName and Program.
        public void DoLoadModel(string modelFilename, out string debugInfo)
        {
            AST <Program> program;

            DoLoadFile(modelFilename, out program, out debugInfo);
            currentProgram  = program;
            currentProgName = new ProgramName(modelFilename);
        }
Exemplo n.º 12
0
        internal Program(ProgramName name)
        {
            Contract.Requires(name != null);

            Name    = name;
            Config  = new Config(default(Span));
            modules = new LinkedList <Node>();
            Modules = new ImmutableCollection <Node>(modules);
        }
Exemplo n.º 13
0
        public ProgramName GetProgram(string programCode)
        {
            string      user     = "******";
            string      password = "******";
            ProgramName program  = new ProgramName();

            SqlConnection BAIS3150 = new SqlConnection();

            BAIS3150.ConnectionString = @$ "Persist Security Info=False;Database={user};User ID={user};Password={password};server=dev1.baist.ca;";
            BAIS3150.Open();

            SqlCommand GetProgramCommand = new SqlCommand
            {
                Connection  = BAIS3150,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetProgram"
            };


            SqlParameter GetProgramParameter = new SqlParameter
            {
                ParameterName = "@ProgramCode",
                SqlDbType     = SqlDbType.VarChar,
                Direction     = ParameterDirection.Input,
                SqlValue      = programCode
            };

            GetProgramCommand.Parameters.Add(GetProgramParameter);
            SqlDataReader ASampleDataReader;

            ASampleDataReader = GetProgramCommand.ExecuteReader();

            if (ASampleDataReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ASampleDataReader.FieldCount; index++)
                {
                    Console.WriteLine(ASampleDataReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                while (ASampleDataReader.Read()) // no value no read (returns true until no rows left to return)
                {
                    for (int i = 0; i < ASampleDataReader.FieldCount; i++)
                    {
                        program.ProgramCode      = programCode;
                        program.Description      = ASampleDataReader.GetValue("Description").ToString();
                        program.EnrolledStudents = GetStudentByProgramCode(programCode);
                    }
                    Console.WriteLine("-");
                }
            }
            ASampleDataReader.Close();
            BAIS3150.Close();
            return(program);
        }
Exemplo n.º 14
0
 ///<summary>Supply a valid program Name, and this will set Cur to be the corresponding Program object.</summary>
 public static Program GetCur(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for(int i=0;i<ProgramC.Listt.Count;i++) {
         if(ProgramC.Listt[i].ProgName==progName.ToString()) {
             return ProgramC.Listt[i];
         }
     }
     return null;//to signify that the program could not be located. (user deleted it in an older version)
 }
Exemplo n.º 15
0
        ///<summary>Safe to call on any program. Only returns true if the program is not enabled
        ///AND the program has a property of "Disable Advertising" = 1 OR "Disable Advertising HQ" = 1.
        ///This means that either the office has disabled the ad or HQ has disabled the ad.</summary>
        public static bool IsAdvertisingDisabled(ProgramName progName)
        {
            Program program = Programs.GetCur(progName);

            if (program == null || program.Enabled)
            {
                return(false);               //do not block advertising
            }
            return(GetForProgram(program.ProgramNum).Any(x => (x.PropertyDesc == "Disable Advertising" && x.PropertyValue == "1") ||      //Office has decided to hide the advertising
                                                         (x.PropertyDesc == "Disable Advertising HQ" && x.PropertyValue == "1")));//HQ has decided to hide the advertising
        }
 public override int GetHashCode() {
   int hash = 1;
   if (ProgramName.Length != 0) hash ^= ProgramName.GetHashCode();
   if (EpisodeName.Length != 0) hash ^= EpisodeName.GetHashCode();
   if (EpisodeNumber != 0) hash ^= EpisodeNumber.GetHashCode();
   if (IsLive != false) hash ^= IsLive.GetHashCode();
   if (_unknownFields != null) {
     hash ^= _unknownFields.GetHashCode();
   }
   return hash;
 }
Exemplo n.º 17
0
        internal bool ParseFile(
            ProgramName file,
            LProgramTopDeclNames topDeclNames,
            LProgram program,
            Dictionary <string, Dictionary <int, SourceInfo> > idToSourceInfo,
            out List <Flag> flags)
        {
            flags = parseFlags = new List <Flag>();
            this.LinkTopDeclNames = topDeclNames;
            parseLinker           = program;
            this.idToSourceInfo   = idToSourceInfo;
            parseSource           = file;
            bool result;

            try
            {
                var fi = new System.IO.FileInfo(file.Uri.LocalPath);
                if (!fi.Exists)
                {
                    var badFile = new Flag(
                        SeverityKind.Error,
                        default(Span),
                        Constants.BadFile.ToString(string.Format("The file {0} does not exist", fi.FullName)),
                        Constants.BadFile.Code,
                        file);
                    result = false;
                    flags.Add(badFile);
                    return(false);
                }

                var str     = new System.IO.FileStream(file.Uri.LocalPath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                var scanner = ((Scanner)Scanner);
                scanner.SetSource(str);
                scanner.SourceProgram = file;
                scanner.Flags         = flags;
                scanner.Failed        = false;
                ResetState();
                result = (!scanner.Failed) && Parse(default(System.Threading.CancellationToken)) && !parseFailed;
                str.Close();
            }
            catch (Exception e)
            {
                var badFile = new Flag(
                    SeverityKind.Error,
                    default(Span),
                    Constants.BadFile.ToString(e.Message),
                    Constants.BadFile.Code,
                    file);
                flags.Add(badFile);
                return(false);
            }

            return(result);
        }
Exemplo n.º 18
0
 ///<summary>Supply a valid program Name, and this will set Cur to be the corresponding Program object.</summary>
 public static Program GetCur(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < ProgramC.Listt.Count; i++)
     {
         if (ProgramC.Listt[i].ProgName == progName.ToString())
         {
             return(ProgramC.Listt[i]);
         }
     }
     return(null);           //to signify that the program could not be located. (user deleted it in an older version)
 }
Exemplo n.º 19
0
 ///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
 public static long GetProgramNum(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < ProgramC.Listt.Count; i++)
     {
         if (ProgramC.Listt[i].ProgName == progName.ToString())
         {
             return(ProgramC.Listt[i].ProgramNum);
         }
     }
     return(0);
 }
Exemplo n.º 20
0
        public static int Compare(Location l1, Location l2)
        {
            if (l1.ast == null)
            {
                return(l2.ast == null ? 0 : -1);
            }
            else if (l2.ast == null)
            {
                return(1);
            }
            else if (l1.ast == l2.ast)
            {
                return(0);
            }

            var cmp = ProgramName.Compare(((Program)l1.ast.Root).Name, ((Program)l2.ast.Root).Name);

            if (cmp != 0)
            {
                return(cmp);
            }

            bool move1, move2;

            using (var it1 = l1.ast.Path.GetEnumerator())
            {
                using (var it2 = l2.ast.Path.GetEnumerator())
                {
                    while ((move1 = it1.MoveNext()) & (move2 = it2.MoveNext()))
                    {
                        cmp = it1.Current.AbsolutePos - it2.Current.AbsolutePos;
                        if (cmp != 0)
                        {
                            return(cmp);
                        }
                    }

                    if (move1 && !move2)
                    {
                        return(1);
                    }
                    else if (move2 && !move1)
                    {
                        return(-1);
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
        }
Exemplo n.º 21
0
        // Execute a query on a specific program based on its ProgramName.
        public async Task <LiftedBool> DoConstraintQuery(string constraint, ProgramName progName)
        {
            AST <Body>[] goals;
            int          id = -1;

            var cmdParts = constraint.Split(cmdSplitChars, 2, StringSplitOptions.RemoveEmptyEntries);

            if (cmdParts.Length != 2)
            {
                Console.WriteLine("Invalid constraint, must contain two parts.");
                return(LiftedBool.Unknown);
            }

            var modelName = cmdParts[0];

            ParseConstraint(cmdParts, out goals);

            List <Flag>        flags;
            Task <QueryResult> task;
            ExecuterStatistics stats;
            var queryCancel = new CancellationTokenSource();

            var result = env.Query(
                progName,
                modelName,
                goals,
                true,
                true,
                out flags,
                out task,
                out stats,
                queryCancel.Token);

            if (!result)
            {
                Console.WriteLine("Could not start operation; environment is busy");
                return(LiftedBool.Unknown);
            }

            if (task != null)
            {
                id = taskManager.StartTask(task, stats, queryCancel);
                Console.WriteLine(string.Format("Started query task with Id {0}.", id));
                task.Wait();
                return(task.Result.Conclusion);
            }
            else
            {
                Console.WriteLine("Failed to generate query task.");
                return(LiftedBool.Unknown);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Adds programs to disallow registry keys of specific user by account SID and program names executables
        /// </summary>
        /// <param name="AccountSID">Account SID for accessing registry</param>
        /// <param name="ProgramNames">Program names executables to include in restriction</param>
        public static void AddDisallowRegistryKeys(string AccountSID, string[] ProgramNames)
        {
            // Get Restriction key for adding restrictions
            RegistryKey RestrictionKey = GetRestrictionKey(AccountSID);

            // Adding each program to the restriction key
            foreach (string ProgramName in ProgramNames)
            {
                RestrictionKey.SetValue(ProgramName.Split('.')[0], ProgramName, RegistryValueKind.String);
            }

            RestrictionKey.Close();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Removes programs from disallow registry keys of specific user by account SID and program names executables
        /// </summary>
        /// <param name="AccountSID">Account SID for accessing registry</param>
        /// <param name="ProgramNames">Program names executables to exclude in restriction</param>
        public static void RemoveDisallowRegistryKeys(string AccountSID, string[] ProgramNames)
        {
            // Get Restriction key for removing restrictions
            RegistryKey RestrictionKey = GetRestrictionKey(AccountSID);

            // Removing each program from the restriction key
            foreach (string ProgramName in ProgramNames)
            {
                RestrictionKey.DeleteValue(ProgramName.Split('.')[0], false);
            }

            RestrictionKey.Close();
        }
Exemplo n.º 24
0
 ///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
 public static bool IsEnabled(ProgramName progName)
 {
     //No need to check RemotingRole; no call to db.
     if (ProgramC.HList == null)
     {
         Programs.RefreshCache();
     }
     if (ProgramC.HList.ContainsKey(progName.ToString()) && ((Program)ProgramC.HList[progName.ToString()]).Enabled)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 25
0
 public static string GetPropVal(ProgramName progName,string propertyDesc)
 {
     //No need to check RemotingRole; no call to db.
     long programNum=Programs.GetProgramNum(progName);
     for(int i=0;i<ProgramPropertyC.Listt.Count;i++) {
         if(ProgramPropertyC.Listt[i].ProgramNum!=programNum) {
             continue;
         }
         if(ProgramPropertyC.Listt[i].PropertyDesc!=propertyDesc) {
             continue;
         }
         return ProgramPropertyC.Listt[i].PropertyValue;
     }
     throw new ApplicationException("Property not found: "+propertyDesc);
 }
Exemplo n.º 26
0
        static void processStopEvent_EventArrived(object sender, EventArrivedEventArgs e)
        {
            //Stop code

            string processName = e.NewEvent.Properties["ProcessName"].Value.ToString();

            if (processName.ToLower() == ProgramName.ToLower())
            {
                using (EventLog eventLog = new EventLog("Application"))
                {
                    eventLog.Source = "Application";
                    eventLog.WriteEntry($"{ProgramName} closed.", EventLogEntryType.Information, 101, 1);
                }
            }
        }
Exemplo n.º 27
0
        public ProgramName GetProgram(string programCode)
        {
            ProgramName program = new ProgramName();
            string      user,
                        password;

            Console.Write("Please enter DB Name : ");
            user = Console.ReadLine();
            Console.Write("Please enter DB Password : "******"ExecuteReadExample");
            SqlConnection BAIS3150 = new SqlConnection(); //instantiation + declararation

            BAIS3150.ConnectionString = @$ "Persist Security Info=False;Database={user};User ID={user};Password={password};server=dev1.baist.ca;";
            BAIS3150.Open();
            SqlCommand ASampleCommand = new SqlCommand
            {
                Connection  = BAIS3150,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetPrograms"
            };
            SqlDataReader ASampleDataReader;

            ASampleDataReader = ASampleCommand.ExecuteReader();
            if (ASampleDataReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ASampleDataReader.FieldCount; index++)
                {
                    Console.WriteLine(ASampleDataReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                while (ASampleDataReader.Read()) // no value no read (returns true until no rows left to return)
                {
                    for (int i = 0; i < ASampleDataReader.FieldCount; i++)
                    {
                        program.ProgramCode = ASampleDataReader.GetValue("ProgramCode").ToString();
                        program.Description = ASampleDataReader.GetValue("Description").ToString();
                    }
                    Console.WriteLine("-");
                }
            }
            ASampleDataReader.Close();
            BAIS3150.Close();
            return(program);
        }
Exemplo n.º 28
0
        private static int CompareModules(AST <Node> mod1, AST <Node> mod2)
        {
            var prog1 = (Program)mod1.GetPathParent();
            var prog2 = (Program)mod2.GetPathParent();
            var cmp   = ProgramName.Compare(prog1.Name, prog2.Name);

            if (cmp != 0)
            {
                return(cmp);
            }

            string name1, name2;

            mod1.Node.TryGetStringAttribute(AttributeKind.Name, out name1);
            mod2.Node.TryGetStringAttribute(AttributeKind.Name, out name2);
            return(string.CompareOrdinal(name1, name2));
        }
Exemplo n.º 29
0
        static ListParser()
        {
            var progName = new ProgramName("env:///temp.4ml");
            var progText = string.Format(listDomainStr, consName, nilName);
            var task     = Factory.Instance.ParseText(progName, progText);

            task.Wait();
            if (!task.Result.Succeeded)
            {
                throw new Exception("Could not parse domain definition");
            }

            var query = new NodePred[] {
                NodePredFactory.Instance.Star,
                NodePredFactory.Instance.MkPredicate(NodeKind.Domain)
            };

            listDomain = (AST <Domain>)task.Result.Program.FindAny(query);
        }
Exemplo n.º 30
0
        public static string GetPropVal(ProgramName progName, string propertyDesc)
        {
            //No need to check RemotingRole; no call to db.
            long programNum = Programs.GetProgramNum(progName);

            for (int i = 0; i < ProgramPropertyC.Listt.Count; i++)
            {
                if (ProgramPropertyC.Listt[i].ProgramNum != programNum)
                {
                    continue;
                }
                if (ProgramPropertyC.Listt[i].PropertyDesc != propertyDesc)
                {
                    continue;
                }
                return(ProgramPropertyC.Listt[i].PropertyValue);
            }
            throw new ApplicationException("Property not found: " + propertyDesc);
        }
Exemplo n.º 31
0
 public void OnPost()
 {
     if (ModelState.IsValid)
     {
         Message = "Hit";
         bool        Confirm;
         ProgramName newProgram = new ProgramName
         {
             ProgramCode = ProgramCodeField,
             Description = DescriptionField
         };
         BCS requesterDirectorUI = new BCS();
         Confirm = requesterDirectorUI.CreateProgram(newProgram.ProgramCode, newProgram.Description);
         Message = $"Create program success:{Confirm}";
     }
     else
     {
         Message = $"Not Valid";
     }
 }
        public virtual string GetVersion(Context context, string fullProgramPath)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            string programPath = String.IsNullOrEmpty(fullProgramPath) ? ProgramName : fullProgramPath;

            if (Path.IsPathRooted(ProgramName))
            {
                programPath = ProgramName;
            }
            else if (ProgramName.IndexOf(Path.DirectorySeparatorChar) >= 0)
            {
                if (ProgramName [0] == Path.DirectorySeparatorChar)                   // Might be the case on Windows
                {
                    programPath = Path.GetFullPath(ProgramName);
                }
                else
                {
                    programPath = Path.Combine(BuildPaths.XamarinAndroidSourceRoot, ProgramName);
                }
            }
            else
            {
                programPath = context.OS.Which(ProgramName, required: false);
            }

            if (!Utilities.FileExists(programPath))
            {
                Log.DebugLine("File {fullProgramPath} does not exist, unable to obtain version");
                return(DefaultVersionString);
            }

            string versionOutput = Utilities.GetStringFromStdout(programPath, VersionArguments);

            Log.DebugLine($"{programPath} {VersionArguments} returned: {versionOutput}");

            return(ParseVersion(versionOutput));
        }
Exemplo n.º 33
0
        // Helper method to get a list of goal from constraint, and will be invoked in DoConstraintQuery().
        public void ParseConstraint(string[] cmdParts, out AST <Body>[] goals)
        {
            goals = null;

            // Parse constraint string as Formula file to get AST tree synchronously, it's not necessary to
            // make parsing here asynchronously since we suppose constraint text are small and trivial.
            var cmdLineName = new ProgramName("CommandLine.4ml");
            var parse       = Factory.Instance.ParseText(
                cmdLineName,
                string.Format("domain Dummy {{q :-\n{0}\n.}}", cmdParts[1])
                );

            parse.Wait();

            if (!parse.Result.Succeeded)
            {
                Console.WriteLine("Failed to parse constraint string");
                return;
            }

            var rule = parse.Result.Program.FindAny(
                new NodePred[]
            {
                NodePredFactory.Instance.Star,
                NodePredFactory.Instance.MkPredicate(NodeKind.Rule),
            }
                );

            Contract.Assert(rule != null);
            var bodies = ((Rule)rule.Node).Bodies;

            goals = new AST <Body> [bodies.Count];
            int i = 0;

            // Return a list of AST tree with Body Node.
            foreach (var b in bodies)
            {
                goals[i++] = (AST <Body>)Factory.Instance.ToAST(b);
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Mở tập tin dùng chương trình của hệ thống
 /// nếu ko có dùng chương trình có trong chương trình của PROTOCOL
 /// </summary>
 /// <param name="FileName"></param>
 public static void OpenFile(string FileName, ProgramName program)
 {
     Process proc = new Process();
     proc.StartInfo.FileName = FileName;
     try
     {
         proc.Start();
     }
     catch (Win32Exception e)
     {
         switch (program)
         {
             case ProgramName.PDF:
                 string foxitFile = RadParams.RUNTIME_PATH + @"\apps\pdf.exe";
                 if (File.Exists(foxitFile))
                     System.Diagnostics.Process.Start(foxitFile, "\"" + FileName + "\"");
                 return;
             case ProgramName.SWF:
                 string swfFile = RadParams.RUNTIME_PATH + @"\apps\FlashPlayer.exe";
                 if (File.Exists(swfFile))
                     System.Diagnostics.Process.Start(swfFile, "\"" + FileName + "\"");
                 return;
             case ProgramName.FLV:
                 string flvFile = RadParams.RUNTIME_PATH + @"\apps\FlashPlayer.exe";
                 if (File.Exists(flvFile))
                     System.Diagnostics.Process.Start(flvFile, "\"" + FileName + "\"");
                 return;
         }
         System.Diagnostics.Process.Start("rundll32.exe", "shell32.dll, OpenAs_RunDLL " + FileName);
     }
 }
Exemplo n.º 35
0
		public static string GetPropVal(ProgramName progName,string desc) {
			//No need to check RemotingRole; no call to db.
			long programNum=Programs.GetProgramNum(progName);
			return GetPropVal(programNum,desc);
		}
Exemplo n.º 36
0
Arquivo: Programs.cs Projeto: mnisl/OD
		///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
		public static long GetProgramNum(ProgramName progName) {
			//No need to check RemotingRole; no call to db.
			List<Program> listPrograms=ProgramC.GetListt();
			for(int i=0;i<listPrograms.Count;i++) {
				if(listPrograms[i].ProgName==progName.ToString()) {
					return listPrograms[i].ProgramNum;
				}
			}
			return 0;
		}
Exemplo n.º 37
0
		///<summary>Returns true if a Program link with the given name or number exists and is enabled.</summary>
		public static bool IsEnabled(ProgramName progName){
			//No need to check RemotingRole; no call to db.
			if(ProgramC.HList==null) {
				Programs.RefreshCache();
			}
			if(ProgramC.HList.ContainsKey(progName.ToString()) && ((Program)ProgramC.HList[progName.ToString()]).Enabled) {
				return true;
			}
			return false;
		}
Exemplo n.º 38
0
		///<summary>If isRemovable is false, then the file referenced in the program property will be cleared.
		///If isRemovable is true, then the file referenced in the program property will be deleted.</summary>
		private static void ScrubFileForProperty(ProgramName programName,string strFileProperty,string strFilePropertySuffix,bool isRemovable) {
			Program program=Programs.GetCur(programName);
			if(!program.Enabled) {
				return;
			}
			string strFileToScrub=CodeBase.ODFileUtils.CombinePaths(ProgramProperties.GetPropVal(program.ProgramNum,strFileProperty),strFilePropertySuffix);
			if(!File.Exists(strFileToScrub)) {
				return;
			}
			try {
				File.WriteAllText(strFileToScrub,"");//Always clear the file contents, in case deleting fails below.
			}
			catch {
				//Another instance of OD might be closing at the same time, in which case the delete will fail. Could also be a permission issue or a concurrency issue. Ignore.
			}
			if(!isRemovable) {
				return;
			}
			try {
				File.Delete(strFileToScrub);
			}
			catch {
				//Another instance of OD might be closing at the same time, in which case the delete will fail. Could also be a permission issue or a concurrency issue. Ignore.
			}
		}
Exemplo n.º 39
0
		///<summary>Supply a valid program Name.  Will return 0 if not found.</summary>
		public static long GetProgramNum(ProgramName progName) {
			//No need to check RemotingRole; no call to db.
			for(int i=0;i<ProgramC.Listt.Count;i++) {
				if(ProgramC.Listt[i].ProgName==progName.ToString()) {
					return ProgramC.Listt[i].ProgramNum;
				}
			}
			return 0;
		}