예제 #1
0
        void Login()
        {
            AppVariable.Variable.Login            = mLogin.Text;
            AppVariable.Variable.Password         = mPass.Text;
            AppVariable.Variable.fireBaseClientID = FirebaseInstanceId.Instance.Token;

            mProgressDialog.SetMessage("Вход...");
            mProgressDialog.Show();

            Dictionary <string, Dictionary <string, string> > LoginData = new Dictionary <string, Dictionary <string, string> >();

            Dictionary <string, string> AppInfo = new Dictionary <string, string>();

            AppInfo.Add("AppVersion", AppVariable.Variable.version.ToString());
            AppInfo.Add("AppFirebaseClientID", AppVariable.Variable.fireBaseClientID);
            AppInfo.Add("DevVersionSDK", AppVariable.Variable.versionSDK);
            AppInfo.Add("DevModelName", AppVariable.Variable.modelName);
            LoginData.Add("AppInfo", AppInfo);

            Dictionary <string, string> Parameters = new Dictionary <string, string>();

            if (mSigninwithapin.Checked)
            {
                AppVariable.Variable.Password = "";
                Parameters.Add("pin", mPass.Text);
            }
            LoginData.Add("Parameters", Parameters);

            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.InitAppAsync(JsonConvert.SerializeObject(LoginData));
            dataSetWS.InitAppCompleted += DataSetWS_InitAppCompleted;
        }
        public override void OnMessageReceived(RemoteMessage message)
        {
            if (message.GetNotification() != null)
            {
                int    nid         = message.Data.ContainsKey("id") ? int.Parse(message.Data["id"]) : AppVariable.nIDFcm;
                string nref        = message.Data.ContainsKey("ref") ? message.Data["ref"] : string.Empty;
                string nreflistmod = message.Data.ContainsKey("reflistmod") ? message.Data["reflistmod"] : string.Empty;
                string nname       = message.Data.ContainsKey("name") ? message.Data["name"] : string.Empty;

                ShowNotification(message.GetNotification().Title, message.GetNotification().Body, nid, nref, nreflistmod, nname);
            }
            else
            {
                if (message.Data.Count > 0)
                {
                    if (message.Data["confirmation"] == "true")
                    {
                        if (!AppPreferences.Preferences.GetPreferences("remember", false))
                        {
                            return;
                        }

                        if (!AppVariable.Variable.isOnline)
                        {
                            AppPreferences.Preferences.LoadPreferences();
                        }

                        DataSetWS dataSetWS = new DataSetWS();
                        dataSetWS.SetMessageCompleted += DataSetWS_SetMessageCompleted;
                        dataSetWS.SetMessageAsync("{\"action\" : \"setstate\", \"id\" : " + message.Data["id"] + ", \"status\" : \"recive\"}");
                    }
                }
            }
        }
예제 #3
0
        private void DeleteMessage()
        {
            DataSetWS dataSetWs = new DataSetWS();

            dataSetWs.SetMessageCompleted += DataSetWs_SetMessageCompleted;
            dataSetWs.SetMessageAsync("{\"action\" : \"setstate\", \"id\" : " + mCurentMessageID.ToString() + ", \"status\" : \"delete\"}");
        }
        private void SetDeleteMark()
        {
            AlertDialog.Builder quitDialog = new AlertDialog.Builder(this);
            quitDialog.SetTitle("Вы уверены?");
            quitDialog.SetPositiveButton("Да", (senderAlert, args) =>
            {
                var item = mAdapterDataList.GetItemAtPosition(mSelectedItemPosition);

                Dictionary <long, ElementData> mCommands = new Dictionary <long, ElementData>();
                mCommands.Add(0, new ElementData()
                {
                    Name = "delete", Data = "delete"
                });
                string output               = JsonConvert.SerializeObject(mCommands);
                DataSetWS dataSetWS         = new DataSetWS();
                dataSetWS.SetDataCompleted += DataSetWS_SetDataCompleted;
                dataSetWS.SetDataAsync(mRef, item.Ref, output, AppVariable.Variable.getSessionParametersJSON());
                mCommands.Remove(0);
            });
            quitDialog.SetNegativeButton("Нет", (senderAlert, args) =>
            {
            });
            Dialog dialog = quitDialog.Create();

            dialog.Show();
        }
