public void Init(string tempalte, string hash) { try { objApp = new Excel.Application(); objBooks = objApp.Workbooks; if (tempalte?.Length == 0) { objBook = objBooks.Add(Missing.Value); } else { tempalte = AppDomain.CurrentDomain.BaseDirectory + "\\Reports\\" + tempalte; objBook = objBooks.Add(tempalte); } } catch (Exception ee) { var li = new LogItem { App = "Apteka.Reports", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "Apteka.Reports.Init" }; CLogJson.Write(li); throw; } }
public void Load(GridView v, string name) { Name = name; try { if (!File.Exists(Vars.RepConfigPath + $"rf{Name}.json")) { return; } var s = Apteka.Utils.CFile.GetFileContents(Vars.RepConfigPath + $"rf{Name}.json"); var config = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GridColunmConfigItem> >(s); v.BeginUpdate(); for (int i = 0; i < config.Count; i++) { var c = v.Columns[config[i].ColunmName]; if (c == null) { return; } if (config[i].IsGroups) { c.GroupIndex = i; } if (config[i].IsAgrs) { c.SummaryItem.FieldName = config[i].ColunmName; c.SummaryItem.SummaryType = config[i].SumType; c.SummaryItem.DisplayFormat = GetNameArg(config[i].SumType); } c.Width = config[i].Width; } } catch (Exception ee) { var li = new LogItem { App = "Apteka.UtilsUI", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "ReportGridForms.ReportGridForms" }; CLogJson.Write(li); } finally { v.EndUpdate(); } }
public static void Export(this List <tbPriceListItem> list, string header) { try { Workbook wb = new Workbook(); var ea = wb.Worksheets[0]; ea.Cells[0, 0].Value = header; ea.Cells[2, 0].Value = "Наименование"; ea.Cells[2, 1].Value = "Наименование (прайс)"; ea.Cells[2, 2].Value = "Производитель"; ea.Cells[2, 3].Value = "Производитель (прайс)"; ea.Cells[2, 4].Value = "Количество"; ea.Cells[2, 5].Value = "Цена"; ea.Cells[2, 6].Value = "Базовая цена"; ea.Cells[2, 7].Value = "Наценка(%)"; ea.Cells[2, 8].Value = "Форма выпуска"; ea.Cells[2, 9].Value = "Срок годности"; int i = 3; foreach (var it in list) { ea.Cells[i, 0].Value = it.Name; ea.Cells[i, 1].Value = it.VendorDrugName; ea.Cells[i, 2].Value = it.Manufacturer; ea.Cells[i, 3].Value = it.VendorManufacturer; ea.Cells[i, 4].Value = it.Qty; ea.Cells[i, 5].Value = it.Price; ea.Cells[i, 6].Value = it.BasePrice; ea.Cells[i, 7].Value = it.ExtraCharge; ea.Cells[i, 8].Value = it.Unit; ea.Cells[i, 9].Value = it.ExpiryDate; i++; } var filename = "1.xls"; ea.Columns.AutoFit(0, 9); wb.SaveDocument(filename, DocumentFormat.Xls); Process.Start(filename); } catch (Exception ee) { var li = new LogItem { App = "Apteka.Reports", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "PriceLoader.Export" }; CLogJson.Write(li); throw; } }
private void RunSql() { var sqlpath = AppDomain.CurrentDomain.BaseDirectory + "dbChange.sql"; if (!File.Exists(sqlpath)) { return; } var connstr = ConfigurationManager.ConnectionStrings["AptekaDBConnectionString"].ConnectionString; var con = new SqlConnection(connstr); string query = File.ReadAllText(sqlpath); var cmd = new SqlCommand(query, con); try { con.Open(); cmd.ExecuteNonQuery(); var li = new LogItem { App = "UpdaterApp", Stacktrace = "", Mestype = "Success", Message = "Column Created Successfully", Method = "RunSql" }; CLogJson.Write(li); } catch (SqlException ee) { var li = new LogItem { App = "UpdaterApp", Stacktrace = ee.StackTrace, Message = ee.Message, Method = "RunSql" }; CLogJson.Write(li); } finally { con.Close(); } }
private void LoadPlugins() { try { var catalog = new DirectoryCatalog(@".\", "*.plg.dll"); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); container.Compose(batch); } catch (Exception ee) { var li = new LogItem { App = "Apteka.Interfaces", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "PluginManager.LoadPlugins" }; CLogJson.Write(li); } }
public bool Connect() { try { this._serialPort.Open(); var res = this.WriteCommand("ATZ"); // && //this.WriteCommand("AT+CSCA=\"+998901850488\", 145"); //this.WriteCommand("AT+CSMS=1"); return(res); } catch (Exception ee) { var li = new LogItem { App = "3G MODEM", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "Connect" }; CLogJson.Write(li); return(false); } }
public PluginManagerSI() { try { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); var catalog = new DirectoryCatalog(@".\", "*.plg.dll"); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); container.Compose(batch); PlgItem?.Initialize(null); } catch (ReflectionTypeLoadException ee) { var li = new LogItem { App = "wsDataBaseSync", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "PluginManagerSI" }; CLogJson.Write(li); } }
private bool WriteCommand(string command, out string receivedData) { this._serialPort.DiscardInBuffer(); this._serialPort.DiscardOutBuffer(); this._receiveAutoResetEvent.Reset(); this._serialPort.Write(command + "\r"); string empty = string.Empty; try { do { if (this._receiveAutoResetEvent.WaitOne(this.ReceiveTimeount, false)) { string str = this._serialPort.ReadExisting(); empty += str; if (!empty.EndsWith("\r\nOK\r\n")) { if (empty.EndsWith("\r\n> ")) { break; } } else { break; } } else { int length = empty.Length; receivedData = string.Empty; return(false); } }while (!empty.EndsWith("\r\nERROR\r\n")); var li = new LogItem { App = "3G MODEM", Mestype = "i", Method = "WriteCommand", Params = $"SEND CMD ==> {command}; RECIVE <== {empty.Replace("\r", "").Replace("\n", " ")}" }; CLogJson.Write(li); } catch (Exception ee) { var li = new LogItem { App = "3G MODEM ERROR", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "WriteCommand" }; CLogJson.Write(li); receivedData = string.Empty; return(false); } int num = empty.EndsWith("\r\nOK\r\n") ? 1 : (empty.EndsWith("\r\n> ") ? 1 : 0); receivedData = empty.Replace("\r\nOK\r\n", string.Empty).Replace("\r\nERROR\r\n", string.Empty).Replace("\r\n> ", string.Empty); return(num != 0); }
private void OnBtnSpListAdd(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { FrmNewSp f; try { if (e.Button.Index == 1) { int i = e.Button.Tag.ToInt(); switch (i) { case 1: var fm = new FrmNewManufacturer(); if (!string.IsNullOrWhiteSpace(drug.PriceManufacturer)) { fm.edName.Text = drug.PriceManufacturer; } if (fm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { cbManufacturer.Properties.DataSource = db.Manufacturer.GetSp(); AlertMessage.Show("Данные успешно сохранены"); } break; case 2: f = new FrmNewSp(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var name = f.edName.Text; if (!string.IsNullOrWhiteSpace(name)) { var ss = new spDrugCategory(); ss.Id = Guid.NewGuid(); ss.Name = name; ss.Status = 1; ss.CreateUser = Vars.UserId; ss.CreateDate = DateTime.Now; db.DrugCategory.Add(ss); db.Complete(); cbDrugCategory.Properties.DataSource = db.DrugCategory.GetSp(); AlertMessage.Show("Данные успешно сохранены"); } } f.Dispose(); break; case 3: f = new FrmNewSp(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var name = f.edName.Text; if (!string.IsNullOrWhiteSpace(name)) { var sc = new spPharmGroup(); sc.Id = Guid.NewGuid(); sc.Name = name; sc.Status = 1; sc.CreateUser = Vars.UserId; sc.CreateDate = DateTime.Now; db.PharmGroup.Add(sc); db.Complete(); cbPharmGroup.Properties.DataSource = db.PharmGroup.GetSp(); AlertMessage.Show("Данные успешно сохранены"); } } f.Dispose(); break; case 4: f = new FrmNewSp(); if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var name = f.edName.Text; if (!string.IsNullOrWhiteSpace(name)) { var su = new spUnit(); su.Name = name; su.Status = 1; su.CreateUser = Vars.UserId; su.CreateDate = DateTime.Now; db.Unit.Add(su); db.Complete(); cbUnit.Properties.DataSource = db.Unit.GetSp(); AlertMessage.Show("Данные успешно сохранены"); } } f.Dispose(); break; } } } catch (System.Exception ee) { var li = new LogItem { App = "Sklad", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "FrmProductList.OnBtnSpListAdd" }; CLogJson.Write(li); AlertMessage.ShowError("Ошибка при сохранении"); } }