Exemplo n.º 1
0
        public async Task postattachmentcomplianceAsync(Comp_AttachmentModel compmodel)
        {
            progress.Show();
            List <Comp_AttachmentModel> models = new List <Comp_AttachmentModel>();

            //for(int i=0; i < models.Count; i++)
            //{
            models.Add(compmodel);
            //  }

            if (compmodel.file_type == "Image")
            {
                byte[] img  = GetStreamFromFile(compmodel.localPath);
                var    url1 = await blob.UploadPhotoAsync(img, compmodel.localPath.Substring(compmodel.localPath.LastIndexOf("/") + 1));

                if (url1 != null)
                {
                    compmodel.Path = url1;
                }
            }
            if (compmodel.file_type == "Video")
            {
                byte[] img  = GetStreamFromFile(compmodel.localPath);
                var    url1 = await blob.UploadPhotoAsync(img, compmodel.localPath.Substring(compmodel.localPath.LastIndexOf("/") + 1));

                if (url1 != null)
                {
                    compmodel.Path = url1;
                }
            }
            if (compmodel.file_type == "Audio")
            {
                byte[] img  = GetStreamFromFile(compmodel.localPath);
                var    url1 = await blob.UploadPhotoAsync(img, compmodel.localPath.Substring(compmodel.localPath.LastIndexOf("/") + 1));

                if (url1 != null)
                {
                    compmodel.Path = url1;
                }
            }

            string json = JsonConvert.SerializeObject(models);

            try
            {
                string item = await restService.CompliancePostServiceMethod(Activity, "UpoadTaskCompliance", json, Description.Text);

                if (item.Contains("Compliance Upload Sucessfully"))
                {
                    db.updateComplianceStatus(compmodel.taskId);
                    Toast.MakeText(Activity, "attachment post  Successfully..", ToastLength.Long).Show();
                    //progress.Dismiss();
                }
                else
                {
                    Toast.MakeText(Activity, "Oops! Something Went Wrong.", ToastLength.Long).Show();
                    //progress.Dismiss();
                }
            }
            catch (Exception ex)
            {
                //progress.Dismiss();
            }
            progress.Dismiss();
        }
        public async Task sendToServer()
        {
            List <GSTINVerFiles1> imageList = new List <GSTINVerFiles1>();

            for (int i = 0; i < Utilities.imageList.Count; i++)
            {
                byte[] img = GetStreamFromFile(Utilities.imageList[i].ImagePath);
                var    url = await ic.UploadPhotoAsync(img, Utilities.imageList[i].ImagePath.Substring(Utilities.imageList[i].ImagePath.LastIndexOf("/") + 1));

                if (url != null)
                {
                    imageList.Add(new GSTINVerFiles1
                    {
                        VerFileName = url,
                        GeoLocation = geo.GetGeoLocation(Activity),
                    });
                }
            }

            GSTINModel model = new GSTINModel();

            model.GeoLocation           = geo.GetGeoLocation(Activity);
            model.GSTINID               = GSTIN;
            model.WentNotVerified       = "";
            model.AppDateTime           = DateTime.Now.ToString("yyyy-MM-dd");
            model.AddressStatus         = address;
            model.BusinessStatus        = businessStatus;
            model.RegistrationAccording = registration;
            model.Other = other;
            model.CompoundingEligible  = compoundingEligible;
            model.PremisesArea         = premisesArea;
            model.GSTINVerFiles        = imageList;
            model.ManufacturerOrTrader = combine;
            model.TurnOver             = turnOver;
            PackageManager manager = Activity.PackageManager;
            PackageInfo    info    = manager.GetPackageInfo(Activity.PackageName, 0);

            model.versionName = info.VersionName.ToString();

            string dt       = JsonConvert.SerializeObject(model);
            string response = "";

            try
            {
                response = await restService.PostServiceMethod(Activity, "SetGSTINCertification", dt);
            }catch (Exception ex)
            {
            }
            if (response.Contains("Success"))
            {
                Toast.MakeText(Activity, "Data Submitted Successfully.", ToastLength.Long).Show();
                GSTIN = "";
                rg1.ClearCheck();
                address = "";
                rg2.ClearCheck();
                businessStatus = "";
                rg3.ClearCheck();
                registration          = "";
                other                 = "";
                otherText.Text        = "";
                checkValidate.Checked = false;
                compoundingEligible   = "";
                premisesArea          = "";
                areaBusiness.Text     = "";
                turnoverText.Text     = "";
                Utilities.imageList.Clear();
                combine  = "";
                turnOver = "";
                submitDataVer.Enabled = true;
                Manufacturer.Checked  = false;
                Trader.Checked        = false;
                ServiceDealer.Checked = false;
                manuf  = "";
                trad   = "";
                dealer = "";
                grid_adapter.NotifyDataSetChanged();
                info.VersionName.ToString();
                Utilities.GlobalBusinessList.Clear();
                try
                {
                    int i = dba.insertGSTINData(geo.GetGeoLocation(Activity), GSTIN, "", DateTime.Now.ToString("yyyy-MM-dd"),
                                                address, businessStatus, registration, other, compoundingEligible, premisesArea,
                                                combine, turnOver, info.VersionName.ToString(), "yes");

                    for (int j = 0; j < imageList.Count; j++)
                    {
                        dba.insertImageDetail(i, imageList[j].VerFileName, geo.GetGeoLocation(Activity));
                    }
                }catch (Exception ex)
                {
                }
            }
            else
            {
                Toast.MakeText(Activity, "Something went wrong. Please try after sometime.", ToastLength.Long).Show();
                submitDataVer.Enabled = true;
                int i = dba.insertGSTINData(geo.GetGeoLocation(Activity), GSTIN, "", DateTime.Now.ToString("yyyy-MM-dd"),
                                            address, businessStatus, registration, other, compoundingEligible, premisesArea,
                                            combine, turnOver, info.VersionName.ToString(), "no");

                for (int j = 0; j < Utilities.imageList.Count; j++)
                {
                    dba.insertImageDetail(i, Utilities.imageList[j].ImagePath, geo.GetGeoLocation(Activity));
                }
            }
        }