예제 #5
0
        public void UpdateData()
        {
            mProgressDialog.SetMessage("Получение информации...");
            mProgressDialog.Show();

            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.GetFileCompleted += DataSetWS_GetFileCompleted;
            dataSetWS.GetFileAsync(mRef);
        }
        private void GetDataFromWS()
        {
            if (AppVariable.Variable.isOnline != true)
            {
                return;
            }
            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.GetDataCompleted += DataSetWS_GetDataCompleted;
            dataSetWS.GetDataAsync(mRefListMod, mRef, AppVariable.Variable.getSessionParametersJSON());

            mProgressDialog.SetMessage("Загрузка...");
            mProgressDialog.Show();
        }
예제 #7
0
 private void SendMessage()
 {
     if (CheckField())
     {
         mProgressDialog.SetMessage("Отправка...");
         mProgressDialog.Show();
         DataSetWS dataSetWs = new DataSetWS();
         dataSetWs.SetMessageCompleted += DataSetWs_SetMessageCompleted;
         dataSetWs.SetMessageAsync(new MessageSender()
         {
             recivers = Recivers, title = mTitle.Text, message = mMessage.Text
         }.getJsonString());
     }
 }
예제 #8
0
        public void GetPeriodicData(Context context)
        {
            this.context = context;

            if (AppPreferences.Preferences.GetPreferences("remember", false))
            {
                if (!AppVariable.Variable.isOnline)
                {
                    AppPreferences.Preferences.LoadPreferences();
                }

                DataSetWS dataSetWS = new DataSetWS();
                dataSetWS.GetPeriodicDataCompleted += DataSetWS_GetPeriodicDataCompleted;
                dataSetWS.GetPeriodicDataAsync("");
            }
        }
        private void SetDataByRef(string Name, string Data)
        {
            mElements.Add(0, new ElementData()
            {
                Name = Name, Data = Data
            });
            string    output    = JsonConvert.SerializeObject(mElements);
            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.SetDataCompleted += DataSetWS_SetDataCompleted;
            dataSetWS.SetDataAsync(mRefListMod, mRef, output, AppVariable.Variable.getSessionParametersJSON());
            mElements.Remove(0);

            mProgressDialog.SetMessage("Отправка...");
            mProgressDialog.Show();
        }
예제 #10
0
        public void UpdateList()
        {
            mDataMessages = new DataMessages();
            DataSetWS dataSetWS         = new DataSetWS();
            string    AllMessagesResult = string.Empty;

            try
            {
                AllMessagesResult = dataSetWS.GetMessage("");
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                });
                return;
            }

            JObject jsonResult = JObject.Parse(AllMessagesResult);

            foreach (JObject Elements in jsonResult["Data"])
            {
                JValue jDirectIn  = (JValue)Elements["DirectIn"];
                JValue jMessageID = (JValue)Elements["MessageID"];
                JValue jTitle     = (JValue)Elements["Title"];
                JValue jDate      = (JValue)Elements["Date"];
                JValue jText      = (JValue)Elements["Text"];
                JValue jUserRef   = (JValue)Elements["UserRef"];
                JValue jUserStr   = (JValue)Elements["UserStr"];
                JValue jRecive    = (JValue)Elements["Recive"];
                JValue jRead      = (JValue)Elements["Read"];
                JValue jFix       = (JValue)Elements["Fix"];
                mDataMessages.Add(new Message
                {
                    DirectIn  = (bool)jDirectIn.Value,
                    MessageID = (long)jMessageID.Value,
                    Title     = (string)jTitle.Value,
                    Date      = (DateTime)jDate.Value,
                    Text      = (string)jText.Value,
                    UserRef   = (string)jUserRef.Value,
                    UserStr   = (string)jUserStr.Value,
                    Recive    = (bool)jRecive.Value,
                    Read      = (bool)jRead.Value,
                    Fix       = (bool)jFix.Value
                });
            }
        }
