private static void SyncCategories(ServiceReference2.StaticClient b, User user)
        {
            var typeTrans = b.GetAllTypeTransactionReasons(user.UserId);
            var cats = b.GetAllCategories(user.UserId);

            var catList = new List<Category>();

            var cat1 = cats[0];
            cat1.CategoryId = 0;
            cat1.Name = "ys1";
            cat1.TypeTransactionReasons = new List<TypeTransactionReason> { typeTrans.FirstOrDefault(x => x.Name == "Other") };
            cat1.ModifiedDate = DateTime.Now;
            
            var cat2 = cats[1];
            cat2.CategoryId = -1;
            cat2.Name = "ys2";
            cat2.TypeTransactionReasons = new List<TypeTransactionReason> { 
                                                            typeTrans.FirstOrDefault(x => x.Name == "Other"),
                                                            typeTrans.FirstOrDefault(x => x.Name != "Other")};
            cat2.ModifiedDate = DateTime.Now;

            catList.AddRange(new List<Category> { cat1, cat2 });
            //catList.AddRange(new List<Category> { cat1});

            b.SyncCategories(catList);
        }
 void service_SelectDonationsByUserIdCompleted(object sender, ServiceReference2.SelectDonationsByUserIdCompletedEventArgs e)
 {
     foreach (DonatiiDetalii donatiaMea in e.Result)
     {
         Donatie don = new Donatie(donatiaMea.Data.ToString(), donatiaMea.NumeCampanie, (float)donatiaMea.SumaBani,donatiaMea.Probleme,donatiaMea.numeJudet,donatiaMea.numeOcol,donatiaMea.DonationId);
         mainStackPanel.Children.Add(don);
     }
 }
