Beispiel #1
0
        public static DbRef GetDbRefFromEnum(ResultEventEnum @enum)
        {
            string res = null;

            switch (@enum)
            {
            case ResultEventEnum.New:
                res = "ae46ba49-b076-6c8c-4730-4709e7191d5b";
                break;

            case ResultEventEnum.Done:
                res = "81270b2c-190a-faf2-440f-4a593042495e";
                break;

            case ResultEventEnum.NotDone:
                res = "9956cf47-e216-522e-48f6-8aba06fc9a5e";
                break;
            }
            if (string.IsNullOrEmpty(res))
            {
                return(null);
            }
            return(DbRef.FromString($"@ref[Enum_ResultEvent]:{res}"));
        }
Beispiel #2
0
        public static DbRef GetDbRefFromEnum(StatusTasksEnum @enum)
        {
            string res = null;

            switch (@enum)
            {
            case StatusTasksEnum.New:
                res = "a0a9e67f-483e-419a-a714-859f13c1245c";
                break;

            case StatusTasksEnum.Done:
                res = "a0a9e67f-483e-423a-a714-859f13c1245c";
                break;

            case StatusTasksEnum.Rejected:
                res = "a0a9e67f-483e-426b-a714-859f13c1245c";
                break;
            }
            if (string.IsNullOrEmpty(res))
            {
                return(null);
            }
            return(DbRef.FromString($"@ref[Enum_StatusTasks]:{res}"));
        }
        internal void TopInfo_RightButton_OnClick(object sender, EventArgs e)
        {
            var name     = ((EditText)Variables["NameEditText"]).Text;
            var surname  = ((EditText)Variables["SurnameEditText"]).Text;
            var position = ((EditText)Variables["PositionEditText"]).Text;
            var phone    = ((EditText)Variables["PhoneEditText"]).Text;
            var email    = ((EditText)Variables["EMailEditText"]).Text;

            // TODO: Разбраться с Code
            if (string.IsNullOrWhiteSpace(name))
            {
                Dialog.Message(Translator.Translate("forgot_name"));
                return;
            }

            Contact.Description = $"{name} {surname}";
            Contact.Position    = position;
            Contact.Tel         = phone;
            Contact.EMail       = email;

            DBHelper.SaveEntity(Contact);

            if (_clientId != null)
            {
                // TODO Разобраться с LineNumber
                var clientContacts = new Client_Contacts
                {
                    Ref     = DbRef.FromString(_clientId),
                    Id      = DbRef.CreateInstance("Catalog_Client_Contacts", Guid.NewGuid()),
                    Contact = Contact.Id,
                    Actual  = false // Actual на самом деле означает "уволен"
                };
                DBHelper.SaveEntity(clientContacts);
            }
            Navigation.Back();
        }
Beispiel #4
0
        public static DbRef GetDbRefFromEnum(CheckListStatusEnum @enum)
        {
            string res = null;

            switch (@enum)
            {
            case CheckListStatusEnum.Blank:
                res = "854946f6-fc1d-bec2-4968-1f7e3c8d3c61";
                break;

            case CheckListStatusEnum.Active:
                res = "ba4d325a-f1b7-072d-4c3e-fd4bf9f33901";
                break;

            case CheckListStatusEnum.Disactive:
                res = "ab0acbab-556c-7058-4ba9-e4cd72c2958d";
                break;
            }
            if (string.IsNullOrEmpty(res))
            {
                return(null);
            }
            return(DbRef.FromString($"@ref[Enum_CheckListStatus]:{res}"));
        }
        public static DbRef GetDbRefFromEnum(StatusImportanceEnum @enum)
        {
            string res = null;

            switch (@enum)
            {
            case StatusImportanceEnum.Standart:
                res = "9deb314e-1bd6-1ee0-4eb2-ac621ba09b74";
                break;

            case StatusImportanceEnum.High:
                res = "9495d0f0-6ef5-a7fe-473f-8e2d6e8586e2";
                break;

            case StatusImportanceEnum.Critical:
                res = "a570aeea-0f88-54c3-4075-d0cb82f0dd95";
                break;
            }
            if (string.IsNullOrEmpty(res))
            {
                return(null);
            }
            return(DbRef.FromString($"@ref[Enum_StatusImportance]:{res}"));
        }
