/// <summary> /// Самодельный мапер /// </summary> /// <param name="item"></param> /// <returns></returns> private SS_FlInfo CustomMapper(FLInfo item) { Int32.TryParse(item.House, out int house); Int32.TryParse(item.Apartment, out int apartment); Int32.TryParse(item.House2, out int house2); Int32.TryParse(item.Counter1Info, out int counter1Info); Int32.TryParse(item.Counter2Info, out int counter2Info); Int32.TryParse(item.Counter3Info, out int counter3Info); return(new SS_FlInfo { C_Guid = Guid.NewGuid(), N_ChetNumber = item.ChetNumber, C_Region = item.Region, C_City = item.City, C_Street = item.Street, C_House = item.House, N_House = GetNullableInteger(house), C_House2 = item.House2, N_House2 = GetNullableInteger(house2), C_HouseCase = item.HouseCase, C_Apartment = item.Apartment, N_Apartment = GetNullableInteger(apartment), C_Room = item.Room, B_Pribor = item.IsPribor, C_Counter1 = item.Counter1.Replace(@"xFC", "№"), N_Counter1_Info = GetNullableInteger(counter1Info), C_Counter2 = item.Counter2.Replace(@"xFC", "№"), N_Counter2_Info = GetNullableInteger(counter2Info), C_Counter3 = item.Counter3.Replace(@"xFC", "№"), N_Counter3_Info = GetNullableInteger(counter3Info), C_Saldo = item.Saldo }); }
public static FLInfo GetFLInfo() { FLInfo i = new FLInfo(); //Get title string fullTitle; if (Process.GetProcessesByName("FL").Length >= 1) { fullTitle = Processes.GetMainWindowsTilteByProcessName("FL"); } else if (Process.GetProcessesByName("FL64").Length >= 1) { fullTitle = Processes.GetMainWindowsTilteByProcessName("FL64"); } else { fullTitle = null; } // Check if project is new/unsaved //if yes, return null //if not, return name if (!fullTitle.Contains("-")) { i.projectName = null; i.appName = fullTitle; } else { string[] splitbyminus = fullTitle.Split('-'); i.projectName = splitbyminus[0]; i.appName = splitbyminus[1]; } //return return(i); }
public static void Start() { Active = true; // loop Csecret = settings.Secret; while (client != null && Active) { // Get info FLInfo InitInfo = GetFLInfo(); // Try to read any keys if available if (Console.In.Peek() != -1) { switch (Console.ReadKey(true).Key) { case ConsoleKey.H: Console.WriteLine("Commands: \n s: turn on secret mode \n q: Quit \n h: help \n Other settings can be changed in the settings.xml file"); break; case ConsoleKey.S: if (Csecret) { Csecret = false; Console.WriteLine("\n Secret Mode turned off!"); rp.State = InitInfo.projectName; } else if (!Csecret) { Csecret = true; Console.WriteLine("\n Secret Mode turned on!"); rp.State = settings.SecretMessage; } break; case ConsoleKey.Q: StopAndExit(); break; } } if (client != null) { client.Invoke(); } //Skip update if nothing changes if (InitInfo.appName == rp.Details && InitInfo.projectName == rp.State && Csecret == Psecret) { continue; } if (InitInfo.projectName == null && rp.State == settings.NoNameMessage && Csecret == Psecret) { continue; } //Fill State and details if (InitInfo.projectName == null) { rp.State = settings.NoNameMessage; rp.Details = InitInfo.appName; } else { rp.Details = InitInfo.appName; rp.State = InitInfo.projectName; } if (Csecret) { rp.State = settings.SecretMessage; } Psecret = Csecret; client.SetPresence(rp); Thread.Sleep(settings.RefeshInterval); } }