Пример #1
0
        internal IEnumerable GetClients()
        {
            DConsole.WriteLine("получение клиентов");
            var result = DBHelper.GetClients(findText);

            DConsole.WriteLine("Получили клиентов");

            //var result2 = DBHelper.GetClients();
            // var dbEx = result2.Unload();
            //DConsole.WriteLine("in result " + dbEx.Count());

            return(result);
        }
Пример #2
0
        internal DbRecordset GetContacts()
        {
            object clientContacts;

            if (!BusinessProcess.GlobalVariables.TryGetValue(Parameters.IdClientId, out clientContacts))
            {
                DConsole.WriteLine("Can't find current clientId, i'm crash.");
            }

            var items = DBHelper.GetContactsByClientID((string)clientContacts);

            return(items);
        }
        private void CameraCallback(object state, ResultEventArgs <bool> args)
        {
            if (!args.Result)
            {
                return;
            }

            DConsole.WriteLine("New image");
            _imgToReplace.Source = "~" + _pathToImg;
            _imgToReplace.Refresh();
            DConsole.WriteLine("Updating");
            UpdateChecklist(_currentCheckListItemID, state.ToString());
        }
Пример #4
0
        internal bool Init()
        {
            //TODO: Опасно брать юзера отсюда.
            var result = DBHelper.GetUserInfoByUserName(Settings.User);

            _userDescription = result.Next() ? (string)result["Description"] : "";

#if DEBUG
            DConsole.WriteLine(_userDescription);
#endif

            return(true);
        }
Пример #5
0
 /// <summary>
 ///     Изменить отображаемый экран, не меняя стек.
 /// </summary>
 /// <param name="screenInfo">Информация об экране</param>
 /// <param name="args">Словарь аргументов</param>
 /// <param name="screen">Ссылка на целевой экран</param>
 public static void ModalMove(ScreenInfo screenInfo, IDictionary <string, object> args = null,
                              Screen screen = null, ShowAnimationType AnimationType = ShowAnimationType.GoNext)
 {
     try
     {
         DConsole.WriteLine($"Moving to {screenInfo.Name}");
         try
         {
             screen = screen ?? (Screen)Application.CreateInstance($"Test.{screenInfo.Name}");
         }
         catch
         {
             DConsole.WriteLine($"Can't load screen with name {screenInfo.Name}");
             if (!_nonModalMove || ScreenInfoStack.Count < 1)
             {
                 return;
             }
             ScreenInfoStack.Pop();
             ScreenStack.Pop();
             return;
         }
         screen.SetData(args);
         try
         {
             screen.LoadFromStream(Application.GetResourceStream(screenInfo.Xml));
         }
         catch (Exception e)
         {
             DConsole.WriteLine($"Error while loading {screenInfo.Name}'s xml ({screenInfo.Xml})");
             DConsole.WriteLine($"{e.Message}");
         }
         try
         {
             screen.LoadStyleSheet(Application.GetResourceStream(screenInfo.Css));
         }
         catch
         {
             screen.LoadStyleSheet(Application.GetResourceStream(DefaultStyle));
         }
         CurrentScreenInfo = screenInfo;
         CurrentScreen     = screen;
         screen.Show(AnimationType);
         _nonModalMove = false;
     }
     catch (Exception e)
     {
         DConsole.WriteLine($"{e.GetType().FullName}:{e.Message}");
         DConsole.WriteLine($"{e.StackTrace}");
     }
 }
Пример #6
0
        internal void TopInfo_RightButton_OnClick(object sender, EventArgs e)
        {
            DConsole.WriteLine("GO to map");
            DConsole.WriteLine("Before dictionary");
            var dictionary = new Dictionary <string, object>
            {
                { Parameters.IdScreenStateId, MapScreenStates.EventListScreen }
            };

            DConsole.WriteLine("After");
            BusinessProcess.GlobalVariables[Parameters.IdScreenStateId] = MapScreenStates.EventListScreen;
            Dialog.ShowProgressDialog(Translator.Translate("loading_message"), true);
            Navigation.Move("MapScreen", dictionary);
        }