Beispiel #6
0
        private object Parse(Type type, object value)
        {
            object result     = null;
            bool   isNullable = !type.IsValueType;
            Type   t          = Nullable.GetUnderlyingType(type);

            if (t == null)
            {
                t          = type;
                isNullable = true;
            }

            if (value == null)
            {
                return(isNullable ? null : Activator.CreateInstance(type));
            }

            var str = value as string;

            if (str != null)
            {
                if (t == typeof(IDbRef))
                {
                    if (DbRef.CheckIsRef(str))
                    {
                        result = DbRef.FromString(str);
                    }
                    else
                    {
                        throw new Exception("Invalid DBRef: " + str);
                    }
                }
                else if (type == typeof(string))
                {
                    result = str;
                }
                else if (t == typeof(Guid))
                {
                    result = Guid.Parse(str);
                }
                else if (t == typeof(DateTime))
                {
                    result = DateTime.Parse(str);
                }
                else if (t == typeof(Int32))
                {
                    result = Int32.Parse(str);
                }
                else if (t == typeof(Decimal))
                {
                    decimal dec;
                    if (!Decimal.TryParse(str, out dec))
                    {
                        dec = Decimal.Parse(str, CultureInfo.InvariantCulture);
                    }
                    result = dec;
                }
                else if (t == typeof(Boolean))
                {
                    result = Boolean.Parse(str);
                }
            }
            else if (t.IsInterface && value != null && value.GetType().GetInterfaces().Contains(t))
            {
                result = value;
            }
            else
            {
                try
                {
                    result = Convert.ChangeType(value, t);
                }
                catch (FormatException)
                {
                    result = Convert.ChangeType(value, t, CultureInfo.InvariantCulture);
                }
            }

            return(result);
        }
Beispiel #7
0
        public static DbRef GetDbRefFromEnum(WebactionsEnum @enum)
        {
            string res = null;

            switch (@enum)
            {
            case WebactionsEnum.EventsEditing:
                res = "0236eb9f-eed9-489b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EventsDeleting:
                res = "0236eb9f-eed9-490b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EventsOptionsEditing:
                res = "0236eb9f-eed9-491b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EventsAllAvaliable:
                res = "0236eb9f-eed9-492b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EventsShowAVR:
                res = "0236eb9f-eed9-494b-9152-86b037e79a79";
                break;

            case WebactionsEnum.UsersEditing:
                res = "0236eb9f-eed9-495b-9152-86b037e79a79";
                break;

            case WebactionsEnum.UsersDeleting:
                res = "0236eb9f-eed9-496b-9152-86b037e79a79";
                break;

            case WebactionsEnum.UsersManageRoles:
                res = "0236eb9f-eed9-497b-9152-86b037e79a79";
                break;

            case WebactionsEnum.ClientsEditing:
                res = "0236eb9f-eed9-498b-9152-86b037e79a79";
                break;

            case WebactionsEnum.ClientsDeleting:
                res = "0236eb9f-eed9-499b-9152-86b037e79a79";
                break;

            case WebactionsEnum.ClientsOptionsEditing:
                res = "0236eb9f-eed9-500b-9152-86b037e79a79";
                break;

            case WebactionsEnum.TasksEditing:
                res = "0236eb9f-eed9-501b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EquipmentsEditing:
                res = "0236eb9f-eed9-502b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EquipmentsDeleting:
                res = "0236eb9f-eed9-503b-9152-86b037e79a79";
                break;

            case WebactionsEnum.EquipmentsOptionsEditing:
                res = "0236eb9f-eed9-504b-9152-86b037e79a79";
                break;

            case WebactionsEnum.RIMEditing:
                res = "0236eb9f-eed9-505b-9152-86b037e79a79";
                break;

            case WebactionsEnum.RIMDeleting:
                res = "0236eb9f-eed9-506b-9152-86b037e79a79";
                break;

            case WebactionsEnum.CheckListsEditing:
                res = "0236eb9f-eed9-507b-9152-86b037e79a79";
                break;

            case WebactionsEnum.CheckListManageActivityStatus:
                res = "0236eb9f-eed9-508b-9152-86b037e79a79";
                break;

            case WebactionsEnum.AnaliticAccess:
                res = "0236eb9f-eed9-509b-9152-86b037e79a79";
                break;

            case WebactionsEnum.WebInterfaceAccess:
                res = "0236eb9f-eed9-510b-9152-86b037e79a79";
                break;

            case WebactionsEnum.MobileAppAccess:
                res = "0236eb9f-eed9-511b-9152-86b037e79a79";
                break;

            case WebactionsEnum.MobileFPRAccess:
                res = "f22c49d3-42b4-4ccc-9646-970ee8f7db23";
                break;
            }
            if (string.IsNullOrEmpty(res))
            {
                return(null);
            }
            return(DbRef.FromString($"@ref[Enum_Webactions]:{res}"));
        }
Beispiel #8
0
 public static object LoadEntity(string id)
 {
     return(DbRef.FromString(id).GetObject());
 }
