Пример #1
0
        private void _Parse(object obj)
        {
            CallBackResult result = new CallBackResult();

            try
            {
                List <List <object> > data = (List <List <object> >)obj;

                result.StartPeriodDate = GetStartPeriodDate(data);

                lBase.Transaction();

                int i = 0;
                while (i < data.Count)
                {
                    if (((string)data[i][0]).Equals(Stop_Sheet_Tag))
                    {
                        break;
                    }

                    if (data[i].Find(cell => Convert.ToString(cell).Contains(Subscriber_Start_Tag)) != null)
                    {
                        Subscriber subscriber = new Subscriber()
                        {
                            Number = GetSubscriberNumber(data[i])
                        };

                        if (!String.IsNullOrEmpty(subscriber.Number))
                        {
                            subscriber.Id = lBase.GetSubscriberIdByNumber(subscriber.Number);
                            if (subscriber.Id == 0)
                            {
                                subscriber.Id = lBase.AddSubscriber(subscriber);
                            }

                            if (subscriber.Id == 0)
                            {
                                continue;
                            }

                            i++;
                            while (i < data.Count)
                            {
                                if (data[i].Find(cell => Convert.ToString(cell).Contains(Subscriber_End_Tag)) != null)
                                {
                                    break;
                                }

                                if (data[i].Find(cell => Convert.ToString(cell).Contains(Internet_Tag)) != null)
                                {
                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (FindHeadder(data[i], Internet_Headder) == true)
                                        {
                                            break;
                                        }

                                        i++;
                                    }

                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (data[i].Find(cell => Convert.ToString(cell).Contains(End_Unit_Tag)) != null)
                                        {
                                            break;
                                        }

                                        Connection connection = GetConnection(data[i], DataType.Intertet);

                                        if (connection != null)
                                        {
                                            lBase.AddConnection(subscriber.Id, connection);
                                        }

                                        i++;
                                    }
                                }

                                if (data[i].Find(cell => Convert.ToString(cell).Contains(SMS_Tag)) != null)
                                {
                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (FindHeadder(data[i], SMS_Headder) == true)
                                        {
                                            break;
                                        }

                                        i++;
                                    }

                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (data[i].Find(cell => Convert.ToString(cell).Contains(End_Unit_Tag)) != null)
                                        {
                                            break;
                                        }

                                        Connection connection = GetConnection(data[i], DataType.SMS);

                                        if (connection != null)
                                        {
                                            lBase.AddConnection(subscriber.Id, connection);
                                        }

                                        i++;
                                    }
                                }

                                if (data[i].Find(cell => Convert.ToString(cell).Contains(MMS_Tag)) != null)
                                {
                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (FindHeadder(data[i], MMS_Headder) == true)
                                        {
                                            break;
                                        }

                                        i++;
                                    }

                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (data[i].Find(cell => Convert.ToString(cell).Contains(End_Unit_Tag)) != null)
                                        {
                                            break;
                                        }

                                        Connection connection = GetConnection(data[i], DataType.MMS);

                                        if (connection != null)
                                        {
                                            lBase.AddConnection(subscriber.Id, connection);
                                        }

                                        i++;
                                    }
                                }

                                if (data[i].Find(cell => Convert.ToString(cell).Contains(Phone_Tag)) != null)
                                {
                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (FindHeadder(data[i], Phone_Headder) == true)
                                        {
                                            break;
                                        }

                                        i++;
                                    }

                                    i++;
                                    while (i < data.Count)
                                    {
                                        if (data[i].Find(cell => Convert.ToString(cell).Contains(End_Unit_Tag)) != null)
                                        {
                                            break;
                                        }

                                        Connection connection = GetConnection(data[i], DataType.Phone);

                                        if (connection != null)
                                        {
                                            lBase.AddConnection(subscriber.Id, connection);
                                        }

                                        i++;
                                    }
                                }

                                i++;
                            }
                        }
                    }

                    i++;
                }

                result.Result = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            lBase.Commit();

            resultListener?.Invoke(result);
        }
Пример #2
0
 //Асинхронный метод, передающий результат в вызывающий класс
 private CallBackResult CallBack(CallBackResult result)
 {
     return(result);
 }