Пример #7
0
        public override void OnLoading()
        {
            base.OnLoading();
            _isEnable = true;
            DConsole.WriteLine("AuthScreen init");

            _loginEditText    = (EditText)GetControl("AuthScreenLoginET", true);
            _passwordEditText = (EditText)GetControl("AuthScreenPasswordET", true);
            _enterButton      = (Button)GetControl("ba603e1782d543f696944a603d7f05f2", true);
            _loginBreaker     = (VerticalLayout)GetControl("LoginBreaker", true);
            _passwordBreaker  = (VerticalLayout)GetControl("PasswordBreaker", true);
            _progressBar      = (ProgressBar)GetControl("SyncProgress", true);
            _progressBarText  = (TextView)GetControl("SyncProgressBarText", true);
        }
Пример #8
0
        /* TODO: Не удалять до тех пор пока платформа не даст разъяснений по поводу корректного удаления элементов.*/

        /// <summary>
        /// Пока данным методом не пользоваться, до выяснения обстоятельств
        /// </summary>
        /// <param name="container"></param>
        /// <param name="index"></param>
        public static void RemoveChild(this IContainer container, int index)
        {
            if (index < 0)
            {
                throw new ArgumentException("Индекс удаляемого элемента не может быть отрицательным.");
            }
            if (index > container.Controls.Length)
            {
                throw new ArgumentException(
                          $"Индекс превышает количество элементов фактически содержащихся в {container.GetType().Name}");
            }

            ((ILayoutableContainer)((IWrappedControl3)container).GetNativeControl()).Withdraw(index);
            DConsole.WriteLine($"Deleted");
        }
Пример #9
0
 public override void OnLoading()
 {
     _map = (WebMapGoogle)GetControl("Map", true);
     _topInfoComponent = new TopInfoComponent(this)
     {
         Header            = Translator.Translate("map"),
         LeftButtonControl = new Image()
         {
             Source = ResourceManager.GetImage("topheading_back")
         },
         ArrowVisible = false
     };
     _topInfoComponent.ActivateBackButton();
     DConsole.WriteLine("MapScreen");
 }
Пример #10
0
        /// <summary>
        ///     Проверяет данные, которые получили в поле
        ///     _data.
        /// </summary>
        /// <returns>true - если данных нет у поля _data, иначе false</returns>
        internal bool GetIsEmptyList()
        {
            DConsole.WriteLine("GetIsEmptyList()");
            if (_data == null)
            {
                _isAdd = _isEdit = false;
                _data  = new ArrayList();
            }
            else
            {
                GetValueFromOtherScreen();
            }

            return(_data.Count == 0);
        }
Пример #11
0
        private void MakeWebRequest_OnClick(object sender, EventArgs e)
        {
            var req = WebRequest.Create("http://bitmobile1.bt/bitmobileX/platform/device/GetClientMetadata");

            DConsole.WriteLine("Web Request Created");
            var svcCredentials =
                Convert.ToBase64String(Encoding.ASCII.GetBytes("fm" + ":" + "fm"));

            req.Headers.Add("Authorization", "Basic " + svcCredentials);
            DConsole.WriteLine("Headers added");
            using (var resp = req.GetResponse())
            {
            }
            DConsole.WriteLine("The response is received");
        }
Пример #12
0
        private void CameraCallback(object state, ResultEventArgs <bool> args)
        {
            if (!args.Result)
            {
                return;
            }

            DConsole.WriteLine("New image");
            _imgToReplace.Source = "~" + _pathToImg;
            _imgToReplace.Refresh();
            DConsole.WriteLine("Updating");
            UpdateChecklist(_currentCheckListItemID, state.ToString());
            DConsole.WriteLine("Changing indicator");
            ChangeRequiredIndicatorForDone(_lastClickedRequiredIndicatior);
        }
