Exemple #1
0
        private bool CheckRand(IDResult ID)
        {
            string Randstr = (ID as ID6)?.Status.ToString() ?? (ID as ID7)?.RandNum.ToString("X16");

            return(RE ? RandList.Any(rand => System.Text.RegularExpressions.Regex.IsMatch(Randstr, rand))
                      : RandList.Any(rand => rand != "" && Randstr.IndexOf(rand.ToUpper(), System.StringComparison.Ordinal) >= 0));
        }
Exemple #2
0
        private bool CheckID(IDResult ID)
        {
            switch (IDType)
            {
            case 0: return(CheckID(string.Format("{0:D5}", ID.TID)));

            case 1: return(CheckID(string.Format("{0:D5}", ID.SID)));

            case 2: return(CheckID(string.Format("{0:D6}", (ID as ID7).G7TID)));

            default: return(false);
            }
        }
        private async void ButtonClick(object sender, EventArgs e)
        {
            if (Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.Internet)
            {
                Device.BeginInvokeOnMainThread(async() => await DisplayAlert(AppResources.ErrorTitle, AppResources.ErrorNoInternet, "OK"));
                return;
            }
            FrameBtnQuest.IsVisible = false;
            progress.IsVisible      = true;
            if (Settings.Person.Accounts.Count > 0)
            {
                IDResult result = await _server.newApp(Settings.Person.Accounts[0].Ident,
                                                       additionalService.id_RequestType.ToString(),
                                                       "Ваш заказ принят. В ближайшее время сотрудник свяжется с Вами для уточнения деталей\n" +
                                                       additionalService.Description);

                if (result.Error == null)
                {
                    RequestsUpdate requestsUpdate =
                        await _server.GetRequestsUpdates(Settings.UpdateKey, result.ID.ToString());

                    if (requestsUpdate.Error == null)
                    {
                        Settings.UpdateKey = requestsUpdate.NewUpdateKey;
                    }

                    await DisplayAlert(AppResources.AlertSuccess, AppResources.OrderSuccess, "OK");

                    RequestInfo requestInfo = new RequestInfo();
                    requestInfo.ID = result.ID; if (Navigation.NavigationStack.FirstOrDefault(x => x is AppPage) == null)
                    {
                        await Navigation.PushAsync(new AppPage(requestInfo, true));
                    }
                }
                else
                {
                    await DisplayAlert(AppResources.ErrorTitle, result.Error, "OK");
                }
            }
            else
            {
                await DisplayAlert(AppResources.ErrorTitle, AppResources.ErrorConnectcIdent, "OK");
            }
            FrameBtnQuest.IsVisible = true;
            progress.IsVisible      = false;
        }