예제 #11
0
        public void UpdateList()
        {
            items = new List <DataElements>();

            if (mRef == null)
            {
                return;
            }

            DataSetWS dataSetWS = new DataSetWS();

            string AllowGroupsResult = string.Empty;

            try
            {
                AllowGroupsResult = dataSetWS.GetElements(mRef);
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    return;
                });
                return;
            }

            JObject jsonResult = JObject.Parse(AllowGroupsResult);

            foreach (JObject Elements in jsonResult["Data"])
            {
                JValue jName        = (JValue)Elements["Name"];
                JValue jDescription = (JValue)Elements["Description"];
                JValue jRef         = (JValue)Elements["Ref"];
                JValue jRead        = (JValue)Elements["Read"];
                JValue jEdit        = (JValue)Elements["Edit"];
                JValue jDelete      = (JValue)Elements["Delete"];
                items.Add(new DataElements()
                {
                    Name        = (string)jName.Value,
                    Description = (string)jDescription.Value,
                    Ref         = (string)jRef.Value,
                    Read        = (bool)jRead.Value,
                    Edit        = (bool)jEdit.Value,
                    Delete      = (bool)jDelete.Value
                });
            }
        }
예제 #12
0
        public void UpdateList()
        {
            DataSetWS dataSetWS     = new DataSetWS();
            string    AllNewsResult = dataSetWS.GetNews();

            JObject jsonResult = JObject.Parse(AllNewsResult);

            foreach (JObject Elements in jsonResult["Data"])
            {
                JValue jTitle = (JValue)Elements["Title"];
                JValue jDate  = (JValue)Elements["Date"];
                JValue jText  = (JValue)Elements["Text"];
                JValue jAutor = (JValue)Elements["Autor"];
                JValue jFix   = (JValue)Elements["Fix"];
                mDataNews.Add(new News
                {
                    Title = (string)jTitle.Value,
                    Date  = (DateTime)jDate.Value,
                    Text  = (string)jText.Value,
                    Autor = (string)jAutor.Value,
                    Fix   = (bool)jFix.Value
                });
            }
        }