Пример #13
0
 public override void OnLoading()
 {
     DConsole.WriteLine("CheckListScreen init");
     _topInfoComponent = new TopInfoComponent(this)
     {
         Header            = Translator.Translate("clist"),
         LeftButtonControl = new Image {
             Source = ResourceManager.GetImage("topheading_back")
         },
         ArrowVisible = false,
         SubHeader    =
             string.Format(Translator.Translate("mandatory_questions_0_1"), _totalAnswered, _totalRequired)
     };
     _readonly = (bool)Variables.GetValueOrDefault(Parameters.IdIsReadonly, false);
     _topInfoComponent.ActivateBackButton();
 }
Пример #14
0
        private void GetAndCheckCountEditText(EditText countEditText)
        {
            int res;

            if (!int.TryParse(countEditText.Text, out res))
            {
                res = AmountFact;
                DConsole.WriteLine($"Unparsed text = {countEditText.Text}");
            }
            if (res < _minimum)
            {
                res = _minimum;
            }

            AmountFact = res;
        }
Пример #15
0
        private void PrintMaterialsData()
        {
            DConsole.WriteLine($"{nameof(_data)}.{nameof(_data.Count)} = {_data.Count}");

            foreach (var item in _data)
            {
                var element = (Dictionary <string, object>)item;

                foreach (var i in element)
                {
                    DConsole.WriteLine($"{i.Key} = {i.Value}");
                }

                DConsole.WriteLine($"{Environment.NewLine}{Environment.NewLine}");
            }
        }
Пример #16
0
        internal string DateTimeToDateWithWeekCheck(string datetime)
        {
            var workDate    = DateTime.Parse(datetime).Date;
            var currentDate = DateTime.Now.Date;

            DConsole.WriteLine($"week = {currentDate.GetWeekNumber()}");

            var workDateWeekNumber    = workDate.GetWeekNumber();
            var currentDateWeekNumber = currentDate.GetWeekNumber();

            if (workDateWeekNumber == currentDateWeekNumber)
            {
                return(DateTime.Parse(datetime).ToString("dddd, dd MMMM").ToUpper());
            }
            return(DateTime.Parse(datetime).ToString("dd MMMM yyyy").ToUpper());
        }
Пример #17
0
        private void DeleteElement(string id)
        {
            var index = -1;

            for (var i = 0; i < _data.Count; i++)
            {
                var element = (Dictionary <string, object>)_data[i];
                var skuId   = (string)element["SKU"];
                if (string.Compare(skuId, id, false) == 0)
                {
                    index = i;
#if DEBUG
                    DConsole.WriteLine("Index naiden" + Environment.NewLine);
#endif
                    break;
                }
            }

            if (index >= 0)
            {
                _data.RemoveAt(index);
#if DEBUG
                DConsole.WriteLine($"Element {id} with {nameof(index)} = {index} is deleted {Environment.NewLine}");
#endif
                if (_data.Count == 0)
                {
                    var bigImage            = (Image)GetControl("BigImageMaterialsRequest", true);
                    var descriptionTextView = (TextView)GetControl("DescriptionMaterialsRequest", true);
                    var button     = (Button)GetControl("ButtonMaterialsRequest", true);
                    var dockLayout = (DockLayout)GetControl("State2DockLayout", true);

                    bigImage.CssClass            = "BigImageMaterialsRequestImg";
                    descriptionTextView.CssClass = "DescriptionMaterialsRequestTV";
                    button.CssClass     = "ButtonMaterialsRequestBtn";
                    dockLayout.CssClass = "NoHeight";
                    dockLayout.Visible  = false;
                    _rootLayout.Refresh();
                }
            }
            else
            {
#if DEBUG
                DConsole.WriteLine(
                    $"Element is not deleted Error in method {nameof(DeleteElement)} {Environment.NewLine}");
#endif
            }
        }