Exemple #4
0
 public bool CheckResult(IDResult ID)
 {
     if (Skip)
     {
         return(true);
     }
     if (IDList.Length != 0 && !CheckID(ID))
     {
         return(false);
     }
     if (TSVList.Length != 0 && !CheckTSV(ID))
     {
         return(false);
     }
     if (RandList.Length != 0 && !CheckRand(ID))
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
        private bool CheckTSV(IDResult ID)
        {
            ushort TSV = ID.TSV;

            for (int i = 0; i < TSVList.Length; i++)
            {
                if (!int.TryParse(TSVList[i], out int val))
                {
                    continue;
                }

                if (0 > val || val > 4095)
                {
                    continue;
                }

                if (val == TSV)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #6
0
 public Frame_ID(IDResult sc, int frame)
 {
     id       = sc;
     FrameNum = frame;
 }
Exemple #7
0
        private bool CheckRand(IDResult ID)
        {
            string Randstr = (ID as ID6)?.Status.ToString() ?? (ID as ID7)?.RandNum.ToString("X16");

            return(RandList.Any(rand => rand != "" && Randstr.IndexOf(rand.ToUpper(), System.StringComparison.Ordinal) >= 0));
        }
        private async void AddPush(object sender, EventArgs e)
        {
            string title = EntryTitle.Text;
            string text  = BordlessEditor.Text;

            if (string.IsNullOrWhiteSpace(title))
            {
                await DisplayAlert(AppResources.ErrorTitle, AppResources.EnterName, "OK");
            }
            else if (string.IsNullOrWhiteSpace(text))
            {
                await DisplayAlert(AppResources.ErrorTitle, AppResources.SfPdfViewerPlaceHolderText, "OK");
            }
            else
            {
                AnnouncementArguments announcementArguments = new AnnouncementArguments()
                {
                    Header         = title,
                    Text           = text,
                    ShowOnMainPage = CheckBox.IsToggled,
                    ActiveFrom     = DatePicker.Date.ToString("dd.MM.yyyy"),
                    ActiveTo       = DatePicker2.Date.ToString("dd.MM.yyyy")
                };
                if (!string.IsNullOrWhiteSpace(EntryLS.Text))
                {
                    announcementArguments.Ident = EntryLS.Text;
                }

                if (!string.IsNullOrWhiteSpace(EntryDebt.Text))
                {
                    try
                    {
                        decimal debt = Decimal.Parse(EntryDebt.Text);
                        announcementArguments.ForAccountsWithDebtOver = debt;
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                    }
                }

                if (SelecttHouses != null && SelecttHouses.Count > 0)
                {
                    announcementArguments.Houses = SelecttHouses.Select(each => each.ID).ToList();
                }

                if (_selectedGroupId != -1)
                {
                    announcementArguments.id_homegroup = _selectedGroupId;
                }

                if (announcementArguments.id_homegroup == null &&
                    announcementArguments.Houses == null &&
                    string.IsNullOrWhiteSpace(announcementArguments.Ident) &&
                    announcementArguments.ForAccountsWithDebtOver == null)
                {
                    announcementArguments.Houses = DefaultHouses.Select(each => each.ID).ToList();
                }

                if (!string.IsNullOrWhiteSpace(_os) && !_os.Equals(AppResources.All))
                {
                    announcementArguments.OS = _os;
                }



                new Task(() =>
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        Configurations.LoadingConfig = new LoadingConfig
                        {
                            IndicatorColor = (Color)Application.Current.Resources["MainColor"],
                            OverlayColor   = Color.Black,
                            Opacity        = 0.8,
                            DefaultMessage = AppResources.Loading,
                        };

                        await Loading.Instance.StartAsync(async progress =>
                        {
                            IDResult newAnnouncement = await _server.NewAnnouncement(announcementArguments);
                            if (newAnnouncement.Error == null)
                            {
                                CommonResult sendAnnouncement = await _server.SendAnnouncement(newAnnouncement.ID);
                                if (sendAnnouncement.Error != null)
                                {
                                    Device.BeginInvokeOnMainThread(async() =>
                                    {
                                        await DisplayAlert(AppResources.ErrorTitle, sendAnnouncement.Error, "OK");
                                    });
                                }
                                else
                                {
                                    Device.BeginInvokeOnMainThread(async() =>
                                    {
                                        await DisplayAlert("", AppResources.SendingPush, "OK");
                                    });
                                }
                            }
                            else
                            {
                                Device.BeginInvokeOnMainThread(async() =>
                                {
                                    await DisplayAlert(AppResources.ErrorTitle, newAnnouncement.Error, "OK");
                                });
                            }
                        });
                    });
                }).Start();
            }
        }
