Exemplo n.º 1
0
        //internal void UpdateStatuses(MySqlKannelManager msm, ChangeProgressNotifier changeProgressDel)
        //{
        //    if (msm == null)
        //        return;
        //    if(IsEmpty)
        //        return;
        //    Dictionary<string, TargetInfo> fastStorage = new Dictionary<string,TargetInfo>(rcvList.Count);
        //    foreach(TargetInfo ti in rcvList)
        //    {
        //        fastStorage.Add(ti.phoneNumber, ti);
        //    }
        //    msm.GetDlrMessages();
        //    int updatedCnt = 0;
        //    for (int i = 0; i < msm.MsgList.Count; i++ )
        //    {
        //        SqlDataContainer sqdc = msm.MsgList[i];
        //        int dlrmask = int.Parse(sqdc[SqlBoxColId.dlr_mask]);
        //        if (fastStorage.ContainsKey(sqdc[SqlBoxColId.receiver]))
        //        {
        //            fastStorage[sqdc[SqlBoxColId.receiver]].dlr = (DLRStatus)dlrmask;
        //            updatedCnt++;
        //        }
        //        if (changeProgressDel != null)
        //            changeProgressDel.Invoke((int)((((double)i / (double)msm.MsgList.Count)) * 100));
        //    }
        //}
        internal void UpdateStatuses(MySqlKannelManager msm, ChangeProgressNotifier changeProgressDel)
        {
            if (msm == null)
                return;
            if (IsEmpty)
                return;

            msm.GetDlrMessages();
            Dictionary<string, SqlDataContainer> fastStorage = new Dictionary<string, SqlDataContainer>(msm.MsgList.Count);

            foreach (SqlDataContainer ans in msm.MsgList)
            {
                fastStorage[ans[SqlBoxColId.receiver]] = ans;
            }

            int updatedCnt = 0;

            for (int i = 0; i < rcvList.Count; i++)
            {
                SqlDataContainer sqdc;
                if (fastStorage.TryGetValue(rcvList[i].phoneNumber, out sqdc))
                {
                    int dlrmask = int.Parse(sqdc[SqlBoxColId.dlr_mask]);
                    rcvList[i].dlr = (DLRStatus)dlrmask;
                    updatedCnt++;
                }
                else
                {
                    if (rcvList[i].preStatus == MessageStatus.Accepted || rcvList[i].preStatus == MessageStatus.Sent)
                        rcvList[i].dlr = DLRStatus.DeliveredToPhone;
                }
                if (changeProgressDel != null)
                    changeProgressDel.Invoke((int)((((double)i / rcvList.Count)) * 100));

            }
            changeProgressDel.Invoke(0);
        }
Exemplo n.º 2
0
 internal void AddMessageList(ExcelMessageList curES, ChangeProgressNotifier changeProgressDel)
 {
     int row = Settings.Default.list_row, col = Settings.Default.list_col;
     changeProgressDel(0);
     List<string> header = new List<string>();
     if (paramList.Count != 0)
         header.AddRange(curES.GetRange(row, col, row, col + (int)paramList.Count));
     else
         header.Add(curES.GetSingleValue(row, col));
     int vrow = row+1;
     int numIdx = (int)header.IndexOf("num")+1;
     int parIdx;
     do {
         TargetInfo ti = new TargetInfo();
         if (!MassMsgStorage.CheckNumber(curES.GetSingleValue(vrow, numIdx), ref ti.phoneNumber))
         {
             ti.preStatus = MessageStatus.IncorrectNumber;
         }
         if (ti.phoneNumber == String.Empty)
             break;
         foreach(string s in paramList)
         {
             parIdx = header.IndexOf(s);
             if (parIdx<0)
                 throw new Exception("There is no necessary variable in the list");
             string paramVal = curES.GetSingleValue(vrow, parIdx + 1);
             if (translitEnabled)
                 paramVal = Translit.Convert(paramVal);
             ti.paramList.Add(paramVal);
         }
         //ti.message = String.Format(templateStringCS, ti.paramList.ToArray());
         ti.message = templateStringCS;
         //if (ti.status == MessageStatus.IncorrectNumber)
         //    reportAdded(ti.phoneNumber, ti.paramList[0], ti.message, ti.status.ToString());
         rcvList.Add(ti);
         vrow++;
     } while (true);
     changeProgressDel(100);
 }