Beispiel #3
0
 void service_SelectDonatiiComentariiByDonatieCompleted(object sender, ServiceReference2.SelectDonatiiComentariiByDonatieCompletedEventArgs e)
 {
     foreach (ComentariiDonatiiType comment in e.Result)
     {
         Comentariu ComentariuControl = new Comentariu(comment.TextComentariu, comment.Data.ToString(), comment.Usr, comment.Poza);
         detaliiComentariiStackPanel.Children.Add(ComentariuControl);
         detaliiComentariiStackPanel.Height += 122;
     }
     AddCommentControl CommentToAdd = new AddCommentControl(null,2);
     detaliiComentariiStackPanel.Children.Add(CommentToAdd);
     CommentToAdd.idCampanieTextBlock.Text = idDonatie.ToString();
     detaliiComentariiStackPanel.Height += 135;
 }
        //void service_SelectCampanieByIdCompleted(object sender, SelectCampanieByIdCompletedEventArgs e)
        //{
        //    Campanie C = e.Result;
        //    MessageBox.Show(C.dateIncaput);
        //}

        void sevice_SelectCampaignsCompleted(object sender, ServiceReference2.SelectCampaignsCompletedEventArgs e)
        {
            
            List<bing.ServiceReference2.Real> Camp = e.Result.ToList<bing.ServiceReference2.Real>();
            for (int i = 0; i < Camp.Count; i++)
            {
                String[] Foto= new String[10];
                int j = 0;
                for (int k = 0; k < 10; k++)
                {
                    switch (i)
                    {
                        case 0:
                                Foto[j++] = Camp[i].Imag1;break;
                        case 1:
                                Foto[j++] = Camp[i].Imag2;break;
                        case 2:
                                Foto[j++] = Camp[i].Imag3;break;
                        case 3:
                                Foto[j++] = Camp[i].Imag4;break;
                        case 4:
                                Foto[j++] = Camp[i].Imag5;break;
                        case 5:
                                Foto[j++] = Camp[i].Imag6;break;
                        case 6:
                                Foto[j++] = Camp[i].Imag7;break;
                        case 7:
                                Foto[j++] = Camp[i].Imag8;break;
                        case 8:
                                Foto[j++] = Camp[i].Imag9;break;
                        case 9:
                                Foto[j++] = Camp[i].Imag10;break;
                    }
                }
                campanii ItemCampanie = new campanii((Camp[i].BaniTotal - Camp[i].BaniStransi).ToString(),
                    Camp[i].NumeZona, Camp[i].NumeCampanie, Camp[i].ID, (float)Camp[i].BaniTotal,Camp[i].Descriere,Foto);
                donatiiStackPanel.Children.Add(ItemCampanie);
            }

        }
        public CodingIncidentMessage ConvertIncidentToCoding(ServiceReference2.DispatchedIncident CADincidentMsg)
        {
            string codingID = _CallOut_CodingService.GetCodingID();

            CodingLocation incidentLocation = new CodingLocation();
            incidentLocation.Name = CADincidentMsg.IncidentLocation.Name;
            incidentLocation.Street = CADincidentMsg.IncidentLocation.Street;
            incidentLocation.Unit = CADincidentMsg.IncidentLocation.Unit;
            incidentLocation.State = CADincidentMsg.IncidentLocation.State;
            incidentLocation.City = CADincidentMsg.IncidentLocation.City;
            incidentLocation.Country = CADincidentMsg.IncidentLocation.Country;
            incidentLocation.PostalCode = CADincidentMsg.IncidentLocation.PostalCode;

            List<CodingUnits> tmpcodingunitList = new List<CodingUnits>();
            foreach (ServiceReference2.DispatchedUnit unit in CADincidentMsg.ListOfUnits)
            {
                CodingUnits newUnit = new CodingUnits();
                newUnit.ID = unit.ID;
                newUnit.Callsign = unit.CallSign;
                newUnit.UnitType = unit.UnitType;
                newUnit.FromStatus = unit.Status;
                newUnit.UnitLocation = unit.Location;
                newUnit.UnitHomeStation = unit.HomeStation;
                newUnit.UnitCurrentStation = unit.CurrentStation;

                tmpcodingunitList.Add(newUnit);
            }

            CodingUnits[] dispatchUnits = tmpcodingunitList.ToArray();

            CodingIncidentMessage codingIncidentMsg = new CodingIncidentMessage();
            codingIncidentMsg.CodingID = codingID;
            codingIncidentMsg.IncidentNo = CADincidentMsg.IncidentNumber;
            codingIncidentMsg.IncidentTitle = CADincidentMsg.IncidentTitle;
            codingIncidentMsg.IncidentLocation = incidentLocation;
            codingIncidentMsg.IncidentType = CADincidentMsg.IncidentType;
            codingIncidentMsg.IncidentAlarm = CADincidentMsg.AlarmLevel;
            codingIncidentMsg.IncidentPriority = CADincidentMsg.Priority;
            codingIncidentMsg.DispatchDateTime = CADincidentMsg.DateTime;
            codingIncidentMsg.DispatchUnits = dispatchUnits;

            return codingIncidentMsg;
        }
        /* 
         * 1) Convert from incident message into coding message
         * 2) Send the coding message to relevant console 
         * 3) Send Ack back to CAD in order to update mainly codingID
         */
        public void RcvCADIncidentMsg(ServiceReference2.DispatchedIncident CADincidentMsg)
        {
            SendOrPostCallback callback =
                delegate (object state)
                {
                    List<string> tmpstationList = new List<string>();
                    List<Tracking> trackingList = new List<Tracking>();
                    //Only take out the stations on the Current Station
                    foreach (ServiceReference2.DispatchedUnit uniqueunit in CADincidentMsg.ListOfUnits)
                    {
                        //Avoid duplicate station name in the list
                        if (!tmpstationList.Contains(uniqueunit.CurrentStation))
                        {
                            tmpstationList.Add(uniqueunit.CurrentStation);
                            Tracking newstation = new Tracking();
                            newstation.Station = uniqueunit.CurrentStation;
                            newstation.Status = "Pending";

                            List<string> unitcallsign = new List<string>();

                            //To give relevant station units callsign
                            foreach (ServiceReference2.DispatchedUnit unit in CADincidentMsg.ListOfUnits)
                            {
                                if (unit.CurrentStation.Equals(uniqueunit.CurrentStation))
                                {
                                    unitcallsign.Add(unit.CallSign);
                                }
                            }

                            newstation.Unit = unitcallsign.ToArray();
                            trackingList.Add(newstation); //Add into tracking list
                        }
                    }

                    string[] addressList = tmpstationList.ToArray();

                    //Convert Incident to Coding Message and send to respective console
                    CodingIncidentMessage codingincidentmsg = ConvertIncidentToCoding(CADincidentMsg);
                    ConvertCodingtoTracker(addressList, codingincidentmsg); //Add to gateway tracker
                    Log("Forward message from simulate CAD to respective console");
                    _CallOut_CodingService.TargetMsg(addressList, codingincidentmsg);

                    //Send ack back to CAD
                    CADIncidentAck cadincidentack = new CADIncidentAck();
                    cadincidentack.CodingID = codingincidentmsg.CodingID;
                    cadincidentack.AckTracking = trackingList.ToArray();
                    DateTime currentdt = DateTime.Now;
                    cadincidentack.AckTimeStamp = currentdt;
                    cadincidentack.AckNo = 0;
                    cadincidentack.AckTotal = tmpstationList.Count;
                    Log("Send ack to simulate CAD for forward message to console");
                    _CallOut_CADService.AckCADIncidentMsg(cadincidentack);


                    //Set Coding Entry
                    CreateCodingEntry(codingincidentmsg, tmpstationList.Count.ToString());
                    //Set Message Entry
                    CreateMessageEntry(codingincidentmsg, tmpstationList.Count.ToString());

                };

            _uiSyncContext.Post(callback, "Rcv Incident Message");
        }
        private static void SaveNotifications(ServiceReference2.StaticClient b, User usr)
        {
            var notes = b.GetAllNotifications(usr.UserId);

            var newNote1 = notes[0];

            newNote1.NotificationId= -1;
            newNote1.Name = "eee";
            newNote1.ModifiedDate = DateTime.Now;

            notes = b.SaveNotifications(new List<Notification>{newNote1});
        }
        private static void UpdateRegisterUser(User user, ServiceReference2.StaticClient client)
        {

                        user.UserName = "******";
            //user.Email = "*****@*****.**";

            var update = client.UpdateUser(user);
            //var register = client.RegisterUser(user);
        }
        private static void ForgotPass(ServiceReference2.StaticClient client)
        {

            var user = new User();
            //            user.UserName = "******";
            user.Email = "*****@*****.**";

            var forgot = client.ForgotPassword(user);
        }
        private static void SaveTypeTransactionReasons(ServiceReference2.StaticClient client, User usr)
        {
            //var stData = client.GetAllStaticData();
            //var stDataCat = client.GetAllCategories();
            var stDataTR = client.GetAllTypeTransactionReasons(usr.UserId);

            var reasons = new List<TypeTransactionReason>();
            reasons.Add(stDataTR[6]);

            reasons[0].Name = "abc";
            //stDataTR[11].Categories.Add(stData.TypeTransactionReasons[0].Categories[0]);
            //stDataTR[11].Categories.RemoveAt(0);
            reasons[0].Categories[1].IsDeleted = true;
            reasons[0].Categories[2].IsDeleted = true;

            //stDataTR[1].TypeTransactionReasonId = -1;
            //stDataTR[1].Categories = null;
            //reasons.Add(stDataTR[1]);

            reasons[0].ModifiedDate = DateTime.Now;
            client.SaveTypeTransactionReasons(reasons);
        }
        private static void InsertTypeInterval(ServiceReference1.MainClient a,ServiceReference2.StaticClient b, User usr)
        {
            var cat = b.GetAllCategories(usr.UserId);
            var typeTransReason = b.GetAllTypeTransactionReasons(usr.UserId);
            var typeIntervals = b.GetAllTypeIntervals(usr.UserId);
            var recurrenceRules = b.GetAllRecurrenceRules();
            var typeTransactions = b.GetAllTypeTransactions(usr.UserId);

            var catList = new CategoryList();
            cat.ForEach(x => catList.Add(x));

            var typeTransReasonList = new TypeTransactionReasonList();
            typeTransReason.ForEach(x => typeTransReasonList.Add(x));

            var typeTransactionsList = new TypeTransactionList();
            typeTransactions.ForEach(x => typeTransactionsList.Add(x));


            // INSERT //
            var intervals = new TypeIntervalList { new TypeInterval(catList, typeTransReasonList, typeTransactionsList, usr) };
            //intervals[0].RecurrenceRule = staticData.RecurrenceRules.FirstOrDefault(x => x.Name == "RuleDailyEveryDays");


            var found = recurrenceRules.FirstOrDefault(x => x.Name == "RuleDailyEveryDays");
            intervals[0].RecurrenceRuleValue.RecurrenceRule = found;
            intervals[0].RecurrenceRuleValue.RulePartValueList[0].Value = "aaa";
            intervals[0].RecurrenceRuleValue.RulePartValueList[1].Value = "bbb";

            intervals[0].RecurrenceRangeRuleValue.RecurrenceRule = recurrenceRules.FirstOrDefault(x => x.Name == Const.Rule.RuleRangeTotalOcurrences.ToString());
            intervals[0].RecurrenceRangeRuleValue.RulePartValueList[0].Value = "20111111";
            intervals[0].RecurrenceRangeRuleValue.RulePartValueList[1].Value = "234";


            var result = b.SaveTypeIntervals(intervals.ToList());

        }
        private static void UpdateTypeInterval(ServiceReference1.MainClient a, ServiceReference2.StaticClient b, User usr)
        {
            var cat = b.GetAllCategories(usr.UserId);
            var typeIntervals = b.GetAllTypeIntervals(usr.UserId);
            var recurrenceRules = b.GetAllRecurrenceRules();
            var typeTransactions = b.GetAllTypeTransactions(usr.UserId);

            // UPDATE //
            typeIntervals[0].Amount = 19d;
            typeIntervals[0].TransactionType = typeTransactions[1];
            typeIntervals[0].RecurrenceRuleValue.RulePartValueList[0].Value = "9123";
            typeIntervals[0].ModifiedDate = DateTime.Now;
            //staticData.TypeIntervals[1].ModifiedDate = DateTime.Now;

            typeIntervals[0].RecurrenceRangeRuleValue.RecurrenceRule = recurrenceRules.FirstOrDefault(x => x.Name == Const.Rule.RuleRangeTotalOcurrences.ToString());
            typeIntervals[0].RecurrenceRangeRuleValue.RulePartValueList[0].Value = "20100202";
            typeIntervals[0].RecurrenceRangeRuleValue.RulePartValueList[1].Value = "3";
            //staticData.TypeIntervals[0].RecurrenceRangeRuleValue.RulePartValueList[1].Value = "b22";
            //staticData.TypeIntervals[0].RecurrenceRangeRuleValue.RulePartValueList[1].Value = "c22";

            var k = new List<TypeInterval>();
            k.Add(typeIntervals[0]);

            var update = b.SaveTypeIntervals(k);

        }
        private static void DeleteTypeInterval(ServiceReference2.StaticClient b, User usr)
        {
            var typeIntervals = b.GetAllTypeIntervals(usr.UserId);

            var interval1 = typeIntervals[0];
            interval1.IsDeleted = true;
            interval1.ModifiedDate = DateTime.Now;

            var interval2 = typeIntervals[1];
            interval2.IsDeleted = true;
            interval2.ModifiedDate = DateTime.Now;

            var interval3 = typeIntervals[2];
            interval3.IsDeleted = true;
            interval3.ModifiedDate = DateTime.Now;

            var k = new List<TypeInterval> { interval1, interval2, interval3 };
            
            var update = b.SaveTypeIntervals(k);
        }
        private static List<Category> SaveCategories(ServiceReference2.StaticClient b, User usr)
        {
            var allCat = b.GetAllCategories(usr.UserId);
            var allReasons = b.GetAllTypeTransactionReasons(usr.UserId);

            var catList = new CategoryList();
            var reasonList = new TypeTransactionReasonList();

            allReasons.ForEach(x=>reasonList.Add(x));
            var newCat = new Category(usr, reasonList);
            newCat = allCat[2];
            newCat.TypeTransactionReasons[1].IsDeleted = true;
            newCat.TypeTransactionReasons[1].ModifiedDate = DateTime.Now;

            newCat.HasChanges = true;
            newCat.ModifiedDate = DateTime.Now;

            //newCat.Name = "CarTest";

            //if (newCat.TypeTransactionReasons == null)
            //    newCat.TypeTransactionReasons = new List<TypeTransactionReason>();

            //newCat.TypeTransactionReasons.Add(allReasons[0]);
            //newCat.TypeTransactionReasons.Add(allReasons[1]);

            //var transReasonList = new List<TypeTransactionReason>();
            //var transReason = new TypeTransactionReason(usr);
            //transReason.Name = "CarTest";


            catList.Add(newCat);

            catList.OptimizeOnTopLevel();

            var result = b.SaveCategories(catList.ToList());
            //var arrC = st.ToList();

            //var c = b.SaveCategories(st.Categories);

            return result;
        }
        private static User CreateUser(ServiceReference2.StaticClient b)
        {
            User usr = new User();

            usr.UserName = "******";
            usr.Password = "******";
            usr.Email = "*****@*****.**";

            return b.RegisterUser(usr);
        }