Esempio n. 1
0
        private static void TestComagickLogin()
        {
            //Console.WriteLine("Testing Comagic login... '{0}'-'{1}'", Config.Comagic.Login, Config.Comagic.Password);
            Console.WriteLine("Testing Comagic login...");
            Comagic.Api x = new Comagic.Api(Config.Comagic.Login, Config.Comagic.Password);
            Console.WriteLine("Done.");

            // read calls 27.01.2015 14:58:50
            Console.WriteLine("trying to search calls...");
            DateTime from = new DateTime(2015, 1, 27, 15, 2, 0);
            DateTime to = from + TimeSpan.FromMinutes(1);
            var calls = x.GetCalls(from, to);
            Console.WriteLine("Done. Found {0} call(s)", calls.Count);

            Console.WriteLine("Performing logout...");
            x.Logout();
            Console.WriteLine("Done");
        }
Esempio n. 2
0
        private static List<Comagic.Call> GetComagicCalls(DateTime readFrom, DateTime readTill, bool doFiltering)
        {
            string cmLogin = Config.Comagic.Login;
            string cmPassword = Config.Comagic.Password;

            LogWriter.Info(String.Format("Performing login to Comagic as '{0}'", cmLogin));

            Comagic.Api cmApi = new Comagic.Api(cmLogin, cmPassword);

            LogWriter.Info(String.Format("Fetching calls between {0} and {1} (Moskow)", readFrom, readTill));

            List<Comagic.Call> calls = cmApi.GetCalls(readFrom, readTill);
            cmApi.Logout();

            LogWriter.Info(String.Format("{0} call(s) total", calls.Count));

            List<Comagic.Call> workList = new List<Comagic.Call>();
            foreach (var call in calls)
            {
                if (Config.NotForMegaplan(call.ToNumber))
                {
                    LogWriter.Info(String.Format("Звонок на номер {0} не для мегаплана", call.ToNumber));
                }
                else
                {
                    workList.Add(call);
                }
            }

            // sort by date to be sure 100% that the order is correct
            workList.Sort(delegate(Comagic.Call x, Comagic.Call y)
            {
                return x.CallDate.CompareTo(y.CallDate);
            });

            return workList;
        }