Пример #18
0
        /// <summary>
        ///     Метод осуществляет проверку, существует ли
        ///     элемент в коллекции _data. Если существует
        ///     тогда объединяет элементы с одинаковым rimId
        ///     и суммирует их колличество.
        /// </summary>
        /// <param name="item"> Элемент, который нужно проверить на существование в коллекции</param>
        /// <returns> true, если элемент существует в коллекции и объединился. false если не существует </returns>
        private bool CombineIfExist(EditServiceOrMaterialsScreenResult item)
        {
            foreach (var element in _data)
            {
                var dictionary   = (Dictionary <string, object>)element;
                var elementRimId = (string)dictionary["SKU"];

                if (string.Compare(elementRimId, item.RimId, false) == 0)
                {
                    DConsole.WriteLine($"Count before {(int)dictionary["Count"]} SKU = {(string)dictionary["SKU"]}");
                    dictionary["Count"] = (int)dictionary["Count"] + item.Count;
                    DConsole.WriteLine($"Element is Exist and changed count = {(int)dictionary["Count"]}");
                    return(true);
                }
            }
            return(false);
        }
Пример #19
0
        internal void GoToMapScreen_OnClick(object sender, EventArgs e)
        {
            DConsole.WriteLine($"{nameof(GoToMapScreen_OnClick)} Start");
            var dictionary = new Dictionary <string, object>
            {
                { Parameters.IdScreenStateId, MapScreenStates.ClientScreen },
                { Parameters.IdClientId, _clientId }
            };

            BusinessProcess.GlobalVariables.Remove(Parameters.IdScreenStateId);
            BusinessProcess.GlobalVariables.Remove(Parameters.IdClientId);
            BusinessProcess.GlobalVariables[Parameters.IdScreenStateId] = MapScreenStates.ClientScreen;
            BusinessProcess.GlobalVariables[Parameters.IdClientId]      = _clientId;

            DConsole.WriteLine($"{nameof(GoToMapScreen_OnClick)} end");
            Navigation.Move("MapScreen", dictionary);
        }
Пример #20
0
 internal void PrintX_OnClick(object sender, EventArgs e)
 {
     Toast.MakeToast(Translator.Translate("start_sync"));
     FileSystem.UploadPrivate(Settings.ImageServer, Settings.User, Settings.Password, (o, args) =>
     {
         DConsole.WriteLine("Sync succesful? = " + args.Result);
         Toast.MakeToast(Translator.Translate(args.Result ? "upload_finished" : "upload_failed"));
         if (args.Result)
         {
             FileSystem.SyncShared(Settings.ImageServer, Settings.User, Settings.Password,
                                   (o1, args1) =>
             {
                 Toast.MakeToast(Translator.Translate(args1.Result ? "sync_success" : "sync_fail"));
             });
         }
     });
 }
Пример #21
0
        public static EventListElement CreateFromRecordSet(DbRecordset recordSet)
        {
            var eventElement = new EventListElement();

            eventElement.Id                = recordSet.GetString(0);
            eventElement.StartDatePlan     = recordSet.GetDateTime(1);
            eventElement.StartDatePlanDate = recordSet.GetDateTime(2);
            eventElement.TypeDeparture     = recordSet.GetString(3);
            eventElement.ActualStartDate   = recordSet.GetDateTime(4);
            eventElement.Importance        = recordSet.GetString(5);
            eventElement.ImportanceName    = recordSet.GetString(6);
            eventElement.ClientDescription = recordSet.GetString(7);
            eventElement.ClientAddress     = recordSet.GetString(8);
            DConsole.WriteLine(nameof(CreateFromRecordSet));

            return(eventElement);
        }