Exemple #9
0
        private void GetClick(object sender, RoutedEventArgs e)
        {
            if (login == null || String.IsNullOrEmpty(login.SessionID))
            {
                AddMessage("Not logged in.");
                return;
            }
            string fct = Function.Text;

            try {
                string str = ID.Text;
                int    id;
                if (!int.TryParse(str, out id))
                {
                    id = 0;
                }
                switch (fct)
                {
                case "GetGatewayHardwareIDs":
                    IDResult gidr = api.GetGatewayHardwareIDs(login.SessionID, str);
                    Done(fct, gidr, gidr.IDs);
                    return;

                case "GetDeviceList":
                    DeviceListResult dr = api.GetDeviceList(login.SessionID);
                    Done(fct, dr, dr.DeviceList);
                    return;

                case "GetDeviceListByID":
                    if (String.IsNullOrWhiteSpace(str))
                    {
                        return;
                    }
                    string[] ids   = str.Split(',');
                    int      count = ids.Length;
                    int[]    pks   = new int[count];
                    for (int i = 0; i < count; i++)
                    {
                        pks[i] = int.Parse(ids[i]);
                    }
                    DeviceListResult dlri = api.GetDeviceListByID(login.SessionID, pks);
                    Done(fct, dlri, dlri.DeviceList);
                    return;

                case "GetDeviceListByHFCandGwType (HFC,GwType)":
                    DeviceListResult dlr = api.GetDeviceListFromHFCandGWType(login.SessionID, str);
                    Done(fct, dlr, dlr.DeviceList);
                    return;

                case "GetUserByName":
                    UserResult sur = api.GetUserByName(login.SessionID, str);
                    Done(fct, sur, sur.Data);
                    return;

                case "GetUsersByEmail":
                    IDResult eur = api.GetUsersByEmail(login.SessionID, str);
                    Done(fct, eur, eur.IDs);
                    return;

                case "GetLoggedInUser (session;ip)":
                    string[] split = str.Split(';');
                    IDResult sir   = api.GetLoggedInUser(login.SessionID, split[0], (split.Length > 1) ? split[1] : null);
                    Done(fct, sir, sir.IDs);
                    return;

                case "GetTimeZones":
                    TimeZonesResult tz = api.GetTimeZones(login.SessionID, str);
                    Done(fct, tz, tz.TimeZones);
                    return;

                case "GetCustomer":
                    if (id <= 0)
                    {
                        id = login.CustomerID;
                    }
                    CustomerResult cr = api.GetCustomer(login.SessionID, id);
                    Done(fct, cr, cr.Data);
                    return;

                case "GetChildCustomerIDs":
                    if (id <= 0)
                    {
                        id = login.CustomerID;
                    }
                    IDResult cidr = api.GetChildCustomerIDs(login.SessionID, id);
                    Done(fct, cidr, cidr.IDs);
                    return;

                case "GetChildSiteIDs":
                    if (id <= 0)
                    {
                        id = login.CustomerID;
                    }
                    IDResult csidr = api.GetChildSiteIDs(login.SessionID, id);
                    Done(fct, csidr, csidr.IDs);
                    return;

                case "GetChildUserIDs":
                    if (id <= 0)
                    {
                        id = login.CustomerID;
                    }
                    IDResult cuidr = api.GetChildUserIDs(login.SessionID, id);
                    Done(fct, cuidr, cuidr.IDs);
                    return;

                case "GetUser":
                    if (id <= 0)
                    {
                        id = login.UserID;
                    }
                    UserResult ur = api.GetUser(login.SessionID, id);
                    Done(fct, ur, ur.Data);
                    return;

                case "GetSite":
                    SiteResult sr = api.GetSite(login.SessionID, id);
                    Done(fct, sr, sr.Data);
                    return;

                case "GetChildHardwareIDs":
                    IDResult chidr = api.GetChildHardwareIDs(login.SessionID, id);
                    Done(fct, chidr, chidr.IDs);
                    return;

                case "GetChildGatewayIDs":
                    IDResult cgidr = api.GetChildGatewayIDs(login.SessionID, id);
                    Done(fct, cgidr, cgidr.IDs);
                    return;

                case "GetChildInverterIDs":
                    IDResult ciidr = api.GetChildInverterIDs(login.SessionID, id);
                    Done(fct, ciidr, ciidr.IDs);
                    return;

                case "GetHardware":
                    HardwareResult hr = api.GetHardware(login.SessionID, id);
                    Done(fct, hr, hr.Data);
                    return;

                case "GetGateway":
                    GatewayResult gr = api.GetGateway(login.SessionID, id);
                    Done(fct, gr, gr.Data);
                    return;

                case "GetInverter":
                    InverterResult ir = api.GetInverter(login.SessionID, id);
                    Done(fct, ir, ir.Data);
                    return;

                case "GetStringCombiner":
                    StringCombinerResult scr = api.GetStringCombiner(login.SessionID, id);
                    Done(fct, scr, scr.Data);
                    return;

                case "GetFieldList":
                    FieldListResult fr = api.GetFieldList(login.SessionID, id);
                    Done(fct, fr, fr.FieldList);
                    return;
                }
            } catch {
                AddMessage(String.Concat(fct, " failed. Please check your connection."));
            }
        }
