private void frmConfiguration_Load(object sender, EventArgs e) { ApplicationConfigManagement acm = new ApplicationConfigManagement(); TxtOutllokAccount.Text = acm.ReadSetting("OutlookAccount"); TxtTestPhoneNumber.Text = acm.ReadSetting("TestPhone"); TxtTestMessageBody.Text = acm.ReadSetting("TestMessage"); }
//private void LoadGSMModem() //{ // try // { // CmbPortName.Items.Clear(); // string[] ports = SerialPort.GetPortNames(); // foreach (string port in ports) // CmbPortName.Items.Add(port); // CmbPortName.SelectedIndex = 0; // } // catch (Exception ex) // { // logger.ErrorLog(ex.Message); // } //} private void frmTestSendSMS_Load(object sender, EventArgs e) { ApplicationConfigManagement acm = new ApplicationConfigManagement(); textBox1.Text = acm.ReadSetting("TestMessage"); textBox2.Text = acm.ReadSetting("TestPhone"); //LoadGSMModem(); }
public bool Open() { //GsmCommMain comm = null; Close(); bool chk = false; try { try { if (GSMport.Length == 0) { ApplicationConfigManagement acm = new ApplicationConfigManagement(); GSMport = acm.ReadSetting("GSMport"); if (GSMport.Length > 0) { comm = new GsmCommMain(GSMport, 19200, 500); comm.Open(); return(true); } } } catch (Exception) { ; } string[] ports = SerialPort.GetPortNames(); foreach (string port in ports) { try { comm = new GsmCommMain(port, 19200, 500); comm.Open(); SmsSubmitPdu[] pdu = SmartMessageFactory.CreateConcatTextMessage("تست سلامت جی اس ام Port:" + port, true, "09195614157"); comm.SendMessages(pdu); chk = true; GSMport = port; AddUpdateAppSettings("GSMport", GSMport); logger.ErrorLog("Valid Port of GSM is : " + GSMport); //Close(ref comm); break; } catch (Exception err) { Close(); //ref comm } } } catch (Exception ex) { logger.ErrorLog("هیچ پورتی وجود ندارد..."); } if (!chk) { logger.ErrorLog("خطای ارتباط با مودم .... \n\r لطفا از ارتباط مودم با سیستم اطمینان حاصل نمایید...."); } return(chk); }
private void InitializeOutlookObjects() { try { /*You can Use one of these lines*/ //ns = OutlookApp.GetNamespace("mapi"); ns = OutlookApp.Session; //CurrentProfileName = ns.CurrentProfileName; //CurrentUser = ns.CurrentUser; foreach (Outlook.Account account in ns.Accounts) { CurrentAccounts.Add(account.SmtpAddress); } ApplicationConfigManagement acm = new ApplicationConfigManagement(); //string usrName = acm.ReadSetting("OutlookAccount").ToLower(); //if (acm.ReadSetting("OutlookProfile").ToLower() != CurrentProfileName.ToLower()) //{ // MessageBox.Show("تنظیمات Outlook شما مشکل دارد...", "پیغام خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign, true); // System.Environment.Exit(0); //} if (CurrentAccounts.IndexOf(acm.ReadSetting("OutlookAccount").ToLower()) != -1) { MessageBox.Show("تنظیمات Outlook شما مشکل دارد...", "پیغام خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign, true); System.Environment.Exit(0); } Thread th = new Thread(new ThreadStart(this.FillAppointments)); th.Start(); Thread th1 = new Thread(new ThreadStart(this.FillContacts)); th1.Start(); //FillAppointments(); //FillContacts(); } catch (Exception err) { MessageBox.Show(string.Format("Error instantiating outlook\n {0}", err.Message)); } }
private void button4_Click(object sender, EventArgs e) { string SourceFilesPath = Application.StartupPath + "\\PatientRecordTemplates\\"; ApplicationConfigManagement acm = new ApplicationConfigManagement(); try { string PatientRecordsPath = acm.ReadSetting("PatientRecords"); string fileName = selectedContact.PatientID; string FileFullPath = ""; if (selectedContact.DiseaseName == "غدد") { SourceFilesPath += "E.Docx"; fileName += "E.Docx"; } else { SourceFilesPath += "D.Docx"; fileName += "D.Docx"; } FileFullPath = PatientRecordsPath + "\\" + fileName; if (!File.Exists(FileFullPath)) { File.Copy(SourceFilesPath, FileFullPath); cls_WordManagement cls_WordManagement = new cls_WordManagement(); cls_WordManagement.ChangeHeaderInfo(selectedContact, FileFullPath); System.Diagnostics.Process.Start(FileFullPath); } else { System.Diagnostics.Process.Start(FileFullPath); } } catch (Exception) { MessageBox.Show("لطفا یکی از بیماران لیست شده را با Double Click انتخاب کنید تا امکان مشاهده پرونده پزشکی بیمار انتخاب شده را دشاته باشید...", "پیغام خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign, true); } }
public string SendSMS(string bodyStr, string Phone, ref bool SendStatus) { bool sendStatus = false; Thread.Sleep(10000); string ReturnStr = ""; string ResultStr = ""; string SMSCPanelStr = acm.ReadSetting("SMSCPanel").ToLower(); //SMSCPanelStr = "false"; string GSMPanelStr = acm.ReadSetting("GSMPanel").ToLower(); string Signeture = acm.ReadSetting("Signeture"); int Result = 0; if (SMSCPanelStr.ToLower() == "true") { Result = sendSMS.Send(Signeture, Phone, bodyStr, ref ResultStr); try { string[] ResultStrNodes = ResultStr.Split(';'); ReturnStr = "وضعیت ارسال با پنل:"; switch (ResultStrNodes[1]) { case "0": ReturnStr += "موفق "; break; case "1": ReturnStr += "ناموفق "; break; case "2": ReturnStr += "خطا "; break; case "3": ReturnStr += "بلک لیست "; break; } ReturnStr += " --- "; } catch (Exception) { ReturnStr = ""; } switch (Result) { case -1: ReturnStr += "امضاء معتبر نیست"; break; case 0: ReturnStr += "ارسال نشد"; break; case 2: ReturnStr += "پیامک معتبر نیست"; break; case 3: ReturnStr += "هیچ شماره موبایلی موجود نیست"; break; case 4: ReturnStr += "فیلتر میباشد"; break; case 5: ReturnStr += "اوپراتور قطع است"; //MessageBox.Show("سرویس ارسال پیامک برای این اپراتوع قطع است . لطفا بعدا تلاش فرمایید..."); break; case 6: ReturnStr += "ارسال مجاز نیست"; break; case 7: ReturnStr += "حساب کاربری غیرفعال است"; break; case 8: ReturnStr += "اعتبار تمام شده است"; MessageBox.Show("اعتبار سرویس شما تمام شده است لطفا آن را شارژ کنید..."); break; case 9: ReturnStr += "محدودیت در تعداد درخواست"; break; case 10: ReturnStr += "محدودیت ارسال روزانه"; break; case 11: ReturnStr += "شماره پیانک معتبر نیست"; break; case 12: ReturnStr += "خطا"; break; case 13: ReturnStr += "حساب کاربری منقضی شده است"; break; case 14: ReturnStr += "باید به پنل لاگین کرد"; break; default: logger.ErrorLog(string.Format("ParsGreen Send SMS . Phone:{0} BodyText:{1} Error:{2}", Phone, bodyStr, Result)); break; } } else { ReturnStr += " اجازه ارسال با پنل اینترنتی داده نشده است. "; } if (Result != 1 && IsPortOpen) { if (GSMPanelStr.ToLower() == "true") { ReturnStr += SendSMSWithGSM(bodyStr, Phone, ref sendStatus); } else { ReturnStr += " اجازه ارسال با گوشی محلی داده نشده است. "; } } else if (Result == 1) { ReturnStr += "از طریق پنل ارسال شد"; sendStatus = true; } else { ReturnStr += "خطایی در ارسال از طریق پنل و گوشی پیش آمده. لطفا سیستم را مجددا اجرا نمایید..."; //sendStatus = true; } SendStatus = sendStatus; return(ReturnStr); }
private void FillAppointments() { DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); string todayENCulture = today.AddDays(-1).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); DateTime todayOneYearLater = today.AddYears(1);// new DateTime(DateTime.Now.Year + 1, DateTime.Now.Month, DateTime.Now.Day); appointments.Clear(); Outlook.MAPIFolder mAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Outlook.Items items = mAPIFolder.Items; items.Sort("[Start]", true); ApplicationConfigManagement acm = new ApplicationConfigManagement(); string dateCultureFormat = acm.ReadSetting("DateCultureFormat").ToLower(); string filterStr = ""; if (dateCultureFormat == "d") { CultureInfo culture = new CultureInfo("EN-en"); filterStr = "[Start] >= '" + today.AddYears(-1).ToString("dd/MM/yyyy", culture) + "'"; } else if (dateCultureFormat == "g") { filterStr = "[Start] >= '" + today.AddYears(-1).ToString("g") + "'"; } Outlook.Items FilteredItems = items.Restrict(filterStr); DateTime lastAppointmentDate = FilteredItems.GetFirst().Start; for (DateTime SlotDateTime = today; SlotDateTime < today.AddDays(7); SlotDateTime = SlotDateTime.AddMinutes(10)) { string startDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); AppointmentInitialDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); cls_Appointment appointment; try { appointment = appointments.Single(m => m.StartDateTimeStr == startDate); int kk = 0; } catch (Exception) { appointment = new cls_Appointment(); appointment.StartDateTimeStr = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.EndDateTimeStr = SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.StartDateTime = SlotDateTime; appointment.EndDateTime = SlotDateTime.AddMinutes(10); appointment.Subject = " "; appointment.Paid = " "; appointment.Date = new DateTime(SlotDateTime.Year, SlotDateTime.Month, SlotDateTime.Day); appointment.DateStr = appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointments.Add(appointment); } } foreach (Outlook.AppointmentItem item in FilteredItems) { try { //if (item.Start < today) // continue; CultureInfo culture1 = new CultureInfo("EN-en"); string kk = item.Start.ToString(culture1); string appointmentDate = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); AppointmentInitialDate = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); TimeSpan temptsp = today - item.Start; if (temptsp.TotalSeconds > 0) { break; } cls_Appointment appointment; try { appointment = appointments.Single(m => m.StartDateTimeStr == appointmentDate); if (item.Subject != null) { appointment.Subject = item.Subject; } if (item.Location != null) { appointment.Paid = item.Location; } } catch (Exception) { appointment = new cls_Appointment(); appointment.StartDateTimeStr = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.EndDateTimeStr = item.Start.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.StartDateTime = item.Start; appointment.EndDateTime = item.Start.AddMinutes(10); appointment.Subject = " "; appointment.Paid = " "; appointment.Date = new DateTime(item.Start.Year, item.Start.Month, item.Start.Day); appointment.DateStr = appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointments.Add(appointment); } } catch (Exception) { if (item.Subject.ToLower().IndexOf("birthday") != -1) { item.Delete(); } ; } } for (DateTime SlotDateTime = today; SlotDateTime < todayOneYearLater; SlotDateTime = SlotDateTime.AddMinutes(10)) { string startDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); AppointmentInitialDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); cls_Appointment appointment; try { appointment = appointments.Single(m => m.StartDateTimeStr == startDate); } catch (Exception) { appointment = new cls_Appointment(); appointment.StartDateTimeStr = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.EndDateTimeStr = SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.StartDateTime = SlotDateTime; appointment.EndDateTime = SlotDateTime.AddMinutes(10); appointment.Subject = " "; appointment.Paid = " "; appointment.Date = new DateTime(SlotDateTime.Year, SlotDateTime.Month, SlotDateTime.Day); appointment.DateStr = appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointments.Add(appointment); } } foreach (Outlook.AppointmentItem item in FilteredItems) { try { //if (item.Start < today) // continue; CultureInfo culture1 = new CultureInfo("EN-en"); string kk = item.Start.ToString(culture1); string appointmentDate = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); AppointmentInitialDate = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); cls_Appointment appointment; try { appointment = appointments.Single(m => m.StartDateTimeStr == appointmentDate); if (item.Subject != null) { appointment.Subject = item.Subject; } if (item.Location != null) { appointment.Paid = item.Location; } } catch (Exception) { appointment = new cls_Appointment(); appointment.StartDateTimeStr = item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.EndDateTimeStr = item.Start.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + item.Start.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); appointment.StartDateTime = item.Start; appointment.EndDateTime = item.Start.AddMinutes(10); appointment.Subject = " "; appointment.Paid = " "; appointment.Date = new DateTime(item.Start.Year, item.Start.Month, item.Start.Day); appointment.DateStr = appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); if (item.Subject != null) { appointment.Subject = item.Subject; } if (item.Location != null) { appointment.Paid = item.Location; } appointments.Add(appointment); } } catch (Exception) { if (item.Subject.ToLower().IndexOf("birthday") != -1) { item.Delete(); } ; } } //for (DateTime SlotDateTime = today.AddYears(-1); SlotDateTime < today; SlotDateTime = SlotDateTime.AddMinutes(10)) //{ // string startDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); // AppointmentInitialDate = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern); // cls_Appointment appointment; // try // { // appointment = appointments.Single(m => m.StartDateTimeStr == startDate); // } // catch (Exception) // { // appointment = new cls_Appointment(); // appointment.StartDateTimeStr = SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); // appointment.EndDateTimeStr = SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + SlotDateTime.AddMinutes(10).ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); // appointment.StartDateTime = SlotDateTime; // appointment.EndDateTime = SlotDateTime.AddMinutes(10); // appointment.Subject = " "; // appointment.Paid = " "; // appointment.Date = new DateTime(SlotDateTime.Year, SlotDateTime.Month, SlotDateTime.Day); // appointment.DateStr = appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortDatePattern) + " " + appointment.Date.ToString(CultureInfo.GetCultureInfo("en-EN").DateTimeFormat.ShortTimePattern); // appointments.Add(appointment); // } //} if (mAPIFolder != null) { Marshal.ReleaseComObject(mAPIFolder); } if (items != null) { Marshal.ReleaseComObject(items); } if (FilteredItems != null) { Marshal.ReleaseComObject(FilteredItems); } }
public bool UpdateAppointment(cls_Appointment oldAppointment, cls_Appointment newAppointment) { try { Outlook.MAPIFolder mAPIFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Outlook.Items items = mAPIFolder.Items; items.Sort("[Start]"); ApplicationConfigManagement acm = new ApplicationConfigManagement(); string dateCultureFormat = acm.ReadSetting("DateCultureFormat").ToLower(); string filterStr = ""; if (dateCultureFormat == "d") { CultureInfo culture = new CultureInfo("EN-en"); string StartStr = oldAppointment.StartDateTime.ToString("dd/MM/yyyy", culture); string EndStr = oldAppointment.StartDateTime.AddDays(1).ToString("dd/MM/yyyy", culture); filterStr = "[Start] >= '" + StartStr + "' AND [End] < '" + EndStr + "'"; } else if (dateCultureFormat == "g") { filterStr = "[Start]='" + oldAppointment.StartDateTime.ToString("g") + "'"; } //Outlook.AppointmentItem appointment = items.Find(filterStr); Outlook.Items appointments = items.Restrict(filterStr); foreach (Outlook.AppointmentItem appointment in appointments) { if (appointment != null && appointment.Subject == oldAppointment.Subject) { appointment.Subject = newAppointment.Subject; appointment.Location = newAppointment.Paid; appointment.Save(); oldAppointment.Subject = newAppointment.Subject; oldAppointment.Paid = newAppointment.Paid; if (mAPIFolder != null) { Marshal.ReleaseComObject(mAPIFolder); } if (items != null) { Marshal.ReleaseComObject(items); } if (appointment != null) { Marshal.ReleaseComObject(appointment); } return(true); } else { } } Outlook.AppointmentItem AddnewAppointment = items.Add(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem; AddnewAppointment.Start = newAppointment.StartDateTime; AddnewAppointment.End = newAppointment.EndDateTime; AddnewAppointment.Subject = newAppointment.Subject; AddnewAppointment.Location = newAppointment.Paid; AddnewAppointment.Save(); oldAppointment.Subject = newAppointment.Subject; oldAppointment.Paid = newAppointment.Paid; if (mAPIFolder != null) { Marshal.ReleaseComObject(mAPIFolder); } if (items != null) { Marshal.ReleaseComObject(items); } if (AddnewAppointment != null) { Marshal.ReleaseComObject(AddnewAppointment); } return(true); } catch (Exception err) { logger.ErrorLog("Update Conact Info : " + err.Message); return(false); } return(false); }