示例#1
0
        public void IniWrite()
        {
            string file = Path + "\\" + account + ".ini";

            FileStream tmp = File.Create(file.Replace(".ini", ".tmp"));

            FileStream ini;

            if (!File.Exists(file))
            {
                ini = File.Create(file);
                ini.Dispose();
            }

            AMS.Profile.Ini Init = new AMS.Profile.Ini(file);
            try
            {
                Init.SetValue("ROSTELECOM", "account", this.account);
                Init.SetValue("ROSTELECOM", "phone", this.phone);
                Init.SetValue("ROSTELECOM", "inn", this.inn);
                Init.SetValue("ROSTELECOM", "korobka", this.korobka);
                Init.SetValue("ROSTELECOM", "name", this.name);
                Init.SetValue("ROSTELECOM", "typedoc", this.typedoc);
                Init.SetValue("ROSTELECOM", "pagecount", this.pagecount);
            }
            catch
            {
            }

            tmp.Dispose();
            File.Delete(file.Replace(".ini", ".tmp"));
        }
示例#2
0
 public void WriteIni()
 {
     AMS.Profile.Ini Init = new AMS.Profile.Ini(Application.StartupPath + "\\" + "AbonentPacket.ini");
     Init.SetValue("FOLDERS", "JpegFiles", _FolderJpegFiles);
     Init.SetValue("FOLDERS", "WorkFiles", _FolderWorkFiles);
     Init.SetValue("EARCHIVE", "UserID", this._UserID);
     Init.SetValue("EARCHIVE", "DepartID", this._DepartID);
     Init.SetValue("EARCHIVE", "FormUser", this._User);
     Init.SetValue("EARCHIVE", "Korobka", this._Korobka);
 }
        void IExport.Run()
        {
            try
            {
                this.theLogger.Log("Export:Run");
                AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "AgkExportSettings.ini");
                if (!Ini.HasSection("COMMON"))
                {
                    Ini.SetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК");
                    Ini.SetValue("COMMON", "CountPrevMonth", "1");
                }

                string strAgkDataFolder = Ini.GetValue("COMMON", "AgkDataFolder", "C:\\Данные_АГК");
                int    countPrevMonth   = Ini.GetValue("COMMON", "CountPrevMonth", 1);

                strAgkDataFolder.TrimEnd(new char[] { '\\' });

                if (!Directory.Exists(strAgkDataFolder))
                {
                    Directory.CreateDirectory(strAgkDataFolder);
                }

                Hydro.HydroServiceClient theHydro = new Hydro.HydroServiceClient("BasicHttpBinding_IHydroService");
                const int TYPE_AGK = 6;
                foreach (var Site in theHydro.GetSiteList(TYPE_AGK))
                {
                    string strSiteFolder = strAgkDataFolder + "\\" + Site.SiteCode.ToString();
                    if (!Directory.Exists(strSiteFolder))
                    {
                        Directory.CreateDirectory(strSiteFolder);
                        theLogger.Log(strSiteFolder);
                    }

                    strSiteFolder = strSiteFolder + "\\уровни";
                    if (!Directory.Exists(strSiteFolder))
                    {
                        Directory.CreateDirectory(strSiteFolder);
                        theLogger.Log(strSiteFolder);
                    }
                    DateTime bgnDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year,
                                                    DateTime.Now.AddMonths(-countPrevMonth).Month, countPrevMonth);
                    DateTime endDate = new DateTime(DateTime.Now.AddMonths(-countPrevMonth).Year,
                                                    DateTime.Now.AddMonths(-countPrevMonth).Month,
                                                    DateTime.DaysInMonth(DateTime.Now.AddMonths(-countPrevMonth).Year, DateTime.Now.AddMonths(-countPrevMonth).Month));
                    const int WATER_LEVEL = 2;

                    string strFileName = strSiteFolder + "\\" + Site.SiteCode.ToString() + "_" + bgnDate.ToString("yyyy_MM") + ".asc";
                    theLogger.Log(strFileName);
                    var fileHandle    = File.CreateText(strFileName);
                    var DataValueList = theHydro.GetDataValues(Site.SiteId, bgnDate, endDate, WATER_LEVEL, null, null, null);
                    if (DataValueList != null)
                    {
                        foreach (var item in DataValueList)
                        {
                            string line = item.Date.ToString("dd.MM.yyyy hh:mm:ss") + "\t" + item.Value.ToString() + "\tсм";
                            fileHandle.WriteLine(line);
                        }
                    }
                    fileHandle.Close();
                    //for (DateTime currDate = bgnDate; currDate <= endDate; currDate.AddDays(1))
                    //{
                    //    var DataValueList = theHydro.GetDataValues(Site.SiteId, TYPE_AGK, currDate, WATER_LEVEL, null, null);
                    //    foreach (var item in DataValueList)
                    //    {

                    //    }
                    //}
                }


                this.theLogger.Log(strAgkDataFolder);
            }
            catch (Exception ex)
            {
                this.theLogger.Error(ex.Message);
                this.theLogger.Error(ex.Source);
                this.theLogger.Error(ex.StackTrace);
            }
        }
        public ActionResult Telephone(string telephone)
        {
            try
            {
                AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "\\Callback.ini");
                if (!Ini.HasSection("SMSC"))
                {
                    Ini.SetValue("SMSC", "login", "mgerasim");
                    Ini.SetValue("SMSC", "psw", "zaq12wsx");
                }


                string login = Ini.GetValue("SMSC", "login", "some-login");
                string psw   = Ini.GetValue("SMSC", "psw", "some-password");

                string code = this.RandomString(4);
                string url  = "http://smsc.ru/sys/send.php?login="******"&psw=" + psw + "&phones=" + telephone + "&mes=" + code;

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

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

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


                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;

                CallbackAspDotNetMvc.Models.User theUser = null;
                theUser = Models.User.GetByPhone(telephone);
                if (theUser == null)
                {
                    theUser           = new Models.User();
                    theUser.code      = code;
                    theUser.telephone = telephone;
                    theUser.result    = responseString;
                    theUser.Save();
                }
                else
                {
                    theUser.code   = code;
                    theUser.result = responseString;
                    theUser.Update();
                }

                var resultData = new { telephone = telephone, 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;


                string err = ex.Message;
                if (ex.InnerException != null)
                {
                    err += ex.InnerException.Message;
                }

                var resultData = new { telephone = telephone, error = err };
                var result     = new ContentResult
                {
                    Content     = serializer.Serialize(resultData),
                    ContentType = "application/json"
                };
                return(result);
            }
            return(View());
        }