Exemplo n.º 3
0
        private async System.Threading.Tasks.Task CreatetaskService()
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            //models = db.GetFullAttachmentData(task_id_to_send);

            for (int i = 0; i < listmapping2.Count; i++)
            {
                byte[] img  = GetStreamFromFile(listmapping2[i].localPath);
                var    url1 = await blob.UploadPhotoAsync(img, listmapping2[i].localPath.Substring(listmapping2[i].localPath.LastIndexOf("/") + 1));

                if (url1 != null)
                {
                    listmapping2[i].Path = url1;
                }
            }
            dynamic value = new ExpandoObject();

            value.task_name          = taskname;
            value.description        = taskdescri;
            value.deadline_date      = deadline;
            value.taskCreatethrough  = "mobile";
            value.markTo             = markto;
            value.lstTaskFileMapping = listmapping2;
            value.lstAddedCompliance = CreateTaskFrag.modelsaddcompliance;
            string json = JsonConvert.SerializeObject(value);

            try
            {
                string item = await restService.CreateTaskMethod(Activity, json, geolocation);

                if (item.Contains("Task Created successfully"))
                {
                    //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto, "yes");


                    //Toast.MakeText(Activity, "Task Assign Successfully..", ToastLength.Long).Show();
                    Toast.MakeText(Activity, "Task Assign Successfully...", ToastLength.Long).Show();
                    CreateTaskFrag.modelsaddcompliance.Clear();
                    progress.Dismiss();
                }
                else
                {
                    //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto,"yes",listmapping2);

                    tasknametext.Text    = null;
                    taskdescription.Text = null;

                    deadlinetext.Text = null;
                    markedontext.Text = null;

                    designationtext.Text = null;
                    nametext.Text        = null;

                    Toast.MakeText(Activity, "Task saved Successfully.. you have not internet connection", ToastLength.Long).Show();
                    progress.Dismiss();
                }
            }
            catch (Exception ex)
            {
                progress.Dismiss();
            }

            progress.Dismiss();
        }