예제 #13
0
        public void UpdateList()
        {
            items = new List <DataGroups>();

            DataSetWS dataSetWS = new DataSetWS();

            string AllowGroupsResult = string.Empty;

            try
            {
                AllowGroupsResult = dataSetWS.GetGroups();
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    return;
                });
                return;
            }

            JObject jsonResult = JObject.Parse(AllowGroupsResult);

            items.Add(new DataGroups()
            {
                Name = "Главная страница", Description = "Новости", Image = Resource.Drawable.Main, Ref = "", ItemCount = String.Empty
            });
            items.Add(new DataGroups()
            {
                Name = "Сообщения", Description = "", Image = Resource.Drawable.Messages, Ref = "", ItemCount = String.Empty
            });
            int totalItemCount = 0;

            foreach (JObject Group in jsonResult["Data"])
            {
                string Name      = (string)(Group.Property("Name").Value);
                string Ref       = (string)(Group.Property("Ref").Value);
                string ItemCount = Group.Property("ItemCount") == null ? String.Empty : (string)(Group.Property("ItemCount").Value);
                totalItemCount += Group.Property("ItemCount") == null ? 0 : Convert.ToInt16((string)(Group.Property("ItemCount").Value));
                int imageId = 0;
                switch (Name)
                {
                case "Задачи":
                    imageId = Resource.Drawable.Tasks;
                    break;

                case "Справочники":
                    imageId = Resource.Drawable.Directories;
                    break;

                case "Документы":
                    imageId = Resource.Drawable.Documents;
                    break;

                case "Обработки":
                    imageId = Resource.Drawable.DataProcessor;
                    break;

                case "Отчеты":
                    imageId = Resource.Drawable.Reports;
                    break;

                case "Прочее":
                    imageId = Resource.Drawable.Other;
                    break;
                }
                items.Add(new DataGroups()
                {
                    Name = Name, Description = "", Image = imageId, Ref = Ref, ItemCount = ItemCount
                });
            }
            ShortcutBadger.ApplyCount(mContext, totalItemCount);
        }
        void Login()
        {
            AppVariable.Variable.Login    = mLogin.Text;
            AppVariable.Variable.Password = mPass.Text;

            //получение настроек для "продвинутых" пользователей   начало
            bool         isCurrentUserAdvanced    = false;
            WebClient    devopts_webclient        = new WebClient();
            string       devopts_DefaultUpdateURL = "http://1c.pozitivtelecom.ru:81/MobileApp";
            const string devoptsFile = "devopts.json";
            Uri          devopts_url = new Uri(devopts_DefaultUpdateURL + "/" + devoptsFile);

            try
            {
                string  stringResult     = devopts_webclient.DownloadString(devopts_url);
                JObject jsonResult       = JObject.Parse(stringResult);
                JArray  advancedUsersSet = (JArray)jsonResult["advancedUsersSet"];

                string advServerUrl = "";
                foreach (var advUser in advancedUsersSet)
                {
                    if (mLogin.Text == (string)advUser["UserName"])
                    {
                        isCurrentUserAdvanced = true;
                        if (advUser["ServerUrl"] != null)
                        {
                            advServerUrl = (string)advUser["ServerUrl"];
                        }
                        break;
                    }
                }


                AppVariable.Variable.WsURL = "http://1c.pozitivtelecom.ru/SkladPozitiv/ws/app.1cws";
                AppPreferences.Preferences.SetPreferences("WsURL", AppVariable.Variable.WsURL);
                if (isCurrentUserAdvanced)
                {
                    if (advServerUrl.Length > 0)
                    {
                        AppVariable.Variable.WsURL = advServerUrl;
                        AppPreferences.Preferences.SetPreferences("WsURL", advServerUrl);
                    }
                }
            }
            catch (Exception e)
            {
                clearPreferences();
                string problemPath = devopts_DefaultUpdateURL + "/" + devoptsFile;
                var    mAlert      = new AlertDialog.Builder(this)
                                     .SetTitle("Ошибка связи с сервером.")
                                     .SetMessage("Файл \"" + problemPath + "\" не доступен! Исключение: " + e.Message)
                                     .SetCancelable(true)
                                     .Show();
                Toast.MakeText(this, "Файл \"" + problemPath + "\" не доступен! Исключение: " + e.Message, ToastLength.Short);
                return;
            }
            //получение настроек для "продвинутых" пользователей   конец

            mProgressDialog.SetMessage("Вход...");
            mProgressDialog.Show();

            Dictionary <string, Dictionary <string, string> > LoginData = new Dictionary <string, Dictionary <string, string> >();

            Dictionary <string, string> AppInfo = new Dictionary <string, string>();

            AppInfo.Add("AppVersion", AppVariable.Variable.version.ToString());
            AppInfo.Add("DevVersionSDK", AppVariable.Variable.versionSDK);
            AppInfo.Add("DevModelName", AppVariable.Variable.modelName);
            LoginData.Add("AppInfo", AppInfo);

            Dictionary <string, string> Parameters = new Dictionary <string, string>();

            if (mSigninwithapin.Checked)
            {
                AppVariable.Variable.Password = "";
                Parameters.Add("pin", mPass.Text);
            }
            LoginData.Add("Parameters", Parameters);

            DataSetWS dataSetWS = new DataSetWS();

            dataSetWS.InitAppAsync(JsonConvert.SerializeObject(LoginData));
            dataSetWS.InitAppCompleted += DataSetWS_InitAppCompleted;
        }
        private void UpdateList()
        {
            items = new List <DataDataList>();


            //извлечение данных из 1с   начало
            var mContext = this;

            DataSetWS dataSetWS = new DataSetWS();

            string DatalistResult = string.Empty;

            try
            {
                DatalistResult = dataSetWS.GetList(mRef, AppVariable.Variable.getSessionParametersJSON());
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    mContext.Finish();
                });
                return;
            }

            JObject jsonResult = JObject.Parse(DatalistResult);

            if (jsonResult.Property("Error") == null)
            {
                foreach (JObject Group in jsonResult["Data"])
                {
                    Newtonsoft.Json.Linq.JValue Name        = (Newtonsoft.Json.Linq.JValue)Group["Name"];
                    Newtonsoft.Json.Linq.JValue Ref         = (Newtonsoft.Json.Linq.JValue)Group["Ref"];
                    Newtonsoft.Json.Linq.JValue Description = (Newtonsoft.Json.Linq.JValue)Group["Description"];



                    items.Add(new DataDataList()
                    {
                        Name = (string)Name.Value, Description = (string)Description.Value, Ref = (string)Ref.Value
                    });
                }
            }
            else
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, (string)jsonResult.Property("Error").Value, ToastLength.Long).Show();
                    mContext.Finish();
                });
            }
            //извлечение данных из 1с   конец

            Button nButton = new Android.Support.V7.Widget.AppCompatButton(this)
            {
                Id = 0
            };

            nButton.Text   = "Очистить";
            nButton.Click += clearEquip;
            mLinearLayout.AddView(nButton);

            Button nButton2 = new Android.Support.V7.Widget.AppCompatButton(this)
            {
                Id = 1
            };

            nButton2.Text   = "Выбрать";
            nButton2.Click += finishEquip;
            mLinearLayout.AddView(nButton2);


            TableLayout mTableLayout = new TableLayout(this);
            var         param        = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            mTableLayout.SetColumnStretchable(0, true);
            mTableLayout.SetColumnShrinkable(0, true);
            mLinearLayout.AddView(mTableLayout, param);



            var curId = 2;

            foreach (var itt in items)
            {
                TableRow mNewRow = new TableRow(this);
                mNewRow.SetGravity(GravityFlags.CenterVertical);
                mTableLayout.AddView(mNewRow);

                TextView mTextViewDesc = new TextView(this);
                mTextViewDesc.Text = itt.Name;
                mNewRow.AddView(mTextViewDesc);


                TextView nTextView = new TextView(this)
                {
                    Id = curId
                };
                nTextView.SetTextSize(Android.Util.ComplexUnitType.Sp, 18);
                nTextView.Text = getSelItemCount(itt.Ref);


                mElements.Add(curId, nTextView);

                mNewRow.AddView(nTextView);
                ImageButton myImageButton1 = new ImageButton(this)
                {
                    Id = curId + 1000
                };
                myImageButton1.SetImageResource(Resource.Drawable.ic_action_new);
                myImageButton1.Click += plusButtonClicked;
                mNewRow.AddView(myImageButton1);

                ImageButton myImageButton2 = new ImageButton(this)
                {
                    Id = curId + 2000
                };
                myImageButton2.SetImageResource(Resource.Drawable.ic_action_minus);
                myImageButton2.Click += minusButtonClicked;
                mNewRow.AddView(myImageButton2);

                curId++;
            }
        }
