public static List <OrderSystem> GetOrdSysListFromServer() { string sql = "select ordSys_Id,ordSys_Name,ordSys_WchExt,ordSys_PrdSubFldr,ordSys_WaitFile,ordSys_WaitIsFldr FROM ordersystems"; List <OrderSystem> list = new List <OrderSystem>(); using (var conn = new MySqlConnection(Set.ConnString)) using (var cmd = new MySqlCommand(sql, conn)) { try { conn.Open(); using (MySqlDataReader rd = cmd.ExecuteReader()) { while (rd.Read()) { var os = new OrderSystem(); os.Id = Convert.ToUInt32(rd[0]); Enum.TryParse(Convert.ToString(rd[1]), out Set.OrdSysName ordSysName); os.Name = ordSysName; os.Ext = Convert.ToString(rd[2]); os.ProductSubFolder = Convert.ToString(rd[3]); os.WaitFile = Convert.ToString(rd[4]); os.WaitIsFolder = Convert.ToBoolean(rd[5]); list.Add(os); } } } catch { MessageBox.Show("Error Connecting to Server"); } } return(list); }
private void but_Update_Click(object sender, EventArgs e) { var webChanged = false; var locChanged = false; if (ordSys.Active != chkBox_Active.Checked || ordSys.WatchedFolder != txtBox_WatchedFolder.Text || ordSys.LabInFldr != txtBox_LabInFolder.Text || ordSys.OutputFolder != txtBox_OutputFolder.Text) { locChanged = true; ordSys.Active = chkBox_Active.Checked; ordSys.WatchedFolder = txtBox_WatchedFolder.Text; ordSys.LabInFldr = txtBox_LabInFolder.Text; ordSys.OutputFolder = txtBox_OutputFolder.Text; } if (ordSys.Ext != txtBox_WchdExt.Text || ordSys.ProductSubFolder != txtBox_ProdSubFldr.Text || ordSys.WaitFile != txtBox_WaitForFile.Text || ordSys.WaitIsFolder != chkBox_WaitFileIsFldr.Checked) { webChanged = true; ordSys.Ext = txtBox_WchdExt.Text; ordSys.ProductSubFolder = txtBox_ProdSubFldr.Text; ordSys.WaitFile = txtBox_WaitForFile.Text; ordSys.WaitIsFolder = chkBox_WaitFileIsFldr.Checked; } if (locChanged) { try { Set.SaveSettings(); } catch { MessageBox.Show("Error saving OrderSystem local settings"); } } if (webChanged) { try { OrderSystem.UpdateOrderSystemOnServer(ordSys); } catch { MessageBox.Show("Error saving OrderSystem web settings"); } } Close(); }
private void fillTextBoxesFromOrdSys(OrderSystem ordSys) { txtBox_OrdSysName.Text = ordSys.Name.ToString(); chkBox_Active.Checked = ordSys.Active; txtBox_WatchedFolder.Text = ordSys.WatchedFolder; txtBox_WchdExt.Text = ordSys.Ext; txtBox_OutputFolder.Text = ordSys.OutputFolder; txtBox_LabInFolder.Text = ordSys.LabInFldr; txtBox_ProdSubFldr.Text = ordSys.ProductSubFolder; txtBox_WaitForFile.Text = ordSys.WaitFile; chkBox_WaitFileIsFldr.Checked = ordSys.WaitIsFolder; Gridview_PukKeyWords.DataSource = ordSys.PuKeyWordList; }
public static void StartStopWatcher(OrderSystem ordSys) { if (ordSys.Active == true) { ordSys.fW.EnableRaisingEvents = true; ordSys.fwActive = true; Data.LogEvents(1, ordSys.Name + " watch started"); } else { ordSys.fW.EnableRaisingEvents = false; ordSys.fwActive = false; Data.LogEvents(1, ordSys.Name + " watch stopped"); } }
public static bool MakeOrdSysList() { OrdSysList = new List <OrderSystem>(); var osNames = Enum.GetValues(typeof(Set.OrdSysName)); UInt32 i = 0; foreach (Set.OrdSysName name in osNames) { if (name.ToString() != "Null") { var os = new OrderSystem(); os.Id = i; os.Name = name; OrdSysList.Add(os); i++; } } return((OrdSysList.Count == 3) ? true : false); }
public static void CreateNewOrderFromDroppedFile(string filePath) { string[] words = filePath.Split('\\'); var droppedFileName = words[words.Length - 1]; var folder = filePath.Substring(0, filePath.Length - (droppedFileName.Length + 1)); var ordSysName = GetOrdSysNameFromFilepath(folder, droppedFileName); if (ordSysName == Set.OrdSysName.Null) { return; } Order order = null; switch (ordSysName) { case Set.OrdSysName.Roes: order = OrderSystem.RoesMakeOrder(filePath, droppedFileName); break; case Set.OrdSysName.Dakis: order = DakisOrder.MakeDakisOrder(droppedFileName); break; case Set.OrdSysName.DGift: //order = DakisReadListFile(fileName); break; case Set.OrdSysName.Null: Data.LogEvents(0, "Unknown filetype " + droppedFileName + " skipped"); break; } var sqlId = Data.SaveOrdertoSqlServer(order); if (sqlId != 0) { return; } //MoveFileToRead(folder, fileName); }
public static void UpdateOrderSystemOnServer(OrderSystem ordSys) { int? count; string sql = "select count(*) FROM ordersystems WHERE ordSys_Id = @ordSysId"; using (var conn = new MySqlConnection(Set.ConnString)) using (var cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@ordSysId", ordSys.Id); conn.Open(); count = Convert.ToInt32(cmd.ExecuteScalar()); } if (count > 0) { sql = "UPDATE ordersystems SET ordSys_Id=@ordSysId, ordSys_Name=@ordSysName, ordSys_WchExt=@ordSysExt, " + "ordSys_PrdSubFldr=@prdSubFldr, ordSys_WaitFile=@waitFile, ordSys_WaitIsFldr=@waitIsFldr " + "WHERE ordSys_Id = @ordSysId"; } else { sql = "INSERT into ordersystems (ordSys_Id, ordSys_Name, ordSys_WchExt, ordSys_PrdSubFldr, ordSys_WaitFile, ordSys_WaitIsFldr )" + " VALUES (@ordSysId, @ordSysName, @ordSysExt, @prdSubFldr, @waitFile, @waitIsFldr)"; } using (var conn = new MySqlConnection(Set.ConnString)) using (var cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.AddWithValue("@ordSysId", ordSys.Id); cmd.Parameters.AddWithValue("@ordSysName", ordSys.Name); cmd.Parameters.AddWithValue("@ordSysExt", ordSys.Ext); cmd.Parameters.AddWithValue("@prdSubFldr", ordSys.ProductSubFolder); cmd.Parameters.AddWithValue("@waitFile", ordSys.WaitFile); cmd.Parameters.AddWithValue("@waitIsFldr", ordSys.WaitIsFolder); conn.Open(); int rowsUpdated = cmd.ExecuteNonQuery(); } }
public static void DoStartUp() { string iniFile = Directory.GetCurrentDirectory() + @"\HotsSavedData.xml"; string connString = "server=69.89.31.188;uid=hitephot_don;database=hitephot_hots;port=3306;password=Hite1985;"; LocalSettings savedSet; List <OrderSystem> webOrdSysList; List <PickupKeyword> pukList; List <Locations> locList; Data.LogEvents(1, "Hots Downloader started"); savedSet = LocalSettings.readSettingsfromDisk(iniFile); Set.SetSettingsFromReadFile(savedSet, iniFile, connString);//fills default inifile & connstring if blank locList = Locations.GetLocationList(); Set.LocList = locList; if (savedSet != null) { Set.ThisLocation = Locations.GetLocById(savedSet.SelectedPickupLocationId); } Set.MakeOrdSysList(); webOrdSysList = OrderSystem.GetOrdSysListFromServer(); while (webOrdSysList.Count < 3) { webOrdSysList.Add(new OrderSystem()); } pukList = PickupKeyword.GetPickupKeyListFromServer(); FillOrdSysProperties(Set.OrdSysList, webOrdSysList, pukList, savedSet); Watchers.MakeFolderWatchers(); }
private void fillKeywordGrid(OrderSystem ordSys) { Gridview_PukKeyWords.DataSource = ordSys.PuKeyWordList; Gridview_PukKeyWords.Columns[0].Visible = false; Gridview_PukKeyWords.Columns[1].Visible = false; }
public frm_UpdOrdSys(OrderSystem _ordSys) { ordSys = _ordSys; InitializeComponent(); }