Exemple #10
0
        private void SetClick(object sender, RoutedEventArgs e)
        {
            if (login == null || String.IsNullOrEmpty(login.SessionID))
            {
                AddMessage("Not logged in.");
                return;
            }
            string fct = SetFunction.Text;

            try {
                int id;
                if (!int.TryParse(SetID.Text, out id))
                {
                    id = 0;
                }
                switch (fct)
                {
                case "SetCustomer":
                    CustomerResult cr = (id > 0) ? api.GetCustomer(login.SessionID, id) : null;
                    if (cr != null && cr.Data == null)
                    {
                        Done(fct, cr, cr.Data);
                    }
                    else
                    {
                        CreateTab(fct, (cr != null) ? cr.Data : new Customer(),
                                  (tab, val) => {
                            try {
                                Customer c = val as Customer;
                                if (!CreatedTab(fct, tab, (object)c ?? (val as Exception), (c != null) ? c.CustomerID : 0, id))
                                {
                                    return;
                                }
                                cr = api.SetCustomer(login.SessionID, c);
                                Done(fct, cr, cr.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;

                case "SetUser":
                    UserResult ur = (id > 0) ? api.GetUser(login.SessionID, id) : null;
                    if (ur != null && ur.Data == null)
                    {
                        Done(fct, ur, ur.Data);
                    }
                    else
                    {
                        CreateTab(fct, (ur != null) ? ur.Data : new User(),
                                  (tab, val) => {
                            try {
                                User u = val as User;
                                if (!CreatedTab(fct, tab, (object)u ?? (val as Exception), (u != null) ? u.UserID : 0, id))
                                {
                                    return;
                                }
                                ur = api.SetUser(login.SessionID, u);
                                Done(fct, ur, ur.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;

                case "SetUserPassword":
                    PasswordDlg dlg = new PasswordDlg();
                    dlg.Owner = GetWindow();
                    if (dlg.ShowDialog() == true)
                    {
                        try {
                            UseHTTPS();
                            Result r = api.SetUserPassword(login.SessionID, id, dlg.Password);
                            Done(fct, r, null);
                        } finally {
                            UseHTTP();
                        }
                    }
                    else
                    {
                        AddMessage(fct + " cancelled");
                    }
                    return;

                case "SendEmail":
                    CreateTab(fct, new Email(),
                              (tab, val) => {
                        try {
                            Email email = val as Email;
                            if (!CreatedTab(fct, tab, (object)email ?? (val as Exception), id, id))
                            {
                                return;
                            }
                            IDResult r = api.SendEmail(login.SessionID, email);
                            Done(fct, r, r.IDs);
                        } catch {
                            AddMessage(String.Concat(fct, " failed. Please check your connection."));
                        }
                    });
                    return;

                case "SetSite":
                    SiteResult sr = (id > 0) ? api.GetSite(login.SessionID, id) : null;
                    if (sr != null && sr.Data == null)
                    {
                        Done(fct, sr, sr.Data);
                    }
                    else
                    {
                        CreateTab(fct, (sr != null) ? sr.Data : new Site(),
                                  (tab, val) => {
                            try {
                                Site s = val as Site;
                                if (!CreatedTab(fct, tab, (object)s ?? (val as Exception), (s != null) ? s.SiteID : 0, id))
                                {
                                    return;
                                }
                                sr = api.SetSite(login.SessionID, s);
                                Done(fct, sr, sr.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;

                case "SetGateway":
                    GatewayResult gr = (id > 0) ? api.GetGateway(login.SessionID, id) : null;
                    if (gr != null && gr.Data == null)
                    {
                        Done(fct, gr, gr.Data);
                    }
                    else
                    {
                        CreateTab(fct, (gr != null) ? gr.Data : new Gateway(),
                                  (tab, val) => {
                            try {
                                Gateway g = val as Gateway;
                                if (!CreatedTab(fct, tab, (object)g ?? (val as Exception), (g != null) ? g.HardwareID : 0, id))
                                {
                                    return;
                                }
                                gr = api.SetGateway(login.SessionID, g);
                                Done(fct, gr, gr.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;

                case "SetInverter":
                    InverterResult ir = (id > 0) ? api.GetInverter(login.SessionID, id) : null;
                    if (ir != null && ir.Data == null)
                    {
                        Done(fct, ir, ir.Data);
                    }
                    else
                    {
                        CreateTab(fct, (ir != null) ? ir.Data : new Inverter(),
                                  (tab, val) => {
                            try {
                                Inverter i = val as Inverter;
                                if (!CreatedTab(fct, tab, (object)i ?? (val as Exception), (i != null) ? i.HardwareID : 0, id))
                                {
                                    return;
                                }
                                ir = api.SetInverter(login.SessionID, i);
                                Done(fct, ir, ir.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;

                case "SetStringCombiner":
                    StringCombinerResult scr = (id > 0) ? api.GetStringCombiner(login.SessionID, id) : null;
                    if (scr != null && scr.Data == null)
                    {
                        Done(fct, scr, scr.Data);
                    }
                    else
                    {
                        CreateTab(fct, (scr != null) ? scr.Data : new StringCombiner(),
                                  (tab, val) => {
                            try {
                                StringCombiner sc = val as StringCombiner;
                                if (!CreatedTab(fct, tab, (object)sc ?? (val as Exception), (sc != null) ? sc.HardwareID : 0, id))
                                {
                                    return;
                                }
                                scr = api.SetStringCombiner(login.SessionID, sc);
                                Done(fct, scr, scr.Data);
                            } catch {
                                AddMessage(String.Concat(fct, " failed. Please check your connection."));
                            }
                        });
                    }
                    return;
                }
            } catch {
                AddMessage(String.Concat(fct, " failed. Please check your connection."));
            }
        }
Exemple #11
0
 private bool CheckTSV(IDResult ID)
 => tsvlist.Contains(ID.TSV);
Exemple #12
0
 public BResult(IDResult iDResult)
 {
     _iDResult = iDResult;
 }