Пример #22
0
        private static void SyncHandler(object state, ResultEventArgs <bool> resultEventArgs)
        {
            if (state.Equals("Full"))
            {
                Toast.MakeToast(Translator.Translate(resultEventArgs.Result ? "sync_success" : "sync_fail"));
            }
            else
            {
#if DEBUG
                DConsole.WriteLine($"---------------{Environment.NewLine}"
                                   + Translator.Translate(resultEventArgs.Result ? "sync_success" : "sync_fail"));
                DConsole.WriteLine($"Последняя ошибка: {LastError}");
                DConsole.WriteLine($"Результат синхронизации в callback {resultEventArgs.Result}" +
                                   $"{Environment.NewLine}{nameof(SuccessSync)}: {SuccessSync}" +
                                   $"{Environment.NewLine}---------------");
#endif
            }
            if (!resultEventArgs.Result)
            {
                isPartialSyncRequired = true;
                Utils.TraceMessage($"Full sync = {isPartialSyncRequired}");
#if DEBUG
                DConsole.WriteLine(Parameters.Splitter);
                DConsole.WriteLine($"Новые данные не пришли," +
                                   $"настройки не обновляем" +
                                   $" {nameof(resultEventArgs.Result)} = {resultEventArgs.Result}" +
                                   $"{Environment.NewLine}Last Error {_db.LastError}");
                DConsole.WriteLine(Parameters.Splitter);
#endif
                return;
            }
#if DEBUG
            DConsole.WriteLine(Parameters.Splitter);
            DConsole.WriteLine("Пришли новые настройки. Обновляем их");
            DConsole.WriteLine(Parameters.Splitter);
#endif
            Application.InvokeOnMainThread(() => GpsTracking.Stop());

            Settings.Init();

            Application.InvokeOnMainThread(() => GpsTracking.Start());

            DynamicScreenRefreshService.RefreshScreen();
            isPartialSyncRequired = false;
        }
Пример #23
0
        private static void ErrorInfo(ResultEventArgs <WebRequest.WebRequestResult> args)
        {
            switch (args.Result.Error.StatusCode)
            {
            case -1:
                DConsole.WriteLine($"{Translator.Translate("сonnection_error")} Error - {args.Result.Error.Message}");
                break;

            case 401:
                DConsole.WriteLine(
                    $"{Translator.Translate("uncorrect_login_or_pass")} Error - {args.Result.Error.Message}");
                break;

            default:
                DConsole.WriteLine($"{Translator.Translate("unexpected_error")} - Error {args.Result.Error.Message}");
                break;
            }
        }
Пример #24
0
 internal void ClientLayout_OnClick(object sender, EventArgs eventArgs)
 {
     //findText = null;
     if (!_isAddTask)
     {
         DConsole.WriteLine("ClientLayout_OnClick " + ((VerticalLayout)sender).Id);
         BusinessProcess.GlobalVariables[Parameters.IdClientId] = ((VerticalLayout)sender).Id;
         Navigation.Move("ClientScreen");
     }
     else
     {
         Navigation.ModalMove(nameof(AddTaskScreen),
                              new Dictionary <string, object>
         {
             { Parameters.IdClientId, ((VerticalLayout)sender).Id }
         });
     }
 }
Пример #25
0
 private void AddIfNotEmpty(VerticalLayout verticalLayout, IWrappedControl3 control)
 {
     if (verticalLayout.Controls.Length == 0)
     {
         verticalLayout.AddChild(control);
     }
     if (LeftButtonControl == null || RightButtonControl == null)
     {
         return;
     }
     if (LeftButtonControl.GetType().Name == nameof(Image) && RightButtonControl.GetType().Name == nameof(Image))
     {
         _leftButton.CssClass  = "TopInfoButtonLeftWithPicOnly";
         _rightButton.CssClass = "TopInfoButtonRightWithPicOnly";
         _topInfoHeadingTextLayout.CssClass = "TopInfoHeadingTextLayoutWithPicOnly";
         DConsole.WriteLine("They are both images!");
     }
 }