예제 #16
0
        public void UpdateList()
        {
            itemsOrig = new List <DataDataList>();
            items     = itemsOrig;

            DataSetWS dataSetWS = new DataSetWS();

            string DatalistResult = string.Empty;

            try
            {
                DatalistResult = dataSetWS.GetList(mRef, AppVariable.Variable.getSessionParametersJSON());
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    mContext.Finish();
                });
                return;
            }

            JObject jsonResult = JObject.Parse(DatalistResult);

            if (jsonResult.Property("Error") == null)
            {
                foreach (JObject Group in jsonResult["Data"])
                {
                    JValue Name        = (JValue)Group["Name"];
                    JValue Ref         = (JValue)Group["Ref"];
                    JValue Description = (JValue)Group["Description"];

                    int imgeID = Resource.Drawable.ic_document;
                    if (Group.Property("Image") != null)
                    {
                        JValue Image = (JValue)Group["Image"];
                        switch ((string)Image.Value)
                        {
                        case "Document":
                            imgeID = Resource.Drawable.ic_document;
                            break;

                        case "DocumentDeleted":
                            imgeID = Resource.Drawable.ic_document_deleted;
                            break;

                        case "DocumentAccept":
                            imgeID = Resource.Drawable.ic_document_accept;
                            break;
                        }
                    }

                    itemsOrig.Add(new DataDataList()
                    {
                        Name = (string)Name.Value, Description = (string)Description.Value, Image = imgeID, Ref = (string)Ref.Value
                    });
                }
                items = itemsOrig;
            }
            else
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, (string)jsonResult.Property("Error").Value, ToastLength.Long).Show();
                    mContext.Finish();
                });
            }
        }