示例#1
0
        /// <summary>
        /// Load the recent files from the ini file
        /// </summary>        
        public static string[] Load()
        {
            Ini settingsFile = new Ini();
            string[] files = new string[MAX_FILES];

            for (int i = 0; i < MAX_FILES; i++)
            {
                if (settingsFile.HasEntry(SECTION_FILES, "File " + (i + 1)))
                    files[i] = settingsFile.GetValue(SECTION_FILES, "File " + (i + 1)).ToString();
            }

            return files;
        }
 public Boolean IsPictogramManagerInstalled()
 {
     var iniFilePath = Environment.GetEnvironmentVariable("WINDIR") + @"\PictogramManager.ini";
     var iniFile = new FileInfo(iniFilePath);
     if (!iniFile.Exists) {
         return false;
     }
     var ini = new Ini(iniFilePath);
     var exeFilePath = ini.GetValue("Inst", "Dir") as string;
     if(exeFilePath == null) {
         return false;
     }
     var exeFile = new FileInfo(exeFilePath + @"\PictogramManager.exe");
     return exeFile.Exists;
 }
示例#3
0
        /// <summary>
        /// Save a filename as the first recent file no matter it is old or new
        /// Bring up the new file if it is already on the list
        /// Only MAX_FILES are stored, so bump the last entry off the list
        /// </summary>        
        public static void Save(string filename)
        {
            Ini settingsFile = new Ini();
            string[] files = Load();

            settingsFile.SetValue(SECTION_FILES, "File 1", filename);

            int n = 1;
            foreach (string file in files)
            {
                if (n >= MAX_FILES) break;
                if (file != null && file != filename)
                {
                    n++;
                    settingsFile.SetValue(SECTION_FILES, "File " + n, file);
                }
            }
        }
示例#4
0
文件: Ini.cs 项目: KaMa4/tas-editor
 /// <summary>
 ///   Initializes a new instance of the Ini class based on another Ini object. </summary>
 /// <param name="ini">
 ///   The Ini object whose properties and events are used to initialize the object being constructed. </param>
 public Ini(Ini ini)
     :
     base(ini)
 {
 }
        public ActionResult doCall(string Name, string phoneBgn, string phoneEnd)
        {
            try
            {
                AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "\\Callback.ini");
                if (!Ini.HasSection("COMMON"))
                {
                    Ini.SetValue("COMMON", "account_id", "12345");
                    Ini.SetValue("COMMON", "api_key", "some-as-uuid-string");
                }


                string account_id = Ini.GetValue("COMMON", "account_id", "12345");
                string api_key    = Ini.GetValue("COMMON", "api_key", "some-as-uuid-string");

                string url = "https://api.voximplant.com/platform_api/StartScenarios/?account_id=" + account_id + "&api_key=" + api_key + "&rule_id=135498&script_custom_data=" + phoneBgn + "%3A" + phoneEnd + "";

                var request = (HttpWebRequest)WebRequest.Create(url);

                var response = (HttpWebResponse)request.GetResponse();

                var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

                Call theCall = Call.GetByCall(phoneBgn, phoneEnd);
                if (theCall == null)
                {
                    theCall          = new Call();
                    theCall.Name     = Name;
                    theCall.phoneBgn = phoneBgn;
                    theCall.phoneEnd = phoneEnd;
                    theCall.Save();
                }
                else
                {
                    theCall.CallsCount++;
                    theCall.Name = Name;
                    theCall.Update();
                }

                var serializer = new JavaScriptSerializer();

                // For simplicity just use Int32's max value.
                // You could always read the value from the config section mentioned above.
                serializer.MaxJsonLength = Int32.MaxValue;

                var resultData = new { phone_bgn = phoneBgn, phone_end = phoneEnd, result = responseString };
                var result     = new ContentResult
                {
                    Content     = serializer.Serialize(resultData),
                    ContentType = "application/json"
                };
                return(result);
            }
            catch (Exception ex)
            {
                var serializer = new JavaScriptSerializer();

                // For simplicity just use Int32's max value.
                // You could always read the value from the config section mentioned above.
                serializer.MaxJsonLength = Int32.MaxValue;

                var resultData = new { phone_bgn = phoneBgn, phone_end = phoneEnd, error = ex.Message };
                var result     = new ContentResult
                {
                    Content     = serializer.Serialize(resultData),
                    ContentType = "application/json"
                };
                return(result);
            }
        }
示例#6
0
 /// <summary>
 ///   Initializes a new instance of the Ini class based on another Ini object. </summary>
 /// <param name="ini">
 ///   The Ini object whose properties and events are used to initialize the object being constructed. </param>
 public Ini(Ini ini)
     : base(ini)
 {
 }
示例#7
0
 public Ini(Ini ini)
     : base((AMS.Profile.Profile)ini)
 {
 }