Beispiel #9
0
        internal void Print_OnClick(object sender, EventArgs e)
        {
            _enteredSumEditText.Enabled = false;

            var checkParameters = new Event_EventFiskalProperties
            {
                Id = DbRef.CreateInstance($"Document_{nameof(Event_EventFiskalProperties)}"
                                          , Guid.NewGuid()),
                Ref  = DbRef.FromString(_eventId),
                User = Settings.UserDetailedInfo.Id
            };

            Dialog.ShowProgressDialog(Translator.Translate("please_wait"), true);

            TaskFactory.RunTaskWithTimeout(() =>
            {
                var checkError = false;

                try
                {
                    PrintCheck();

                    if (_fptr.CloseCheck() < 0)
                    {
                        _fptr.CheckError();
                    }

                    checkParameters.Date = DateTime.Now;

                    DBHelper.SaveEntity(checkParameters, false);
                }
                catch (FPTRException exception)
                {
                    Utils.TraceMessage($"Error code {exception.Result} {exception.Message}");
                    checkError = true;
                    Toast.MakeToast(Translator.Translate(exception.Message));
                }
                catch (Exception exception)
                {
                    Utils.TraceMessage($"{exception.Message}{Environment.NewLine}" +
                                       $"Type {exception.GetType()}");
                }

                Utils.TraceMessage($"Check Error: {checkError}");

                if (!checkError)
                {
                    SaveFptrParameters(checkParameters);
                    BusinessProcess.GlobalVariables[Parameters.IdCurrentEventId] = _eventId;

                    Utils.TraceMessage($"GoTo {nameof(COCScreen)}");
                    Application.InvokeOnMainThread(() =>
                    {
                        Navigation.ModalMove(nameof(COCScreen), new Dictionary <string, object>
                        {
                            { Parameters.IdCurrentEventId, _eventId },
                            { Parameters.IdIsReadonly, _readonly },
                            { Parameters.IdWasEventStarted, _wasStarted }
                        });
                    });
                }
                else
                {
                    try
                    {
                        DBHelper.DeleteByRef(checkParameters.Id, false);
                        _fptr.CancelCheck();
                    }
                    catch (FPTRException exception)
                    {
                        Toast.MakeToast(Translator.Translate(exception.Message));
                    }
                    finally
                    {
                        if (_choosedPaymentType == 0)
                        {
                            Application.InvokeOnMainThread(()
                                                           => _enteredSumEditText.Enabled = true);
                        }
                    }
                }
            }, FptrAction.PrintingTimeOut, result =>
            {
                if (result.Finished)
                {
                    Dialog.HideProgressDialog();
                    return;
                }

                Dialog.HideProgressDialog();
                Toast.MakeToast(Translator.Translate("сonnection_error"));
            });
        }
Beispiel #10
0
        internal void FinishButton_OnClick(object sender, EventArgs eventArgs)
        {
            if (_eventResults.Id == null)
            {
                Toast.MakeToast("Результат завершения не может быть пустым");
                return;
            }


            Utils.TraceMessage($"_eventResult.Id.Empty: {_eventResults.Id.EmptyRef()} not {!_eventResults.Id.EmptyRef()}{Environment.NewLine}" +
                               $"_evenResult.Negative {_eventResults.Negative} {Environment.NewLine}" +
                               $"string.IsNullOrEmpty(_commentaryMemoEdit.Text) {string.IsNullOrEmpty(_commentaryMemoEdit.Text)}{Environment.NewLine}" +
                               $"Total Result: {!_eventResults.Id.EmptyRef() && _eventResults.Negative && string.IsNullOrEmpty(_commentaryMemoEdit.Text)}");

            if (!_eventResults.Id.EmptyRef() && _eventResults.Negative && string.IsNullOrEmpty(_commentaryMemoEdit.Text))
            {
                Toast.MakeToast("Комментарий не может быть пустым");
                return;
            }
            var eventRef     = DbRef.FromString((string)BusinessProcess.GlobalVariables[Parameters.IdCurrentEventId]);
            var entitiesList = new ArrayList();
            var @event       = (Event)eventRef.GetObject();

            if (((TypesEvents)@event.KindEvent.GetObject()).Name == "Visit")
            {
                var result    = DBHelper.GetCoordinate(TimeRangeCoordinate.DefaultTimeRange);
                var latitude  = Converter.ToDouble(result["Latitude"]);
                var longitude = Converter.ToDouble(result["Longitude"]);
                @event.Latitude  = Converter.ToDecimal(latitude);
                @event.Longitude = Converter.ToDecimal(longitude);
                var text = "";
                Utils.TraceMessage($"lat:{latitude} long:{longitude}");
                if (latitude.Equals(0) & longitude.Equals(0))
                {
                    text += "Не удалось сохранить координаты встречи";
                }
                else
                {
                    text += "Координаты встречи успешно сохранены";
                }
                Toast.MakeToast(text);
            }



            if (!string.IsNullOrEmpty(_commentaryMemoEdit.Text))
            {
                @event.CommentContractor = _commentaryMemoEdit.Text;
            }

            if (!_eventResults.Id.EmptyRef())
            {
                @event.EventResult = _eventResults.Id;
            }

            if (!string.IsNullOrEmpty(@event.CommentContractor) || [email protected]())
            {
                entitiesList.Add(@event);
            }

            DBHelper.SaveEntities(entitiesList);

            _eventResults     = null;
            _commentaryString = null;
            Navigation.CleanStack();
            Navigation.ModalMove("EventListScreen");
        }