Пример #26
0
        public override void OnLoading()
        {
            _topInfoComponent = new TopInfoComponent(this)
            {
                LeftButtonControl  = new TextView("Отмена"),
                RightButtonControl = new TextView("Сохранить"),
                Header             = "Курочка ряба",
            };

            _topInfoComponent.CommentLayout.AddChild(new TextView("Малая балканская, 17, Санкт-Петербург"));

            _topInfoComponent.ExtraLayout.AddChild(new TextView("Экстра инфо"));
            _topInfoComponent.ExtraLayout.AddChild(new TextView("Шамеймару, Марисса, Спелл Кард, Спелл Кард, Мастер Спарк, Экстра Фантазм"));

            _indicator = (Indicator)Variables["Indicator"];
            DConsole.WriteLine($"Yes, I loaded indicator ({_indicator})");
            _indicator.Start();
        }
Пример #27
0
        public static void SyncPhotos()
        {
            var rst = DB.GetUnsyncedPhotos();

            while (rst.Next())
            {
                var id       = rst["Id"].ToString();
                var fileName = rst["FileName"].ToString();
                var link     = UploadFile(FileSystem.GetFileStream(fileName));

                if (!string.IsNullOrEmpty(link))
                {
                    DB.MarkPhotoAsSynced(id, link);
                    //FileSystem.DeleteFile(fileName);

                    DConsole.WriteLine(string.Format("Photo file {0} has been successfully uploaded", fileName));
                }
            }
        }
Пример #28
0
        /// <summary>
        ///     Перейти на один экран по стеку назад
        /// </summary>
        /// <param name="reload">Перезагржать ли целевой экран (ВНИМАНИЕ, СТАВИТЬ СЮДА false ОПАСНО)</param>
        public static void Back(bool reload = true)
        {
            if (ScreenInfoStack.Count == 0)
            {
                DConsole.WriteLine("Can't go back when stack is empty");
                return;
            }
            var screenInfo = (ScreenInfo)ScreenInfoStack.Pop();
            var nextScreen = (Screen)ScreenStack.Pop();

            if (!reload)
            {
                ModalMove(screenInfo, screen: nextScreen);
            }
            else
            {
                ModalMove(screenInfo, nextScreen.Variables);
            }
        }
Пример #29
0
        internal string DateTimeToDateWithWeekCheck(string datetime)
        {
            DateTime workDate;
            var      Wecan = DateTime.TryParse(datetime, out workDate);

            if (Wecan)
            {
                workDate = workDate.Date;
            }
            else
            {
                workDate = DateTime.MinValue.Date;
                return(datetime);
            }
            var currentDate = DateTime.Now.Date;

            DConsole.WriteLine($"week = {currentDate.GetWeekNumber()}");

            var workDateWeekNumber    = workDate.GetWeekNumber();
            var currentDateWeekNumber = currentDate.GetWeekNumber();

            if (workDate.Equals(currentDate.AddDays(1)))
            {
                return(Translator.Translate("tomorrowToUpper"));
            }

            if (workDate.Equals(currentDate.AddDays(-1)))
            {
                return(Translator.Translate("yesterdayToUpper"));
            }

            if (workDate.Equals(currentDate))
            {
                return(Translator.Translate("todayUpper"));
            }

            if (workDateWeekNumber == currentDateWeekNumber)
            {
                return(workDate.ToString("dddd, dd MMMM").ToUpper());
            }
            return(workDate.ToString("dd MMMM yyyy").ToUpper());
        }
Пример #30
0
        private void FillMap()
        {
            DConsole.WriteLine("start FillMap");
            DConsole.WriteLine($"{nameof(_location)}.{nameof(_location.Count)} = {_location.Count}");
            foreach (var element in _location)
            {
                var item        = (Dictionary <string, object>)element;
                var description = (string)item["Description"];
                var latitude    = (double)(decimal)item["Latitude"];
                var longitude   = (double)(decimal)item["Longitude"];

                DConsole.WriteLine($"{nameof(description)}:{description} " +
                                   $"{Environment.NewLine} " +
                                   $"{nameof(latitude)}={latitude} " +
                                   $"{nameof(longitude)}={longitude}");

                _map.AddMarker(description, latitude, longitude, "red");
            }
            DConsole.WriteLine("end FillMap");
        }